1 // Created on: 1995-01-04
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <BRepLib_MakeSolid.ixx>
20 #include <BRep_Builder.hxx>
21 #include <TopExp_Explorer.hxx>
22 #include <TopTools_MapOfShape.hxx>
23 #include <TopTools_MapIteratorOfMapOfShape.hxx>
24 #include <TopTools_ListIteratorOfListOfShape.hxx>
26 //=======================================================================
27 //function : BRepLib_MakeSolid
29 //=======================================================================
31 BRepLib_MakeSolid::BRepLib_MakeSolid()
34 B.MakeSolid(TopoDS::Solid(myShape));
38 //=======================================================================
39 //function : BRepLib_MakeSolid
41 //=======================================================================
43 BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_CompSolid& S)
46 B.MakeSolid(TopoDS::Solid(myShape));
48 TopExp_Explorer ex1, ex2;
49 TopTools_MapOfShape aMapOfFaces;
50 for (ex1.Init(S,TopAbs_SHELL); ex1.More(); ex1.Next()) {
51 for (ex2.Init(ex1.Current(),TopAbs_FACE); ex2.More(); ex2.Next()) {
52 if(!aMapOfFaces.Add(ex2.Current())) {
53 myDeletedFaces.Append(ex2.Current());
54 aMapOfFaces.Remove(ex2.Current());
60 B.MakeShell(TopoDS::Shell(aShell));
62 TopTools_MapIteratorOfMapOfShape aFaceIter(aMapOfFaces);
63 for(; aFaceIter.More(); aFaceIter.Next()) {
64 B.Add(aShell, aFaceIter.Key());
66 aShell.Closed (BRep_Tool::IsClosed (aShell));
68 B.Add(myShape,aShell);
74 //=======================================================================
75 //function : BRepLib_MakeSolid
77 //=======================================================================
79 BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Shell& S)
82 B.MakeSolid(TopoDS::Solid(myShape));
88 //=======================================================================
89 //function : BRepLib_MakeSolid
91 //=======================================================================
93 BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Shell& S1, const TopoDS_Shell& S2)
96 B.MakeSolid(TopoDS::Solid(myShape));
103 //=======================================================================
104 //function : BRepLib_MakeSolid
106 //=======================================================================
108 BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Shell& S1, const TopoDS_Shell& S2, const TopoDS_Shell& S3)
111 B.MakeSolid(TopoDS::Solid(myShape));
119 //=======================================================================
120 //function : BRepLib_MakeSolid
122 //=======================================================================
124 BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Solid& So)
127 B.MakeSolid(TopoDS::Solid(myShape));
129 for (ex.Init(So,TopAbs_SHELL); ex.More(); ex.Next())
130 B.Add(myShape,ex.Current());
135 //=======================================================================
136 //function : BRepLib_MakeSolid
138 //=======================================================================
140 BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Solid& So, const TopoDS_Shell& S)
143 B.MakeSolid(TopoDS::Solid(myShape));
145 for (ex.Init(So,TopAbs_SHELL); ex.More(); ex.Next())
146 B.Add(myShape,ex.Current());
152 //=======================================================================
155 //=======================================================================
157 void BRepLib_MakeSolid::Add(const TopoDS_Shell& S)
164 //=======================================================================
167 //=======================================================================
169 const TopoDS_Solid& BRepLib_MakeSolid::Solid()const
171 return TopoDS::Solid(Shape());
176 //=======================================================================
177 //function : operator
179 //=======================================================================
181 BRepLib_MakeSolid::operator TopoDS_Solid() const
183 return TopoDS::Solid(Shape());
186 //=======================================================================
187 //function : FaceStatus
189 //=======================================================================
191 BRepLib_ShapeModification BRepLib_MakeSolid::FaceStatus
192 (const TopoDS_Face& F) const
194 BRepLib_ShapeModification myStatus = BRepLib_Preserved;
195 TopTools_ListIteratorOfListOfShape anIter(myDeletedFaces);
197 for(; anIter.More(); anIter.Next()) {
198 if(F.IsSame(anIter.Value())) {
199 myStatus = BRepLib_Deleted;