ViennaLS
Loading...
Searching...
No Matches
pyWrap.hpp
Go to the documentation of this file.
1#include <pybind11/functional.h>
2#include <pybind11/iostream.h>
3#include <pybind11/pybind11.h>
4#include <pybind11/stl.h>
5
6// all header files which define API functions
7#include <lsAdvect.hpp>
12#include <lsCheck.hpp>
13#include <lsCompareChamfer.hpp>
17#include <lsCompareVolume.hpp>
18#include <lsConvexHull.hpp>
19#include <lsDetectFeatures.hpp>
20#include <lsDomain.hpp>
21#include <lsExpand.hpp>
22#include <lsExtrude.hpp>
23#include <lsFileFormats.hpp>
24#include <lsFromMesh.hpp>
25#include <lsFromSurfaceMesh.hpp>
26#include <lsFromVolumeMesh.hpp>
27#include <lsGeometricAdvect.hpp>
29#include <lsGeometries.hpp>
30#include <lsMakeGeometry.hpp>
31#include <lsMarkVoidPoints.hpp>
32#include <lsMaterialMap.hpp>
33#include <lsMesh.hpp>
34#include <lsPointData.hpp>
35#include <lsPrune.hpp>
36#include <lsReader.hpp>
37#include <lsReduce.hpp>
39#include <lsSlice.hpp>
40#include <lsToDiskMesh.hpp>
41#include <lsToHullMesh.hpp>
42#include <lsToMesh.hpp>
44#include <lsToSurfaceMesh.hpp>
45#include <lsToVoxelMesh.hpp>
46#include <lsTransformMesh.hpp>
47#include <lsVTKReader.hpp>
48#include <lsVTKRenderWindow.hpp>
49#include <lsVTKWriter.hpp>
50#include <lsVelocityField.hpp>
51#include <lsVersion.hpp>
53#include <lsWriter.hpp>
54
55#include <vcLogger.hpp>
56#include <vcSmartPointer.hpp>
57
58using namespace viennals;
59namespace py = pybind11;
60
61// always use double for python export
62typedef double T;
63
64PYBIND11_DECLARE_HOLDER_TYPE(TemplateType, SmartPointer<TemplateType>);
65
66// GeometricAdvectDistribution
67template <int D>
69 : public GeometricAdvectDistribution<T, D> {
70 typedef std::array<viennahrle::CoordType, 3> vectorType;
71 typedef std::array<viennahrle::CoordType, 6> boundsType;
72 typedef GeometricAdvectDistribution<T, D> ClassType;
74
75public:
76 bool isInside(const vectorType &initial, const vectorType &candidate,
77 double eps = 0.) const override {
78 PYBIND11_OVERLOAD(bool, ClassType, isInside, initial, candidate, eps);
79 }
80
81 T getSignedDistance(const vectorType &initial, const vectorType &candidate,
82 unsigned long initialPointId) const override {
83 PYBIND11_OVERLOAD_PURE(T, ClassType, getSignedDistance, initial, candidate,
84 initialPointId);
85 }
86
87 boundsType getBounds() const override {
88 PYBIND11_OVERLOAD_PURE(boundsType, ClassType, getBounds);
89 }
90};
91
92template <int D> void bindApi(py::module &module) {
93 // Also wrap hrleGrid so it can be used to create new LevelSets
94 py::class_<viennahrle::Grid<D>>(module, "hrleGrid");
95
96 // Domain
97 py::class_<Domain<T, D>, SmartPointer<Domain<T, D>>>(module, "Domain")
98 // constructors
99 .def(py::init(&SmartPointer<Domain<T, D>>::template New<>))
100 .def(
101 py::init(
102 &SmartPointer<Domain<T, D>>::template New<viennahrle::CoordType>),
103 py::arg("gridDelta") = 1.0)
104 // .def(py::init(
105 // &SmartPointer<Domain<T, D>>::New<viennahrle::CoordType *,
106 // BoundaryConditionEnum *>))
107 .def(py::init([](std::array<viennahrle::CoordType, 2 * D> bounds,
108 std::array<BoundaryConditionEnum, D> bcs,
109 viennahrle::CoordType gridDelta) {
110 return SmartPointer<Domain<T, D>>::New(bounds.data(), bcs.data(),
111 gridDelta);
112 }),
113 py::arg("bounds"), py::arg("boundaryConditions"),
114 py::arg("gridDelta") = 1.0)
115 .def(py::init(&SmartPointer<Domain<T, D>>::template New<
116 std::vector<viennahrle::CoordType>, std::vector<unsigned>,
117 viennahrle::CoordType>),
118 py::arg("bounds"), py::arg("boundaryConditions"),
119 py::arg("gridDelta") = 1.0)
120 // .def(py::init(
121 // &SmartPointer<Domain<T, D>>::New<Domain<T,
122 // D>::PointValueVectorType,
123 // viennahrle::CoordType *,
124 // BoundaryConditionEnum *>))
125 // .def(py::init(&SmartPointer<Domain<T, D>>::New<
126 // Domain<T, D>::PointValueVectorType,
127 // viennahrle::CoordType
128 // *, BoundaryConditionEnum *,
129 // viennahrle::CoordType>))
130 .def(py::init(&SmartPointer<Domain<T, D>>::template New<
131 SmartPointer<Domain<T, D>> &>))
132 .def(py::init(
133 &SmartPointer<Domain<T, D>>::template New<viennahrle::Grid<D> &>))
134 // methods
135 .def("deepCopy", &Domain<T, D>::deepCopy,
136 "Copy lsDomain in this lsDomain.")
137 .def("getNumberOfSegments", &Domain<T, D>::getNumberOfSegments,
138 "Get the number of segments, the level set structure is divided "
139 "into.")
140 .def("getNumberOfPoints", &Domain<T, D>::getNumberOfPoints,
141 "Get the number of defined level set values.")
142 .def("getLevelSetWidth", &Domain<T, D>::getLevelSetWidth,
143 "Get the number of layers of level set points around the explicit "
144 "surface.")
145 .def("setLevelSetWidth", &Domain<T, D>::setLevelSetWidth,
146 "Set the number of layers of level set points which should be "
147 "stored around the explicit surface.")
148 .def("clearMetaData", &Domain<T, D>::clearMetaData,
149 "Clear all metadata stored in the level set.")
150 // allow filehandle to be passed and default to python standard output
151 .def(
152 "print",
153 [](Domain<T, D> &d, py::object fileHandle) {
154 if (!(py::hasattr(fileHandle, "write") &&
155 py::hasattr(fileHandle, "flush"))) {
156 throw py::type_error(
157 "MyClass::read_from_file_like_object(file): incompatible "
158 "function argument: `file` must be a file-like object, but "
159 "`" +
160 (std::string)(py::repr(fileHandle)) + "` provided");
161 }
162 py::detail::pythonbuf buf(fileHandle);
163 std::ostream stream(&buf);
164 d.print(stream);
165 },
166 py::arg("stream") = py::module::import("sys").attr("stdout"));
167
168 // Advect
169 py::class_<Advect<T, D>, SmartPointer<Advect<T, D>>>(module, "Advect")
170 // constructors
171 .def(py::init(&SmartPointer<Advect<T, D>>::template New<>))
172 .def(py::init(&SmartPointer<Advect<T, D>>::template New<
173 SmartPointer<Domain<T, D>> &>))
174 .def(py::init(
175 &SmartPointer<Advect<T, D>>::template New<
176 SmartPointer<Domain<T, D>> &, SmartPointer<VelocityField<T>> &>))
177 // getters and setters
178 .def("insertNextLevelSet", &Advect<T, D>::insertNextLevelSet,
179 "Insert next level set to use for advection.")
180 .def("clearLevelSets", &Advect<T, D>::clearLevelSets,
181 "Clear all level sets used for advection.")
182 .def("setVelocityField", &Advect<T, D>::setVelocityField,
183 "Set the velocity to use for advection.")
184 .def("setAdvectionTime", &Advect<T, D>::setAdvectionTime,
185 "Set the time until when the level set should be advected.")
186 .def("setSingleStep", &Advect<T, D>::setSingleStep, py::arg("singleStep"),
187 "Set whether only a single advection step should be performed.")
188 .def("setTimeStepRatio", &Advect<T, D>::setTimeStepRatio,
189 "Set the maximum time step size relative to grid size. Advection is "
190 "only stable for <0.5.")
191 .def("setCalculateNormalVectors",
193 "Set whether normal vectors are needed for the supplied velocity "
194 "field.")
195 .def("setIgnoreVoids", &Advect<T, D>::setIgnoreVoids,
196 "Set whether voids in the geometry should be ignored during "
197 "advection or not.")
198 .def("setAdaptiveTimeStepping", &Advect<T, D>::setAdaptiveTimeStepping,
199 py::arg("enabled") = true, py::arg("subdivisions") = 20,
200 "Enable/disable adaptive time stepping and set the number of "
201 "subdivisions.")
202 .def(
203 "setSaveAdvectionVelocities",
205 "Set whether the velocities applied to each point should be saved in "
206 "the level set for debug purposes.")
207 .def("setCheckDissipation", &Advect<T, D>::setCheckDissipation,
208 py::arg("check"), "Enable/disable dissipation checking.")
209 .def("setUpdatePointData", &Advect<T, D>::setUpdatePointData,
210 py::arg("update"),
211 "Enable/disable updating point data after advection.")
212 .def("getAdvectedTime", &Advect<T, D>::getAdvectedTime,
213 "Get the time passed during advection.")
214 .def("getNumberOfTimeSteps", &Advect<T, D>::getNumberOfTimeSteps,
215 "Get how many advection steps were performed after the last apply() "
216 "call.")
217 .def("getTimeStepRatio", &Advect<T, D>::getTimeStepRatio,
218 "Get the time step ratio used for advection.")
219 .def("getCurrentTimeStep", &Advect<T, D>::getCurrentTimeStep,
220 "Get the current time step.")
221 .def("getCalculateNormalVectors",
223 "Get whether normal vectors are computed during advection.")
224 .def("setSpatialScheme", &Advect<T, D>::setSpatialScheme,
225 "Set the spatial discretization scheme to use during advection.")
226 .def("setTemporalScheme", &Advect<T, D>::setTemporalScheme,
227 "Set the time integration scheme to use during advection.")
228 .def("setIntegrationScheme", &Advect<T, D>::setIntegrationScheme,
229 "(DEPRECATED, use setSpatialScheme instead) Set the spatial "
230 "discretization scheme to use during advection.")
231 .def("setDissipationAlpha", &Advect<T, D>::setDissipationAlpha,
232 "Set the dissipation value to use for Lax Friedrichs spatial "
233 "discretization.")
234 .def("setUpdatePointData", &Advect<T, D>::setUpdatePointData,
235 "Set whether the point data in the old LS should be translated to "
236 "the advected LS. Defaults to true.")
237 .def(
238 "setVelocityUpdateCallback", &Advect<T, D>::setVelocityUpdateCallback,
239 "Set a callback function that is called after the level set has been "
240 "updated during intermediate time integration steps (e.g. RK2, RK3).")
241 .def("prepareLS", &Advect<T, D>::prepareLS, "Prepare the level-set.")
242 // need scoped release since we are calling a python method from
243 // parallelised C++ code here
244 .def("apply", &Advect<T, D>::apply,
245 py::call_guard<py::gil_scoped_release>(), "Perform advection.");
246
247 py::class_<lsInternal::StencilLocalLaxFriedrichsScalar<T, D, 1>>(
248 module, "StencilLocalLaxFriedrichsScalar")
249 .def_static(
250 "setMaxDissipation",
252 1>::setMaxDissipation,
253 py::arg("maxDissipation"));
254
255 module.def("PrepareStencilLocalLaxFriedrichs",
256 &PrepareStencilLocalLaxFriedrichs<T, D>, py::arg("levelSets"),
257 py::arg("isDepo"));
258
259 module.def("FinalizeStencilLocalLaxFriedrichs",
260 &FinalizeStencilLocalLaxFriedrichs<T, D>, py::arg("levelSets"));
261
262 // BooleanOperation
263 py::class_<BooleanOperation<T, D>, SmartPointer<BooleanOperation<T, D>>>(
264 module, "BooleanOperation")
265 // constructors
266 .def(py::init(&SmartPointer<BooleanOperation<T, D>>::template New<>))
267 .def(py::init(&SmartPointer<BooleanOperation<T, D>>::template New<
268 SmartPointer<Domain<T, D>> &>))
269 .def(
270 py::init(&SmartPointer<BooleanOperation<T, D>>::template New<
271 SmartPointer<Domain<T, D>> &, SmartPointer<Domain<T, D>> &>))
272 // some constructors need lambda to work: seems to be an issue with
273 // implicit move constructor
274 .def(py::init(
275 [](SmartPointer<Domain<T, D>> &domain, BooleanOperationEnum op) {
276 return SmartPointer<BooleanOperation<T, D>>::New(domain, op);
277 }))
278 .def(py::init([](SmartPointer<Domain<T, D>> &domainA,
279 SmartPointer<Domain<T, D>> &domainB,
281 return SmartPointer<BooleanOperation<T, D>>::New(domainA, domainB, op);
282 }))
283 // methods
284 .def("setLevelset", &BooleanOperation<T, D>::setLevelSet,
285 "Set levelset on which the boolean operation should be performed.")
286 .def("setSecondLevelSet", &BooleanOperation<T, D>::setSecondLevelSet,
287 "Set second levelset for boolean operation.")
288 .def("setBooleanOperation", &BooleanOperation<T, D>::setBooleanOperation,
289 "Set which type of boolean operation should be performed.")
290 .def("apply", &BooleanOperation<T, D>::apply,
291 "Perform the boolean operation.");
292
293 py::class_<CalculateCurvatures<T, D>,
294 SmartPointer<CalculateCurvatures<T, D>>>(module,
295 "CalculateCurvatures")
296 // constructors
297 .def(py::init(&SmartPointer<CalculateCurvatures<T, D>>::template New<>))
298 .def(py::init(&SmartPointer<CalculateCurvatures<T, D>>::template New<
299 SmartPointer<Domain<T, D>> &>))
300 // some constructors need lambda to work: seems to be an issue with
301 // implicit move constructor
302 .def(py::init([](SmartPointer<Domain<T, D>> &domain, CurvatureEnum type) {
303 return SmartPointer<CalculateCurvatures<T, D>>::New(domain, type);
304 }))
305 // methods
306 .def("setLevelSet", &CalculateCurvatures<T, D>::setLevelSet,
307 "Set levelset for which to calculate the curvatures.")
308 .def("setCurvatureType", &CalculateCurvatures<T, D>::setCurvatureType,
309 "Set which method to use for calculation: Defaults to mean "
310 "curvature.")
311 .def("setMaxValue", &CalculateCurvatures<T, D>::setMaxValue,
312 "Curvatures will be calculated for all LS values < maxValue.")
314 "Perform normal vector calculation.");
315
316 // CalculateNormalVectors
317 py::class_<CalculateNormalVectors<T, D>,
318 SmartPointer<CalculateNormalVectors<T, D>>>(
319 module, "CalculateNormalVectors")
320 // constructors
321 .def(
322 py::init(&SmartPointer<CalculateNormalVectors<T, D>>::template New<>))
323 .def(py::init(&SmartPointer<CalculateNormalVectors<T, D>>::template New<
324 SmartPointer<Domain<T, D>> &>))
325 // methods
327 "Set levelset for which to calculate normal vectors.")
329 "Set the maximum value for which normals should be calculated.")
331 "Set the method to use for normal calculation.")
333 "Perform normal vector calculation.");
334
335 // CalculateVisibilities
336 py::class_<CalculateVisibilities<T, D>,
337 SmartPointer<CalculateVisibilities<T, D>>>(module,
338 "CalculateVisibilities")
339 .def(py::init(
340 &SmartPointer<CalculateVisibilities<T, D>>::template New<
341 SmartPointer<Domain<T, D>> &, const Vec3D<T> &, std::string>))
343
344 // Check
345 py::class_<Check<T, D>, SmartPointer<Check<T, D>>>(module, "Check")
346 // constructors
347 .def(py::init(&SmartPointer<Check<T, D>>::template New<>))
348 .def(py::init(&SmartPointer<Check<T, D>>::template New<
349 SmartPointer<Domain<T, D>> &>))
350 // methods
351 .def("setLevelSet", &Check<T, D>::setLevelSet,
352 "Set levelset for which to calculate normal vectors.")
353 .def("apply", &Check<T, D>::apply, "Perform check.");
354
355 // PointCloud
356 py::class_<PointCloud<T, D>, SmartPointer<PointCloud<T, D>>>(module,
357 "PointCloud")
358 // constructors
359 .def(py::init(&SmartPointer<PointCloud<T, D>>::template New<
360 const std::vector<VectorType<T, D>> &>))
361 // methods
362 .def("insertNextPoint",
363 (void(PointCloud<T, D>::*)(const VectorType<T, D> &)) &
365
366 // ConvexHull
367 py::class_<ConvexHull<T, D>, SmartPointer<ConvexHull<T, D>>>(module,
368 "ConvexHull")
369 // constructors
370 .def(py::init(&SmartPointer<ConvexHull<T, D>>::template New<>))
371 .def(py::init(&SmartPointer<ConvexHull<T, D>>::template New<
372 SmartPointer<Mesh<T>> &, SmartPointer<PointCloud<T, D>> &>))
373 // methods
374 .def("setMesh", &ConvexHull<T, D>::setMesh,
375 "Set mesh object where the generated mesh should be stored.")
376 .def("setPointCloud", &ConvexHull<T, D>::setPointCloud,
377 "Set point cloud used to generate mesh.")
378 .def("apply", &ConvexHull<T, D>::apply, "Generate Hull.");
379
380 // DetectFeatures
381 py::class_<DetectFeatures<T, D>, SmartPointer<DetectFeatures<T, D>>>(
382 module, "DetectFeatures")
383 // constructors
384 .def(py::init(&SmartPointer<DetectFeatures<T, D>>::template New<>))
385 .def(py::init(&SmartPointer<DetectFeatures<T, D>>::template New<
386 SmartPointer<Domain<T, D>> &>))
387 .def(py::init(&SmartPointer<DetectFeatures<T, D>>::template New<
388 SmartPointer<Domain<T, D>> &, T>))
389 // some constructors need lambda to work: seems to be an issue with
390 // implicit move constructor
391 .def(py::init([](SmartPointer<Domain<T, D>> &domain, T maxValue,
393 return SmartPointer<DetectFeatures<T, D>>::New(domain, maxValue, type);
394 }))
395 .def("setDetectionThreshold",
397 "Set the curvature value above which a point is considered a "
398 "feature.")
399 .def("setDetectionMethod", &DetectFeatures<T, D>::setDetectionMethod,
400 "Set which method to use to detect features. Defaults to Curvature.")
401 .def("apply", &DetectFeatures<T, D>::apply, "Detect features.");
402
403 // GeometricAdvect
404 py::class_<GeometricAdvect<T, D>, SmartPointer<GeometricAdvect<T, D>>>(
405 module, "GeometricAdvect")
406 // constructors
407 .def(py::init(&SmartPointer<GeometricAdvect<T, D>>::template New<>))
408 .def(py::init(
409 &SmartPointer<GeometricAdvect<T, D>>::template New<
410 SmartPointer<Domain<T, D>> &,
411 SmartPointer<
413 // methods
414 .def("setLevelSet", &GeometricAdvect<T, D>::setLevelSet,
415 "Set levelset to advect.")
416 .def(
417 "setAdvectionDistribution",
419 "Set advection distribution to use as kernel for the fast advection.")
420 .def("apply", &GeometricAdvect<T, D>::apply,
421 py::call_guard<py::gil_scoped_release>(), "Perform advection.");
422
423 // GeometricAdvectDistributions
424 py::class_<GeometricAdvectDistribution<T, D>,
425 SmartPointer<GeometricAdvectDistribution<T, D>>,
427 "GeometricAdvectDistribution")
428 // constructors
429 .def(py::init<>())
430 // methods
432 "Check whether passed point is inside the distribution.")
433 .def("getSignedDistance",
435 "Get the signed distance of the passed point to the surface of the "
436 "distribution.")
438 "Get the cartesian bounds of the distribution.")
440 "Prepare the distribution for use with the passed level set.")
442 "Finalize the distribution after use with the level set.");
443
444 py::class_<SphereDistribution<T, D>, SmartPointer<SphereDistribution<T, D>>,
445 GeometricAdvectDistribution<T, D>>(module, "SphereDistribution")
446 // constructors
447 .def(py::init(&SmartPointer<SphereDistribution<T, D>>::template New<T>))
448 // methods
449 .def("isInside", &SphereDistribution<T, D>::isInside,
450 "Check whether passed point is inside the distribution.")
451 .def("getSignedDistance", &SphereDistribution<T, D>::getSignedDistance,
452 "Get the signed distance of the passed point to the surface of the "
453 "distribution.")
454 .def("getBounds", &SphereDistribution<T, D>::getBounds,
455 "Get the cartesian bounds of the distribution.");
456
457 py::class_<BoxDistribution<T, D>, SmartPointer<BoxDistribution<T, D>>,
458 GeometricAdvectDistribution<T, D>>(module, "BoxDistribution")
459 // constructors
460 .def(py::init(&SmartPointer<BoxDistribution<T, D>>::template New<
461 const std::array<T, 3>>))
462 // methods
463 .def("isInside", &BoxDistribution<T, D>::isInside,
464 "Check whether passed point is inside the distribution.")
465 .def("getSignedDistance", &BoxDistribution<T, D>::getSignedDistance,
466 "Get the signed distance of the passed point to the surface of the "
467 "distribution.")
468 .def("getBounds", &BoxDistribution<T, D>::getBounds,
469 "Get the cartesian bounds of the distribution.");
470
471 py::class_<CustomSphereDistribution<T, D>,
472 SmartPointer<CustomSphereDistribution<T, D>>,
474 "CustomSphereDistribution")
475 // constructors
476 .def(py::init(&SmartPointer<CustomSphereDistribution<T, D>>::template New<
477 const std::vector<T> &>))
478 // methods
480 "Check whether passed point is inside the distribution.")
481 .def("getSignedDistance",
483 "Get the signed distance of the passed point to the surface of the "
484 "distribution.")
486 "Get the cartesian bounds of the distribution.");
487
488 // Expand
489 py::class_<Expand<T, D>, SmartPointer<Expand<T, D>>>(module, "Expand")
490 // constructors
491 .def(py::init(&SmartPointer<Expand<T, D>>::template New<>))
492 .def(py::init(&SmartPointer<Expand<T, D>>::template New<
493 SmartPointer<Domain<T, D>> &>))
494 .def(py::init(&SmartPointer<Expand<T, D>>::template New<
495 SmartPointer<Domain<T, D>> &, int>))
496 // methods
497 .def("setLevelSet", &Expand<T, D>::setLevelSet, "Set levelset to expand.")
498 .def("setWidth", &Expand<T, D>::setWidth, "Set the width to expand to.")
499 .def("apply", &Expand<T, D>::apply, "Perform expansion.");
500
501 // FromSurfaceMesh
502 py::class_<FromSurfaceMesh<T, D>, SmartPointer<FromSurfaceMesh<T, D>>>(
503 module, "FromSurfaceMesh")
504 // constructors
505 .def(py::init(&SmartPointer<FromSurfaceMesh<T, D>>::template New<>))
506 .def(py::init(&SmartPointer<FromSurfaceMesh<T, D>>::template New<
507 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &>))
508 .def(py::init(
509 &SmartPointer<FromSurfaceMesh<T, D>>::template New<
510 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &, bool>))
511 // methods
512 .def("setLevelSet", &FromSurfaceMesh<T, D>::setLevelSet,
513 "Set levelset to read into.")
514 .def("setMesh", &FromSurfaceMesh<T, D>::setMesh,
515 "Set the mesh to read from.")
516 .def("setRemoveBoundaryTriangles",
517 static_cast<void (FromSurfaceMesh<T, D>::*)(bool)>(
519 "Set whether to include mesh elements outside of the simulation "
520 "domain.")
521 .def("setRemoveBoundaryTriangles",
522 static_cast<void (FromSurfaceMesh<T, D>::*)(std::array<bool, 3>)>(
524 "Set whether to include mesh elements outside of the simulation "
525 "domain.")
526 .def("apply", &FromSurfaceMesh<T, D>::apply,
527 "Construct a levelset from a surface mesh.");
528
529 // FromVolumeMesh
530 py::class_<FromVolumeMesh<T, D>, SmartPointer<FromVolumeMesh<T, D>>>(
531 module, "FromVolumeMesh")
532 // constructors
533 .def(py::init(&SmartPointer<FromVolumeMesh<T, D>>::template New<>))
534 .def(py::init(&SmartPointer<FromVolumeMesh<T, D>>::template New<
536 SmartPointer<Mesh<T>> &>))
537 .def(py::init(&SmartPointer<FromVolumeMesh<T, D>>::template New<
539 SmartPointer<Mesh<T>> &, bool>))
540 // methods
541 .def("setGrid", &FromVolumeMesh<T, D>::setGrid,
542 "Set the grid used to read in the level sets.")
543 .def("setMesh", &FromVolumeMesh<T, D>::setMesh,
544 "Set the mesh to read from.")
545 .def("setRemoveBoundaryTriangles",
547 "Set whether to include mesh elements outside of the simulation "
548 "domain.")
549 .def("apply", &FromVolumeMesh<T, D>::apply,
550 "Construct a levelset from a volume mesh.");
551
552 // FromMesh
553 py::class_<FromMesh<T, D>, SmartPointer<FromMesh<T, D>>>(module, "FromMesh")
554 .def(py::init(&SmartPointer<FromMesh<T, D>>::template New<>))
555 .def(py::init(&SmartPointer<FromMesh<T, D>>::template New<
556 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &>))
557 .def("setMesh", &FromMesh<T, D>::setMesh, "Set the mesh to read from.")
558 .def("setSortPointList", &FromMesh<T, D>::setSortPointList)
559 .def("apply", &FromMesh<T, D>::apply);
560
561 // lsGeometries
562 // Sphere
563 py::class_<Sphere<T, D>, SmartPointer<Sphere<T, D>>>(module, "Sphere")
564 // constructors
565 .def(py::init(&SmartPointer<Sphere<T, D>>::template New<
566 const std::vector<T> & /*origin*/, T /*radius*/>),
567 py::arg("origin"), py::arg("radius"));
568 // Plane
569 py::class_<Plane<T, D>, SmartPointer<Plane<T, D>>>(module, "Plane")
570 // constructors
571 .def(py::init(&SmartPointer<Plane<T, D>>::template New<
572 const std::vector<T> & /*origin*/,
573 const std::vector<T> & /*normal*/>),
574 py::arg("origin"), py::arg("normal"));
575 // Box
576 py::class_<Box<T, D>, SmartPointer<Box<T, D>>>(module, "Box")
577 // constructors
578 .def(py::init(&SmartPointer<Box<T, D>>::template New<
579 const std::vector<T> & /*minPoint*/,
580 const std::vector<T> & /*maxPoint*/>),
581 py::arg("minPoint"), py::arg("maxPoint"));
582 // Cylinder
583 py::class_<Cylinder<T, D>, SmartPointer<Cylinder<T, D>>>(module, "Cylinder")
584 // constructors
585 .def(
586 py::init(&SmartPointer<Cylinder<T, D>>::template New<
587 const std::vector<T> & /*origin*/,
588 const std::vector<T> & /*axisDirection*/, const T /*height*/,
589 const T /*radius*/, const T /*topRadius*/>),
590 py::arg("origin"), py::arg("axisDirection"), py::arg("height"),
591 py::arg("radius"), py::arg("topRadius") = 0.);
592
593 // MakeGeometry
594 py::class_<MakeGeometry<T, D>, SmartPointer<MakeGeometry<T, D>>>(
595 module, "MakeGeometry")
596 // constructors
597 .def(py::init(&SmartPointer<MakeGeometry<T, D>>::template New<>))
598 .def(py::init(&SmartPointer<MakeGeometry<T, D>>::template New<
599 SmartPointer<Domain<T, D>> &>))
600 .def(
601 py::init(&SmartPointer<MakeGeometry<T, D>>::template New<
602 SmartPointer<Domain<T, D>> &, SmartPointer<Sphere<T, D>> &>))
603 .def(py::init(&SmartPointer<MakeGeometry<T, D>>::template New<
604 SmartPointer<Domain<T, D>> &, SmartPointer<Plane<T, D>> &>))
605 .def(py::init(&SmartPointer<MakeGeometry<T, D>>::template New<
606 SmartPointer<Domain<T, D>> &, SmartPointer<Box<T, D>> &>))
607 .def(py::init(
608 &SmartPointer<MakeGeometry<T, D>>::template New<
609 SmartPointer<Domain<T, D>> &, SmartPointer<Cylinder<T, D>> &>))
610 .def(py::init(
611 &SmartPointer<MakeGeometry<T, D>>::template New<
612 SmartPointer<Domain<T, D>> &, SmartPointer<PointCloud<T, D>> &>))
613 // methods
614 .def("setLevelSet", &MakeGeometry<T, D>::setLevelSet,
615 "Set the levelset in which to create the geometry.")
616 .def("setGeometry",
617 (void(MakeGeometry<T, D>::*)(SmartPointer<Sphere<T, D>>)) &
619 .def("setGeometry",
620 (void(MakeGeometry<T, D>::*)(SmartPointer<Plane<T, D>>)) &
622 .def("setGeometry",
623 (void(MakeGeometry<T, D>::*)(SmartPointer<Box<T, D>>)) &
625 .def("setGeometry",
626 (void(MakeGeometry<T, D>::*)(SmartPointer<Cylinder<T, D>>)) &
628 .def("setGeometry",
629 (void(MakeGeometry<T, D>::*)(SmartPointer<PointCloud<T, D>>)) &
631 .def("setIgnoreBoundaryConditions",
632 (void(MakeGeometry<T, D>::*)(bool)) &
634 .def("setIgnoreBoundaryConditions",
635 (void(MakeGeometry<T, D>::*)(std::array<bool, 3>)) &
637 .def("apply", &MakeGeometry<T, D>::apply, "Generate the geometry.");
638
639 // MarkVoidPoints
640 py::class_<MarkVoidPoints<T, D>, SmartPointer<MarkVoidPoints<T, D>>>(
641 module, "MarkVoidPoints")
642 // constructors
643 .def(py::init(&SmartPointer<MarkVoidPoints<T, D>>::template New<>))
644 .def(py::init(&SmartPointer<MarkVoidPoints<T, D>>::template New<
645 SmartPointer<Domain<T, D>> &>))
646 .def(py::init(&SmartPointer<MarkVoidPoints<T, D>>::template New<
647 SmartPointer<Domain<T, D>> &, bool &>))
648 // methods
649 .def("setLevelSet", &MarkVoidPoints<T, D>::setLevelSet,
650 "Set the levelset to mark void points in.")
651 .def("setReverseVoidDetection",
653 "Reverse the logic of detecting the top surface.")
654 .def("setDetectLargestSurface",
656 "Set that the top surface should be the one with the most connected "
657 "LS points.")
658 .def("setVoidTopSurface", &MarkVoidPoints<T, D>::setVoidTopSurface,
659 "Set the logic by which to choose the surface which is non-void. "
660 "All other connected surfaces will then be marked as void points.")
661 .def("setSaveComponentIds", &MarkVoidPoints<T, D>::setSaveComponentIds,
662 "Save the connectivity information of all LS points in the "
663 "pointData of the level set.")
664 .def("getNumberOfComponents",
666 "Get the number of connected components found in the level set.")
667 .def("apply", &MarkVoidPoints<T, D>::apply, "Mark void points.");
668
669 // Prune
670 py::class_<Prune<T, D>, SmartPointer<Prune<T, D>>>(module, "Prune")
671 // constructors
672 .def(py::init(&SmartPointer<Prune<T, D>>::template New<>))
673 .def(py::init(&SmartPointer<Prune<T, D>>::template New<
674 SmartPointer<Domain<T, D>> &>))
675 // methods
676 .def("setLevelSet", &Prune<T, D>::setLevelSet, "Set levelset to prune.")
677 .def("apply", &Prune<T, D>::apply, "Perform pruning operation.");
678
679 // Reader
680 py::class_<Reader<T, D>, SmartPointer<Reader<T, D>>>(module, "Reader")
681 // constructors
682 .def(py::init(&SmartPointer<Reader<T, D>>::template New<>))
683 .def(py::init(&SmartPointer<Reader<T, D>>::template New<
684 SmartPointer<Domain<T, D>> &>))
685 .def(py::init(&SmartPointer<Reader<T, D>>::template New<
686 SmartPointer<Domain<T, D>> &, std::string>))
687 // methods
688 .def("setLevelSet", &Reader<T, D>::setLevelSet,
689 "Set levelset to write to file.")
690 .def("setFileName", &Reader<T, D>::setFileName,
691 "Set the filename for the output file.")
692 .def("apply", &Reader<T, D>::apply, "Write to file.");
693
694 // Reduce
695 py::class_<Reduce<T, D>, SmartPointer<Reduce<T, D>>>(module, "Reduce")
696 // constructors
697 .def(py::init(&SmartPointer<Reduce<T, D>>::template New<>))
698 .def(py::init(&SmartPointer<Reduce<T, D>>::template New<
699 SmartPointer<Domain<T, D>> &>))
700 .def(py::init(&SmartPointer<Reduce<T, D>>::template New<
701 SmartPointer<Domain<T, D>> &, int>))
702 .def(py::init(&SmartPointer<Reduce<T, D>>::template New<
703 SmartPointer<Domain<T, D>> &, int, bool>))
704 // methods
705 .def("setLevelSet", &Reduce<T, D>::setLevelSet, "Set levelset to reduce.")
706 .def("setWidth", &Reduce<T, D>::setWidth, "Set the width to reduce to.")
707 .def("setNoNewSegment", &Reduce<T, D>::setNoNewSegment,
708 "Set whether the levelset should be segmented anew (balanced across "
709 "cores) after reduction.")
710 .def("apply", &Reduce<T, D>::apply, "Perform reduction.");
711
712 // RemoveStrayPoints
713 py::class_<RemoveStrayPoints<T, D>, SmartPointer<RemoveStrayPoints<T, D>>>(
714 module, "RemoveStrayPoints")
715 // constructors
716 .def(py::init(&SmartPointer<RemoveStrayPoints<T, D>>::template New<>))
717 .def(py::init(&SmartPointer<RemoveStrayPoints<T, D>>::template New<
718 SmartPointer<Domain<T, D>> &>))
719 // methods
720 .def("setLevelSet", &RemoveStrayPoints<T, D>::setLevelSet,
721 "Set levelset for stray point removal.")
722 .def("setVoidTopSurface", &RemoveStrayPoints<T, D>::setVoidTopSurface,
723 "Set the logic by which to choose the surface which should be kept. "
724 "All other LS values will be marked as stray points and removed.")
725 .def("apply", &RemoveStrayPoints<T, D>::apply, "Remove stray points.");
726
727 // ToDiskMesh
728 py::class_<ToDiskMesh<T, D>, SmartPointer<ToDiskMesh<T, D>>>(module,
729 "ToDiskMesh")
730 // constructors
731 .def(py::init(&SmartPointer<ToDiskMesh<T, D>>::template New<>))
732 .def(py::init(&SmartPointer<ToDiskMesh<T, D>>::template New<
733 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &>))
734 // methods
735 .def("setLevelSet", &ToDiskMesh<T, D>::setLevelSet,
736 "Set levelset to mesh.")
737 .def("clearLevelSets", &ToDiskMesh<T, D>::clearLevelSets,
738 "Clear all inserted level sets.")
739 .def("insertNextLevelSet", &ToDiskMesh<T, D>::insertNextLevelSet,
740 "Insert next level set to output in the disk mesh.")
741 .def("setMesh", &ToDiskMesh<T, D>::setMesh, "Set the mesh to generate.")
742 .def("setMaterialMap", &ToDiskMesh<T, D>::setMaterialMap,
743 "Set the material map to use for the disk mesh.")
744 .def("setMaxValue", &ToDiskMesh<T, D>::setMaxValue,
745 "Set the maximum level set value to include in the disk mesh.")
746 .def("apply", &ToDiskMesh<T, D>::apply,
747 "Convert the levelset to a surface mesh.");
748
749 // ToMesh
750 py::class_<ToMesh<T, D>, SmartPointer<ToMesh<T, D>>>(module, "ToMesh")
751 // constructors
752 .def(py::init(&SmartPointer<ToMesh<T, D>>::template New<>))
753 .def(py::init(&SmartPointer<ToMesh<T, D>>::template New<
754 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &>))
755 .def(py::init(
756 &SmartPointer<ToMesh<T, D>>::template New<
757 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &, bool>))
758 .def(py::init(&SmartPointer<ToMesh<T, D>>::template New<
759 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &, bool,
760 bool>))
761 // methods
762 .def("setLevelSet", &ToMesh<T, D>::setLevelSet, "Set levelset to mesh.")
763 .def("setMesh", &ToMesh<T, D>::setMesh, "Set the mesh to generate.")
764 .def("setOnlyDefined", &ToMesh<T, D>::setOnlyDefined,
765 "Set whether only defined points should be output to the mesh.")
766 .def("setOnlyActive", &ToMesh<T, D>::setOnlyActive,
767 "Set whether only level set points <0.5 should be output.")
768 .def("apply", &ToMesh<T, D>::apply,
769 "Convert the levelset to a surface mesh.");
770
771 // ToSurfaceMesh
772 py::class_<ToSurfaceMesh<T, D>, SmartPointer<ToSurfaceMesh<T, D>>>(
773 module, "ToSurfaceMesh")
774 // constructors
775 .def(
776 py::init(
777 &SmartPointer<ToSurfaceMesh<T, D>>::template New<double, double>),
778 py::arg("minNodeDistFactor") = 0.05, py::arg("eps") = 1e-12)
779 .def(py::init(&SmartPointer<ToSurfaceMesh<T, D>>::template New<
780 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &,
781 double, double>),
782 py::arg("domain"), py::arg("mesh"),
783 py::arg("minNodeDistFactor") = 0.05, py::arg("eps") = 1e-12)
784 // methods
785 .def("setLevelSet", &ToSurfaceMesh<T, D>::setLevelSet,
786 "Set levelset to mesh.")
787 .def("setMesh", &ToSurfaceMesh<T, D>::setMesh,
788 "Set the mesh to generate.")
789 .def("setUpdatePointData", &ToSurfaceMesh<T, D>::setUpdatePointData,
790 "Set whether to update point data. Defaults to true.")
791 .def("setSharpCorners", &ToSurfaceMesh<T, D>::setSharpCorners,
792 "Set whether to preserve sharp corners. Defaults to false.")
793 .def("apply", &ToSurfaceMesh<T, D>::apply,
794 "Convert the levelset to a surface mesh.");
795
796 // ToMultiSurfaceMesh
797 py::class_<ToMultiSurfaceMesh<T, D>, SmartPointer<ToMultiSurfaceMesh<T, D>>>(
798 module, "ToMultiSurfaceMesh")
799 // constructors
800 .def(py::init(
801 &SmartPointer<ToMultiSurfaceMesh<T, D>>::template New<double,
802 double>),
803 py::arg("minNodeDistFactor") = 0.05, py::arg("eps") = 1e-12)
804 .def(py::init(&SmartPointer<ToMultiSurfaceMesh<T, D>>::template New<
805 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &,
806 double, double>),
807 py::arg("domain"), py::arg("mesh"),
808 py::arg("minNodeDistFactor") = 0.05, py::arg("eps") = 1e-12)
809 .def(py::init(&SmartPointer<ToMultiSurfaceMesh<T, D>>::template New<
810 std::vector<SmartPointer<Domain<T, D>>> &,
811 SmartPointer<Mesh<T>> &, double, double>),
812 py::arg("domains"), py::arg("mesh"),
813 py::arg("minNodeDistFactor") = 0.05, py::arg("eps") = 1e-12)
814 .def(py::init(&SmartPointer<ToMultiSurfaceMesh<T, D>>::template New<
815 SmartPointer<Mesh<T>> &, double, double>),
816 py::arg("mesh"), py::arg("minNodeDistFactor") = 0.05,
817 py::arg("eps") = 1e-12)
818 // methods
819 .def("insertNextLevelSet", &ToMultiSurfaceMesh<T, D>::insertNextLevelSet,
820 "Insert next level set to output in the mesh.")
821 .def("clearLevelSets", &ToMultiSurfaceMesh<T, D>::clearLevelSets,
822 "Clear all inserted level sets.")
823 .def("setMesh", &ToMultiSurfaceMesh<T, D>::setMesh,
824 "Set the mesh to generate.")
825 .def("setMaterialMap", &ToMultiSurfaceMesh<T, D>::setMaterialMap,
826 "Set the material map to use for the multi surface mesh.")
827 .def("setSharpCorners", &ToMultiSurfaceMesh<T, D>::setSharpCorners,
828 "Set whether to preserve sharp corners. Defaults to false.")
829 .def("apply", &ToMultiSurfaceMesh<T, D>::apply,
830 "Convert the levelset to a surface mesh.");
831
832 // ToVoxelMesh
833 py::class_<ToVoxelMesh<T, D>, SmartPointer<ToVoxelMesh<T, D>>>(module,
834 "ToVoxelMesh")
835 // constructors
836 .def(py::init(&SmartPointer<ToVoxelMesh<T, D>>::template New<>))
837 .def(py::init(&SmartPointer<ToVoxelMesh<T, D>>::template New<
838 SmartPointer<Mesh<T>> &>))
839 .def(py::init(&SmartPointer<ToVoxelMesh<T, D>>::template New<
840 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &>))
841 .def(py::init(&SmartPointer<ToVoxelMesh<T, D>>::template New<
842 std::vector<SmartPointer<Domain<T, D>>> &,
843 SmartPointer<Mesh<T>> &>))
844 // methods
845 .def("insertNextLevelSet", &ToVoxelMesh<T, D>::insertNextLevelSet,
846 "Insert next level set to output in the mesh.")
847 .def("clearLevelSets", &ToVoxelMesh<T, D>::clearLevelSets,
848 "Clear all inserted level sets.")
849 .def("setMesh", &ToVoxelMesh<T, D>::setMesh, "Set the mesh to generate.")
850 .def("apply", &ToVoxelMesh<T, D>::apply,
851 "Convert the levelset to a surface mesh.");
852
853 // Writer
854 py::class_<Writer<T, D>, SmartPointer<Writer<T, D>>>(module, "Writer")
855 // constructors
856 .def(py::init(&SmartPointer<Writer<T, D>>::template New<>))
857 .def(py::init(&SmartPointer<Writer<T, D>>::template New<
858 SmartPointer<Domain<T, D>> &>))
859 .def(py::init(&SmartPointer<Writer<T, D>>::template New<
860 SmartPointer<Domain<T, D>> &, std::string>))
861 // methods
862 .def("setLevelSet", &Writer<T, D>::setLevelSet,
863 "Set levelset to write to file.")
864 .def("setFileName", &Writer<T, D>::setFileName,
865 "Set the filename for the output file.")
866 .def("apply", &Writer<T, D>::apply, "Write to file.");
867
868 // CompareSparseField
869 py::class_<CompareSparseField<T, D>, SmartPointer<CompareSparseField<T, D>>>(
870 module, "CompareSparseField")
871 // constructors
872 .def(py::init(&SmartPointer<CompareSparseField<T, D>>::template New<>))
873 .def(
874 py::init(&SmartPointer<CompareSparseField<T, D>>::template New<
875 SmartPointer<Domain<T, D>> &, SmartPointer<Domain<T, D>> &>))
876 // methods
877 .def("setLevelSetExpanded",
879 "Sets the expanded level set for comparison.")
880 .def("setLevelSetIterated",
882 "Sets the iterated level set to compare against the expanded one.")
883 .def("setXRange", &CompareSparseField<T, D>::setXRange,
884 "Set the x-coordinate range to restrict the comparison area")
885 .def("setYRange", &CompareSparseField<T, D>::setYRange,
886 "Set the y-coordinate range to restrict the comparison area")
887 .def("clearXRange", &CompareSparseField<T, D>::clearXRange,
888 "Clear the x-range restriction")
889 .def("clearYRange", &CompareSparseField<T, D>::clearYRange,
890 "Clear the y-range restriction")
891 .def("setZRange", &CompareSparseField<T, D>::setZRange,
892 "Set the z-coordinate range to restrict the comparison area")
893 .def("clearZRange", &CompareSparseField<T, D>::clearZRange,
894 "Clear the z-range restriction")
895 .def("setOutputMesh", &CompareSparseField<T, D>::setOutputMesh,
896 "Set the output mesh where difference values will be stored")
897 .def("setFillIteratedWithDistances",
899 "Set whether to fill the iterated level set with distance values")
900 .def("setExpandedLevelSetWidth",
902 "Set the expansion width for the expanded level set")
903 .def("apply", &CompareSparseField<T, D>::apply,
904 "Apply the comparison and calculate the sum of squared "
905 "differences.")
906 .def("getSumSquaredDifferences",
908 "Return the sum of squared differences calculated by apply().")
909 .def("getSumDifferences", &CompareSparseField<T, D>::getSumDifferences,
910 "Return the sum of absolute differences calculated by apply().")
911 .def("getNumPoints", &CompareSparseField<T, D>::getNumPoints,
912 "Return the number of points used in the comparison.")
913 .def("getNumSkippedPoints",
915 "Return the number of points skipped during comparison.")
916 .def("getRMSE", &CompareSparseField<T, D>::getRMSE,
917 "Calculate the root mean square error from previously computed "
918 "values.");
919
920// WriteVisualizationMesh
921#ifdef VIENNALS_USE_VTK
922 py::class_<WriteVisualizationMesh<T, D>,
923 SmartPointer<WriteVisualizationMesh<T, D>>>(
924 module, "WriteVisualizationMesh")
925 // constructors
926 .def(
927 py::init(&SmartPointer<WriteVisualizationMesh<T, D>>::template New<>))
928 .def(py::init(&SmartPointer<WriteVisualizationMesh<T, D>>::template New<
929 SmartPointer<Domain<T, D>> &>))
930 // methods
931 .def("insertNextLevelSet",
932 &WriteVisualizationMesh<T, D>::insertNextLevelSet,
933 "Insert next level set to convert. Bigger level sets wrapping "
934 "smaller ones, should be inserted last.")
935 .def("setFileName", &WriteVisualizationMesh<T, D>::setFileName,
936 "Set Name of File to write.")
937 .def("setExtractHullMesh",
938 &WriteVisualizationMesh<T, D>::setExtractHullMesh,
939 "Whether to extract a hull mesh. Defaults to false.")
940 .def("setExtractVolumeMesh",
941 &WriteVisualizationMesh<T, D>::setExtractVolumeMesh,
942 " Whether to extract a tetra volume mesh. Defaults to true.")
943 .def("setMetaData", &WriteVisualizationMesh<T, D>::setMetaData,
944 "Set the metadata to be written to the file.")
945 .def("addMetaData",
946 py::overload_cast<const std::string &, T>(
947 &WriteVisualizationMesh<T, D>::addMetaData),
948 "Add a single metadata entry to the file.")
949 .def("addMetaData",
950 py::overload_cast<const std::string &, const std::vector<T> &>(
951 &WriteVisualizationMesh<T, D>::addMetaData),
952 "Add a single metadata entry to the file.")
953 .def("addMetaData",
954 py::overload_cast<
955 const std::unordered_map<std::string, std::vector<T>> &>(
956 &WriteVisualizationMesh<T, D>::addMetaData),
957 "Add metadata to the file.")
958 .def("apply", &WriteVisualizationMesh<T, D>::apply,
959 "Make and write mesh.");
960#endif
961
962 // ToHullMesh
963 py::class_<ToHullMesh<T, D>, SmartPointer<ToHullMesh<T, D>>>(module,
964 "ToHullMesh")
965 // constructors
966 .def(py::init(&SmartPointer<ToHullMesh<T, D>>::template New<>))
967 .def(py::init(&SmartPointer<ToHullMesh<T, D>>::template New<
968 SmartPointer<Mesh<T>> &>))
969 .def(py::init(&SmartPointer<ToHullMesh<T, D>>::template New<
970 SmartPointer<Mesh<T>> &,
971 std::vector<SmartPointer<Domain<T, D>>> &>))
972 .def(py::init(&SmartPointer<ToHullMesh<T, D>>::template New<
973 SmartPointer<Mesh<T>> &, SmartPointer<Domain<T, D>> &>))
974 // methods
975 .def("setMesh", &ToHullMesh<T, D>::setMesh, "Set the mesh to generate.")
976 .def("insertNextLevelSet", &ToHullMesh<T, D>::insertNextLevelSet,
977 "Insert next level set to convert. Bigger level sets wrapping "
978 "smaller ones, should be inserted last.")
979 .def("clearLevelSets", &ToHullMesh<T, D>::clearLevelSets,
980 "Clear all inserted level sets.")
981 .def("setSharpCorners", &ToHullMesh<T, D>::setSharpCorners,
982 "Set whether to generate sharp corners. Defaults to false.")
983 .def("setMaterialMap", &ToHullMesh<T, D>::setMaterialMap,
984 "Set the material map to use for the hull mesh.")
985 .def("setBottomExtension", &ToHullMesh<T, D>::setBottomExtension,
986 "Set the bottom extension value for 2D hull meshes.")
987 .def("apply", &ToHullMesh<T, D>::apply, "Generate hull mesh.");
988
989 // CompareVolume
990 py::class_<CompareVolume<T, D>, SmartPointer<CompareVolume<T, D>>>(
991 module, "CompareVolume")
992 // constructors
993 .def(py::init(&SmartPointer<CompareVolume<T, D>>::template New<>))
994 .def(
995 py::init(&SmartPointer<CompareVolume<T, D>>::template New<
996 SmartPointer<Domain<T, D>> &, SmartPointer<Domain<T, D>> &>))
997 // methods
998 .def("setLevelSetTarget", &CompareVolume<T, D>::setLevelSetTarget,
999 "Sets the target level set.")
1000 .def("setLevelSetSample", &CompareVolume<T, D>::setLevelSetSample,
1001 "Sets the sample level set.")
1002 .def("setDefaultIncrement", &CompareVolume<T, D>::setDefaultIncrement,
1003 "Set default increment value")
1004 .def("setXRangeAndIncrement", &CompareVolume<T, D>::setXRangeAndIncrement,
1005 "Sets the x-range and custom increment value")
1006 .def("setYRangeAndIncrement", &CompareVolume<T, D>::setYRangeAndIncrement,
1007 "Sets the y-range and custom increment value")
1008 .def("setZRangeAndIncrement", &CompareVolume<T, D>::setZRangeAndIncrement,
1009 "Sets the z-range and custom increment value")
1010 .def("setOutputMesh", &CompareVolume<T, D>::setOutputMesh,
1011 "Set the output mesh where difference areas will be stored")
1012 .def("getVolumeMismatch", &CompareVolume<T, D>::getVolumeMismatch,
1013 "Returns the computed volume mismatch.")
1014 .def("getAreaMismatch", &CompareVolume<T, D>::getAreaMismatch,
1015 "Returns the computed area mismatch.")
1016 .def("getCustomVolumeMismatch",
1018 "Returns the computed volume mismatch, with custom increments "
1019 "applied.")
1020 .def("getCustomAreaMismatch", &CompareVolume<T, D>::getCustomAreaMismatch,
1021 "Returns the computed area mismatch, with custom increments "
1022 "applied.")
1023 .def("getCellCount", &CompareVolume<T, D>::getCellCount,
1024 "Returns the number of cells where the level sets differ.")
1025 .def("getCustomCellCount", &CompareVolume<T, D>::getCustomCellCount,
1026 "Returns the number of cells where the level sets differ, with "
1027 "custom increments applied.")
1028 .def("apply", &CompareVolume<T, D>::apply,
1029 "Computes the volume difference between the two level sets.");
1030
1031 if constexpr (D == 2) {
1032 module.attr("CompareArea") = module.attr("CompareVolume");
1033 }
1034
1035 // CompareChamfer
1036 py::class_<CompareChamfer<T, D>, SmartPointer<CompareChamfer<T, D>>>(
1037 module, "CompareChamfer")
1038 // constructors
1039 .def(py::init(&SmartPointer<CompareChamfer<T, D>>::template New<>))
1040 .def(
1041 py::init(&SmartPointer<CompareChamfer<T, D>>::template New<
1042 SmartPointer<Domain<T, D>> &, SmartPointer<Domain<T, D>> &>))
1043 // methods
1044 .def("setLevelSetTarget", &CompareChamfer<T, D>::setLevelSetTarget,
1045 "Set the target level set.")
1046 .def("setLevelSetSample", &CompareChamfer<T, D>::setLevelSetSample,
1047 "Set the sample level set.")
1048 .def("setOutputMeshTarget", &CompareChamfer<T, D>::setOutputMeshTarget,
1049 "Set output mesh for target surface points with distance data.")
1050 .def("setOutputMeshSample", &CompareChamfer<T, D>::setOutputMeshSample,
1051 "Set output mesh for sample surface points with distance data.")
1052 .def("apply", &CompareChamfer<T, D>::apply,
1053 "Apply the Chamfer distance calculation.")
1054 .def("getForwardDistance", &CompareChamfer<T, D>::getForwardDistance,
1055 "Get the forward distance (average distance from target to "
1056 "sample).")
1057 .def("getBackwardDistance", &CompareChamfer<T, D>::getBackwardDistance,
1058 "Get the backward distance (average distance from sample to "
1059 "target).")
1060 .def("getChamferDistance", &CompareChamfer<T, D>::getChamferDistance,
1061 "Get the Chamfer distance (average of forward and backward).")
1062 .def("getRMSChamferDistance",
1064 "Get the RMS Chamfer distance.")
1065 .def("getMaxDistance", &CompareChamfer<T, D>::getMaxDistance,
1066 "Get the maximum nearest-neighbor distance.")
1067 .def("getNumTargetPoints", &CompareChamfer<T, D>::getNumTargetPoints,
1068 "Get the number of target surface points.")
1069 .def("getNumSamplePoints", &CompareChamfer<T, D>::getNumSamplePoints,
1070 "Get the number of sample surface points.");
1071
1072 // CompareCriticalDimensions
1073 py::class_<CompareCriticalDimensions<T, D>,
1074 SmartPointer<CompareCriticalDimensions<T, D>>>(
1075 module, "CompareCriticalDimensions")
1076 // constructors
1077 .def(py::init(
1078 &SmartPointer<CompareCriticalDimensions<T, D>>::template New<>))
1079 .def(
1080 py::init(&SmartPointer<CompareCriticalDimensions<T, D>>::template New<
1081 SmartPointer<Domain<T, D>> &, SmartPointer<Domain<T, D>> &>))
1082 // methods
1083 .def("setLevelSetTarget",
1085 "Sets the target level set.")
1086 .def("setLevelSetSample",
1088 "Sets the sample level set.")
1090 py::arg("measureDimension"), py::arg("minBounds"),
1091 py::arg("maxBounds"), py::arg("findMaximum") = true,
1092 "Add a generic range specification.")
1094 py::arg("minX"), py::arg("maxX"), py::arg("findMaximum") = true,
1095 "Add an X range to find maximum or minimum Y position.")
1097 py::arg("minY"), py::arg("maxY"), py::arg("findMaximum") = true,
1098 "Add a Y range to find maximum or minimum X position.")
1100 "Clear all range specifications.")
1102 "Set the output mesh where critical dimension locations will be "
1103 "stored.")
1105 "Apply the comparison.")
1106 .def("getNumCriticalDimensions",
1108 "Get the number of critical dimensions compared.")
1109 .def(
1110 "getCriticalDimensionResult",
1111 [](CompareCriticalDimensions<T, D> &self, size_t index) -> py::tuple {
1112 T posRef{}, posCmp{}, diff{};
1113 bool valid =
1114 self.getCriticalDimensionResult(index, posRef, posCmp, diff);
1115 if (valid)
1116 return py::make_tuple(true, posRef, posCmp, diff);
1117 return py::make_tuple(false, T(0), T(0), T(0));
1118 },
1119 py::arg("index"),
1120 "Get a specific critical dimension result. Returns (valid, "
1121 "positionTarget, positionSample, difference).")
1122 .def("getMeanDifference",
1124 "Get mean absolute difference across all valid critical "
1125 "dimensions.")
1126 .def("getMaxDifference",
1128 "Get maximum difference across all valid critical dimensions.")
1130 "Get RMSE across all valid critical dimensions.")
1131 .def("getAllDifferences",
1133 "Get all valid differences as a list.");
1134
1135 // CompareNarrowBand
1136 py::class_<CompareNarrowBand<T, D>, SmartPointer<CompareNarrowBand<T, D>>>(
1137 module, "CompareNarrowBand")
1138 // constructors
1139 .def(py::init(&SmartPointer<CompareNarrowBand<T, D>>::template New<>))
1140 .def(
1141 py::init(&SmartPointer<CompareNarrowBand<T, D>>::template New<
1142 SmartPointer<Domain<T, D>> &, SmartPointer<Domain<T, D>> &>))
1143 // methods
1144 .def("setLevelSetTarget", &CompareNarrowBand<T, D>::setLevelSetTarget,
1145 "Sets the target level set.")
1146 .def("setLevelSetSample", &CompareNarrowBand<T, D>::setLevelSetSample,
1147 "Sets the sample level set.")
1148 .def("setXRange", &CompareNarrowBand<T, D>::setXRange,
1149 "Set the x-coordinate range to restrict the comparison area")
1150 .def("setYRange", &CompareNarrowBand<T, D>::setYRange,
1151 "Set the y-coordinate range to restrict the comparison area")
1152 .def("clearXRange", &CompareNarrowBand<T, D>::clearXRange,
1153 "Clear the x-range restriction")
1154 .def("clearYRange", &CompareNarrowBand<T, D>::clearYRange,
1155 "Clear the y-range restriction")
1156 .def("setZRange", &CompareNarrowBand<T, D>::setZRange,
1157 "Set the z-coordinate range to restrict the comparison area")
1158 .def("clearZRange", &CompareNarrowBand<T, D>::clearZRange,
1159 "Clear the z-range restriction")
1160 .def("setOutputMesh", &CompareNarrowBand<T, D>::setOutputMesh,
1161 "Set the output mesh where difference values will be stored")
1162 .def("setOutputMeshSquaredDifferences",
1164 "Set whether to output squared differences (true) or absolute "
1165 "differences (false)")
1166 .def("apply", &CompareNarrowBand<T, D>::apply,
1167 "Apply the comparison and calculate the sum of squared "
1168 "differences.")
1169 .def("getSumSquaredDifferences",
1171 "Return the sum of squared differences calculated by apply().")
1172 .def("getSumDifferences", &CompareNarrowBand<T, D>::getSumDifferences,
1173 "Return the sum of absolute differences calculated by apply().")
1174 .def("getNumPoints", &CompareNarrowBand<T, D>::getNumPoints,
1175 "Return the number of points used in the comparison.")
1176 .def("getRMSE", &CompareNarrowBand<T, D>::getRMSE,
1177 "Calculate the root mean square error from previously computed "
1178 "values.");
1179}
constexpr int D
Definition Epitaxy.cpp:11
double T
Definition Epitaxy.cpp:12
Definition pyWrap.hpp:69
T getSignedDistance(const vectorType &initial, const vectorType &candidate, unsigned long initialPointId) const override
Definition pyWrap.hpp:81
bool isInside(const vectorType &initial, const vectorType &candidate, double eps=0.) const override
Definition pyWrap.hpp:76
boundsType getBounds() const override
Sets bounds to the bounding box of the distribution.
Definition pyWrap.hpp:87
Stencil Local Lax Friedrichs Discretization Scheme. It uses a stencil of order around active points,...
Definition lsStencilLocalLaxFriedrichsScalar.hpp:33
This class is used to advance level sets over time. Level sets are passed to the constructor in a std...
Definition lsAdvect.hpp:54
void setVelocityField(SmartPointer< VelocityField< T > > passedVelocities)
Set the velocity field used for advection. This should be a concrete implementation of lsVelocityFiel...
Definition lsAdvect.hpp:863
void insertNextLevelSet(SmartPointer< Domain< T, D > > passedlsDomain)
Pushes the passed level set to the back of the list of level sets used for advection.
Definition lsAdvect.hpp:855
void setVelocityUpdateCallback(std::function< bool(SmartPointer< Domain< T, D > >)> callback)
Set a callback function that is called after the level set has been updated during intermediate time ...
Definition lsAdvect.hpp:965
void setUpdatePointData(bool update)
Set whether the point data in the old LS should be translated to the advected LS. Defaults to true.
Definition lsAdvect.hpp:961
void setSpatialScheme(SpatialSchemeEnum scheme)
Set which spatial discretization scheme should be used out of the ones specified in SpatialSchemeEnum...
Definition lsAdvect.hpp:935
bool getCalculateNormalVectors() const
Get whether normal vectors were calculated.
Definition lsAdvect.hpp:931
void setIgnoreVoids(bool iV)
Set whether level set values, which are not part of the "top" geometrically connected part of values,...
Definition lsAdvect.hpp:898
void clearLevelSets()
Definition lsAdvect.hpp:859
void setCalculateNormalVectors(bool cnv)
Set whether normal vectors should be calculated at each level set point. Defaults to true....
Definition lsAdvect.hpp:890
void apply()
Definition lsAdvect.hpp:1016
void setSingleStep(bool singleStep)
If set to true, only a single advection step will be performed, even if the advection time set with s...
Definition lsAdvect.hpp:878
void prepareLS()
Definition lsAdvect.hpp:972
double getAdvectedTime() const
Get by how much the physical time was advanced during the last apply() call.
Definition lsAdvect.hpp:919
void setTemporalScheme(TemporalSchemeEnum scheme)
Set which time integration scheme should be used.
Definition lsAdvect.hpp:948
void setDissipationAlpha(const double &a)
Set the alpha dissipation coefficient. For lsLaxFriedrichs, this is used as the alpha value....
Definition lsAdvect.hpp:954
void setCheckDissipation(bool check)
Definition lsAdvect.hpp:957
void setIntegrationScheme(IntegrationSchemeEnum scheme)
Definition lsAdvect.hpp:940
double getCurrentTimeStep() const
Return the last applied time step.
Definition lsAdvect.hpp:922
void setAdvectionTime(double time)
Set the time until when the level set should be advected. If this takes more than one advection step,...
Definition lsAdvect.hpp:872
unsigned getNumberOfTimeSteps() const
Get how many advection steps were performed during the last apply() call.
Definition lsAdvect.hpp:925
void setAdaptiveTimeStepping(bool aTS=true, unsigned subdivisions=20)
Set whether adaptive time stepping should be used when approaching material boundaries during etching...
Definition lsAdvect.hpp:903
void setTimeStepRatio(const double &cfl)
Set the CFL condition to use during advection. The CFL condition sets the maximum distance a surface ...
Definition lsAdvect.hpp:884
double getTimeStepRatio() const
Get the value of the CFL number.
Definition lsAdvect.hpp:928
void setSaveAdvectionVelocities(bool sAV)
Set whether the velocities applied to each point should be saved in the level set for debug purposes.
Definition lsAdvect.hpp:915
This class is used to perform boolean operations on two level sets and write the resulting level set ...
Definition lsBooleanOperation.hpp:45
void setLevelSet(SmartPointer< Domain< T, D > > passedlsDomain)
Set which level set to perform the boolean operation on.
Definition lsBooleanOperation.hpp:290
void setSecondLevelSet(SmartPointer< Domain< T, D > > passedlsDomain)
Set the level set which will be used to modify the first level set.
Definition lsBooleanOperation.hpp:296
void setBooleanOperation(BooleanOperationEnum passedOperation)
Set which of the operations of BooleanOperationEnum to perform.
Definition lsBooleanOperation.hpp:301
void apply()
Perform operation.
Definition lsBooleanOperation.hpp:319
Concrete implementation of GeometricAdvectDistribution for a rectangular box distribution.
Definition lsGeometricAdvectDistributions.hpp:129
bool isInside(const Vec3D< viennahrle::CoordType > &initial, const Vec3D< viennahrle::CoordType > &candidate, double eps) const override
Quick check whether a point relative to the distributions center is inside the distribution....
Definition lsGeometricAdvectDistributions.hpp:136
std::array< viennahrle::CoordType, 6 > getBounds() const override
Sets bounds to the bounding box of the distribution.
Definition lsGeometricAdvectDistributions.hpp:159
T getSignedDistance(const Vec3D< viennahrle::CoordType > &initial, const Vec3D< viennahrle::CoordType > &candidate, unsigned long) const override
Returns the signed distance of a point relative to the distributions center. This is the signed manha...
Definition lsGeometricAdvectDistributions.hpp:148
Class describing a square box from one coordinate to another.
Definition lsGeometries.hpp:71
Definition lsCalculateCurvatures.hpp:24
void setCurvatureType(CurvatureEnum passedType)
Definition lsCalculateCurvatures.hpp:46
void setMaxValue(const T passedMaxValue)
Definition lsCalculateCurvatures.hpp:59
void apply()
Definition lsCalculateCurvatures.hpp:61
void setLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsCalculateCurvatures.hpp:42
This algorithm is used to compute the normal vectors for all points with level set values <= maxValue...
Definition lsCalculateNormalVectors.hpp:40
void setLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsCalculateNormalVectors.hpp:63
void apply()
Definition lsCalculateNormalVectors.hpp:95
void setMethod(NormalCalculationMethodEnum passedMethod)
Definition lsCalculateNormalVectors.hpp:79
void setMaxValue(const T passedMaxValue)
Definition lsCalculateNormalVectors.hpp:67
Definition lsCalculateVisibilities.hpp:10
void apply()
Definition lsCalculateVisibilities.hpp:25
This class is used to find errors in the underlying level set structure, like invalid neighbours of d...
Definition lsCheck.hpp:22
void apply()
Definition lsCheck.hpp:78
void setLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsCheck.hpp:66
Calculate Chamfer distance between two level sets by comparing their zero-level-set surfaces....
Definition lsCompareChamfer.hpp:39
unsigned getNumSamplePoints() const
Get the number of sample surface points.
Definition lsCompareChamfer.hpp:329
void apply()
Apply the Chamfer distance calculation.
Definition lsCompareChamfer.hpp:104
T getMaxDistance() const
Get the maximum nearest-neighbor distance.
Definition lsCompareChamfer.hpp:323
T getBackwardDistance() const
Get the backward distance (average distance from sample to target).
Definition lsCompareChamfer.hpp:314
void setOutputMeshSample(SmartPointer< Mesh< T > > passedMesh)
Set output mesh for sample surface points with distance data.
Definition lsCompareChamfer.hpp:99
T getRMSChamferDistance() const
Get the RMS Chamfer distance.
Definition lsCompareChamfer.hpp:320
T getChamferDistance() const
Get the Chamfer distance (average of forward and backward).
Definition lsCompareChamfer.hpp:317
T getForwardDistance() const
Get the forward distance (average distance from target to sample).
Definition lsCompareChamfer.hpp:311
void setOutputMeshTarget(SmartPointer< Mesh< T > > passedMesh)
Set output mesh for target surface points with distance data.
Definition lsCompareChamfer.hpp:94
void setLevelSetTarget(SmartPointer< Domain< T, D > > passedLevelSet)
Set the target level set.
Definition lsCompareChamfer.hpp:84
unsigned getNumTargetPoints() const
Get the number of target surface points.
Definition lsCompareChamfer.hpp:326
void setLevelSetSample(SmartPointer< Domain< T, D > > passedLevelSet)
Set the sample level set.
Definition lsCompareChamfer.hpp:89
Compares critical dimensions (surface positions) between two level sets. Critical dimensions are defi...
Definition lsCompareCriticalDimensions.hpp:33
void apply()
Apply the comparison.
Definition lsCompareCriticalDimensions.hpp:197
std::vector< T > getAllDifferences() const
Get all valid results.
Definition lsCompareCriticalDimensions.hpp:309
void setOutputMesh(SmartPointer< Mesh< T > > passedMesh)
Set the output mesh where critical dimension locations will be stored.
Definition lsCompareCriticalDimensions.hpp:192
bool getCriticalDimensionResult(size_t index, T &positionTarget, T &positionSample, T &difference) const
Get a specific critical dimension result.
Definition lsCompareCriticalDimensions.hpp:259
size_t getNumCriticalDimensions() const
Get the number of critical dimensions compared.
Definition lsCompareCriticalDimensions.hpp:256
void addRange(int measureDimension, const std::array< T, D > &minBounds, const std::array< T, D > &maxBounds, bool findMaximum=true)
Add a generic range specification.
Definition lsCompareCriticalDimensions.hpp:154
void addYRange(T minY, T maxY, bool findMaximum=true)
Add a Y range to find maximum or minimum X position.
Definition lsCompareCriticalDimensions.hpp:177
void clearRanges()
Clear all range specifications.
Definition lsCompareCriticalDimensions.hpp:189
void setLevelSetTarget(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsCompareCriticalDimensions.hpp:145
T getMeanDifference() const
Get mean absolute difference across all valid critical dimensions.
Definition lsCompareCriticalDimensions.hpp:271
T getMaxDifference() const
Get maximum difference across all valid critical dimensions.
Definition lsCompareCriticalDimensions.hpp:284
void addXRange(T minX, T maxX, bool findMaximum=true)
Add an X range to find maximum or minimum Y position.
Definition lsCompareCriticalDimensions.hpp:165
T getRMSE() const
Get RMSE across all valid critical dimensions.
Definition lsCompareCriticalDimensions.hpp:295
void setLevelSetSample(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsCompareCriticalDimensions.hpp:149
Calculate distance measure between two level sets by comparing their SDF values on a narrow band....
Definition lsCompareNarrowBand.hpp:19
void setYRange(T minYRange, T maxYRange)
Set the y-coordinate range to restrict the comparison area.
Definition lsCompareNarrowBand.hpp:164
void setOutputMeshSquaredDifferences(bool value)
Set whether to output squared differences (true) or absolute differences (false).
Definition lsCompareNarrowBand.hpp:207
void setXRange(T minXRange, T maxXRange)
Set the x-coordinate range to restrict the comparison area.
Definition lsCompareNarrowBand.hpp:157
void setOutputMesh(SmartPointer< Mesh< T > > passedMesh, bool outputMeshSquaredDiffs=true)
Set the output mesh where difference values will be stored.
Definition lsCompareNarrowBand.hpp:199
void clearZRange()
Clear the z-range restriction.
Definition lsCompareNarrowBand.hpp:192
void setLevelSetTarget(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsCompareNarrowBand.hpp:148
T getRMSE() const
Calculate the root mean square error from previously computed values.
Definition lsCompareNarrowBand.hpp:387
void setLevelSetSample(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsCompareNarrowBand.hpp:152
unsigned getNumPoints() const
Return the number of points used in the comparison.
Definition lsCompareNarrowBand.hpp:384
void clearYRange()
Clear the y-range restriction.
Definition lsCompareNarrowBand.hpp:178
T getSumSquaredDifferences() const
Return the sum of squared differences calculated by apply().
Definition lsCompareNarrowBand.hpp:378
void apply()
Apply the comparison and calculate the sum of squared differences.
Definition lsCompareNarrowBand.hpp:212
void clearXRange()
Clear the x-range restriction.
Definition lsCompareNarrowBand.hpp:171
T getSumDifferences() const
Definition lsCompareNarrowBand.hpp:381
void setZRange(T minZRange, T maxZRange)
Set the z-coordinate range to restrict the comparison area.
Definition lsCompareNarrowBand.hpp:185
Calculate distance measure between two level sets by comparing their SDF values on a sparse field....
Definition lsCompareSparseField.hpp:34
unsigned getNumPoints() const
Return the number of points used in the comparison.
Definition lsCompareSparseField.hpp:398
T getRMSE() const
Calculate the root mean square error from previously computed values.
Definition lsCompareSparseField.hpp:404
void setXRange(T minXRange, T maxXRange)
Set the x-coordinate range to restrict the comparison area.
Definition lsCompareSparseField.hpp:155
void setExpandedLevelSetWidth(int width)
Set the expansion width for the expanded level set This value will be used if the expanded level set ...
Definition lsCompareSparseField.hpp:209
void setOutputMesh(SmartPointer< Mesh< T > > passedMesh)
Set the output mesh where difference values will be stored.
Definition lsCompareSparseField.hpp:197
void setLevelSetIterated(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsCompareSparseField.hpp:150
unsigned getNumSkippedPoints() const
Return the number of skipped points during the comparison.
Definition lsCompareSparseField.hpp:401
void setYRange(T minYRange, T maxYRange)
Set the y-coordinate range to restrict the comparison area.
Definition lsCompareSparseField.hpp:162
void setLevelSetExpanded(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsCompareSparseField.hpp:146
void setFillIteratedWithDistances(bool fill)
Set whether to fill the iterated level set with distances.
Definition lsCompareSparseField.hpp:202
T getSumSquaredDifferences() const
Return the sum of squared differences calculated by apply().
Definition lsCompareSparseField.hpp:392
T getSumDifferences() const
Return the sum of differences calculated by apply().
Definition lsCompareSparseField.hpp:395
void clearZRange()
Clear the z-range restriction.
Definition lsCompareSparseField.hpp:190
void clearYRange()
Clear the y-range restriction.
Definition lsCompareSparseField.hpp:176
void apply()
Apply the comparison and calculate the sum of squared differences.
Definition lsCompareSparseField.hpp:220
void clearXRange()
Clear the x-range restriction.
Definition lsCompareSparseField.hpp:169
void setZRange(T minZRange, T maxZRange)
Set the z-coordinate range to restrict the comparison area.
Definition lsCompareSparseField.hpp:183
Computes an estimate of the volume/area where two level sets differ. The volume is calculated by iter...
Definition lsCompareVolume.hpp:25
void setOutputMesh(SmartPointer< Mesh< T > > passedMesh)
Set the output mesh where difference areas will be stored for visualization. Each cell in the mesh wi...
Definition lsCompareVolume.hpp:171
unsigned long int getCellCount() const
Returns the number of cells where the level sets differ.
Definition lsCompareVolume.hpp:193
void setXRangeAndIncrement(hrleIndexType minXRange, hrleIndexType maxXRange, unsigned short int Xincrement)
Sets the x-range and custom increment value.
Definition lsCompareVolume.hpp:141
void setLevelSetTarget(SmartPointer< Domain< T, D > > passedLevelSet)
Sets the target level set.
Definition lsCompareVolume.hpp:126
void apply()
Computes the volume/area difference between the two level sets.
Definition lsCompareVolume.hpp:202
double getAreaMismatch() const
Alias for getVolumeMismatch for 2D compatibility.
Definition lsCompareVolume.hpp:181
void setYRangeAndIncrement(hrleIndexType minYRange, hrleIndexType maxYRange, unsigned short int Yincrement)
Sets the y-range and custom increment value.
Definition lsCompareVolume.hpp:150
void setZRangeAndIncrement(hrleIndexType minZRange, hrleIndexType maxZRange, unsigned short int Zincrement)
Sets the z-range and custom increment value.
Definition lsCompareVolume.hpp:159
void setDefaultIncrement(unsigned short int increment)
Set default increment value.
Definition lsCompareVolume.hpp:136
double getCustomVolumeMismatch() const
Returns the computed volume/area mismatch, with custom increments applied.
Definition lsCompareVolume.hpp:184
unsigned long int getCustomCellCount() const
Returns the number of cells where the level sets differ, with custom increments applied.
Definition lsCompareVolume.hpp:197
double getVolumeMismatch() const
Returns the computed volume/area mismatch.
Definition lsCompareVolume.hpp:176
void setLevelSetSample(SmartPointer< Domain< T, D > > passedLevelSet)
Sets the sample level set.
Definition lsCompareVolume.hpp:131
double getCustomAreaMismatch() const
Alias for getCustomVolumeMismatch for 2D compatibility.
Definition lsCompareVolume.hpp:190
This algorithm creates a convex hull mesh from a point cloud. This is done using the gift wrapping ap...
Definition lsConvexHull.hpp:23
void apply()
Definition lsConvexHull.hpp:332
void setMesh(SmartPointer< Mesh< T > > passedMesh)
Definition lsConvexHull.hpp:326
void setPointCloud(SmartPointer< PointCloud< T, D > > passedPointCloud)
Definition lsConvexHull.hpp:328
Definition lsGeometricAdvectDistributions.hpp:185
T getSignedDistance(const Vec3D< viennahrle::CoordType > &initial, const Vec3D< viennahrle::CoordType > &candidate, unsigned long pointId) const override
Returns the signed distance of a point relative to the distributions center. This is the signed manha...
Definition lsGeometricAdvectDistributions.hpp:198
std::array< viennahrle::CoordType, 6 > getBounds() const override
Sets bounds to the bounding box of the distribution.
Definition lsGeometricAdvectDistributions.hpp:242
Class describing a square box from one coordinate to another.
Definition lsGeometries.hpp:100
This class detects features of the level set function. This class offers two methods to determine fea...
Definition lsDetectFeatures.hpp:26
void apply()
Execute the algorithm.
Definition lsDetectFeatures.hpp:64
void setDetectionThreshold(T threshold)
Definition lsDetectFeatures.hpp:51
void setDetectionMethod(FeatureDetectionEnum passedMethod)
Set which algorithm to use to detect features. The curvature-based algorithm should always be preferr...
Definition lsDetectFeatures.hpp:59
Class containing all information about the level set, including the dimensions of the domain,...
Definition lsDomain.hpp:28
void clearMetaData()
Definition lsDomain.hpp:164
void deepCopy(const SmartPointer< Domain< T, D > > passedDomain)
copy all values of "passedDomain" to this Domain
Definition lsDomain.hpp:125
unsigned getNumberOfSegments() const
returns the number of segments, the levelset is split into. This is useful for algorithm parallelisat...
Definition lsDomain.hpp:154
void print(std::ostream &out=std::cout)
prints basic information and all memebers of the levelset structure
Definition lsDomain.hpp:179
int getLevelSetWidth() const
Definition lsDomain.hpp:159
unsigned getNumberOfPoints() const
returns the number of defined points
Definition lsDomain.hpp:157
void setLevelSetWidth(int width)
Definition lsDomain.hpp:161
Expands the levelSet to the specified number of layers. The largest value in the levelset is thus wid...
Definition lsExpand.hpp:17
void apply()
Apply the expansion to the specified width.
Definition lsExpand.hpp:44
void setWidth(int passedWidth)
Set how far the level set should be extended. Points with value width*0.5 will be added by this algor...
Definition lsExpand.hpp:37
void setLevelSet(SmartPointer< Domain< T, D > > passedlsDomain)
Definition lsExpand.hpp:31
Import the regular grid, on which the level set values are defined, from an explicit Mesh<>....
Definition lsFromMesh.hpp:16
void setMesh(const SmartPointer< Mesh< T > > passedMesh)
Definition lsFromMesh.hpp:34
void setSortPointList(bool passedSortPointList)
Definition lsFromMesh.hpp:36
void apply()
Definition lsFromMesh.hpp:40
Construct a level set from an explicit mesh.
Definition lsFromSurfaceMesh.hpp:15
void setRemoveBoundaryTriangles(bool passedRemoveBoundaryTriangles)
Set whether all triangles outside the domain should be ignored (=true) or whether boundary conditions...
Definition lsFromSurfaceMesh.hpp:227
void setLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsFromSurfaceMesh.hpp:218
void apply()
Definition lsFromSurfaceMesh.hpp:243
void setMesh(SmartPointer< Mesh< T > > passedMesh)
Definition lsFromSurfaceMesh.hpp:222
This class creates a level set from a tetrahedral mesh. If the mesh contains a scalar data array call...
Definition lsFromVolumeMesh.hpp:22
typename Domain< T, D >::GridType GridType
Definition lsFromVolumeMesh.hpp:26
void apply()
Definition lsFromVolumeMesh.hpp:56
void setMesh(SmartPointer< Mesh< T > > passedMesh)
Definition lsFromVolumeMesh.hpp:48
void setGrid(const GridType &passedGrid)
Definition lsFromVolumeMesh.hpp:43
void setRemoveBoundaryTriangles(bool passedRemoveBoundaryTriangles)
Definition lsFromVolumeMesh.hpp:50
Base class for distributions used by lsGeometricAdvect. All functions are pure virtual and must be im...
Definition lsGeometricAdvectDistributions.hpp:15
virtual void prepare(SmartPointer< Domain< T, D > > domain)
Definition lsGeometricAdvectDistributions.hpp:43
virtual bool isInside(const Vec3D< viennahrle::CoordType > &initial, const Vec3D< viennahrle::CoordType > &candidate, double eps) const
Quick check whether a point relative to the distributions center is inside the distribution....
Definition lsGeometricAdvectDistributions.hpp:23
virtual T getSignedDistance(const Vec3D< viennahrle::CoordType > &initial, const Vec3D< viennahrle::CoordType > &candidate, unsigned long pointId) const =0
Returns the signed distance of a point relative to the distributions center. This is the signed manha...
virtual void finalize()
Definition lsGeometricAdvectDistributions.hpp:44
virtual std::array< viennahrle::CoordType, 6 > getBounds() const =0
Sets bounds to the bounding box of the distribution.
This class advects the level set according to a given distribution. This distribution is overlayed at...
Definition lsGeometricAdvect.hpp:35
void setLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Set the levelset which should be advected.
Definition lsGeometricAdvect.hpp:76
void apply()
Perform geometrical advection.
Definition lsGeometricAdvect.hpp:95
void setAdvectionDistribution(SmartPointer< GeometricAdvectDistribution< T, D > > passedDist)
Set which advection distribution to use. Must be derived from GeometricAdvectDistribution.
Definition lsGeometricAdvect.hpp:82
Create level sets describing basic geometric forms.
Definition lsMakeGeometry.hpp:27
void setIgnoreBoundaryConditions(bool passedIgnoreBoundaryConditions)
Ignore boundary conditions, meaning the parts of the generated geometry which are outside of the doma...
Definition lsMakeGeometry.hpp:127
void apply()
Definition lsMakeGeometry.hpp:144
void setLevelSet(SmartPointer< Domain< T, D > > passedlsDomain)
Definition lsMakeGeometry.hpp:87
void setGeometry(SmartPointer< Sphere< T, D > > passedSphere)
Set sphere as geometry to be created in the level set.
Definition lsMakeGeometry.hpp:92
This class is used to mark points of the level set which are enclosed in a void.
Definition lsMarkVoidPoints.hpp:28
void setLevelSet(SmartPointer< Domain< T, D > > passedlsDomain)
Definition lsMarkVoidPoints.hpp:95
void setReverseVoidDetection(bool passedReverseVoidDetection)
Set whether the "top" level set should be the most positive(default) connected chain of level set val...
Definition lsMarkVoidPoints.hpp:103
void apply()
Definition lsMarkVoidPoints.hpp:154
void setSaveComponentIds(bool scid)
Set whether the connected component IDs used to generate the void points should be saved....
Definition lsMarkVoidPoints.hpp:150
void setDetectLargestSurface(bool passedDetect)
Set whether the number of points of one connected surface should be used to detect void points....
Definition lsMarkVoidPoints.hpp:113
void setVoidTopSurface(VoidTopSurfaceEnum topSurface)
Set which connected component to use as the top surface and mark all other components as void points.
Definition lsMarkVoidPoints.hpp:119
std::size_t getNumberOfComponents() const
Definition lsMarkVoidPoints.hpp:152
This class holds an explicit mesh, which is always given in 3 dimensions. If it describes a 2D mesh,...
Definition lsMesh.hpp:22
Class describing a plane via a point in it and the plane normal.
Definition lsGeometries.hpp:42
Class describing a point cloud, which can be used to create geometries from its convex hull mesh.
Definition lsGeometries.hpp:145
void insertNextPoint(T *newPoint)
Definition lsGeometries.hpp:154
Removes all level set points, which do not have at least one oppositely signed neighbour (Meaning the...
Definition lsPrune.hpp:17
void apply()
removes all grid points, which do not have at least one opposite signed neighbour returns the number ...
Definition lsPrune.hpp:74
void setLevelSet(SmartPointer< Domain< T, D > > passedlsDomain)
Definition lsPrune.hpp:59
Definition lsReader.hpp:13
void setLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsReader.hpp:26
void apply()
Definition lsReader.hpp:35
void setFileName(std::string passedFileName)
set file name for file to write
Definition lsReader.hpp:31
Reduce the level set size to the specified width. This means all level set points with value <= 0....
Definition lsReduce.hpp:14
void apply()
Reduces the leveleSet to the specified number of layers. The largest value in the levelset is thus wi...
Definition lsReduce.hpp:55
void setLevelSet(SmartPointer< Domain< T, D > > passedlsDomain)
Definition lsReduce.hpp:32
void setWidth(int passedWidth)
Set which level set points should be kept. All points with a level set value >0.5*width will be remov...
Definition lsReduce.hpp:39
void setNoNewSegment(bool passedNoNewSegment)
Set whether to segment the level set after algorithm is finished. This means points will be evenly di...
Definition lsReduce.hpp:44
This algorithm can be used to remove all LS values which are not part of a so-called top surface....
Definition lsRemoveStrayPoints.hpp:17
void setVoidTopSurface(VoidTopSurfaceEnum topSurface)
Set how the algorithm should pick the surface which will not be removed. Defaults to the surface with...
Definition lsRemoveStrayPoints.hpp:33
void apply()
Definition lsRemoveStrayPoints.hpp:37
void setLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsRemoveStrayPoints.hpp:27
Concrete implementation of GeometricAdvectDistribution for a spherical advection distribution.
Definition lsGeometricAdvectDistributions.hpp:50
bool isInside(const Vec3D< viennahrle::CoordType > &initial, const Vec3D< viennahrle::CoordType > &candidate, double eps) const override
Quick check whether a point relative to the distributions center is inside the distribution....
Definition lsGeometricAdvectDistributions.hpp:60
std::array< viennahrle::CoordType, 6 > getBounds() const override
Sets bounds to the bounding box of the distribution.
Definition lsGeometricAdvectDistributions.hpp:110
T getSignedDistance(const Vec3D< viennahrle::CoordType > &initial, const Vec3D< viennahrle::CoordType > &candidate, unsigned long) const override
Returns the signed distance of a point relative to the distributions center. This is the signed manha...
Definition lsGeometricAdvectDistributions.hpp:75
Class describing a sphere via origin and radius.
Definition lsGeometries.hpp:15
This class creates a mesh from the level set with all grid points with a level set value <= 0....
Definition lsToDiskMesh.hpp:24
void clearLevelSets()
Definition lsToDiskMesh.hpp:83
void setMesh(SmartPointer< Mesh< N > > passedMesh)
Definition lsToDiskMesh.hpp:70
void setMaterialMap(SmartPointer< MaterialMap > passedMaterialMap)
Definition lsToDiskMesh.hpp:77
void apply()
Definition lsToDiskMesh.hpp:85
void insertNextLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Pushes the passed level set to the back of the list of level sets.
Definition lsToDiskMesh.hpp:66
void setMaxValue(const T passedMaxValue)
Definition lsToDiskMesh.hpp:81
void setLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsToDiskMesh.hpp:61
Extracts a hull (surface outline) mesh from a stack of level sets using ToMultiSurfaceMesh with close...
Definition lsToHullMesh.hpp:22
void setMaterialMap(SmartPointer< MaterialMap > passedMaterialMap)
Definition lsToHullMesh.hpp:430
void setMesh(SmartPointer< Mesh< T > > passedMesh)
Definition lsToHullMesh.hpp:417
void clearLevelSets()
Definition lsToHullMesh.hpp:424
void insertNextLevelSet(SmartPointer< Domain< T, D > > levelSet)
Level sets wrapping other level sets have to be inserted last.
Definition lsToHullMesh.hpp:420
void apply()
Definition lsToHullMesh.hpp:450
void setSharpCorners(bool passedSharpCorners)
Definition lsToHullMesh.hpp:426
void setBottomExtension(T extension)
Definition lsToHullMesh.hpp:434
Extract the regular grid, on which the level set values are defined, to an explicit Mesh<>....
Definition lsToMesh.hpp:19
void setOnlyDefined(bool passedOnlyDefined)
Definition lsToMesh.hpp:43
void setLevelSet(SmartPointer< Domain< T, D > > passedlsDomain)
Definition lsToMesh.hpp:37
void apply()
Definition lsToMesh.hpp:49
void setOnlyActive(bool passedOnlyActive)
Definition lsToMesh.hpp:47
void setMesh(SmartPointer< Mesh< T > > passedMesh)
Definition lsToMesh.hpp:41
Definition lsToMultiSurfaceMesh.hpp:11
void apply() override
Definition lsToMultiSurfaceMesh.hpp:623
void setMaterialMap(SmartPointer< MaterialMap > passedMaterialMap)
Definition lsToMultiSurfaceMesh.hpp:619
void clearLevelSets()
Definition lsToMultiSurfaceMesh.hpp:617
void insertNextLevelSet(SmartPointer< lsDomainType > passedLevelSet)
Definition lsToMultiSurfaceMesh.hpp:613
Extract an explicit Mesh<> instance from an lsDomain. The interface is then described by explicit sur...
Definition lsToSurfaceMesh.hpp:25
void setMesh(SmartPointer< Mesh< T > > passedMesh)
Definition lsToSurfaceMesh.hpp:95
void setUpdatePointData(bool update)
Definition lsToSurfaceMesh.hpp:97
void setSharpCorners(bool check)
Definition lsToSurfaceMesh.hpp:99
virtual void apply()
Definition lsToSurfaceMesh.hpp:101
void setLevelSet(SmartPointer< lsDomainType > passedlsDomain)
Definition lsToSurfaceMesh.hpp:90
Creates a mesh, which consists only of quads/hexas for completely filled grid cells in the level set....
Definition lsToVoxelMesh.hpp:20
void setMesh(SmartPointer< Mesh< T > > passedMesh)
Definition lsToVoxelMesh.hpp:76
void clearLevelSets()
Definition lsToVoxelMesh.hpp:74
void insertNextLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Push level set to the list of level sets used for output. If more than one are specified,...
Definition lsToVoxelMesh.hpp:70
void apply()
Definition lsToVoxelMesh.hpp:82
Abstract class defining the interface for the velocity field used during advection using lsAdvect.
Definition lsVelocityField.hpp:11
Definition lsWriter.hpp:13
void setFileName(std::string passedFileName)
set file name for file to write
Definition lsWriter.hpp:31
void setLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsWriter.hpp:26
void apply()
Definition lsWriter.hpp:35
Definition lsAdvect.hpp:41
FeatureDetectionEnum
Definition lsDetectFeatures.hpp:16
BooleanOperationEnum
Enumeration for the different types of boolean operations which are supported. When INVERT,...
Definition lsBooleanOperation.hpp:27
CurvatureEnum
Definition lsCalculateCurvatures.hpp:15
void bindApi(py::module &module)
Definition pyWrap.hpp:92
PYBIND11_DECLARE_HOLDER_TYPE(TemplateType, SmartPointer< TemplateType >)