How to use Spline.Insertknot method to convert Periodic spline(closed) to Non-Periodic spline

How to use Spline.Insertknot method to convert Periodic spline(closed) to Non-Periodic spline

pacifierY83DN
Participant Participant
882 Views
7 Replies
Message 1 of 8

How to use Spline.Insertknot method to convert Periodic spline(closed) to Non-Periodic spline

pacifierY83DN
Participant
Participant

I'm new to .NET Arx and now I have a question about how to convert a periodic spline to a non-periodic one. I would appreciate for any help here.

If we use spline command to create a spline in AutoCAD and close it, we will get a closed periodic spline (unclamped spline).

Spline can be represented by clamped format or unclamped format. The difference is the form of the knot vector. The clamped format will look like (0, 0, 0, 0, 1, 2, 3, 4, ... n, n, n, n). The unclamped format will look like (0, 1, 2, ..., n). Only unclamped format can be used to represent a periodic spline. So when we talk about periodic spline, it must be in unclamped format. 

I used Spline.InsertKnot Method to insert three knots (value=0.0) and three knots (value=last existing knot value), but it did not work. Although the spline was converted into a non-periodic spline, the control points and knots were wrong. 

pacifierY83DN_0-1697080247166.png

 

0 Likes
Accepted solutions (2)
883 Views
7 Replies
Replies (7)
Message 2 of 8

SEANT61
Advisor
Advisor

Hmmm!  That's looks like what I would expect to see.  If a curve were needed to match a periodic curve - similar shape with Tangency and curvature continuity at the start/endpoints - whilst being clamped. . . .  

 

What is not matching your expectations?


************************************************************
May your cursor always snap to the location intended.
0 Likes
Message 3 of 8

pacifierY83DN
Participant
Participant

Thank you for your quick reply and I am sorry that I failed to describe my question properly and clearly. Given the fact that I am from China and my English is not that good to express myself well enough to get me understood. I would like to give it a shot and describe my question step by step. So bear with me…

01.jpg02.jpg03.jpg04.jpg05.jpg

I really don’t know what caused the failure. Any help would be greatly appreciated.

0 Likes
Message 4 of 8

SEANT61
Advisor
Advisor

I still don’t understand your ultimate objective. It seems that you are exploring the NURBS Curve mechanics by modifying Knot Vectors to analyze the results. I applaud that effort though, as you mentioned, there will be combinations that will be unstable.

As useful and interesting as that “trial and error” method might be, it would probably take a long time to completely decipher the inner working of NURBS curves. There are significant complexities involved.

I recommend reading through these course notes. Hopefully they can be translated.


https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/


In my opinion, the programmers at Autodesk simplified the production and analysis of Periodic Splines (NURBS) at the cost of covering up what is going on behind the scenes.

As an example: the attached is a degree 3, Periodic Spline with 3 Control Points (CPs). But a valid spline needs Degree + 1 CPs. AutoCAD hides the fact that CPs 0,1,2 are all used more than once in the evaluation of that curve.

 

Let me know if any of this helps matters.  I may be misinterpreting what you require.  If this does help, I may be able to elaborate further if need be.


************************************************************
May your cursor always snap to the location intended.
Message 5 of 8

pacifierY83DN
Participant
Participant

Thanks for you patient reply and sorry again for not explaining my objectives clearly.

My objective is to read all relevant CAD entities in a DWG file, display them in APP for further processing and customizations by converting them into GDI+ objects and then generate 3D models in 3ds Max. For splines in AutoCAD, the only way I know is to convert them into Bezier curves and then they can be shown correctly in GDI+, and also that is the only way I know to convert them into 3ds Max Splines. That works well for unclamped splines whose length of knot vector is greater than length of the control array by degree+1.

When I first came to get to know .NET API about one week ago, I found the spline.insertknot method. So I wanted to convert all unclamped splines in CAD drawings into clamped splines once for all, and then I did not need to convert them the next time I access them.

Perhaps there is a lot more I need to learn about .NET API.

0 Likes
Message 6 of 8

SEANT61
Advisor
Advisor
Accepted solution

Cool  project!

 

You may find the Curve.GetSplitCurves Method (DoubleCollection)  - as well as Curve2d, Curve3d.GetSplitCurve(double value) – useful in the NURBS to Bezier conversion.

 

Some NURBS geometry may be incompatible with the Bezier structure.  Fortunately, those are not common in a typical AutoCAD workflow.


************************************************************
May your cursor always snap to the location intended.
Message 7 of 8

SEANT61
Advisor
Advisor
Accepted solution

To elaborate a bit further on my previous post, if an AutoCAD spline is split at the Knot values, the resulting geometry is compatible with the Bezier structure.


************************************************************
May your cursor always snap to the location intended.
Message 8 of 8

pacifierY83DN
Participant
Participant

Thanks a lot! I’m really glad and lucky to get help from experts like you.

Now I have a second and more efficient way to convert AutoCAD Splines into GDI+ Bezier curves as well as 3ds Max Splines. And with the application of .NET API, my APP runs much faster and more robust than that of ActiveX COM.