54 #include "progmesh.hxx" 60 int mapVertex(::
List<int>& collapse_map,
int a,
int mx)
75 int main(
int argc,
char *argv[])
79 "Surface coarsening using 'bunnylod'" 90 "Input geometry scaling factor" 96 const auto reduction =
args.
get<scalar>(2);
99 if (reduction <= 0 || reduction > 1)
102 <<
"Reduction factor " << reduction
103 <<
" should be within 0..1" <<
endl 104 <<
"(it is the reduction in number of vertices)" 110 Info<<
"Input surface :" << inFileName <<
nl 111 <<
"Scaling factor :" << scaleFactor <<
nl 112 <<
"Reduction factor:" << reduction <<
nl 113 <<
"Output surface :" << outFileName <<
nl 116 const triSurface surf(inFileName, scaleFactor);
119 surf.writeStats(
Info);
132 vert.Add(::
Vector(pt.x(), pt.y(), pt.z()));
147 ::ProgressiveMesh(vert,tri,collapse_map,permutation);
151 for (
int i=0; i<vert.num; i++)
153 temp_list.Add(vert[i]);
155 for (
int i=0; i<vert.num; i++)
157 vert[permutation[i]] = temp_list[i];
161 for (
int i=0; i<tri.num; i++)
163 for (
int j=0; j<3; j++)
165 tri[i].v[j] = permutation[tri[i].v[j]];
170 int render_num = int(reduction * surf.nPoints());
172 Info<<
"Reducing to " << render_num <<
" vertices" <<
endl;
180 for (
int i=0; i<tri.num; i++)
182 int p0 = mapVertex(collapse_map, tri[i].v[0], render_num);
183 int p1 = mapVertex(collapse_map, tri[i].v[1], render_num);
184 int p2 = mapVertex(collapse_map, tri[i].v[2], render_num);
189 if (
p0 == p1 || p1 == p2 || p2 ==
p0)
196 newTris.setSize(newI);
201 for (
int i=0; i<vert.num; i++)
203 const ::Vector & v = vert[i];
205 newPoints[i] =
point(v.x, v.y, v.z);
217 Info<<
"Coarsened surface:" <<
endl;
218 surf2.writeStats(
Info);
221 Info<<
"Writing to file " << outFileName <<
endl <<
endl;
223 surf2.
write(outFileName);
static void addNote(const string ¬e)
Add extra notes for the usage information.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void noParallel()
Remove the parallel options.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
Extract command arguments and options from the supplied argc and argv parameters. ...
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A triFace with additional (region) index.
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross-product operators.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
vector point
Point is a vector.
T get(const label index) const
Get a value from the argument at index.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Triangulated surface description with patch information.
Foam::argList args(argc, argv)
const volScalarField & p0