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.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/Vtk/src/G4VtkSceneHandler.cc (Version 11.3.0) and /visualization/Vtk/src/G4VtkSceneHandler.cc (Version 5.0)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 //                                                
 27 //                                                
 28 //                                                
 29 // John Allison  5th April 2001                   
 30 // A template for a simplest possible graphics    
 31 //?? Lines or sections marked like this requir    
 32                                                   
 33 #include "G4VtkSceneHandler.hh"                   
 34                                                   
 35 #include "G4Box.hh"                               
 36 #include "G4Circle.hh"                            
 37 #include "G4LogicalVolume.hh"                     
 38 #include "G4LogicalVolumeModel.hh"                
 39 #include "G4Material.hh"                          
 40 #include "G4Mesh.hh"                              
 41 #include "G4PhysicalVolumeModel.hh"               
 42 #include "G4Polyhedron.hh"                        
 43 #include "G4Polyline.hh"                          
 44 #include "G4PseudoScene.hh"                       
 45 #include "G4Square.hh"                            
 46 #include "G4SystemOfUnits.hh"                     
 47 #include "G4Text.hh"                              
 48 #include "G4UnitsTable.hh"                        
 49 #include "G4VNestedParameterisation.hh"           
 50 #include "G4VPhysicalVolume.hh"                   
 51 #include "G4VtkStore.hh"                          
 52 #include "G4VtkVisContext.hh"                     
 53                                                   
 54 #include <vtkColorTransferFunction.h>             
 55 #include <vtkContourValues.h>                     
 56 #include <vtkPiecewiseFunction.h>                 
 57 #include <vtkVolumeProperty.h>                    
 58                                                   
 59 #include <cstdlib>                                
 60                                                   
 61 G4int G4VtkSceneHandler::fSceneIdCount = 0;       
 62 // Counter for XXX scene handlers.                
 63                                                   
 64 G4VtkSceneHandler::G4VtkSceneHandler(G4VGraphi    
 65   : G4VSceneHandler(system, fSceneIdCount++, n    
 66 {}                                                
 67                                                   
 68 void G4VtkSceneHandler::AddPrimitive(const G4P    
 69 {                                                 
 70 #ifdef G4VTKDEBUG                                 
 71   G4cout << "G4VtkSceneHandler::AddPrimitive(c    
 72 #endif                                            
 73   auto vc = MakeDefaultVisContext();              
 74                                                   
 75   if (fReadyForTransients)                        
 76     transientStore.AddPrimitive(polyline, vc);    
 77   else                                            
 78     store.AddPrimitive(polyline, vc);             
 79 }                                                 
 80                                                   
 81 void G4VtkSceneHandler::AddPrimitive(const G4T    
 82 {                                                 
 83 #ifdef G4VTKDEBUG                                 
 84   G4cout << "G4VtkSceneHandler::AddPrimitive(c    
 85 #endif                                            
 86                                                   
 87   auto vc = MakeDefaultVisContext();              
 88                                                   
 89   if (fReadyForTransients)                        
 90     transientStore.AddPrimitive(text, vc);        
 91   else                                            
 92     store.AddPrimitive(text, vc);                 
 93 }                                                 
 94                                                   
 95 void G4VtkSceneHandler::AddPrimitive(const G4C    
 96 {                                                 
 97 #ifdef G4VTKDEBUG                                 
 98   G4cout << "G4VtkSceneHandler::AddPrimitive(c    
 99 #endif                                            
100                                                   
101   auto vc = MakeDefaultVisContext();              
102   G4VSceneHandler::MarkerSizeType sizeType;       
103   vc.fSize = GetMarkerSize(circle, sizeType);     
104                                                   
105   if (fReadyForTransients)                        
106     transientStore.AddPrimitive(circle, vc);      
107   else                                            
108     store.AddPrimitive(circle, vc);               
109 }                                                 
110                                                   
111 void G4VtkSceneHandler::AddPrimitive(const G4S    
112 {                                                 
113 #ifdef G4VTKDEBUG                                 
114   G4cout << "G4VtkSceneHandler::AddPrimitive(c    
115 #endif                                            
116                                                   
117   auto vc = MakeDefaultVisContext();              
118   G4VSceneHandler::MarkerSizeType sizeType;       
119   vc.fSize = GetMarkerSize(square, sizeType);     
120                                                   
121   if (fReadyForTransients)                        
122     transientStore.AddPrimitive(square, vc);      
123   else                                            
124     store.AddPrimitive(square, vc);               
125 }                                                 
126                                                   
127 void G4VtkSceneHandler::AddPrimitive(const G4P    
128 {                                                 
129 #ifdef G4VTKDEBUG                                 
130   G4cout << "G4VtkSceneHandler::AddPrimitive(c    
131 #endif                                            
132                                                   
133   auto vc = MakeDefaultVisContext();              
134   auto visAtt = vc.fViewer->GetApplicableVisAt    
135   auto colour = visAtt->GetColour();              
136                                                   
137   vc.fDrawingStyle = GetDrawingStyle(visAtt);     
138   vc.alpha = colour.GetAlpha();                   
139   vc.red = colour.GetRed();                       
140   vc.green = colour.GetGreen();                   
141   vc.blue = colour.GetBlue();                     
142                                                   
143   auto pPVModel = dynamic_cast<G4PhysicalVolum    
144   if (pPVModel != nullptr) {                      
145     vc.fDepth = pPVModel->GetCurrentDepth();      
146     vc.fDescription = pPVModel->GetCurrentDesc    
147   }                                               
148                                                   
149   if (fReadyForTransients) {                      
150     if (polyhedronPipelineType == "tensor")       
151       transientStore.AddPrimitiveTensorGlyph(p    
152     else if (polyhedronPipelineType == "append    
153       transientStore.AddPrimitiveAppend(polyhe    
154     else if (polyhedronPipelineType == "bake")    
155       transientStore.AddPrimitiveTransformBake    
156     else if (polyhedronPipelineType == "separa    
157       transientStore.AddPrimitiveSeparate(poly    
158   }                                               
159   else {                                          
160     if (polyhedronPipelineType == "tensor")       
161       store.AddPrimitiveTensorGlyph(polyhedron    
162     else if (polyhedronPipelineType == "append    
163       store.AddPrimitiveAppend(polyhedron, vc)    
164     else if (polyhedronPipelineType == "bake")    
165       store.AddPrimitiveTransformBake(polyhedr    
166     else if (polyhedronPipelineType == "separa    
167       store.AddPrimitiveSeparate(polyhedron, v    
168   }                                               
169 }                                                 
170                                                   
171 void G4VtkSceneHandler::Modified()                
172 {                                                 
173 #ifdef G4VTKDEBUG                                 
174   G4cout << "G4VtkSceneHandler::Modified()" <<    
175 #endif                                            
176                                                   
177   store.Modified();                               
178   transientStore.Modified();                      
179 }                                                 
180                                                   
181 void G4VtkSceneHandler::ClearStore()              
182 {                                                 
183 #ifdef G4VTKDEBUG                                 
184   G4cout << "G4VtkSceneHandler::ClearStore()"     
185 #endif                                            
186   store.Clear();                                  
187 }                                                 
188                                                   
189 void G4VtkSceneHandler::ClearTransientStore()     
190 {                                                 
191 #ifdef G4VTKDEBUG                                 
192   G4cout << "G4VtkSceneHandler::ClearTransient    
193 #endif                                            
194   transientStore.Clear();                         
195 }                                                 
196                                                   
197 G4VtkVisContext G4VtkSceneHandler::MakeDefault    
198 {                                                 
199   auto vc = G4VtkVisContext(dynamic_cast<G4Vtk    
200                             fObjectTransformat    
201                                                   
202   if (fpVisAttribs != nullptr) {                  
203     G4Colour c = fpVisAttribs->GetColour();       
204     vc.red = c.GetRed();                          
205     vc.green = c.GetGreen();                      
206     vc.blue = c.GetBlue();                        
207     vc.alpha = c.GetAlpha();                      
208     vc.fDrawingStyle = fpViewer->GetViewParame    
209   }                                               
210                                                   
211   return vc;                                      
212 }                                                 
213                                                   
214 void G4VtkSceneHandler::AddSolid(const G4Box&     
215 {                                                 
216   G4VSceneHandler::AddSolid(box);                 
217                                                   
218   return;                                         
219                                                   
220   const G4VModel* pv_model = GetModel();          
221   if (pv_model == nullptr) {                      
222     return;                                       
223   }                                               
224                                                   
225   auto pPVModel = dynamic_cast<G4PhysicalVolum    
226   if (pPVModel == nullptr) {                      
227     return;                                       
228   }                                               
229                                                   
230   //-- debug information                          
231 #ifdef G4VTKDEBUG                                 
232   G4VPhysicalVolume* pv = pPVModel->GetCurrent    
233   G4LogicalVolume* lv = pv->GetLogicalVolume()    
234   G4cout << "name=" << box.GetName() << " volu    
235          << " pvName=" << pv->GetName() << " l    
236          << " multiplicity=" << pv->GetMultipl    
237          << " isreplicated=" << pv->IsReplicat    
238          << " parametrisation=" << pv->GetPara    
239          << G4endl                                
240                                                   
241               G4Material* mat = pPVModel->GetC    
242   G4String name = mat->GetName();                 
243   G4double dens = mat->GetDensity() / (g / cm3    
244   G4int copyNo = pPVModel->GetCurrentPV()->Get    
245   G4int depth = pPVModel->GetCurrentDepth();      
246   G4cout << "    name    : " << box.GetName()     
247   G4cout << "    copy no.: " << copyNo << G4en    
248   G4cout << "    depth   : " << depth << G4end    
249   G4cout << "    density : " << dens << " [g/c    
250   G4cout << "    location: " << pPVModel->GetC    
251   G4cout << "    Multiplicity        : " << pP    
252   G4cout << "    Is replicated?      : " << pP    
253   G4cout << "    Is parameterised?   : " << pP    
254   G4cout << "    top phys. vol. name : " << pP    
255 #endif                                            
256 }                                                 
257                                                   
258 void G4VtkSceneHandler::AddCompound(const G4Me    
259 {                                                 
260 #ifdef G4VTKDEBUG                                 
261   G4cout << "G4VtkSceneHandler::AddCompound> m    
262          << fpViewer->GetViewParameters().GetS    
263 #endif                                            
264                                                   
265   if(fpViewer->GetViewParameters().GetSpecialM    
266   {                                               
267     auto vc = MakeDefaultVisContext();            
268                                                   
269     if (fReadyForTransients)                      
270       transientStore.AddCompound(mesh, vc);       
271     else                                          
272       store.AddCompound(mesh, vc);                
273   }                                               
274   else {                                          
275     StandardSpecialMeshRendering(mesh);           
276   }                                               
277 }                                                 
278                                                   
279 void G4VtkSceneHandler::Print() {}                
280                                                   
281 void G4VtkSceneHandler::SetPolyhedronPipeline(    
282 {                                                 
283   polyhedronPipelineType = type;                  
284 }                                                 
285