+ 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.Distance(aPnt) < Precision::Confusion();
+ }
+ case TopAbs_EDGE:
+ {
+ TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+ Standard_Real aFirst, aLast;
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aFirst, aLast);
+ gp_Pnt aFirstPnt = aCurve->Value(aFirst);
+ gp_Pnt aMidPnt = aCurve->Value((aFirst + aLast) / 2.);
+ gp_Pnt aLastPnt = aCurve->Value(aLast);
+ bool aD1 = aPlane.Distance(aFirstPnt) < Precision::Confusion();
+ bool aD2 = aPlane.Distance(aMidPnt) < Precision::Confusion();
+ bool aD3 = aPlane.Distance(aLastPnt) < Precision::Confusion();
+ return aD1 && aD2 && aD3;
+ }
+ 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;