Jump to content

GpiPolyFilletSharp

From EDM2
Revision as of 20:58, 6 April 2025 by Iturbide (talk | contribs) (Created page with "This function creates a fillet on a series of connected lines, with the first line starting at the current position. Subsequent points identify the end points of the lines. ==Syntax== GpiPolyFilletSharp(hps, lCount, aptlPoints, afxPoints) ==Parameters== ; hps (HPS) - input : Presentation-space handle. ; lCount (LONG) - input : Count of points. : This is the number of points specified in aptlPoints. It must be 2*f, where f is the number of fillets; the value m...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function creates a fillet on a series of connected lines, with the first line starting at the current position. Subsequent points identify the end points of the lines.

Syntax

GpiPolyFilletSharp(hps, lCount, aptlPoints, afxPoints)

Parameters

hps (HPS) - input
Presentation-space handle.
lCount (LONG) - input
Count of points.
This is the number of points specified in aptlPoints. It must be 2*f, where f is the number of fillets; the value must be a positive even number. Zero is valid but causes no output.
aptlPoints (PPOINTL) - input
An array of points.
These points are set as follows: c1, e1, c2, e2, c3, e3, ... cf, ef
where:
cf is the control point for the f'th fillet
ef is the end point of the f'th fillet.
afxPoints (PFIXED) - input
Array of sharpness values.
These give the sharpness of successive fillets.

Return Value

lHits (LONG) - returns
Correlation and error indicators.
GPI_OK
Successful
GPI_HITS
Correlate hits
GPI_ERROR
Error.

Remarks

The first fillet is drawn using the two imaginary lines, one from current position to its control point (the first point specified in aptlPoints), and one from this point to the second point specified in aptlPoints. The fillet starts from current position, and ends at this second point. It is tangential to the first line at current position, and to the second line at the second point of aptlPoints. The sharpness of this fillet is given by the first element of the afxPoints array. Each subsequent fillet is drawn starting from the end point of the previous fillet, and uses the next two lines in the sequence, in a similar way. Therefore two points and one sharpness value are required for each fillet. The differences from GpiPolyFillet are:

  • The sharpness of each fillet is explicitly specified.
  • Both the control and the end point of each fillet are explicitly specified.
  • Adjacent fillets, generally, have a discontinuity in gradient, unless the points are chosen so that this is not the case.

The sharpness of each fillet is defined as follows. Let A and C be the start and end points, respectively, of the fillet, and let B be the control point. Let W be the mid-point of AC. Let D be the point where the fillet intersects WB. sharpness = WD/DB so that

  • > 1.0 means a hyperbola is drawn
  • = 1.0 means a parabola is drawn
  • < 1.0 means an ellipse is drawn.

On completion, the current position is the end point of the last line in the series. Each individual fillet always lies within the area bounded by the start, end, and control points. It is not an error for any of the points to be coincident. The maximum number of fillets allowed is more than 2 000.

Errors

Possible returns from WinGetLastError:

PMERR_INV_HPS (0x207F)
An invalid presentation-space handle was specified.
PMERR_PS_BUSY (0x20F4)
An attempt was made to access the presentation space from more than one thread simultaneously.
PMERR_INV_LENGTH_OR_COUNT (0x2092)
An invalid length or count parameter was specified.
PMERR_INV_COORDINATE (0x205B)
An invalid coordinate value was specified.
PMERR_INV_SHARPNESS_PARM (0x20CD)
An invalid sharpness parameter was specified with GpiPolyFilletSharp.
PMERR_INV_NESTED_FIGURES (0x20A8)
Nested figures have been detected within a path definition.

Graphic Elements and Orders

Element Type: OCODE_GCSFLT Order: Sharp Fillet at Current Position As many of these orders are generated as is necessary to hold the specified fillets.

Example Code

#define INCL_GPIPRIMITIVES /* Or use INCL_GPI, INCL_PM, */
#include <os2.h>

HPS     hps;         /* Presentation-space handle. */
LONG    lCount;      /* Count of points. */
PPOINTL aptlPoints;  /* An array of points. */
PFIXED  afxPoints;   /* Array of sharpness values. */
LONG    lHits;       /* Correlation and error indicators. */

lHits = GpiPolyFilletSharp(hps, lCount, aptlPoints, afxPoints);

This example uses the GpiPolyFilletSharp function to draw a curve with a loop. The curve is drawn within a rectangle. The sharpness values are chosen to draw the curve close to the control points.

#define INCL_GPIPRIMITIVES /* GPI primitive functions */
#include <os2.h>

HPS hps; /* presentation space handle */
POINTL ptlStart = { 0, 0 }; /* start of curve */
POINTL aptl[4]={ 100, 100, 200, 100, 0, 100, 200, 0};/* points */
FIXED afx[2]={MAKEFIXED(4, 0), MAKEFIXED(4, 0)};/* sharpness */

GpiMove(hps, &ptlStart); /* move to first starting point */
GpiPolyFilletSharp(hps, /* presentation-space handle */
                     4L, /* 4 points in the array */
                     aptl, /* address of array of points */
                     afx); /* address of array of sharpness values */

Related Functions