1 // File: QANewBRepNaming_Common.cxx
2 // Created: Tue Oct 31 14:55:47 2000
3 // Author: Sergey ZARITCHNY
4 // <szy@opencascade.com
5 // Copyright: Open CASCADE 2003
7 // Lastly modified by :
8 // +---------------------------------------------------------------------------+
9 // ! szy ! Modified Load !30-10-2003! 4.0-2-%L%!
10 // +---------------------------------------------------------------------------+
12 #include <QANewBRepNaming_Common.ixx>
13 #include <TNaming_Builder.hxx>
14 #include <QANewBRepNaming_Loader.hxx>
15 #include <TopExp_Explorer.hxx>
16 #include <TopTools_ListIteratorOfListOfShape.hxx>
17 #include <TNaming_Tool.hxx>
18 #include <TopoDS_Iterator.hxx>
19 #include <TNaming_NamedShape.hxx>
20 #include <TopoDS_Shell.hxx>
21 #include <BRep_Builder.hxx>
22 #include <TopTools_MapOfShape.hxx>
23 //=======================================================================
24 //function : QANewBRepNaming_Common
26 //=======================================================================
28 QANewBRepNaming_Common::QANewBRepNaming_Common() {}
30 //=======================================================================
31 //function : QANewBRepNaming_Common
33 //=======================================================================
35 QANewBRepNaming_Common::QANewBRepNaming_Common(const TDF_Label& ResultLabel)
36 :QANewBRepNaming_BooleanOperationFeat(ResultLabel) {}
38 //=======================================================================
41 //=======================================================================
43 void QANewBRepNaming_Common::Load(BRepAlgoAPI_BooleanOperation& MS) const {
44 TopoDS_Shape ResSh = MS.Shape();
47 cout<<"QANewBRepNaming_Common::Load(): The result of the Common is null"<<endl;
63 const TopAbs_ShapeEnum& ResType = ShapeType(ResSh);
64 const TopoDS_Shape& ObjSh = MS.Shape1();
65 const TopoDS_Shape& ToolSh = MS.Shape2();
67 // If the shapes are the same - select the result and exit:
68 if (IsResultChanged(MS)) {
70 cout<<"QANewBRepNaming_Common::Load(): The object and the result of COMMON operation are the same"<<endl;
72 if (ResType == TopAbs_COMPOUND) {
73 Standard_Integer nbSubResults = 0;
74 TopoDS_Iterator itr(MS.Shape());
75 for (; itr.More(); itr.Next()) nbSubResults++;
76 if (nbSubResults == 1) {
77 itr.Initialize(MS.Shape());
78 if (itr.More()) ResSh = itr.Value();
81 TNaming_Builder aBuilder(ResultLabel());
82 aBuilder.Select(ResSh, ObjSh);
83 aBuilder.Select(ResSh, ToolSh);
86 const TopAbs_ShapeEnum& anObjType = ShapeType(ObjSh);
87 const TopAbs_ShapeEnum& aToolType = ShapeType(ToolSh);
112 if(aToolType == TopAbs_SOLID)
114 else anArg = UNEXPECTED;
118 if(aToolType == TopAbs_SOLID)
120 else anArg = UNEXPECTED;
126 if( anArg == UNEXPECTED)
129 cout <<"QANewBRepNaming_Common:: Unexpected Use Case" << endl;
133 // Naming of the result:
136 // Naming of modified, deleted and new sub shapes:
137 if (anArg == SOLID_WIRE || anArg == WIRE_SOLID) { // Result => Wire/Edge
138 TopoDS_Shape aWire, aSolid;
139 if(anArg == WIRE_SOLID) {
140 aWire = ObjSh; aSolid = ToolSh;}
142 aWire = ToolSh; aSolid = ObjSh;}
144 TNaming_Builder ModEBuilder(ModifiedEdges());
145 QANewBRepNaming_Loader::LoadModifiedShapes(MS, aWire, TopAbs_EDGE, ModEBuilder, Standard_True);
147 if(MS.HasGenerated()) {
148 TNaming_Builder nBuilder (NewShapes());
149 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, aWire, TopAbs_EDGE, nBuilder);
150 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, aSolid, TopAbs_FACE, nBuilder);
151 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, aSolid, TopAbs_VERTEX, nBuilder);
153 //Deleted (Faces, Edges, Vertexes)
155 TNaming_Builder DelFBuilder(DeletedFaces()); // all deleted shapes
156 QANewBRepNaming_Loader::LoadDeletedShapes(MS, aSolid, TopAbs_FACE, DelFBuilder);
157 QANewBRepNaming_Loader::LoadDeletedShapes(MS, aWire, TopAbs_EDGE, DelFBuilder);
158 QANewBRepNaming_Loader::LoadDeletedShapes(MS, aWire, TopAbs_VERTEX, DelFBuilder);
161 else if (anArg == SOLID_SHELL || anArg == SHELL_SOLID) { //Result: Shell/Face
163 if(anArg == SHELL_SOLID)
168 TNaming_Builder ModFBuilder(ModifiedFaces());
169 QANewBRepNaming_Loader::LoadModifiedShapes(MS, aShell, TopAbs_FACE, ModFBuilder, Standard_True);
170 TNaming_Builder ModEBuilder(ModifiedEdges());
171 QANewBRepNaming_Loader::LoadModifiedShapes(MS, aShell, TopAbs_EDGE, ModEBuilder, Standard_True);
172 //Generated edges (edges of free boundaries)
173 if(MS.HasGenerated()) {
174 TNaming_Builder nBuilder (NewShapes());
175 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape1(), TopAbs_FACE, nBuilder);
176 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, MS.Shape2(), TopAbs_FACE, nBuilder);
180 TNaming_Builder DelFBuilder(DeletedFaces());
181 QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape1(), TopAbs_FACE, DelFBuilder);
182 QANewBRepNaming_Loader::LoadDeletedShapes(MS, MS.Shape2(), TopAbs_FACE, DelFBuilder);
183 QANewBRepNaming_Loader::LoadDeletedShapes(MS, aShell, TopAbs_EDGE, DelFBuilder);
188 // cout <<"Solid case - modified = " << MS.HasModified()<< endl;
190 TNaming_Builder ModBuilder(ModifiedFaces());
191 QANewBRepNaming_Loader::LoadModifiedShapes (MS, ObjSh, TopAbs_FACE, ModBuilder, Standard_True);
192 QANewBRepNaming_Loader::LoadModifiedShapes (MS, ToolSh, TopAbs_FACE, ModBuilder, Standard_True);
193 if(MS.HasGenerated()) {
194 TNaming_Builder GenBuilder (NewShapes());
195 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ToolSh, TopAbs_FACE, GenBuilder);
198 TNaming_Builder DelBuilder(DeletedFaces());
199 QANewBRepNaming_Loader::LoadDeletedShapes (MS, ObjSh, TopAbs_FACE, DelBuilder);
200 QANewBRepNaming_Loader::LoadDeletedShapes (MS, ToolSh, TopAbs_FACE, DelBuilder);
206 // Naming of the content:
207 if (ShapeType(ObjSh) == TopAbs_SOLID) LoadContent(MS);
212 // File history synopsis (creation,modification,correction)
213 // +---------------------------------------------------------------------------+
214 // ! Developer ! Comments ! Date ! Version !
215 // +-----------!-----------------------------------------!----------!----------+
216 // ! vro ! Creation !31-10-2000! 3.0-00-3 !
217 // ! vro ! Redesign !13-12-2000! 3.0-00-3 !
218 // ! vro ! Result control !07-03-2001! 3.0-00-3 !
219 // ! vro ! Result may be null !19-03-2001! 3.0-00-3 !
220 // ! szy ! Modified Load ! 8-05-2003! 3.0-00-2 !
221 // ! szy ! Modified Load !21-05-2003! 3.0-00-2 !
222 // ! szy ! Adopted ! 9-06-2003! 3.0-00-2 !
223 // ! vladimir ! adaptation to CAS 5.0 ! 07/01/03! 4.0-2 !
224 // ! szy ! Modified Load !30-10-2003! 4.0-2-%L%!
225 // +---------------------------------------------------------------------------+