]> SALOME platform Git repositories - modules/shaper.git/blob - src/Model/Model_ResultBody.cpp
Salome HOME
Topological name management. Patch#2
[modules/shaper.git] / src / Model / Model_ResultBody.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_ResultBody.cpp
4 // Created:     08 Jul 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include <Model_ResultBody.h>
8 #include <Model_Data.h>
9 #include <Model_Document.h>
10 #include <TNaming_Builder.hxx>
11 #include <TNaming_NamedShape.hxx>
12 #include <TDataStd_Name.hxx>
13 #include <TopoDS.hxx>
14 #include <TopoDS_Shape.hxx>
15 #include <TopoDS_Face.hxx>
16 #include <TDF_ChildIterator.hxx>
17 #include <TopTools_MapOfShape.hxx>
18 #include <TopExp_Explorer.hxx>
19 #include <TopTools_ListOfShape.hxx>
20 #include <TopTools_ListIteratorOfListOfShape.hxx>
21 #include <TopTools_DataMapOfShapeListOfShape.hxx>
22 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
23 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
24 #include <TopTools_MapIteratorOfMapOfShape.hxx>
25 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
26 #include <TopTools_IndexedMapOfShape.hxx>
27 #include <TopTools_DataMapOfShapeShape.hxx>
28 #include <TopExp.hxx>
29 #include <BRepTools.hxx>
30 #include <GeomAPI_Shape.h>
31 #include <GeomAlgoAPI_MakeShape.h>
32 // DEB
33 //#include <TCollection_AsciiString.hxx>
34 //#include <TDF_Tool.hxx>
35 Model_ResultBody::Model_ResultBody()
36 {
37   setIsConcealed(false);
38 }
39
40 void Model_ResultBody::store(const std::shared_ptr<GeomAPI_Shape>& theShape)
41 {
42   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
43   if (aData) {
44     TDF_Label& aShapeLab = aData->shapeLab();
45     // clean builders
46     clean();   
47     // store the new shape as primitive
48     TNaming_Builder aBuilder(aShapeLab);
49     if (!theShape)
50       return;  // bad shape
51     TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
52     if (aShape.IsNull())
53       return;  // null shape inside
54
55     aBuilder.Generated(aShape); 
56   }
57 }
58
59 void Model_ResultBody::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
60   const std::shared_ptr<GeomAPI_Shape>& theToShape)
61 {
62   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
63   if (aData) {
64     TDF_Label& aShapeLab = aData->shapeLab();
65     // clean builders
66     clean();   
67     // store the new shape as primitive
68     TNaming_Builder aBuilder(aShapeLab);
69     if (!theFromShape || !theToShape)
70       return;  // bad shape
71     TopoDS_Shape aShapeBasis = theFromShape->impl<TopoDS_Shape>();
72     if (aShapeBasis.IsNull())
73       return;  // null shape inside
74     TopoDS_Shape aShapeNew = theToShape->impl<TopoDS_Shape>();
75     if (aShapeNew.IsNull())
76       return;  // null shape inside
77     aBuilder.Generated(aShapeBasis, aShapeNew);
78   }
79 }
80
81 void Model_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
82   const std::shared_ptr<GeomAPI_Shape>& theNewShape)
83 {
84   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
85   if (aData) {
86     TDF_Label& aShapeLab = aData->shapeLab();
87     // clean builders
88     clean();   
89     // store the new shape as primitive
90     TNaming_Builder aBuilder(aShapeLab);
91     if (!theOldShape || !theNewShape)
92       return;  // bad shape
93     TopoDS_Shape aShapeOld = theOldShape->impl<TopoDS_Shape>();
94     if (aShapeOld.IsNull())
95       return;  // null shape inside
96     TopoDS_Shape aShapeNew = theNewShape->impl<TopoDS_Shape>();
97     if (aShapeNew.IsNull())
98       return;  // null shape inside
99         aBuilder.Modify(aShapeOld, aShapeNew);
100   }
101 }
102
103 std::shared_ptr<GeomAPI_Shape> Model_ResultBody::shape()
104 {
105   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
106   if (aData) {
107     TDF_Label& aShapeLab = aData->shapeLab();
108     Handle(TNaming_NamedShape) aName;
109     if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
110       TopoDS_Shape aShape = aName->Get();
111       if (!aShape.IsNull()) {
112         std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
113         aRes->setImpl(new TopoDS_Shape(aShape));
114         return aRes;
115       }
116     }
117   }
118   return std::shared_ptr<GeomAPI_Shape>();
119 }
120
121 void Model_ResultBody::clean()
122 {
123   std::vector<TNaming_Builder*>::iterator aBuilder = myBuilders.begin();
124   for(; aBuilder != myBuilders.end(); aBuilder++)
125     delete *aBuilder;
126   myBuilders.clear();
127 }
128
129 Model_ResultBody::~Model_ResultBody()
130 {
131   clean();
132 }
133
134 TNaming_Builder* Model_ResultBody::builder(const int theTag)
135 {
136   if (myBuilders.size() <= (unsigned int)theTag) {
137     myBuilders.insert(myBuilders.end(), theTag - myBuilders.size() + 1, NULL);
138   }
139   if (!myBuilders[theTag]) {
140     std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
141     myBuilders[theTag] = new TNaming_Builder(aData->shapeLab().FindChild(theTag));
142     //TCollection_AsciiString entry;//
143     //TDF_Tool::Entry(aData->shapeLab().FindChild(theTag), entry);
144     //cout << "Label = " <<entry.ToCString() <<endl;
145   }
146   return myBuilders[theTag];
147 }
148
149 void Model_ResultBody::buildName(const int theTag, const std::string& theName)
150 {
151   std::string aName = data()->name() + "/" + theName; 
152   std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
153   aDoc->addNamingName(builder(theTag)->NamedShape()->Label(), aName);
154   TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(),aName.c_str());
155 }
156 void Model_ResultBody::generated(
157   const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
158 {
159   TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
160   builder(theTag)->Generated(aShape);
161   if(!theName.empty()) 
162     buildName(theTag, theName);
163 }
164
165 void Model_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
166   const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
167 {
168   TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
169   TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
170   builder(theTag)->Generated(anOldShape, aNewShape);
171   if(!theName.empty()) 
172     buildName(theTag, theName);
173 }
174
175
176 void Model_ResultBody::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
177   const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
178 {
179   TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
180   TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
181   builder(theTag)->Modify(anOldShape, aNewShape);
182   if(!theName.empty()) 
183     buildName(theTag, theName);
184 }
185
186 void Model_ResultBody::deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
187   const int theTag)
188 {
189   TopoDS_Shape aShape = theOldShape->impl<TopoDS_Shape>();
190   builder(theTag)->Delete(aShape);
191 }
192
193 void Model_ResultBody::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
194   std::shared_ptr<GeomAPI_Shape>  theShapeIn,
195   const int  theKindOfShape,
196   const int  theTag)
197 {
198   TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
199   TopTools_MapOfShape aView;
200   TopExp_Explorer ShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
201   for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
202     const TopoDS_Shape& aRoot = ShapeExplorer.Current ();
203     if (!aView.Add(aRoot)) continue;
204     std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
205     aRShape->setImpl((new TopoDS_Shape(aRoot)));
206     if (theMS->isDeleted (aRShape)) {
207       builder(theTag)->Delete(aRoot);
208     }
209   }
210 }
211
212 void Model_ResultBody::loadAndOrientModifiedShapes (
213   GeomAlgoAPI_MakeShape* theMS,
214   std::shared_ptr<GeomAPI_Shape>  theShapeIn,
215   const int  theKindOfShape,
216   const int  theTag,
217   const std::string& theName,
218   GeomAPI_DataMapOfShapeShape& theSubShapes)
219 {
220   TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
221   TopTools_MapOfShape aView;
222   bool isBuilt = theName.empty();
223   TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
224   for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
225     const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
226     if (!aView.Add(aRoot)) continue;
227     ListOfShape aList;
228     std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
229     aRShape->setImpl((new TopoDS_Shape(aRoot)));
230         theMS->modified(aRShape, aList);
231     std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aList.begin(), aLast = aList.end();
232     for (; anIt != aLast; anIt++) {
233       TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();     
234       if (theSubShapes.isBound(*anIt)) {
235         std::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
236         aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
237       }
238       if (!aRoot.IsSame (aNewShape)) {
239         builder(theTag)->Modify(aRoot,aNewShape);
240                 if(!isBuilt) 
241                   buildName(theTag, theName);           
242           }
243     }
244   }
245 }
246
247 void Model_ResultBody::loadAndOrientGeneratedShapes (
248   GeomAlgoAPI_MakeShape* theMS,
249   std::shared_ptr<GeomAPI_Shape>  theShapeIn,
250   const int  theKindOfShape,
251   const int  theTag,
252   const std::string& theName,
253   GeomAPI_DataMapOfShapeShape& theSubShapes)
254 {
255   TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
256   TopTools_MapOfShape aView;
257   bool isBuilt = theName.empty();
258   TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
259   for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
260     const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
261     if (!aView.Add(aRoot)) continue;
262     ListOfShape aList;
263     std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
264     aRShape->setImpl((new TopoDS_Shape(aRoot)));
265     theMS->generated(aRShape, aList);
266     std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aList.begin(), aLast = aList.end();
267     for (; anIt != aLast; anIt++) {
268       TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();     
269       if (theSubShapes.isBound(*anIt)) {
270         std::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
271         aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
272       }
273       if (!aRoot.IsSame (aNewShape)) {
274         builder(theTag)->Generated(aRoot,aNewShape);
275                 if(!isBuilt) 
276                   buildName(theTag, theName);   
277           }
278     }
279   }
280 }
281
282 //=======================================================================
283 int getDangleShapes(const TopoDS_Shape&           theShapeIn, 
284                                         const TopAbs_ShapeEnum        theGeneratedFrom,
285                                     TopTools_DataMapOfShapeShape& theDangles) 
286 {
287   theDangles.Clear();
288   TopTools_IndexedDataMapOfShapeListOfShape subShapeAndAncestors;
289   TopAbs_ShapeEnum GeneratedTo;
290   if (theGeneratedFrom == TopAbs_FACE) GeneratedTo = TopAbs_EDGE;
291   else if (theGeneratedFrom == TopAbs_EDGE) GeneratedTo = TopAbs_VERTEX;
292   else return Standard_False;
293   TopExp::MapShapesAndAncestors(theShapeIn, GeneratedTo, theGeneratedFrom, subShapeAndAncestors);
294   for (Standard_Integer i = 1; i <= subShapeAndAncestors.Extent(); i++) {
295     const TopoDS_Shape& mayBeDangle = subShapeAndAncestors.FindKey(i);
296     const TopTools_ListOfShape& ancestors = subShapeAndAncestors.FindFromIndex(i);
297     if (ancestors.Extent() == 1) theDangles.Bind(ancestors.First(), mayBeDangle);
298   }
299   return theDangles.Extent();
300 }
301
302 //=======================================================================
303 void loadGeneratedDangleShapes(
304                                                            const TopoDS_Shape&      theShapeIn,
305                                                const TopAbs_ShapeEnum   theGeneratedFrom,
306                                                TNaming_Builder *        theBuilder)
307 {
308   TopTools_DataMapOfShapeShape dangles;
309   if (!getDangleShapes(theShapeIn, theGeneratedFrom, dangles)) return;
310   TopTools_DataMapIteratorOfDataMapOfShapeShape itr(dangles);
311   for (; itr.More(); itr.Next()) 
312         theBuilder->Generated(itr.Key(), itr.Value());
313 }
314
315 //=======================================================================
316 void Model_ResultBody::loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape, 
317                                           const std::string& theName, int&  theTag)
318 {
319   if(theShape->isNull()) return;
320   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();    
321   std::string aName;
322   if (aShape.ShapeType() == TopAbs_SOLID) {                 
323     TopExp_Explorer expl(aShape, TopAbs_FACE);
324     for (; expl.More(); expl.Next())      
325           builder(++theTag)->Generated(expl.Current()); 
326           TCollection_AsciiString aStr(theTag);
327           aName = theName + aStr.ToCString();
328           buildName(theTag, aName);
329   }
330   else if (aShape.ShapeType() == TopAbs_SHELL || aShape.ShapeType() == TopAbs_FACE) {
331     // load faces and all the free edges
332     TopTools_IndexedMapOfShape Faces;
333     TopExp::MapShapes(aShape, TopAbs_FACE, Faces);
334     if (Faces.Extent() > 1 || (aShape.ShapeType() == TopAbs_SHELL && Faces.Extent() == 1)) {
335       TopExp_Explorer expl(aShape, TopAbs_FACE);
336       for (; expl.More(); expl.Next()) {
337                   builder(++theTag)->Generated(expl.Current());          
338                   TCollection_AsciiString aStr(theTag);
339               aName = theName + aStr.ToCString();
340               buildName(theTag, aName);
341           }
342         }
343     TopTools_IndexedDataMapOfShapeListOfShape anEdgeAndNeighbourFaces;
344     TopExp::MapShapesAndAncestors(aShape, TopAbs_EDGE, TopAbs_FACE, anEdgeAndNeighbourFaces);
345     for (Standard_Integer i = 1; i <= anEdgeAndNeighbourFaces.Extent(); i++) 
346         {
347       const TopTools_ListOfShape& aLL = anEdgeAndNeighbourFaces.FindFromIndex(i);
348       if (aLL.Extent() < 2) {
349             builder(++theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
350                 TCollection_AsciiString aStr(theTag);
351             aName = theName + aStr.ToCString();
352             buildName(theTag, aName);
353       } else {
354           TopTools_ListIteratorOfListOfShape anIter(aLL);
355           const TopoDS_Face& aFace = TopoDS::Face(anIter.Value());
356           anIter.Next();
357           if(aFace.IsEqual(anIter.Value())) {
358                 builder(++theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
359                 TCollection_AsciiString aStr(theTag);
360             aName = theName + aStr.ToCString();
361             buildName(theTag, aName);
362           }
363           }
364         }
365   } else if (aShape.ShapeType() == TopAbs_WIRE) {
366     TopTools_IndexedMapOfShape Edges;
367     BRepTools::Map3DEdges(aShape, Edges);
368     if (Edges.Extent() == 1) {
369           builder(++theTag)->Generated(Edges.FindKey(1));
370       TopExp_Explorer expl(aShape, TopAbs_VERTEX);
371       for (; expl.More(); expl.Next()) {
372             builder(++theTag)->Generated(expl.Current());
373                 TCollection_AsciiString aStr(theTag);
374             aName = theName + aStr.ToCString();
375             buildName(theTag, aName);
376           }
377         } else {
378       TopExp_Explorer expl(aShape, TopAbs_EDGE); 
379       for (; expl.More(); expl.Next()) {        
380                 builder(++theTag)->Generated(expl.Current());
381                 TCollection_AsciiString aStr(theTag);
382             aName = theName + aStr.ToCString();
383             buildName(theTag, aName);
384           }   
385       // and load generated vertices.
386       TopTools_DataMapOfShapeShape generated;
387       if (getDangleShapes(aShape, TopAbs_EDGE, generated)) 
388           {
389                 TNaming_Builder* pBuilder = builder(++theTag);
390                 loadGeneratedDangleShapes(aShape, TopAbs_EDGE, pBuilder);  
391           }
392         }
393   } else if (aShape.ShapeType() == TopAbs_EDGE) {
394     TopExp_Explorer expl(aShape, TopAbs_VERTEX);
395     for (; expl.More(); expl.Next()) {      
396                 builder(++theTag)->Generated(expl.Current());
397                 TCollection_AsciiString aStr(theTag);
398             aName = theName + aStr.ToCString();
399             buildName(theTag, aName);
400         }
401   }
402 }
403 //=======================================================================
404 void Model_ResultBody::loadFirstLevel(
405                      std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag)
406 {
407   if(theShape->isNull()) return;
408   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>(); 
409   std::string aName;
410   if (aShape.ShapeType() == TopAbs_COMPOUND || aShape.ShapeType() == TopAbs_COMPSOLID) {
411     TopoDS_Iterator itr(aShape);
412     for (; itr.More(); itr.Next()) {
413           builder(++theTag)->Generated(itr.Value());
414           TCollection_AsciiString aStr(theTag);
415           aName = theName + aStr.ToCString();
416           buildName(theTag, aName);
417           if(!theName.empty()) buildName(theTag, aName);
418       if (itr.Value().ShapeType() == TopAbs_COMPOUND || 
419                   itr.Value().ShapeType() == TopAbs_COMPSOLID) 
420           {
421                 std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
422         itrShape->setImpl(new TopoDS_Shape(itr.Value()));
423             loadFirstLevel(itrShape, theName, theTag);
424       } else {
425                 std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
426         itrShape->setImpl(new TopoDS_Shape(itr.Value()));               
427                 loadNextLevels(itrShape, theName, theTag);
428           }
429     }
430   } else {
431     std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
432     itrShape->setImpl(new TopoDS_Shape(aShape));
433         loadNextLevels(itrShape, theName, theTag); 
434   }
435 }
436
437 //=======================================================================
438 void Model_ResultBody::loadDisconnectedEdges(
439                      std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag)
440 {
441   if(theShape->isNull()) return;
442   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();  
443   TopTools_DataMapOfShapeListOfShape edgeNaborFaces;
444   TopTools_ListOfShape empty;
445   TopExp_Explorer explF(aShape, TopAbs_FACE);
446   for (; explF.More(); explF.Next()) {
447     const TopoDS_Shape& aFace = explF.Current();
448     TopExp_Explorer explV(aFace, TopAbs_EDGE);
449     for (; explV.More(); explV.Next()) {
450       const TopoDS_Shape& anEdge = explV.Current();
451       if (!edgeNaborFaces.IsBound(anEdge)) edgeNaborFaces.Bind(anEdge, empty);
452       Standard_Boolean faceIsNew = Standard_True;
453       TopTools_ListIteratorOfListOfShape itrF(edgeNaborFaces.Find(anEdge));
454       for (; itrF.More(); itrF.Next()) {
455             if (itrF.Value().IsSame(aFace)) {
456             faceIsNew = Standard_False;
457             break;
458                 }
459           }
460       if (faceIsNew) 
461             edgeNaborFaces.ChangeFind(anEdge).Append(aFace);      
462         }
463   }
464   
465   TopTools_MapOfShape anEdgesToDelete;
466   TopExp_Explorer anEx(aShape,TopAbs_EDGE); 
467   std::string aName;
468   for(;anEx.More();anEx.Next()) {
469     Standard_Boolean aC0 = Standard_False;
470     TopoDS_Shape anEdge1 = anEx.Current();
471     if (edgeNaborFaces.IsBound(anEdge1)) {
472       const TopTools_ListOfShape& aList1 = edgeNaborFaces.Find(anEdge1);
473       if (aList1.Extent()<2) continue;
474       TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(edgeNaborFaces);
475       for (; itr.More(); itr.Next()) {
476             TopoDS_Shape anEdge2 = itr.Key();
477             if(anEdgesToDelete.Contains(anEdge2)) continue;
478             if (anEdge1.IsSame(anEdge2)) continue;
479             const TopTools_ListOfShape& aList2 = itr.Value();
480             // compare lists of the neighbour faces of edge1 and edge2
481             if (aList1.Extent() == aList2.Extent()) {
482             Standard_Integer aMatches = 0;
483             for(TopTools_ListIteratorOfListOfShape aLIter1(aList1);aLIter1.More();aLIter1.Next())
484               for(TopTools_ListIteratorOfListOfShape aLIter2(aList2);aLIter2.More();aLIter2.Next())
485                 if (aLIter1.Value().IsSame(aLIter2.Value())) aMatches++;
486                 if (aMatches == aList1.Extent()) {
487                   aC0=Standard_True;
488                           builder(++theTag)->Generated(anEdge2);
489                   anEdgesToDelete.Add(anEdge2);
490                           TCollection_AsciiString aStr(theTag);
491                           aName = theName + aStr.ToCString();
492                   buildName(theTag, aName);
493                         }
494                 }
495           }      
496       TopTools_MapIteratorOfMapOfShape itDelete(anEdgesToDelete);
497       for(;itDelete.More();itDelete.Next()) 
498             edgeNaborFaces.UnBind(itDelete.Key());      
499       edgeNaborFaces.UnBind(anEdge1);
500         }
501     if (aC0) {
502           builder(++theTag)->Generated(anEdge1);
503           TCollection_AsciiString aStr(theTag);
504           aName = theName + aStr.ToCString();
505           buildName(theTag, aName);      
506         }
507   }
508 }
509
510 void Model_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag)
511 {
512   if(theShape->isNull()) return;
513   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();  
514   TopTools_DataMapOfShapeListOfShape vertexNaborFaces;
515   TopTools_ListOfShape empty;
516   TopExp_Explorer explF(aShape, TopAbs_FACE);
517   for (; explF.More(); explF.Next()) {
518     const TopoDS_Shape& aFace = explF.Current();
519     TopExp_Explorer explV(aFace, TopAbs_VERTEX);
520     for (; explV.More(); explV.Next()) {
521       const TopoDS_Shape& aVertex = explV.Current();
522       if (!vertexNaborFaces.IsBound(aVertex)) vertexNaborFaces.Bind(aVertex, empty);
523       Standard_Boolean faceIsNew = Standard_True;
524       TopTools_ListIteratorOfListOfShape itrF(vertexNaborFaces.Find(aVertex));
525       for (; itrF.More(); itrF.Next()) {
526         if (itrF.Value().IsSame(aFace)) {
527           faceIsNew = Standard_False;
528           break;
529         }
530       }
531       if (faceIsNew) {
532         vertexNaborFaces.ChangeFind(aVertex).Append(aFace);
533       }
534     }
535   }
536   std::string aName;
537   TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(vertexNaborFaces);
538   for (; itr.More(); itr.Next()) {
539     const TopTools_ListOfShape& naborFaces = itr.Value();
540     if (naborFaces.Extent() < 3) {
541                 builder(++theTag)->Generated(itr.Key());
542                 TCollection_AsciiString aStr(theTag);
543             aName = theName + aStr.ToCString();
544             buildName(theTag, aName);    
545         }
546   }
547 }