1 // Copyright (C) 2007-2014 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_WireSolid.cxx
24 // Created: Wed Jan 12 10:19:31 2005
25 // Author: Peter KURNEV
28 #include <GEOMAlgo_WireSolid.hxx>
30 #include <Basics_OCCTVersion.hxx>
32 #include <Standard_Failure.hxx>
34 #include <TopAbs_ShapeEnum.hxx>
36 #include <TopTools_ListIteratorOfListOfShape.hxx>
38 #include <BOPDS_DS.hxx>
39 #include <BOPDS_IndexRange.hxx>
40 #include <BOPDS_ListOfPaveBlock.hxx>
41 #include <BOPDS_PaveBlock.hxx>
42 #include <TopoDS_Solid.hxx>
43 #if OCC_VERSION_LARGE > 0x06070100
44 #include <IntTools_Context.hxx>
46 #include <BOPInt_Context.hxx>
48 #include <BRepClass3d_SolidClassifier.hxx>
49 #include <BRep_Tool.hxx>
50 #include <BOPTools_AlgoTools.hxx>
52 #include <Basics_OCCTVersion.hxx>
54 //=======================================================================
55 //function : GEOMAlgo_WireSolid
57 //=======================================================================
58 GEOMAlgo_WireSolid::GEOMAlgo_WireSolid()
63 //=======================================================================
66 //=======================================================================
67 GEOMAlgo_WireSolid::~GEOMAlgo_WireSolid()
70 //=======================================================================
73 //=======================================================================
74 void GEOMAlgo_WireSolid::Perform()
79 if (myDSFiller==NULL) {
83 if(myDSFiller->ErrorStatus()) {
88 Standard_Integer aNbArgs;
90 const BOPDS_DS& aDS=myDSFiller->DS();
91 const BOPCol_ListOfShape& aLS=aDS.Arguments();
101 catch (Standard_Failure) {
105 //=======================================================================
106 // function: BuildResult
108 //=======================================================================
109 void GEOMAlgo_WireSolid::BuildResult()
111 Standard_Boolean bHasPaveBlocks;
112 Standard_Integer i, iRank, aNbPB, iBeg, iEnd, aNbArgs, nE;// nSp
114 TopAbs_ShapeEnum aType;
123 const BOPDS_DS& aDS=myDSFiller->DS();
124 BOPDS_DS* pDS=(BOPDS_DS*)&aDS;
126 const BOPCol_ListOfShape& aLS=pDS->Arguments();
127 aNbArgs=aLS.Extent();
134 const TopoDS_Shape& aObj=aLS.First();
135 if (aObj.ShapeType()==TopAbs_WIRE) {
138 const TopoDS_Shape& aTool=aLS.Last();
139 if (aTool.ShapeType()==TopAbs_WIRE) {
150 const TopoDS_Solid& aSolid=(iRank==0) ? *((TopoDS_Solid*)&aTool) :
151 *((TopoDS_Solid*)&aObj);
153 #if OCC_VERSION_LARGE > 0x06070100
154 Handle(IntTools_Context) aCtx=myDSFiller->Context();
156 Handle(BOPInt_Context) aCtx=myDSFiller->Context();
158 //BRepClass3d_SolidClassifier& aSC=aCtx->SolidClassifier(aSolid);
160 const BOPDS_IndexRange& aRange=pDS->Range(iRank);
161 aRange.Indices(iBeg, iEnd);
163 for (i=iBeg; i<=iEnd; ++i) {
164 const TopoDS_Shape& aS=pDS->Shape(i);
165 aType=aS.ShapeType();
166 if (aType!=TopAbs_EDGE) {
170 aE=*((TopoDS_Edge*)&pDS->Shape(i));
171 if (BRep_Tool::Degenerated(aE)) {
175 bHasPaveBlocks=pDS->HasPaveBlocks(i);
176 if (!bHasPaveBlocks) {
180 aState=TopAbs_UNKNOWN;
182 const BOPDS_ListOfPaveBlock& aLPB=pDS->PaveBlocks(i);
185 aState=BOPTools_AlgoTools::ComputeStateByOnePoint(aE, aSolid, aTol, aCtx);
188 const Handle(BOPDS_PaveBlock)& aPB=aLPB.First();
189 #if OCC_VERSION_LARGE > 0x06060000 // Porting to OCCT higher 6.6.0 version
190 if (pDS->IsCommonBlock(aPB)) {
192 if (aPB->IsCommonBlock()) {
198 aE=*((TopoDS_Edge*)&pDS->Shape(nE));
199 aState=BOPTools_AlgoTools::ComputeStateByOnePoint(aE, aSolid, aTol, aCtx);
202 if (aState==TopAbs_ON) {
205 else if (aState==TopAbs_OUT) {
208 else if (aState==TopAbs_IN) {