- gp_Pnt aPoint;
- gp_Pnt aPnt1, aPnt2;
- Handle(AIS_Line) aLine = Handle(AIS_Line)::DownCast( theObject );
- if ( !aLine.IsNull() ) {
- const Handle(Geom_Line) aGLine = aLine->Line();
- Handle(Geom_Point) aPStart;
- Handle(Geom_Point) aPEnd;
- aLine->Points( aPStart, aPEnd );
- aPnt1 = aPStart->Pnt();
- aPnt2 = aPEnd->Pnt();
- isFound = hasProjectPointOnCurve( theX, theY, aGLine, aPoint );
- }
- else {
- Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast( theObject );
- if ( !aShape.IsNull() ) {
- const TopoDS_Wire& aWire = TopoDS::Wire( aShape->Shape() );
- if ( !aWire.IsNull() ) {
- TopExp_Explorer anExp( aWire, TopAbs_EDGE );
- for ( ; anExp.More(); anExp.Next())
- {
- const TopoDS_Edge& anEdge = TopoDS::Edge(anExp.Current());
- if ( !anEdge.IsNull() ) {
- Standard_Real aFirst, aLast;
- Handle(Geom_Curve) aCurve = BRep_Tool::Curve( anEdge, aFirst, aLast );
- aCurve->D0(aFirst,aPnt1);
- aCurve->D0(aLast,aPnt2);
- isFound = hasProjectPointOnCurve( theX, theY, aCurve, aPoint );
- }
- }
- }
- }
- }
- if ( isFound ) {
- thePoint = aPoint;
- thePoint1 = findLocalPointIndex( 0, aPnt1.X(), aPnt1.Y() );
- thePoint2 = findLocalPointIndex( 0, aPnt2.X(), aPnt2.Y() );
- isFound = thePoint1 >= 0 && thePoint2 >= 0;
- }
- return isFound;