]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Added selectSubShape() method (part1: face selection)
authorszy <szy@opencascade.com>
Mon, 29 Dec 2014 12:29:41 +0000 (15:29 +0300)
committerszy <szy@opencascade.com>
Mon, 29 Dec 2014 12:29:41 +0000 (15:29 +0300)
src/Model/Model_AttributeSelection.cpp

index 9a54673f58b1211563e9547be2743b044baa77f1..fa96b0ce6f60d4a01b4dfe2112ecbf951075833c 100644 (file)
@@ -63,7 +63,7 @@ Standard_GUID kSIMPLE_REF_ID("635eacb2-a1d6-4dec-8348-471fae17cb29");
 // TDataStd_IntPackedMap - indexes of edges in composite element (for construction)
 // TDataStd_Integer - type of the selected shape (for construction)
 // TDF_Reference - from ReferenceAttribute, the context
-
+#define DDDD 1
 void Model_AttributeSelection::setValue(const ResultPtr& theContext,
   const std::shared_ptr<GeomAPI_Shape>& theSubShape)
 {
@@ -94,7 +94,11 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext,
   std::string aSelName = namingName();
   if(!aSelName.empty())
          TDataStd_Name::Set(selectionLabel(), aSelName.c_str()); //set name
-
+#ifdef DDDD
+  //####
+  //selectSubShape("FACE",  "Extrusion_1/LateralFace_3");
+  //selectSubShape("FACE",  "Extrusion_1/TopFace");
+#endif
   myIsInitialized = true;
   owner()->data()->sendAttributeUpdated(this);
 }
@@ -725,8 +729,8 @@ const TopoDS_Shape getShapeFromCompound(const std::string& theSubShapeName, cons
 {
   TopoDS_Shape aSelection;
   std::string::size_type n = theSubShapeName.rfind('/');                       
-  if (n == std::string::npos) n = 1;
-       std::string aSubString = theSubShapeName.substr(n);
+  if (n == std::string::npos) n = 0;
+       std::string aSubString = theSubShapeName.substr(n + 1);
        n = aSubString.rfind('_');
        if (n == std::string::npos) return aSelection;
        aSubString = aSubString.substr(n+1);
@@ -745,7 +749,18 @@ const TopoDS_Shape getShapeFromCompound(const std::string& theSubShapeName, cons
 const TopoDS_Shape findFaceByName(const std::string& theSubShapeName, std::shared_ptr<Model_Document> theDoc)
 {
   TopoDS_Shape aFace;
-  const TDF_Label& aLabel = theDoc->findNamingName(theSubShapeName);
+  std::string::size_type n, nb = theSubShapeName.rfind('/');                   
+  if (nb == std::string::npos) nb = 0;
+  std::string aSubString = theSubShapeName.substr(nb + 1);
+  n = aSubString.rfind('_');
+  if (n != std::string::npos) {
+         std::string aSubStr2 = aSubString.substr(0, n);
+       aSubString  = theSubShapeName.substr(0, nb + 1);
+       aSubString = aSubString + aSubStr2;     
+  } else
+       aSubString = theSubShapeName;
+                               
+  const TDF_Label& aLabel = theDoc->findNamingName(aSubString);
   if(aLabel.IsNull()) return aFace;
   Handle(TNaming_NamedShape) aNS;
   if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
@@ -759,6 +774,16 @@ const TopoDS_Shape findFaceByName(const std::string& theSubShapeName, std::share
   }
   return aFace;
 }
+
+int ParseEdgeName(const std::string& theSubShapeName)
+{
+  int n = theSubShapeName.find('|');
+  if (n == std::string::npos) return 0;
+  std::string aName = theSubShapeName.substr(0, n); //name of face
+  std::string aSubString = theSubShapeName.substr(n + 1);
+  //...
+}
+// type ::= COMP | COMS | SOLD | SHEL | FACE | WIRE | EDGE | VERT
 void Model_AttributeSelection::selectSubShape(const std::string& theType, const std::string& theSubShapeName)
 {
   if(theSubShapeName.empty() || theType.empty()) return;