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<<
"Input surface :" << inFileName <<
endl
89 <<
"Reduction factor:" << reduction <<
endl
90 <<
"Output surface :" << outFileName <<
endl <<
endl;
95 surf.writeStats(
Info);
109 const point& pt = pts[ptI];
111 vert.Add( ::
Vector(pt.
x(), pt.
y(), pt.
z()));
128 ::ProgressiveMesh(vert,tri,collapse_map,permutation);
132 for (
int i=0;i<vert.num;i++)
134 temp_list.Add(vert[i]);
136 for (
int i=0;i<vert.num;i++)
138 vert[permutation[i]]=temp_list[i];
142 for (
int i=0;i<tri.num;i++)
144 for (
int j=0;j<3;j++)
146 tri[i].v[j] = permutation[tri[i].v[j]];
151 int render_num = int(reduction * surf.nPoints());
153 Info<<
"Reducing to " << render_num <<
" vertices" <<
endl;
161 for (
int i=0; i<tri.num; i++)
163 int p0 = mapVertex(collapse_map, tri[i].v[0], render_num);
164 int p1 = mapVertex(collapse_map, tri[i].v[1], render_num);
165 int p2 = mapVertex(collapse_map, tri[i].v[2], render_num);
170 if (p0 == p1 || p1 == p2 || p2 == p0)
177 newTris.setSize(newI);
182 for (
int i=0; i<vert.num; i++)
184 const ::Vector & v = vert[i];
186 newPoints[i] =
point(v.x, v.y, v.z);
198 Info<<
"Coarsened surface:" <<
endl;
199 surf2.writeStats(
Info);
202 Info<<
"Writing to file " << outFileName <<
endl <<
endl;
204 surf2.
write(outFileName);
#define forAll(list, i)
Loop across all elements in list.
virtual Ostream & write(const char)=0
Write character.
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)
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.
vector point
Point is a vector.
Foam::argList args(argc, argv)