1 // Created on: 2000-10-31
2 // Created by: Sergey ZARITCHNY
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <QANewBRepNaming_Cut.ixx>
17 #include <TopoDS_Iterator.hxx>
18 #include <TopoDS_Shell.hxx>
19 #include <BRep_Builder.hxx>
20 #include <TopExp_Explorer.hxx>
21 #include <TopTools_ListOfShape.hxx>
22 #include <TopTools_ListIteratorOfListOfShape.hxx>
23 #include <TNaming_NamedShape.hxx>
24 #include <TNaming_Tool.hxx>
25 #include <TNaming_Builder.hxx>
26 #include <TNaming_Builder.hxx>
27 #include <QANewBRepNaming_Loader.hxx>
30 //=======================================================================
31 //function : QANewBRepNaming_Cut
33 //=======================================================================
35 QANewBRepNaming_Cut::QANewBRepNaming_Cut() {}
37 //=======================================================================
38 //function : QANewBRepNaming_Cut
40 //=======================================================================
42 QANewBRepNaming_Cut::QANewBRepNaming_Cut(const TDF_Label& ResultLabel)
43 :QANewBRepNaming_BooleanOperationFeat(ResultLabel) {}
45 //=======================================================================
48 //=======================================================================
50 void QANewBRepNaming_Cut::Load(BRepAlgoAPI_BooleanOperation& MS) const {
52 TopoDS_Shape ResSh = MS.Shape();
53 const TopoDS_Shape& ObjSh = MS.Shape1();
54 const TopoDS_Shape& ToolSh = MS.Shape2();
55 const TopAbs_ShapeEnum& TypeSh = ShapeType(ObjSh);
59 cout<<"QANewBRepNaming_Cut::Load(): The result of the boolean operation is null"<<endl;
64 // If the shapes are the same - select the result and exit:
65 if (IsResultChanged(MS)) {
67 cout<<"QANewBRepNaming_Cut::Load(): The object and the result of CUT operation are the same"<<endl;
69 if (MS.Shape().ShapeType() == TopAbs_COMPOUND) {
70 Standard_Integer nbSubResults = 0;
71 TopoDS_Iterator itr(MS.Shape());
72 for (; itr.More(); itr.Next()) nbSubResults++;
73 if (nbSubResults == 1) { //
74 itr.Initialize(MS.Shape());
75 if (itr.More()) ResSh = itr.Value();
78 TNaming_Builder aBuilder(ResultLabel());
79 aBuilder.Select(ResSh, ObjSh);
83 Standard_Boolean aWRCase = IsWRCase(MS);
84 // Naming of the result:
87 // Naming of modified, deleted and new sub shapes:
88 if (TypeSh == TopAbs_WIRE || TypeSh == TopAbs_EDGE) {//LoadWire(MS);
90 TNaming_Builder ModEBuilder(ModifiedEdges());
91 QANewBRepNaming_Loader::LoadModifiedShapes(MS, ObjSh, TopAbs_EDGE, ModEBuilder, Standard_True);
93 if(MS.HasGenerated()) {
94 TNaming_Builder nBuilder (NewShapes());
95 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ObjSh, TopAbs_EDGE, nBuilder);
96 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ToolSh, TopAbs_FACE, nBuilder);
98 //Deleted (Faces, Edges, Vertexes)
100 TNaming_Builder DelFBuilder(DeletedFaces()); // all deleted shapes
101 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ObjSh, TopAbs_EDGE, DelFBuilder);
102 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ObjSh, TopAbs_VERTEX, DelFBuilder);
103 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ToolSh, TopAbs_FACE, DelFBuilder);
107 else if (TypeSh == TopAbs_SHELL || TypeSh == TopAbs_FACE) {//LoadShell(MS);
110 TNaming_Builder ModFBuilder(ModifiedFaces());
111 QANewBRepNaming_Loader::LoadModifiedShapes(MS, ObjSh, TopAbs_FACE, ModFBuilder, Standard_True);
113 LoadSymmetricalEdges(MS);
114 LoadModified1n (MS, ObjSh, TopAbs_FACE);
115 LoadModified11 (MS, ObjSh, TopAbs_FACE);
117 TNaming_Builder ModEBuilder(ModifiedEdges());
118 QANewBRepNaming_Loader::LoadModifiedShapes(MS, ObjSh, TopAbs_EDGE, ModEBuilder, Standard_True);
122 //Generated edges (edges of free boundaries)
123 if(MS.HasGenerated()) {
124 TNaming_Builder nBuilder (NewShapes());
125 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ObjSh, TopAbs_FACE, nBuilder);
126 QANewBRepNaming_Loader::LoadGeneratedShapes (MS, ToolSh, TopAbs_FACE, nBuilder);
130 TNaming_Builder DelFBuilder(DeletedFaces());
131 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ObjSh, TopAbs_FACE, DelFBuilder);
132 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ObjSh, TopAbs_EDGE, DelFBuilder);
133 QANewBRepNaming_Loader::LoadDeletedShapes(MS, ToolSh, TopAbs_FACE, DelFBuilder);
138 if(MS.HasModified()){
140 LoadSymmetricalEdges(MS);
141 LoadModified1n (MS, ObjSh, TopAbs_FACE);
142 LoadModified11 (MS, ObjSh, TopAbs_FACE);
143 LoadModified11 (MS, ToolSh, TopAbs_FACE);
144 } else if(QANewBRepNaming_BooleanOperationFeat::IsWRCase2(MS)) {
145 LoadModified1n (MS, ObjSh, TopAbs_FACE);
146 LoadModified11 (MS, ObjSh, TopAbs_FACE);
147 LoadModified11 (MS, ToolSh, TopAbs_FACE);
150 TNaming_Builder ModBuilder(ModifiedFaces());
151 QANewBRepNaming_Loader::LoadModifiedShapes (MS, ObjSh, TopAbs_FACE, ModBuilder, Standard_True);
152 QANewBRepNaming_Loader::LoadModifiedShapes (MS, ToolSh, TopAbs_FACE, ModBuilder, Standard_True);
158 TNaming_Builder DelBuilder(DeletedFaces());
159 QANewBRepNaming_Loader::LoadDeletedShapes (MS, ObjSh, TopAbs_FACE, DelBuilder);
160 QANewBRepNaming_Loader::LoadDeletedShapes (MS, ToolSh, TopAbs_FACE, DelBuilder);
166 // Naming of the content:
167 if (ShapeType(ObjSh) == TopAbs_SOLID) LoadContent(MS);