0022904: Clean up sccsid variables
[occt.git] / src / QANewBRepNaming / QANewBRepNaming_Limitation.cxx
CommitLineData
7fd59977 1// File: QANewBRepNaming_Limitation.cxx
2// Created: Tue Dec 26 14:27:46 2000
3// Author: Vladislav ROMASHKO <vro@nnov.matra-dtv.fr>
4// Copyright: Matra Datavision 2000
5
7fd59977 6// Lastly modified by :
7// +---------------------------------------------------------------------------+
8// ! szy ! Modify Load !21-05-2003! 3.0-00-2!
9// +---------------------------------------------------------------------------+
10
11
12#include <QANewBRepNaming_Limitation.ixx>
13#include <TopTools_ListIteratorOfListOfShape.hxx>
14#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
15#include <TopTools_IndexedMapOfShape.hxx>
16#include <BRep_Tool.hxx>
17#include <TopoDS.hxx>
18#include <TopoDS_Iterator.hxx>
19#include <TopExp.hxx>
20#include <TopExp_Explorer.hxx>
21
22// OCAF
23#include <TDataStd_Name.hxx>
24#include <TNaming_Builder.hxx>
25#include <TNaming_NamedShape.hxx>
26#include <QANewBRepNaming_Loader.hxx>
27// Specific
28#include <QANewModTopOpe_ModeOfLimitation.hxx>
29
30//=======================================================================
31//function : QANewBRepNaming_Limitation
32//purpose :
33//=======================================================================
34
35QANewBRepNaming_Limitation::QANewBRepNaming_Limitation() {}
36
37//=======================================================================
38//function : QANewBRepNaming_Limitation
39//purpose :
40//=======================================================================
41
42QANewBRepNaming_Limitation::QANewBRepNaming_Limitation(const TDF_Label& ResultLabel)
43 :QANewBRepNaming_BooleanOperationFeat(ResultLabel) {}
44
45//=======================================================================
46//function : Load
47//purpose :
48//=======================================================================
49
50void QANewBRepNaming_Limitation::Load(QANewModTopOpe_Limitation& MS) const {
51 TopoDS_Shape ResSh = MS.Shape();
52
53 const TopoDS_Shape& ObjSh = MS.Shape1();
54 const TopoDS_Shape& ToolSh = MS.Shape2();
55 const TopAbs_ShapeEnum& ObjType = ShapeType(ObjSh);
56
57 if (ResSh.IsNull()) {
58#ifdef MDTV_DEB
59 cout<<"QANewBRepNaming_Limitation::Load(): The result of the boolean operation is null"<<endl;
60#endif
61 return;
62 }
63
64 if (MS.Shape().ShapeType() == TopAbs_COMPOUND) {
65 Standard_Integer nbSubResults = 0;
66 TopoDS_Iterator itr(MS.Shape());
67 for (; itr.More(); itr.Next()) nbSubResults++;
68 if (nbSubResults == 1) {
69 itr.Initialize(MS.Shape());
70 if (itr.More()) ResSh = itr.Value();
71 }
72 }
73 if(MS.Shape1().IsSame(ResSh)) {
74// If the shapes are the same - select the result and exit:
75#ifdef MDTV_DEB
76 cout<<"QANewBRepNaming_Limitation::Load(): The object and the result of LIMITATION operation are the same"<<endl;
77#endif
78 TNaming_Builder aBuilder(ResultLabel());
79 aBuilder.Select(ResSh, ObjSh);
80 return;
81 }
82 // Naming of the result:
83 LoadResult(MS);
84
85 // Naming of the content:
86// if (ResSh.ShapeType() == TopAbs_COMPOUND) {
87
88// LoadContent(MS);
89
90// }
91
92 // Naming of modified, deleted and new sub shapes:
93 if (ObjType == TopAbs_WIRE || ObjType == TopAbs_EDGE) {
94// LoadWire(MS);
95 TNaming_Builder ModBuilder(ModifiedEdges());
96 QANewBRepNaming_Loader::LoadModifiedShapes (MS, MS.Shape1(), TopAbs_EDGE, ModBuilder, Standard_False);
97 if(MS.HasGenerated()) {
98 TNaming_Builder nBuilder (NewShapes());
99// generated Vertexes
100 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape1(), TopAbs_EDGE, nBuilder);
101 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape2(), TopAbs_FACE, nBuilder);
102 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape2(), TopAbs_EDGE, nBuilder);
103 }
104 if(MS.HasDeleted()){
105 TNaming_Builder DelEBuilder(DeletedEdges());
106 QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape1(), TopAbs_EDGE, DelEBuilder);
107 QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape2(), TopAbs_EDGE, DelEBuilder);
108 QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape1(), TopAbs_VERTEX, DelEBuilder);
109 QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape2(), TopAbs_VERTEX, DelEBuilder);
110 }
111 }
112 else if (ObjType == TopAbs_SHELL || ObjType == TopAbs_FACE) {
113 //LoadShell(MS);
114 TNaming_Builder ModBuilder(ModifiedFaces());
115 QANewBRepNaming_Loader::LoadModifiedShapes (MS, MS.Shape1(), TopAbs_FACE, ModBuilder, Standard_False);
116 QANewBRepNaming_Loader::LoadModifiedShapes (MS, MS.Shape1(), TopAbs_EDGE, ModBuilder, Standard_False);
117
118 if(MS.HasGenerated()) {
119 TNaming_Builder nBuilder (NewShapes());
120// generated free Edges
121 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape1(), TopAbs_FACE, nBuilder);
122 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape2(), TopAbs_FACE, nBuilder);
123 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape2(), TopAbs_EDGE, nBuilder);
124 }
125 if(MS.HasDeleted()){
126 TNaming_Builder DelEBuilder(DeletedFaces());
127 QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape1(), TopAbs_FACE, DelEBuilder);
128 QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape2(), TopAbs_FACE, DelEBuilder);
129 QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape1(), TopAbs_EDGE, DelEBuilder); //free bound.
130 QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape2(), TopAbs_EDGE, DelEBuilder);
131 }
132 }
133 else if(ObjType == TopAbs_SOLID) {
134 TNaming_Builder ModBuilder(ModifiedFaces());
135 QANewBRepNaming_Loader::LoadModifiedShapes (MS, MS.Shape1(), TopAbs_FACE, ModBuilder, Standard_False);
136 QANewBRepNaming_Loader::LoadModifiedShapes (MS, MS.Shape2(), TopAbs_FACE, ModBuilder, Standard_False);
137
138 if(MS.HasDeleted()){
139 TNaming_Builder DelEBuilder(DeletedFaces());
140 QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape1(), TopAbs_FACE, DelEBuilder);
141 QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape2(), TopAbs_FACE, DelEBuilder);
142 }
143 }
144
145 LoadDegenerated(MS);
146
147}
148
149//=======================================================================
150//function : LoadResult
151//purpose :
152//=======================================================================
153
154void QANewBRepNaming_Limitation::LoadResult(QANewModTopOpe_Limitation& MS) const {
155 Handle(TDF_TagSource) Tagger = TDF_TagSource::Set(ResultLabel());
156 if (Tagger.IsNull()) return;
157 Tagger->Set(0);
158 TNaming_Builder Builder (ResultLabel());
159 TopoDS_Shape aResult = MS.Shape();
160 if (aResult.ShapeType() == TopAbs_COMPOUND) {
161 Standard_Integer nbSubResults = 0;
162 TopoDS_Iterator itr(aResult);
163 for (; itr.More(); itr.Next()) nbSubResults++;
164 if (nbSubResults == 1) {
165 itr.Initialize(aResult);
166 if (itr.More()) aResult = itr.Value();
167 }
168 }
169 if (MS.Shape1().IsNull()) Builder.Generated(aResult);
170 else Builder.Modify(MS.Shape1(), aResult);
171}
172
173//=======================================================================
174//function : LoadDegenerated
175//purpose :
176//=======================================================================
177
178void QANewBRepNaming_Limitation::LoadDegenerated(QANewModTopOpe_Limitation& MS) const {
179 TopTools_IndexedMapOfShape allEdges;
180 TopExp::MapShapes(MS.Shape1(), TopAbs_EDGE, allEdges);
181 Standard_Integer i = 1;
182 for (; i <= allEdges.Extent(); i++) {
183 if (BRep_Tool::Degenerated(TopoDS::Edge(allEdges.FindKey(i)))) {
184 if (MS.IsDeleted(allEdges.FindKey(i))) {
185 TNaming_Builder DegeneratedBuilder(DeletedDegeneratedEdges());
186 DegeneratedBuilder.Generated(allEdges.FindKey(i));
187#ifdef MDTV_DEB
188 TDataStd_Name::Set(DegeneratedBuilder.NamedShape()->Label(), "DeletedDegenerated");
189#endif
190 }
191 }
192 }
193}
194//=======================================================================
195//function : LoadContent
196//purpose :
197//=======================================================================
198
199void QANewBRepNaming_Limitation::LoadContent(QANewModTopOpe_Limitation& MS) const {
200 if (MS.Shape().ShapeType() == TopAbs_COMPSOLID || MS.Shape().ShapeType() == TopAbs_COMPOUND) {
201 TopoDS_Iterator itr(MS.Shape());
202 Standard_Integer nbShapes = 0;
203 while (itr.More()) {
204 nbShapes++;
205 itr.Next();
206 }
207 if (nbShapes > 1) {
208 for (itr.Initialize(MS.Shape()); itr.More(); itr.Next()) {
209 TNaming_Builder bContent(Content());
210 bContent.Generated(MS.Shape1(),itr.Value());
211 bContent.Generated(MS.Shape2(),itr.Value());
212 }
213 }
214 }
215}
216
217
218// @@SDM: begin
219
220// Lastly modified by : vro Date : 26-12-2000
221
222// File history synopsis (creation,modification,correction)
223// +---------------------------------------------------------------------------+
224// ! Developer ! Comments ! Date ! Version !
225// +-----------!-----------------------------------------!----------!----------+
226// ! vro ! Creation !26-12-2000! 3.0-00-1!
227// ! vro ! Result control !07-03-2001! 3.0-00-1!
228// ! vro ! Result may be null !19-03-2001! 3.0-00-1!
229// ! szy ! Modified input parameter type of Load !18-10-2002! 3.0-00-5!
230// ! szy ! Modify Load !21-05-2003! 3.0-00-2!
231// ! vladimir ! adaptation to CAS 5.0 ! 07/01/03! 4.0-2!
232// +---------------------------------------------------------------------------+
233//
234// @@SDM: end