Improve constraint Middle point on elliptic arc.
}
}
+%typemap(in) double & (double temp) {
+ if (PyLong_Check($input)) {
+ temp = PyLong_AsLong($input);
+ $1 = &temp;
+ }
+}
+
+%typemap(argout) double & {
+ $result = PyFloat_FromDouble(*$1);
+}
+
// all supported interfaces
%include "GeomAPI_Interface.h"
if (aFeature->getKind() == SketchPlugin_Point::ID())
++aNbPoints;
else if (aFeature->getKind() == SketchPlugin_Line::ID() ||
- aFeature->getKind() == SketchPlugin_Arc::ID())
+ aFeature->getKind() == SketchPlugin_Arc::ID() ||
+ aFeature->getKind() == SketchPlugin_EllipticArc::ID())
++aNbLines;
}
}
<validator id="PartSet_DifferentObjects"/>
<validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
<validator id="SketchPlugin_PerpendicularAttr" parameters="ConstraintEntityB"/>
- <validator id="GeomValidators_ShapeType" parameters="line,circle"/>
+ <validator id="GeomValidators_ShapeType" parameters="edge"/>
</sketch_shape_selector>
<sketch_shape_selector id="ConstraintEntityB"
<validator id="PartSet_DifferentObjects"/>
<validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
<validator id="SketchPlugin_PerpendicularAttr" parameters="ConstraintEntityA"/>
- <validator id="GeomValidators_ShapeType" parameters="line,circle"/>
+ <validator id="GeomValidators_ShapeType" parameters="edge"/>
</sketch_shape_selector>
<validator id="PartSet_PerpendicularSelection"/>
</feature>
new PlaneGCSSolver_ConstraintWrapper(aNewConstr, CONSTRAINT_PT_ON_CURVE));
}
+template <typename ARCTYPE>
+void createConstraintMiddlePointOnArc(ARCTYPE theArc,
+ GCSPointPtr thePoint,
+ std::shared_ptr<PlaneGCSSolver_PointWrapper> theAuxParameters,
+ std::list<GCSConstraintPtr>& theConstraints)
+{
+ double* u = theAuxParameters->point()->x;
+ double* diff = theAuxParameters->point()->y;
+ *u = (*theArc->startAngle + *theArc->endAngle) * 0.5;
+ *diff = (*theArc->endAngle - *theArc->startAngle) * 0.5;
+
+ theConstraints.push_back(GCSConstraintPtr(
+ new GCS::ConstraintCurveValue(*thePoint, thePoint->x, *theArc, u)));
+ theConstraints.push_back(GCSConstraintPtr(
+ new GCS::ConstraintCurveValue(*thePoint, thePoint->y, *theArc, u)));
+ theConstraints.push_back(GCSConstraintPtr(
+ new GCS::ConstraintDifference(theArc->startAngle, u, diff)));
+ theConstraints.push_back(GCSConstraintPtr(
+ new GCS::ConstraintDifference(u, theArc->endAngle, diff)));
+}
+
ConstraintWrapperPtr createConstraintMiddlePoint(
std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint,
std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity,
}
else {
std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(theEntity->entity());
- if (anArc) {
- double* u = theAuxParameters->point()->x;
- double* diff = theAuxParameters->point()->y;
- *u = (*anArc->startAngle + *anArc->endAngle) * 0.5;
- *diff = (*anArc->endAngle - *anArc->startAngle) * 0.5;
-
- aConstrList.push_back(GCSConstraintPtr(
- new GCS::ConstraintCurveValue(*aPoint, aPoint->x, *anArc, u)));
- aConstrList.push_back(GCSConstraintPtr(
- new GCS::ConstraintCurveValue(*aPoint, aPoint->y, *anArc, u)));
- aConstrList.push_back(GCSConstraintPtr(
- new GCS::ConstraintDifference(anArc->startAngle, u, diff)));
- aConstrList.push_back(GCSConstraintPtr(
- new GCS::ConstraintDifference(u, anArc->endAngle, diff)));
+ if (anArc)
+ createConstraintMiddlePointOnArc(anArc, aPoint, theAuxParameters, aConstrList);
+ else {
+ std::shared_ptr<GCS::ArcOfEllipse> aEllArc =
+ std::dynamic_pointer_cast<GCS::ArcOfEllipse>(theEntity->entity());
+ if (aEllArc)
+ createConstraintMiddlePointOnArc(aEllArc, aPoint, theAuxParameters, aConstrList);
}
}
#include <PlaneGCSSolver_Tools.h>
#include <PlaneGCSSolver_UpdateCoincidence.h>
+static bool isArc(EntityWrapperPtr theEntity)
+{
+ return theEntity->type() == ENTITY_ARC || theEntity->type() == ENTITY_ELLIPTIC_ARC;
+}
+
void SketchSolver_ConstraintMiddle::getAttributes(
EntityWrapperPtr& theValue,
std::vector<EntityWrapperPtr>& theAttributes)
SketchSolver_Constraint::getAttributes(theValue, theAttributes);
// create auxiliary point if middle point on arc is specified
- if (theAttributes[2]->type() == ENTITY_ARC) {
+ if (isArc(theAttributes[2])) {
std::shared_ptr<PlaneGCSSolver_Storage> aStorage =
std::dynamic_pointer_cast<PlaneGCSSolver_Storage>(myStorage);
// update the middle point parameter if the constraint is "point-on-arc".
if (myOddPoint) {
EntityWrapperPtr anArcEntity =
- myAttributes.front()->type() == ENTITY_ARC ? myAttributes.front() : myAttributes.back();
+ isArc(myAttributes.front()) ? myAttributes.front() : myAttributes.back();
EdgeWrapperPtr anArcEdge =
std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(anArcEntity);
- std::shared_ptr<GCS::Arc> anArc;
- if (anArcEdge)
- anArc = std::dynamic_pointer_cast<GCS::Arc>(anArcEdge->entity());
- if (anArc) {
- // recalculate parameters of middle point according to arc
- *myOddPoint->x = (*anArc->startAngle + *anArc->endAngle) * 0.5;
- *myOddPoint->y = (*anArc->endAngle - *anArc->startAngle) * 0.5;
+ if (anArcEdge) {
+ std::shared_ptr<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(anArcEdge->entity());
+ if (anArc) {
+ // recalculate parameters of middle point according to arc
+ *myOddPoint->x = (*anArc->startAngle + *anArc->endAngle) * 0.5;
+ *myOddPoint->y = (*anArc->endAngle - *anArc->startAngle) * 0.5;
+ }
+ else {
+ std::shared_ptr<GCS::ArcOfEllipse> aEllArc =
+ std::dynamic_pointer_cast<GCS::ArcOfEllipse>(anArcEdge->entity());
+ if (aEllArc) {
+ // recalculate parameters of middle point according to arc
+ *myOddPoint->x = (*aEllArc->startAngle + *aEllArc->endAngle) * 0.5;
+ *myOddPoint->y = (*aEllArc->endAngle - *aEllArc->startAngle) * 0.5;
+ }
+ }
}
}
return;