1 // Created by: Peter KURNEV
2 // Copyright (c) 2010-2014 OPEN CASCADE SAS
3 // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
5 // EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 // This file is part of Open CASCADE Technology software library.
9 // This library is free software; you can redistribute it and/or modify it under
10 // the terms of the GNU Lesser General Public License version 2.1 as published
11 // by the Free Software Foundation, with special exception defined in the file
12 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
13 // distribution for complete text of the license and disclaimer of any warranty.
15 // Alternatively, this file may be used under the terms of Open CASCADE
16 // commercial license or contractual agreement.
18 #include <BOPAlgo_Builder.ixx>
20 #include <Standard_ErrorHandler.hxx>
21 #include <Standard_Failure.hxx>
23 #include <NCollection_IncAllocator.hxx>
25 #include <TopoDS_Compound.hxx>
26 #include <BRep_Builder.hxx>
28 #include <BOPTools_AlgoTools.hxx>
30 //=======================================================================
33 //=======================================================================
34 BOPAlgo_Builder::BOPAlgo_Builder()
36 BOPAlgo_BuilderShape(),
37 myArguments(myAllocator),
38 myMapFence(100, myAllocator),
42 myImages(100, myAllocator),
43 myShapesSD(100, myAllocator),
44 mySplits(100, myAllocator),
45 myOrigins(100, myAllocator)
48 //=======================================================================
51 //=======================================================================
52 BOPAlgo_Builder::BOPAlgo_Builder
53 (const Handle(NCollection_BaseAllocator)& theAllocator)
55 BOPAlgo_BuilderShape(theAllocator),
56 myArguments(myAllocator),
57 myMapFence(100, myAllocator),
61 myImages(100, myAllocator),
62 myShapesSD(100, myAllocator),
63 mySplits(100, myAllocator),
64 myOrigins(100, myAllocator)
67 //=======================================================================
70 //=======================================================================
71 BOPAlgo_Builder::~BOPAlgo_Builder()
73 if (myEntryPoint==1) {
80 //=======================================================================
83 //=======================================================================
84 void BOPAlgo_Builder::Clear()
93 //=======================================================================
94 //function : AddArgument
96 //=======================================================================
97 void BOPAlgo_Builder::AddArgument(const TopoDS_Shape& theShape)
99 if (myMapFence.Add(theShape)) {
100 myArguments.Append(theShape);
103 //=======================================================================
104 //function : SetArguments
106 //=======================================================================
107 void BOPAlgo_Builder::SetArguments(const BOPCol_ListOfShape& theShapes)
109 BOPCol_ListIteratorOfListOfShape aIt;
111 aIt.Initialize(theShapes);
112 for (; aIt.More(); aIt.Next()) {
113 const TopoDS_Shape& aS = aIt.Value();
117 //=======================================================================
118 //function : Arguments
120 //=======================================================================
121 const BOPCol_ListOfShape& BOPAlgo_Builder::Arguments()const
125 //=======================================================================
128 //=======================================================================
129 const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Images()const
133 //=======================================================================
136 //=======================================================================
137 const BOPCol_DataMapOfShapeShape& BOPAlgo_Builder::Origins()const
142 //=======================================================================
143 //function : ShapesSd
145 //=======================================================================
146 const BOPCol_DataMapOfShapeShape& BOPAlgo_Builder::ShapesSD()const
150 //=======================================================================
153 //=======================================================================
154 const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Splits()const
158 //=======================================================================
159 //function : PPaveFiller
161 //=======================================================================
162 BOPAlgo_PPaveFiller BOPAlgo_Builder::PPaveFiller()
166 //=======================================================================
169 //=======================================================================
170 BOPDS_PDS BOPAlgo_Builder::PDS()
174 //=======================================================================
175 // function: CheckData
177 //=======================================================================
178 void BOPAlgo_Builder::CheckData()
180 Standard_Integer aNb;
184 aNb=myArguments.Extent();
186 myErrorStatus=100; // too few arguments to process
196 myErrorStatus=myPaveFiller->ErrorStatus();
198 myErrorStatus=102; // PaveFiller is failed
202 //=======================================================================
205 //=======================================================================
206 void BOPAlgo_Builder::Prepare()
213 // 1. myShape is empty compound
214 aBB.MakeCompound(aC);
216 myFlagHistory=Standard_True;
218 //=======================================================================
221 //=======================================================================
222 void BOPAlgo_Builder::Perform()
226 if (myEntryPoint==1) {
233 Handle(NCollection_BaseAllocator) aAllocator=new NCollection_IncAllocator;
235 BOPAlgo_PaveFiller* pPF=new BOPAlgo_PaveFiller(aAllocator);
237 pPF->SetArguments(myArguments);
238 pPF->SetRunParallel(myRunParallel);
243 PerformInternal(*pPF);
245 //=======================================================================
246 //function : PerformWithFiller
248 //=======================================================================
249 void BOPAlgo_Builder::PerformWithFiller(const BOPAlgo_PaveFiller& theFiller)
252 PerformInternal(theFiller);
254 //=======================================================================
255 //function : PerformInternal
257 //=======================================================================
258 void BOPAlgo_Builder::PerformInternal(const BOPAlgo_PaveFiller& theFiller)
262 PerformInternal1(theFiller);
265 catch (Standard_Failure) {
269 //=======================================================================
270 //function : PerformInternal1
272 //=======================================================================
273 void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller)
277 myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller;
278 myDS=myPaveFiller->PDS();
279 myContext=myPaveFiller->Context();
295 FillImagesVertices();
300 BuildResult(TopAbs_VERTEX);
310 BuildResult(TopAbs_EDGE);
316 FillImagesContainers(TopAbs_WIRE);
321 BuildResult(TopAbs_WIRE);
332 BuildResult(TopAbs_FACE);
337 FillImagesContainers(TopAbs_SHELL);
342 BuildResult(TopAbs_SHELL);
352 BuildResult(TopAbs_SOLID);
357 FillImagesContainers(TopAbs_COMPSOLID);
362 BuildResult(TopAbs_COMPSOLID);
368 FillImagesCompounds();
373 BuildResult(TopAbs_COMPOUND);
391 //=======================================================================
392 //function : PostTreat
394 //=======================================================================
395 void BOPAlgo_Builder::PostTreat()
397 BOPTools_AlgoTools::CorrectTolerances(myShape, 0.05, myRunParallel);
398 BOPTools_AlgoTools::CorrectShapeTolerances(myShape, myRunParallel);