-void Model_ResultBody::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
-{
- TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
- TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
- builder(theTag)->Modify(anOldShape, aNewShape);
- if(!theName.empty())
- buildName(theTag, theName);
-}
-
-void Model_ResultBody::deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const int theTag)
-{
- TopoDS_Shape aShape = theOldShape->impl<TopoDS_Shape>();
- builder(theTag)->Delete(aShape);
-}
-
-void Model_ResultBody::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag)
-{
- TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
- TopTools_MapOfShape aView;
- TopExp_Explorer ShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
- for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
- const TopoDS_Shape& aRoot = ShapeExplorer.Current ();
- if (!aView.Add(aRoot)) continue;
- std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
- aRShape->setImpl((new TopoDS_Shape(aRoot)));
- if (theMS->isDeleted (aRShape)) {
- builder(theTag)->Delete(aRoot);
- }
- }
-}
-
-void Model_ResultBody::loadAndOrientModifiedShapes (
- GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const std::string& theName,
- GeomAPI_DataMapOfShapeShape& theSubShapes)
-{
- TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
- TopTools_MapOfShape aView;
- bool isBuilt = theName.empty();
- TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
- for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
- const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
- if (!aView.Add(aRoot)) continue;
- ListOfShape aList;
- std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
- aRShape->setImpl((new TopoDS_Shape(aRoot)));
- theMS->modified(aRShape, aList);
- std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aList.begin(), aLast = aList.end();
- for (; anIt != aLast; anIt++) {
- TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();
- if (theSubShapes.isBound(*anIt)) {
- std::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
- aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
- }
- if (!aRoot.IsSame (aNewShape)) {
- builder(theTag)->Modify(aRoot,aNewShape);
- if(!isBuilt)
- buildName(theTag, theName);
- }
- }
- }
-}
-
-void Model_ResultBody::loadAndOrientGeneratedShapes (
- GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const std::string& theName,
- GeomAPI_DataMapOfShapeShape& theSubShapes)
-{
- TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
- TopTools_MapOfShape aView;
- bool isBuilt = theName.empty();
- TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
- for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
- const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
- if (!aView.Add(aRoot)) continue;
- ListOfShape aList;
- std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
- aRShape->setImpl((new TopoDS_Shape(aRoot)));
- theMS->generated(aRShape, aList);
- std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aList.begin(), aLast = aList.end();
- for (; anIt != aLast; anIt++) {
- TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();
- if (theSubShapes.isBound(*anIt)) {
- std::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
- aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
- }
- if (!aRoot.IsSame (aNewShape)) {
- builder(theTag)->Generated(aRoot,aNewShape);
- if(!isBuilt)
- buildName(theTag, theName);
- }
- }
- }
-}
-
-//=======================================================================
-int getDangleShapes(const TopoDS_Shape& theShapeIn,
- const TopAbs_ShapeEnum theGeneratedFrom,
- TopTools_DataMapOfShapeShape& theDangles)
-{
- theDangles.Clear();
- TopTools_IndexedDataMapOfShapeListOfShape subShapeAndAncestors;
- TopAbs_ShapeEnum GeneratedTo;
- if (theGeneratedFrom == TopAbs_FACE) GeneratedTo = TopAbs_EDGE;
- else if (theGeneratedFrom == TopAbs_EDGE) GeneratedTo = TopAbs_VERTEX;
- else return Standard_False;
- TopExp::MapShapesAndAncestors(theShapeIn, GeneratedTo, theGeneratedFrom, subShapeAndAncestors);
- for (Standard_Integer i = 1; i <= subShapeAndAncestors.Extent(); i++) {
- const TopoDS_Shape& mayBeDangle = subShapeAndAncestors.FindKey(i);
- const TopTools_ListOfShape& ancestors = subShapeAndAncestors.FindFromIndex(i);
- if (ancestors.Extent() == 1) theDangles.Bind(ancestors.First(), mayBeDangle);
- }
- return theDangles.Extent();
-}
-
-//=======================================================================
-void loadGeneratedDangleShapes(
- const TopoDS_Shape& theShapeIn,
- const TopAbs_ShapeEnum theGeneratedFrom,
- TNaming_Builder * theBuilder)
-{
- TopTools_DataMapOfShapeShape dangles;
- if (!getDangleShapes(theShapeIn, theGeneratedFrom, dangles)) return;
- TopTools_DataMapIteratorOfDataMapOfShapeShape itr(dangles);
- for (; itr.More(); itr.Next())
- theBuilder->Generated(itr.Key(), itr.Value());