51 int mapVertex(::
List<int>& collapse_map,
int a,
int mx)
66 int main(
int argc,
char *argv[])
79 if (reduction <= 0 || reduction > 1)
82 <<
"Reduction factor " << reduction
83 <<
" should be within 0..1" <<
endl
84 <<
"(it is the reduction in number of vertices)"
88 Info<<
nl <<
"Input surface : " << inFileName
89 <<
nl <<
"Reduction factor : " << reduction
90 <<
nl <<
"Output surface : " << outFileName <<
nl <<
endl;
95 surf.writeStats(
Info);
106 const point& pt = pts[ptI];
121 ::ProgressiveMesh(
vertices, triangles, collapse_map, permutation);
125 for (
int i = 0; i <
vertices.num; i ++)
129 for (
int i = 0; i <
vertices.num; i ++)
131 vertices[permutation[i]] = temp_list[i];
135 for (
int i=0; i < triangles.num; i++)
137 for (
int j=0;j<3;j++)
139 triangles[i].v[j] = permutation[triangles[i].v[j]];
144 int render_num = int(reduction * surf.nPoints());
146 Info<<
"Reducing to " << render_num <<
" vertices" <<
endl <<
endl;
150 label newTrianglei = 0;
151 for (
int i = 0; i < triangles.num; i ++)
153 int p0 = mapVertex(collapse_map, triangles[i].v[0], render_num);
154 int p1 = mapVertex(collapse_map, triangles[i].v[1], render_num);
155 int p2 = mapVertex(collapse_map, triangles[i].v[2], render_num);
157 if (p0 == p1 || p1 == p2 || p2 == p0)
continue;
159 newTriangles[newTrianglei++] =
labelledTri(p0, p1, p2, 0);
161 newTriangles.setSize(newTrianglei);
165 for (
int i = 0; i <
vertices.num; i ++)
174 newSurf =
triSurface(newSurf.localFaces(), newSurf.localPoints());
177 newSurf.writeStats(
Info);
180 Info<<
"Writing to file " << outFileName <<
endl <<
endl;
182 newSurf.
write(outFileName);
#define forAll(list, i)
Loop across all elements in list.
virtual Ostream & write(const token &)
Write token.
Extract command arguments and options from the supplied argc and argv parameters.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
T argRead(const label index) const
Read a value from the argument at index.
A class for handling file names.
Triangle with additional region number.
Triangulated surface description with patch information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
errorManipArg< error, int > exit(error &err, const int errNo=1)
pointField vertices(const blockVertexList &bvl)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
vector point
Point is a vector.
Foam::argList args(argc, argv)