Logo ROOT   6.16/01
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
15This class is an interface to convert ROOT's geometry file
16to STEP file. The TGeoToStep Class takes a gGeoManager pointer and gives
17back a STEP file. gGeoManager is the instance of TGeoManager class
18containing tree of geometries creating resulting geometry.
19Standard for the Exchange of Product model data (STEP) is an international
20standard for the exchange of industrial product data. It is typically used
21to exchange data between various CAD, CAM and CAE applications.
22TGeoToStep Class is using RootOCC class to translate the root geometry
23in the corresponding OpenCascade geometry and and TOCCToStep to write the
24OpenCascade geometry to the step File.
25OpenCascade Technology (OCC) is a software development platform freely
26available in open source. It includes C++ components for 3D surface and
27solid modeling,visualization, data exchange and rapid application
28development. For more information about OCC see http://www.opencascade.org
29Each object in ROOT is represented by an OCC TopoDS_Shape
30
31This class is needed to be instantiated and can be used calling the
32CreateGeometry method:
33
34~~~ {.cpp}
35 TGeoToStep * mygeom= new TGeoToStep(gGeoManager);
36 mygeom->CreateGeometry("output_geometry.stp",3);
37~~~
38
39The resulting STEP file will be saved in the current directory and called
40output_geometry.stp and will have converted all the nodes up to and
41including level 3.
42To 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
70void TGeoToStep::CreateGeometry(const char* fname, int max_level)
71{
72 //ROOT CAD CONVERSION
73 fCreate = new TOCCToStep();
76 fCreate->OCCWriteStep(fname);
77 //fCreate->PrintAssembly();
78 delete(fCreate);
79}
80
81void 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
99void 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
#define ClassImp(name)
Definition: Rtypes.h:363
The manager class for any TGeo geometry.
Definition: TGeoManager.h:39
This class is an interface to convert ROOT's geometry file to STEP file.
Definition: TGeoToStep.h:24
TGeoManager * fGeometry
Definition: TGeoToStep.h:27
void CreateGeometry(const char *fname="geometry.stp", int max_level=-1)
Definition: TGeoToStep.cxx:70
void CreatePartialGeometry(const char *part_name, int max_level=-1, const char *fname="geometry.stp")
Definition: TGeoToStep.cxx:81
TOCCToStep * fCreate
Definition: TGeoToStep.h:28
This class contains implementation of writing OpenCascade's geometry shapes to the STEP file reproduc...
Definition: TOCCToStep.h:27
bool OCCPartialTreeCreation(TGeoManager *m, const char *node_name, int max_level=-1)
Definition: TOCCToStep.cxx:255
void OCCWriteStep(const char *fname)
Definition: TOCCToStep.cxx:142
TDF_Label OCCShapeCreation(TGeoManager *m)
Logical fTree creation.
Definition: TOCCToStep.cxx:71
void OCCTreeCreation(TGeoManager *m, int max_level=-1)
Definition: TOCCToStep.cxx:208
Mother of all ROOT objects.
Definition: TObject.h:37