MCPcopy Create free account
hub / github.com/SimVascular/SimVascular / MeshUtils_remesh

Function MeshUtils_remesh

Code/Source/PythonAPI/MeshUtils_PyModule.cxx:119–185  ·  view source on GitHub ↗

------------ MMG_remesh ------------

Source from the content-addressed store, hash-verified

117//------------
118//
119static PyObject *
120MeshUtils_remesh(PyObject* self, PyObject* args, PyObject* kwargs)
121{
122 auto api = PyUtilApiFunction("O|ddddds", PyRunTimeErr, __func__);
123 static char *keywords[] = {"surface", "hmin", "hmax", "angle", "hgrad", "hausd", "log_file", NULL};
124 PyObject* surfaceArg;
125 double hmin = 0.1;
126 double hmax = 0.1;
127 double angle = 45.0;
128 double hgrad = 1.1;
129 double hausd = 0.01;
130 char *logFileName = nullptr;
131
132 if (!PyArg_ParseTupleAndKeywords(args, kwargs, api.format, keywords, &surfaceArg, &hmin, &hmax, &angle,
133 &hgrad, &hausd, &logFileName)) {
134 return api.argsError();
135 }
136
137 // Redirect stdout to the 'mesh.log' file.
138 //
139 // [TODO:DaveP] this does not work for mmg or doesn't work on ubunutu?
140 //
141 // [TODO:DaveP] put this in py utils as a class.
142 //
143/*
144 if (logFileName == nullptr) {
145 logFileName = "/dev/null";
146 }
147 int stdout_dupe = dup(fileno(stdout));
148 freopen(logFileName, "w", stdout);
149*/
150
151 // Get the vtkPolyData objectsfrom the Python object.
152 //
153 auto surfPolydata = GetVtkPolyData(api, surfaceArg);
154 if (surfPolydata == nullptr) {
155 return nullptr;
156 }
157 //cvPolyData cvSurfPolydata(surfPolydata);
158 surfPolydata->BuildLinks();
159
160 // Remesh the entire surface polydata.
161 //
162 int useSizingFunction = 0;
163 int numAddedRefines = 0;
164 vtkDoubleArray *meshSizingFunction = NULL;
165
166 if (MMGUtils_SurfaceRemeshing(surfPolydata, hmin, hmax, hausd, angle, hgrad, useSizingFunction, meshSizingFunction,
167 numAddedRefines) != SV_OK) {
168 api.error("Remeshing failed.");
169 return nullptr;
170 }
171
172 auto result = new cvPolyData(surfPolydata);
173 if (result == NULL) {
174 api.error("Error creating polydata from the remeshed object.");
175 return nullptr;
176 }

Callers

nothing calls this directly

Calls 5

argsErrorMethod · 0.80
errorMethod · 0.80
GetVtkPolyDataFunction · 0.70
GetVtkPolyDataMethod · 0.45

Tested by

no test coverage detected