[CONNECT U13.1 C++] How to determine start point of Curve's segment

I developing a tool that will move a cell along linear segments. When the element is a LineString, my projection of the cursor's location to the element returns a CurveLocationDetail which contains the "componentIndex". This lets me determine which "segment" of the LineString the cursor is projected to. I also need to know which "side" (above/below) of the segment the cursor is on, so I want to determine the CrossProduct. To do that I need to create two DVec3d's - one from the segment start point to the cursor and the other from the segment start point to the segment end. I am attempting to get the segment's start/end points by Cloning the segment based on the componentIndex of the CurveLocationDetail. When the cursor projection is on componentIndex 1 or greater, the returned segment start point is always 0,0. 

How can I return the start/end points of a given "segment" of a LineString?

CurveVectorPtr				pickedLine = ICurvePathQuery::ElementToCurveVector(*GetElementAgenda().GetEntry(0));
if (pickedLine.IsValid())
{
	CurveLocationDetail				intersectDetail;
	DPoint3d					intersectPnt{ 0 };
	DVec3d						tangentAtPoint;
	pickedLine->ClosestPointBounded(*ev.GetPoint(), intersectDetail);
	intersectDetail.curve->FractionToPoint(intersectDetail.fraction, intersectPnt, tangentAtPoint);	// tangent NOT NORMALIZED
	tangentAtPoint.Normalize();	// we now have the line's tangent at the intersection point

	CurveVectorPtr				segment = pickedLine->CloneBetweenDirectedFractions(intersectDetail.componentIndex, 0.0, intersectDetail.componentIndex, 1.0, false);
	if (segment.IsValid())
	{
		DPoint3d				startPoint;
		segment->GetStartPoint(startPoint);
		wprintf(L"%f,  %f\n", startPoint.x, startPoint.y);
	}
	else
		wprintf(L"Invalid\n");
}

Bruce

Parents Reply Children
No Data