home *** CD-ROM | disk | FTP | other *** search
- /* LINKFEATS: contains functions for creating and adding to linked list
- * of WW features
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include "pcc2.h"
- #include <images.h>
-
- extern struct featNode *featHead, /* linked list of features for */
- *featTail; /* beginning and current list pos */
- extern long nFeats; /* number of ww features */
-
- int featadd (int, char *, struct dpoint);
- int insertendfeat (struct featNode **, struct point);
-
- /* LINKCORNER: */
-
- int
- linkcorner (type, coord)
- int type;
- struct point coord;
- {
- struct featK *featK;
- struct dpoint intrsct; /* corner intersection */
-
- featK = (struct featK *) malloc (sizeof (struct featK));
- featK->coord = coord;
- intrsct.x = (double) coord.x;
- intrsct.y = (double) coord.y;
- featadd (type, (char *) featK, intrsct); /*, CURVELT180); */
-
- return (0);
- }
-
- /* LINKCURVE: */
-
- int
- linkcurve (intrsct, trans1, trans2, center, radiusC, curveDirn)
- struct dpoint intrsct; /* intersection of tangents to curve */
- struct point trans1, trans2; /* transition pts from lines to curve */
- struct dpoint center; /* center of curvature */
- double radiusC; /* radius of curvature */
- short curveDirn; /* direction of curve */
- {
- struct featC *featC;
-
- featC = (struct featC *) malloc (sizeof (struct featC));
- featC->trans1 = trans1;
- featC->trans2 = trans2;
- featC->center = center;
- featC->radiusC = radiusC;
- featC->dirn = curveDirn;
- featadd (WWCURVE, (char *) featC, intrsct);
-
- return (0);
- }
-
-
-
- /* FEATADD: */
-
- int
- featadd (type, info, intrsct)
- int type;
- char *info;
- struct dpoint intrsct; /* corner, or tangent intersection */
- {
- struct featNode *featNew;
-
- nFeats++;
- featNew = (struct featNode *) malloc (sizeof (struct featNode));
- featNew->type = type;
- featNew->intrsct = intrsct;
- featNew->info = info;
- featNew->next = NULL;
- if (featHead == NULL) {
- featNew->previous = NULL;
- featHead = featTail = featNew;
- }
- else {
- featNew->previous = featTail;
- featTail->next = featNew;
- featTail = featNew;
- }
-
- return (0);
- }
-
-
- /* INSERTENDFEAT: */
-
- int
- insertendfeat (featEnd, endPt)
- struct featNode **featEnd; /* ptr to end feature ptr */
- struct point endPt; /* new end point */
- {
- struct featNode *featNew; /* ptr to new feature */
- struct dpoint intrsct; /* (double) of <endPt> */
- struct featK *featK; /* information for new end feature */
-
- nFeats++;
- featNew = (struct featNode *) malloc (sizeof (struct featNode));
- featNew->type = (*featEnd)->type;
- intrsct.x = (double) endPt.x;
- intrsct.y = (double) endPt.y;
- featNew->intrsct = intrsct;
- featK = (struct featK *) malloc (sizeof (struct featK));
- featK->coord = endPt;
- featNew->info = (char *) featK;
-
- if (featNew->type == WWSTRT) { /* start feature type */
- featNew->previous = (*featEnd)->previous;
- featNew->next = (*featEnd);
- if ((*featEnd)->previous != NULL)
- ((*featEnd)->previous)->next = featNew;
- (*featEnd)->previous = featNew;
- (*featEnd)->type = WWCORNER;
- if ((*featEnd) == featHead)
- featHead = featNew;
- }
- else { /* end feature type */
- featNew->previous = (*featEnd);
- featNew->next = (*featEnd)->next;
- if ((*featEnd)->next != NULL)
- ((*featEnd)->next)->previous = featNew;
- (*featEnd)->next = featNew;
- (*featEnd)->type = WWCORNER;
- }
-
- (*featEnd) = featNew;
-
- return (0);
- }
-