else:
groupType = "SOLID"
- # iterate on exported objects and check if the current
- # group refers to this object
- for obj in self.geomObjects:
- if aSelectionContext.shape().isEqual(obj[0]):
- aGroup = self.geompy.CreateGroup(obj[1], self.geompy.ShapeType[groupType])
- self.geompy.UnionIDs(aGroup,Ids)
- self.geompy.addToStudyInFather(obj[1], aGroup, theGroupName)
+ aContextBody = ModelAPI.modelAPI_ResultBody(aSelectionContext)
+ if aContextBody is not None:
+ # iterate on exported objects and check if the current
+ # group refers to this object
+ for obj in self.geomObjects:
+ if aContextBody.isLatestEqual(obj[0]):
+ aGroup = self.geompy.CreateGroup(obj[1], self.geompy.ShapeType[groupType])
+ self.geompy.UnionIDs(aGroup,Ids)
+ self.geompy.addToStudyInFather(obj[1], aGroup, theGroupName)
## Exports all shapes and groups into the GEOM module.
def execute(self):
aCompositeOwnerOwner = ModelAPI_Tools::compositeOwner(aCompositeOwner);
}
}
+ // for group Scope is not limitet: this is always up to date objects
+ bool isGroup = aFeature.get() && aFeature->getKind() == "Group";
for(; aFIter != allFeatures.end(); aFIter++) {
if (*aFIter == owner()) { // the left features are created later (except subs of composite)
aMePassed = true;
continue;
}
+ if (isGroup) aMePassed = false;
bool isInScope = !aMePassed;
if (!isInScope && aComposite.get()) { // try to add sub-elements of composite if this is composite
if (aComposite->isSub(*aFIter))
int Model_AttributeSelection::Id()
{
+ int anID = 0;
std::shared_ptr<GeomAPI_Shape> aSelection = value();
std::shared_ptr<GeomAPI_Shape> aContext = context()->shape();
- const TopoDS_Shape& aMainShape = aContext->impl<TopoDS_Shape>();
+ TopoDS_Shape aMainShape = aContext->impl<TopoDS_Shape>();
const TopoDS_Shape& aSubShape = aSelection->impl<TopoDS_Shape>();
- int anID = 0;
+ // searching for the latest main shape
if (aSelection && !aSelection->isNull() &&
aContext && !aContext->isNull())
{
+ std::shared_ptr<Model_Document> aDoc =
+ std::dynamic_pointer_cast<Model_Document>(context()->document());
+ if (aDoc.get()) {
+ Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aMainShape, aDoc->generalLabel());
+ if (!aNS.IsNull()) {
+ aMainShape = TNaming_Tool::CurrentShape(aNS);
+ }
+ }
+
TopTools_IndexedMapOfShape aSubShapesMap;
TopExp::MapShapes(aMainShape, aSubShapesMap);
anID = aSubShapesMap.FindIndex(aSubShape);
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Iterator.hxx>
+#include <TNaming_Tool.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_Integer.hxx>
#include <TopoDS.hxx>
}
return std::shared_ptr<GeomAPI_Shape>();
}
+
+bool Model_BodyBuilder::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
+{
+ if (theShape.get()) {
+ TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
+ if (aData) {
+ TDF_Label& aShapeLab = aData->shapeLab();
+ Handle(TNaming_NamedShape) aName;
+ if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
+ TopoDS_Shape aLatest = TNaming_Tool::CurrentShape(aName);
+ if (aLatest.IsEqual(aShape))
+ return true;
+ }
+ }
+ }
+ return false;
+}
/// (theFlag = true) and back (theFlag = false)
MODEL_EXPORT virtual void evolutionToSelection(const bool theFlag);
+ /// Returns true if the latest modification of this body in the naming history
+ // is equal to the given shape
+ MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
+
protected:
/// Default constructor accessible only by Model_Objects
Model_BodyBuilder(ModelAPI_Object* theOwner);
friend class Model_AttributeReference;
friend class Model_AttributeRefAttr;
friend class Model_AttributeRefList;
+ friend class Model_AttributeSelection;
friend class Model_ResultPart;
friend class Model_ResultCompSolid;
friend class DFBrowser;
}
return aChanged;
}
+
+bool Model_ResultBody::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
+{
+ return myBuilder->isLatestEqual(theShape);
+}
/// naming data structure if theFlag if false. Or restores everything on theFlag is true.
MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
const bool theFlag);
+
+ /// Returns true if the latest modification of this body in the naming history
+ // is equal to the given shape
+ MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
+
/// Removes the stored builders
MODEL_EXPORT virtual ~Model_ResultBody() {};
aECreator->sendUpdated(data()->owner(), EVENT_DISP);
}
}
+
+bool Model_ResultCompSolid::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
+{
+ return myBuilder->isLatestEqual(theShape);
+}
/// Sets all subs as concealed in the data tree (referenced by other objects)
MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
+ /// Returns true if the latest modification of this body in the naming history
+ // is equal to the given shape
+ MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
+
protected:
/// Makes a body on the given feature
Model_ResultCompSolid();
/// (theFlag = true) and back (theFlag = false)
virtual void evolutionToSelection(const bool theFlag) = 0;
+ /// Returns true if the latest modification of this body in the naming history
+ // is equal to the given shape
+ virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+
protected:
/// Returns the data manager of this object: attributes
MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Data> data() const;
MODELAPI_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
const std::string& theName,int& theTag);
+ /// Returns true if the latest modification of this body in the naming history
+ // is equal to the given shape
+ MODELAPI_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+
protected:
/// Default constructor accessible only from Model_Objects
MODELAPI_EXPORT ModelAPI_ResultBody();