1 // Copyright (C) 2007-2016 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 <Basics_OCCTVersion.hxx>
32 #include <Standard_Failure.hxx>
34 #include <gp_Pnt2d.hxx>
39 #include <TopoDS_Face.hxx>
40 #include <TopoDS_Edge.hxx>
41 #include <TopoDS_Shape.hxx>
42 #include <TopoDS_Solid.hxx>
44 #include <BRep_Tool.hxx>
45 #include <BRepTools.hxx>
47 #include <TopTools_ListOfShape.hxx>
48 #include <TopTools_ListIteratorOfListOfShape.hxx>
49 #include <TopExp_Explorer.hxx>
51 #include <BOPTools_AlgoTools.hxx>
53 #include <BOPCol_DataMapOfShapeListOfShape.hxx>
54 #include <BOPCol_ListOfShape.hxx>
55 #if OCC_VERSION_LARGE > 0x06070100
56 #include <IntTools_Context.hxx>
58 #include <BOPInt_Context.hxx>
60 #include <BOPDS_DS.hxx>
61 #include <BOPAlgo_Builder.hxx>
63 #include <GEOMAlgo_AlgoTools.hxx>
64 /////////////////////////////////////////////////////////////////////////
65 //=======================================================================
66 //class : GEOMAlgo_ShellSolidBuilder
68 //=======================================================================
69 class GEOMAlgo_ShellSolidBuilder : public BOPAlgo_Builder {
72 GEOMAlgo_ShellSolidBuilder();
75 virtual ~GEOMAlgo_ShellSolidBuilder();
79 virtual void PerformInternal(const BOPAlgo_PaveFiller& theFiller);
82 //=======================================================================
83 //function : GEOMAlgo_ShellSolidBuilder
85 //=======================================================================
86 GEOMAlgo_ShellSolidBuilder::GEOMAlgo_ShellSolidBuilder()
91 //=======================================================================
92 //function : ~GEOMAlgo_ShellSolidBuilder
94 //=======================================================================
95 GEOMAlgo_ShellSolidBuilder::~GEOMAlgo_ShellSolidBuilder()
98 //=======================================================================
99 //function : PerformInternal
101 //=======================================================================
102 void GEOMAlgo_ShellSolidBuilder::PerformInternal(const BOPAlgo_PaveFiller& theFiller)
104 #if OCC_VERSION_LARGE <= 0x07010000
108 myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller;
109 myDS=myPaveFiller->PDS();
110 myContext=myPaveFiller->Context();
114 #if OCC_VERSION_LARGE > 0x07010000
124 #if OCC_VERSION_LARGE > 0x07010000
134 FillImagesVertices();
135 #if OCC_VERSION_LARGE > 0x07010000
143 BuildResult(TopAbs_VERTEX);
144 #if OCC_VERSION_LARGE > 0x07010000
153 #if OCC_VERSION_LARGE > 0x07010000
161 BuildResult(TopAbs_EDGE);
162 #if OCC_VERSION_LARGE > 0x07010000
171 FillImagesContainers(TopAbs_WIRE);
172 #if OCC_VERSION_LARGE > 0x07010000
180 BuildResult(TopAbs_WIRE);
181 #if OCC_VERSION_LARGE > 0x07010000
191 #if OCC_VERSION_LARGE > 0x07010000
199 BuildResult(TopAbs_FACE);
200 #if OCC_VERSION_LARGE > 0x07010000
208 /////////////////////////////////////////////////////////////////////////
209 //=======================================================================
210 //function : GEOMAlgo_ShellSolid
212 //=======================================================================
213 GEOMAlgo_ShellSolid::GEOMAlgo_ShellSolid()
215 GEOMAlgo_ShapeSolid()
218 //=======================================================================
221 //=======================================================================
222 GEOMAlgo_ShellSolid::~GEOMAlgo_ShellSolid()
225 //=======================================================================
228 //=======================================================================
229 void GEOMAlgo_ShellSolid::Perform()
231 #if OCC_VERSION_LARGE <= 0x07010000
236 Standard_Integer aNbArgs, iRank, iErr, iBeg, iEnd, i, aNbSp;
238 TopAbs_ShapeEnum aType;
250 if (myDSFiller==NULL) {
254 #if OCC_VERSION_LARGE > 0x07010000
255 if(myDSFiller->HasErrors()) {
257 if(myDSFiller->ErrorStatus()) {
263 const BOPDS_DS& aDS=myDSFiller->DS();
264 BOPDS_DS* pDS=(BOPDS_DS*)&aDS;
265 const BOPCol_ListOfShape& aLS=pDS->Arguments();
267 aNbArgs=aLS.Extent();
274 const TopoDS_Shape& aObj=aLS.First();
275 if (aObj.ShapeType()==TopAbs_SHELL) {
278 const TopoDS_Shape& aTool=aLS.Last();
279 if (aTool.ShapeType()==TopAbs_SHELL) {
288 #if OCC_VERSION_LARGE > 0x06070100
289 Handle(IntTools_Context) aCtx=myDSFiller->Context();
291 Handle(BOPInt_Context) aCtx=myDSFiller->Context();
293 const BOPDS_IndexRange& aRange=pDS->Range(iRank);
294 aRange.Indices(iBeg, iEnd);
295 const TopoDS_Solid& aSolid=(!iRank) ? *((TopoDS_Solid*)&aTool) : *((TopoDS_Solid*)&aObj);
296 //BRepClass3d_SolidClassifier& aSC=aCtx->SolidClassifier(aSolid);
298 //------------------------------ShellSolidBuilder
299 GEOMAlgo_ShellSolidBuilder aSSB;
301 aSSB.PerformWithFiller(*myDSFiller);
302 #if OCC_VERSION_LARGE > 0x07010000
303 iErr=aSSB.HasErrors();
305 iErr=aSSB.ErrorStatus();
312 const BOPCol_DataMapOfShapeListOfShape& aImages=aSSB.Images();
314 //-------------------------------
315 for (i=iBeg; i<=iEnd; ++i) {
316 const TopoDS_Shape& aS=pDS->Shape(i);
317 aType=aS.ShapeType();
318 if (aType!=TopAbs_FACE) {
322 aState=TopAbs_UNKNOWN;
323 aF=*((TopoDS_Face*)&aS);
325 if (!aImages.IsBound(aS)) {
326 iErr=GEOMAlgo_AlgoTools::PntInFace(aF, aP, aP2D);
332 aState=BOPTools_AlgoTools::ComputeState(aP, aSolid, aTol, aCtx);
335 const BOPCol_ListOfShape& aLSp=aImages.Find(aS);
342 aF=*((TopoDS_Face*)&aLSp.First());
345 iErr=GEOMAlgo_AlgoTools::PntInFace(aF, aP, aP2D);
351 aState=BOPTools_AlgoTools::ComputeState(aP, aSolid, aTol, aCtx);
354 if (aState==TopAbs_ON) {
357 else if (aState==TopAbs_OUT) {
360 else if (aState==TopAbs_IN) {
364 }//for (i=iBeg; i<=iEnd; ++i) {
367 catch (Standard_Failure) {