1 // Created on: 2003-06-20
2 // Created by: Sergey ZARITCHNY
3 // Copyright (c) 2003-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
20 #include <QANewBRepNaming.ixx>
22 #include <TopTools_ListOfShape.hxx>
23 #include <TopTools_ListIteratorOfListOfShape.hxx>
24 #include <TDF_Label.hxx>
25 #include <TDF_ChildIterator.hxx>
26 #include <TNaming.hxx>
27 #include <TNaming_Iterator.hxx>
28 #include <TNaming_Builder.hxx>
29 #include <TNaming_NamedShape.hxx>
31 //=======================================================================
32 //function : CleanStructure
34 //=======================================================================
36 void QANewBRepNaming::CleanStructure(const TDF_Label& theLabel) {
38 TopTools_ListOfShape Olds;
39 TopTools_ListOfShape News;
40 TNaming_Evolution anEvol;
41 TNaming_Iterator anIt(theLabel);
43 anEvol = anIt.Evolution();
44 for ( ; anIt.More(); anIt.Next()) {
45 Olds.Append(anIt.OldShape());
46 News.Append(anIt.NewShape());
49 TopTools_ListIteratorOfListOfShape itOlds(Olds);
50 TopTools_ListIteratorOfListOfShape itNews(News);
51 TNaming_Builder aBuilder(theLabel);
52 anEvol = TNaming_DELETE;
54 for ( ;itOlds.More() ; itOlds.Next(),itNews.Next()) {
55 const TopoDS_Shape& OS = itOlds.Value();
56 const TopoDS_Shape& NS = itNews.Value();
57 LoadNamedShape ( aBuilder, anEvol, OS, NS);
60 for (TDF_ChildIterator chlIt(theLabel, Standard_True); chlIt.More(); chlIt.Next()) {
61 CleanStructure (chlIt.Value());
65 //=======================================================================
66 //function : LoadNamedShape
68 //=======================================================================
70 void QANewBRepNaming::LoadNamedShape (TNaming_Builder& theBuilder,
71 const TNaming_Evolution theEvol,
72 const TopoDS_Shape& theOS,
73 const TopoDS_Shape& theNS)
76 case TNaming_PRIMITIVE :
78 theBuilder.Generated(theNS);
81 case TNaming_GENERATED :
83 theBuilder.Generated(theOS, theNS);
88 theBuilder.Modify(theOS, theNS);
91 // case TNaming_REPLACE :
93 // theBuilder.Replace(theOS, theNS);
98 theBuilder.Delete (theOS);
101 case TNaming_SELECTED :
103 theBuilder.Select(theNS, theOS);
110 //=======================================================================
111 //function : Displace
112 //purpose : if WithOld == True, dsplace with old subshapes
113 //=======================================================================
115 void QANewBRepNaming::Displace (const TDF_Label& theLabel,
116 const TopLoc_Location& theLoc,
117 const Standard_Boolean theWithOld)
119 TopTools_ListOfShape Olds;
120 TopTools_ListOfShape News;
121 TNaming_Evolution Evol;
122 TNaming_Iterator it(theLabel);
125 Evol = it.Evolution();
126 for ( ; it.More(); it.Next()) {
127 Olds.Append(it.OldShape());
128 News.Append(it.NewShape());
131 TopTools_ListIteratorOfListOfShape itOlds(Olds);
132 TopTools_ListIteratorOfListOfShape itNews(News);
133 TNaming_Builder B(theLabel);
135 for ( ;itOlds.More() ; itOlds.Next(),itNews.Next()) {
137 const TopoDS_Shape& SO = itOlds.Value();
138 const TopoDS_Shape& SN = itNews.Value();
140 if (theWithOld && !SO.IsNull()) OS = SO.Moved(theLoc);
141 if (!SN.IsNull()) NS = SN.Moved(theLoc);
143 LoadNamedShape ( B, Evol, OS, NS);
146 for (TDF_ChildIterator ciL(theLabel); ciL.More(); ciL.Next()) {
147 Displace (ciL.Value(),theLoc,theWithOld);