47 double trArea(
const Pt3d& a_pt1,
const Pt3d& a_pt2,
const Pt3d& a_pt3)
49 return (((a_pt2.x - a_pt1.x) * (a_pt3.y - a_pt1.y)) -
50 ((a_pt3.x - a_pt1.x) * (a_pt2.y - a_pt1.y))) *
73 void trBuildGridTrianglePolys(
int rows,
int cols,
VecPt3d& a_points,
VecInt2d& a_polys)
75 trBuildGridPolys(rows, cols, a_points, a_polys);
80 for (
size_t i = 0; i < a_polys.size(); ++i)
84 size_t numPts = poly.size();
86 for (
size_t j = 0; j < numPts; ++j)
88 pts.push_back(a_points[poly[j]]);
90 Pt3d centroid = gmComputeCentroid(pts);
91 points.push_back(centroid);
95 int firstCellCenter = (int)a_points.size();
98 for (
size_t cellIdx = 0; cellIdx < a_polys.size(); ++cellIdx)
101 VecInt& poly = a_polys[cellIdx];
102 size_t numPts = poly.size();
103 for (
size_t pt = 0; pt < numPts; ++pt)
105 newPoly[0] = poly[pt];
106 newPoly[1] = poly[(pt + 1) % numPts];
107 newPoly[2] = firstCellCenter + (int)cellIdx;
108 trianglePolys.push_back(newPoly);
113 a_polys = trianglePolys;
133 void trBuildGridPolys(
int rows,
int cols,
VecPt3d& pts,
VecInt2d& polys)
136 for (
int i = 0; i <= rows; ++i)
138 for (
int j = 0; j <= cols; ++j)
140 pts.push_back(
Pt3d(j * 10.0, -i * 10.0, 0.0));
144 polys.assign(rows * cols,
VecInt());
147 int nodeNextRow = cols + 1;
148 for (
int i = 0; i < rows; ++i)
150 for (
int j = 0; j < cols; ++j)
152 VecInt& poly = polys[count++];
153 poly.push_back(node++);
154 poly.push_back(nodeNextRow++);
155 poly.push_back(nodeNextRow);
156 poly.push_back(node);
Functions dealing with triangles.
std::vector< int > VecInt
Functions dealing with geometry.
std::vector< Pt3d > VecPt3d
std::vector< VecInt > VecInt2d