#include <AIS_Point.hxx>
#include <AIS_Line.hxx>
#include <Geom_Point.hxx>
+#include <Geom_BSplineCurve.hxx>
+#include <Geom_Line.hxx>
#include <StdSelect_BRepOwner.hxx>
#include <QHBoxLayout>
return isFound;
gp_Pnt aPoint;
+ Standard_Real aParameter;
gp_Pnt aPnt1, aPnt2;
Handle(AIS_Line) aLine = Handle(AIS_Line)::DownCast( theObject );
if ( !aLine.IsNull() ) {
const Handle(Geom_Line) aGLine = aLine->Line();
+ isFound = hasProjectPointOnCurve( theX, theY, aGLine, aParameter );
+ if ( isFound ) {
+ aPoint = aGLine->Value( aParameter );
+
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 ( !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 ( aCurve->IsKind( STANDARD_TYPE(Geom_BSplineCurve) ) ) {
+ Handle(Geom_BSplineCurve) aBSplineCurve = Handle(Geom_BSplineCurve)::DownCast( aCurve );
+ if ( !aBSplineCurve.IsNull() ) {
+ isFound = hasProjectPointOnCurve( theX, theY, aCurve, aParameter );
+ if ( isFound ) {
+ aPoint = aBSplineCurve->Value( aParameter );
+ Standard_Integer anI1, anI2;
+ aBSplineCurve->LocateU( aParameter, LOCAL_SELECTION_TOLERANCE, anI1, anI2 );
+
+ aPnt1 = aBSplineCurve->Value( aBSplineCurve->Knot( anI1 ) );
+ aPnt2 = aBSplineCurve->Value( aBSplineCurve->Knot( anI2 ) );
+ }
+ }
+ }
}
}
}
*/
bool CurveCreator_Widget::hasProjectPointOnCurve( const int theX, const int theY,
const Handle(Geom_Curve)& theCurve,
- gp_Pnt& theOutPoint )
+ Standard_Real& theParameter )
{
bool isFound = false;
OCCViewer_Viewer* aViewer = getOCCViewer();
Standard_Integer aNbPoint = aProj.NbPoints();
if (aNbPoint > 0) {
for (Standard_Integer j = 1; j <= aNbPoint && !isFound; j++) {
- gp_Pnt aNewPoint = aProj.Point(j);
+ gp_Pnt aNewPoint = aProj.Point( j );
+ theParameter = aProj.Parameter( j );
int aX, anY;
CurveCreator_Utils::ConvertPointToClick( aNewPoint, aView, aX, anY );
int aXDelta = abs( aX - theX );
int anYDelta = abs( anY - theY );
isFound = aXDelta < SCENE_PIXEL_TOLERANCE && anYDelta < SCENE_PIXEL_TOLERANCE;
- if ( isFound ) {
- theOutPoint = aNewPoint;
- }
}
}
return isFound;