For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

How to find intersection of two lines?

Pawel Dobrowolski's picture
Forums: 

I tried to find intersection of two lines on the same plane. gp_Lin or gp_Lin2d
I wanted to use Geom2dAPI_InterCurveCurve.
This function uses Handle_Geom2d_Curve us input parameters.
Is there any method to change type from gp_Lin for Handle_Geom2d_Curve.
Maybe there is another function to find intersection between two lines?

Paweł

Rob Bachrach's picture

You can create a Geom2d_Line, which is derived from Geom2d_Curve, from a gp_Lin2d.

Pawel Dobrowolski's picture

I tried to do like this:

Handle(Geom2d_Curve) line_angle_geom = Geom2d_Line(line_angle) ;

where line_angle is gp_Lin2d.

I receive message that Geom2d_Line can't be changed to Handle(Geom2d_Curve). How can I do it?

Paweł

Sharjith Naramparambath's picture

>I tried to do like this:

>Handle(Geom2d_Curve) line_angle_geom = Geom2d_Line>(line_angle) ;

>where line_angle is gp_Lin2d.

The syntax is wrong.
Here you are trying to assign the object directly.
Please use the new keyword to create the pointer and then assign to Handle(Geom2d_Curve).

Pawel Dobrowolski's picture

I finally succeeded with code below:

Handle(Geom2d_Curve) line_angle_gc;
Handle(Geom2d_Curve) line_bottom_gc;
Handle(Geom2d_Curve) line_upper_gc;

Handle(Geom2d_Line) line_angle_2d;
Handle(Geom2d_Line) line_bottom_2d;
Handle(Geom2d_Line) line_upper_2d;

Geom2d_Line line_up = Geom2d_Line(line_upper);
Geom2d_Line line_bot = Geom2d_Line(line_bottom);
Geom2d_Line line_ang = Geom2d_Line(line_angle);

line_upper_2d = &line_up;
line_angle_2d = &line_ang;
line_bottom_2d = &line_bot;

line_angle_gc = Handle (Geom2d_Line)::DownCast(line_angle_2d);
line_bottom_gc = Handle (Geom2d_Line)::DownCast(line_bottom_2d);
line_upper_gc = Handle (Geom2d_Line)::DownCast(line_upper_2d);

Geom2dAPI_InterCurveCurve Intersector_1( line_bottom_gc, line_angle_gc, 1.0e-6);
Geom2dAPI_InterCurveCurve Intersector_2( line_upper_gc, line_angle_gc, 1.0e-6);

gp_Pnt2d intersection2d_1 = Intersector_1.Point(1);
gp_Pnt2d intersection2d_2 = Intersector_2.Point(1);

Paul Jimenez's picture

Why not using IntAna2d_AnaIntersection instead?

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.