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>
43 void MapShapes(const TopoDS_Shape& aS,
44 TopTools_MapOfShape& aM);
46 //=======================================================================
47 //function : Generated
49 //=======================================================================
50 const TopTools_ListOfShape& GEOMAlgo_Builder::Generated(const TopoDS_Shape& theS)
52 const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS();
53 NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller());
54 IntTools_Context& aCtx=pPF->ChangeContext();
56 Standard_Boolean bHasImage, bToReverse;
57 TopAbs_ShapeEnum aType;
58 TopTools_ListIteratorOfListOfShape aIt;
66 bHasImage=myImages.HasImage(theS);
71 aType=theS.ShapeType();
73 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
74 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
75 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
77 for (; aIt.More(); aIt.Next()) {
78 const TopoDS_Shape& aSp=aIt.Value();
79 if (mySameDomainShapes.Contains(aSp)) {
80 if (myMapShape.Contains(aSp)) {
81 TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
83 if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
84 aSpR.Orientation(theS.Orientation());
87 bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSpR, theS, aCtx);
93 myHistShapes.Append(aSpR);
101 //=======================================================================
102 //function : Modified
104 //=======================================================================
105 const TopTools_ListOfShape& GEOMAlgo_Builder::Modified(const TopoDS_Shape& theS)
107 const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS();
108 NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller());
109 IntTools_Context& aCtx=pPF->ChangeContext();
111 Standard_Boolean bHasImage, bToReverse;
112 TopAbs_ShapeEnum aType;
113 TopTools_ListIteratorOfListOfShape aIt;
115 myHistShapes.Clear();
121 bHasImage=myImages.HasImage(theS);
126 aType=theS.ShapeType();
128 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
129 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
130 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
131 aIt.Initialize(aLSp);
132 for (; aIt.More(); aIt.Next()) {
133 TopoDS_Shape aSp=aIt.Value();
134 if (!mySameDomainShapes.Contains(aSp)) {
135 if (myMapShape.Contains(aSp)) {
137 if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
138 aSp.Orientation(theS.Orientation());
141 bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSp, theS, aCtx);
147 myHistShapes.Append(aSp);
155 //=======================================================================
156 //function : IsDeleted
158 //=======================================================================
159 Standard_Boolean GEOMAlgo_Builder::IsDeleted(const TopoDS_Shape& theS)
161 Standard_Boolean bRet, bHasImage, bContains;
162 TopAbs_ShapeEnum aType;
163 TopTools_ListIteratorOfListOfShape aIt;
171 bContains=myMapShape.Contains(theS);
176 bHasImage=myImages.HasImage(theS);
181 aType=theS.ShapeType();
182 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
183 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
184 const TopTools_ListOfShape& aLSp=myImages.Image(theS);
185 aIt.Initialize(aLSp);
186 for (; aIt.More(); aIt.Next()) {
187 TopoDS_Shape aSp=aIt.Value();
189 if (!mySameDomainShapes.Contains(aSp)) {
190 if (myMapShape.Contains(aSp)) {
195 TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
196 if (myMapShape.Contains(aSpR)) {
202 return !bRet; // true
204 //=======================================================================
205 //function : PrepareHistory
207 //=======================================================================
208 void GEOMAlgo_Builder::PrepareHistory()
210 if(myShape.IsNull()) {
214 Standard_Boolean bHasImage, bContainsSD;
215 TopAbs_ShapeEnum aType;
216 TopTools_MapOfShape aMS;
217 TopTools_ListIteratorOfListOfShape aIt;
218 TopTools_MapIteratorOfMapOfShape aItM;
221 GEOMAlgo_BuilderShape::PrepareHistory();
223 // 2. myMapShape - all shapes of result with theirs sub-shapes
224 MapShapes(myShape, myMapShape);
226 // 3. MS - all argument shapes with theirs sub-shapes
227 aIt.Initialize(myShapes);
228 for (; aIt.More(); aIt.Next()) {
229 const TopoDS_Shape& aSx=aIt.Value();
234 aItM.Initialize(aMS);
235 for (; aItM.More(); aItM.Next()) {
236 const TopoDS_Shape& aSx=aItM.Key();
237 aType=aSx.ShapeType();
238 //modified by NIZNHY-PKV Thu Dec 7 11:34:05 2006f
240 // 4.1 .myImagesResult
241 TopTools_ListOfShape aLSx;
243 bHasImage=myImages.HasImage(aSx);
245 if (myMapShape.Contains(aSx)) {
247 myImagesResult.Add(aSx, aLSx);
251 const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
252 aIt.Initialize(aLSp);
253 for (; aIt.More(); aIt.Next()) {
254 const TopoDS_Shape& aSp=aIt.Value();
255 if (myMapShape.Contains(aSp)) {
259 myImagesResult.Add(aSx, aLSx);
262 //modified by NIZNHY-PKV Thu Dec 7 11:34:10 2006t
266 myHasDeleted=IsDeleted(aSx);//xx
269 if (!myHasGenerated || !myHasModified) {
270 if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
271 aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
272 //modified by NIZNHY-PKV Thu Dec 7 11:53:01 2006f
273 //bHasImage=myImages.HasImage(aSx);
274 //modified by NIZNHY-PKV Thu Dec 7 11:53:04 2006t
276 const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
277 aIt.Initialize(aLSp);
278 for (; aIt.More(); aIt.Next()) {
279 const TopoDS_Shape& aSp=aIt.Value();
281 if (myMapShape.Contains(aSp)) {
282 bContainsSD=mySameDomainShapes.Contains(aSp);
284 if (!myHasGenerated) {
286 myHasGenerated=Standard_True;
289 if (!myHasModified) {
291 myHasModified=Standard_True;
294 } // if (myMapShape.Contains(aSp))
302 //=======================================================================
303 //function : MapShapes
305 //=======================================================================
306 void MapShapes(const TopoDS_Shape& theS,
307 TopTools_MapOfShape& theM)
310 TopoDS_Iterator anIt;
311 anIt.Initialize(theS);
312 for (; anIt.More(); anIt.Next()) {
313 const TopoDS_Shape& aSx=anIt.Value();
314 MapShapes(aSx, theM);