X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_ViewerFilters.cpp;h=f92e3895e9ab363cdb63cb29d0a6b0b6f0f13fb9;hb=9aeb69897970e21212d6f8926ec33d2eb696f18d;hp=6406ccca612aca59840aa253b243fbecf8c65f55;hpb=abac27c7c46a40f8bf1f96f6c54d62c1c929c6c3;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_ViewerFilters.cpp b/src/ModuleBase/ModuleBase_ViewerFilters.cpp index 6406ccca6..f92e3895e 100644 --- a/src/ModuleBase/ModuleBase_ViewerFilters.cpp +++ b/src/ModuleBase/ModuleBase_ViewerFilters.cpp @@ -13,8 +13,16 @@ #include #include +#include + #include #include +#include +#include +#include +#include +#include +#include #include @@ -74,29 +82,22 @@ Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk(const Handle(SelectMgr_Enti if (myPlane.get()) { aValid = Standard_False; if (theOwner->HasSelectable()) { + gp_Pln aPlane = myPlane->impl(); Handle(StdSelect_BRepOwner) aShapeOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner); - if (!aShapeOwner.IsNull()) { + if (!aShapeOwner.IsNull() && aShapeOwner->HasShape()) { TopoDS_Shape aShape = aShapeOwner->Shape(); TopAbs_ShapeEnum aType = aShape.ShapeType(); - gp_Pln aPlane = myPlane->impl(); switch (aType) { case TopAbs_VERTEX: { gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape)); - return aPlane.Distance(aPnt) < Precision::Confusion(); + return aPlane.SquareDistance(aPnt) < Precision::SquareConfusion(); } 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; + std::shared_ptr anEdge(new GeomAPI_Edge); + anEdge->setImpl(new TopoDS_Shape(aShape)); + return anEdge->isInPlane(myPlane); } default: // The object can be selected in Object browser and contain, for example, compound. @@ -105,6 +106,23 @@ Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk(const Handle(SelectMgr_Enti break; } } else { + // Check Trihedron sub-objects + Handle(SelectMgr_SelectableObject) aSelObj = theOwner->Selectable(); + Handle(Standard_Type) aType = aSelObj->DynamicType(); + if (aType == STANDARD_TYPE(AIS_Axis)) { + Handle(AIS_Axis) aAxis = Handle(AIS_Axis)::DownCast(aSelObj); + gp_Lin aLine = aAxis->Component()->Lin(); + return aPlane.Contains(aLine, Precision::Confusion(), Precision::Angular()); + + } else if (aType == STANDARD_TYPE(AIS_Point)) { + Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast(aSelObj); + return aPlane.Distance(aPoint->Component()->Pnt()) < Precision::Confusion(); + + } else if (aType == STANDARD_TYPE(AIS_Plane)) { + Handle(AIS_Plane) aAisPlane = Handle(AIS_Plane)::DownCast(aSelObj); + gp_Pln aPln = aAisPlane->Component()->Pln(); + return aPlane.Distance(aPln) < Precision::Confusion(); + } // This is not object controlled by the filter aValid = Standard_True; }