| 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | //
|
|---|
| 27 | // $Id: G4VRML2SceneHandler.cc,v 1.12 2006/06/29 21:26:15 gunter Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $
|
|---|
| 29 | //
|
|---|
| 30 | // G4VRML2SceneHandler.cc
|
|---|
| 31 | // Satoshi Tanaka & Yasuhide Sawada
|
|---|
| 32 |
|
|---|
| 33 | #ifndef WIN32
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 | //=================//
|
|---|
| 37 | #ifdef G4VIS_BUILD_VRML_DRIVER
|
|---|
| 38 | //=================//
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 | //#define DEBUG_FR_SCENE
|
|---|
| 42 |
|
|---|
| 43 | #include <unistd.h>
|
|---|
| 44 | #include <fstream>
|
|---|
| 45 | #include <cmath>
|
|---|
| 46 |
|
|---|
| 47 | #include "globals.hh"
|
|---|
| 48 | #include "G4VPhysicalVolume.hh"
|
|---|
| 49 | #include "G4LogicalVolume.hh"
|
|---|
| 50 | #include "G4Point3D.hh"
|
|---|
| 51 | #include "G4VModel.hh"
|
|---|
| 52 | #include "G4Scene.hh"
|
|---|
| 53 | #include "G4VisAttributes.hh"
|
|---|
| 54 | #include "G4Polyhedron.hh"
|
|---|
| 55 | #include "G4Box.hh"
|
|---|
| 56 | #include "G4Cons.hh"
|
|---|
| 57 | #include "G4Polyline.hh"
|
|---|
| 58 | #include "G4Trd.hh"
|
|---|
| 59 | #include "G4Tubs.hh"
|
|---|
| 60 | #include "G4Text.hh"
|
|---|
| 61 | #include "G4Circle.hh"
|
|---|
| 62 | #include "G4Square.hh"
|
|---|
| 63 |
|
|---|
| 64 | #include "G4VRML2SceneHandler.hh"
|
|---|
| 65 | #include "G4VRML2Viewer.hh"
|
|---|
| 66 | #include "G4VRML2.hh"
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 | G4VRML2SceneHandler::G4VRML2SceneHandler(G4VRML2& system, const G4String& name) :
|
|---|
| 71 | G4VSceneHandler(system, fSceneIdCount++, name),
|
|---|
| 72 | fSystem(system),
|
|---|
| 73 | fPVPickable ( false ),
|
|---|
| 74 | fDest()
|
|---|
| 75 | {
|
|---|
| 76 |
|
|---|
| 77 | // PV name pickability
|
|---|
| 78 | if( getenv( "G4VRML_PV_PICKABLE" ) != NULL ) {
|
|---|
| 79 |
|
|---|
| 80 | int is_pickable ;
|
|---|
| 81 | sscanf( getenv("G4VRML_PV_PICKABLE"), "%d", &is_pickable ) ;
|
|---|
| 82 |
|
|---|
| 83 | if ( is_pickable ) { SetPVPickability ( true ) ; }
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | // PV Transparency
|
|---|
| 87 | SetPVTransparency ();
|
|---|
| 88 |
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 | G4VRML2SceneHandler::~G4VRML2SceneHandler()
|
|---|
| 93 | {
|
|---|
| 94 | #if defined DEBUG_FR_SCENE
|
|---|
| 95 | G4cerr << "***** ~G4VRML2SceneHandler" << G4endl;
|
|---|
| 96 | #endif
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 | #define G4VRML2SCENEHANDLER G4VRML2SceneHandler
|
|---|
| 102 | #define IS_CONNECTED fDest.isConnected()
|
|---|
| 103 | #include "G4VRML2SceneHandlerFunc.icc"
|
|---|
| 104 | #undef IS_CONNECTED
|
|---|
| 105 | #undef G4VRML2SCENEHANDLER
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 | void G4VRML2SceneHandler::connectPort(G4int max_trial)
|
|---|
| 109 | {
|
|---|
| 110 | G4int trial = 0 ;
|
|---|
| 111 | int port = fSystem.getPort();
|
|---|
| 112 | for (trial = 0; !fDest.isConnected()&& trial < max_trial; trial++, port++ ) {
|
|---|
| 113 | if (fDest.connect( (const char * )fSystem.getHostName(), port)) {
|
|---|
| 114 | // INET domain connection is established
|
|---|
| 115 | G4cerr << "*** GEANT4 is connected to port ";
|
|---|
| 116 | G4cerr << fDest.getPort();
|
|---|
| 117 | G4cerr << " of server " << fSystem.getHostName() << G4endl;
|
|---|
| 118 | break;
|
|---|
| 119 | } else {
|
|---|
| 120 | // Connection failed. Try the next port.
|
|---|
| 121 | G4cerr << "*** GEANT4 incremented targeting port to ";
|
|---|
| 122 | G4cerr << port << G4endl;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | sleep (1);
|
|---|
| 126 |
|
|---|
| 127 | } // for
|
|---|
| 128 |
|
|---|
| 129 | if (!fDest.isConnected()) {
|
|---|
| 130 | G4cerr << "*** INET Connection failed. " << G4endl;
|
|---|
| 131 | G4cerr << " Maybe, you have not invoked viewer g4vrmlview yet, " << G4endl;
|
|---|
| 132 | G4cerr << " or too many viewers are already running in the " << G4endl;
|
|---|
| 133 | G4cerr << " server host(" << fSystem.getHostName() << "). " << G4endl;
|
|---|
| 134 | }
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | void G4VRML2SceneHandler::closePort()
|
|---|
| 138 | {
|
|---|
| 139 | fDest.close();
|
|---|
| 140 | G4cerr << "*** INET Connection closed. " << G4endl;
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 | G4int G4VRML2SceneHandler::fSceneIdCount = 0;
|
|---|
| 145 |
|
|---|
| 146 | #endif
|
|---|
| 147 | #endif //WIN32
|
|---|