41 #include "glimports.h"
43 #include "sampledLine.h"
45 void sampledLine::setPoint(Int i, Real p[2])
59 void sampledLine::deleteList()
62 for(temp =
this; temp != NULL; temp = tempNext)
64 tempNext = temp->next;
71 sampledLine::sampledLine(Int n_points)
74 points = (Real2*) malloc(
sizeof(Real2) * n_points);
82 sampledLine::sampledLine(Int n_points, Real2 pts[])
86 points = (Real2*) malloc(
sizeof(Real2) * n_points);
88 for(i=0; i<npoints; i++) {
89 points[i][0] = pts[i][0];
90 points[i][1] = pts[i][1];
95 sampledLine::sampledLine(Real pt1[2], Real pt2[2])
98 points = (Real2*) malloc(
sizeof(Real2) * 2);
100 points[0][0] = pt1[0];
101 points[0][1] = pt1[1];
102 points[1][0] = pt2[0];
103 points[1][1] = pt2[1];
108 sampledLine::sampledLine()
113 void sampledLine::init(Int n_points, Real2 *pts)
121 sampledLine::~sampledLine()
126 void sampledLine::print()
129 printf(
"npoints=%i\n", npoints);
131 for(i=0; i<npoints; i++){
132 printf(
"(%f,%f)\n", points[i][0], points[i][1]);
137 void sampledLine::tessellate(Real u_reso, Real v_reso)
142 nu = 1+(Int) (fabs((points[npoints-1][0] - points[0][0])) * u_reso);
143 nv = 1+(Int) (fabs((points[npoints-1][1] - points[0][1])) * v_reso);
151 Real du = (points[npoints-1][0] - points[0][0])/n;
152 Real dv = (points[npoints-1][1] - points[0][1])/n;
153 Real2 *temp = (Real2*) malloc(
sizeof(Real2) * (n+1));
157 for(i=0, u=points[0][0], v=points[0][1]; i<n; i++, u+=du, v+=dv)
162 temp[n][0] = points[npoints-1][0];
163 temp[n][1] = points[npoints-1][1];
172 void sampledLine::tessellateAll(Real u_reso, Real v_reso)
175 for(temp =
this; temp != NULL; temp = temp->next)
177 temp->tessellate(u_reso, v_reso);