1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: GEOMAlgo_Builder.cxx
22 // Author: Peter KURNEV
25 #include <GEOMAlgo_Builder.ixx>
27 #include <TopAbs_ShapeEnum.hxx>
29 #include <TopoDS_Shape.hxx>
30 #include <TopoDS_Compound.hxx>
31 #include <TopoDS_Iterator.hxx>
33 #include <BRep_Builder.hxx>
35 #include <TopTools_MapOfShape.hxx>
36 #include <TopTools_ListOfShape.hxx>
37 #include <TopTools_ListIteratorOfListOfShape.hxx>
39 #include <BOP_CorrectTolerances.hxx>
41 #include <BRepLib.hxx>
42 #include <NMTTools_PaveFiller.hxx>
44 //=======================================================================
47 //=======================================================================
48 GEOMAlgo_Builder::GEOMAlgo_Builder()
50 GEOMAlgo_BuilderShape()
54 myEntryPoint=0; // Entry point through PerformWithFiller ()
56 //=======================================================================
59 //=======================================================================
60 GEOMAlgo_Builder::~GEOMAlgo_Builder()
62 if (myEntryPoint==1) {
69 //=======================================================================
70 //function : AddCompound
72 //=======================================================================
73 void GEOMAlgo_Builder::AddCompound(const TopoDS_Shape& theShape)
77 aIt.Initialize(theShape);
78 for (; aIt.More(); aIt.Next()) {
79 const TopoDS_Shape& aS=aIt.Value();
83 //=======================================================================
86 //=======================================================================
87 void GEOMAlgo_Builder::AddShape(const TopoDS_Shape& theShape)
89 if (myMapFence.Add(theShape)) {
90 myShapes.Append(theShape);
93 //=======================================================================
96 //=======================================================================
97 const TopTools_ListOfShape& GEOMAlgo_Builder::Shapes()const
101 //=======================================================================
104 //=======================================================================
105 void GEOMAlgo_Builder::Clear()
110 //=======================================================================
111 //function : ClearInternals
113 //=======================================================================
114 void GEOMAlgo_Builder::ClearInternals()
118 for (i=0; i<myNbTypes; ++i){
119 myShapes1[i].Clear();
124 mySplitFaces.Clear();
125 mySameDomainShapes.Clear();
126 myDraftSolids.Clear();
129 //=======================================================================
132 //=======================================================================
133 void GEOMAlgo_Builder::Prepare()
137 Standard_Integer aNb;
140 TopTools_ListIteratorOfListOfShape aIt;
142 aNb=myShapes.Extent();
144 myErrorStatus=10; // No shapes to process
148 // 1. myShape is empty compound
149 aBB.MakeCompound(aC);
153 aIt.Initialize(myShapes);
154 for (; aIt.More(); aIt.Next()) {
155 const TopoDS_Shape& aS=aIt.Value();
159 //=======================================================================
160 //function : PostTreat
162 //=======================================================================
163 void GEOMAlgo_Builder::PostTreat()
165 Standard_Integer aNbS;
167 TopTools_ListOfShape aLS;
169 aIt.Initialize(myShape);
170 for (; aIt.More(); aIt.Next()) {
171 const TopoDS_Shape& aS=aIt.Value();
179 BRepLib::SameParameter(myShape, 1.e-7, Standard_True);
181 //=======================================================================
182 //function : AddShape1
184 //=======================================================================
185 void GEOMAlgo_Builder::AddShape1(const TopoDS_Shape& theShape)
187 Standard_Integer iType;
188 TopAbs_ShapeEnum aType;
190 TopTools_MapOfShape aM;
192 aType=theShape.ShapeType();
193 if (aType==TopAbs_COMPOUND) {
194 aIt.Initialize(theShape);
195 for (; aIt.More(); aIt.Next()) {
196 const TopoDS_Shape& aS=aIt.Value();
201 iType=(Standard_Integer)aType;
202 if (aM.Add(theShape)) {
203 myShapes1[iType].Append(theShape);
206 //=======================================================================
207 //function : BuildResult
209 //=======================================================================
210 void GEOMAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType)
214 TopAbs_ShapeEnum aType;
216 TopTools_MapOfShape aM;
217 TopTools_ListIteratorOfListOfShape aIt, aItIm;
219 aIt.Initialize(myShapes);
220 for (; aIt.More(); aIt.Next()) {
221 const TopoDS_Shape& aS=aIt.Value();
222 aType=aS.ShapeType();
223 if (aType==theType) {
224 if (myImages.HasImage(aS)){
225 const TopTools_ListOfShape& aLSIm=myImages.Image(aS);
226 aItIm.Initialize(aLSIm);
227 for (; aItIm.More(); aItIm.Next()) {
228 const TopoDS_Shape& aSIm=aItIm.Value();
230 aBB.Add(myShape, aSIm);
236 aBB.Add(myShape, aS);
242 //=======================================================================
245 //=======================================================================
246 void GEOMAlgo_Builder::Perform()
252 TopTools_ListIteratorOfListOfShape aIt;
254 aBB.MakeCompound(aCS);
256 aIt.Initialize(myShapes);
257 for (; aIt.More(); aIt.Next()) {
258 const TopoDS_Shape& aS=aIt.Value();
262 NMTTools_PaveFiller* pPF=new NMTTools_PaveFiller;
264 pPF->SetCompositeShape(aCS);
268 PerformInternal(*pPF);
270 //=======================================================================
271 //function : PerformWithFiller
273 //=======================================================================
274 void GEOMAlgo_Builder::PerformWithFiller(const NMTTools_PaveFiller& theDSF)
278 PerformInternal(theDSF);
280 //=======================================================================
281 //function : PerformInternal
283 //=======================================================================
284 void GEOMAlgo_Builder::PerformInternal(const NMTTools_PaveFiller& pPF)
288 Standard_Boolean bIsDone;
291 myPaveFiller=(NMTTools_PaveFiller *)&pPF;
293 bIsDone=myPaveFiller->IsDone();
295 myErrorStatus=2; // PaveFiller is failed
299 // 1. Clear Internal fields
311 FillImagesVertices();
316 BuildResult(TopAbs_VERTEX);
326 BuildResult(TopAbs_EDGE);
331 FillImagesContainers(TopAbs_WIRE);
336 BuildResult(TopAbs_WIRE);
347 BuildResult(TopAbs_FACE);
353 FillImagesContainers(TopAbs_SHELL);
358 BuildResult(TopAbs_SHELL);
368 BuildResult(TopAbs_SOLID);
373 FillImagesContainers(TopAbs_COMPSOLID);
378 BuildResult(TopAbs_COMPSOLID);
383 FillImagesContainers(TopAbs_COMPOUND);
388 BuildResult(TopAbs_COMPOUND);
403 // 1 - The object is just initialized
404 // 2 - PaveFiller is failed
405 // 10 - No shapes to process
406 // 30 - SolidBuilder failed