- if (theOwner->HasSelectable()) {
- Handle(StdSelect_BRepOwner) aShapeOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
- if (!aShapeOwner.IsNull()) {
- TopoDS_Shape aShape = aShapeOwner->Shape();
- TopAbs_ShapeEnum aType = aShape.ShapeType();
- switch (aType) {
- case TopAbs_VERTEX:
- {
- gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
- return myPlane.Distance(aPnt) < Precision::Confusion();
+ bool aValid = true;
+
+ if (myPlane.get()) {
+ aValid = Standard_False;
+ if (theOwner->HasSelectable()) {
+ gp_Pln aPlane = myPlane->impl<gp_Pln>();
+ Handle(StdSelect_BRepOwner) aShapeOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
+ if (!aShapeOwner.IsNull() && aShapeOwner->HasShape()) {
+ TopoDS_Shape aShape = aShapeOwner->Shape();
+ TopAbs_ShapeEnum aType = aShape.ShapeType();
+ switch (aType) {
+ case TopAbs_VERTEX:
+ {
+ gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
+ return aPlane.SquareDistance(aPnt) < Precision::SquareConfusion();
+ }
+ case TopAbs_EDGE:
+ {
+ std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge);
+ anEdge->setImpl<TopoDS_Shape>(new TopoDS_Shape(aShape));
+ return anEdge->isInPlane(myPlane);
+ }
+ default:
+ // The object can be selected in Object browser and contain, for example, compound.
+ // The compound could not belong to any plane, so the result is false
+ aValid = Standard_False;
+ break;