How to force draw a spline with its fitpoints instead of control points

How to force draw a spline with its fitpoints instead of control points

Anonymous
Not applicable
1,564 Views
3 Replies
Message 1 of 4

How to force draw a spline with its fitpoints instead of control points

Anonymous
Not applicable

I derived a custom entity from AcDbSpline, and I need to draw something else at the fitpoints.

void MyEnt::subViewportDraw(AcGiViewportDraw* pVd)
{
	assertReadEnabled();
	AcDbSpline::subViewportDraw(pVd);
	if (!hasFitData())
		return;
	AcDbSpline* currentEnt = NULL;
	AcDbObjectIdArray ss;
	AcDbObjectId oID = NULL;
	AcDbEntity* pEnt = NULL;
	AcGePoint3dArray fitPoints;
	Adesk::Boolean tangentsExist;
	AcGeVector3d startTangent;
	AcGeVector3d endTangent;
	int degree;
	double fitTolerance;
	AcDbExtents extents;
	getGeomExtents(extents);
	double max = 0, disp = 0;
	disp = abs(extents.maxPoint().x - extents.minPoint().x);
	if (disp > max)
		max = disp;
	disp = abs(extents.maxPoint().y - extents.minPoint().y);
	if (disp > max)
		max = disp;
	disp = abs(extents.maxPoint().z - extents.minPoint().z);
	if (disp > max)
		max = disp;
	max /= 50;
	getFitData(fitPoints, degree, fitTolerance, tangentsExist, startTangent, endTangent);
	for (int i = 0; i < fitPoints.length(); i++) {
		drawBDpoint(pVd, fitPoints[i], max);   //draw a circle at the i-th fitpoint with the radius max.
	}
	return;
}

When the spline is displayed fitpoints,  the drawing works fine, while the circles will not be drawn the control points are displayed.

I need to create myEnt with NURBS data instead of fitpoints, and the spline created are displayed with control points on default. If I want to see my custom drawing, I need to display the fitpoints manually. And there comes the question, how can I force draw the spline with its fitpoints, no mater how it is created?

0 Likes
Accepted solutions (2)
1,565 Views
3 Replies
Replies (3)
Message 2 of 4

tbrammer
Advisor
Advisor
Accepted solution

You can remove the fit data from an AcDbSpline using AcDbSpline::purgeFitData(). It will be displayed with circles at the control points then.

If you don't want to loose the fit data you can retrieve it with AcDbSpline::getFitData(..) and restore it with AcDbSpline::setFitData(..).

 

 


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

0 Likes
Message 3 of 4

Anonymous
Not applicable

Sorry for the confusion of my words before. I want to display circles(and someting else) at the fitpoints using the code above. If the spline is created using fit data, the fitpoints are displayed and the circles are drawn as I expected. If the spline is created using nurbs data, the control points are displayed, and the circles will not be drawn. So, I wonder if there is a simple way to force draw a spline with its fitpoints, no matter how the spline is created.

 

AcDbSpline(nurbs data) ----> getFitData() ----> setFitdata() looks a littel inefficient.

 

In the AutoCad program, I can switch the drawing manually in the right-mouse menu of spline, but I can't find that in the arx document. I wonder if there is a sample "switch" can do the job, which determines how a spline is drawn. Thank you.

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

Oh, I found that in the document. Sorry for my negligence.

AcDbSpline::setType()  would do the job.

0 Likes