Logo ROOT   6.14/05
Reference Guide
TGeoToStep.cxx
Go to the documentation of this file.
1 // @(#)geom/geocad:$Id$
2 // Author: Cinzia Luzzi 5/5/2012
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2012, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \class TGeoToStep
13 \ingroup Geometry_cad
14 
15 This class is an interface to convert ROOT's geometry file
16 to STEP file. The TGeoToStep Class takes a gGeoManager pointer and gives
17 back a STEP file. gGeoManager is the instance of TGeoManager class
18 containing tree of geometries creating resulting geometry.
19 Standard for the Exchange of Product model data (STEP) is an international
20 standard for the exchange of industrial product data. It is typically used
21 to exchange data between various CAD, CAM and CAE applications.
22 TGeoToStep Class is using RootOCC class to translate the root geometry
23 in the corresponding OpenCascade geometry and and TOCCToStep to write the
24 OpenCascade geometry to the step File.
25 OpenCascade Technology (OCC) is a software development platform freely
26 available in open source. It includes C++ components for 3D surface and
27 solid modeling,visualization, data exchange and rapid application
28 development. For more information about OCC see http://www.opencascade.org
29 Each object in ROOT is represented by an OCC TopoDS_Shape
30 
31 This class is needed to be instantiated and can be used calling the
32 CreateGeometry method:
33 
34 ~~~ {.cpp}
35  TGeoToStep * mygeom= new TGeoToStep(gGeoManager);
36  mygeom->CreateGeometry("output_geometry.stp",3);
37 ~~~
38 
39 The resulting STEP file will be saved in the current directory and called
40 output_geometry.stp and will have converted all the nodes up to and
41 including level 3.
42 To compile the TGeoCad module on ROOT, OpenCascade must be installed!
43 */
44 
45 #include "TGeoManager.h"
46 #include "TOCCToStep.h"
47 #include "TGeoToStep.h"
48 #include "TString.h"
49 #include "TClass.h"
50 #include <string>
51 #include <map>
52 
54 
56 {
57 
58 }
59 
61 {
62 
63 }
64 
66 {
67  if (fGeometry) delete fGeometry;
68 }
69 
70 void TGeoToStep::CreateGeometry(const char* fname, int max_level)
71 {
72  //ROOT CAD CONVERSION
73  fCreate = new TOCCToStep();
75  fCreate->OCCTreeCreation(fGeometry, max_level);
76  fCreate->OCCWriteStep(fname);
77  //fCreate->PrintAssembly();
78  delete(fCreate);
79 }
80 
81 void TGeoToStep::CreatePartialGeometry(const char* part_name, int max_level, const char* fname)
82 {
83  //ROOT CAD CONVERSION
84  fCreate = new TOCCToStep();
86  if( !(fCreate->OCCPartialTreeCreation(fGeometry, part_name, max_level)) ) {
87  // std::cout << " Part: " << part_name << ", max_level = " << max_level;
88  // std::cout << ", Found.\n";
89  //} else {
90  std::cout << " Part: " << part_name << ", max_level = " << max_level;
91  std::cout << ", NOT FOUND!\n";
92  }
93  fCreate->OCCWriteStep(fname);
94  //fCreate->PrintAssembly();
95  delete(fCreate);
96 }
97 
98 
99 void TGeoToStep::CreatePartialGeometry(std::map<std::string,int> part_name_levels, const char* fname)
100 {
101  //ROOT CAD CONVERSION
102  fCreate = new TOCCToStep();
104  if( !(fCreate->OCCPartialTreeCreation(fGeometry, part_name_levels)) ) {
105  // std::cout << " At least one part found.\n";
106  //} else {
107  std::cout << " NO PARTS FOUND!\n";
108  }
109  fCreate->OCCWriteStep(fname);
110  //fCreate->PrintAssembly();
111  delete(fCreate);
112 }
113 
114 
void CreateGeometry(const char *fname="geometry.stp", int max_level=-1)
Definition: TGeoToStep.cxx:70
The manager class for any TGeo geometry.
Definition: TGeoManager.h:38
void OCCWriteStep(const char *fname)
Definition: TOCCToStep.cxx:144
TGeoManager * fGeometry
Definition: TGeoToStep.h:27
void CreatePartialGeometry(const char *part_name, int max_level=-1, const char *fname="geometry.stp")
Definition: TGeoToStep.cxx:81
This class contains implementation of writing OpenCascade&#39;s geometry shapes to the STEP file reproduc...
Definition: TOCCToStep.h:27
#define ClassImp(name)
Definition: Rtypes.h:359
void OCCTreeCreation(TGeoManager *m, int max_level=-1)
Definition: TOCCToStep.cxx:210
TDF_Label OCCShapeCreation(TGeoManager *m)
Logical fTree creation.
Definition: TOCCToStep.cxx:71
Mother of all ROOT objects.
Definition: TObject.h:37
bool OCCPartialTreeCreation(TGeoManager *m, const char *node_name, int max_level=-1)
Definition: TOCCToStep.cxx:257
TOCCToStep * fCreate
Definition: TGeoToStep.h:28
This class is an interface to convert ROOT&#39;s geometry file to STEP file.
Definition: TGeoToStep.h:24