0028567: Get rid of the unused DRAW commands based on old Boolean Operations (BRepAlgo)
[occt.git] / src / QANewBRepNaming / QANewBRepNaming_Cut.cxx
CommitLineData
b311480e 1// Created on: 2000-10-31
2// Created by: Sergey ZARITCHNY
973c2be1 3// Copyright (c) 2000-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
42cf5bc1 16
7fd59977 17#include <BRep_Builder.hxx>
42cf5bc1 18#include <BRepAlgoAPI_BooleanOperation.hxx>
19#include <QANewBRepNaming_Cut.hxx>
20#include <QANewBRepNaming_Loader.hxx>
21#include <TDF_Label.hxx>
22#include <TNaming_Builder.hxx>
7fd59977 23#include <TNaming_NamedShape.hxx>
24#include <TNaming_Tool.hxx>
42cf5bc1 25#include <TopExp_Explorer.hxx>
26#include <TopoDS_Iterator.hxx>
27#include <TopoDS_Shell.hxx>
28#include <TopTools_ListIteratorOfListOfShape.hxx>
29#include <TopTools_ListOfShape.hxx>
7fd59977 30
31//=======================================================================
32//function : QANewBRepNaming_Cut
33//purpose :
34//=======================================================================
7fd59977 35QANewBRepNaming_Cut::QANewBRepNaming_Cut() {}
36
37//=======================================================================
38//function : QANewBRepNaming_Cut
39//purpose :
40//=======================================================================
41
42QANewBRepNaming_Cut::QANewBRepNaming_Cut(const TDF_Label& ResultLabel)
e45b5ff7 43 :QANewBRepNaming_BooleanOperation(ResultLabel) {}
7fd59977 44
45//=======================================================================
46//function : Load
47//purpose :
48//=======================================================================
49
50void QANewBRepNaming_Cut::Load(BRepAlgoAPI_BooleanOperation& MS) const {
51
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);
56
57 if (ResSh.IsNull()) {
0797d9d3 58#ifdef OCCT_DEBUG
7fd59977 59 cout<<"QANewBRepNaming_Cut::Load(): The result of the boolean operation is null"<<endl;
60#endif
61 return;
62 }
63
64 // If the shapes are the same - select the result and exit:
65 if (IsResultChanged(MS)) {
0797d9d3 66#ifdef OCCT_DEBUG
7fd59977 67 cout<<"QANewBRepNaming_Cut::Load(): The object and the result of CUT operation are the same"<<endl;
68#endif
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();
76 } //
77 }
78 TNaming_Builder aBuilder(ResultLabel());
79 aBuilder.Select(ResSh, ObjSh);
80 return;
81 }
82 //
83 Standard_Boolean aWRCase = IsWRCase(MS);
84 // Naming of the result:
85 LoadResult(MS);
86
87 // Naming of modified, deleted and new sub shapes:
88 if (TypeSh == TopAbs_WIRE || TypeSh == TopAbs_EDGE) {//LoadWire(MS);
89//Modified
90 TNaming_Builder ModEBuilder(ModifiedEdges());
91 QANewBRepNaming_Loader::LoadModifiedShapes(MS, ObjSh, TopAbs_EDGE, ModEBuilder, Standard_True);
92//Generated vertexes
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);
97 }
98//Deleted (Faces, Edges, Vertexes)
99 if(MS.HasDeleted()){
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);
104 }
105
106 }
107 else if (TypeSh == TopAbs_SHELL || TypeSh == TopAbs_FACE) {//LoadShell(MS);
108//Modified
109 if(!aWRCase) {
110 TNaming_Builder ModFBuilder(ModifiedFaces());
111 QANewBRepNaming_Loader::LoadModifiedShapes(MS, ObjSh, TopAbs_FACE, ModFBuilder, Standard_True);
112 } else {
113 LoadSymmetricalEdges(MS);
114 LoadModified1n (MS, ObjSh, TopAbs_FACE);
115 LoadModified11 (MS, ObjSh, TopAbs_FACE);
116 }
117 TNaming_Builder ModEBuilder(ModifiedEdges());
118 QANewBRepNaming_Loader::LoadModifiedShapes(MS, ObjSh, TopAbs_EDGE, ModEBuilder, Standard_True);
119//
120
121
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);
127 }
128//Deleted
129 if(MS.HasDeleted()){
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);
134 }
135 }
136 else { // Solid
137
138 if(MS.HasModified()){
139 if(aWRCase) {
140 LoadSymmetricalEdges(MS);
141 LoadModified1n (MS, ObjSh, TopAbs_FACE);
142 LoadModified11 (MS, ObjSh, TopAbs_FACE);
143 LoadModified11 (MS, ToolSh, TopAbs_FACE);
e45b5ff7 144 } else if(QANewBRepNaming_BooleanOperation::IsWRCase2(MS)) {
7fd59977 145 LoadModified1n (MS, ObjSh, TopAbs_FACE);
146 LoadModified11 (MS, ObjSh, TopAbs_FACE);
147 LoadModified11 (MS, ToolSh, TopAbs_FACE);
148 LoadWRCase(MS);
149 } else {
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);
153 }
154 }
155
156
157 if(MS.HasDeleted()){
158 TNaming_Builder DelBuilder(DeletedFaces());
159 QANewBRepNaming_Loader::LoadDeletedShapes (MS, ObjSh, TopAbs_FACE, DelBuilder);
160 QANewBRepNaming_Loader::LoadDeletedShapes (MS, ToolSh, TopAbs_FACE, DelBuilder);
161 }
162 }
163
164 LoadDegenerated(MS);
165
166 // Naming of the content:
167 if (ShapeType(ObjSh) == TopAbs_SOLID) LoadContent(MS);
168}