AcGeNurbSurface - control points

AcGeNurbSurface - control points

Anonymous
Not applicable
751 Views
2 Replies
Message 1 of 3

AcGeNurbSurface - control points

Anonymous
Not applicable

Hello everyone,

 

I am trying to get the control points from an AcGeNurbSurface entity. What I found from the documentation is that I can use the method getControlPoints. However, this method does not mention how the control points are arranged, if they vary most quickly in the u direction and then in the v direction or vice versa?

 

In addition, I was expecting to find a method to get a single control point at specific location. So, I can revert by myself.

 

Could anyone explain me how the control points are arranged and if there is any other way to obtain more specific information for them?

 

Respectfully,

Evangelos

 

0 Likes
Accepted solutions (1)
752 Views
2 Replies
Replies (2)
Message 2 of 3

tbrammer
Advisor
Advisor
Accepted solution

I use the follwing code to convert some 3rd party NURBS surface data to AcGeNurbSurface:

 

bool setNurbSurface(AcGeNurbSurface &acSurf, const ExternalNurbSurface &extNurbSurf)
{
	int degreeU = extNurbSurf.DegreeU(); 
	int degreeV = extNurbSurf.DegreeV();
	//props: See AcGe::NurbSurfaceProperties 
        //enum NurbSurfaceProperties {kOpen=0x01, kClosed=0x02, kPeriodic=0x04,
        //                            kRational=0x08, kNoPoles=0x10, kPoleAtMin=0x20,
        //                            kPoleAtMax=0x40, kPoleAtBoth=0x80};

	const ExternalNurbSurfNet surfNet=extNurbSurf.SurfNet();
	bool bIsReversed = extNurbSurf.IsReversed();

	int propsInU = AcGe::kOpen; 
	int propsInV = AcGe::kOpen; 

	AcGeDoubleArray weights;
	AcGePoint3dArray controlPoints;
	AcGePoint3d acPt;
	double w, f;
	int numControlPointsInU = (int)surfNet.rows();
	int numControlPointsInV = (int)surfNet.columns();
	int u,v;

	for (u=0; u<numControlPointsInU; u++)
	for (v=0; v<numControlPointsInV; v++)
	{
		const ExternalPoint &extPt = surfNet[u][v];
		w = Weight(extPt.w());
		f = (fabs(w) > 1e-10)?  (1.0 / w) : 1.0;

		acPt.x = f*extPt.x();
		acPt.y = f*extPt.y();
		acPt.z = f*extPt.z();

		if ((u>0) && (w != Weight(surfNet[u][0].w())) )
			propsInU |= AcGe::kRational; 
		if ((v>0) && (w != Weight(surfNet[0][v].w())) )
			propsInV |= AcGe::kRational; 

		controlPoints.append(acPt);
		weights.append(w);
	}

	ExternalKnotVectors extKnots = extNurbSurf.GetKnotVectors();
	size_t nUknots = extKnots.UKnots();
	size_t nVknots = extKnots.VKnots();
	AcGeKnotVector uKnots, vKnots;

	for (u=0; u<nUknots ; u++)
		uKnots.append(extKnots.GetUKnot(u));

	for (v=0; v<nVknots ; v++)
		vKnots.append(extKnots.GetVKnot(v));

	acSurf.set(
		degreeU, degreeV,
		propsInU, propsInV,
		numControlPointsInU, numControlPointsInV,
		controlPoints.asArrayPtr(),
		weights.asArrayPtr(),
		uKnots, vKnots
	);

	if (bIsReversed)
		acSurf.reverseNormal();

	return true;
}

As you can see in the two for-Loops the controlpoints are ordered like this:

[u0,v0], [u0,v1], [u0,v2],   [u1,v0], [u1,v1], [u1,v2],   [u2,v0], [u2,v1], [u2,v2],   ...


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

Message 3 of 3

Anonymous
Not applicable

Thank you very much for your reply tbrammer!

 

So, AutoCAD assumes by default that the control points vary most quickly with v and then with u. In my opinion, it must be mentioned in the description of the control points of the AcGeNurbSurface.

 

Kind regards,

Evangelos

 

 

0 Likes