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)
52 //=======================================================================
55 //=======================================================================
56 BOPAlgo_Builder::BOPAlgo_Builder(const Handle(NCollection_BaseAllocator)& theAllocator)
58 BOPAlgo_BuilderShape(theAllocator),
59 myArguments(myAllocator),
60 myMapFence(100, myAllocator),
65 myImages(100, myAllocator),
66 myShapesSD(100, myAllocator),
67 mySplits(100, myAllocator),
68 myOrigins(100, myAllocator)
71 //=======================================================================
74 //=======================================================================
75 BOPAlgo_Builder::~BOPAlgo_Builder()
77 if (myEntryPoint==1) {
84 //=======================================================================
87 //=======================================================================
88 void BOPAlgo_Builder::Clear()
97 //=======================================================================
98 //function : AddArgument
100 //=======================================================================
101 void BOPAlgo_Builder::AddArgument(const TopoDS_Shape& theShape)
103 if (myMapFence.Add(theShape)) {
104 myArguments.Append(theShape);
107 //=======================================================================
108 //function : Arguments
110 //=======================================================================
111 const BOPCol_ListOfShape& BOPAlgo_Builder::Arguments()const
115 //=======================================================================
118 //=======================================================================
119 const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Images()const
123 //=======================================================================
126 //=======================================================================
127 const BOPCol_DataMapOfShapeShape& BOPAlgo_Builder::Origins()const
132 //=======================================================================
133 //function : ShapesSd
135 //=======================================================================
136 const BOPCol_DataMapOfShapeShape& BOPAlgo_Builder::ShapesSD()const
140 //=======================================================================
143 //=======================================================================
144 const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Splits()const
148 //=======================================================================
149 //function : PPaveFiller
151 //=======================================================================
152 BOPAlgo_PPaveFiller BOPAlgo_Builder::PPaveFiller()
156 //=======================================================================
159 //=======================================================================
160 BOPDS_PDS BOPAlgo_Builder::PDS()
164 //=======================================================================
165 // function: CheckData
167 //=======================================================================
168 void BOPAlgo_Builder::CheckData()
170 Standard_Integer aNb;
174 aNb=myArguments.Extent();
176 myErrorStatus=100; // too few arguments to process
186 myErrorStatus=myPaveFiller->ErrorStatus();
188 myErrorStatus=102; // PaveFiller is failed
192 //=======================================================================
195 //=======================================================================
196 void BOPAlgo_Builder::Prepare()
203 // 1. myShape is empty compound
204 aBB.MakeCompound(aC);
206 myFlagHistory=Standard_True;
208 //=======================================================================
211 //=======================================================================
212 void BOPAlgo_Builder::Perform()
216 if (myEntryPoint==1) {
223 Handle(NCollection_BaseAllocator) aAllocator=new NCollection_IncAllocator;
225 BOPAlgo_PaveFiller* pPF=new BOPAlgo_PaveFiller(aAllocator);
227 pPF->SetArguments(myArguments);
232 PerformInternal(*pPF);
234 //=======================================================================
235 //function : PerformWithFiller
237 //=======================================================================
238 void BOPAlgo_Builder::PerformWithFiller(const BOPAlgo_PaveFiller& theFiller)
241 PerformInternal(theFiller);
243 //=======================================================================
244 //function : PerformInternal
246 //=======================================================================
247 void BOPAlgo_Builder::PerformInternal(const BOPAlgo_PaveFiller& theFiller)
251 myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller;
252 myDS=myPaveFiller->PDS();
253 myContext=myPaveFiller->Context();
269 FillImagesVertices();
274 BuildResult(TopAbs_VERTEX);
284 BuildResult(TopAbs_EDGE);
290 FillImagesContainers(TopAbs_WIRE);
295 BuildResult(TopAbs_WIRE);
306 BuildResult(TopAbs_FACE);
311 FillImagesContainers(TopAbs_SHELL);
316 BuildResult(TopAbs_SHELL);
326 BuildResult(TopAbs_SOLID);
331 FillImagesContainers(TopAbs_COMPSOLID);
336 BuildResult(TopAbs_COMPSOLID);
342 FillImagesCompounds();
347 BuildResult(TopAbs_COMPOUND);
365 //=======================================================================
366 //function : PostTreat
368 //=======================================================================
369 void BOPAlgo_Builder::PostTreat()
371 //BRepLib::SameParameter(myShape, 1.e-7, Standard_True);
372 BOPTools_AlgoTools::CorrectTolerances(myShape, 0.05);
373 BOPTools_AlgoTools::CorrectShapeTolerances(myShape);