]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make selection naming works wit hsketch faces (added sub-edges in naming structure)
authormpv <mikhail.ponikarov@opencascade.com>
Fri, 31 Oct 2014 13:12:09 +0000 (16:12 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Fri, 31 Oct 2014 13:12:09 +0000 (16:12 +0300)
src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp
src/Model/Model_AttributeSelection.cpp
src/Model/Model_Data.cpp
src/Model/Model_ResultBody.cpp

index 3c9a61fda4fdd8a23a07ce7f073ddffb7768bb01..85df8286aa5288e9ee402ec670fa6260c7934b53 100644 (file)
@@ -34,6 +34,8 @@ boost::shared_ptr<GeomAPI_Pln> GeomAlgoAPI_FaceBuilder::plane(
   TopoDS_Shape aShape = theFace->impl<TopoDS_Shape>();
   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
index dd360d258474f4baf9e732802c6eff3e5940511b..ee90d9fa98aa158036b150155687e35955381bc9 100644 (file)
@@ -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);
+                }
+              }
             }
           }
         }
index 573086ed0a31d441a51f47b4fbf3efe5c2776df2..90bb20e2e2fa3a5d6983673d621249c616e7334c 100644 (file)
@@ -404,7 +404,6 @@ void Model_Data::referencesToObjects(
       boost::shared_ptr<ModelAPI_AttributeSelection> aRef = boost::dynamic_pointer_cast<
           ModelAPI_AttributeSelection>(anAttr->second);
       aReferenced.push_back(aRef->context());
-      theRefs.push_back(std::pair<std::string, std::list<ObjectPtr> >(anAttr->first, aReferenced));
     } else if (aType == ModelAPI_AttributeSelectionList::type()) { // list of selection attributes
       boost::shared_ptr<ModelAPI_AttributeSelectionList> aRef = boost::dynamic_pointer_cast<
           ModelAPI_AttributeSelectionList>(anAttr->second);
index 4aeeeed7a5ec78c36a9fc936d06df5461f6df989..7e504953170efd29fb1f71ab9f57a2937acd8a44 100644 (file)
@@ -45,7 +45,7 @@ void Model_ResultBody::store(const boost::shared_ptr<GeomAPI_Shape>& theShape)
 }
 
 void Model_ResultBody::storeGenerated(const boost::shared_ptr<GeomAPI_Shape>& theFromShape,
-                                         const boost::shared_ptr<GeomAPI_Shape>& theToShape)
+  const boost::shared_ptr<GeomAPI_Shape>& theToShape)
 {
   boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(data());
   if (aData) {
@@ -59,7 +59,7 @@ void Model_ResultBody::storeGenerated(const boost::shared_ptr<GeomAPI_Shape>& th
     TopoDS_Shape aShapeBasis = theFromShape->impl<TopoDS_Shape>();
     if (aShapeBasis.IsNull())
       return;  // null shape inside
-       TopoDS_Shape aShapeNew = theToShape->impl<TopoDS_Shape>();
+    TopoDS_Shape aShapeNew = theToShape->impl<TopoDS_Shape>();
     if (aShapeNew.IsNull())
       return;  // null shape inside
     aBuilder.Generated(aShapeBasis, aShapeNew);
@@ -67,7 +67,7 @@ void Model_ResultBody::storeGenerated(const boost::shared_ptr<GeomAPI_Shape>& th
 }
 
 void Model_ResultBody::storeModified(const boost::shared_ptr<GeomAPI_Shape>& theOldShape,
-                                         const boost::shared_ptr<GeomAPI_Shape>& theNewShape)
+  const boost::shared_ptr<GeomAPI_Shape>& theNewShape)
 {
   boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(data());
   if (aData) {
@@ -81,7 +81,7 @@ void Model_ResultBody::storeModified(const boost::shared_ptr<GeomAPI_Shape>& the
     TopoDS_Shape aShapeOld = theOldShape->impl<TopoDS_Shape>();
     if (aShapeOld.IsNull())
       return;  // null shape inside
-       TopoDS_Shape aShapeNew = theNewShape->impl<TopoDS_Shape>();
+    TopoDS_Shape aShapeNew = theNewShape->impl<TopoDS_Shape>();
     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<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(data());
     myBuilders[theTag] = new TNaming_Builder(aData->shapeLab().FindChild(theTag));
-       //TCollection_AsciiString entry;//
-       //TDF_Tool::Entry(aData->shapeLab().FindChild(theTag), entry);
-       //cout << "Label = " <<entry.ToCString() <<endl;
+    //TCollection_AsciiString entry;//
+    //TDF_Tool::Entry(aData->shapeLab().FindChild(theTag), entry);
+    //cout << "Label = " <<entry.ToCString() <<endl;
   }
   return myBuilders[theTag];
 }
@@ -142,7 +142,7 @@ void Model_ResultBody::generated(
 }
 
 void Model_ResultBody::generated(const boost::shared_ptr<GeomAPI_Shape>& theOldShape,
-    const boost::shared_ptr<GeomAPI_Shape>& theNewShape, const int theTag)
+  const boost::shared_ptr<GeomAPI_Shape>& theNewShape, const int theTag)
 {
   TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
   TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
@@ -151,7 +151,7 @@ void Model_ResultBody::generated(const boost::shared_ptr<GeomAPI_Shape>& theOldS
 
 
 void Model_ResultBody::modified(const boost::shared_ptr<GeomAPI_Shape>& theOldShape,
-    const boost::shared_ptr<GeomAPI_Shape>& theNewShape, const int theTag)
+  const boost::shared_ptr<GeomAPI_Shape>& theNewShape, const int theTag)
 {
   TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
   TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
@@ -159,16 +159,16 @@ void Model_ResultBody::modified(const boost::shared_ptr<GeomAPI_Shape>& theOldSh
 }
 
 void Model_ResultBody::deleted(const boost::shared_ptr<GeomAPI_Shape>& theOldShape,
-    const int theTag)
+  const int theTag)
 {
   TopoDS_Shape aShape = theOldShape->impl<TopoDS_Shape>();
   builder(theTag)->Delete(aShape);
 }
 
 void Model_ResultBody::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
-                                               boost::shared_ptr<GeomAPI_Shape>  theShapeIn,
-                                               const int  theKindOfShape,
-                                               const int  theTag)
+  boost::shared_ptr<GeomAPI_Shape>  theShapeIn,
+  const int  theKindOfShape,
+  const int  theTag)
 {
   TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
   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<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
-       aRShape->setImpl((new TopoDS_Shape(aRoot)));
+    boost::shared_ptr<GeomAPI_Shape> 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<GeomAPI_Shape>  theShapeIn,
-                                               const int  theKindOfShape,
-                                               const int  theTag,
-                                               GeomAPI_DataMapOfShapeShape& theSubShapes)
+  GeomAlgoAPI_MakeShape* theMS,
+  boost::shared_ptr<GeomAPI_Shape>  theShapeIn,
+  const int  theKindOfShape,
+  const int  theTag,
+  GeomAPI_DataMapOfShapeShape& theSubShapes)
 {
   TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
   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<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
-       aRShape->setImpl((new TopoDS_Shape(aRoot)));
+    ListOfShape aList;
+    boost::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
+    aRShape->setImpl((new TopoDS_Shape(aRoot)));
        theMS->modified(aRShape, aList);
-       std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aList.begin(), aLast = aList.end();
+    std::list<boost::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)) {
-               boost::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
-               aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
+      if (theSubShapes.isBound(*anIt)) {
+        boost::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
+        aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().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<GeomAPI_Shape>  theShapeIn,
-                                               const int  theKindOfShape,
-                                               const int  theTag,
-                                               GeomAPI_DataMapOfShapeShape& theSubShapes)
+  GeomAlgoAPI_MakeShape* theMS,
+  boost::shared_ptr<GeomAPI_Shape>  theShapeIn,
+  const int  theKindOfShape,
+  const int  theTag,
+  GeomAPI_DataMapOfShapeShape& theSubShapes)
 {
   TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
   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<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
-       aRShape->setImpl((new TopoDS_Shape(aRoot)));
-       theMS->generated(aRShape, aList);
-       std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aList.begin(), aLast = aList.end();
+    ListOfShape aList;
+    boost::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
+    aRShape->setImpl((new TopoDS_Shape(aRoot)));
+    theMS->generated(aRShape, aList);
+    std::list<boost::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)) {
-               boost::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
-               aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
+      if (theSubShapes.isBound(*anIt)) {
+        boost::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
+        aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
       }
       if (!aRoot.IsSame (aNewShape)) 
-                 builder(theTag)->Generated(aRoot,aNewShape);
+        builder(theTag)->Generated(aRoot,aNewShape);
     }
   }
 }