intersectWith api has error, the intersect points are wrong

intersectWith api has error, the intersect points are wrong

475867377
Advocate Advocate
501 Views
2 Replies
Message 1 of 3

intersectWith api has error, the intersect points are wrong

475867377
Advocate
Advocate

a ray intersectWith a polyline,get three intersect points.but one point is wrong .it is not intersct point in fact. i use red line to join the three point.i have marked the three point "1,2,3". the third point is not intersect  with polyline in fact.there are only two intersect points in fact. the following are the code. pts_intesect and pts_intesect2 are the same result.

 

AcGePoint3d pttemp = AcGePoint3d(ptc.x + drad*cos(dang),ptc.y+ drad*sin(dang),ptc.z);
AcDbRay* pray = new AcDbRay();
pray->setBasePoint(pttemp);
pray->setUnitDir(rayvec);
AcGePoint3dArray pts_intesect;
vector<AcGePoint3d> vec1;
err = polyLine->intersectWith(pray, AcDb::kExtendArg, pts_intesect);
for each (AcGePoint3d var in pts_intesect)
{
vec1.push_back(var);
}
AcGePoint3dArray pts_intesect2;
vector<AcGePoint3d> vec2;
 
err = pray->intersectWith(polyLine, AcDb::kExtendThis, pts_intesect2);
for each (AcGePoint3d var in pts_intesect2)
{
vec2.push_back(var);
}
 
delete pray;

475867377_0-1709173941669.png

475867377_1-1709174078935.png

 

 

0 Likes
502 Views
2 Replies
Replies (2)
Message 2 of 3

ynapeu
Advocate
Advocate

I think you should use, AcDb::kOnBothOperands 

AcDb::kOnBothOperands 
Do not extend either entity. This results in only calculating intersections where the two entity's geometry actually intersect 
0 Likes
Message 3 of 3

tbrammer
Advisor
Advisor

I tried to reproduce your observation. But the provided code is not sufficient.

Please provide values for ptc, drad, dang and rayvec and either a DWG with a polyline that can be used for polyline or code to create it.

 

tbrammer_0-1713340925710.pngtbrammer_1-1713340943512.png

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes