#include <GeomAPI_Lin.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Vertex.h>
+
#include <GeomDataAPI_Point2D.h>
+#include <GeomDataAPI_Point2DArray.h>
#include <algorithm>
#include <cmath>
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;
}
}
AttributeReferencePtr aFeatureAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
+ std::shared_ptr<SketchPlugin_Feature> aSplitFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
ObjectPtr anAttrObject = aFeatureAttr->value();
+ if (!anAttrObject) {
+ AttributePtr aPreviewAttr = aSplitFeature->attribute(SketchPlugin_Trim::PREVIEW_OBJECT());
+ aFeatureAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(aPreviewAttr);
+ anAttrObject = aFeatureAttr->value();
+ }
+
FeaturePtr anAttrFeature = ModelAPI_Feature::feature(anAttrObject);
if (!anAttrFeature)
return aValid;
std::shared_ptr<GeomAPI_Dir> aNormal = aPlane->direction();
std::shared_ptr<GeomAPI_Pnt> anOrigin = aPlane->location();
+ bool aValid = true;
if (anEdge->isLine()) {
std::shared_ptr<GeomAPI_Lin> aLine = anEdge->line();
std::shared_ptr<GeomAPI_Dir> aLineDir = aLine->direction();
double aDot = fabs(aNormal->dot(aLineDir));
- bool aValid = fabs(aDot - 1.0) >= tolerance * tolerance;
+ aValid = fabs(aDot - 1.0) >= tolerance * tolerance;
if (!aValid)
theError = "Error: Line is orthogonal to the sketch plane.";
- return aValid;
}
else if (anEdge->isCircle() || anEdge->isArc()) {
std::shared_ptr<GeomAPI_Circ> aCircle = anEdge->circle();
std::shared_ptr<GeomAPI_Dir> aCircNormal = aCircle->normal();
double aDot = fabs(aNormal->dot(aCircNormal));
- bool aValid = aDot >= tolerance * tolerance;
+ aValid = aDot >= tolerance * tolerance;
if (!aValid)
theError.arg(anEdge->isCircle() ? "Error: Circle is orthogonal to the sketch plane."
: "Error: Arc is orthogonal to the sketch plane.");
- return aValid;
}
else if (anEdge->isEllipse()) {
std::shared_ptr<GeomAPI_Ellipse> anEllipse = anEdge->ellipse();
std::shared_ptr<GeomAPI_Dir> anEllipseNormal = anEllipse->normal();
double aDot = fabs(aNormal->dot(anEllipseNormal));
- bool aValid = fabs(aDot - 1.0) <= tolerance * tolerance;
+ aValid = fabs(aDot - 1.0) <= tolerance * tolerance;
if (!aValid)
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 supported for projection.";
- return false;
+ return aValid;
}
return true;
}
+
+bool SketchPlugin_BSplineValidator::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const
+{
+ AttributePoint2DArrayPtr aPolesArray =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2DArray>(theAttribute);
+ if (!aPolesArray)
+ return false;
+
+ if (aPolesArray->size() < 2) {
+ theError = "Number of B-spline poles should be 2 and more";
+ return false;
+ }
+
+ return true;
+}