1 // Created by: Peter KURNEV
2 // Copyright (c) 2010-2012 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 // The content of this file is subject to the Open CASCADE Technology Public
8 // License Version 6.5 (the "License"). You may not use the content of this file
9 // except in compliance with the License. Please obtain a copy of the License
10 // at http://www.opencascade.org and read it completely before using this file.
12 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
13 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
15 // The Original Code and all software distributed under the License is
16 // distributed on an "AS IS" basis, without warranty of any kind, and the
17 // Initial Developer hereby disclaims all such warranties, including without
18 // limitation, any warranties of merchantability, fitness for a particular
19 // purpose or non-infringement. Please see the License for the specific terms
20 // and conditions governing the rights and limitations under the License.
23 #include <BOPAlgo_Builder.ixx>
25 #include <NCollection_IncAllocator.hxx>
27 #include <TopoDS_Compound.hxx>
28 #include <BRep_Builder.hxx>
31 #include <BOPTools_AlgoTools.hxx>
33 //=======================================================================
36 //=======================================================================
37 BOPAlgo_Builder::BOPAlgo_Builder()
39 BOPAlgo_BuilderShape(),
40 myArguments(myAllocator),
41 myMapFence(100, myAllocator),
46 myImages(100, myAllocator),
47 myShapesSD(100, myAllocator),
48 mySplits(100, myAllocator),
49 myOrigins(100, myAllocator),
50 myRunParallel(Standard_False)
53 //=======================================================================
56 //=======================================================================
57 BOPAlgo_Builder::BOPAlgo_Builder
58 (const Handle(NCollection_BaseAllocator)& theAllocator)
60 BOPAlgo_BuilderShape(theAllocator),
61 myArguments(myAllocator),
62 myMapFence(100, myAllocator),
67 myImages(100, myAllocator),
68 myShapesSD(100, myAllocator),
69 mySplits(100, myAllocator),
70 myOrigins(100, myAllocator),
71 myRunParallel(Standard_False)
74 //=======================================================================
77 //=======================================================================
78 BOPAlgo_Builder::~BOPAlgo_Builder()
80 if (myEntryPoint==1) {
87 //=======================================================================
90 //=======================================================================
91 void BOPAlgo_Builder::Clear()
100 //=======================================================================
101 //function : SetRunParallel
103 //=======================================================================
104 void BOPAlgo_Builder::SetRunParallel(const Standard_Boolean theFlag)
106 myRunParallel=theFlag;
108 //=======================================================================
109 //function : RunParallel
111 //=======================================================================
112 Standard_Boolean BOPAlgo_Builder::RunParallel()const
114 return myRunParallel;
116 //=======================================================================
117 //function : AddArgument
119 //=======================================================================
120 void BOPAlgo_Builder::AddArgument(const TopoDS_Shape& theShape)
122 if (myMapFence.Add(theShape)) {
123 myArguments.Append(theShape);
126 //=======================================================================
127 //function : Arguments
129 //=======================================================================
130 const BOPCol_ListOfShape& BOPAlgo_Builder::Arguments()const
134 //=======================================================================
137 //=======================================================================
138 const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Images()const
142 //=======================================================================
145 //=======================================================================
146 const BOPCol_DataMapOfShapeShape& BOPAlgo_Builder::Origins()const
151 //=======================================================================
152 //function : ShapesSd
154 //=======================================================================
155 const BOPCol_DataMapOfShapeShape& BOPAlgo_Builder::ShapesSD()const
159 //=======================================================================
162 //=======================================================================
163 const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Splits()const
167 //=======================================================================
168 //function : PPaveFiller
170 //=======================================================================
171 BOPAlgo_PPaveFiller BOPAlgo_Builder::PPaveFiller()
175 //=======================================================================
178 //=======================================================================
179 BOPDS_PDS BOPAlgo_Builder::PDS()
183 //=======================================================================
184 // function: CheckData
186 //=======================================================================
187 void BOPAlgo_Builder::CheckData()
189 Standard_Integer aNb;
193 aNb=myArguments.Extent();
195 myErrorStatus=100; // too few arguments to process
205 myErrorStatus=myPaveFiller->ErrorStatus();
207 myErrorStatus=102; // PaveFiller is failed
211 //=======================================================================
214 //=======================================================================
215 void BOPAlgo_Builder::Prepare()
222 // 1. myShape is empty compound
223 aBB.MakeCompound(aC);
225 myFlagHistory=Standard_True;
227 //=======================================================================
230 //=======================================================================
231 void BOPAlgo_Builder::Perform()
235 if (myEntryPoint==1) {
242 Handle(NCollection_BaseAllocator) aAllocator=new NCollection_IncAllocator;
244 BOPAlgo_PaveFiller* pPF=new BOPAlgo_PaveFiller(aAllocator);
246 pPF->SetArguments(myArguments);
251 PerformInternal(*pPF);
253 //=======================================================================
254 //function : PerformWithFiller
256 //=======================================================================
257 void BOPAlgo_Builder::PerformWithFiller(const BOPAlgo_PaveFiller& theFiller)
260 PerformInternal(theFiller);
262 //=======================================================================
263 //function : PerformInternal
265 //=======================================================================
266 void BOPAlgo_Builder::PerformInternal(const BOPAlgo_PaveFiller& theFiller)
270 myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller;
271 myDS=myPaveFiller->PDS();
272 myContext=myPaveFiller->Context();
288 FillImagesVertices();
293 BuildResult(TopAbs_VERTEX);
303 BuildResult(TopAbs_EDGE);
309 FillImagesContainers(TopAbs_WIRE);
314 BuildResult(TopAbs_WIRE);
325 BuildResult(TopAbs_FACE);
330 FillImagesContainers(TopAbs_SHELL);
335 BuildResult(TopAbs_SHELL);
345 BuildResult(TopAbs_SOLID);
350 FillImagesContainers(TopAbs_COMPSOLID);
355 BuildResult(TopAbs_COMPSOLID);
361 FillImagesCompounds();
366 BuildResult(TopAbs_COMPOUND);
384 //=======================================================================
385 //function : PostTreat
387 //=======================================================================
388 void BOPAlgo_Builder::PostTreat()
390 //BRepLib::SameParameter(myShape, 1.e-7, Standard_True);
391 BOPTools_AlgoTools::CorrectTolerances(myShape, 0.05);
392 BOPTools_AlgoTools::CorrectShapeTolerances(myShape);