Salome HOME
Copyrights update
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_WireSolid.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
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.
8 // 
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.
13 //
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
17 //
18 // See http://www.salome-platform.org/
19 //
20 // File:        GEOMAlgo_WireSolid.cxx
21 // Created:     Wed Jan 12 10:19:31 2005
22 // Author:      Peter KURNEV
23 //              <pkv@irinox>
24
25
26 #include <GEOMAlgo_WireSolid.ixx>
27
28 #include <Standard_Failure.hxx>
29
30 #include <TopAbs_ShapeEnum.hxx>
31
32 #include <TopTools_ListIteratorOfListOfShape.hxx>
33
34 #include <BOPTColStd_Dump.hxx>
35
36 #include <BooleanOperations_ShapesDataStructure.hxx>
37 #include <BooleanOperations_StateOfShape.hxx>
38
39 #include <BOPTools_PaveFiller.hxx>
40 #include <BOPTools_SplitShapesPool.hxx>
41 #include <BOPTools_PaveBlock.hxx>
42 #include <BOPTools_ListOfPaveBlock.hxx>
43 #include <BOPTools_DSFiller.hxx>
44 #include <BOPTools_WireStateFiller.hxx>
45
46 //=======================================================================
47 //function : GEOMAlgo_WireSolid
48 //purpose  : 
49 //=======================================================================
50 GEOMAlgo_WireSolid::GEOMAlgo_WireSolid()
51
52   GEOMAlgo_ShapeSolid()
53 {
54 }
55 //=======================================================================
56 //function : ~
57 //purpose  : 
58 //=======================================================================
59 GEOMAlgo_WireSolid::~GEOMAlgo_WireSolid()
60 {
61 }
62 //=======================================================================
63 // function: Perform
64 // purpose: 
65 //=======================================================================
66 void GEOMAlgo_WireSolid::Perform()
67 {
68   myErrorStatus=0;
69   //
70   try {
71     if (myDSFiller==NULL) {
72       myErrorStatus=10;
73       return;
74     }
75     if(!myDSFiller->IsDone()) {
76       myErrorStatus=11;
77       return;
78     }
79     //
80     Standard_Boolean bIsNewFiller;
81     //
82     bIsNewFiller=myDSFiller->IsNewFiller();
83     
84     if (bIsNewFiller) {
85       Prepare();
86       myDSFiller->SetNewFiller(!bIsNewFiller);
87     }
88     BuildResult();
89   }
90   //
91   catch (Standard_Failure) {
92     myErrorStatus= 12;
93   }
94
95 //=======================================================================
96 // function: Prepare
97 // purpose: 
98 //=======================================================================
99 void GEOMAlgo_WireSolid::Prepare()
100 {
101   const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller();
102   //
103   BOPTools_WireStateFiller aStateFiller(aPaveFiller);
104   aStateFiller.Do();
105   //
106 }
107 //=======================================================================
108 // function: BuildResult
109 // purpose: 
110 //=======================================================================
111 void GEOMAlgo_WireSolid::BuildResult()
112 {
113   const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
114   const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller();
115   const BOPTools_SplitShapesPool& aSplitShapesPool=aPaveFiller.SplitShapesPool();
116   //
117   Standard_Integer i, aNbPB, nSp, iBeg, iEnd;
118   TopAbs_ShapeEnum aType;
119   BooleanOperations_StateOfShape aState;
120   //
121   myLSIN.Clear();
122   myLSOUT.Clear();
123   myLSON.Clear();
124   //
125   iBeg=1;
126   iEnd=aDS.NumberOfShapesOfTheObject();
127   if (aDS.Tool().ShapeType()==TopAbs_WIRE) {
128     iBeg=iEnd+1;
129     iEnd=aDS.NumberOfSourceShapes();
130   }
131   //
132   for (i=iBeg; i<=iEnd; ++i) {
133     aType=aDS.GetShapeType(i);
134     if (aType==TopAbs_EDGE) {
135       const TopoDS_Shape& aE=aDS.Shape(i);
136       const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(aDS.RefEdge(i));
137       aNbPB=aLPB.Extent();
138       //
139       if (!aNbPB) {
140         aState=aDS.GetState(i);
141         //
142         if (aState==BooleanOperations_IN) {
143           myLSIN.Append(aE);
144         }
145         else if (aState==BooleanOperations_OUT) {
146           myLSOUT.Append(aE);
147         }
148         else if (aState==BooleanOperations_ON) {
149           myLSON.Append(aE);
150         }
151       }
152       //
153       else if (aNbPB==1) {
154         const BOPTools_PaveBlock& aPB=aLPB.First();
155         nSp=aPB.Edge();
156         const TopoDS_Shape& aSp=aDS.Shape(nSp);
157         aState=aDS.GetState(nSp);
158          //
159         if (aState==BooleanOperations_IN) {
160           myLSIN.Append(aE);
161         }
162         else if (aState==BooleanOperations_OUT) {
163           myLSOUT.Append(aE);
164         }
165         else if (aState==BooleanOperations_ON) {
166           myLSON.Append(aE);
167         } 
168       }
169     }
170   }
171 }