]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
authorszy <szy@opencascade.com>
Tue, 30 Dec 2014 09:52:39 +0000 (12:52 +0300)
committerszy <szy@opencascade.com>
Tue, 30 Dec 2014 09:52:39 +0000 (12:52 +0300)
1  2 
src/Model/Model_AttributeSelection.cpp

index ff46a56abbd467cdec624fc337f84c394519ef9f,bcf8a57b3d18bcb63917524d87b95d5b727ee5de..8f60cf0593ef611d9b4fcbcebd03a58bb553cd83
@@@ -8,7 -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>
@@@ -81,16 -80,19 +81,19 @@@ void Model_AttributeSelection::setValue
  
    // do noth use naming if selected shape is result shape itself, but not sub-shape
    TDF_Label aSelLab = selectionLabel();
-   if (theContext->shape().get() && theContext->shape()->isEqual(theSubShape)) {
-     aSelLab.ForgetAllAttributes(true);
-     TDataStd_UAttribute::Set(aSelLab, kSIMPLE_REF_ID);
-   } else {
-     aSelLab.ForgetAttribute(kSIMPLE_REF_ID);
-     if (theContext->groupName() == ModelAPI_ResultBody::group())
+   aSelLab.ForgetAttribute(kSIMPLE_REF_ID);
+   if (theContext->groupName() == ModelAPI_ResultBody::group()) {
+     // do not select the whole shape for body:it is already must be in the data framework
+     if (theContext->shape().get() && theContext->shape()->isEqual(theSubShape)) {
+       aSelLab.ForgetAllAttributes(true);
+       TDataStd_UAttribute::Set(aSelLab, kSIMPLE_REF_ID);
+     } else {
        selectBody(theContext, theSubShape);
-     else if (theContext->groupName() == ModelAPI_ResultConstruction::group())
-       selectConstruction(theContext, theSubShape);
+     }
+   } else if (theContext->groupName() == ModelAPI_ResultConstruction::group()) {
+     selectConstruction(theContext, theSubShape);
    }
+   myIsInitialized = true;
  
    std::string aSelName = namingName();
    if(!aSelName.empty())
    //selectSubShape("EDGE", "Extrusion_1/TopFace|Extrusion_1/LateralFace_1");
    //selectSubShape("EDGE", "Sketch_1/Edge_6");
  #endif
-   myIsInitialized = true;
    owner()->data()->sendAttributeUpdated(this);
  }
  
@@@ -349,6 -350,7 +351,7 @@@ bool Model_AttributeSelection::update(
          }
        }
      } else { // simple construction element: the selected is that needed
+       selectConstruction(aContext, aContext->shape());
        owner()->data()->sendAttributeUpdated(this);
        return true;
      }
@@@ -399,11 -401,11 +402,11 @@@ static void registerSubShape(TDF_Label
    else if (theShape.ShapeType() == TopAbs_VERTEX) aName<<"Vertex";
  
    if (theRefs.IsNull()) {
-     aName<<"_"<<theID;
+     aName<<theID;
    } else { // make a compisite name from all sub-elements indexes: "1_2_3_4"
      TColStd_MapIteratorOfPackedMapOfInteger aRef(theRefs->GetMap());
      for(; aRef.More(); aRef.Next()) {
-       aName<<"_"<<aRef.Key();
+       aName<<"-"<<aRef.Key();
      }
    }
  
@@@ -419,13 -421,18 +422,18 @@@ void Model_AttributeSelection::selectCo
    FeaturePtr aContextFeature = theContext->document()->feature(theContext);
    CompositeFeaturePtr aComposite = 
      std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aContextFeature);
+   const TopoDS_Shape& aSubShape = theSubShape->impl<TopoDS_Shape>();
    if (!aComposite || aComposite->numberOfSubs() == 0) {
-     return; // saving of context is enough: result construction contains exactly the needed shape
+     // saving of context is enough: result construction contains exactly the needed shape
+     TNaming_Builder aBuilder(selectionLabel());
+     aBuilder.Generated(aSubShape);
+     aMyDoc->addNamingName(selectionLabel(), theContext->data()->name());
+     TDataStd_Name::Set(selectionLabel(), theContext->data()->name().c_str());
+     return;
    }
    std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(owner()->data());
    TDF_Label aLab = myRef.myRef->Label();
    // identify the reuslts of sub-object of the composite by edges
-   const TopoDS_Shape& aSubShape = theSubShape->impl<TopoDS_Shape>();
    // save type of the selected shape in integer attribute
    TopAbs_ShapeEnum aShapeType = aSubShape.ShapeType();
    TDataStd_Integer::Set(aLab, (int)aShapeType);
@@@ -820,54 -827,27 +828,54 @@@ const TopoDS_Shape findCommonShape(cons
        }
    }
    //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) 
    {