#include <PlaneGCSSolver_PointWrapper.h>
#include <PlaneGCSSolver_ScalarWrapper.h>
#include <PlaneGCSSolver_BooleanWrapper.h>
+#include <PlaneGCSSolver_Tools.h>
#include <SketchPlugin_Arc.h>
#include <SketchPlugin_Circle.h>
#include <SketchPlugin_Ellipse.h>
+#include <SketchPlugin_EllipticArc.h>
#include <SketchPlugin_IntersectionPoint.h>
#include <SketchPlugin_Line.h>
#include <SketchPlugin_Point.h>
static EntityWrapperPtr createArc(const AttributeEntityMap& theAttributes,
PlaneGCSSolver_Storage* theStorage);
static EntityWrapperPtr createEllipse(const AttributeEntityMap& theAttributes);
+static EntityWrapperPtr createEllipticArc(const AttributeEntityMap& theAttributes,
+ PlaneGCSSolver_Storage* theStorage);
PlaneGCSSolver_FeatureBuilder::PlaneGCSSolver_FeatureBuilder(
// Ellipse
else if (aFeatureKind == SketchPlugin_Ellipse::ID())
aResult = createEllipse(myAttributes);
+ // Arc of ellipse
+ else if (aFeatureKind == SketchPlugin_EllipticArc::ID())
+ aResult = createEllipticArc(myAttributes, myStorage);
// Point (it has low probability to be an attribute of constraint, so it is checked at the end)
else if (aFeatureKind == SketchPlugin_Point::ID() ||
aFeatureKind == SketchPlugin_IntersectionPoint::ID()) {
}
}
- // Additional atrtributes of arc necessary for PlaneGCS solver
+ // Additional attributes of arc necessary for PlaneGCS solver
// (start and end angles, radius)
aNewArc->startAngle = createParameter(theStorage);
aNewArc->endAngle = createParameter(theStorage);
aNewArc->rad = createParameter(theStorage);
- static std::shared_ptr<GeomAPI_Dir2d> OX(new GeomAPI_Dir2d(1.0, 0.0));
- std::shared_ptr<GeomAPI_Pnt2d> aCenter(
- new GeomAPI_Pnt2d(*aNewArc->center.x, *aNewArc->center.y));
- std::shared_ptr<GeomAPI_Pnt2d> aStart(
- new GeomAPI_Pnt2d(*aNewArc->start.x, *aNewArc->start.y));
-
- *aNewArc->rad = aStart->distance(aCenter);
-
- std::shared_ptr<GeomAPI_Dir2d> aDir(new GeomAPI_Dir2d(aStart->xy()->decreased(aCenter->xy())));
- *aNewArc->startAngle = OX->angle(aDir);
-
- aDir = std::shared_ptr<GeomAPI_Dir2d>(
- new GeomAPI_Dir2d((*aNewArc->end.x) - aCenter->x(), (*aNewArc->end.y) - aCenter->y()));
- *aNewArc->endAngle = OX->angle(aDir);
-
EdgeWrapperPtr anArcWrapper(new PlaneGCSSolver_EdgeWrapper(aNewArc));
anArcWrapper->setReversed(isReversed);
+ PlaneGCSSolver_Tools::recalculateArcParameters(anArcWrapper);
+
return anArcWrapper;
}
return anEllipseWrapper;
}
+EntityWrapperPtr createEllipticArc(const AttributeEntityMap& theAttributes,
+ PlaneGCSSolver_Storage* theStorage)
+{
+ std::shared_ptr<GCS::ArcOfEllipse> aNewArc(new GCS::ArcOfEllipse);
+
+ BooleanWrapperPtr isReversed;
+ std::map<std::string, EntityWrapperPtr> anAdditionalAttributes;
+
+ AttributeEntityMap::const_iterator anIt = theAttributes.begin();
+ for (; anIt != theAttributes.end(); ++anIt) {
+ std::shared_ptr<PlaneGCSSolver_PointWrapper> aPoint =
+ std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(anIt->second);
+ if (aPoint) {
+ if (anIt->first->id() == SketchPlugin_EllipticArc::CENTER_ID())
+ aNewArc->center = *(aPoint->point());
+ else if (anIt->first->id() == SketchPlugin_EllipticArc::FIRST_FOCUS_ID())
+ aNewArc->focus1 = *(aPoint->point());
+ else if (anIt->first->id() == SketchPlugin_EllipticArc::START_POINT_ID())
+ aNewArc->start = *(aPoint->point());
+ else if (anIt->first->id() == SketchPlugin_EllipticArc::END_POINT_ID())
+ aNewArc->end = *(aPoint->point());
+ else
+ anAdditionalAttributes[anIt->first->id()] = anIt->second;
+ }
+ else if (anIt->first->id() == SketchPlugin_EllipticArc::MINOR_RADIUS_ID()) {
+ ScalarWrapperPtr aScalar =
+ std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(anIt->second);
+ aNewArc->radmin = aScalar->scalar();
+ }
+ else if (anIt->first->id() == SketchPlugin_EllipticArc::REVERSED_ID())
+ isReversed = std::dynamic_pointer_cast<PlaneGCSSolver_BooleanWrapper>(anIt->second);
+ else
+ anAdditionalAttributes[anIt->first->id()] = anIt->second;
+ }
+
+ // Additional attributes of elliptic arc necessary for PlaneGCS solver (start and end angles)
+ aNewArc->startAngle = createParameter(theStorage);
+ aNewArc->endAngle = createParameter(theStorage);
+
+ EdgeWrapperPtr anEllipseWrapper(new PlaneGCSSolver_EdgeWrapper(aNewArc));
+ anEllipseWrapper->setReversed(isReversed);
+ anEllipseWrapper->setAdditionalAttributes(anAdditionalAttributes);
+ PlaneGCSSolver_Tools::recalculateArcParameters(anEllipseWrapper);
+
+ return anEllipseWrapper;
+}
+
bool isAttributeApplicable(const std::string& theAttrName, const std::string& theOwnerName)
{
if (theOwnerName == SketchPlugin_Arc::ID()) {
theAttrName == SketchPlugin_Ellipse::MAJOR_RADIUS_ID() ||
theAttrName == SketchPlugin_Ellipse::MINOR_RADIUS_ID();
}
+ else if (theOwnerName == SketchPlugin_EllipticArc::ID()) {
+ return theAttrName == SketchPlugin_EllipticArc::CENTER_ID() ||
+ theAttrName == SketchPlugin_EllipticArc::FIRST_FOCUS_ID() ||
+ theAttrName == SketchPlugin_EllipticArc::SECOND_FOCUS_ID() ||
+ theAttrName == SketchPlugin_EllipticArc::MAJOR_AXIS_START_ID() ||
+ theAttrName == SketchPlugin_EllipticArc::MAJOR_AXIS_END_ID() ||
+ theAttrName == SketchPlugin_EllipticArc::MINOR_AXIS_START_ID() ||
+ theAttrName == SketchPlugin_EllipticArc::MINOR_AXIS_END_ID() ||
+ theAttrName == SketchPlugin_EllipticArc::MAJOR_RADIUS_ID() ||
+ theAttrName == SketchPlugin_EllipticArc::MINOR_RADIUS_ID() ||
+ theAttrName == SketchPlugin_EllipticArc::START_POINT_ID() ||
+ theAttrName == SketchPlugin_EllipticArc::END_POINT_ID() ||
+ theAttrName == SketchPlugin_EllipticArc::REVERSED_ID();
+ }
// suppose that all remaining features are points
return theAttrName == SketchPlugin_Point::COORD_ID();