From caa2ac92b289e88592286da703c871dd58147b88 Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 21 Sep 2018 16:18:05 +0300 Subject: [PATCH] Issue #2622: Weak naming Implementation of weak-naming dump to python script --- src/ExchangePlugin/ExchangePlugin_Dump.cpp | 7 +- src/ExchangePlugin/ExchangePlugin_Dump.h | 24 ++- src/ExchangePlugin/plugin-Exchange.xml | 12 +- src/GeomAlgoAPI/CMakeLists.txt | 2 + src/GeomAlgoAPI/GeomAlgoAPI_NExplode.cpp | 180 ++++++++++++++++++ src/GeomAlgoAPI/GeomAlgoAPI_NExplode.h | 49 +++++ src/Model/Model_AttributeSelection.cpp | 27 +++ src/Model/Model_AttributeSelection.h | 3 + src/Model/Model_AttributeSelectionList.cpp | 18 ++ src/Model/Model_AttributeSelectionList.h | 4 + src/ModelAPI/ModelAPI_AttributeSelection.h | 4 + .../ModelAPI_AttributeSelectionList.h | 4 + src/ModelHighAPI/ModelHighAPI_Dumper.cpp | 13 +- src/ModelHighAPI/ModelHighAPI_Dumper.h | 5 + src/ModelHighAPI/ModelHighAPI_Selection.cpp | 17 ++ src/ModelHighAPI/ModelHighAPI_Selection.h | 11 +- 16 files changed, 372 insertions(+), 8 deletions(-) create mode 100644 src/GeomAlgoAPI/GeomAlgoAPI_NExplode.cpp create mode 100644 src/GeomAlgoAPI/GeomAlgoAPI_NExplode.h diff --git a/src/ExchangePlugin/ExchangePlugin_Dump.cpp b/src/ExchangePlugin/ExchangePlugin_Dump.cpp index dc74c54c4..dbec8bef6 100644 --- a/src/ExchangePlugin/ExchangePlugin_Dump.cpp +++ b/src/ExchangePlugin/ExchangePlugin_Dump.cpp @@ -44,8 +44,8 @@ void ExchangePlugin_Dump::initAttributes() data()->addAttribute(FILE_PATH_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(FILE_FORMAT_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(GEOMETRIC_DUMP_ID(), ModelAPI_AttributeBoolean::typeId()); - boolean(GEOMETRIC_DUMP_ID())->setValue(false); + data()->addAttribute(SELECTION_TYPE_ID(), ModelAPI_AttributeString::typeId()); + //string(SELECTION_TYPE_ID())->setValue(TOPOLOGICAL_NAMING_DUMP_ID()); // default value } void ExchangePlugin_Dump::execute() @@ -66,7 +66,8 @@ void ExchangePlugin_Dump::dump(const std::string& theFileName) ModelHighAPI_Dumper* aDumper = ModelHighAPI_Dumper::getInstance(); aDumper->clear(); - aDumper->setSelectionByGeometry(boolean(GEOMETRIC_DUMP_ID())->value()); + aDumper->setSelectionByGeometry(string(SELECTION_TYPE_ID())->value() == GEOMETRIC_DUMP_ID()); + aDumper->setSelectionWeakNaming(string(SELECTION_TYPE_ID())->value() == WEAK_NAMING_DUMP_ID()); DocumentPtr aDoc = ModelAPI_Session::get()->moduleDocument(); diff --git a/src/ExchangePlugin/ExchangePlugin_Dump.h b/src/ExchangePlugin/ExchangePlugin_Dump.h index 591838dfe..06047cde0 100644 --- a/src/ExchangePlugin/ExchangePlugin_Dump.h +++ b/src/ExchangePlugin/ExchangePlugin_Dump.h @@ -51,13 +51,33 @@ public: static const std::string MY_FILE_FORMAT_ID("file_format"); return MY_FILE_FORMAT_ID; } - /// attribute name of flag dumping by geometric selection (not by naming) + /// attribute name of selection type string (GUI radio button) of dumping by topological naming + inline static const std::string& SELECTION_TYPE_ID() + { + static const std::string MY_SELECTION_TYPE_ID("selection_type"); + return MY_SELECTION_TYPE_ID; + } + + /// string identifier of dumping by topological naming + inline static const std::string& TOPOLOGICAL_NAMING_DUMP_ID() + { + static const std::string MY_TOOPNAMING_DUMP_ID("topological_naming"); + return MY_TOOPNAMING_DUMP_ID; + } + /// string identifier of dumping by geometric selection inline static const std::string& GEOMETRIC_DUMP_ID() { - static const std::string MY_GEOM_DUMP_ID("geometric_dump"); + static const std::string MY_GEOM_DUMP_ID("geometric_selection"); return MY_GEOM_DUMP_ID; } + /// string identifier of dumping by using weak naming identifiers of selection + inline static const std::string& WEAK_NAMING_DUMP_ID() + { + static const std::string MY_WEAK_NAMING_DUMP_ID("weak_naming"); + return MY_WEAK_NAMING_DUMP_ID; + } + /// Default constructor EXCHANGEPLUGIN_EXPORT ExchangePlugin_Dump(); /// Default destructor diff --git a/src/ExchangePlugin/plugin-Exchange.xml b/src/ExchangePlugin/plugin-Exchange.xml index 5bd7fb979..cdf7370b0 100755 --- a/src/ExchangePlugin/plugin-Exchange.xml +++ b/src/ExchangePlugin/plugin-Exchange.xml @@ -41,7 +41,17 @@ email : webmaster.salome@opencascade.com - + + + + + diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 4038fb2de..77e7d3b1a 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -78,6 +78,7 @@ SET(PROJECT_HEADERS GeomAlgoAPI_SortListOfShapes.h GeomAlgoAPI_Filling.h GeomAlgoAPI_CurveBuilder.h + GeomAlgoAPI_NExplode.h ) SET(PROJECT_SOURCES @@ -134,6 +135,7 @@ SET(PROJECT_SOURCES GeomAlgoAPI_SortListOfShapes.cpp GeomAlgoAPI_Filling.cpp GeomAlgoAPI_CurveBuilder.cpp + GeomAlgoAPI_NExplode.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_NExplode.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_NExplode.cpp new file mode 100644 index 000000000..392ac4c4c --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_NExplode.cpp @@ -0,0 +1,180 @@ +// Copyright (C) 2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// + +#include "GeomAlgoAPI_NExplode.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +static std::pair ShapeToDouble (const TopoDS_Shape& S) +{ + // Computing of CentreOfMass + gp_Pnt GPoint; + double Len; + + if (S.ShapeType() == TopAbs_VERTEX) { + GPoint = BRep_Tool::Pnt(TopoDS::Vertex(S)); + Len = (double)S.Orientation(); + } + else { + GProp_GProps GPr; + if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { + BRepGProp::LinearProperties(S, GPr); + } + else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { + BRepGProp::SurfaceProperties(S, GPr); + } + else { + BRepGProp::VolumeProperties(S, GPr); + } + GPoint = GPr.CentreOfMass(); + Len = GPr.Mass(); + } + + double dMidXYZ = GPoint.X() * 999.0 + GPoint.Y() * 99.0 + GPoint.Z() * 0.9; + return std::make_pair(dMidXYZ, Len); +} + +/*! +* \brief Sort shapes in the list by their coordinates. +*/ +struct CompareShapes : public std::binary_function +{ + typedef NCollection_DataMap > DataMapOfShapeDouble; + + CompareShapes(DataMapOfShapeDouble* theCashMap) : myMap(theCashMap) {} + + bool operator() (const TopoDS_Shape& lhs, const TopoDS_Shape& rhs); + + DataMapOfShapeDouble* myMap; +}; + +bool CompareShapes::operator() (const TopoDS_Shape& theShape1, + const TopoDS_Shape& theShape2) +{ + if (!myMap->IsBound(theShape1)) { + myMap->Bind(theShape1, ShapeToDouble(theShape1)); + } + + if (!myMap->IsBound(theShape2)) { + myMap->Bind(theShape2, ShapeToDouble(theShape2)); + } + + std::pair val1 = myMap->Find(theShape1); + std::pair val2 = myMap->Find(theShape2); + + double tol = Precision::Confusion(); + bool exchange = Standard_False; + + double dMidXYZ = val1.first - val2.first; + if (dMidXYZ >= tol) { + exchange = Standard_True; + } + else if (Abs(dMidXYZ) < tol) { + double dLength = val1.second - val2.second; + if (dLength >= tol) { + exchange = Standard_True; + } + else if (Abs(dLength) < tol && theShape1.ShapeType() <= TopAbs_FACE) { + // equal values possible on shapes such as two halves of a sphere and + // a membrane inside the sphere + Bnd_Box box1,box2; + BRepBndLib::Add(theShape1, box1); + if (!box1.IsVoid()) { + BRepBndLib::Add(theShape2, box2); + Standard_Real dSquareExtent = box1.SquareExtent() - box2.SquareExtent(); + if (dSquareExtent >= tol) { + exchange = Standard_True; + } + else if (Abs(dSquareExtent) < tol) { + Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, val1, val2; + box1.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + val1 = (aXmin+aXmax)*999.0 + (aYmin+aYmax)*99.0 + (aZmin+aZmax)*0.9; + box2.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + val2 = (aXmin+aXmax)*999.0 + (aYmin+aYmax)*99.0 + (aZmin+aZmax)*0.9; + if ((val1 - val2) >= tol) { + exchange = Standard_True; + } + } + } + } else // compare adresses if shapes are geometrically equal + return theShape1.TShape().get() > theShape2.TShape().get(); + } + + //return val1 < val2; + return !exchange; +} + +GeomAlgoAPI_NExplode::GeomAlgoAPI_NExplode( + const GeomShapePtr theContext, const GeomAPI_Shape::ShapeType theShapeType) +{ + std::vector aShapesVec; + + const TopoDS_Shape& aContext = theContext->impl(); + TopExp_Explorer anExp(aContext, (TopAbs_ShapeEnum)theShapeType); + TopTools_MapOfShape aMapShape; + for(; anExp.More(); anExp.Next()) { + if (aMapShape.Add(anExp.Current())) + aShapesVec.push_back(anExp.Current()); + } + + CompareShapes::DataMapOfShapeDouble aCash; + CompareShapes shComp(&aCash); + std::stable_sort(aShapesVec.begin(), aShapesVec.end(), shComp); + + std::vector::const_iterator anIter = aShapesVec.begin(); + for (; anIter != aShapesVec.end(); ++anIter) { + GeomShapePtr aShapePtr(new GeomAPI_Shape); + aShapePtr->setImpl(new TopoDS_Shape(*anIter)); + mySorted.push_back(aShapePtr); + } +} + +int GeomAlgoAPI_NExplode::index(const GeomShapePtr theSubShape) +{ + ListOfShape::iterator anIter = mySorted.begin(); + for(int anIndex = 1; anIter != mySorted.end(); anIter++, anIndex++) { + if ((*anIter)->isSame(theSubShape)) + return anIndex; + } + return 0; // not found +} + +GeomShapePtr GeomAlgoAPI_NExplode::shape(const int theIndex) +{ + ListOfShape::iterator anIter = mySorted.begin(); + for(int anIndex = 1; anIter != mySorted.end(); anIter++, anIndex++) { + if (anIndex == theIndex) + return *anIter; + } + return GeomShapePtr(); // not found +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_NExplode.h b/src/GeomAlgoAPI/GeomAlgoAPI_NExplode.h new file mode 100644 index 000000000..146ab9a49 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_NExplode.h @@ -0,0 +1,49 @@ +// Copyright (C) 2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// + +#ifndef GeomAlgoAPI_NExplode_H_ +#define GeomAlgoAPI_NExplode_H_ + +#include "GeomAlgoAPI.h" + +#include + +/// \class GeomAlgoAPI_NExplode +/// \ingroup DataAlgo +/// \brief Sort shapes by their centers of mass, using formula X*999 + Y*99 + Z*0.9. +/// Algorithm is copied from GEOM module, which uses nexplode Draw command from OCCT. +/// Used for getting index of sub0shape in WeakNaming algorithm. +class GeomAlgoAPI_NExplode +{ + public: + /// \brief Initializes the sorted list of shapes by the context shape and type of sub-shapes. + GEOMALGOAPI_EXPORT GeomAlgoAPI_NExplode( + const GeomShapePtr theContext, const GeomAPI_Shape::ShapeType theShapeType); + + /// Returns an index (started from one) of sub-shape in the sorted list. Returns 0 if not found. + GEOMALGOAPI_EXPORT int index(const GeomShapePtr theSubShape); + /// Returns a shape by an index (started from one). Returns null if not found. + GEOMALGOAPI_EXPORT GeomShapePtr shape(const int theIndex); + +protected: + ListOfShape mySorted; +}; + +#endif diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 7a0652391..af1020ab5 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -1154,6 +1155,32 @@ void Model_AttributeSelection::selectSubShape(const std::string& theType, reset(); } +void Model_AttributeSelection::selectSubShape(const std::string& theType, + const std::string& theContextName, const int theIndex) +{ + // selection of context by name + //std::string aNamingContextName = theContextName + "/"; + //selectSubShape(theType, aNamingContextName); + std::shared_ptr aDoc = + std::dynamic_pointer_cast(owner()->document()); + if (aDoc.get()) { + bool aUnique = true; + std::string aContextName = theContextName; + std::string anEmptySub = ""; + ResultPtr aContext = aDoc->findByName(aContextName, anEmptySub, aUnique); + //ResultPtr aContext = context(); + if (aContext.get()) { + GeomShapePtr aContShape = aContext->shape(); + if (aContShape.get()) { + GeomAlgoAPI_NExplode aNExp(aContShape, GeomAPI_Shape::shapeTypeByStr(theType)); + GeomShapePtr aValue = aNExp.shape(theIndex); + if (aValue.get()) + setValue(aContext, aValue); + } + } + } +} + int Model_AttributeSelection::Id() { int anID = 0; diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index ac31cb335..cafa6ea37 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -111,6 +111,9 @@ public: /// Selects sub-shape by its inner point MODEL_EXPORT virtual void selectSubShape(const std::string& theType, const std::shared_ptr& thePoint); + /// Selects sub-shape by weak naming index + MODEL_EXPORT virtual void selectSubShape(const std::string& theType, + const std::string& theContextName, const int theIndex); /// Returns true if attribute was initialized by some value MODEL_EXPORT virtual bool isInitialized(); diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index c7e852221..9fb412407 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -113,6 +113,24 @@ void Model_AttributeSelectionList::append(const GeomPointPtr& thePoint, const st owner()->data()->sendAttributeUpdated(this); } +void Model_AttributeSelectionList::append(const std::string& theType, + const std::string& theContextName, const int theIndex) +{ + int aNewTag = mySize->Get() + 1; + TDF_Label aNewLab = mySize->Label().FindChild(aNewTag); + + std::shared_ptr aNewAttr = + std::shared_ptr(new Model_AttributeSelection(aNewLab)); + if (owner()) { + aNewAttr->setObject(owner()); + aNewAttr->setParent(this); + } + aNewAttr->setID(id()); + mySize->Set(aNewTag); + aNewAttr->selectSubShape(theType, theContextName, theIndex); + owner()->data()->sendAttributeUpdated(this); +} + void Model_AttributeSelectionList::removeTemporaryValues() { if (myTmpAttr.get()) { diff --git a/src/Model/Model_AttributeSelectionList.h b/src/Model/Model_AttributeSelectionList.h index d582447c3..7e0736fe8 100644 --- a/src/Model/Model_AttributeSelectionList.h +++ b/src/Model/Model_AttributeSelectionList.h @@ -63,6 +63,10 @@ public: MODEL_EXPORT virtual void append(const std::shared_ptr& thePoint, const std::string& theType); + /// Adds the new reference to the end of the list by weak naming index + MODEL_EXPORT virtual void append(const std::string& theType, const std::string& theContextName, + const int theIndex); + /// Reset temporary stored values virtual void removeTemporaryValues(); diff --git a/src/ModelAPI/ModelAPI_AttributeSelection.h b/src/ModelAPI/ModelAPI_AttributeSelection.h index 9829bde79..53e0151b8 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelection.h +++ b/src/ModelAPI/ModelAPI_AttributeSelection.h @@ -108,6 +108,10 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute virtual void selectSubShape(const std::string& theType, const std::shared_ptr& thePoint) = 0; + /// Selects sub-shape by weak naming index + virtual void selectSubShape(const std::string& theType, + const std::string& theContextName, const int theIndex) = 0; + /// Returns true if recompute of selection become impossible virtual bool isInvalid() = 0; diff --git a/src/ModelAPI/ModelAPI_AttributeSelectionList.h b/src/ModelAPI/ModelAPI_AttributeSelectionList.h index 69e45b2e7..fe432944a 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelectionList.h +++ b/src/ModelAPI/ModelAPI_AttributeSelectionList.h @@ -53,6 +53,10 @@ class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute virtual void append(const std::shared_ptr& thePoint, const std::string& theType) = 0; + /// Adds the new reference to the end of the list by weak naming index + virtual void append(const std::string& theType, const std::string& theContextName, + const int theIndex) = 0; + /// Reset temporary stored values virtual void removeTemporaryValues() = 0; diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index b7d35b4f1..92eaa64f2 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -1067,6 +1068,7 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( } myDumpBuffer << "\"" << aShape->shapeTypeStr(); + bool aStandardDump = true; if (isDumpByGeom) { // check the selected item is a ResultPart; // in this case it is necessary to get shape with full transformation @@ -1091,8 +1093,17 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( myDumpBuffer << anIndex << "\", "; *this << aMiddlePoint; + aStandardDump = false; + } if (myWeakNamingSelection && aShape.get() && theAttrSelect->context().get() && + aShape != theAttrSelect->context()->shape()) { // weak naming for local selection only + GeomAlgoAPI_NExplode aNExplode(theAttrSelect->context()->shape(), aShape->shapeType()); + int anIndex = aNExplode.index(aShape); + if (anIndex != 0) { // found a week-naming index, so, export it + myDumpBuffer<<"\", \""<context()->data()->name()<<"\", "<namingName() << "\""; myDumpBuffer << ")"; return *this; diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.h b/src/ModelHighAPI/ModelHighAPI_Dumper.h index 8cb9c5457..5c854bab2 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.h +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.h @@ -91,6 +91,10 @@ public: void setSelectionByGeometry(bool theDumpByGeom = true) { myGeometricalSelection = theDumpByGeom; } + /// Set/unset flag to dump selection attributes by weak naming + void setSelectionWeakNaming(bool theDumpByWeakNaming = true) + { myWeakNamingSelection = theDumpByWeakNaming; } + /// Dump given document into the file /// \return \c true, if succeed MODELHIGHAPI_EXPORT @@ -361,6 +365,7 @@ private: bool myDumpPostponedInProgress; ///< processing postponed is in progress bool myGeometricalSelection; ///< dump selection not by naming, but by coordinates of inner point + bool myWeakNamingSelection; ///< dump selection by weak naming protected: /// list of entities, used by other features but not dumped yet diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.cpp b/src/ModelHighAPI/ModelHighAPI_Selection.cpp index 7738eb38f..025314d22 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Selection.cpp @@ -58,6 +58,14 @@ ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType, { } +ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType, + const std::string& theContextName, const int theIndex) + : myVariantType(VT_WeakNamingPair) + , myWeakNamingPair(theType, std::pair(theContextName, theIndex)) +{ +} + + ModelHighAPI_Selection::~ModelHighAPI_Selection() { } @@ -77,6 +85,10 @@ void ModelHighAPI_Selection::fillAttribute( case VT_TypeInnerPointPair: theAttribute->selectSubShape(myTypeInnerPointPair.first, myTypeInnerPointPair.second); return; + case VT_WeakNamingPair: + theAttribute->selectSubShape( + myWeakNamingPair.first, myWeakNamingPair.second.first, myWeakNamingPair.second.second); + break; } if (theAttribute->isInvalid()) { @@ -103,6 +115,11 @@ void ModelHighAPI_Selection::appendToList( // Note: the reverse order (first - type, second - selected point) theAttribute->append(myTypeInnerPointPair.second, myTypeInnerPointPair.first); return; + case VT_WeakNamingPair: + // Note: the reverse order (first - type, second - selected point) + theAttribute->append( + myWeakNamingPair.first, myWeakNamingPair.second.first, myWeakNamingPair.second.second); + return; } } diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.h b/src/ModelHighAPI/ModelHighAPI_Selection.h index c63d15650..8612a8125 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.h +++ b/src/ModelHighAPI/ModelHighAPI_Selection.h @@ -38,6 +38,7 @@ typedef std::pair, std::shared_ptr TypeSubShapeNamePair; typedef std::pair > TypeInnerPointPair; +typedef std::pair > TypeWeakNamingPair; //-------------------------------------------------------------------------------------- /**\class ModelHighAPI_Selection * \ingroup CPPHighAPI @@ -50,7 +51,8 @@ public: VT_Empty, VT_ResultSubShapePair, VT_TypeSubShapeNamePair, - VT_TypeInnerPointPair + VT_TypeInnerPointPair, + VT_WeakNamingPair }; public: @@ -73,6 +75,12 @@ public: ModelHighAPI_Selection(const std::string& theType, const std::shared_ptr& theSubShapeInnerPoint); + + /// Constructor for sub-shape by weak naming identifier + MODELHIGHAPI_EXPORT + ModelHighAPI_Selection(const std::string& theType, + const std::string& theContextName, const int theIndex); + /// Destructor MODELHIGHAPI_EXPORT virtual ~ModelHighAPI_Selection(); @@ -138,6 +146,7 @@ private: ResultSubShapePair myResultSubShapePair; TypeSubShapeNamePair myTypeSubShapeNamePair; TypeInnerPointPair myTypeInnerPointPair; + TypeWeakNamingPair myWeakNamingPair; }; //-------------------------------------------------------------------------------------- -- 2.30.2