solvespace/polygon.h
Jonathan Westhues a7cec38656 Add code to assemble the piecewise linear segments in a group into
a polygon, and to fill that polygon.

[git-p4: depot-paths = "//depot/solvespace/": change = 1686]
2008-04-24 23:04:09 -08:00

76 lines
1.1 KiB
C++

#ifndef __POLYGON_H
#define __POLYGON_H
class SPolygon;
template <class T>
class SList {
public:
T *elem;
int n;
int elemsAllocated;
void Add(T *t) {
if(n >= elemsAllocated) {
elemsAllocated = (elemsAllocated + 32)*2;
elem = (T *)MemRealloc(elem, elemsAllocated*sizeof(elem[0]));
}
elem[n++] = *t;
}
void ClearTags(void) {
int i;
for(i = 0; i < n; i++) {
elem[i].tag = 0;
}
}
void Clear(void) {
if(elem) MemFree(elem);
elem = NULL;
n = elemsAllocated = 0;
}
};
class SEdge {
public:
int tag;
Vector a, b;
};
class SEdgeList {
public:
SList<SEdge> l;
bool AssemblePolygon(SPolygon *dest, SEdge *errorAt);
};
class SPoint {
public:
int tag;
Vector p;
};
class SContour {
public:
SList<SPoint> l;
};
class SPolygon {
public:
SList<SContour> l;
void AddEmptyContour(void);
void AddPoint(Vector p);
void Clear(void);
};
class SPolyhedron {
SList<SPolygon> l;
public:
};
#endif