}
}
ResultPartPtr aResultPart = document()->copyPart(aCurrentResult, anOrigin, aResultIndex);
- aResultPart->setShape(*aContext, aMovementAlgo.shape());
+ aResultPart->setTrsf(*aContext, aMovementAlgo.transformation());
setResult(aResultPart);
} else {
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
std::shared_ptr<ModelAPI_ResultBody> aResultBody;
if (!isPart)
aResultBody = document()->createBody(data());
- GeomAlgoAPI_Placement aFeature(aSlaveObject, aBaseObject, aSlaveShape, aBaseShape, isReverse, isCentering);
+ GeomAlgoAPI_Placement aFeature(
+ aSlaveObject, aBaseObject, aSlaveShape, aBaseShape, isReverse, isCentering, isPart);
if(!aFeature.isDone()) {
static const std::string aFeatureError = "Placement algorithm failed";
setError(aFeatureError);
if (isPart) { // for part results just set transformation
ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aContextRes);
ResultPartPtr aResultPart = document()->copyPart(firstResult(), anOrigin);
- aResultPart->setShape(aContextRes, aFeature.shape());
+ aResultPart->setTrsf(aContextRes, aFeature.transformation());
setResult(aResultPart);
} else {
//LoadNamingDS
}
}
ResultPartPtr aResultPart = document()->copyPart(aCurrentResult, anOrigin, aResultIndex);
- aResultPart->setShape(*aContext, aRotationAlgo.shape());
+ aResultPart->setTrsf(*aContext, aRotationAlgo.transformation());
setResult(aResultPart);
} else {
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
</feature>
</group>
</workbench>
- <workbench id="Features">
- <group id="Basic">
+ <workbench id="Part">
+ <group id="Movement">
<feature id="Placement" title="Placement" tooltip="Perform moving of an object to specified position" icon=":icons/placement.png">
<source path="placement_widget.xml"/>
</feature>
- <feature id="Movement" title="Movement" tooltip="Perform movement of an objects along the axis to specified distance" icon=":icons/movement.png">
+ <feature id="Movement" title="Translation" tooltip="Perform movement of an objects along the axis to specified distance" icon=":icons/movement.png">
<source path="movement_widget.xml"/>
</feature>
<feature id="Rotation" title="Rotation" tooltip="Perform rotation of an objects around the axis to specified angle" icon=":icons/rotation.png">
GeomAPI_Vertex.h
GeomAPI_Ax1.h
GeomAPI_Ax3.h
+ GeomAPI_Trsf.h
)
SET(PROJECT_SOURCES
GeomAPI_Ax1.cpp
GeomAPI_Ax3.cpp
GeomAPI_IPresentable.cpp
+ GeomAPI_Trsf.cpp
)
SET(PROJECT_LIBRARIES
#include "GeomAPI_Vertex.h"
#include "GeomAPI_XY.h"
#include "GeomAPI_XYZ.h"
+ #include "GeomAPI_Trsf.h"
#include <memory>
#include <string>
%shared_ptr(GeomAPI_Vertex)
%shared_ptr(GeomAPI_XY)
%shared_ptr(GeomAPI_XYZ)
+%shared_ptr(GeomAPI_Trsf)
// all supported interfaces
%include "GeomAPI_Vertex.h"
%include "GeomAPI_XY.h"
%include "GeomAPI_XYZ.h"
+%include "GeomAPI_Trsf.h"
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAPI_Trsf.cpp
+// Created: 13 Jul 2015
+// Author: Mikhail PONIKAROV
+
+#include<GeomAPI_Trsf.h>
+
+#include<gp_Trsf.hxx>
+
+GeomAPI_Trsf::GeomAPI_Trsf()
+ : GeomAPI_Interface()
+{
+}
+
+GeomAPI_Trsf::GeomAPI_Trsf(void* theTrsf)
+ : GeomAPI_Interface(theTrsf)
+{
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAPI_XYZ.hxx
+// Created: 13 July 2015
+// Author: Mikhail PONIKAROV
+
+#ifndef GeomAPI_Trsf_H_
+#define GeomAPI_Trsf_H_
+
+#include <GeomAPI_Interface.h>
+#include <memory>
+
+/**\class GeomAPI_Trsf
+ * \ingroup DataModel
+ * \brief Keep the transformation matrix coefficients
+ */
+
+class GeomAPI_Trsf : public GeomAPI_Interface
+{
+ public:
+ /// Keeps no transformation, it may be set by setImpl
+ GEOMAPI_EXPORT GeomAPI_Trsf();
+ /// Takes the pointer to existing transformation
+ GEOMAPI_EXPORT GeomAPI_Trsf(void* theTrsf);
+};
+
+#endif
+
if (theSimpleTransform) {
TopLoc_Location aDelta(aTrsf);
aResult = aSourceShape.Moved(aDelta);
+ // store the accumulated information about the result and this delta
+ myTrsf = std::make_shared<GeomAPI_Trsf>(
+ new gp_Trsf(aTrsf * aSourceShape.Location().Transformation()));
myDone = true; // is OK for sure
} else {
BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true);
{
return myMkShape;
}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Trsf> GeomAlgoAPI_Movement::transformation() const
+{
+ return myTrsf;
+}
#include <GeomAPI_Ax1.h>
#include <GeomAPI_DataMapOfShapeShape.h>
#include <GeomAPI_Shape.h>
+#include <GeomAPI_Trsf.h>
/** \class GeomAlgoAPI_Movement
* \ingroup DataAlgo
/// \return interface for for History processing.
GEOMALGOAPI_EXPORT std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape() const;
+ /// Returns the simple transformation
+ GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Trsf> transformation() const;
+
private:
/// Builds resulting shape.
void build(std::shared_ptr<GeomAPI_Shape> theSourceShape,
std::shared_ptr<GeomAPI_Shape> myShape;
std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
std::shared_ptr<GeomAlgoAPI_MakeShape> myMkShape;
+ std::shared_ptr<GeomAPI_Trsf> myTrsf; ///< transformation of the shape in case theSimpleTransform
};
#endif
#include <BRepGProp.hxx>
#include <Precision.hxx>
-#define DEB_PLACEMENT 1
GeomAlgoAPI_Placement::GeomAlgoAPI_Placement(
std::shared_ptr<GeomAPI_Shape> theSourceSolid,
std::shared_ptr<GeomAPI_Shape> theDestSolid,
TopLoc_Location aDelta(aTrsf);
TopoDS_Shape aResult = aSourceShape.Moved(aDelta);
myShape->setImpl(new TopoDS_Shape(aResult));
+ // store the accumulated information about the result and this delta
+ myTrsf = std::make_shared<GeomAPI_Trsf>(
+ new gp_Trsf(aTrsf * aSourceShape.Location().Transformation()));
+ myDone = true; // it is allways true for simple transformation generation
} else { // internal rebuild of the shape
// Transform the shape with copying it
BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true);
aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current()));
myMap.bind(aCurrentShape, aCurrentShape);
}
- #ifdef DEB_PLACEMENT
- int aNum = myMap.size();
- cout << "MAP of Oriented shapes =" << aNum <<endl;
-
- #endif
-
myShape->setImpl(new TopoDS_Shape(aResult));
myMkShape = new GeomAlgoAPI_MakeShape (aBuilder);
}
return myMkShape;
}
+std::shared_ptr<GeomAPI_Trsf> GeomAlgoAPI_Placement::transformation() const
+{
+ return myTrsf;
+}
+
//============================================================================
GeomAlgoAPI_Placement::~GeomAlgoAPI_Placement()
{
#include <GeomAPI_Shape.h>
#include <GeomAPI_Dir.h>
#include <GeomAPI_Face.h>
+#include <GeomAPI_Trsf.h>
#include <GeomAlgoAPI_MakeShape.h>
#include <GeomAPI_DataMapOfShapeShape.h>
#include <memory>
/// Return interface for for History processing
GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape* makeShape () const;
+ /// Returns the simple transformation
+ GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Trsf> transformation() const;
+
/// Destructor
GEOMALGOAPI_EXPORT virtual ~GeomAlgoAPI_Placement();
std::shared_ptr<GeomAPI_Shape> myShape;
GeomAPI_DataMapOfShapeShape myMap;
GeomAlgoAPI_MakeShape * myMkShape;
+ std::shared_ptr<GeomAPI_Trsf> myTrsf; ///< transformation of the shape in case theSimpleTransform
};
#endif
if (theSimpleTransform) {
TopLoc_Location aDelta(aTrsf);
aResult = aSourceShape.Moved(aDelta);
+ myTrsf = std::make_shared<GeomAPI_Trsf>(
+ new gp_Trsf(aTrsf * aSourceShape.Location().Transformation()));
myDone = true; // is OK for sure
} else {
BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true);
{
return myMkShape;
}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Trsf> GeomAlgoAPI_Rotation::transformation() const
+{
+ return myTrsf;
+}
#include <GeomAPI_Ax1.h>
#include <GeomAPI_DataMapOfShapeShape.h>
#include <GeomAPI_Shape.h>
+#include <GeomAPI_Trsf.h>
/** \class GeomAlgoAPI_Rotation
* \ingroup DataAlgo
/// \return interface for for History processing.
GEOMALGOAPI_EXPORT std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape() const;
+ /// Returns the simple transformation
+ GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Trsf> transformation() const;
+
private:
/// Builds resulting shape.
void build(std::shared_ptr<GeomAPI_Shape> theSourceShape,
std::shared_ptr<GeomAPI_Shape> myShape;
std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
std::shared_ptr<GeomAlgoAPI_MakeShape> myMkShape;
+ std::shared_ptr<GeomAPI_Trsf> myTrsf; ///< transformation of the shape in case theSimpleTransform
};
#endif
TDF_Label aSelLab = selectionLabel();
if (aSelLab.IsAttribute(kSIMPLE_REF_ID)) { // it is just reference to shape, not sub-shape
ResultPtr aContext = context();
- return aContext.get();
+ return aContext.get() != NULL;
}
if (aSelLab.IsAttribute(kCONSTUCTION_SIMPLE_REF_ID)) { // it is just reference to construction, nothing is in value
return true;
ResultConstructionPtr aConstr =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(context());
if (aConstr.get()) {
- return aConstr->shape().get();
+ return aConstr->shape().get() != NULL;
}
}
}
}
ResultPtr Model_AttributeSelection::context() {
- return std::dynamic_pointer_cast<ModelAPI_Result>(myRef.value());
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(myRef.value());
+ // for parts there could be same-data result, so take the last enabled
+ if (aResult.get() && aResult->groupName() == ModelAPI_ResultPart::group()) {
+ int aSize = aResult->document()->size(ModelAPI_ResultPart::group());
+ for(int a = aSize - 1; a >= 0; a--) {
+ ObjectPtr aPart = aResult->document()->object(ModelAPI_ResultPart::group(), a);
+ if (aPart.get() && aPart->data() == aResult->data()) {
+ ResultPtr aPartResult = std::dynamic_pointer_cast<ModelAPI_Result>(aPart);
+ FeaturePtr anOwnerFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+ // check that this result is not this-feature result (it is forbidden t oselect itself)
+ if (anOwnerFeature.get() && anOwnerFeature->firstResult() != aPartResult) {
+ return aPartResult;
+ }
+ }
+ }
+ }
+ return aResult;
}
TDF_LabelMap& Model_AttributeSelection::scope()
{
if (myScope.IsEmpty()) { // create a new scope if not yet done
- // gets all labels with named shapes that are bofore this feature label (before in history)
- TDF_Label aFeatureLab = std::dynamic_pointer_cast<Model_Data>(
- owner()->data())->label().Father();
- int aFeatureID = aFeatureLab.Tag();
- TDF_ChildIterator aFeaturesIter(aFeatureLab.Father());
- for(; aFeaturesIter.More(); aFeaturesIter.Next()) {
- if (aFeaturesIter.Value().Tag() >= aFeatureID) // the left labels are created later
- break;
- TDF_ChildIDIterator aNSIter(aFeaturesIter.Value(), TNaming_NamedShape::GetID(), 1);
- for(; aNSIter.More(); aNSIter.Next()) {
- Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(aNSIter.Value());
- if (!aNS.IsNull() && aNS->Evolution() != TNaming_SELECTED) {
- myScope.Add(aNS->Label());
+ // gets all featueres with named shapes that are bofore this feature label (before in history)
+ DocumentPtr aMyDoc = owner()->document();
+ std::list<std::shared_ptr<ModelAPI_Feature> > allFeatures = aMyDoc->allFeatures();
+ std::list<std::shared_ptr<ModelAPI_Feature> >::iterator aFIter = allFeatures.begin();
+ for(; aFIter != allFeatures.end(); aFIter++) {
+ if (*aFIter == owner()) break; // the left features are created later
+ if (aFIter->get() && (*aFIter)->data()->isValid()) {
+ TDF_Label aFeatureLab = std::dynamic_pointer_cast<Model_Data>(
+ (*aFIter)->data())->label().Father();
+ TDF_ChildIDIterator aNSIter(aFeatureLab, TNaming_NamedShape::GetID(), 1);
+ for(; aNSIter.More(); aNSIter.Next()) {
+ Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(aNSIter.Value());
+ if (!aNS.IsNull() && aNS->Evolution() != TNaming_SELECTED) {
+ myScope.Add(aNS->Label());
+ }
}
}
}
void Model_ResultPart::initAttributes()
{
// append the color attribute. It is empty, the attribute will be filled by a request
- DataPtr aData = data();
- aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
+ data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::typeId());
+ data()->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
}
std::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
setIsConcealed(false);
}
-void Model_ResultPart::setData(std::shared_ptr<ModelAPI_Data> theData)
-{
- ModelAPI_Result::setData(theData);
- if (theData) {
- data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::typeId());
- }
-}
-
void Model_ResultPart::activate()
{
std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->document(DOC_REF());
bool Model_ResultPart::isActivated()
{
std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->document(DOC_REF());
- return aDocRef->value().get();
+ return aDocRef->value().get() != NULL;
}
bool Model_ResultPart::setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
const bool theFlag)
{
if (ModelAPI_ResultPart::setDisabled(theThis, theFlag)) {
- DocumentPtr aDoc = Model_ResultPart::partDoc();
- if (aDoc.get() && aDoc->isOpened()) {
- // make the current feature the last in any case: to update shapes defore deactivation too
- FeaturePtr aLastFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aDoc->object(
- ModelAPI_Feature::group(), aDoc->size(ModelAPI_Feature::group()) - 1));
- aDoc->setCurrentFeature(aLastFeature, false);
- if (theFlag) { // disable, so make all features disabled too
- // update the shape just before the deactivation: it will be used outside of part
- myShape.Nullify();
- shape();
- aDoc->setCurrentFeature(FeaturePtr(), false);
+ if (!myTrsf.get()) { // disable of base result part
+ DocumentPtr aDoc = Model_ResultPart::partDoc();
+ if (aDoc.get() && aDoc->isOpened()) {
+ // make the current feature the last in any case: to update shapes defore deactivation too
+ FeaturePtr aLastFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aDoc->object(
+ ModelAPI_Feature::group(), aDoc->size(ModelAPI_Feature::group()) - 1));
+ aDoc->setCurrentFeature(aLastFeature, false);
+ if (theFlag) { // disable, so make all features disabled too
+ // update the shape just before the deactivation: it will be used outside of part
+ updateShape();
+ shape();
+ aDoc->setCurrentFeature(FeaturePtr(), false);
+ }
}
}
return true;
std::shared_ptr<GeomAPI_Shape> Model_ResultPart::shape()
{
- if (myShape.IsNull()) {
+ std::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape);
+ if (myTrsf.get()) { // get shape of the base result and apply the transformation
+ ResultPtr anOrigResult =
+ std::dynamic_pointer_cast<ModelAPI_Result>(data()->attribute(COLOR_ID())->owner());
+ std::shared_ptr<GeomAPI_Shape> anOrigShape = anOrigResult->shape();
+ if (anOrigShape.get()) {
+ TopoDS_Shape aShape = anOrigShape->impl<TopoDS_Shape>();
+ if (!aShape.IsNull()) {
+ aShape.Move(*(myTrsf.get()));
+ aResult->setImpl(new TopoDS_Shape(aShape));
+ }
+ }
+ return aResult;
+ }
+ if (myShape.IsNull()) { // shape is not produced yet, create it
DocumentPtr aDoc = Model_ResultPart::partDoc();
if (aDoc.get() && aDoc->isOpened()) {
const std::string& aBodyGroup = ModelAPI_ResultBody::group();
int aNumSubs = 0;
for(int a = aDoc->size(aBodyGroup) - 1; a >= 0; a--) {
ResultPtr aBody = std::dynamic_pointer_cast<ModelAPI_Result>(aDoc->object(aBodyGroup, a));
- if (aBody.get() && aBody->shape().get() && !aBody->isDisabled()) {
+ // "object" method filters out disabled and concealed anyway, so don't check
+ if (aBody.get() && aBody->shape().get()) {
TopoDS_Shape aShape = *(aBody->shape()->implPtr<TopoDS_Shape>());
if (!aShape.IsNull()) {
aBuilder.Add(aResultComp, aShape);
}
}
}
- if (myShape.IsNull())
- return std::shared_ptr<GeomAPI_Shape>();
- std::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape);
- aResult->setImpl(new TopoDS_Shape(myShape));
+ if (!myShape.IsNull())
+ aResult->setImpl(new TopoDS_Shape(myShape));
return aResult;
}
+// Returns true is transformation matrices are equal
+static bool IsEqualTrsf(gp_Trsf& theT1, gp_Trsf theT2) {
+ for(int aRow = 1; aRow < 4; aRow++) {
+ for(int aCol = 1; aCol < 5; aCol++) {
+ double aDiff = theT1.Value(aRow, aCol) - theT2.Value(aRow, aCol);
+ if (Abs(aDiff) > 1.e-9)
+ return false;
+ }
+ }
+ return true;
+}
+
std::string Model_ResultPart::nameInPart(const std::shared_ptr<GeomAPI_Shape>& theShape,
int& theIndex)
{
theIndex = 0; // not initialized
- TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
- if (aShape.IsNull())
- return "";
- if (data()->isOwner(this)) { // if this is moved copy of part => return the name of original shape
- FeaturePtr anOrigFeature =
- std::dynamic_pointer_cast<ModelAPI_Feature>(data()->attribute(COLOR_ID())->owner());
- if (anOrigFeature.get()) {
- if (anOrigFeature->firstResult().get() && anOrigFeature->firstResult()->shape().get()) {
- TopoDS_Shape anOrigShape = anOrigFeature->firstResult()->shape()->impl<TopoDS_Shape>();
- if (!anOrigShape.IsNull()) {
- TopExp_Explorer anExp(anOrigShape, aShape.ShapeType());
- for(; anExp.More(); anExp.Next()) {
- if (aShape.IsPartner(anExp.Current())) {
- std::shared_ptr<GeomAPI_Shape> anOrigGeomShape(new GeomAPI_Shape);
- anOrigGeomShape->setImpl(new TopoDS_Shape(anExp.Current()));
- return std::dynamic_pointer_cast<Model_ResultPart>(anOrigFeature->firstResult())->
- nameInPart(theShape, theIndex);
- }
+ if (myTrsf.get()) { // if this is moved copy of part => return the name of original shape
+ ResultPartPtr anOrigResult =
+ std::dynamic_pointer_cast<ModelAPI_ResultPart>(data()->attribute(COLOR_ID())->owner());
+ // searching in the origin the shape equal to the given but with myTrsf
+ TopoDS_Shape aSelection = theShape->impl<TopoDS_Shape>();
+ gp_Trsf aSelTrsf = aSelection.Location().Transformation();
+ TopoDS_Shape anOrigMain = anOrigResult->shape()->impl<TopoDS_Shape>();
+ if (!aSelection.IsNull() && !anOrigMain.IsNull()) {
+ TopExp_Explorer anExp(anOrigMain, aSelection.ShapeType());
+ for(; anExp.More(); anExp.Next()) {
+ if (anExp.Current().IsPartner(aSelection)) {
+ TopoDS_Shape anOrigMoved = anExp.Current().Moved(*(myTrsf.get()));
+ //if (anOrigMoved.IsSame(aSelection)) {
+ if (IsEqualTrsf(aSelTrsf, anOrigMoved.Location().Transformation())) {
+ std::shared_ptr<GeomAPI_Shape> anOrigSel(new GeomAPI_Shape);
+ anOrigSel->setImpl(new TopoDS_Shape(anExp.Current()));
+ return anOrigResult->nameInPart(anOrigSel, theIndex);
}
}
}
}
+ // something is not right
+ return "";
}
+
+ TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ if (aShape.IsNull())
+ return "";
+
// getting an access to the document of part
std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(partDoc());
if (!aDoc.get()) // the part document is not presented for the moment
void Model_ResultPart::updateShape()
{
myShape.Nullify();
+ myTrsf.reset();
}
-void Model_ResultPart::setShape(std::shared_ptr<ModelAPI_Result> theThis,
- const std::shared_ptr<GeomAPI_Shape>& theTransformed)
+void Model_ResultPart::setTrsf(std::shared_ptr<ModelAPI_Result> theThis,
+ const std::shared_ptr<GeomAPI_Trsf>& theTransformation)
{
- myShape = theTransformed->impl<TopoDS_Shape>();
+ updateShape();
+ if (theTransformation.get()) {
+ myTrsf = std::make_shared<gp_Trsf>(theTransformation->impl<gp_Trsf>());
+ }
// the result must be explicitly updated
static Events_Loop* aLoop = Events_Loop::loop();
static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
#include "Model.h"
#include <ModelAPI_ResultPart.h>
#include <TopoDS_Shape.hxx>
+#include <gp_Trsf.hxx>
/**\class Model_ResultPart
* \ingroup DataModel
class Model_ResultPart : public ModelAPI_ResultPart
{
TopoDS_Shape myShape; ///< shape of this part created from bodies (updated only of Part deactivation)
+ std::shared_ptr<gp_Trsf> myTrsf; ///< if it is just copy of original shape, keep just transformation
public:
/// Request for initialization of data model of the result: adding all attributes
virtual void initAttributes();
MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shapeInPart(const std::string& theName);
/// Updates the shape-result of the part (called on Part feature execution)
MODEL_EXPORT virtual void updateShape();
- MODEL_EXPORT virtual void setShape(std::shared_ptr<ModelAPI_Result> theThis,
- const std::shared_ptr<GeomAPI_Shape>& theTransformed);
+ /// Applies the additional transformation of the part
+ MODEL_EXPORT virtual void setTrsf(std::shared_ptr<ModelAPI_Result> theThis,
+ const std::shared_ptr<GeomAPI_Trsf>& theTransformation);
/// Returns the parameters of color definition in the resources config manager
MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
/// makes a result on a temporary feature (an action)
Model_ResultPart();
- /// Sets the data manager of an object (document does), here also attributes are initialized
- virtual void setData(std::shared_ptr<ModelAPI_Data> theData);
-
/// Returns true if document is activated (loaded into the memory)
virtual bool isActivated();
using namespace std;
Model_Update MY_UPDATER_INSTANCE; /// the only one instance initialized on load of the library
-// #define DEB_UPDATE
+//#define DEB_UPDATE
Model_Update::Model_Update()
{
processOperation(false);
} else if (theMessage->eventID() == kOpFinishEvent || theMessage->eventID() == kOpAbortEvent ||
theMessage->eventID() == kOpStartEvent) {
- myIsParamUpdated = false;
if (!(theMessage->eventID() == kOpStartEvent)) {
myIsFinish = true;
}
// in the end of transaction everything is updated, so clear the old objects (the only one
// place where results are cleared)
+ myIsParamUpdated = false;
myJustUpdated.clear();
myWaitForFinish.clear();
}
FeaturePtr aFeatureIter = anObjs->firstFeature();
std::set<FeaturePtr> aProcessedFeatures; // to avoid processing twice
for (; aFeatureIter.get(); aFeatureIter = anObjs->nextFeature(aFeatureIter)) {
- if (aFeatureIter->groupName() == "Parameter")
+ if (aFeatureIter->getKind() == "Parameter")
updateFeature(aFeatureIter, aProcessedFeatures);
}
aFeatureIter = anObjs->firstFeature();
for (; aFeatureIter.get(); aFeatureIter = anObjs->nextFeature(aFeatureIter)) {
- if (aFeatureIter->groupName() != "Parameter")
+ if (aFeatureIter->getKind() != "Parameter")
updateFeature(aFeatureIter, aProcessedFeatures);
}
// two cycles: parameters must be processed first
for(int a = 0; a < aCompos->numberOfSubs(); a++) {
FeaturePtr aSub = aCompos->subFeature(a);
- if (aSub->groupName() == "Parameter")
+ if (aSub->getKind() == "Parameter")
updateFeature(aSub, theProcessed);
}
// number of subs can be changed in execution: like fillet
for(int a = 0; a < aCompos->numberOfSubs(); a++) {
FeaturePtr aSub = aCompos->subFeature(a);
- if (aSub->groupName() != "Parameter")
+ if (aSub->getKind() != "Parameter")
updateFeature(aSub, theProcessed);
}
}
std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
for (; aRIter != aResults.cend(); aRIter++) {
std::shared_ptr<ModelAPI_Result> aRes = *aRIter;
- aRes->data()->execState(theState);
+ if (!aRes->isDisabled()) // update state only for enabled results (Placement Result Part may make the original Part Result as invalid)
+ aRes->data()->execState(theState);
if (theFeature->data()->updateID() > aRes->data()->updateID()) {
aRes->data()->setUpdateID(theFeature->data()->updateID());
}
// number of subs can be changed in execution: like fillet
for(int a = 0; a < aCompos->numberOfSubs(); a++) {
FeaturePtr aSub = aCompos->subFeature(a);
- if (myJustUpdated.find(aSub) != myJustUpdated.end() ||
- (aSub.get() && aSub->data()->updateID() > theFeature->data()->updateID())) {
- if (aState == ModelAPI_StateDone)
+ if (aSub.get() && aState == ModelAPI_StateDone) {
+ if (myJustUpdated.find(aSub) != myJustUpdated.end() ||
+ (aSub->data()->updateID() > theFeature->data()->updateID())) {
+ aState = ModelAPI_StateMustBeUpdated;
+ }
+ // also check that all results of subs were updated: composite also depends on the results
+ const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = aSub->results();
+ std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter = aResults.begin();
+ for(; aResIter != aResults.end(); aResIter++) {
+ if (aResIter->get() && (*aResIter)->data()->isValid() && !(*aResIter)->isDisabled() &&
+ (myJustUpdated.find(*aResIter) != myJustUpdated.end() ||
+ ((*aResIter)->data()->updateID() > theFeature->data()->updateID()))) {
aState = ModelAPI_StateMustBeUpdated;
+ }
+ }
}
}
}
#define ModelAPI_ResultPart_H_
#include "ModelAPI_Result.h"
+#include <GeomAPI_Trsf.h>
#include <string>
/// Updates the selection inside of the part by the selection index
virtual bool updateInPart(const int theIndex) = 0;
- /// Applies the additional transformation ofthe part
- virtual void setShape(std::shared_ptr<ModelAPI_Result> theThis,
- const std::shared_ptr<GeomAPI_Shape>& theTransformed) = 0;
+ /// Applies the additional transformation of the part
+ virtual void setTrsf(std::shared_ptr<ModelAPI_Result> theThis,
+ const std::shared_ptr<GeomAPI_Trsf>& theTransformation) = 0;
/// Returns the shape by the name in the part
virtual std::shared_ptr<GeomAPI_Shape> shapeInPart(const std::string& theName) = 0;