0023604: Uninitialized variables in debug mode
[occt.git] / src / QANewBRepNaming / QANewBRepNaming.cxx
CommitLineData
b311480e 1// Created on: 2003-06-20
2// Created by: Sergey ZARITCHNY
3// Copyright (c) 2003-2012 OPEN CASCADE SAS
4//
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.
9//
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.
12//
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.
7fd59977 19
20#include <QANewBRepNaming.ixx>
21
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>
30
31//=======================================================================
32//function : CleanStructure
33//purpose :
34//=======================================================================
35
36void QANewBRepNaming::CleanStructure(const TDF_Label& theLabel) {
37
38 TopTools_ListOfShape Olds;
39 TopTools_ListOfShape News;
40 TNaming_Evolution anEvol;
41 TNaming_Iterator anIt(theLabel);
42 if (anIt.More()) {
43 anEvol = anIt.Evolution();
44 for ( ; anIt.More(); anIt.Next()) {
45 Olds.Append(anIt.OldShape());
46 News.Append(anIt.NewShape());
47 }
48
49 TopTools_ListIteratorOfListOfShape itOlds(Olds);
50 TopTools_ListIteratorOfListOfShape itNews(News);
51 TNaming_Builder aBuilder(theLabel);
52 anEvol = TNaming_DELETE;
53
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);
58 }
59 }
60 for (TDF_ChildIterator chlIt(theLabel, Standard_True); chlIt.More(); chlIt.Next()) {
61 CleanStructure (chlIt.Value());
62 }
63}
64
65//=======================================================================
66//function : LoadNamedShape
67//purpose :
68//=======================================================================
69
70void QANewBRepNaming::LoadNamedShape (TNaming_Builder& theBuilder,
71 const TNaming_Evolution theEvol,
72 const TopoDS_Shape& theOS,
73 const TopoDS_Shape& theNS)
74{
75 switch (theEvol) {
76 case TNaming_PRIMITIVE :
77 {
78 theBuilder.Generated(theNS);
79 break;
80 }
81 case TNaming_GENERATED :
82 {
83 theBuilder.Generated(theOS, theNS);
84 break;
85 }
86 case TNaming_MODIFY :
87 {
88 theBuilder.Modify(theOS, theNS);
89 break;
90 }
1ec8a59e 91// case TNaming_REPLACE :
92// {
93// theBuilder.Replace(theOS, theNS);
94// break;
95// }
7fd59977 96 case TNaming_DELETE :
97 {
98 theBuilder.Delete (theOS);
99 break;
100 }
101 case TNaming_SELECTED :
102 {
103 theBuilder.Select(theNS, theOS);
104 }
7fd59977 105 default:
106 break;
7fd59977 107 }
108}
109
110//=======================================================================
111//function : Displace
112//purpose : if WithOld == True, dsplace with old subshapes
113//=======================================================================
114
115void QANewBRepNaming::Displace (const TDF_Label& theLabel,
116 const TopLoc_Location& theLoc,
117 const Standard_Boolean theWithOld)
118{
119 TopTools_ListOfShape Olds;
120 TopTools_ListOfShape News;
121 TNaming_Evolution Evol;
122 TNaming_Iterator it(theLabel);
123
124 if (it.More()) {
125 Evol = it.Evolution();
126 for ( ; it.More(); it.Next()) {
127 Olds.Append(it.OldShape());
128 News.Append(it.NewShape());
129 }
130
131 TopTools_ListIteratorOfListOfShape itOlds(Olds);
132 TopTools_ListIteratorOfListOfShape itNews(News);
133 TNaming_Builder B(theLabel);
134
135 for ( ;itOlds.More() ; itOlds.Next(),itNews.Next()) {
136 TopoDS_Shape OS,NS;
137 const TopoDS_Shape& SO = itOlds.Value();
138 const TopoDS_Shape& SN = itNews.Value();
139 OS = SO;
140 if (theWithOld && !SO.IsNull()) OS = SO.Moved(theLoc);
141 if (!SN.IsNull()) NS = SN.Moved(theLoc);
142
143 LoadNamedShape ( B, Evol, OS, NS);
144 }
145 }
146 for (TDF_ChildIterator ciL(theLabel); ciL.More(); ciL.Next()) {
147 Displace (ciL.Value(),theLoc,theWithOld);
148 }
149}