1 // Created on: 2000-10-31
2 // Created by: Vladislav ROMASHKO
3 // Copyright (c) 2000-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_Intersection.ixx>
21 #include <TNaming_Builder.hxx>
22 #include <QANewBRepNaming_Loader.hxx>
23 #include <TopTools_ListIteratorOfListOfShape.hxx>
24 #include <TopOpeBRepBuild_HBuilder.hxx>
25 #include <TopoDS_Iterator.hxx>
28 #include <TDataStd_Name.hxx>
29 #include <TNaming_NamedShape.hxx>
43 //=======================================================================
44 //function : QANewBRepNaming_Intersection
46 //=======================================================================
48 QANewBRepNaming_Intersection::QANewBRepNaming_Intersection() {}
50 //=======================================================================
51 //function : QANewBRepNaming_Intersection
53 //=======================================================================
55 QANewBRepNaming_Intersection::QANewBRepNaming_Intersection(const TDF_Label& ResultLabel)
56 :QANewBRepNaming_BooleanOperationFeat(ResultLabel) {}
58 //=======================================================================
61 //=======================================================================
63 void QANewBRepNaming_Intersection::Load(BRepAlgoAPI_BooleanOperation& MS) const {
64 TopoDS_Shape ResSh = MS.Shape();
67 cout<<"QANewBRepNaming_Intersection::Load(): The result of the Intersection is null"<<endl;
72 const TopAbs_ShapeEnum& ResType = ShapeType(ResSh);
73 const TopoDS_Shape& ObjSh = MS.Shape1();
74 const TopoDS_Shape& ToolSh = MS.Shape2();
76 // If the shapes are the same - select the result and exit:
77 if (IsResultChanged(MS)) {
79 cout<<"QANewBRepNaming_Intersection::Load(): The object and the result of INTERSECTION operation are the same"<<endl;
82 if (ResType == TopAbs_COMPOUND) {
83 Standard_Integer nbSubResults = 0;
84 TopoDS_Iterator itr(MS.Shape());
85 for (; itr.More(); itr.Next()) nbSubResults++;
86 if (nbSubResults == 1) {
87 itr.Initialize(MS.Shape());
88 if (itr.More()) ResSh = itr.Value();
91 TNaming_Builder aBuilder(ResultLabel());
92 aBuilder.Select(ResSh, ObjSh);
96 const TopAbs_ShapeEnum& anObjType = ShapeType(ObjSh);
97 const TopAbs_ShapeEnum& aToolType = ShapeType(ToolSh);
101 case TopAbs_SOLID://1
115 case TopAbs_SHELL://2
154 if(anArg == UNEXPECTED) {
156 cout <<"QANewBRepNaming_Intersection:: Unexpected Use Case" << endl;
162 // Naming of modified, deleted and new sub shapes:
163 if (anArg == SHELL_SHELL) { // Result Wire/Edge
164 //Generated Edges and (may be) vertexes
165 if(MS.HasGenerated()) {
166 TNaming_Builder nBuilder (NewShapes());
167 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ObjSh, TopAbs_FACE, nBuilder);
168 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ToolSh, TopAbs_FACE, nBuilder);
169 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ObjSh, TopAbs_EDGE, nBuilder);
170 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ToolSh, TopAbs_EDGE, nBuilder);
173 TNaming_Builder DelFBuilder(DeletedFaces());
174 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ObjSh, TopAbs_FACE, DelFBuilder);
175 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ToolSh, TopAbs_FACE, DelFBuilder);
176 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ObjSh, TopAbs_EDGE, DelFBuilder);
177 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ToolSh, TopAbs_EDGE, DelFBuilder);
180 else if (anArg == SOLID_WIRE || anArg == WIRE_SOLID ||
181 anArg == SHELL_WIRE || anArg == WIRE_SHELL) { // Result ==> Vertex
183 if(MS.HasGenerated()) {
184 TNaming_Builder nBuilder (NewShapes());
185 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ObjSh, TopAbs_FACE, nBuilder);
186 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ToolSh, TopAbs_FACE, nBuilder);
187 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ObjSh, TopAbs_EDGE, nBuilder);
188 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ToolSh, TopAbs_EDGE, nBuilder);
191 TNaming_Builder DelFBuilder(DeletedFaces());
192 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ObjSh, TopAbs_FACE, DelFBuilder);
193 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ToolSh, TopAbs_FACE, DelFBuilder);
194 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ObjSh, TopAbs_EDGE, DelFBuilder);
195 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ToolSh, TopAbs_EDGE, DelFBuilder);
196 if(anArg == SOLID_WIRE || anArg == SHELL_WIRE) {
197 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ToolSh, TopAbs_VERTEX, DelFBuilder);
199 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ObjSh, TopAbs_VERTEX, DelFBuilder);
201 } else if (anArg == WIRE_WIRE) {
202 if(MS.HasGenerated()) {
203 TNaming_Builder nBuilder (NewShapes());
204 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ObjSh, TopAbs_EDGE, nBuilder);
205 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ToolSh, TopAbs_EDGE, nBuilder);
208 TNaming_Builder DelFBuilder(DeletedFaces());
209 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ObjSh, TopAbs_EDGE, DelFBuilder);
210 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ToolSh, TopAbs_EDGE, DelFBuilder);
211 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ToolSh, TopAbs_VERTEX, DelFBuilder);
212 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ObjSh, TopAbs_VERTEX, DelFBuilder);
218 // Naming of the content:
219 // if (ShapeType(ResSh) == TopAbs_VERTEX) LoadContent(MS);