From: mpv Date: Fri, 31 Oct 2014 13:12:09 +0000 (+0300) Subject: Make selection naming works wit hsketch faces (added sub-edges in naming structure) X-Git-Tag: V_0.5~48^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2060965fb573ad7eb9a2ea2f2a11786b40c4b963;p=modules%2Fshaper.git Make selection naming works wit hsketch faces (added sub-edges in naming structure) --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp index 3c9a61fda..85df8286a 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp @@ -34,6 +34,8 @@ boost::shared_ptr GeomAlgoAPI_FaceBuilder::plane( TopoDS_Shape aShape = theFace->impl(); if (aShape.IsNull()) return aResult; // null shape + if (aShape.ShapeType() != TopAbs_FACE) + return aResult; // not face TopoDS_Face aFace = TopoDS::Face(aShape); if (aFace.IsNull()) return aResult; // not face diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index dd360d258..ee90d9fa9 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -105,7 +105,9 @@ bool Model_AttributeSelection::update() TNaming_Selector aSelector(selectionLabel()); TDF_LabelMap aScope; // empty means the whole document owner()->data()->sendAttributeUpdated(this); - return aSelector.Solve(aScope) == Standard_True; + bool aResult = aSelector.Solve(aScope) == Standard_True; + owner()->data()->sendAttributeUpdated(this); + return aResult; } else if (aContext->groupName() == ModelAPI_ResultConstruction::group()) { // construction: identification by the results indexes, recompute faces and // take the face that more close by the indexes @@ -364,7 +366,18 @@ void Model_AttributeSelection::selectConstruction( Standard_Real aFirst, aLast; Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast); if (allCurves.Contains(aCurve)) { - aRefs->Add(aComposite->subFeatureId(a)); + int anID = aComposite->subFeatureId(a); + aRefs->Add(anID); + // add edges to sub-label to support naming for edges selection + for(TopExp_Explorer anEdgeExp(aSubShape, TopAbs_EDGE); anEdgeExp.More(); anEdgeExp.Next()) { + TopoDS_Edge anEdge = TopoDS::Edge(anEdgeExp.Current()); + Standard_Real aFirst, aLast; + Handle(Geom_Curve) aFaceCurve = BRep_Tool::Curve(anEdge, aFirst, aLast); + if (aFaceCurve == aCurve) { + TNaming_Builder anEdgeBuilder(selectionLabel().FindChild(anID)); + anEdgeBuilder.Generated(anEdge); + } + } } } } diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 573086ed0..90bb20e2e 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -404,7 +404,6 @@ void Model_Data::referencesToObjects( boost::shared_ptr aRef = boost::dynamic_pointer_cast< ModelAPI_AttributeSelection>(anAttr->second); aReferenced.push_back(aRef->context()); - theRefs.push_back(std::pair >(anAttr->first, aReferenced)); } else if (aType == ModelAPI_AttributeSelectionList::type()) { // list of selection attributes boost::shared_ptr aRef = boost::dynamic_pointer_cast< ModelAPI_AttributeSelectionList>(anAttr->second); diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index 4aeeeed7a..7e5049531 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -45,7 +45,7 @@ void Model_ResultBody::store(const boost::shared_ptr& theShape) } void Model_ResultBody::storeGenerated(const boost::shared_ptr& theFromShape, - const boost::shared_ptr& theToShape) + const boost::shared_ptr& theToShape) { boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); if (aData) { @@ -59,7 +59,7 @@ void Model_ResultBody::storeGenerated(const boost::shared_ptr& th TopoDS_Shape aShapeBasis = theFromShape->impl(); if (aShapeBasis.IsNull()) return; // null shape inside - TopoDS_Shape aShapeNew = theToShape->impl(); + TopoDS_Shape aShapeNew = theToShape->impl(); if (aShapeNew.IsNull()) return; // null shape inside aBuilder.Generated(aShapeBasis, aShapeNew); @@ -67,7 +67,7 @@ void Model_ResultBody::storeGenerated(const boost::shared_ptr& th } void Model_ResultBody::storeModified(const boost::shared_ptr& theOldShape, - const boost::shared_ptr& theNewShape) + const boost::shared_ptr& theNewShape) { boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); if (aData) { @@ -81,7 +81,7 @@ void Model_ResultBody::storeModified(const boost::shared_ptr& the TopoDS_Shape aShapeOld = theOldShape->impl(); if (aShapeOld.IsNull()) return; // null shape inside - TopoDS_Shape aShapeNew = theNewShape->impl(); + TopoDS_Shape aShapeNew = theNewShape->impl(); if (aShapeNew.IsNull()) return; // null shape inside aBuilder.Generated(aShapeOld, aShapeNew); @@ -127,9 +127,9 @@ TNaming_Builder* Model_ResultBody::builder(const int theTag) if (!myBuilders[theTag]) { boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); myBuilders[theTag] = new TNaming_Builder(aData->shapeLab().FindChild(theTag)); - //TCollection_AsciiString entry;// - //TDF_Tool::Entry(aData->shapeLab().FindChild(theTag), entry); - //cout << "Label = " <shapeLab().FindChild(theTag), entry); + //cout << "Label = " <& theOldShape, - const boost::shared_ptr& theNewShape, const int theTag) + const boost::shared_ptr& theNewShape, const int theTag) { TopoDS_Shape anOldShape = theOldShape->impl(); TopoDS_Shape aNewShape = theNewShape->impl(); @@ -151,7 +151,7 @@ void Model_ResultBody::generated(const boost::shared_ptr& theOldS void Model_ResultBody::modified(const boost::shared_ptr& theOldShape, - const boost::shared_ptr& theNewShape, const int theTag) + const boost::shared_ptr& theNewShape, const int theTag) { TopoDS_Shape anOldShape = theOldShape->impl(); TopoDS_Shape aNewShape = theNewShape->impl(); @@ -159,16 +159,16 @@ void Model_ResultBody::modified(const boost::shared_ptr& theOldSh } void Model_ResultBody::deleted(const boost::shared_ptr& theOldShape, - const int theTag) + const int theTag) { TopoDS_Shape aShape = theOldShape->impl(); builder(theTag)->Delete(aShape); } void Model_ResultBody::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS, - boost::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag) + boost::shared_ptr theShapeIn, + const int theKindOfShape, + const int theTag) { TopoDS_Shape aShapeIn = theShapeIn->impl(); TopTools_MapOfShape aView; @@ -176,20 +176,20 @@ void Model_ResultBody::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS, for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { const TopoDS_Shape& aRoot = ShapeExplorer.Current (); if (!aView.Add(aRoot)) continue; - boost::shared_ptr aRShape(new GeomAPI_Shape()); - aRShape->setImpl((new TopoDS_Shape(aRoot))); + boost::shared_ptr aRShape(new GeomAPI_Shape()); + aRShape->setImpl((new TopoDS_Shape(aRoot))); if (theMS->isDeleted (aRShape)) { - builder(theTag)->Delete(aRoot); + builder(theTag)->Delete(aRoot); } } } void Model_ResultBody::loadAndOrientModifiedShapes ( - GeomAlgoAPI_MakeShape* theMS, - boost::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - GeomAPI_DataMapOfShapeShape& theSubShapes) + GeomAlgoAPI_MakeShape* theMS, + boost::shared_ptr theShapeIn, + const int theKindOfShape, + const int theTag, + GeomAPI_DataMapOfShapeShape& theSubShapes) { TopoDS_Shape aShapeIn = theShapeIn->impl(); TopTools_MapOfShape aView; @@ -197,29 +197,29 @@ void Model_ResultBody::loadAndOrientModifiedShapes ( for (; aShapeExplorer.More(); aShapeExplorer.Next ()) { const TopoDS_Shape& aRoot = aShapeExplorer.Current (); if (!aView.Add(aRoot)) continue; - ListOfShape aList; - boost::shared_ptr aRShape(new GeomAPI_Shape()); - aRShape->setImpl((new TopoDS_Shape(aRoot))); + ListOfShape aList; + boost::shared_ptr aRShape(new GeomAPI_Shape()); + aRShape->setImpl((new TopoDS_Shape(aRoot))); theMS->modified(aRShape, aList); - std::list >::const_iterator anIt = aList.begin(), aLast = aList.end(); + std::list >::const_iterator anIt = aList.begin(), aLast = aList.end(); for (; anIt != aLast; anIt++) { TopoDS_Shape aNewShape = (*anIt)->impl(); - if (theSubShapes.isBound(*anIt)) { - boost::shared_ptr aMapShape(theSubShapes.find(*anIt)); - aNewShape.Orientation(aMapShape->impl().Orientation()); + if (theSubShapes.isBound(*anIt)) { + boost::shared_ptr aMapShape(theSubShapes.find(*anIt)); + aNewShape.Orientation(aMapShape->impl().Orientation()); } if (!aRoot.IsSame (aNewShape)) - builder(theTag)->Modify(aRoot,aNewShape); + builder(theTag)->Modify(aRoot,aNewShape); } } } void Model_ResultBody::loadAndOrientGeneratedShapes ( - GeomAlgoAPI_MakeShape* theMS, - boost::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - GeomAPI_DataMapOfShapeShape& theSubShapes) + GeomAlgoAPI_MakeShape* theMS, + boost::shared_ptr theShapeIn, + const int theKindOfShape, + const int theTag, + GeomAPI_DataMapOfShapeShape& theSubShapes) { TopoDS_Shape aShapeIn = theShapeIn->impl(); TopTools_MapOfShape aView; @@ -227,19 +227,19 @@ void Model_ResultBody::loadAndOrientGeneratedShapes ( for (; aShapeExplorer.More(); aShapeExplorer.Next ()) { const TopoDS_Shape& aRoot = aShapeExplorer.Current (); if (!aView.Add(aRoot)) continue; - ListOfShape aList; - boost::shared_ptr aRShape(new GeomAPI_Shape()); - aRShape->setImpl((new TopoDS_Shape(aRoot))); - theMS->generated(aRShape, aList); - std::list >::const_iterator anIt = aList.begin(), aLast = aList.end(); + ListOfShape aList; + boost::shared_ptr aRShape(new GeomAPI_Shape()); + aRShape->setImpl((new TopoDS_Shape(aRoot))); + theMS->generated(aRShape, aList); + std::list >::const_iterator anIt = aList.begin(), aLast = aList.end(); for (; anIt != aLast; anIt++) { TopoDS_Shape aNewShape = (*anIt)->impl(); - if (theSubShapes.isBound(*anIt)) { - boost::shared_ptr aMapShape(theSubShapes.find(*anIt)); - aNewShape.Orientation(aMapShape->impl().Orientation()); + if (theSubShapes.isBound(*anIt)) { + boost::shared_ptr aMapShape(theSubShapes.find(*anIt)); + aNewShape.Orientation(aMapShape->impl().Orientation()); } if (!aRoot.IsSame (aNewShape)) - builder(theTag)->Generated(aRoot,aNewShape); + builder(theTag)->Generated(aRoot,aNewShape); } } }