1 // Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: GEOMAlgo_ShellSolid.cxx
24 // Created: Wed Jan 12 12:49:45 2005
25 // Author: Peter KURNEV
28 #include <GEOMAlgo_ShellSolid.hxx>
30 #include <Standard_Failure.hxx>
32 #include <gp_Pnt2d.hxx>
37 #include <TopoDS_Face.hxx>
38 #include <TopoDS_Edge.hxx>
39 #include <TopoDS_Shape.hxx>
40 #include <TopoDS_Solid.hxx>
42 #include <BRep_Tool.hxx>
43 #include <BRepTools.hxx>
45 #include <TopTools_ListOfShape.hxx>
46 #include <TopTools_ListIteratorOfListOfShape.hxx>
47 #include <TopExp_Explorer.hxx>
49 #include <BOPTools_AlgoTools.hxx>
51 #include <TopTools_DataMapOfShapeListOfShape.hxx>
52 #include <TopTools_ListOfShape.hxx>
53 #include <IntTools_Context.hxx>
54 #include <BOPDS_DS.hxx>
55 #include <BOPAlgo_Builder.hxx>
57 #include <GEOMAlgo_AlgoTools.hxx>
59 #include <Basics_OCCTVersion.hxx>
61 /////////////////////////////////////////////////////////////////////////
62 //=======================================================================
63 //class : GEOMAlgo_ShellSolidBuilder
65 //=======================================================================
66 class GEOMAlgo_ShellSolidBuilder : public BOPAlgo_Builder {
69 GEOMAlgo_ShellSolidBuilder();
72 virtual ~GEOMAlgo_ShellSolidBuilder();
76 #if OCC_VERSION_LARGE < 0x07070000
77 virtual void PerformInternal(const BOPAlgo_PaveFiller& theFiller);
79 virtual void PerformInternal(const BOPAlgo_PaveFiller& theFiller,
80 const Message_ProgressRange& theRange);
84 //=======================================================================
85 //function : GEOMAlgo_ShellSolidBuilder
87 //=======================================================================
88 GEOMAlgo_ShellSolidBuilder::GEOMAlgo_ShellSolidBuilder()
93 //=======================================================================
94 //function : ~GEOMAlgo_ShellSolidBuilder
96 //=======================================================================
97 GEOMAlgo_ShellSolidBuilder::~GEOMAlgo_ShellSolidBuilder()
100 //=======================================================================
101 //function : PerformInternal
103 //=======================================================================
104 #if OCC_VERSION_LARGE < 0x07070000
105 void GEOMAlgo_ShellSolidBuilder::PerformInternal(const BOPAlgo_PaveFiller& theFiller)
107 void GEOMAlgo_ShellSolidBuilder::PerformInternal(const BOPAlgo_PaveFiller& theFiller,
108 const Message_ProgressRange& theRange)
111 myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller;
112 myDS=myPaveFiller->PDS();
113 myContext=myPaveFiller->Context();
127 #if OCC_VERSION_LARGE >= 0x07070000
128 Message_ProgressScope aPS(theRange, "Building the result of Boolean operation", 100);
130 BOPAlgo_PISteps aSteps (PIOperation_Last);
131 analyzeProgress (100, aSteps);
136 #if OCC_VERSION_LARGE < 0x07070000
137 FillImagesVertices();
139 FillImagesVertices(aPS.Next(aSteps.GetStep(PIOperation_TreatVertices)));
145 BuildResult(TopAbs_VERTEX);
150 #if OCC_VERSION_LARGE < 0x07070000
153 FillImagesEdges(aPS.Next(aSteps.GetStep(PIOperation_TreatEdges)));
159 BuildResult(TopAbs_EDGE);
165 #if OCC_VERSION_LARGE < 0x07070000
166 FillImagesContainers(TopAbs_WIRE);
168 FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps.GetStep(PIOperation_TreatWires)));
174 BuildResult(TopAbs_WIRE);
180 #if OCC_VERSION_LARGE < 0x07070000
183 FillImagesFaces(aPS.Next(aSteps.GetStep(PIOperation_TreatFaces)));
189 BuildResult(TopAbs_FACE);
194 /////////////////////////////////////////////////////////////////////////
195 //=======================================================================
196 //function : GEOMAlgo_ShellSolid
198 //=======================================================================
199 GEOMAlgo_ShellSolid::GEOMAlgo_ShellSolid()
201 GEOMAlgo_ShapeSolid()
204 //=======================================================================
207 //=======================================================================
208 GEOMAlgo_ShellSolid::~GEOMAlgo_ShellSolid()
211 //=======================================================================
214 //=======================================================================
215 void GEOMAlgo_ShellSolid::Perform()
219 Standard_Integer aNbArgs, iRank, iErr, iBeg, iEnd, i, aNbSp;
221 TopAbs_ShapeEnum aType;
233 if (myDSFiller==NULL) {
237 if(myDSFiller->HasErrors()) {
242 const BOPDS_DS& aDS=myDSFiller->DS();
243 BOPDS_DS* pDS=(BOPDS_DS*)&aDS;
244 const TopTools_ListOfShape& aLS=pDS->Arguments();
246 aNbArgs=aLS.Extent();
253 const TopoDS_Shape& aObj=aLS.First();
254 if (aObj.ShapeType()==TopAbs_SHELL) {
257 const TopoDS_Shape& aTool=aLS.Last();
258 if (aTool.ShapeType()==TopAbs_SHELL) {
267 Handle(IntTools_Context) aCtx=myDSFiller->Context();
268 const BOPDS_IndexRange& aRange=pDS->Range(iRank);
269 aRange.Indices(iBeg, iEnd);
270 const TopoDS_Solid& aSolid=(!iRank) ? *((TopoDS_Solid*)&aTool) : *((TopoDS_Solid*)&aObj);
271 //BRepClass3d_SolidClassifier& aSC=aCtx->SolidClassifier(aSolid);
273 //------------------------------ShellSolidBuilder
274 GEOMAlgo_ShellSolidBuilder aSSB;
276 aSSB.PerformWithFiller(*myDSFiller);
277 iErr=aSSB.HasErrors();
283 const TopTools_DataMapOfShapeListOfShape& aImages=aSSB.Images();
285 //-------------------------------
286 for (i=iBeg; i<=iEnd; ++i) {
287 const TopoDS_Shape& aS=pDS->Shape(i);
288 aType=aS.ShapeType();
289 if (aType!=TopAbs_FACE) {
293 aState=TopAbs_UNKNOWN;
294 aF=*((TopoDS_Face*)&aS);
296 if (!aImages.IsBound(aS)) {
297 iErr=GEOMAlgo_AlgoTools::PntInFace(aF, aP, aP2D);
303 aState=BOPTools_AlgoTools::ComputeState(aP, aSolid, aTol, aCtx);
306 const TopTools_ListOfShape& aLSp=aImages.Find(aS);
313 aF=*((TopoDS_Face*)&aLSp.First());
316 iErr=GEOMAlgo_AlgoTools::PntInFace(aF, aP, aP2D);
322 aState=BOPTools_AlgoTools::ComputeState(aP, aSolid, aTol, aCtx);
325 if (aState==TopAbs_ON) {
328 else if (aState==TopAbs_OUT) {
331 else if (aState==TopAbs_IN) {
335 }//for (i=iBeg; i<=iEnd; ++i) {
338 catch (Standard_Failure&) {