1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: GEOMAlgo_Splitter.cxx
22 // Author: Peter KURNEV
25 #include <GEOMAlgo_Splitter.ixx>
27 #include <TopAbs_ShapeEnum.hxx>
29 #include <TopoDS_Shape.hxx>
30 #include <TopoDS_Compound.hxx>
31 #include <TopoDS_Iterator.hxx>
35 #include <BRep_Builder.hxx>
36 #include <BRepLib.hxx>
38 #include <TopTools_MapOfShape.hxx>
39 #include <TopTools_ListOfShape.hxx>
40 #include <TopTools_ListIteratorOfListOfShape.hxx>
41 #include <TopTools_IndexedMapOfShape.hxx>
43 #include <BOP_CorrectTolerances.hxx>
45 #include <NMTTools_DSFiller.hxx>
47 //=======================================================================
50 //=======================================================================
51 GEOMAlgo_Splitter::GEOMAlgo_Splitter()
57 //=======================================================================
60 //=======================================================================
61 GEOMAlgo_Splitter::~GEOMAlgo_Splitter()
64 //=======================================================================
65 //function : AddToolCompound
67 //=======================================================================
68 void GEOMAlgo_Splitter::AddToolCompound(const TopoDS_Shape& theShape)
72 aIt.Initialize(theShape);
73 for (; aIt.More(); aIt.Next()) {
74 const TopoDS_Shape& aS=aIt.Value();
78 //=======================================================================
81 //=======================================================================
82 void GEOMAlgo_Splitter::AddTool(const TopoDS_Shape& theShape)
84 if (myMapTools.Add(theShape)) {
85 myTools.Append(theShape);
90 //=======================================================================
93 //=======================================================================
94 const TopTools_ListOfShape& GEOMAlgo_Splitter::Tools()const
98 //=======================================================================
101 //=======================================================================
102 void GEOMAlgo_Splitter::SetLimit(const TopAbs_ShapeEnum aLimit)
106 //=======================================================================
109 //=======================================================================
110 TopAbs_ShapeEnum GEOMAlgo_Splitter::Limit()const
114 //=======================================================================
117 //=======================================================================
118 void GEOMAlgo_Splitter::Clear()
122 myLimit=TopAbs_SHAPE;
123 GEOMAlgo_Builder::Clear();
125 //=======================================================================
126 //function : BuildResult
128 //=======================================================================
129 void GEOMAlgo_Splitter::BuildResult(const TopAbs_ShapeEnum theType)
133 TopAbs_ShapeEnum aType;
135 TopTools_MapOfShape aM;
136 TopTools_ListIteratorOfListOfShape aIt, aItIm;
138 aIt.Initialize(myShapes);
139 for (; aIt.More(); aIt.Next()) {
140 const TopoDS_Shape& aS=aIt.Value();
141 aType=aS.ShapeType();
142 if (aType==theType && !myMapTools.Contains(aS)) {
143 if (myImages.HasImage(aS)) {
144 const TopTools_ListOfShape& aLSIm=myImages.Image(aS);
145 aItIm.Initialize(aLSIm);
146 for (; aItIm.More(); aItIm.Next()) {
147 const TopoDS_Shape& aSIm=aItIm.Value();
149 aBB.Add(myShape, aSIm);
155 aBB.Add(myShape, aS);
161 //=======================================================================
162 //function : PostTreat
164 //=======================================================================
165 void GEOMAlgo_Splitter::PostTreat()
167 if (myLimit!=TopAbs_SHAPE) {
168 Standard_Integer i, aNbS;
171 TopTools_IndexedMapOfShape aM;
173 aBB.MakeCompound(aC);
175 TopExp::MapShapes(myShape, myLimit, aM);
177 for (i=1; i<=aNbS; ++i) {
178 const TopoDS_Shape& aS=aM(i);
184 GEOMAlgo_Builder::PostTreat();
191 // 1 - The object is just initialized
192 // 2 - DSFiller is failed
193 // 10 - No shapes to process
194 // 30 - SolidBuilder failed