]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Edges selection - second part.
authorszy <szy@opencascade.com>
Tue, 30 Dec 2014 09:51:56 +0000 (12:51 +0300)
committerszy <szy@opencascade.com>
Tue, 30 Dec 2014 09:51:56 +0000 (12:51 +0300)
src/Model/Model_AttributeSelection.cpp

index cb6db8e7478f9efdb9b905ef42751a12bb28aecf..ff46a56abbd467cdec624fc337f84c394519ef9f 100644 (file)
@@ -8,6 +8,7 @@
 #include "Model_Application.h"
 #include "Model_Events.h"
 #include "Model_Data.h"
+#include "Model_Document.h"
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultConstruction.h>
@@ -819,27 +820,54 @@ const TopoDS_Shape findCommonShape(const TopAbs_ShapeEnum theType, const TopTool
        }
   }
   //trivial case: 2 faces
+  TopTools_ListOfShape aList;
   TopTools_MapIteratorOfMapOfShape it2(aVec[0]);
   for(;it2.More();it2.Next()) {
-         if(aVec[1].Contains(it2.Key())) {
-           aShape = it2.Key();
-               break;
+       if(aVec[1].Contains(it2.Key())) {
+         aShape = it2.Key();
+         if(theList.Extent() == 2)
+           break;
+         else 
+               aList.Append(it2.Key());
+       }
+  }
+  if(aList.Extent()) {// list of common edges ==> search ny neighbors 
+       if(aVec[2].Extent() && aVec[3].Extent()) {
+         TopTools_ListIteratorOfListOfShape it(aList);
+         for(;it.More();it.Next()) {
+               const TopoDS_Shape& aCand = it.Value();
+               // not yet implemented
+
          }
+       }
   }
   return aShape;
 }
+
+std::string getContextName(const std::string& theSubShapeName)
+{
+  std::string aName;
+  std::string::size_type n = theSubShapeName.find('/');                        
+  if (n == std::string::npos) return aName;
+  aName = theSubShapeName.substr(0, n);
+  return aName;
+}
 // 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;
   TopAbs_ShapeEnum aType = translateType(theType);
-  ResultPtr aCont = context();
+  std::shared_ptr<Model_Document> aDoc =  std::dynamic_pointer_cast<Model_Document>(owner()->document());//std::dynamic_pointer_cast<Model_Document>(aCont->document());
+  std::string aContName = getContextName(theSubShapeName);
+  if(aContName.empty()) return;
+  //ResultPtr aCont = context();
+  ResultPtr aCont = aDoc->findByName(aContName);
   if(!aCont.get() || aCont->shape()->isNull()) return;
   TopoDS_Shape aContext  = aCont->shape()->impl<TopoDS_Shape>();
   TopAbs_ShapeEnum aContType = aContext.ShapeType();
   if(aType <= aContType) return; // not applicable
-
-  std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(aCont->document());
+  
   TopoDS_Shape aSelection;
   switch (aType) 
   {