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_Builder_4.cxx
22 // Author: Peter KURNEV
24 #include <GEOMAlgo_Builder.hxx>
26 #include <TopoDS_Iterator.hxx>
28 #include <TopTools_ListOfShape.hxx>
29 #include <TopTools_ListIteratorOfListOfShape.hxx>
30 #include <TopTools_MapOfShape.hxx>
31 #include <TopTools_MapIteratorOfMapOfShape.hxx>
33 #include <IntTools_Context.hxx>
35 #include <NMTDS_ShapesDataStructure.hxx>
37 #include <NMTTools_PaveFiller.hxx>
38 #include <NMTTools_DSFiller.hxx>
40 #include <GEOMAlgo_Tools3D.hxx>
44 void MapShapes(const TopoDS_Shape& aS,
45 TopTools_MapOfShape& aM);
47 //=======================================================================
48 //function : Generated
50 //=======================================================================
51 const TopTools_ListOfShape& GEOMAlgo_Builder::Generated(const TopoDS_Shape& theS)
53 const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS();
54 NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller());
55 IntTools_Context& aCtx=pPF->ChangeContext();
57 Standard_Boolean bHasImage, bToReverse;
58 TopAbs_ShapeEnum aType;
59 TopTools_ListIteratorOfListOfShape aIt;
67 bHasImage=myImages.HasImage(theS);
72 aType=theS.ShapeType();
74 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
75 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
76 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
78 for (; aIt.More(); aIt.Next()) {
79 const TopoDS_Shape& aSp=aIt.Value();
80 if (mySameDomainShapes.Contains(aSp)) {
81 if (myMapShape.Contains(aSp)) {
82 TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
84 if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
85 aSpR.Orientation(theS.Orientation());
88 bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSpR, theS, aCtx);
94 myHistShapes.Append(aSpR);
102 //=======================================================================
103 //function : Modified
105 //=======================================================================
106 const TopTools_ListOfShape& GEOMAlgo_Builder::Modified(const TopoDS_Shape& theS)
108 const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS();
109 NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller());
110 IntTools_Context& aCtx=pPF->ChangeContext();
112 Standard_Boolean bHasImage, bToReverse;
113 TopAbs_ShapeEnum aType;
114 TopTools_ListIteratorOfListOfShape aIt;
116 myHistShapes.Clear();
122 bHasImage=myImages.HasImage(theS);
127 aType=theS.ShapeType();
129 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
130 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
131 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
132 aIt.Initialize(aLSp);
133 for (; aIt.More(); aIt.Next()) {
134 TopoDS_Shape aSp=aIt.Value();
135 if (!mySameDomainShapes.Contains(aSp)) {
136 if (myMapShape.Contains(aSp)) {
138 if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
139 aSp.Orientation(theS.Orientation());
142 bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSp, theS, aCtx);
148 myHistShapes.Append(aSp);
156 //=======================================================================
157 //function : IsDeleted
159 //=======================================================================
160 Standard_Boolean GEOMAlgo_Builder::IsDeleted(const TopoDS_Shape& theS)
162 Standard_Boolean bRet, bHasImage, bContains;
163 TopAbs_ShapeEnum aType;
164 TopTools_ListIteratorOfListOfShape aIt;
172 bContains=myMapShape.Contains(theS);
177 bHasImage=myImages.HasImage(theS);
182 aType=theS.ShapeType();
183 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
184 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
185 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
186 aIt.Initialize(aLSp);
187 for (; aIt.More(); aIt.Next()) {
188 TopoDS_Shape aSp=aIt.Value();
190 if (!mySameDomainShapes.Contains(aSp)) {
191 if (myMapShape.Contains(aSp)) {
196 TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
197 if (myMapShape.Contains(aSpR)) {
203 return !bRet; // true
205 //=======================================================================
206 //function : PrepareHistory
208 //=======================================================================
209 void GEOMAlgo_Builder::PrepareHistory()
211 myHistShapes.Clear();
213 myHasDeleted=Standard_False;
214 myHasGenerated=Standard_False;
215 myHasModified=Standard_False;
217 if(myShape.IsNull()) {
221 MapShapes(myShape, myMapShape);
223 Standard_Boolean bHasImage, bContainsSD;
224 TopAbs_ShapeEnum aType;
225 TopTools_MapOfShape aMS;
226 TopTools_ListIteratorOfListOfShape aIt;
227 TopTools_MapIteratorOfMapOfShape aItM;
229 aIt.Initialize(myShapes);
230 for (; aIt.More(); aIt.Next()) {
231 const TopoDS_Shape& aS=aIt.Value();
235 aItM.Initialize(aMS);
236 for (; aItM.More(); aItM.Next()) {
237 const TopoDS_Shape& aSx=aItM.Key();
238 aType=aSx.ShapeType();
241 myHasDeleted=IsDeleted(aSx);//xx
244 if (!myHasGenerated || !myHasModified) {
245 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
246 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
247 bHasImage=myImages.HasImage(aSx);
249 const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
250 aIt.Initialize(aLSp);
251 for (; aIt.More(); aIt.Next()) {
252 const TopoDS_Shape& aSp=aIt.Value();
254 if (myMapShape.Contains(aSp)) {
255 bContainsSD=mySameDomainShapes.Contains(aSp);
257 if (!myHasGenerated) {
259 myHasGenerated=Standard_True;
262 if (!myHasModified) {
264 myHasModified=Standard_True;
267 } // if (myMapShape.Contains(aSp))
275 //=======================================================================
276 //function : MapShapes
278 //=======================================================================
279 void MapShapes(const TopoDS_Shape& theS,
280 TopTools_MapOfShape& theM)
283 TopoDS_Iterator anIt;
284 anIt.Initialize(theS);
285 for (; anIt.More(); anIt.Next()) {
286 const TopoDS_Shape& aSx=anIt.Value();
287 MapShapes(aSx, theM);