From: szy Date: Mon, 29 Dec 2014 12:29:41 +0000 (+0300) Subject: Added selectSubShape() method (part1: face selection) X-Git-Tag: V_0.7.0_rc1~17^2~1^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=84c4dc29a6bd04fcde759a25ece0503b24dcb78a;p=modules%2Fshaper.git Added selectSubShape() method (part1: face selection) --- diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 9a54673f5..fa96b0ce6 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -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& 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 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;