39 #include <Interface_Static.hxx>
40 #include <BRepBuilderAPI_Transform.hxx>
41 #include <TDataStd_Name.hxx>
42 #include <XCAFDoc_DocumentTool.hxx>
43 #include <Standard.hxx>
45 #include <XCAFApp_Application.hxx>
61 Handle (XCAFApp_Application)
A = XCAFApp_Application::GetApplication();
63 A->NewDocument (
"MDTV-XCAF", fDoc);
66 ::Error(
"TOCCToStep::OCCDocCreation",
"creating OCC application");
74 TDF_Label motherLabel;
82 fLabel = XCAFDoc_DocumentTool::ShapeTool(fDoc->Main())->NewShape();
84 XCAFDoc_DocumentTool::ShapeTool(fDoc->Main())->SetShape(fLabel, fShape);
86 XCAFDoc_DocumentTool::ShapeTool(fDoc->Main())->UpdateAssembly(fDoc->Main());
90 if (GetLabelOfVolume(currentVolume).IsNull()) {
92 if ((GetLabelOfVolume(currentVolume).IsNull())) {
96 fShape = fRootShape.OCC_SimpleShape(currentVolume->
GetShape());
101 while ((current = nextNode())) {
102 if ((current->
GetVolume() == currentVolume) && (GetLabelOfVolume(current->
GetVolume()).IsNull())) {
104 nextNode.GetPath(path);
108 TGeoNode * mother = nextNode.GetNode(--level);
111 motherLabel = GetLabelOfVolume(motherVol);
112 if (!motherLabel.IsNull()) {
113 fLabel = TDF_TagSource::NewChild(motherLabel);
116 TGeoNode * grandMother = nextNode.GetNode(level);
118 TopoDS_Shape Mothershape;
122 Mothershape = fRootShape.OCC_SimpleShape(motherVol->
GetShape());
124 motherLabel = TDF_TagSource::NewChild(GetLabelOfVolume(Top));
125 XCAFDoc_DocumentTool::ShapeTool(fDoc->Main())->SetShape(motherLabel, Mothershape);
126 TDataStd_Name::Set(motherLabel, motherVol->
GetName());
127 XCAFDoc_DocumentTool::ShapeTool(fDoc->Main())->UpdateAssembly(fDoc->Main());
128 fTree[motherVol] = motherLabel;
129 fLabel = TDF_TagSource::NewChild(motherLabel);
134 XCAFDoc_DocumentTool::ShapeTool(fDoc->Main())->SetShape(fLabel, fShape);
135 TDataStd_Name::Set(fLabel, currentVolume->
GetName());
136 XCAFDoc_DocumentTool::ShapeTool(fDoc->Main())->UpdateAssembly(fDoc->Main());
137 fTree[currentVolume] = fLabel;
147 STEPControl_StepModelType mode = STEPControl_AsIs;
148 fWriter.SetNameMode(Standard_True);
149 if (!Interface_Static::SetIVal(
"write.step.assembly", 1)) {
150 Error(
"TOCCToStep::OCCWriteStep",
"failed to set assembly mode for step data");
152 if (!fWriter.Transfer(fDoc, mode)) {
153 ::Error(
"TOCCToStep::OCCWriteStep",
"error translating document");
155 fWriter.Write(fname);
163 if (fTree.find(v) != fTree.end())
173 map <TGeoVolume *,TDF_Label>::iterator it;
174 for(it = fTree.begin(); it != fTree.end(); it++)
175 if (it->second.IsEqual(fLabel))
184 XCAFDoc_DocumentTool::ShapeTool(mother)->AddComponent(mother, child,loc);
185 XCAFDoc_DocumentTool::ShapeTool(mother)->UpdateAssembly(mother);
193 TopLoc_Location locA;
196 TR1.SetTranslation(gp_Vec(t[0],t[1],t[2]));
197 TR.SetValues(r[0],r[1],r[2],0,
200 #
if OCC_VERSION_MAJOR == 6 && OCC_VERSION_MINOR < 8
205 locA = TopLoc_Location (TR1);
218 TDF_Label labelMother;
222 while ((currentNode = nextNode())) {
223 level = nextNode.GetLevel();
226 for (
int i = level; i > 0; i--) {
230 motherNode = nextNode.GetNode(--level);
231 labelMother = GetLabelOfVolume(motherNode->
GetVolume());
233 fLabel = GetLabelOfVolume(currentNode->GetVolume());
234 loc = CalcLocation((*(currentNode->GetMatrix())));
235 if ((XCAFDoc_DocumentTool::ShapeTool(fDoc->Main())->NbComponents(labelMother) < ndMother) && (!nd)) {
236 AddChildLabel(labelMother, fLabel, loc);
237 }
else if ((XCAFDoc_DocumentTool::ShapeTool(fDoc->Main())->NbComponents(fLabel) == nd) && (XCAFDoc_DocumentTool::ShapeTool(fDoc->Main())->NbComponents(labelMother) == motherNode->
GetVolume()->
GetIndex(currentNode))) {
238 AddChildLabel(labelMother, fLabel, loc);
240 currentNode = motherNode;
241 fLabel = labelMother;
252 #if OCC_VERSION_MAJOR == 6 && OCC_VERSION_MINOR < 8
253 XCAFDoc_DocumentTool::ShapeTool(fDoc->Main())->Dump();
255 XCAFDoc_DocumentTool::ShapeTool(fDoc->Main())->Dump(std::cout);
TGeoVolume * GetVolume() const
void OCCWriteStep(const char *fname)
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
void AddChildLabel(TDF_Label mother, TDF_Label child, TopLoc_Location loc)
TGeoVolume * GetVolumeOfLabel(TDF_Label fLabel)
Int_t GetNdaughters() const
TGeoNode * GetTopNode() const
virtual const Double_t * GetRotationMatrix() const
void OCCTreeCreation(TGeoManager *m)
TGeoVolume * GetTopVolume() const
void Error(const char *location, const char *msgfmt,...)
TObjArray * GetListOfVolumes() const
Int_t GetIndex(const TGeoNode *node) const
get index number for a given daughter
virtual const char * GetName() const
Returns name of object.
TopLoc_Location CalcLocation(TGeoHMatrix matrix)
TGeoShape * GetShape() const
TDF_Label OCCShapeCreation(TGeoManager *m)
Logical fTree creation.
TDF_Label GetLabelOfVolume(TGeoVolume *v)
virtual const Double_t * GetTranslation() const
Int_t GetNdaughters() const