Jump to content
Developer Wiki and Function Reference Links ×

Polylines in PIO: arcs and stuff


Hippocode

Recommended Posts

I've been trying to "round" or lets say "fillet" a custom polyline PIO.

It works with ArcTo when using some simple vectorscript like this:

BeginPoly;
ArcTo(0,50,5);
ArcTo(50,50,5);
ArcTo(50,-50,5);
ArcTo(0,-50,5);
EndPoly;

I fail at doing so when I try it on a PIO.

When looping trough the vertexes, I use the same code (ArcTo) to define the next points without result.

FOR i:= 2 TO num_vertices DO BEGIN
GetPolyPt(pathHd,i,v2x,v2y);
GetPolyPt(pathHd,i - 1,v1x,v1y);
ArcTo(v2x,v2y,5);

I also tried to change the vertexes after they were added as a polyline:

FOR i := 1 TO num_vertices DO BEGIN
GetPolylineVertex(polyHd, i, x, y, vertexType, vertexRadius);
SetPolylineVertex(polyHd, i, x, y, 3, kFilletRadius, TRUE);
END;

Does anyone know how to handle this properly ?

Edited by hippothamus
Link to comment
  • 1 year later...
hi Wouter,

did you find a sollution to this? I have the same problem (and tried the same code)

Yes I did.

Actually one of the above options worked out when using the "correct" path handle.

I created a function for it:

{ FILLET 2D POLY }
PROCEDURE F_FilletPoly(PolyHd:	HANDLE; FilletRadius:	REAL);
VAR
i,a,vertexType	:INTEGER;
x,y,vertexRadius	:REAL;
BEGIN
IF PolyHd <> NIL THEN BEGIN
	a:=GetVertNum(PolyHd);
	FOR i:= 1 TO a DO BEGIN
		GetPolylineVertex(PolyHd, i, x, y, vertexType, vertexRadius);
		If (i <> 1) AND (i <> a) THEN SetPolylineVertex(PolyHd, i, x, y, 3, FilletRadius, TRUE);
	END;
END;
END;

Link to comment

Wouter,

Is this working on 3D Polygon (gettype=25)? What you suggested I tried before but it is not working. It seems GetPolylineVertex/SetPolylineVertex is not working on 3D Polygon.

When I use GetPolylineVertex on 3D Polygon (and also on a nurb curve) then x,y,vertextype,vertexRadius are all '0' for all vertexes

Link to comment
Wouter,

Is this working on 3D Polygon (gettype=25)? What you suggested I tried before but it is not working. It seems /SetPolylineVertex is not working on 3D Polygon.

When I use GetPolylineVertex on 3D Polygon (and also on a nurb curve) then x,y,vertextype,vertexRadius are all '0' for all vertexes

Oh you were talking about a 3D curve.

I don't think it works on a nurbs curve sadly. And even if it did, you'd need to change the used functions to work with 3D vertexes. GetPolylineVertex = 2d only

Anyway, the only way I managed to round a 3D path was by extruding on a rounded 2D path. This only works if Z doesn't change of course :(

Link to comment

First, what you are calling a 3D polyline is actually defined in VW as a NURBS curve. Having said that, I think the best solution would be to create the 2D polyline first and then convert it to a NURBS curve.

Creating the NURBS curve from the start would be a very complex operation to get the desired roundness, which depends on the weight of each vertex.

The following is a 90 degree 2D arc with a 100 radius that I converted to a NURBS curve:

tempHandle := CreateNurbsCurve(100.00, 0.00, 0.00,TRUE,3);
AddVertex3D(tempHandle, 100.000000000000000,  58.578643762690483, 0.000000000000000);
AddVertex3D(tempHandle,  58.578643762690483, 100.000000000000000, 0.000000000000000);
AddVertex3D(tempHandle,   0.000000000000000, 100.000000000000000, 0.000000000000000);

NurbsSetWeight(tempHandle, 0,0,1);
NurbsSetWeight(tempHandle, 0,1,0.804737854124365);
NurbsSetWeight(tempHandle, 0,2,0.804737854124365);
NurbsSetWeight(tempHandle, 0,3,1);

NurbsSetKnot(tempHandle, 0,0,0);
NurbsSetKnot(tempHandle, 0,1,0);
NurbsSetKnot(tempHandle, 0,2,0);
NurbsSetKnot(tempHandle, 0,3,0);
NurbsSetKnot(tempHandle, 0,4,1);
NurbsSetKnot(tempHandle, 0,5,1);
NurbsSetKnot(tempHandle, 0,6,1);
NurbsSetKnot(tempHandle, 0,7,1);

If you search for "NURBS", you will find a few sites that give a good explanation of the theory behind its construction.

Link to comment
First, what you are calling a 3D polyline is actually defined in VW as a NURBS curve. Having said that, I think the best solution would be to create the 2D polyline first and then convert it to a NURBS curve.

Yes but you can't do that when you start from a 3D path based object where each vertex might have a different elevation. Its probably possible doing it all manually but that's a bit too much effort I guess :)

Link to comment
Yes but you can't do that when you start from a 3D path based object where each vertex might have a different elevation.

All you have to do is change the elevation of each NURBS vertex. In the example above if you start at 0.00 and end at 12.00 elevation, you then assign the appropriate elevation to the other mid points, which in this case is 4.00 & 8.00. The effect is a quarter spiral. In my experience, getting the NURBS object in the correct shape or roundness is far more complicated than setting elevations. By converting a polyline to a NURBS curve, most of the hard work is already done.

Its probably possible doing it all manually but that's a bit too much effort I guess

Is it a bit too much effort? Yes, it is and the NURBS learning curve is steep. I spent countless hours trying to get a traffic signal mast arm (a tapered path extrude) in the right shape so that I could calculate the elevation at any point along the arm axis.

Link to comment

Is it a bit too much effort? Yes, it is and the NURBS learning curve is steep. I spent countless hours trying to get a traffic signal mast arm (a tapered path extrude) in the right shape so that I could calculate the elevation at any point along the arm axis.

Well thank you for explaining it, I might try it after all as I'll need it soon. I'm actually hoping to find a SDK function for it :)

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...