#include "SketchPlugin_ConstraintRigid.h"
#include "SketchPlugin_ConstraintTangent.h"
#include "SketchPlugin_Ellipse.h"
+#include "SketchPlugin_EllipticArc.h"
#include "SketchPlugin_Fillet.h"
#include "SketchPlugin_Line.h"
#include "SketchPlugin_MacroArc.h"
if (aFeature->getKind() != SketchPlugin_Line::ID() &&
aFeature->getKind() != SketchPlugin_Circle::ID() &&
aFeature->getKind() != SketchPlugin_Arc::ID() &&
- aFeature->getKind() != SketchPlugin_Ellipse::ID()) {
+ aFeature->getKind() != SketchPlugin_Ellipse::ID() &&
+ aFeature->getKind() != SketchPlugin_EllipticArc::ID()) {
theError = "The %1 feature is not supported by the Equal constraint.";
theError.arg(aFeature->getKind());
// wrong type of attribute
}
if (!isOk) {
// ellipse and elliptic arc may be equal
- // TODO
+ isOk = (aType[0] == SketchPlugin_EllipticArc::ID() && aType[1] == SketchPlugin_Ellipse::ID())
+ || (aType[0] == SketchPlugin_Ellipse::ID() && aType[1] == SketchPlugin_EllipticArc::ID());
}
if (!isOk) {
theError = "Features with kinds %1 and %2 can not be equal.";
GCS_EDGE_WRAPPER(theEntity2));
break;
case CONSTRAINT_EQUAL_LINES:
+ case CONSTRAINT_EQUAL_ELLIPSES:
anIntermediate = GCS_SCALAR_WRAPPER(theValue); // parameter is used to store length of lines
case CONSTRAINT_EQUAL_LINE_ARC:
case CONSTRAINT_EQUAL_RADIUS:
new GCS::ConstraintP2PDistance(aLine2->p1, aLine2->p2, theIntermed->scalar())));
// update value of intermediate parameter
theIntermed->setValue(distance(aLine1->p1, aLine1->p2));
- } else {
+ }
+ else if (theType == CONSTRAINT_EQUAL_ELLIPSES) {
+ std::shared_ptr<GCS::Ellipse> anEllipse1 =
+ std::dynamic_pointer_cast<GCS::Ellipse>(theEntity1->entity());
+ std::shared_ptr<GCS::Ellipse> anEllipse2 =
+ std::dynamic_pointer_cast<GCS::Ellipse>(theEntity2->entity());
+
+ aConstrList.push_back(GCSConstraintPtr(
+ new GCS::ConstraintEqual(anEllipse1->radmin, anEllipse2->radmin)));
+ aConstrList.push_back(GCSConstraintPtr(new GCS::ConstraintP2PDistance(
+ anEllipse1->center, anEllipse1->focus1, theIntermed->scalar())));
+ aConstrList.push_back(GCSConstraintPtr(new GCS::ConstraintP2PDistance(
+ anEllipse2->center, anEllipse2->focus1, theIntermed->scalar())));
+ // update value of intermediate parameter
+ theIntermed->setValue(distance(anEllipse1->center, anEllipse1->focus1));
+ }
+ else {
std::shared_ptr<GCS::Circle> aCirc1 =
std::dynamic_pointer_cast<GCS::Circle>(theEntity1->entity());
std::shared_ptr<GCS::Circle> aCirc2 =
std::dynamic_pointer_cast<GCS::Circle>(theEntity2->entity());
-
- if (aCirc1 && aCirc2)
- aConstrList.push_back(GCSConstraintPtr(new GCS::ConstraintEqual(aCirc1->rad, aCirc2->rad)));
- else {
- std::shared_ptr<GCS::Ellipse> anEllipse1 =
- std::dynamic_pointer_cast<GCS::Ellipse>(theEntity1->entity());
- std::shared_ptr<GCS::Ellipse> anEllipse2 =
- std::dynamic_pointer_cast<GCS::Ellipse>(theEntity2->entity());
-
- aConstrList.push_back(GCSConstraintPtr(
- new GCS::ConstraintEqual(anEllipse1->radmin, anEllipse2->radmin)));
- aConstrList.push_back(GCSConstraintPtr(
- new GCS::ConstraintEqualMajorAxesConic(anEllipse1.get(), anEllipse2.get())));
- }
+ aConstrList.push_back(GCSConstraintPtr(new GCS::ConstraintEqual(aCirc1->rad, aCirc2->rad)));
}
std::shared_ptr<PlaneGCSSolver_ConstraintWrapper> aResult(