FeaturePtr aNewFeatureA = sketch()->addFeature(aFeatureA->getKind());
aFeatureA->data()->copyTo(aNewFeatureA->data());
aNewFeatureA->execute();
- aRefListOfFillet->append(aNewFeatureA);
+ aRefListOfFillet->append(aNewFeatureA->firstResult());
// copy aFeatureB
FeaturePtr aNewFeatureB = sketch()->addFeature(aFeatureB->getKind());
aFeatureB->data()->copyTo(aNewFeatureB->data());
aNewFeatureB->execute();
- aRefListOfFillet->append(aNewFeatureB);
- // create filleting arc
+ aRefListOfFillet->append(aNewFeatureB->firstResult());
+ // create filleting arc (it will be attached to the list later)
FeaturePtr aNewArc = sketch()->addFeature(SketchPlugin_Arc::ID());
- aRefListOfFillet->append(aNewArc);
- aRefListOfFillet->setInitialized();
// Wait all constraints being created, then send update events
static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
aNewArc->attribute(SketchPlugin_Arc::END_ID()))->setValue(
aCenter->x() + aStep->y(), aCenter->y() - aStep->x());
aNewArc->execute();
+ // attach new arc to the list
+ aRefListOfFillet->append(aNewArc->lastResult());
+ aRefListOfFillet->setInitialized();
// Create list of additional constraints:
// 1. Coincidence of boundary points of features and fillet arc
#include <SketchSolver_ConstraintMirror.h>
#include <SketchSolver_ConstraintRigid.h>
#include <SketchSolver_ConstraintTangent.h>
+#include <SketchSolver_Error.h>
#include <GeomAPI_Edge.h>
#include <GeomDataAPI_Dir.h>
#include <GeomDataAPI_Point.h>
#include <GeomDataAPI_Point2D.h>
+#include <Events_Error.h>
#include <ModelAPI_Attribute.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeRefAttr.h>
if (!aData || !aData->isValid())
return aResult;
+#ifdef _DEBUG
+ // Verify attributes of constraint and generate errors
+ std::list<AttributePtr> anAttrList = aData->attributes(std::string());
+ std::list<AttributePtr>::iterator anIter = anAttrList.begin();
+ for (; anIter != anAttrList.end(); anIter++) {
+ AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anIter);
+ if (aRefAttr) {
+ if (aRefAttr->isObject() && aRefAttr->object()) {
+ ResultConstructionPtr aRC =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aRefAttr->object());
+ if (!aRC)
+ Events_Error::send(SketchSolver_Error::NEED_OBJECT_NOT_FEATURE(), this);
+ }
+ continue;
+ }
+ AttributeRefListPtr aRefList = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*anIter);
+ if (aRefList) {
+ std::list<ObjectPtr> aList = aRefList->list();
+ std::list<ObjectPtr>::iterator aListIter = aList.begin();
+ for (; aListIter != aList.end(); aListIter++) {
+ ResultConstructionPtr aRC =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aListIter);
+ if (*aListIter && !aRC)
+ Events_Error::send(SketchSolver_Error::NEED_OBJECT_NOT_FEATURE(), this);
+ }
+ }
+ }
+#endif
+
if (theConstraint->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
return SolverConstraintPtr(new SketchSolver_ConstraintCoincidence(theConstraint));
} else if (theConstraint->getKind() == SketchPlugin_ConstraintDistance::ID()) {
static const std::string MY_ERROR_VALUE("Conflicting constraints");
return MY_ERROR_VALUE;
}
+ /// Constraints should use objects instead of features as attributes
+ inline static const std::string& NEED_OBJECT_NOT_FEATURE()
+ {
+ static const std::string MY_ERROR_VALUE("Constraint should be based on object instead of feature");
+ return MY_ERROR_VALUE;
+ }
/// The entities need to have shared point, but they have not
inline static const std::string& NO_COINCIDENT_POINTS()
{