#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()) {
- theError = "The %1 feature kind of attribute is wrong. It should be %2 or %3 or %4 or %5";
- theError.arg(aFeature->getKind()).arg(SketchPlugin_Line::ID())
- .arg(SketchPlugin_Circle::ID()).arg(SketchPlugin_Arc::ID())
- .arg(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
return false;
}
}
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 = "Feature with kinds %1 and %2 can not be equal.";
+ theError = "Features with kinds %1 and %2 can not be equal.";
theError.arg(aType[0]).arg(aType[1]);
return false;
}
}
if(!aConstraintCoincidence.get()) {
- theError = "Error: one of the selected point does not have coicidence.";
+ theError = "Error: one of the selected point does not have coincidence.";
return false;
}
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;
}
}
}
}
else {
- theError = "Unable to build transversal arc on %1";
+ theError = "Unable to build perpendicular arc on %1";
theError.arg(anAttrFeature->getKind());
return false;
}
if (!anAttrFeature)
return aValid;
- std::string aKind = anAttrFeature->getKind();
- if (aKind == SketchPlugin_Line::ID() ||
- aKind == SketchPlugin_Arc::ID() ||
- aKind == SketchPlugin_Circle::ID()) {
-
- std::set<ResultPtr> anEdgeShapes;
- ModelGeomAlgo_Shape::shapesOfType(anAttrFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
- if (anEdgeShapes.empty() || anEdgeShapes.size() > 1 /*there case has not existed yet*/)
- return aValid;
-
- // coincidences to the feature
- std::set<std::shared_ptr<GeomDataAPI_Point2D> > aRefAttributes;
- ModelGeomAlgo_Point2D::getPointsOfReference(anAttrFeature,
- SketchPlugin_ConstraintCoincidence::ID(),
- aRefAttributes, SketchPlugin_Point::ID(), SketchPlugin_Point::COORD_ID());
-
- GeomShapePtr anAttrShape = (*anEdgeShapes.begin())->shape();
- std::shared_ptr<SketchPlugin_Feature> aSFeature =
- std::dynamic_pointer_cast<SketchPlugin_Feature>(anAttrFeature);
- SketchPlugin_Sketch* aSketch = aSFeature->sketch();
-
- std::shared_ptr<ModelAPI_Data> aData = aSketch->data();
- std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
- aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
- std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
- aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
- std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
- aData->attribute(SketchPlugin_Sketch::NORM_ID()));
- std::shared_ptr<GeomAPI_Dir> aDirY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir())));
-
- typedef std::map<std::shared_ptr<GeomAPI_Pnt>,
- std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
- std::list<std::shared_ptr<ModelAPI_Object> > > > PointToRefsMap;
- PointToRefsMap aPointsInfo;
-
- ModelGeomAlgo_Point2D::getPointsInsideShape(anAttrShape, aRefAttributes, aC->pnt(),
- aX->dir(), aDirY, aPointsInfo);
- int aCoincidentToFeature = (int)aPointsInfo.size();
- if (aKind == SketchPlugin_Circle::ID())
- aValid = aCoincidentToFeature >= 2;
- else
- aValid = aCoincidentToFeature >= 1;
- }
+ std::set<ResultPtr> anEdgeShapes;
+ ModelGeomAlgo_Shape::shapesOfType(anAttrFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
+ if (anEdgeShapes.empty() || anEdgeShapes.size() > 1 /*there case has not existed yet*/)
+ return aValid;
+
+ // coincidences to the feature
+ std::set<std::shared_ptr<GeomDataAPI_Point2D> > aRefAttributes;
+ ModelGeomAlgo_Point2D::getPointsOfReference(anAttrFeature,
+ SketchPlugin_ConstraintCoincidence::ID(),
+ aRefAttributes, SketchPlugin_Point::ID(), SketchPlugin_Point::COORD_ID());
+
+ GeomShapePtr anAttrShape = (*anEdgeShapes.begin())->shape();
+ std::shared_ptr<SketchPlugin_Feature> aSFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(anAttrFeature);
+ if (!aSFeature)
+ return false;
+ SketchPlugin_Sketch* aSketch = aSFeature->sketch();
+
+ std::shared_ptr<ModelAPI_Data> aData = aSketch->data();
+ std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
+ aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
+ std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+ std::shared_ptr<GeomAPI_Dir> aDirY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir())));
+
+ typedef std::map<std::shared_ptr<GeomAPI_Pnt>,
+ std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
+ std::list<std::shared_ptr<ModelAPI_Object> > > > PointToRefsMap;
+ PointToRefsMap aPointsInfo;
+
+ ModelGeomAlgo_Point2D::getPointsInsideShape(anAttrShape, aRefAttributes, aC->pnt(),
+ aX->dir(), aDirY, aPointsInfo);
+ int aCoincidentToFeature = (int)aPointsInfo.size();
+ if (anAttrFeature->getKind() == SketchPlugin_Circle::ID() ||
+ anAttrFeature->getKind() == SketchPlugin_Ellipse::ID())
+ aValid = aCoincidentToFeature >= 2;
+ else
+ aValid = aCoincidentToFeature >= 1;
return aValid;
}
if (!aSketchFeature.get() || aSketchFeature->isCopy())
return aValid;
- std::string aKind = aBaseFeature->getKind();
- if (aKind != SketchPlugin_Line::ID() &&
- aKind != SketchPlugin_Arc::ID() &&
- aKind != SketchPlugin_Circle::ID())
- return aValid;
-
// point on feature
AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aTrimFeature->data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
std::map<ObjectPtr, std::map<std::shared_ptr<GeomAPI_Pnt>,
std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
std::list<std::shared_ptr<ModelAPI_Object> > > > > anObjectToPoints;
- SketchPlugin_Trim::fillObjectShapes(aBaseObject, aSketch->data()->owner(),
- aCashedShapes, anObjectToPoints);
+ SketchPlugin_SegmentationTools::fillObjectShapes(
+ aTrimFeature.get(), aBaseObject, aCashedShapes, anObjectToPoints);
const std::set<GeomShapePtr>& aShapes = aCashedShapes[aBaseObject];
return aShapes.size() > 1;
std::shared_ptr<GeomAPI_Ellipse> anEllipse = anEdge->ellipse();
std::shared_ptr<GeomAPI_Dir> anEllipseNormal = anEllipse->normal();
double aDot = fabs(aNormal->dot(anEllipseNormal));
- bool aValid = aDot >= tolerance * tolerance;
+ bool aValid = fabs(aDot - 1.0) <= tolerance * tolerance;
if (!aValid)
- theError.arg(anEdge->isEllipse() ? "Error: Ellipse is orthogonal to the sketch plane."
- : "Error: Elliptic Arc is orthogonal to the sketch plane.");
+ theError.arg(anEdge->isClosed() ? "Error: Ellipse is orthogonal to the sketch plane."
+ : "Error: Elliptic Arc is orthogonal to the sketch plane.");
return aValid;
}
- theError = "Error: Selected object is not line, circle or arc.";
+ theError = "Error: Selected object is not supported for projection.";
return false;
}