GeomPlanePtr getPlane(AttributeSelectionPtr theAttr)
{
GeomShapePtr aGeom = theAttr->value();
+ if (!aGeom.get()) { // construction plane, #2942
+ aGeom = theAttr->context()->shape();
+ }
GeomFacePtr aFace(new GeomAPI_Face(aGeom));
return aFace->getPlane();
}
-bool FiltersPlugin_OnPlane::isOk(const GeomShapePtr& theShape,
- const ModelAPI_FiltersArgs& theArgs) const
+bool FiltersPlugin_OnPlane::isOk(const GeomShapePtr& theShape, const ResultPtr&,
+ const ModelAPI_FiltersArgs& theArgs) const
{
AttributePtr aAttr = theArgs.argument("OnPlane");
AttributeSelectionListPtr aList =
return true;
}
}
- else if (aEdge->isCircle()) {
- GeomCurvePtr aCurve(new GeomAPI_Curve(aEdge));
- GeomCirclePtr aCircle(new GeomAPI_Circ(aCurve));
- GeomDirPtr aDir = aCircle->normal();
- GeomPointPtr aPnt = aCircle->center();
+ else if (aEdge->isPlanar()) {
for (int i = 0; i < aList->size(); i++) {
GeomPlanePtr aPlane = getPlane(aList->value(i));
- if ((aPlane->direction()->isParallel(aDir)) && (aPlane->distance(aPnt) < LIN_TOLERANCE))
+ if (aEdge->isInPlane(aPlane))
return true;
}
}
return false;
}
-static std::string XMLRepresentation =
-"<filter id = \"OnPlane\">"
-" <multi_selector id=\"OnPlane__OnPlane\""
-" label=\"Planes:\""
-" tooltip=\"Select planes or planar faces.\""
-" type_choice=\"faces\">"
-" <validator id=\"GeomValidators_ShapeType\" parameters=\"plane\"/>"
-" </multi_selector>"
-"</filter>";
-
-
std::string FiltersPlugin_OnPlane::xmlRepresentation() const
{
- return XMLRepresentation;
+ return xmlFromFile("filter-OnPlane.xml");
}
void FiltersPlugin_OnPlane::initAttributes(ModelAPI_FiltersArgs& theArguments)