G4VRML1SceneHandler.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // G4VRML1SceneHandler.cc
00030 // Yasuhide Sawada and Satoshi Tanaka
00031 
00032 #ifndef WIN32
00033 
00034 //=================//
00035 #ifdef G4VIS_BUILD_VRML_DRIVER
00036 //=================//
00037 
00038 
00039 //#define DEBUG_FR_SCENE
00040 
00041 #include <unistd.h>
00042 #include <fstream>
00043 
00044 #include "globals.hh"
00045 #include "G4VisManager.hh"
00046 #include "G4VPhysicalVolume.hh"
00047 #include "G4LogicalVolume.hh"
00048 #include "G4Point3D.hh"
00049 #include "G4Scene.hh"
00050 #include "G4VisAttributes.hh"
00051 #include "G4Polyhedron.hh"
00052 #include "G4Box.hh"
00053 #include "G4Cons.hh"
00054 #include "G4Polyline.hh"
00055 #include "G4Trd.hh"
00056 #include "G4Tubs.hh"
00057 #include "G4Trap.hh"
00058 #include "G4Para.hh"
00059 #include "G4Torus.hh"
00060 #include "G4Sphere.hh"
00061 #include "G4Text.hh"
00062 #include "G4Circle.hh"
00063 #include "G4Square.hh"
00064 
00065 #include "G4VRML1SceneHandler.hh"
00066 #include "G4VRML1Viewer.hh"
00067 #include "G4VRML1.hh"
00068 
00069 
00070 
00071 G4VRML1SceneHandler::G4VRML1SceneHandler(G4VRML1& system, const G4String& name) :
00072         G4VSceneHandler(system, fSceneIdCount++, name),
00073         fSystem(system),
00074         fDest()
00075 {
00076         fCurrentDEF = "";
00077 }
00078 
00079 
00080 G4VRML1SceneHandler::~G4VRML1SceneHandler()
00081 {
00082 #if defined DEBUG_FR_SCENE
00083   if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00084         G4cout << "***** ~G4VRML1SceneHandler" << G4endl;
00085 #endif 
00086 }
00087 
00088 
00089 
00090 #define  G4VRML1SCENEHANDLER  G4VRML1SceneHandler
00091 #define  IS_CONNECTED  fDest.isConnected() 
00092 #include "G4VRML1SceneHandlerFunc.icc"
00093 #undef   IS_CONNECTED
00094 #undef   G4VRML1SCENEHANDLER
00095 
00096 
00097 void G4VRML1SceneHandler::connectPort(G4int max_trial)
00098 {
00099         G4int trial = 0 ;
00100         int port = fSystem.getPort();
00101         for (trial = 0; !fDest.isConnected()&& trial < max_trial; trial++, port++ ) {
00102                 if (fDest.connect( (const char * )fSystem.getHostName(), port)) {
00103                     // INET domain connection is established
00104                   if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
00105                         G4cout << "*** GEANT4 is connected to port  ";
00106                         G4cout << fDest.getPort(); 
00107                         G4cout << " of server  " << fSystem.getHostName() << G4endl;
00108                   }
00109                         break; 
00110                 } else { 
00111                         // Connection failed. Try the next port.
00112                   if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
00113                         G4cout << "*** GEANT4 incremented targeting port to ";
00114                         G4cout << port << G4endl;
00115                   }
00116                 }
00117 
00118                 sleep (1);
00119 
00120         } // for
00121 
00122         if (!fDest.isConnected()) {
00123           if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
00124                 G4cout << "*** INET Connection failed. " << G4endl;
00125                 G4cout << "    Maybe, you have not invoked viewer  g4vrmlview  yet, " << G4endl;
00126                 G4cout << "    or too many viewers are already running in the " << G4endl;
00127                 G4cout << "    server host(" << fSystem.getHostName() << "). " << G4endl;
00128           }
00129         }
00130 }
00131 
00132 void G4VRML1SceneHandler::closePort()
00133 {
00134         fDest.close();
00135         if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00136               G4cout << "*** INET Connection closed. " << G4endl;
00137 }
00138 
00139 
00140 G4int G4VRML1SceneHandler::fSceneIdCount = 0;
00141 
00142 #endif
00143 #endif

Generated on Mon May 27 17:50:21 2013 for Geant4 by  doxygen 1.4.7