]> SALOME platform Git repositories - modules/shaper.git/blob - src/Model/Model_ResultBody.cpp
Salome HOME
9f1afcdee18b10bd9292473938734f7aa53bd41f
[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           theTag++;
330         }
331   }
332   else if (aShape.ShapeType() == TopAbs_SHELL || aShape.ShapeType() == TopAbs_FACE) {
333     // load faces and all the free edges
334     TopTools_IndexedMapOfShape Faces;
335     TopExp::MapShapes(aShape, TopAbs_FACE, Faces);
336     if (Faces.Extent() > 1 || (aShape.ShapeType() == TopAbs_SHELL && Faces.Extent() == 1)) {
337       TopExp_Explorer expl(aShape, TopAbs_FACE);
338       for (; expl.More(); expl.Next()) {
339                   builder(theTag)->Generated(expl.Current());          
340                   TCollection_AsciiString aStr(theTag);
341               aName = theName + aStr.ToCString();
342               buildName(theTag, aName);
343                   theTag++;
344           }
345         }
346     TopTools_IndexedDataMapOfShapeListOfShape anEdgeAndNeighbourFaces;
347     TopExp::MapShapesAndAncestors(aShape, TopAbs_EDGE, TopAbs_FACE, anEdgeAndNeighbourFaces);
348     for (Standard_Integer i = 1; i <= anEdgeAndNeighbourFaces.Extent(); i++) 
349         {
350       const TopTools_ListOfShape& aLL = anEdgeAndNeighbourFaces.FindFromIndex(i);
351       if (aLL.Extent() < 2) {
352             builder(theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
353                 TCollection_AsciiString aStr(theTag);
354             aName = theName + aStr.ToCString();
355             buildName(theTag, aName);
356                 theTag++;
357       } else {
358           TopTools_ListIteratorOfListOfShape anIter(aLL);
359           const TopoDS_Face& aFace = TopoDS::Face(anIter.Value());
360           anIter.Next();
361           if(aFace.IsEqual(anIter.Value())) {
362                 builder(theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
363                 TCollection_AsciiString aStr(theTag);
364             aName = theName + aStr.ToCString();
365             buildName(theTag, aName);
366             theTag++;
367           }
368           }
369         }
370   } else if (aShape.ShapeType() == TopAbs_WIRE) {
371     TopTools_IndexedMapOfShape Edges;
372     BRepTools::Map3DEdges(aShape, Edges);
373     if (Edges.Extent() == 1) {
374           builder(++theTag)->Generated(Edges.FindKey(1));
375       TopExp_Explorer expl(aShape, TopAbs_VERTEX);
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             theTag++;
382           }
383         } else {
384       TopExp_Explorer expl(aShape, TopAbs_EDGE); 
385       for (; expl.More(); expl.Next()) {        
386                 builder(theTag)->Generated(expl.Current());
387                 TCollection_AsciiString aStr(theTag);
388             aName = theName + aStr.ToCString();
389             buildName(theTag, aName);
390                 theTag++;
391           }   
392       // and load generated vertices.
393       TopTools_DataMapOfShapeShape generated;
394       if (getDangleShapes(aShape, TopAbs_EDGE, generated)) 
395           {
396                 TNaming_Builder* pBuilder = builder(theTag++);
397                 loadGeneratedDangleShapes(aShape, TopAbs_EDGE, pBuilder);  
398           }
399         }
400   } else if (aShape.ShapeType() == TopAbs_EDGE) {
401     TopExp_Explorer expl(aShape, TopAbs_VERTEX);
402     for (; expl.More(); expl.Next()) {      
403                 builder(theTag)->Generated(expl.Current());
404                 TCollection_AsciiString aStr(theTag);
405             aName = theName + aStr.ToCString();
406             buildName(theTag, aName);
407                 theTag++;
408         }
409   }
410 }
411 //=======================================================================
412 void Model_ResultBody::loadFirstLevel(
413                      std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag)
414 {
415   if(theShape->isNull()) return;
416   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>(); 
417   std::string aName;
418   if (aShape.ShapeType() == TopAbs_COMPOUND || aShape.ShapeType() == TopAbs_COMPSOLID) {
419     TopoDS_Iterator itr(aShape);
420     for (; itr.More(); itr.Next(),theTag++) {
421           builder(theTag)->Generated(itr.Value());
422           TCollection_AsciiString aStr(theTag);
423           aName = theName + aStr.ToCString();
424           buildName(theTag, aName);
425           if(!theName.empty()) buildName(theTag, aName);
426       if (itr.Value().ShapeType() == TopAbs_COMPOUND || 
427                   itr.Value().ShapeType() == TopAbs_COMPSOLID) 
428           {
429                 std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
430         itrShape->setImpl(new TopoDS_Shape(itr.Value()));
431             loadFirstLevel(itrShape, theName, theTag);
432       } else {
433                 std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
434         itrShape->setImpl(new TopoDS_Shape(itr.Value()));               
435                 loadNextLevels(itrShape, theName, theTag);
436           }
437     }
438   } else {
439     std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
440     itrShape->setImpl(new TopoDS_Shape(aShape));
441         loadNextLevels(itrShape, theName, theTag); 
442   }
443 }
444
445 //=======================================================================
446 void Model_ResultBody::loadDisconnectedEdges(
447                      std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag)
448 {
449   if(theShape->isNull()) return;
450   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();  
451   TopTools_DataMapOfShapeListOfShape edgeNaborFaces;
452   TopTools_ListOfShape empty;
453   TopExp_Explorer explF(aShape, TopAbs_FACE);
454   for (; explF.More(); explF.Next()) {
455     const TopoDS_Shape& aFace = explF.Current();
456     TopExp_Explorer explV(aFace, TopAbs_EDGE);
457     for (; explV.More(); explV.Next()) {
458       const TopoDS_Shape& anEdge = explV.Current();
459       if (!edgeNaborFaces.IsBound(anEdge)) edgeNaborFaces.Bind(anEdge, empty);
460       Standard_Boolean faceIsNew = Standard_True;
461       TopTools_ListIteratorOfListOfShape itrF(edgeNaborFaces.Find(anEdge));
462       for (; itrF.More(); itrF.Next()) {
463             if (itrF.Value().IsSame(aFace)) {
464             faceIsNew = Standard_False;
465             break;
466                 }
467           }
468       if (faceIsNew) 
469             edgeNaborFaces.ChangeFind(anEdge).Append(aFace);      
470         }
471   }
472   
473   TopTools_MapOfShape anEdgesToDelete;
474   TopExp_Explorer anEx(aShape,TopAbs_EDGE); 
475   std::string aName;
476   for(;anEx.More();anEx.Next()) {
477     Standard_Boolean aC0 = Standard_False;
478     TopoDS_Shape anEdge1 = anEx.Current();
479     if (edgeNaborFaces.IsBound(anEdge1)) {
480       const TopTools_ListOfShape& aList1 = edgeNaborFaces.Find(anEdge1);
481       if (aList1.Extent()<2) continue;
482       TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(edgeNaborFaces);
483       for (; itr.More(); itr.Next()) {
484             TopoDS_Shape anEdge2 = itr.Key();
485             if(anEdgesToDelete.Contains(anEdge2)) continue;
486             if (anEdge1.IsSame(anEdge2)) continue;
487             const TopTools_ListOfShape& aList2 = itr.Value();
488             // compare lists of the neighbour faces of edge1 and edge2
489             if (aList1.Extent() == aList2.Extent()) {
490             Standard_Integer aMatches = 0;
491             for(TopTools_ListIteratorOfListOfShape aLIter1(aList1);aLIter1.More();aLIter1.Next())
492               for(TopTools_ListIteratorOfListOfShape aLIter2(aList2);aLIter2.More();aLIter2.Next())
493                 if (aLIter1.Value().IsSame(aLIter2.Value())) aMatches++;
494                 if (aMatches == aList1.Extent()) {
495                   aC0=Standard_True;
496                           builder(theTag)->Generated(anEdge2);
497                   anEdgesToDelete.Add(anEdge2);
498                           TCollection_AsciiString aStr(theTag);
499                           aName = theName + aStr.ToCString();
500                   buildName(theTag, aName);
501                           theTag++;
502                         }
503                 }
504           }      
505       TopTools_MapIteratorOfMapOfShape itDelete(anEdgesToDelete);
506       for(;itDelete.More();itDelete.Next()) 
507             edgeNaborFaces.UnBind(itDelete.Key());      
508       edgeNaborFaces.UnBind(anEdge1);
509         }
510     if (aC0) {
511           builder(theTag)->Generated(anEdge1);
512           TCollection_AsciiString aStr(theTag);
513           aName = theName + aStr.ToCString();
514           buildName(theTag, aName);      
515           theTag++;
516         }
517   }
518 }
519
520 void Model_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag)
521 {
522   if(theShape->isNull()) return;
523   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();  
524   TopTools_DataMapOfShapeListOfShape vertexNaborFaces;
525   TopTools_ListOfShape empty;
526   TopExp_Explorer explF(aShape, TopAbs_FACE);
527   for (; explF.More(); explF.Next()) {
528     const TopoDS_Shape& aFace = explF.Current();
529     TopExp_Explorer explV(aFace, TopAbs_VERTEX);
530     for (; explV.More(); explV.Next()) {
531       const TopoDS_Shape& aVertex = explV.Current();
532       if (!vertexNaborFaces.IsBound(aVertex)) vertexNaborFaces.Bind(aVertex, empty);
533       Standard_Boolean faceIsNew = Standard_True;
534       TopTools_ListIteratorOfListOfShape itrF(vertexNaborFaces.Find(aVertex));
535       for (; itrF.More(); itrF.Next()) {
536         if (itrF.Value().IsSame(aFace)) {
537           faceIsNew = Standard_False;
538           break;
539         }
540       }
541       if (faceIsNew) {
542         vertexNaborFaces.ChangeFind(aVertex).Append(aFace);
543       }
544     }
545   }
546   std::string aName;
547   TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(vertexNaborFaces);
548   for (; itr.More(); itr.Next()) {
549     const TopTools_ListOfShape& naborFaces = itr.Value();
550     if (naborFaces.Extent() < 1) {              
551                 builder(theTag)->Generated(itr.Key());
552                 TCollection_AsciiString aStr(theTag);
553             aName = theName + aStr.ToCString();
554             buildName(theTag, aName);    
555                 theTag++;
556         }
557   }
558 }