1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_ResultBody.cpp
4 // Created: 08 Jul 2014
5 // Author: Mikhail PONIKAROV
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>
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>
29 #include <BRepTools.hxx>
30 #include <BRep_Tool.hxx>
31 #include <GeomAPI_Shape.h>
32 #include <GeomAlgoAPI_MakeShape.h>
34 //#include <TCollection_AsciiString.hxx>
35 //#include <TDF_Tool.hxx>
38 Model_ResultBody::Model_ResultBody()
40 setIsConcealed(false);
43 void Model_ResultBody::store(const std::shared_ptr<GeomAPI_Shape>& theShape)
45 std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
47 TDF_Label& aShapeLab = aData->shapeLab();
50 // store the new shape as primitive
51 TNaming_Builder aBuilder(aShapeLab);
54 TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
56 return; // null shape inside
58 aBuilder.Generated(aShape);
60 if(!aBuilder.NamedShape()->IsEmpty()) {
61 Handle(TDataStd_Name) anAttr;
62 if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
63 std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
65 std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
66 aDoc->addNamingName(aBuilder.NamedShape()->Label(), aName);
73 void Model_ResultBody::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
74 const std::shared_ptr<GeomAPI_Shape>& theToShape)
76 std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
78 TDF_Label& aShapeLab = aData->shapeLab();
81 // store the new shape as primitive
82 TNaming_Builder aBuilder(aShapeLab);
83 if (!theFromShape || !theToShape)
85 TopoDS_Shape aShapeBasis = theFromShape->impl<TopoDS_Shape>();
86 if (aShapeBasis.IsNull())
87 return; // null shape inside
88 TopoDS_Shape aShapeNew = theToShape->impl<TopoDS_Shape>();
89 if (aShapeNew.IsNull())
90 return; // null shape inside
91 aBuilder.Generated(aShapeBasis, aShapeNew);
93 if(!aBuilder.NamedShape()->IsEmpty()) {
94 Handle(TDataStd_Name) anAttr;
95 if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
96 std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
98 std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
99 aDoc->addNamingName(aBuilder.NamedShape()->Label(), aName);
106 void Model_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
107 const std::shared_ptr<GeomAPI_Shape>& theNewShape)
109 std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
111 TDF_Label& aShapeLab = aData->shapeLab();
114 // store the new shape as primitive
115 TNaming_Builder aBuilder(aShapeLab);
116 if (!theOldShape || !theNewShape)
118 TopoDS_Shape aShapeOld = theOldShape->impl<TopoDS_Shape>();
119 if (aShapeOld.IsNull())
120 return; // null shape inside
121 TopoDS_Shape aShapeNew = theNewShape->impl<TopoDS_Shape>();
122 if (aShapeNew.IsNull())
123 return; // null shape inside
124 aBuilder.Modify(aShapeOld, aShapeNew);
128 std::shared_ptr<GeomAPI_Shape> Model_ResultBody::shape()
130 std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
132 TDF_Label& aShapeLab = aData->shapeLab();
133 Handle(TNaming_NamedShape) aName;
134 if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
135 TopoDS_Shape aShape = aName->Get();
136 if (!aShape.IsNull()) {
137 std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
138 aRes->setImpl(new TopoDS_Shape(aShape));
143 return std::shared_ptr<GeomAPI_Shape>();
146 void Model_ResultBody::clean()
148 std::vector<TNaming_Builder*>::iterator aBuilder = myBuilders.begin();
149 for(; aBuilder != myBuilders.end(); aBuilder++)
154 Model_ResultBody::~Model_ResultBody()
159 TNaming_Builder* Model_ResultBody::builder(const int theTag)
161 if (myBuilders.size() <= (unsigned int)theTag) {
162 myBuilders.insert(myBuilders.end(), theTag - myBuilders.size() + 1, NULL);
164 if (!myBuilders[theTag]) {
165 std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
166 myBuilders[theTag] = new TNaming_Builder(aData->shapeLab().FindChild(theTag));
167 //TCollection_AsciiString entry;//
168 //TDF_Tool::Entry(aData->shapeLab().FindChild(theTag), entry);
169 //cout << "Label = " <<entry.ToCString() <<endl;
171 return myBuilders[theTag];
174 void Model_ResultBody::buildName(const int theTag, const std::string& theName)
176 std::string aName = data()->name() + "/" + theName;
177 std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
178 aDoc->addNamingName(builder(theTag)->NamedShape()->Label(), aName);
179 TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(),aName.c_str());
181 void Model_ResultBody::generated(
182 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
184 TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
185 builder(theTag)->Generated(aShape);
187 buildName(theTag, theName);
190 void Model_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
191 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
193 TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
194 TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
195 builder(theTag)->Generated(anOldShape, aNewShape);
197 buildName(theTag, theName);
201 void Model_ResultBody::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
202 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
204 TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
205 TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
206 builder(theTag)->Modify(anOldShape, aNewShape);
208 buildName(theTag, theName);
211 void Model_ResultBody::deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
214 TopoDS_Shape aShape = theOldShape->impl<TopoDS_Shape>();
215 builder(theTag)->Delete(aShape);
218 void Model_ResultBody::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
219 std::shared_ptr<GeomAPI_Shape> theShapeIn,
220 const int theKindOfShape,
223 TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
224 TopTools_MapOfShape aView;
225 TopExp_Explorer ShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
226 for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
227 const TopoDS_Shape& aRoot = ShapeExplorer.Current ();
228 if (!aView.Add(aRoot)) continue;
229 std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
230 aRShape->setImpl((new TopoDS_Shape(aRoot)));
231 if (theMS->isDeleted (aRShape)) {
232 builder(theTag)->Delete(aRoot);
237 void Model_ResultBody::loadAndOrientModifiedShapes (
238 GeomAlgoAPI_MakeShape* theMS,
239 std::shared_ptr<GeomAPI_Shape> theShapeIn,
240 const int theKindOfShape,
242 const std::string& theName,
243 GeomAPI_DataMapOfShapeShape& theSubShapes)
245 TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
246 TopTools_MapOfShape aView;
247 bool isBuilt = theName.empty();
248 TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
249 for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
250 const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
251 if (!aView.Add(aRoot)) continue;
253 std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
254 aRShape->setImpl((new TopoDS_Shape(aRoot)));
255 theMS->modified(aRShape, aList);
256 std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aList.begin(), aLast = aList.end();
257 for (; anIt != aLast; anIt++) {
258 TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();
259 if (theSubShapes.isBound(*anIt)) {
260 std::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
261 aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
263 if (!aRoot.IsSame (aNewShape)) {
264 builder(theTag)->Modify(aRoot,aNewShape);
266 buildName(theTag, theName);
272 void Model_ResultBody::loadAndOrientGeneratedShapes (
273 GeomAlgoAPI_MakeShape* theMS,
274 std::shared_ptr<GeomAPI_Shape> theShapeIn,
275 const int theKindOfShape,
277 const std::string& theName,
278 GeomAPI_DataMapOfShapeShape& theSubShapes)
280 TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
281 TopTools_MapOfShape aView;
282 bool isBuilt = theName.empty();
283 TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
284 for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
285 const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
286 if (!aView.Add(aRoot)) continue;
288 std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
289 aRShape->setImpl((new TopoDS_Shape(aRoot)));
290 theMS->generated(aRShape, aList);
291 std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aList.begin(), aLast = aList.end();
292 for (; anIt != aLast; anIt++) {
293 TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();
294 if (theSubShapes.isBound(*anIt)) {
295 std::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
296 aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
298 if (!aRoot.IsSame (aNewShape)) {
299 builder(theTag)->Generated(aRoot,aNewShape);
301 buildName(theTag, theName);
307 //=======================================================================
308 int getDangleShapes(const TopoDS_Shape& theShapeIn,
309 const TopAbs_ShapeEnum theGeneratedFrom,
310 TopTools_DataMapOfShapeShape& theDangles)
313 TopTools_IndexedDataMapOfShapeListOfShape subShapeAndAncestors;
314 TopAbs_ShapeEnum GeneratedTo;
315 if (theGeneratedFrom == TopAbs_FACE) GeneratedTo = TopAbs_EDGE;
316 else if (theGeneratedFrom == TopAbs_EDGE) GeneratedTo = TopAbs_VERTEX;
317 else return Standard_False;
318 TopExp::MapShapesAndAncestors(theShapeIn, GeneratedTo, theGeneratedFrom, subShapeAndAncestors);
319 for (Standard_Integer i = 1; i <= subShapeAndAncestors.Extent(); i++) {
320 const TopoDS_Shape& mayBeDangle = subShapeAndAncestors.FindKey(i);
321 const TopTools_ListOfShape& ancestors = subShapeAndAncestors.FindFromIndex(i);
322 if (ancestors.Extent() == 1) theDangles.Bind(ancestors.First(), mayBeDangle);
324 return theDangles.Extent();
327 //=======================================================================
328 void loadGeneratedDangleShapes(
329 const TopoDS_Shape& theShapeIn,
330 const TopAbs_ShapeEnum theGeneratedFrom,
331 TNaming_Builder * theBuilder)
333 TopTools_DataMapOfShapeShape dangles;
334 if (!getDangleShapes(theShapeIn, theGeneratedFrom, dangles)) return;
335 TopTools_DataMapIteratorOfDataMapOfShapeShape itr(dangles);
336 for (; itr.More(); itr.Next())
337 theBuilder->Generated(itr.Key(), itr.Value());
340 //=======================================================================
341 void Model_ResultBody::loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape,
342 const std::string& theName, int& theTag)
344 if(theShape->isNull()) return;
345 TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
347 if (aShape.ShapeType() == TopAbs_SOLID) {
348 TopExp_Explorer expl(aShape, TopAbs_FACE);
349 for (; expl.More(); expl.Next()) {
350 builder(theTag)->Generated(expl.Current());
351 TCollection_AsciiString aStr(theTag);
352 aName = theName + aStr.ToCString();
353 buildName(theTag, aName);
357 else if (aShape.ShapeType() == TopAbs_SHELL || aShape.ShapeType() == TopAbs_FACE) {
358 // load faces and all the free edges
359 TopTools_IndexedMapOfShape Faces;
360 TopExp::MapShapes(aShape, TopAbs_FACE, Faces);
361 if (Faces.Extent() > 1 || (aShape.ShapeType() == TopAbs_SHELL && Faces.Extent() == 1)) {
362 TopExp_Explorer expl(aShape, TopAbs_FACE);
363 for (; expl.More(); expl.Next()) {
364 builder(theTag)->Generated(expl.Current());
365 TCollection_AsciiString aStr(theTag);
366 aName = theName + aStr.ToCString();
367 buildName(theTag, aName);
371 TopTools_IndexedDataMapOfShapeListOfShape anEdgeAndNeighbourFaces;
372 TopExp::MapShapesAndAncestors(aShape, TopAbs_EDGE, TopAbs_FACE, anEdgeAndNeighbourFaces);
373 for (Standard_Integer i = 1; i <= anEdgeAndNeighbourFaces.Extent(); i++)
375 const TopTools_ListOfShape& aLL = anEdgeAndNeighbourFaces.FindFromIndex(i);
376 if (aLL.Extent() < 2) {
377 if (BRep_Tool::Degenerated(TopoDS::Edge(anEdgeAndNeighbourFaces.FindKey(i))))
379 builder(theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
380 TCollection_AsciiString aStr(theTag);
381 aName = theName + aStr.ToCString();
382 buildName(theTag, aName);
385 TopTools_ListIteratorOfListOfShape anIter(aLL);
386 const TopoDS_Face& aFace = TopoDS::Face(anIter.Value());
388 if(aFace.IsEqual(anIter.Value())) {
389 builder(theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
390 TCollection_AsciiString aStr(theTag);
391 aName = theName + aStr.ToCString();
392 buildName(theTag, aName);
397 } else if (aShape.ShapeType() == TopAbs_WIRE) {
398 TopTools_IndexedMapOfShape Edges;
399 BRepTools::Map3DEdges(aShape, Edges);
400 if (Edges.Extent() == 1) {
401 builder(++theTag)->Generated(Edges.FindKey(1));
402 TopExp_Explorer expl(aShape, TopAbs_VERTEX);
403 for (; expl.More(); expl.Next()) {
404 builder(theTag)->Generated(expl.Current());
405 TCollection_AsciiString aStr(theTag);
406 aName = theName + aStr.ToCString();
407 buildName(theTag, aName);
411 TopExp_Explorer expl(aShape, TopAbs_EDGE);
412 for (; expl.More(); expl.Next()) {
413 builder(theTag)->Generated(expl.Current());
414 TCollection_AsciiString aStr(theTag);
415 aName = theName + aStr.ToCString();
416 buildName(theTag, aName);
419 // and load generated vertices.
420 TopTools_DataMapOfShapeShape generated;
421 if (getDangleShapes(aShape, TopAbs_EDGE, generated))
423 TNaming_Builder* pBuilder = builder(theTag++);
424 loadGeneratedDangleShapes(aShape, TopAbs_EDGE, pBuilder);
427 } else if (aShape.ShapeType() == TopAbs_EDGE) {
428 TopExp_Explorer expl(aShape, TopAbs_VERTEX);
429 for (; expl.More(); expl.Next()) {
430 builder(theTag)->Generated(expl.Current());
431 TCollection_AsciiString aStr(theTag);
432 aName = theName + aStr.ToCString();
433 buildName(theTag, aName);
438 //=======================================================================
439 void Model_ResultBody::loadFirstLevel(
440 std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag)
442 if(theShape->isNull()) return;
443 TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
445 if (aShape.ShapeType() == TopAbs_COMPOUND || aShape.ShapeType() == TopAbs_COMPSOLID) {
446 TopoDS_Iterator itr(aShape);
447 for (; itr.More(); itr.Next(),theTag++) {
448 builder(theTag)->Generated(itr.Value());
449 TCollection_AsciiString aStr(theTag);
450 aName = theName + aStr.ToCString();
451 buildName(theTag, aName);
452 if(!theName.empty()) buildName(theTag, aName);
453 if (itr.Value().ShapeType() == TopAbs_COMPOUND ||
454 itr.Value().ShapeType() == TopAbs_COMPSOLID)
456 std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
457 itrShape->setImpl(new TopoDS_Shape(itr.Value()));
458 loadFirstLevel(itrShape, theName, theTag);
460 std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
461 itrShape->setImpl(new TopoDS_Shape(itr.Value()));
462 loadNextLevels(itrShape, theName, theTag);
466 std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
467 itrShape->setImpl(new TopoDS_Shape(aShape));
468 loadNextLevels(itrShape, theName, theTag);
472 //=======================================================================
473 void Model_ResultBody::loadDisconnectedEdges(
474 std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag)
476 if(theShape->isNull()) return;
477 TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
478 TopTools_DataMapOfShapeListOfShape edgeNaborFaces;
479 TopTools_ListOfShape empty;
480 TopExp_Explorer explF(aShape, TopAbs_FACE);
481 for (; explF.More(); explF.Next()) {
482 const TopoDS_Shape& aFace = explF.Current();
483 TopExp_Explorer explV(aFace, TopAbs_EDGE);
484 for (; explV.More(); explV.Next()) {
485 const TopoDS_Shape& anEdge = explV.Current();
486 if (!edgeNaborFaces.IsBound(anEdge)) edgeNaborFaces.Bind(anEdge, empty);
487 Standard_Boolean faceIsNew = Standard_True;
488 TopTools_ListIteratorOfListOfShape itrF(edgeNaborFaces.Find(anEdge));
489 for (; itrF.More(); itrF.Next()) {
490 if (itrF.Value().IsSame(aFace)) {
491 faceIsNew = Standard_False;
496 edgeNaborFaces.ChangeFind(anEdge).Append(aFace);
500 /* TopTools_IndexedDataMapOfShapeListOfShape aDM;
501 TopExp::MapShapesAndAncestors(aShape, TopAbs_EDGE, TopAbs_FACE, aDM);
502 for(int i=1; i <= aDM.Extent(); i++) {
503 if(aDM.FindFromIndex(i).Extent() > 1) continue;
504 if (BRep_Tool::Degenerated(TopoDS::Edge(aDM.FindKey(i))))
506 builder(theTag)->Generated(aDM.FindKey(i));
507 TCollection_AsciiString aStr(theTag);
508 std::string aName = theName + aStr.ToCString();
509 buildName(theTag, aName);
512 BRepTools::Write(aDM.FindKey(i), aName.c_str());
517 TopTools_MapOfShape anEdgesToDelete;
518 TopExp_Explorer anEx(aShape,TopAbs_EDGE);
520 for(;anEx.More();anEx.Next()) {
521 Standard_Boolean aC0 = Standard_False;
522 TopoDS_Shape anEdge1 = anEx.Current();
523 if (edgeNaborFaces.IsBound(anEdge1)) {
524 const TopTools_ListOfShape& aList1 = edgeNaborFaces.Find(anEdge1);
525 if (aList1.Extent()<2) continue;
526 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(edgeNaborFaces);
527 for (; itr.More(); itr.Next()) {
528 TopoDS_Shape anEdge2 = itr.Key();
529 if(anEdgesToDelete.Contains(anEdge2)) continue;
530 if (anEdge1.IsSame(anEdge2)) continue;
531 const TopTools_ListOfShape& aList2 = itr.Value();
532 // compare lists of the neighbour faces of edge1 and edge2
533 if (aList1.Extent() == aList2.Extent()) {
534 Standard_Integer aMatches = 0;
535 for(TopTools_ListIteratorOfListOfShape aLIter1(aList1);aLIter1.More();aLIter1.Next())
536 for(TopTools_ListIteratorOfListOfShape aLIter2(aList2);aLIter2.More();aLIter2.Next())
537 if (aLIter1.Value().IsSame(aLIter2.Value())) aMatches++;
538 if (aMatches == aList1.Extent()) {
540 builder(theTag)->Generated(anEdge2);
541 anEdgesToDelete.Add(anEdge2);
542 TCollection_AsciiString aStr(theTag);
543 aName = theName + aStr.ToCString();
544 buildName(theTag, aName);
549 TopTools_MapIteratorOfMapOfShape itDelete(anEdgesToDelete);
550 for(;itDelete.More();itDelete.Next())
551 edgeNaborFaces.UnBind(itDelete.Key());
552 edgeNaborFaces.UnBind(anEdge1);
555 builder(theTag)->Generated(anEdge1);
556 TCollection_AsciiString aStr(theTag);
557 aName = theName + aStr.ToCString();
558 buildName(theTag, aName);
564 void Model_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag)
566 if(theShape->isNull()) return;
567 TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
568 TopTools_DataMapOfShapeListOfShape vertexNaborEdges;
569 TopTools_ListOfShape empty;
570 TopExp_Explorer explF(aShape, TopAbs_EDGE);
571 for (; explF.More(); explF.Next()) {
572 const TopoDS_Shape& anEdge = explF.Current();
573 TopExp_Explorer explV(anEdge, TopAbs_VERTEX);
574 for (; explV.More(); explV.Next()) {
575 const TopoDS_Shape& aVertex = explV.Current();
576 if (!vertexNaborEdges.IsBound(aVertex)) vertexNaborEdges.Bind(aVertex, empty);
577 Standard_Boolean faceIsNew = Standard_True;
578 TopTools_ListIteratorOfListOfShape itrF(vertexNaborEdges.Find(aVertex));
579 for (; itrF.More(); itrF.Next()) {
580 if (itrF.Value().IsSame(anEdge)) {
581 faceIsNew = Standard_False;
586 vertexNaborEdges.ChangeFind(aVertex).Append(anEdge);
591 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(vertexNaborEdges);
592 for (; itr.More(); itr.Next()) {
593 const TopTools_ListOfShape& naborEdges = itr.Value();
594 if (naborEdges.Extent() < 2) {
595 builder(theTag)->Generated(itr.Key());
596 TCollection_AsciiString aStr(theTag);
597 aName = theName + aStr.ToCString();
598 buildName(theTag, aName);