// File: TNaming_Selector.cxx // Created: Thu Sep 30 15:07:20 1999 // Author: Denis PASCAL // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define BUC60862 #define OCC273 #define OCC351 //#define MDTV_DEB_SEL #ifdef MDTV_DEB_SEL //#define MDTV_DEB_BNP #include #include #include #include #include #include void PrintEntry(const TDF_Label& label, const Standard_Boolean allLevels) { TCollection_AsciiString entry; TDF_Tool::Entry(label, entry); cout << "LabelEntry = "<< entry << endl; if(allLevels) { TDF_ChildIterator it (label, allLevels); for (; it.More(); it.Next()) { TDF_Tool::Entry(it.Value(), entry); cout << "ChildLabelEntry = "<< entry << endl; } } } #include static void Write(const TopoDS_Shape& shape, const Standard_CString filename) { char buf[256]; if(strlen(filename) > 255) return; #if defined WNT strcpy_s (buf, filename); #else strcpy (buf, filename); #endif char* p = buf; while (*p) { if(*p == ':') *p = '-'; p++; } ofstream save (buf); if(!save) cout << "File " << buf << " was not created: rdstate = " << save.rdstate() << endl; save << "DBRep_DrawableShape" << endl << endl; if(!shape.IsNull()) BRepTools::Write(shape, save); save.close(); } #endif #define ORIENTATION_DSOPT #ifdef ORIENTATION_DSOPT #include #include #include #include #include #include //========================================================================================== inline static void MapOfOrientedShapes(const TopoDS_Shape& S, TopTools_MapOfOrientedShape& M) { M.Add(S); TopoDS_Iterator It(S,Standard_True,Standard_True); while (It.More()) { MapOfOrientedShapes(It.Value(),M); It.Next(); } } //======================================================================= static void BuildAtomicMap(const TopoDS_Shape& S, TopTools_MapOfOrientedShape& M) { if(S.ShapeType() > TopAbs_COMPSOLID) return; TopoDS_Iterator it(S); for(;it.More();it.Next()) { if(it.Value().ShapeType() > TopAbs_COMPSOLID) M.Add(it.Value()); else BuildAtomicMap(it.Value(), M); } } //========================================================================================== static const Handle(TNaming_NamedShape) FindPrevNDS(const Handle(TNaming_NamedShape)& CNS) { Handle(TNaming_NamedShape) aNS; TNaming_Iterator it(CNS); if(it.More()) { if(!it.OldShape().IsNull()) { aNS = TNaming_Tool::NamedShape(it.OldShape(), CNS->Label()); return aNS; } } return aNS; } //========================================================================================== // Purpose: checks correspondens between orientation of sub-shapes of Context and orientation // of sub-shapes registered in DF and put under result label //========================================================================================== static Standard_Boolean IsSpecificCase(const TDF_Label& F, const TopoDS_Shape& Context) { Standard_Boolean isFound(Standard_False); TopTools_MapOfOrientedShape shapesOfContext; MapOfOrientedShapes(Context,shapesOfContext); Handle(TNaming_NamedShape) CNS = TNaming_Tool::NamedShape(Context, F); #ifdef MDTV_DEB_BNP PrintEntry (CNS->Label(),0); #endif if(!CNS.IsNull()) { TNaming_ListOfNamedShape aLNS; TDF_ChildIDIterator cit(CNS->Label(), TNaming_NamedShape::GetID(), Standard_False); if(!cit.More()) { // Naming data structure is empty - no sub-shapes under resulting shape const Handle(TNaming_NamedShape) aNS = FindPrevNDS(CNS); //look to old shape data structure if exist if(!aNS.IsNull()) { #ifdef MDTV_DEB_BNP PrintEntry (aNS->Label(),0); #endif cit.Initialize(aNS->Label(), TNaming_NamedShape::GetID(), Standard_False); } else return Standard_True; } for(;cit.More();cit.Next()) { const Handle(TNaming_NamedShape)& NS = Handle(TNaming_NamedShape)::DownCast(cit.Value()); if(!NS.IsNull()) { TopoDS_Shape aS = TNaming_Tool::CurrentShape(NS); if(aS.IsNull()) continue; #ifdef MDTV_DEB_BNP PrintEntry(NS->Label(), 0); cout <<"ShapeType =" << aS.ShapeType() < "; PrintEntry(myLabel,0); #endif if (myLabel.FindAttribute(TNaming_Naming::GetID(),name)) { return name->Solve(Valid); } return Standard_False; } //======================================================================= //function : Arguments //purpose : //======================================================================= void TNaming_Selector::Arguments (TDF_AttributeMap& args) const { TDF_Tool::OutReferences(myLabel,args); } //======================================================================= //function : TNaming_Selector //purpose : //======================================================================= Handle(TNaming_NamedShape) TNaming_Selector::NamedShape() const { Handle(TNaming_NamedShape) NS; myLabel.FindAttribute(TNaming_NamedShape::GetID(),NS); return NS; }