// Created on: 2000-02-14 // Created by: Denis PASCAL // Copyright (c) 2000-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #include #include #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) {//OR-N Handle (TNaming_Naming) aNaming; Lab.FindAttribute(TNaming_Naming::GetID(), aNaming); if(!aNaming.IsNull()) { if(aNaming->GetName().Type() == TNaming_ORIENTATION) { OrientationToApply = aNaming->GetName().Orientation(); } else { Handle (TNaming_Naming) aNaming2; TDF_ChildIterator it(aNaming->Label()); for(;it.More();it.Next()) { const TDF_Label& aLabel = it.Value(); aLabel.FindAttribute(TNaming_Naming::GetID(), aNaming2); if(!aNaming2.IsNull()) { if(aNaming2->GetName().Type() == TNaming_ORIENTATION) { OrientationToApply = aNaming2->GetName().Orientation(); break; } } } } if(OrientationToApply == TopAbs_FORWARD || OrientationToApply == TopAbs_REVERSED) YaOrientationToApply = Standard_True; } } // } 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 = " <