0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BRepLib / BRepLib_MakeSolid.cxx
CommitLineData
b311480e 1// Created on: 1995-01-04
2// Created by: Bruno DUMORTIER
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
7fd59977 18#include <BRep_Builder.hxx>
42cf5bc1 19#include <BRepLib_MakeSolid.hxx>
20#include <StdFail_NotDone.hxx>
7fd59977 21#include <TopExp_Explorer.hxx>
42cf5bc1 22#include <TopoDS.hxx>
23#include <TopoDS_CompSolid.hxx>
24#include <TopoDS_Face.hxx>
25#include <TopoDS_Shell.hxx>
26#include <TopoDS_Solid.hxx>
7fd59977 27#include <TopTools_ListIteratorOfListOfShape.hxx>
42cf5bc1 28#include <TopTools_MapIteratorOfMapOfShape.hxx>
29#include <TopTools_MapOfShape.hxx>
7fd59977 30
31//=======================================================================
32//function : BRepLib_MakeSolid
33//purpose :
34//=======================================================================
7fd59977 35BRepLib_MakeSolid::BRepLib_MakeSolid()
36{
37 BRep_Builder B;
38 B.MakeSolid(TopoDS::Solid(myShape));
39 Done();
40}
41
42//=======================================================================
43//function : BRepLib_MakeSolid
44//purpose :
45//=======================================================================
46
47BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_CompSolid& S)
48{
49 BRep_Builder B;
50 B.MakeSolid(TopoDS::Solid(myShape));
51
52 TopExp_Explorer ex1, ex2;
53 TopTools_MapOfShape aMapOfFaces;
54 for (ex1.Init(S,TopAbs_SHELL); ex1.More(); ex1.Next()) {
55 for (ex2.Init(ex1.Current(),TopAbs_FACE); ex2.More(); ex2.Next()) {
56 if(!aMapOfFaces.Add(ex2.Current())) {
57 myDeletedFaces.Append(ex2.Current());
58 aMapOfFaces.Remove(ex2.Current());
59 }
60 }
61 }
62
63 TopoDS_Shape aShell;
64 B.MakeShell(TopoDS::Shell(aShell));
65
66 TopTools_MapIteratorOfMapOfShape aFaceIter(aMapOfFaces);
67 for(; aFaceIter.More(); aFaceIter.Next()) {
68 B.Add(aShell, aFaceIter.Key());
69 }
ab860031 70 aShell.Closed (BRep_Tool::IsClosed (aShell));
7fd59977 71
72 B.Add(myShape,aShell);
73
74 Done();
75}
76
77
78//=======================================================================
79//function : BRepLib_MakeSolid
80//purpose :
81//=======================================================================
82
83BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Shell& S)
84{
85 BRep_Builder B;
86 B.MakeSolid(TopoDS::Solid(myShape));
87 B.Add(myShape,S);
88 Done();
89}
90
91
92//=======================================================================
93//function : BRepLib_MakeSolid
94//purpose :
95//=======================================================================
96
97BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Shell& S1, const TopoDS_Shell& S2)
98{
99 BRep_Builder B;
100 B.MakeSolid(TopoDS::Solid(myShape));
101 B.Add(myShape,S1);
102 B.Add(myShape,S2);
103 Done();
104}
105
106
107//=======================================================================
108//function : BRepLib_MakeSolid
109//purpose :
110//=======================================================================
111
112BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Shell& S1, const TopoDS_Shell& S2, const TopoDS_Shell& S3)
113{
114 BRep_Builder B;
115 B.MakeSolid(TopoDS::Solid(myShape));
116 B.Add(myShape,S1);
117 B.Add(myShape,S2);
118 B.Add(myShape,S3);
119 Done();
120}
121
122
123//=======================================================================
124//function : BRepLib_MakeSolid
125//purpose :
126//=======================================================================
127
128BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Solid& So)
129{
130 BRep_Builder B;
131 B.MakeSolid(TopoDS::Solid(myShape));
132 TopExp_Explorer ex;
133 for (ex.Init(So,TopAbs_SHELL); ex.More(); ex.Next())
134 B.Add(myShape,ex.Current());
135 Done();
136}
137
138
139//=======================================================================
140//function : BRepLib_MakeSolid
141//purpose :
142//=======================================================================
143
144BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Solid& So, const TopoDS_Shell& S)
145{
146 BRep_Builder B;
147 B.MakeSolid(TopoDS::Solid(myShape));
148 TopExp_Explorer ex;
149 for (ex.Init(So,TopAbs_SHELL); ex.More(); ex.Next())
150 B.Add(myShape,ex.Current());
151 B.Add(myShape,S);
152 Done();
153}
154
155
156//=======================================================================
157//function : Add
158//purpose :
159//=======================================================================
160
161void BRepLib_MakeSolid::Add(const TopoDS_Shell& S)
162{
163 BRep_Builder B;
164 B.Add(myShape,S);
165}
166
167
168//=======================================================================
169//function : Solid
170//purpose :
171//=======================================================================
172
173const TopoDS_Solid& BRepLib_MakeSolid::Solid()const
174{
175 return TopoDS::Solid(Shape());
176}
177
178
179
180//=======================================================================
181//function : operator
182//purpose :
183//=======================================================================
184
185BRepLib_MakeSolid::operator TopoDS_Solid() const
186{
187 return TopoDS::Solid(Shape());
188}
189
190//=======================================================================
191//function : FaceStatus
192//purpose :
193//=======================================================================
194
195BRepLib_ShapeModification BRepLib_MakeSolid::FaceStatus
196 (const TopoDS_Face& F) const
197{
198 BRepLib_ShapeModification myStatus = BRepLib_Preserved;
199 TopTools_ListIteratorOfListOfShape anIter(myDeletedFaces);
200
201 for(; anIter.More(); anIter.Next()) {
202 if(F.IsSame(anIter.Value())) {
203 myStatus = BRepLib_Deleted;
204 break;
205 }
206 }
207
208 return myStatus;
209}
210