71 #include "bunnylod/progmesh.h"
77 int mapVertex(::
List<int>& collapse_map,
int a,
int mx)
93 int main(
int argc,
char *argv[])
106 if (reduction <= 0 || reduction > 1)
109 <<
"Reduction factor " << reduction
110 <<
" should be within 0..1" <<
endl
111 <<
"(it is the reduction in number of vertices)"
117 Info<<
"Input surface :" << inFileName <<
endl
118 <<
"Reduction factor:" << reduction <<
endl
119 <<
"Output surface :" << outFileName <<
endl <<
endl;
124 surf.writeStats(
Info);
138 const point& pt = pts[ptI];
140 vert.Add( ::
Vector(pt.
x(), pt.
y(), pt.
z()));
157 ::ProgressiveMesh(vert,tri,collapse_map,permutation);
161 for(
int i=0;i<vert.num;i++)
163 temp_list.Add(vert[i]);
165 for(
int i=0;i<vert.num;i++)
167 vert[permutation[i]]=temp_list[i];
171 for(
int i=0;i<tri.num;i++)
175 tri[i].v[j] = permutation[tri[i].v[j]];
180 int render_num = int(reduction * surf.nPoints());
182 Info<<
"Reducing to " << render_num <<
" vertices" <<
endl;
190 for (
int i=0; i<tri.num; i++)
192 int p0 = mapVertex(collapse_map, tri[i].v[0], render_num);
193 int p1 = mapVertex(collapse_map, tri[i].v[1], render_num);
194 int p2 = mapVertex(collapse_map, tri[i].v[2], render_num);
199 if (p0 == p1 || p1 == p2 || p2 == p0)
206 newTris.setSize(newI);
211 for(
int i=0; i<vert.num; i++)
213 const ::Vector & v = vert[i];
215 newPoints[i] =
point(v.x, v.y, v.z);
227 Info<<
"Coarsened surface:" <<
endl;
228 surf2.writeStats(
Info);
231 Info<<
"Writing to file " << outFileName << endl <<
endl;
233 surf2.
write(outFileName);