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