#include <TNaming_Selector.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Tool.hxx>
+#include <TNaming_Builder.hxx>
#include <TopoDS_Shape.hxx>
#include <TDataStd_ReferenceList.hxx>
#include <TopTools_MapOfShape.hxx>
Handle(TNaming_NamedShape) aSelection;
if (myRef.myRef->Label().FindAttribute(TNaming_NamedShape::GetID(), aSelection)) {
TopoDS_Shape aSelShape = aSelection->Get();
- aResult->setImpl(&aSelShape);
+ aResult = boost::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
+ aResult->setImpl(new TopoDS_Shape(aSelShape));
}
}
return aResult;
aSel.Select(aNewShape, aContext);
}
-#include <BRepTools.hxx>
-
void Model_AttributeSelection::selectConstruction(
const ResultPtr& theContext, const boost::shared_ptr<GeomAPI_Shape>& theSubShape)
{
const TopoDS_Shape& aSubShape = theSubShape->impl<TopoDS_Shape>();
TopTools_MapOfShape allEdges;
for(TopExp_Explorer anEdgeExp(aSubShape, TopAbs_EDGE); anEdgeExp.More(); anEdgeExp.Next()) {
- BRepTools::Write(anEdgeExp.Current(), "D:\\selected.brep");
allEdges.Add(anEdgeExp.Current());
}
// iterate and store the result ids of sub-elements
boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aRes);
if (aConstr->shape()) {
const TopoDS_Shape& aResShape = aConstr->shape()->impl<TopoDS_Shape>();
- BRepTools::Write(aResShape, "D:\\sub.brep");
if (allEdges.Contains(aResShape)) {
boost::shared_ptr<Model_Data> aSubData = boost::dynamic_pointer_cast<Model_Data>(aSub->data());
TDF_Label aSubLab = aSubData->label();
}
}
}
+ // store the selected as primitive
+ TNaming_Builder aBuilder(myRef.myRef->Label());
+ aBuilder.Generated(aSubShape);
}
#include <ModelAPI_AttributeRefAttr.h>
#include <ModelAPI_Result.h>
#include <ModelAPI_Validator.h>
+#include <ModelAPI_CompositeFeature.h>
#include <Events_Loop.h>
#include <Events_LongOp.h>
#include <Events_Error.h>
aDocs = ModelAPI_Session::get()->allOpenedDocuments();
}
}
- // collect all documents involved into the update
+ // collect all documents involved into the update process
set<boost::shared_ptr<ModelAPI_Object> >::iterator aFIter = myInitial.begin();
for (; aFIter != myInitial.end(); aFIter++) {
aDocs.push_back((*aFIter)->document());
bool aMustbeUpdated = myInitial.find(theFeature) != myInitial.end();
if (theFeature) { // only real feature contains references to other objects
if (theFeature->data()->mustBeUpdated()) aMustbeUpdated = true;
+
+ // composite feature must be executed after sub-features execution
+ CompositeFeaturePtr aComposite =
+ boost::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
+ if (aComposite) {
+ int aSubsNum = aComposite->numberOfSubs();
+ for(int a = 0; a < aSubsNum; a++) {
+ if (updateFeature(aComposite->subFeature(a)))
+ aMustbeUpdated = true;
+ }
+ }
+
// references
list<boost::shared_ptr<ModelAPI_Attribute> > aRefs = theFeature->data()->attributes(
ModelAPI_AttributeReference::type());
}
}
}
+
// execute feature if it must be updated
if (aMustbeUpdated) {
bool Model_Update::updateObject(boost::shared_ptr<ModelAPI_Object> theObject)
{
+ if (myUpdated.find(theObject) != myUpdated.end())
+ return myUpdated[theObject]; // already processed
+ return myInitial.find(theObject) != myInitial.end();
+
+ /* remove algorithm for update of all features by dependencies tree
if (!theObject)
return false;
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
if (myInitial.find(theObject) != myInitial.end())
return true;
return false; // nothing is known
+ */
}
SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<ModelAPI_Feature>
subFeature(const int theIndex) const;
- protected:
+ /// Construction result is allways recomuted on the fly
+ SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
+
+protected:
/// Creates a plane and append it to the list
/// \param theX the X normal value
/// \param theY the Y normal value