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: G4VRML1SceneHandler.cc,v 1.10 2006/06/29 21:26:01 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: $ |
---|
29 | // |
---|
30 | // G4VRML1SceneHandler.cc |
---|
31 | // Yasuhide Sawada and Satoshi Tanaka |
---|
32 | |
---|
33 | #ifndef WIN32 |
---|
34 | |
---|
35 | //=================// |
---|
36 | #ifdef G4VIS_BUILD_VRML_DRIVER |
---|
37 | //=================// |
---|
38 | |
---|
39 | |
---|
40 | //#define DEBUG_FR_SCENE |
---|
41 | |
---|
42 | #include <unistd.h> |
---|
43 | #include <fstream> |
---|
44 | |
---|
45 | #include "globals.hh" |
---|
46 | #include "G4VPhysicalVolume.hh" |
---|
47 | #include "G4LogicalVolume.hh" |
---|
48 | #include "G4Point3D.hh" |
---|
49 | #include "G4Scene.hh" |
---|
50 | #include "G4VisAttributes.hh" |
---|
51 | #include "G4Polyhedron.hh" |
---|
52 | #include "G4Box.hh" |
---|
53 | #include "G4Cons.hh" |
---|
54 | #include "G4Polyline.hh" |
---|
55 | #include "G4Trd.hh" |
---|
56 | #include "G4Tubs.hh" |
---|
57 | #include "G4Trap.hh" |
---|
58 | #include "G4Para.hh" |
---|
59 | #include "G4Torus.hh" |
---|
60 | #include "G4Sphere.hh" |
---|
61 | #include "G4Text.hh" |
---|
62 | #include "G4Circle.hh" |
---|
63 | #include "G4Square.hh" |
---|
64 | |
---|
65 | #include "G4VRML1SceneHandler.hh" |
---|
66 | #include "G4VRML1Viewer.hh" |
---|
67 | #include "G4VRML1.hh" |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | G4VRML1SceneHandler::G4VRML1SceneHandler(G4VRML1& system, const G4String& name) : |
---|
72 | G4VSceneHandler(system, fSceneIdCount++, name), |
---|
73 | fSystem(system), |
---|
74 | fDest() |
---|
75 | { |
---|
76 | fCurrentDEF = ""; |
---|
77 | } |
---|
78 | |
---|
79 | |
---|
80 | G4VRML1SceneHandler::~G4VRML1SceneHandler() |
---|
81 | { |
---|
82 | #if defined DEBUG_FR_SCENE |
---|
83 | G4cerr << "***** ~G4VRML1SceneHandler" << G4endl; |
---|
84 | #endif |
---|
85 | } |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | #define G4VRML1SCENEHANDLER G4VRML1SceneHandler |
---|
90 | #define IS_CONNECTED fDest.isConnected() |
---|
91 | #include "G4VRML1SceneHandlerFunc.icc" |
---|
92 | #undef IS_CONNECTED |
---|
93 | #undef G4VRML1SCENEHANDLER |
---|
94 | |
---|
95 | |
---|
96 | void G4VRML1SceneHandler::connectPort(G4int max_trial) |
---|
97 | { |
---|
98 | G4int trial = 0 ; |
---|
99 | int port = fSystem.getPort(); |
---|
100 | for (trial = 0; !fDest.isConnected()&& trial < max_trial; trial++, port++ ) { |
---|
101 | if (fDest.connect( (const char * )fSystem.getHostName(), port)) { |
---|
102 | // INET domain connection is established |
---|
103 | G4cerr << "*** GEANT4 is connected to port "; |
---|
104 | G4cerr << fDest.getPort(); |
---|
105 | G4cerr << " of server " << fSystem.getHostName() << G4endl; |
---|
106 | break; |
---|
107 | } else { |
---|
108 | // Connection failed. Try the next port. |
---|
109 | G4cerr << "*** GEANT4 incremented targeting port to "; |
---|
110 | G4cerr << port << G4endl; |
---|
111 | } |
---|
112 | |
---|
113 | sleep (1); |
---|
114 | |
---|
115 | } // for |
---|
116 | |
---|
117 | if (!fDest.isConnected()) { |
---|
118 | G4cerr << "*** INET Connection failed. " << G4endl; |
---|
119 | G4cerr << " Maybe, you have not invoked viewer g4vrmlview yet, " << G4endl; |
---|
120 | G4cerr << " or too many viewers are already running in the " << G4endl; |
---|
121 | G4cerr << " server host(" << fSystem.getHostName() << "). " << G4endl; |
---|
122 | } |
---|
123 | } |
---|
124 | |
---|
125 | void G4VRML1SceneHandler::closePort() |
---|
126 | { |
---|
127 | fDest.close(); |
---|
128 | G4cerr << "*** INET Connection closed. " << G4endl; |
---|
129 | } |
---|
130 | |
---|
131 | |
---|
132 | G4int G4VRML1SceneHandler::fSceneIdCount = 0; |
---|
133 | |
---|
134 | #endif |
---|
135 | #endif |
---|