// File: TNaming_NamingTool.cxx // Created: Mon Feb 14 16:00:07 2000 // Author: Denis PASCAL // #include #include #include #include #include #include #include #ifdef DEB //#define MDTV_DEB_DESC //#define MDTV_DEB_APPLY #ifdef MDTV_DEB_DESC #include #include #include static void WriteS(const TopoDS_Shape& shape, const Standard_CString filename) { char buf[256]; if(strlen(filename) > 255) return; #ifdef 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 #endif //======================================================================= //function : IsForbiden //purpose : ANaming voir NamingTool //======================================================================= static Standard_Boolean IsForbiden(const TDF_LabelMap& Forbiden, const TDF_Label& Lab) { if (Lab.IsRoot()) { return Standard_False; } if (Forbiden.Contains(Lab)) return Standard_True; else { return IsForbiden(Forbiden,Lab.Father()); } } //======================================================================= //function : LastModif //purpose : ANaming //======================================================================= static void LastModif( TNaming_NewShapeIterator& it, const TopoDS_Shape& S, TopTools_MapOfShape& MS, const TDF_LabelMap& Updated, const TDF_LabelMap& Forbiden) { Standard_Boolean YaModif = Standard_False; for (; it.More(); it.Next()) { const TDF_Label& Lab = it.Label(); #ifdef MDTV_DEB TCollection_AsciiString entry; TDF_Tool::Entry(Lab, entry); cout << "NamingTool:: LastModif LabelEntry = "<< entry << endl; #endif if (!Updated.IsEmpty() && !Updated.Contains(Lab)) continue; if (IsForbiden(Forbiden, Lab)) continue; if (it.IsModification()) { YaModif = Standard_True; TNaming_NewShapeIterator it2(it); if (!it2.More()) { const TopoDS_Shape& S = it.Shape(); MS.Add (S); // Modified } else LastModif(it2,it.Shape(),MS,Updated,Forbiden); } } if (!YaModif) MS.Add(S); } //======================================================================= static void ApplyOrientation (TopTools_MapOfShape& MS, const TopAbs_Orientation OrientationToApply) { if (!MS.IsEmpty ()) { #ifdef MDTV_DEB_APPLY cout <<"OrientationToApply = " <Evolution() == TNaming_SELECTED) { if (itL.More() && itL.NewShape().ShapeType() != TopAbs_VERTEX && !itL.OldShape().IsNull() && itL.OldShape().ShapeType() == TopAbs_VERTEX) { YaOrientationToApply = Standard_True; OrientationToApply = itL.OldShape().Orientation(); } } TNaming_NewShapeIterator it(itL); if (!it.More()) { if (YaOrientationToApply) MS.Add(S.Oriented(OrientationToApply)); else MS.Add(S); } else { // LastModif(it, S, MS, Valid, Forbiden); TopTools_MapOfShape MS2; LastModif(it, S, MS2, Valid, Forbiden); if (YaOrientationToApply) ApplyOrientation (MS2, OrientationToApply);//the solution to be refined for (TopTools_MapIteratorOfMapOfShape itMS2(MS2); itMS2.More();itMS2.Next()) MS.Add(itMS2.Key()); } } } //======================================================================= //function : CurrentShapeFromShape //purpose : ANaming //======================================================================= void TNaming_NamingTool::CurrentShapeFromShape(const TDF_LabelMap& Valid, const TDF_LabelMap& Forbiden, const TDF_Label& Acces, const TopoDS_Shape& S, TopTools_MapOfShape& MS) { TNaming_NewShapeIterator it(S,Acces); Handle(TNaming_NamedShape) NS = it.NamedShape(); if(!NS.IsNull() && NS->Evolution() == TNaming_SELECTED) MS.Add(TNaming_Tool::GetShape(NS)); else { if (!it.More()) MS.Add(S); else LastModif(it, S, MS, Valid, Forbiden); } } //======================================================================= //function : MakeDescendants //purpose : ANaming //======================================================================= static void MakeDescendants (TNaming_NewShapeIterator& it, TDF_LabelMap& Descendants) { for (; it.More(); it.Next()) { Descendants.Add(it.Label()); #ifdef MDTV_DEB_DESC TCollection_AsciiString entry; TDF_Tool::Entry(it.Label(), entry); cout<< "MakeDescendants: Label = " <