Function Prototypes
/*-------------------------------------------------------------------
Open a surface model with file location and name FileName.
*/
int FnModelOpenSurface( char *FileName) ;
/*-------------------------------------------------------------------
Close all open surface models.
*/
int FnModelCloseSurfaces( void) ;
/*-------------------------------------------------------------------
Return number of triangulated surface models.
*/
int FnSurfaceCount( void) ;
/*-------------------------------------------------------------------
Fill structure with information about triangulated surfaces.
S points to a table of SurfInfo structures. Calling application
should have allocated it to hold at least FnSurfaceCount()
items.
Return number of items filled in the table (=FnSurfaceCount()).
*/
int FnSurfaceList( SurfInfo *S) ;
typedef struct { |
int Id ; // Id |
int DrawInProfile ; // Draw in profiles? |
char Name[32] ; // Name |
int Type ; // Type id |
char Reserved[76] ; // For future development - ignore now |
} SurfInfo ;
/*-------------------------------------------------------------------
Copy name of surface with id I into Str.
Return 1 if id I was valid.
Return 0 if id was invalid.
*/
int FnSurfaceName( char *Str, int I) ;
/*-------------------------------------------------------------------
Return profile color of surface with id I.
Return 0 if id was invalid.
*/
int FnSurfaceColor( int I) ;
/*-------------------------------------------------------------------
Compute bounding cube for surface with id I.
Mn is set to be the minimum x,y,z of the surface model.
Mx is set to be the maximum x,y,z of the surface model.
Return 1 if successful.
Return 0 if failed.
*/
int FnSurfaceMinMax( Dpoint3d *Mn, Dpoint3d *Mx, int I) ;
/*-------------------------------------------------------------------
Calculate elevation Pt->z at location Pt->x,Pt->y from surface
with id I.
The elevation can not be calculated if:
- the surface id is invalid
- the surface is empty
- the point is outside surface
- the point is inside an excluded triangle
Return 1 if successful.
Return 0 if the elevation could not be calculated.
*/
int FnSurfaceZ( Dpoint3d *Pt, int I) ;
/*-------------------------------------------------------------------
Calculate elevation for an array of x,y points from surface
with id I.
Tbl is a pointer to an array of x,y points.
Cnt is the number of points in the array.
The calling application should initialize the z values
of the points to an invalid value such as -999999.
If the elevation of a x,y point can not be calculated,
the z value will remain unchanged.
Return 1 if successful.
Return 0 if the surface is invalid.
*/
int FnSurfaceArrayZ( Dpoint3d *Tbl, int Cnt, int I) ;
/*-------------------------------------------------------------------
Drape an array of points over surface model with id I.
Tbl is a pointer to an array of x,y points.
Cnt is the number of points in the array.
I is the id of the surface model.
After the routine:
*Pnt points to a table of generated points.
*Val points to a table of characters which indicate
what point intervals are valid. Val[0] indicates
if point interval Pnt[0] - Pnt[1] is valid.
Return the number of points generated.
Return 0 if failed.
*/
int FnDrapeArray( Dpoint3d **Pnt, char **Val, const Dpoint3d *Tbl, int Cnt, int I) ;
/*-------------------------------------------------------------------
Free the results from a call to FnDrapeArray().
Pnt points to a table of generated points.
Val points to a table of characters.
Return 0.
*/
int FnDrapeFree( Dpoint3d *Pnt, char *Val) ;
/*-------------------------------------------------------------------
Drape descriptor Dp over surface model with id I.
FileNr is the file number of descriptor Dp.
Method determines what is generated for places where
the original descriptor is outside the surface.
If Method is
0 : Outside part will remain unchanged.
1 : Outside part will be drawn with active symbology.
2 : Outside part will not be drawn, thus resulting in a gap.
Create new descriptor as *Pp (Dp is not changed in the process).
Return 1 if successful.
Return 0 if failed.
*/
int FnDrapeDscr( MSElementDescr **Pp, MSElementDescr *Dp, |
int FileNr, int Method, int I) ; |
/*-------------------------------------------------------------------
Has surface with id I been triangulated?
*/
int FnModelExists( int I) ;
/*-------------------------------------------------------------------
Fill an option button with surface names. This function lets
an external application create an option button for selecting
a surface.
If P == 0, list all surfaces.
If P == 1, list all triangulated surfaces.
*/
int FnSurfaceOption( RawItemHdr *Raw, int P) ;
/*-------------------------------------------------------------------
Fill option button with surface type names.
Return 1 always.
*/
int FnSurfTypeOption( RawHdr *Raw) ;
/*-------------------------------------------------------------------
Create a new empty surface model into which points can be added
using FnAddPoints() or FnInsertPoints().
Type is the surface type as defined in Modeler user settings.
Calling application should use zero (normally ground) or let
the user select type from an option button (use FnSurfTypeOption).
Name is an optional name for the new surface. If Name == NULL,
surface type name is retrieved for the surface model name.
Return ID of the new surface (0,1,...).
Return -1 if failed (out of memory).
*/
int FnCreateSurface( int Type, char *Name) ;
/*-------------------------------------------------------------------
Add random points to surface with id I. This routine can
be used to insert points to an existing surface or to create
a new surface. TerraModeler will always triangulate
the surface during this function.
Tbl points to an array of Cnt points.
Cnt is the number of points in Tbl.
If AskSet is true, ask triangulation settings.
In a result of this call,
Return true if points were inserted.
Return 0 if unsuccessful.
*/
int FnInsertPoints( int I, int AskSet, Dpoint3d *Tbl, int Cnt) ;
/*-------------------------------------------------------------------
Add points of type Type to surface with id I.
TerraModeler will add these points to its point list
but will not immediately triangulate the new points.
This routine can be used to insert points to an existing
surface or to create a new surface.
Tbl points to an array of Cnt points.
Cnt is the number of points in Tbl.
Type is the point type:
1 = random
2 = breakline
3 = contour
10 = external 3D boundary
11 = external 2D boundary
20 = internal 3D boundary
21 = internal 2D boundary
Return true if points were inserted.
Return 0 if unsuccessful.
*/
int FnAddPoints( int I, Dpoint3d *Tbl, int Cnt, int Type) ;
/*-------------------------------------------------------------------
Triangulate surface with id I. The calling application will
typically call this function after calling FnAddPoints()
a number of times.
If AskSet is true, ask triangulation settings.
Return 1 if triangulation was completed.
Return 0 if unsuccessful.
*/
int FnAddDone( int I, int AskSet) ;
/*-------------------------------------------------------------------
Retriangulate surface with id I after calls to FnAddPoints().
Return 1 if triangulation was completed.
Return 0 if unsuccessful.
*/
int FnAddRetriangulate( int I) ;
/*-------------------------------------------------------------------
Add a linear element representing surface elevations to a
profile descriptor. This routine can be called by an
application creating a profile in which surface(s) are
drawn as line string type elements.
This routine uses surface’s profile color and line style
when adding elements to the descriptor.
Dp is descriptor where elements will be added.
L defines the profile settings and the alignment.
Return 1 if drawn.
Return 0 if failed.
Return -1 if no need to draw:
- surface is empty or
- ‘Draw in profile’ setting is off
*/
int FnProfileDscr( MSElementDescr *Dp, FnProf *L) ;
typedef struct {
int SurfId ; // Surface id or -3=all surfaces |
int Lvl ; // Level to draw on |
Dscr *Align ; // 2D alignment |
double AlignLen ; // Length of the alignment |
double ExaggZ ; // Horizontal scale / Vertical |
double RangeStart ; // Elevation range from |
double RangeEnd ; // Elevation range to |
Dpoint3d Org ; // Lower left corner of range |
int Scale ; // Horizontal scale |
} FnProf ;
/*-------------------------------------------------------------------
Find out grid elevation at location Pt->x, Pt->y.
This function searches the lattice database for a grid
file which covers the given location and reads the closest
elevation value.
Return 1 if Pt->z was successfully set.
Return 0 if point was outside grid data files.
Return -1 if no grid files were found.
*/
int FnGridZ( Dpoint3d *Pt) ;
/*-------------------------------------------------------------------
Compute lattice elevation values from surface SurfId.
The calling application should:
1. Fill in values in TinLtc structure
2. If integer (uor) elevation values are needed:
* allocate memory as T->ElevInt (CntX*CntY*sizeof(int))
* initialize every value to an invalid value (such as 0x80000000)
3. If floating point (master unit (m))) elevation values are needed:
* allocate memory as T->ElevInt (CntX*CntY*sizeof(double))
* initialize every value to an invalid value (such as -999999.0)
4. If elevations from excluded triangles are needed:
* allocate memory as T->Valid (CntX*CntY*sizeof(char))
This routine sets only those elevation values for which an elevation
from SurfId can be calculated. Lattice points outside the surface will
not be affected.
If the calling application provider T->Valid as non-NULL, TerraModeler
will calculate elevations from excluded triangles as well and fill
in T->Valid[] to indicate which point are:
0 outside surface
1 inside an excluded triangle
2 inside a valid triangle
Return 1 on success.
Return 0 if SurfId is invalid.
*/
int FnComputeTinLattice( TinLtc *T, int SurfId) ;
typedef struct {
Dpoint3d Org ; // Origin point (lower left) |
double StpX ; // X interval |
double StpY ; // Y interval |
int CntX ; // Column count |
int CntY ; // Row count |
int *ElevInt ; // Elevation as integer values (uor) |
double *ElevDbl ; // Elevation as double values (master units) |
char *Valid ; // Validity information |
} TinLtc ;
/*-------------------------------------------------------------------
Calculate elevation Pt->z at location Pt->x,Pt->y from
a surface of type Type. This routine will loop thru all
surfaces to find one of matching type where location Pt
is valid.
Return 1 if successful.
Return 0 if the elevation could not be calculated.
*/
int FnSurfaceTypeZ( Dpoint3d *P, int Type) ;
/*-------------------------------------------------------------------
Compute elevation for each P->x,P->y point in table Tbl.
Use first triangulated surface of type Type to compute
the elevations.
Tbl is a pointer to an array of x,y points.
Cnt is the number of points in the array.
The calling application should initialize the z values
of the points to an invalid value such as -999999.
If the elevation of a x,y point can not be calculated,
the z value will remain unchanged.
Return 1 if a surface of Type exists.
Return 0 if no surface.
*/
int FnSurfTypeArrayZ( Dpoint3d *Tbl, int Cnt, int Type) ;
/*-------------------------------------------------------------------
Open window for specifying how to display surfaces in profiles.
Return 0 always.
*/
int FnAskProfSurfaces( void) ;
/*-------------------------------------------------------------------
Compute slope end points starting from master alignment points
Vrt[] using normal direction as defined by Nrm[].x and Nrm[].y.
Find solution from first surface of type Typ where Prj[] is
valid.
Make sure slope end points are at least Dst from master points.
Store end points in Vrt[]. If slope can not be computed, compute
vertex by offseting master point by at least Dst.
Return number of successfully computed points.
Return -1 if no surface of type Typ.
*/
int FnSlopeVertices( Dp3d *Vrt, Dp3d *Nrm, int Cnt, double Rup, |
double Rdn, int Type, double Dst) ; |
/*-------------------------------------------------------------------
Display shaded surface of surface Idv in views Vwb.
Vwb specifies views as a bit mask (bit 0 for view 1, ...).
This routine does not update views.
Return 1 on success.
Return 0 if failed (I out of range).
*/
int FnDisplayShaded( int Idv, int Vwb) ;
/*-------------------------------------------------------------------
Display contours for surface with id SurfId.
Ap points to contour action settings.
Sp points to contour settings. Sp may be NULL.
Lp points to label settings. Lp may be NULL.
Tp points to tick settings. Tp may be NULL.
Return 1 on success.
Return 0 if failed (no surface or invalid Ap).
*/
int FnDisplayContours( int SurfId, ContAct *Ap, ContSet *Sp, ContLbl *Lp, ContTck *Tp);
// Contour action for FnDisplayContours()
typedef struct {
int Mode ; // 0=display only, 1=write to file, 2=preview |
int Type ; // 0=curves, 1=line strings, 2=soft line strings |
int DrawTicks ; // Draw contour ticks? |
int DrawLabels; // Draw contour labels? |
int Draw1 ; // Draw minor contours? |
int Draw2 ; // Draw basic contours? |
int Draw3 ; // Draw major contours? |
int Reserved1 ; |
double Every1 ; // Minor contour interval (master unit) |
double Every3 ; // Major contour interval (master unit) |
char Reserved2[80]; |
} ContAct ;
// Contour settings for FnDisplayContours()
typedef struct {
int ColorBy ; // Color by 0=contour type, 1=elevation |
int Lvl1 ; // Minor contour level |
int Lvl2 ; // Basic contour level |
int Lvl3 ; // Major contour level |
int Clr1 ; // Minor contour color 0-255 |
int Clr2 ; // Basic contour color 0-255 |
int Clr3 ; // Major contour color 0-255 |
int Sty1 ; // Minor contour style |
int Sty2 ; // Basic contour style |
int Sty3 ; // Major contour style |
int Wgt1 ; // Minor contour weight |
int Wgt2 ; // Basic contour weight |
int Wgt3 ; // Major contour weight |
int Reserved1 ; |
int ClrCnt ; // Number of scheme colors |
int Clrs[127] ; // Scheme colors max 127 |
long ClrElev[128] ; // Color elevations |
char ClrFix[128] ; // Fixed flags for elevations |
int Domains ; // 0=all domains, 1=only selected domains |
int ElevLimit ; // 0=all elevations, 1=only ElevMin-ElevMax |
double ElevMin ; // - lowest elevation to draw |
double ElevMax ; // - highest elevation to draw |
int Smoothing ; // Smoothen contours? |
int AreaSkip ; // Skip small closed contours? |
double AreaMin ; // - min area (sq master units) |
int Complex ; // Build complex chains? |
int Thin ; // Thin contours? |
double ThinDst ; // - distance (master units) |
double ThinDev ; // - deviation (master units) |
double ThinAng ; // - turn angle (degrees) |
char Reserved2[80] ; |
} ContSet ;
// Contour label settings for FnDisplayContours()
typedef struct {
int LabelsOn ; // 0=major, 1=major&basic, 2=all |
int Pos ; // 0=above, 1=on, 2=below, 3=start point |
int UpHill ; // 0=label downhill, 1=uphill |
int Cut ; // Cut underlying contour? (if Pos == 1) |
double Every ; // Label interval (master units) |
int Sty ; // Style |
int Wgt ; // Weight |
int OwnSymb ; // 0=contour level+color, 1=own level+color |
int Lvl ; // - own level |
int Clr ; // - own color |
char Prefix[12]; // Prefix text |
char Suffix[12]; // Suffix text |
int Decim ; // Number of decimals 0,1,2 or 3 |
int Plus ; // Display plus? |
int Minus ; // Display minus? |
char Reserved1[80] ; |
} ContLbl ;
// Contour tick settings for FnDisplayContours()
typedef struct {
double Every ; // Tick interval (master unit) |
int OnlyDepr ; // Only depressions? |
int Triangle ; // 0=draw line, 1=draw triangle |
int MaxUse ; // 0=all, 1=only closed contours < MaxArea |
double Length ; // Symbol length (master unit) |
double MaxArea ; // Maximum area (sq master unit) |
} ContTck ;