ViennaLS
Loading...
Searching...
No Matches
pyWrap.hpp
Go to the documentation of this file.
1#include <pybind11/iostream.h>
2#include <pybind11/pybind11.h>
3#include <pybind11/stl.h>
4
5// all header files which define API functions
6#include <lsAdvect.hpp>
11#include <lsCheck.hpp>
12#include <lsCompareArea.hpp>
15#include <lsConvexHull.hpp>
16#include <lsDetectFeatures.hpp>
17#include <lsDomain.hpp>
18#include <lsExpand.hpp>
19#include <lsExtrude.hpp>
20#include <lsFileFormats.hpp>
21#include <lsFromMesh.hpp>
22#include <lsFromSurfaceMesh.hpp>
23#include <lsFromVolumeMesh.hpp>
24#include <lsGeometricAdvect.hpp>
26#include <lsGeometries.hpp>
27#include <lsMakeGeometry.hpp>
28#include <lsMarkVoidPoints.hpp>
29#include <lsMaterialMap.hpp>
30#include <lsMesh.hpp>
31#include <lsPointData.hpp>
32#include <lsPrune.hpp>
33#include <lsReader.hpp>
34#include <lsReduce.hpp>
36#include <lsSlice.hpp>
37#include <lsToDiskMesh.hpp>
38#include <lsToMesh.hpp>
40#include <lsToSurfaceMesh.hpp>
41#include <lsToVoxelMesh.hpp>
42#include <lsTransformMesh.hpp>
43#include <lsVTKReader.hpp>
44#include <lsVTKWriter.hpp>
45#include <lsVelocityField.hpp>
46#include <lsVersion.hpp>
48#include <lsWriter.hpp>
49
50#include <vcLogger.hpp>
51#include <vcSmartPointer.hpp>
52
53using namespace viennals;
54namespace py = pybind11;
55
56// always use double for python export
57typedef double T;
58
59PYBIND11_DECLARE_HOLDER_TYPE(TemplateType, SmartPointer<TemplateType>);
60
61// GeometricAdvectDistribution
62template <int D>
64 : public GeometricAdvectDistribution<T, D> {
65 typedef std::array<viennahrle::CoordType, 3> vectorType;
66 typedef std::array<viennahrle::CoordType, 6> boundsType;
67 typedef GeometricAdvectDistribution<T, D> ClassType;
69
70public:
71 bool isInside(const vectorType &initial, const vectorType &candidate,
72 double eps = 0.) const override {
73 PYBIND11_OVERLOAD(bool, ClassType, isInside, initial, candidate, eps);
74 }
75
76 T getSignedDistance(const vectorType &initial, const vectorType &candidate,
77 unsigned long initialPointId) const override {
78 PYBIND11_OVERLOAD_PURE(T, ClassType, getSignedDistance, initial, candidate,
79 initialPointId);
80 }
81
82 boundsType getBounds() const override {
83 PYBIND11_OVERLOAD_PURE(boundsType, ClassType, getBounds);
84 }
85};
86
87template <int D> void bindApi(py::module &module) {
88 // Also wrap hrleGrid so it can be used to create new LevelSets
89 py::class_<viennahrle::Grid<D>>(module, "hrleGrid");
90
91 // Domain
92 py::class_<Domain<T, D>, SmartPointer<Domain<T, D>>>(module, "Domain")
93 // constructors
94 .def(py::init(&SmartPointer<Domain<T, D>>::template New<>))
95 .def(
96 py::init(
97 &SmartPointer<Domain<T, D>>::template New<viennahrle::CoordType>),
98 py::arg("gridDelta") = 1.0)
99 // .def(py::init(
100 // &SmartPointer<Domain<T, D>>::New<viennahrle::CoordType *,
101 // BoundaryConditionEnum *>))
102 .def(py::init([](std::array<viennahrle::CoordType, 2 * D> bounds,
103 std::array<BoundaryConditionEnum, D> bcs,
104 viennahrle::CoordType gridDelta) {
105 return SmartPointer<Domain<T, D>>::New(bounds.data(), bcs.data(),
106 gridDelta);
107 }),
108 py::arg("bounds"), py::arg("boundaryConditions"),
109 py::arg("gridDelta") = 1.0)
110 .def(py::init(&SmartPointer<Domain<T, D>>::template New<
111 std::vector<viennahrle::CoordType>, std::vector<unsigned>,
112 viennahrle::CoordType>),
113 py::arg("bounds"), py::arg("boundaryConditions"),
114 py::arg("gridDelta") = 1.0)
115 // .def(py::init(
116 // &SmartPointer<Domain<T, D>>::New<Domain<T,
117 // D>::PointValueVectorType,
118 // viennahrle::CoordType *,
119 // BoundaryConditionEnum *>))
120 // .def(py::init(&SmartPointer<Domain<T, D>>::New<
121 // Domain<T, D>::PointValueVectorType,
122 // viennahrle::CoordType
123 // *, BoundaryConditionEnum *,
124 // viennahrle::CoordType>))
125 .def(py::init(&SmartPointer<Domain<T, D>>::template New<
126 SmartPointer<Domain<T, D>> &>))
127 .def(py::init(
128 &SmartPointer<Domain<T, D>>::template New<viennahrle::Grid<D> &>))
129 // methods
130 .def("deepCopy", &Domain<T, D>::deepCopy,
131 "Copy lsDomain in this lsDomain.")
132 .def("getNumberOfSegments", &Domain<T, D>::getNumberOfSegments,
133 "Get the number of segments, the level set structure is divided "
134 "into.")
135 .def("getNumberOfPoints", &Domain<T, D>::getNumberOfPoints,
136 "Get the number of defined level set values.")
137 .def("getLevelSetWidth", &Domain<T, D>::getLevelSetWidth,
138 "Get the number of layers of level set points around the explicit "
139 "surface.")
140 .def("setLevelSetWidth", &Domain<T, D>::setLevelSetWidth,
141 "Set the number of layers of level set points which should be "
142 "stored around the explicit surface.")
143 .def("clearMetaData", &Domain<T, D>::clearMetaData,
144 "Clear all metadata stored in the level set.")
145 // allow filehandle to be passed and default to python standard output
146 .def(
147 "print",
148 [](Domain<T, D> &d, py::object fileHandle) {
149 if (!(py::hasattr(fileHandle, "write") &&
150 py::hasattr(fileHandle, "flush"))) {
151 throw py::type_error(
152 "MyClass::read_from_file_like_object(file): incompatible "
153 "function argument: `file` must be a file-like object, but "
154 "`" +
155 (std::string)(py::repr(fileHandle)) + "` provided");
156 }
157 py::detail::pythonbuf buf(fileHandle);
158 std::ostream stream(&buf);
159 d.print(stream);
160 },
161 py::arg("stream") = py::module::import("sys").attr("stdout"));
162
163 // Advect
164 py::class_<Advect<T, D>, SmartPointer<Advect<T, D>>>(module, "Advect")
165 // constructors
166 .def(py::init(&SmartPointer<Advect<T, D>>::template New<>))
167 .def(py::init(&SmartPointer<Advect<T, D>>::template New<
168 SmartPointer<Domain<T, D>> &>))
169 .def(py::init(
170 &SmartPointer<Advect<T, D>>::template New<
171 SmartPointer<Domain<T, D>> &, SmartPointer<VelocityField<T>> &>))
172 // getters and setters
173 .def("insertNextLevelSet", &Advect<T, D>::insertNextLevelSet,
174 "Insert next level set to use for advection.")
175 .def("setVelocityField", &Advect<T, D>::setVelocityField,
176 "Set the velocity to use for advection.")
177 .def("setAdvectionTime", &Advect<T, D>::setAdvectionTime,
178 "Set the time until when the level set should be advected.")
179 .def("setTimeStepRatio", &Advect<T, D>::setTimeStepRatio,
180 "Set the maximum time step size relative to grid size. Advection is "
181 "only stable for <0.5.")
182 .def("setCalculateNormalVectors",
184 "Set whether normal vectors are needed for the supplied velocity "
185 "field.")
186 .def("setIgnoreVoids", &Advect<T, D>::setIgnoreVoids,
187 "Set whether voids in the geometry should be ignored during "
188 "advection or not.")
189 .def("getAdvectedTime", &Advect<T, D>::getAdvectedTime,
190 "Get the time passed during advection.")
191 .def("getNumberOfTimeSteps", &Advect<T, D>::getNumberOfTimeSteps,
192 "Get how many advection steps were performed after the last apply() "
193 "call.")
194 .def("getTimeStepRatio", &Advect<T, D>::getTimeStepRatio,
195 "Get the time step ratio used for advection.")
196 .def("getCurrentTimeStep", &Advect<T, D>::getCurrentTimeStep,
197 "Get the current time step.")
198 .def("getCalculateNormalVectors",
200 "Get whether normal vectors are computed during advection.")
201 .def("setIntegrationScheme", &Advect<T, D>::setIntegrationScheme,
202 "Set the integration scheme to use during advection.")
203 .def("setDissipationAlpha", &Advect<T, D>::setDissipationAlpha,
204 "Set the dissipation value to use for Lax Friedrichs integration.")
205 .def("prepareLS", &Advect<T, D>::prepareLS, "Prepare the level-set.")
206 // need scoped release since we are calling a python method from
207 // parallelised C++ code here
208 .def("apply", &Advect<T, D>::apply,
209 py::call_guard<py::gil_scoped_release>(), "Perform advection.")
210 .def("applyIntegration", &Advect<T, D>::applyIntegration,
211 py::call_guard<py::gil_scoped_release>(),
212 "Apply the integration scheme and calculate rates and maximum time "
213 "step, but it do **not** move the surface.");
214
215 py::class_<lsInternal::StencilLocalLaxFriedrichsScalar<T, D, 1>>(
216 module, "StencilLocalLaxFriedrichsScalar")
217 .def_static(
218 "setMaxDissipation",
220 1>::setMaxDissipation,
221 py::arg("maxDissipation"));
222
223 module.def("PrepareStencilLocalLaxFriedrichs",
224 &PrepareStencilLocalLaxFriedrichs<T, D>, py::arg("levelSets"),
225 py::arg("isDepo"));
226
227 module.def("FinalizeStencilLocalLaxFriedrichs",
228 &FinalizeStencilLocalLaxFriedrichs<T, D>, py::arg("levelSets"));
229
230 // BooleanOperation
231 py::class_<BooleanOperation<T, D>, SmartPointer<BooleanOperation<T, D>>>(
232 module, "BooleanOperation")
233 // constructors
234 .def(py::init(&SmartPointer<BooleanOperation<T, D>>::template New<>))
235 .def(py::init(&SmartPointer<BooleanOperation<T, D>>::template New<
236 SmartPointer<Domain<T, D>> &>))
237 .def(
238 py::init(&SmartPointer<BooleanOperation<T, D>>::template New<
239 SmartPointer<Domain<T, D>> &, SmartPointer<Domain<T, D>> &>))
240 // some constructors need lambda to work: seems to be an issue with
241 // implicit move constructor
242 .def(py::init(
243 [](SmartPointer<Domain<T, D>> &domain, BooleanOperationEnum op) {
244 return SmartPointer<BooleanOperation<T, D>>::New(domain, op);
245 }))
246 .def(py::init([](SmartPointer<Domain<T, D>> &domainA,
247 SmartPointer<Domain<T, D>> &domainB,
249 return SmartPointer<BooleanOperation<T, D>>::New(domainA, domainB, op);
250 }))
251 // methods
252 .def("setLevelset", &BooleanOperation<T, D>::setLevelSet,
253 "Set levelset on which the boolean operation should be performed.")
254 .def("setSecondLevelSet", &BooleanOperation<T, D>::setSecondLevelSet,
255 "Set second levelset for boolean operation.")
256 .def("setBooleanOperation", &BooleanOperation<T, D>::setBooleanOperation,
257 "Set which type of boolean operation should be performed.")
258 .def("apply", &BooleanOperation<T, D>::apply,
259 "Perform the boolean operation.");
260
261 py::class_<CalculateCurvatures<T, D>,
262 SmartPointer<CalculateCurvatures<T, D>>>(module,
263 "CalculateCurvatures")
264 // constructors
265 .def(py::init(&SmartPointer<CalculateCurvatures<T, D>>::template New<>))
266 .def(py::init(&SmartPointer<CalculateCurvatures<T, D>>::template New<
267 SmartPointer<Domain<T, D>> &>))
268 // some constructors need lambda to work: seems to be an issue with
269 // implicit move constructor
270 .def(py::init([](SmartPointer<Domain<T, D>> &domain, CurvatureEnum type) {
271 return SmartPointer<CalculateCurvatures<T, D>>::New(domain, type);
272 }))
273 // methods
274 .def("setLevelSet", &CalculateCurvatures<T, D>::setLevelSet,
275 "Set levelset for which to calculate the curvatures.")
276 .def("setCurvatureType", &CalculateCurvatures<T, D>::setCurvatureType,
277 "Set which method to use for calculation: Defaults to mean "
278 "curvature.")
279 .def("setMaxValue", &CalculateCurvatures<T, D>::setMaxValue,
280 "Curvatures will be calculated for all LS values < maxValue.")
282 "Perform normal vector calculation.");
283
284 // CalculateNormalVectors
285 py::class_<CalculateNormalVectors<T, D>,
286 SmartPointer<CalculateNormalVectors<T, D>>>(
287 module, "CalculateNormalVectors")
288 // constructors
289 .def(
290 py::init(&SmartPointer<CalculateNormalVectors<T, D>>::template New<>))
291 .def(py::init(&SmartPointer<CalculateNormalVectors<T, D>>::template New<
292 SmartPointer<Domain<T, D>> &>))
293 // methods
295 "Set levelset for which to calculate normal vectors.")
297 "Perform normal vector calculation.");
298
299 // CalculateVisibilities
300 py::class_<CalculateVisibilities<T, D>,
301 SmartPointer<CalculateVisibilities<T, D>>>(module,
302 "CalculateVisibilities")
303 .def(py::init(
304 &SmartPointer<CalculateVisibilities<T, D>>::template New<
305 SmartPointer<Domain<T, D>> &, const Vec3D<T> &, std::string>))
307
308 // Check
309 py::class_<Check<T, D>, SmartPointer<Check<T, D>>>(module, "Check")
310 // constructors
311 .def(py::init(&SmartPointer<Check<T, D>>::template New<>))
312 .def(py::init(&SmartPointer<Check<T, D>>::template New<
313 SmartPointer<Domain<T, D>> &>))
314 // methods
315 .def("setLevelSet", &Check<T, D>::setLevelSet,
316 "Set levelset for which to calculate normal vectors.")
317 .def("apply", &Check<T, D>::apply, "Perform check.");
318
319 // PointCloud
320 py::class_<PointCloud<T, D>, SmartPointer<PointCloud<T, D>>>(module,
321 "PointCloud")
322 // constructors
323 .def(py::init(&SmartPointer<PointCloud<T, D>>::template New<
324 const std::vector<VectorType<T, D>> &>))
325 // methods
326 .def("insertNextPoint",
327 (void(PointCloud<T, D>::*)(const VectorType<T, D> &)) &
329
330 // ConvexHull
331 py::class_<ConvexHull<T, D>, SmartPointer<ConvexHull<T, D>>>(module,
332 "ConvexHull")
333 // constructors
334 .def(py::init(&SmartPointer<ConvexHull<T, D>>::template New<>))
335 .def(py::init(&SmartPointer<ConvexHull<T, D>>::template New<
336 SmartPointer<Mesh<T>> &, SmartPointer<PointCloud<T, D>> &>))
337 // methods
338 .def("setMesh", &ConvexHull<T, D>::setMesh,
339 "Set mesh object where the generated mesh should be stored.")
340 .def("setPointCloud", &ConvexHull<T, D>::setPointCloud,
341 "Set point cloud used to generate mesh.")
342 .def("apply", &ConvexHull<T, D>::apply, "Generate Hull.");
343
344 // DetectFeatures
345 py::class_<DetectFeatures<T, D>, SmartPointer<DetectFeatures<T, D>>>(
346 module, "DetectFeatures")
347 // constructors
348 .def(py::init(&SmartPointer<DetectFeatures<T, D>>::template New<>))
349 .def(py::init(&SmartPointer<DetectFeatures<T, D>>::template New<
350 SmartPointer<Domain<T, D>> &>))
351 .def(py::init(&SmartPointer<DetectFeatures<T, D>>::template New<
352 SmartPointer<Domain<T, D>> &, T>))
353 // some constructors need lambda to work: seems to be an issue with
354 // implicit move constructor
355 .def(py::init([](SmartPointer<Domain<T, D>> &domain, T maxValue,
357 return SmartPointer<DetectFeatures<T, D>>::New(domain, maxValue, type);
358 }))
359 .def("setDetectionThreshold",
361 "Set the curvature value above which a point is considered a "
362 "feature.")
363 .def("setDetectionMethod", &DetectFeatures<T, D>::setDetectionMethod,
364 "Set which method to use to detect features. Defaults to Curvature.")
365 .def("apply", &DetectFeatures<T, D>::apply, "Detect features.");
366
367 // GeometricAdvect
368 py::class_<GeometricAdvect<T, D>, SmartPointer<GeometricAdvect<T, D>>>(
369 module, "GeometricAdvect")
370 // constructors
371 .def(py::init(&SmartPointer<GeometricAdvect<T, D>>::template New<>))
372 .def(py::init(
373 &SmartPointer<GeometricAdvect<T, D>>::template New<
374 SmartPointer<Domain<T, D>> &,
375 SmartPointer<
377 // methods
378 .def("setLevelSet", &GeometricAdvect<T, D>::setLevelSet,
379 "Set levelset to advect.")
380 .def(
381 "setAdvectionDistribution",
383 "Set advection distribution to use as kernel for the fast advection.")
384 .def("apply", &GeometricAdvect<T, D>::apply,
385 py::call_guard<py::gil_scoped_release>(), "Perform advection.");
386
387 // GeometricAdvectDistributions
388 py::class_<GeometricAdvectDistribution<T, D>,
389 SmartPointer<GeometricAdvectDistribution<T, D>>,
391 "GeometricAdvectDistribution")
392 // constructors
393 .def(py::init<>())
394 // methods
396 "Check whether passed point is inside the distribution.")
397 .def("getSignedDistance",
399 "Get the signed distance of the passed point to the surface of the "
400 "distribution.")
402 "Get the cartesian bounds of the distribution.")
404 "Prepare the distribution for use with the passed level set.")
406 "Finalize the distribution after use with the level set.");
407
408 py::class_<SphereDistribution<T, D>, SmartPointer<SphereDistribution<T, D>>,
409 GeometricAdvectDistribution<T, D>>(module, "SphereDistribution")
410 // constructors
411 .def(py::init(&SmartPointer<SphereDistribution<T, D>>::template New<T>))
412 // methods
413 .def("isInside", &SphereDistribution<T, D>::isInside,
414 "Check whether passed point is inside the distribution.")
415 .def("getSignedDistance", &SphereDistribution<T, D>::getSignedDistance,
416 "Get the signed distance of the passed point to the surface of the "
417 "distribution.")
418 .def("getBounds", &SphereDistribution<T, D>::getBounds,
419 "Get the cartesian bounds of the distribution.");
420
421 py::class_<BoxDistribution<T, D>, SmartPointer<BoxDistribution<T, D>>,
422 GeometricAdvectDistribution<T, D>>(module, "BoxDistribution")
423 // constructors
424 .def(py::init(&SmartPointer<BoxDistribution<T, D>>::template New<
425 const std::array<T, 3>>))
426 // methods
427 .def("isInside", &BoxDistribution<T, D>::isInside,
428 "Check whether passed point is inside the distribution.")
429 .def("getSignedDistance", &BoxDistribution<T, D>::getSignedDistance,
430 "Get the signed distance of the passed point to the surface of the "
431 "distribution.")
432 .def("getBounds", &BoxDistribution<T, D>::getBounds,
433 "Get the cartesian bounds of the distribution.");
434
435 py::class_<CustomSphereDistribution<T, D>,
436 SmartPointer<CustomSphereDistribution<T, D>>,
438 "CustomSphereDistribution")
439 // constructors
440 .def(py::init(&SmartPointer<CustomSphereDistribution<T, D>>::template New<
441 const std::vector<T> &>))
442 // methods
444 "Check whether passed point is inside the distribution.")
445 .def("getSignedDistance",
447 "Get the signed distance of the passed point to the surface of the "
448 "distribution.")
450 "Get the cartesian bounds of the distribution.");
451
452 // Expand
453 py::class_<Expand<T, D>, SmartPointer<Expand<T, D>>>(module, "Expand")
454 // constructors
455 .def(py::init(&SmartPointer<Expand<T, D>>::template New<>))
456 .def(py::init(&SmartPointer<Expand<T, D>>::template New<
457 SmartPointer<Domain<T, D>> &>))
458 .def(py::init(&SmartPointer<Expand<T, D>>::template New<
459 SmartPointer<Domain<T, D>> &, int>))
460 // methods
461 .def("setLevelSet", &Expand<T, D>::setLevelSet, "Set levelset to expand.")
462 .def("setWidth", &Expand<T, D>::setWidth, "Set the width to expand to.")
463 .def("apply", &Expand<T, D>::apply, "Perform expansion.");
464
465 // FromSurfaceMesh
466 py::class_<FromSurfaceMesh<T, D>, SmartPointer<FromSurfaceMesh<T, D>>>(
467 module, "FromSurfaceMesh")
468 // constructors
469 .def(py::init(&SmartPointer<FromSurfaceMesh<T, D>>::template New<>))
470 .def(py::init(&SmartPointer<FromSurfaceMesh<T, D>>::template New<
471 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &>))
472 .def(py::init(
473 &SmartPointer<FromSurfaceMesh<T, D>>::template New<
474 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &, bool>))
475 // methods
476 .def("setLevelSet", &FromSurfaceMesh<T, D>::setLevelSet,
477 "Set levelset to read into.")
478 .def("setMesh", &FromSurfaceMesh<T, D>::setMesh,
479 "Set the mesh to read from.")
480 .def("setRemoveBoundaryTriangles",
481 static_cast<void (FromSurfaceMesh<T, D>::*)(bool)>(
483 "Set whether to include mesh elements outside of the simulation "
484 "domain.")
485 .def("setRemoveBoundaryTriangles",
486 static_cast<void (FromSurfaceMesh<T, D>::*)(std::array<bool, 3>)>(
488 "Set whether to include mesh elements outside of the simulation "
489 "domain.")
490 .def("apply", &FromSurfaceMesh<T, D>::apply,
491 "Construct a levelset from a surface mesh.");
492
493 // FromVolumeMesh
494 py::class_<FromVolumeMesh<T, D>, SmartPointer<FromVolumeMesh<T, D>>>(
495 module, "FromVolumeMesh")
496 // constructors
497 .def(py::init(&SmartPointer<FromVolumeMesh<T, D>>::template New<>))
498 .def(py::init(&SmartPointer<FromVolumeMesh<T, D>>::template New<
500 SmartPointer<Mesh<T>> &>))
501 .def(py::init(&SmartPointer<FromVolumeMesh<T, D>>::template New<
503 SmartPointer<Mesh<T>> &, bool>))
504 // methods
505 .def("setGrid", &FromVolumeMesh<T, D>::setGrid,
506 "Set the grid used to read in the level sets.")
507 .def("setMesh", &FromVolumeMesh<T, D>::setMesh,
508 "Set the mesh to read from.")
509 .def("setRemoveBoundaryTriangles",
511 "Set whether to include mesh elements outside of the simulation "
512 "domain.")
513 .def("apply", &FromVolumeMesh<T, D>::apply,
514 "Construct a levelset from a volume mesh.");
515
516 // FromMesh
517 py::class_<FromMesh<T, D>, SmartPointer<FromMesh<T, D>>>(module, "FromMesh")
518 .def(py::init(&SmartPointer<FromMesh<T, D>>::template New<>))
519 .def(py::init(&SmartPointer<FromMesh<T, D>>::template New<
520 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &>))
521 .def("setMesh", &FromMesh<T, D>::setMesh, "Set the mesh to read from.")
522 .def("setSortPointList", &FromMesh<T, D>::setSortPointList)
523 .def("apply", &FromMesh<T, D>::apply);
524
525 // lsGeometries
526 // Sphere
527 py::class_<Sphere<T, D>, SmartPointer<Sphere<T, D>>>(module, "Sphere")
528 // constructors
529 .def(py::init(&SmartPointer<Sphere<T, D>>::template New<
530 const std::vector<T> & /*origin*/, T /*radius*/>),
531 py::arg("origin"), py::arg("radius"));
532 // Plane
533 py::class_<Plane<T, D>, SmartPointer<Plane<T, D>>>(module, "Plane")
534 // constructors
535 .def(py::init(&SmartPointer<Plane<T, D>>::template New<
536 const std::vector<T> & /*origin*/,
537 const std::vector<T> & /*normal*/>),
538 py::arg("origin"), py::arg("normal"));
539 // Box
540 py::class_<Box<T, D>, SmartPointer<Box<T, D>>>(module, "Box")
541 // constructors
542 .def(py::init(&SmartPointer<Box<T, D>>::template New<
543 const std::vector<T> & /*minPoint*/,
544 const std::vector<T> & /*maxPoint*/>),
545 py::arg("minPoint"), py::arg("maxPoint"));
546 // Cylinder
547 py::class_<Cylinder<T, D>, SmartPointer<Cylinder<T, D>>>(module, "Cylinder")
548 // constructors
549 .def(
550 py::init(&SmartPointer<Cylinder<T, D>>::template New<
551 const std::vector<T> & /*origin*/,
552 const std::vector<T> & /*axisDirection*/, const T /*height*/,
553 const T /*radius*/, const T /*topRadius*/>),
554 py::arg("origin"), py::arg("axisDirection"), py::arg("height"),
555 py::arg("radius"), py::arg("topRadius") = 0.);
556
557 // MakeGeometry
558 py::class_<MakeGeometry<T, D>, SmartPointer<MakeGeometry<T, D>>>(
559 module, "MakeGeometry")
560 // constructors
561 .def(py::init(&SmartPointer<MakeGeometry<T, D>>::template New<>))
562 .def(py::init(&SmartPointer<MakeGeometry<T, D>>::template New<
563 SmartPointer<Domain<T, D>> &>))
564 .def(
565 py::init(&SmartPointer<MakeGeometry<T, D>>::template New<
566 SmartPointer<Domain<T, D>> &, SmartPointer<Sphere<T, D>> &>))
567 .def(py::init(&SmartPointer<MakeGeometry<T, D>>::template New<
568 SmartPointer<Domain<T, D>> &, SmartPointer<Plane<T, D>> &>))
569 .def(py::init(&SmartPointer<MakeGeometry<T, D>>::template New<
570 SmartPointer<Domain<T, D>> &, SmartPointer<Box<T, D>> &>))
571 .def(py::init(
572 &SmartPointer<MakeGeometry<T, D>>::template New<
573 SmartPointer<Domain<T, D>> &, SmartPointer<Cylinder<T, D>> &>))
574 .def(py::init(
575 &SmartPointer<MakeGeometry<T, D>>::template New<
576 SmartPointer<Domain<T, D>> &, SmartPointer<PointCloud<T, D>> &>))
577 // methods
578 .def("setLevelSet", &MakeGeometry<T, D>::setLevelSet,
579 "Set the levelset in which to create the geometry.")
580 .def("setGeometry",
581 (void(MakeGeometry<T, D>::*)(SmartPointer<Sphere<T, D>>)) &
583 .def("setGeometry",
584 (void(MakeGeometry<T, D>::*)(SmartPointer<Plane<T, D>>)) &
586 .def("setGeometry",
587 (void(MakeGeometry<T, D>::*)(SmartPointer<Box<T, D>>)) &
589 .def("setGeometry",
590 (void(MakeGeometry<T, D>::*)(SmartPointer<Cylinder<T, D>>)) &
592 .def("setGeometry",
593 (void(MakeGeometry<T, D>::*)(SmartPointer<PointCloud<T, D>>)) &
595 .def("setIgnoreBoundaryConditions",
596 (void(MakeGeometry<T, D>::*)(bool)) &
598 .def("setIgnoreBoundaryConditions",
599 (void(MakeGeometry<T, D>::*)(std::array<bool, 3>)) &
601 .def("apply", &MakeGeometry<T, D>::apply, "Generate the geometry.");
602
603 // MarkVoidPoints
604 py::class_<MarkVoidPoints<T, D>, SmartPointer<MarkVoidPoints<T, D>>>(
605 module, "MarkVoidPoints")
606 // constructors
607 .def(py::init(&SmartPointer<MarkVoidPoints<T, D>>::template New<>))
608 .def(py::init(&SmartPointer<MarkVoidPoints<T, D>>::template New<
609 SmartPointer<Domain<T, D>> &>))
610 .def(py::init(&SmartPointer<MarkVoidPoints<T, D>>::template New<
611 SmartPointer<Domain<T, D>> &, bool &>))
612 // methods
613 .def("setLevelSet", &MarkVoidPoints<T, D>::setLevelSet,
614 "Set the levelset to mark void points in.")
615 .def("setReverseVoidDetection",
617 "Reverse the logic of detecting the top surface.")
618 .def("setDetectLargestSurface",
620 "Set that the top surface should be the one with the most connected "
621 "LS points.")
622 .def("setVoidTopSurface", &MarkVoidPoints<T, D>::setVoidTopSurface,
623 "Set the logic by which to choose the surface which is non-void. "
624 "All other connected surfaces will then be marked as void points.")
625 .def("setSaveComponentsId", &MarkVoidPoints<T, D>::setSaveComponentIds,
626 "Save the connectivity information of all LS points in the "
627 "pointData of the level set.")
628 .def("apply", &MarkVoidPoints<T, D>::apply, "Mark void points.");
629
630 // Prune
631 py::class_<Prune<T, D>, SmartPointer<Prune<T, D>>>(module, "Prune")
632 // constructors
633 .def(py::init(&SmartPointer<Prune<T, D>>::template New<>))
634 .def(py::init(&SmartPointer<Prune<T, D>>::template New<
635 SmartPointer<Domain<T, D>> &>))
636 // methods
637 .def("setLevelSet", &Prune<T, D>::setLevelSet, "Set levelset to prune.")
638 .def("apply", &Prune<T, D>::apply, "Perform pruning operation.");
639
640 // Reader
641 py::class_<Reader<T, D>, SmartPointer<Reader<T, D>>>(module, "Reader")
642 // constructors
643 .def(py::init(&SmartPointer<Reader<T, D>>::template New<>))
644 .def(py::init(&SmartPointer<Reader<T, D>>::template New<
645 SmartPointer<Domain<T, D>> &>))
646 .def(py::init(&SmartPointer<Reader<T, D>>::template New<
647 SmartPointer<Domain<T, D>> &, std::string>))
648 // methods
649 .def("setLevelSet", &Reader<T, D>::setLevelSet,
650 "Set levelset to write to file.")
651 .def("setFileName", &Reader<T, D>::setFileName,
652 "Set the filename for the output file.")
653 .def("apply", &Reader<T, D>::apply, "Write to file.");
654
655 // Reduce
656 py::class_<Reduce<T, D>, SmartPointer<Reduce<T, D>>>(module, "Reduce")
657 // constructors
658 .def(py::init(&SmartPointer<Reduce<T, D>>::template New<>))
659 .def(py::init(&SmartPointer<Reduce<T, D>>::template New<
660 SmartPointer<Domain<T, D>> &>))
661 .def(py::init(&SmartPointer<Reduce<T, D>>::template New<
662 SmartPointer<Domain<T, D>> &, int>))
663 .def(py::init(&SmartPointer<Reduce<T, D>>::template New<
664 SmartPointer<Domain<T, D>> &, int, bool>))
665 // methods
666 .def("setLevelSet", &Reduce<T, D>::setLevelSet, "Set levelset to reduce.")
667 .def("setWidth", &Reduce<T, D>::setWidth, "Set the width to reduce to.")
668 .def("setNoNewSegment", &Reduce<T, D>::setNoNewSegment,
669 "Set whether the levelset should be segmented anew (balanced across "
670 "cores) after reduction.")
671 .def("apply", &Reduce<T, D>::apply, "Perform reduction.");
672
673 // RemoveStrayPoints
674 py::class_<RemoveStrayPoints<T, D>, SmartPointer<RemoveStrayPoints<T, D>>>(
675 module, "RemoveStrayPoints")
676 // constructors
677 .def(py::init(&SmartPointer<RemoveStrayPoints<T, D>>::template New<>))
678 .def(py::init(&SmartPointer<RemoveStrayPoints<T, D>>::template New<
679 SmartPointer<Domain<T, D>> &>))
680 // methods
681 .def("setLevelSet", &RemoveStrayPoints<T, D>::setLevelSet,
682 "Set levelset for stray point removal.")
683 .def("setVoidTopSurface", &RemoveStrayPoints<T, D>::setVoidTopSurface,
684 "Set the logic by which to choose the surface which should be kept. "
685 "All other LS values will be marked as stray points and removed.")
686 .def("apply", &RemoveStrayPoints<T, D>::apply, "Remove stray points.");
687
688 // ToDiskMesh
689 py::class_<ToDiskMesh<T, D>, SmartPointer<ToDiskMesh<T, D>>>(module,
690 "ToDiskMesh")
691 // constructors
692 .def(py::init(&SmartPointer<ToDiskMesh<T, D>>::template New<>))
693 .def(py::init(&SmartPointer<ToDiskMesh<T, D>>::template New<
694 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &>))
695 // methods
696 .def("setLevelSet", &ToDiskMesh<T, D>::setLevelSet,
697 "Set levelset to mesh.")
698 .def("setMesh", &ToDiskMesh<T, D>::setMesh, "Set the mesh to generate.")
699 .def("setMaterialMap", &ToDiskMesh<T, D>::setMaterialMap,
700 "Set the material map to use for the disk mesh.")
701 .def("setMaxValue", &ToDiskMesh<T, D>::setMaxValue,
702 "Set the maximum level set value to include in the disk mesh.")
703 .def("apply", &ToDiskMesh<T, D>::apply,
704 "Convert the levelset to a surface mesh.");
705
706 // ToMesh
707 py::class_<ToMesh<T, D>, SmartPointer<ToMesh<T, D>>>(module, "ToMesh")
708 // constructors
709 .def(py::init(&SmartPointer<ToMesh<T, D>>::template New<>))
710 .def(py::init(&SmartPointer<ToMesh<T, D>>::template New<
711 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &>))
712 .def(py::init(
713 &SmartPointer<ToMesh<T, D>>::template New<
714 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &, bool>))
715 .def(py::init(&SmartPointer<ToMesh<T, D>>::template New<
716 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &, bool,
717 bool>))
718 // methods
719 .def("setLevelSet", &ToMesh<T, D>::setLevelSet, "Set levelset to mesh.")
720 .def("setMesh", &ToMesh<T, D>::setMesh, "Set the mesh to generate.")
721 .def("setOnlyDefined", &ToMesh<T, D>::setOnlyDefined,
722 "Set whether only defined points should be output to the mesh.")
723 .def("setOnlyActive", &ToMesh<T, D>::setOnlyActive,
724 "Set whether only level set points <0.5 should be output.")
725 .def("apply", &ToMesh<T, D>::apply,
726 "Convert the levelset to a surface mesh.");
727
728 // ToSurfaceMesh
729 py::class_<ToSurfaceMesh<T, D>, SmartPointer<ToSurfaceMesh<T, D>>>(
730 module, "ToSurfaceMesh")
731 // constructors
732 .def(py::init(&SmartPointer<ToSurfaceMesh<T, D>>::template New<>))
733 .def(py::init(&SmartPointer<ToSurfaceMesh<T, D>>::template New<
734 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &>))
735 // methods
736 .def("setLevelSet", &ToSurfaceMesh<T, D>::setLevelSet,
737 "Set levelset to mesh.")
738 .def("setMesh", &ToSurfaceMesh<T, D>::setMesh,
739 "Set the mesh to generate.")
740 .def("apply", &ToSurfaceMesh<T, D>::apply,
741 "Convert the levelset to a surface mesh.");
742
743 // ToMultiSurfaceMesh
744 py::class_<ToMultiSurfaceMesh<T, D>, SmartPointer<ToMultiSurfaceMesh<T, D>>>(
745 module, "ToMultiSurfaceMesh")
746 // constructors
747 .def(py::init(&SmartPointer<ToMultiSurfaceMesh<T, D>>::template New<>))
748 .def(py::init(&SmartPointer<ToMultiSurfaceMesh<T, D>>::template New<
749 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &>))
750 .def(py::init(&SmartPointer<ToMultiSurfaceMesh<T, D>>::template New<
751 SmartPointer<Mesh<T>> &>))
752 // methods
753 .def("insertNextLevelSet", &ToMultiSurfaceMesh<T, D>::insertNextLevelSet,
754 "Insert next level set to output in the mesh.")
755 .def("setMesh", &ToMultiSurfaceMesh<T, D>::setMesh,
756 "Set the mesh to generate.")
757 .def("setMaterialMap", &ToMultiSurfaceMesh<T, D>::setMaterialMap,
758 "Set the material map to use for the multi surface mesh.")
759 .def("apply", &ToMultiSurfaceMesh<T, D>::apply,
760 "Convert the levelset to a surface mesh.");
761
762 // ToVoxelMesh
763 py::class_<ToVoxelMesh<T, D>, SmartPointer<ToVoxelMesh<T, D>>>(module,
764 "ToVoxelMesh")
765 // constructors
766 .def(py::init(&SmartPointer<ToVoxelMesh<T, D>>::template New<>))
767 .def(py::init(&SmartPointer<ToVoxelMesh<T, D>>::template New<
768 SmartPointer<Mesh<T>> &>))
769 .def(py::init(&SmartPointer<ToVoxelMesh<T, D>>::template New<
770 SmartPointer<Domain<T, D>> &, SmartPointer<Mesh<T>> &>))
771 .def(py::init(&SmartPointer<ToVoxelMesh<T, D>>::template New<
772 std::vector<SmartPointer<Domain<T, D>>> &,
773 SmartPointer<Mesh<T>> &>))
774 // methods
775 .def("insertNextLevelSet", &ToVoxelMesh<T, D>::insertNextLevelSet,
776 "Insert next level set to output in the mesh.")
777 .def("setMesh", &ToVoxelMesh<T, D>::setMesh, "Set the mesh to generate.")
778 .def("apply", &ToVoxelMesh<T, D>::apply,
779 "Convert the levelset to a surface mesh.");
780
781 // Writer
782 py::class_<Writer<T, D>, SmartPointer<Writer<T, D>>>(module, "Writer")
783 // constructors
784 .def(py::init(&SmartPointer<Writer<T, D>>::template New<>))
785 .def(py::init(&SmartPointer<Writer<T, D>>::template New<
786 SmartPointer<Domain<T, D>> &>))
787 .def(py::init(&SmartPointer<Writer<T, D>>::template New<
788 SmartPointer<Domain<T, D>> &, std::string>))
789 // methods
790 .def("setLevelSet", &Writer<T, D>::setLevelSet,
791 "Set levelset to write to file.")
792 .def("setFileName", &Writer<T, D>::setFileName,
793 "Set the filename for the output file.")
794 .def("apply", &Writer<T, D>::apply, "Write to file.");
795
796// WriteVisualizationMesh
797#ifdef VIENNALS_USE_VTK
798 py::class_<WriteVisualizationMesh<T, D>,
799 SmartPointer<WriteVisualizationMesh<T, D>>>(
800 module, "WriteVisualizationMesh")
801 // constructors
802 .def(
803 py::init(&SmartPointer<WriteVisualizationMesh<T, D>>::template New<>))
804 .def(py::init(&SmartPointer<WriteVisualizationMesh<T, D>>::template New<
805 SmartPointer<Domain<T, D>> &>))
806 // methods
807 .def("insertNextLevelSet",
808 &WriteVisualizationMesh<T, D>::insertNextLevelSet,
809 "Insert next level set to convert. Bigger level sets wrapping "
810 "smaller ones, should be inserted last.")
811 .def("setFileName", &WriteVisualizationMesh<T, D>::setFileName,
812 "Set Name of File to write.")
813 .def("setExtractHullMesh",
814 &WriteVisualizationMesh<T, D>::setExtractHullMesh,
815 "Whether to extract a hull mesh. Defaults to false.")
816 .def("setExtractVolumeMesh",
817 &WriteVisualizationMesh<T, D>::setExtractVolumeMesh,
818 " Whether to extract a tetra volume mesh. Defaults to true.")
819 .def("setMetaData", &WriteVisualizationMesh<T, D>::setMetaData,
820 "Set the metadata to be written to the file.")
821 .def("addMetaData",
822 py::overload_cast<const std::string &, T>(
823 &WriteVisualizationMesh<T, D>::addMetaData),
824 "Add a single metadata entry to the file.")
825 .def("addMetaData",
826 py::overload_cast<const std::string &, const std::vector<T> &>(
827 &WriteVisualizationMesh<T, D>::addMetaData),
828 "Add a single metadata entry to the file.")
829 .def("addMetaData",
830 py::overload_cast<
831 const std::unordered_map<std::string, std::vector<T>> &>(
832 &WriteVisualizationMesh<T, D>::addMetaData),
833 "Add metadata to the file.")
834 .def("apply", &WriteVisualizationMesh<T, D>::apply,
835 "Make and write mesh.");
836#endif
837
838 if constexpr (D == 2) {
839 // CompareArea
840 py::class_<CompareArea<T, D>, SmartPointer<CompareArea<T, D>>>(
841 module, "CompareArea")
842 // constructors
843 .def(py::init(&SmartPointer<CompareArea<T, D>>::template New<>))
844 .def(py::init(
845 &SmartPointer<CompareArea<T, D>>::template New<
846 SmartPointer<Domain<T, D>> &, SmartPointer<Domain<T, D>> &>))
847 // methods
848 .def("setLevelSetTarget", &CompareArea<T, D>::setLevelSetTarget,
849 "Sets the target level set.")
850 .def("setLevelSetSample", &CompareArea<T, D>::setLevelSetSample,
851 "Sets the sample level set.")
852 .def("setDefaultIncrement", &CompareArea<T, D>::setDefaultIncrement,
853 "Set default increment value")
854 .def("setXRangeAndIncrement", &CompareArea<T, D>::setXRangeAndIncrement,
855 "Sets the x-range and custom increment value")
856 .def("setYRangeAndIncrement", &CompareArea<T, D>::setYRangeAndIncrement,
857 "Sets the y-range and custom increment value")
858 .def("setOutputMesh", &CompareArea<T, D>::setOutputMesh,
859 "Set the output mesh where difference areas will be stored")
860 .def("getAreaMismatch", &CompareArea<T, D>::getAreaMismatch,
861 "Returns the computed area mismatch.")
862 .def("getCustomAreaMismatch", &CompareArea<T, D>::getCustomAreaMismatch,
863 "Returns the computed area mismatch, with custom increments "
864 "applied.")
865 .def("getCellCount", &CompareArea<T, D>::getCellCount,
866 "Returns the number of cells where the level sets differ.")
867 .def("getCustomCellCount", &CompareArea<T, D>::getCustomCellCount,
868 "Returns the number of cells where the level sets differ, with "
869 "custom increments applied.")
870 .def("apply", &CompareArea<T, D>::apply,
871 "Computes the area difference between the two level sets.");
872
873 // CompareNarrowBand
874 py::class_<CompareNarrowBand<T, D>, SmartPointer<CompareNarrowBand<T, D>>>(
875 module, "CompareNarrowBand")
876 // constructors
877 .def(py::init(&SmartPointer<CompareNarrowBand<T, D>>::template New<>))
878 .def(py::init(
879 &SmartPointer<CompareNarrowBand<T, D>>::template New<
880 SmartPointer<Domain<T, D>> &, SmartPointer<Domain<T, D>> &>))
881 // methods
882 .def("setLevelSetTarget", &CompareNarrowBand<T, D>::setLevelSetTarget,
883 "Sets the target level set.")
884 .def("setLevelSetSample", &CompareNarrowBand<T, D>::setLevelSetSample,
885 "Sets the sample level set.")
886 .def("setXRange", &CompareNarrowBand<T, D>::setXRange,
887 "Set the x-coordinate range to restrict the comparison area")
888 .def("setYRange", &CompareNarrowBand<T, D>::setYRange,
889 "Set the y-coordinate range to restrict the comparison area")
890 .def("clearXRange", &CompareNarrowBand<T, D>::clearXRange,
891 "Clear the x-range restriction")
892 .def("clearYRange", &CompareNarrowBand<T, D>::clearYRange,
893 "Clear the y-range restriction")
894 .def("setOutputMesh", &CompareNarrowBand<T, D>::setOutputMesh,
895 "Set the output mesh where difference values will be stored")
896 .def("setOutputMeshSquaredDifferences",
898 "Set whether to output squared differences (true) or absolute "
899 "differences (false)")
900 .def("apply", &CompareNarrowBand<T, D>::apply,
901 "Apply the comparison and calculate the sum of squared "
902 "differences.")
903 .def("getSumSquaredDifferences",
905 "Return the sum of squared differences calculated by apply().")
906 .def("getSumDifferences", &CompareNarrowBand<T, D>::getSumDifferences,
907 "Return the sum of absolute differences calculated by apply().")
908 .def("getNumPoints", &CompareNarrowBand<T, D>::getNumPoints,
909 "Return the number of points used in the comparison.")
910 .def("getRMSE", &CompareNarrowBand<T, D>::getRMSE,
911 "Calculate the root mean square error from previously computed "
912 "values.");
913
914 // CompareSparseField
915 py::class_<CompareSparseField<T, D>,
916 SmartPointer<CompareSparseField<T, D>>>(module,
917 "CompareSparseField")
918 // constructors
919 .def(py::init(&SmartPointer<CompareSparseField<T, D>>::template New<>))
920 .def(py::init(
921 &SmartPointer<CompareSparseField<T, D>>::template New<
922 SmartPointer<Domain<T, D>> &, SmartPointer<Domain<T, D>> &>))
923 // methods
924 .def("setLevelSetExpanded",
926 "Sets the expanded level set for comparison.")
927 .def("setLevelSetIterated",
929 "Sets the iterated level set to compare against the expanded one.")
930 .def("setXRange", &CompareSparseField<T, D>::setXRange,
931 "Set the x-coordinate range to restrict the comparison area")
932 .def("setYRange", &CompareSparseField<T, D>::setYRange,
933 "Set the y-coordinate range to restrict the comparison area")
934 .def("clearXRange", &CompareSparseField<T, D>::clearXRange,
935 "Clear the x-range restriction")
936 .def("clearYRange", &CompareSparseField<T, D>::clearYRange,
937 "Clear the y-range restriction")
938 .def("setOutputMesh", &CompareSparseField<T, D>::setOutputMesh,
939 "Set the output mesh where difference values will be stored")
940 .def("setFillIteratedWithDistances",
942 "Set whether to fill the iterated level set with distance values")
943 .def("apply", &CompareSparseField<T, D>::apply,
944 "Apply the comparison and calculate the sum of squared "
945 "differences.")
946 .def("getSumSquaredDifferences",
948 "Return the sum of squared differences calculated by apply().")
949 .def("getSumDifferences", &CompareSparseField<T, D>::getSumDifferences,
950 "Return the sum of absolute differences calculated by apply().")
951 .def("getNumPoints", &CompareSparseField<T, D>::getNumPoints,
952 "Return the number of points used in the comparison.")
953 .def("getNumSkippedPoints",
955 "Return the number of points skipped during comparison.")
956 .def("getRMSE", &CompareSparseField<T, D>::getRMSE,
957 "Calculate the root mean square error from previously computed "
958 "values.");
959 }
960}
constexpr int D
Definition Epitaxy.cpp:11
double T
Definition Epitaxy.cpp:12
Definition pyWrap.hpp:64
T getSignedDistance(const vectorType &initial, const vectorType &candidate, unsigned long initialPointId) const override
Definition pyWrap.hpp:76
bool isInside(const vectorType &initial, const vectorType &candidate, double eps=0.) const override
Definition pyWrap.hpp:71
boundsType getBounds() const override
Sets bounds to the bounding box of the distribution.
Definition pyWrap.hpp:82
Stencil Local Lax Friedrichs Integration 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:64
void setVelocityField(SmartPointer< VelocityField< T > > passedVelocities)
Set the velocity field used for advection. This should be a concrete implementation of lsVelocityFiel...
Definition lsAdvect.hpp:736
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:730
bool getCalculateNormalVectors() const
Get whether normal vectors were calculated.
Definition lsAdvect.hpp:791
void setIgnoreVoids(bool iV)
Set whether level set values, which are not part of the "top" geometrically connected part of values,...
Definition lsAdvect.hpp:771
void setCalculateNormalVectors(bool cnv)
Set whether normal vectors should be calculated at each level set point. Defaults to true....
Definition lsAdvect.hpp:763
void apply()
Perform the advection.
Definition lsAdvect.hpp:861
void prepareLS()
Definition lsAdvect.hpp:814
double getAdvectedTime() const
Get by how much the physical time was advanced during the last apply() call.
Definition lsAdvect.hpp:779
void setDissipationAlpha(const double &a)
Set the alpha dissipation coefficient. For lsLaxFriedrichs, this is used as the alpha value....
Definition lsAdvect.hpp:803
void setIntegrationScheme(IntegrationSchemeEnum scheme)
Set which integration scheme should be used out of the ones specified in IntegrationSchemeEnum.
Definition lsAdvect.hpp:795
double getCurrentTimeStep() const
Return the last applied time step.
Definition lsAdvect.hpp:782
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:745
unsigned getNumberOfTimeSteps() const
Get how many advection steps were performed during the last apply() call.
Definition lsAdvect.hpp:785
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:757
void applyIntegration(double maxTimeStep=std::numeric_limits< double >::max())
This function applies the integration scheme and calculates the rates and the maximum time step,...
Definition lsAdvect.hpp:881
double getTimeStepRatio() const
Get the value of the CFL number.
Definition lsAdvect.hpp:788
This class is used to perform boolean operations on two level sets and write the resulting level set ...
Definition lsBooleanOperation.hpp:43
void setLevelSet(SmartPointer< Domain< T, D > > passedlsDomain)
Set which level set to perform the boolean operation on.
Definition lsBooleanOperation.hpp:287
void setSecondLevelSet(SmartPointer< Domain< T, D > > passedlsDomain)
Set the level set which will be used to modify the first level set.
Definition lsBooleanOperation.hpp:293
void setBooleanOperation(BooleanOperationEnum passedOperation)
Set which of the operations of BooleanOperationEnum to perform.
Definition lsBooleanOperation.hpp:298
void apply()
Perform operation.
Definition lsBooleanOperation.hpp:316
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:35
void setLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsCalculateNormalVectors.hpp:53
void apply()
Definition lsCalculateNormalVectors.hpp:82
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
Computes an estimate of the area where two level sets differ. The area is calculated by iterating thr...
Definition lsCompareArea.hpp:23
unsigned long int getCustomCellCount() const
Returns the number of cells where the level sets differ, with custom increments applied.
Definition lsCompareArea.hpp:175
void setXRangeAndIncrement(hrleIndexType minXRange, hrleIndexType maxXRange, unsigned short int Xincrement)
Sets the x-range and custom increment value.
Definition lsCompareArea.hpp:134
void setLevelSetTarget(SmartPointer< Domain< T, D > > passedLevelSet)
Sets the target level set.
Definition lsCompareArea.hpp:119
unsigned long int getCellCount() const
Returns the number of cells where the level sets differ.
Definition lsCompareArea.hpp:171
double getCustomAreaMismatch() const
Returns the computed area mismatch, with custom increments applied.
Definition lsCompareArea.hpp:165
void setLevelSetSample(SmartPointer< Domain< T, D > > passedLevelSet)
Sets the sample level set.
Definition lsCompareArea.hpp:124
void apply()
Computes the area difference between the two level sets.
Definition lsCompareArea.hpp:180
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 lsCompareArea.hpp:155
void setDefaultIncrement(unsigned short int increment)
Set default increment value.
Definition lsCompareArea.hpp:129
void setYRangeAndIncrement(hrleIndexType minYRange, hrleIndexType maxYRange, unsigned short int Yincrement)
Sets the y-range and custom increment value.
Definition lsCompareArea.hpp:143
double getAreaMismatch() const
Returns the computed area mismatch.
Definition lsCompareArea.hpp:160
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:172
void setOutputMeshSquaredDifferences(bool value)
Set whether to output squared differences (true) or absolute differences (false)
Definition lsCompareNarrowBand.hpp:201
void setXRange(T minXRange, T maxXRange)
Set the x-coordinate range to restrict the comparison area.
Definition lsCompareNarrowBand.hpp:165
void setOutputMesh(SmartPointer< Mesh< T > > passedMesh, bool outputMeshSquaredDiffs=true)
Set the output mesh where difference values will be stored.
Definition lsCompareNarrowBand.hpp:193
void setLevelSetTarget(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsCompareNarrowBand.hpp:156
T getRMSE() const
Calculate the root mean square error from previously computed values.
Definition lsCompareNarrowBand.hpp:373
void setLevelSetSample(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsCompareNarrowBand.hpp:160
unsigned getNumPoints() const
Return the number of points used in the comparison.
Definition lsCompareNarrowBand.hpp:370
void clearYRange()
Clear the y-range restriction.
Definition lsCompareNarrowBand.hpp:186
T getSumSquaredDifferences() const
Return the sum of squared differences calculated by apply().
Definition lsCompareNarrowBand.hpp:364
void apply()
Apply the comparison and calculate the sum of squared differences.
Definition lsCompareNarrowBand.hpp:206
void clearXRange()
Clear the x-range restriction.
Definition lsCompareNarrowBand.hpp:179
T getSumDifferences() const
Definition lsCompareNarrowBand.hpp:367
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:368
T getRMSE() const
Calculate the root mean square error from previously computed values.
Definition lsCompareSparseField.hpp:374
void setXRange(T minXRange, T maxXRange)
Set the x-coordinate range to restrict the comparison area.
Definition lsCompareSparseField.hpp:161
void setOutputMesh(SmartPointer< Mesh< T > > passedMesh)
Set the output mesh where difference values will be stored.
Definition lsCompareSparseField.hpp:189
void setLevelSetIterated(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsCompareSparseField.hpp:156
unsigned getNumSkippedPoints() const
Return the number of skipped points during the comparison.
Definition lsCompareSparseField.hpp:371
void setYRange(T minYRange, T maxYRange)
Set the y-coordinate range to restrict the comparison area.
Definition lsCompareSparseField.hpp:168
void setLevelSetExpanded(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsCompareSparseField.hpp:152
void setFillIteratedWithDistances(bool fill)
Set whether to fill the iterated level set with distances.
Definition lsCompareSparseField.hpp:194
T getSumSquaredDifferences() const
Return the sum of squared differences calculated by apply().
Definition lsCompareSparseField.hpp:362
T getSumDifferences() const
Return the sum of differences calculated by apply().
Definition lsCompareSparseField.hpp:365
void clearYRange()
Clear the y-range restriction.
Definition lsCompareSparseField.hpp:182
void apply()
Apply the comparison and calculate the sum of squared differences.
Definition lsCompareSparseField.hpp:199
void clearXRange()
Clear the x-range restriction.
Definition lsCompareSparseField.hpp:175
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:285
void setMesh(SmartPointer< Mesh< T > > passedMesh)
Definition lsConvexHull.hpp:279
void setPointCloud(SmartPointer< PointCloud< T, D > > passedPointCloud)
Definition lsConvexHull.hpp:281
Definition lsGeometricAdvectDistributions.hpp:186
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:199
std::array< viennahrle::CoordType, 6 > getBounds() const override
Sets bounds to the bounding box of the distribution.
Definition lsGeometricAdvectDistributions.hpp:243
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:27
void clearMetaData()
Definition lsDomain.hpp:163
void deepCopy(const SmartPointer< Domain< T, D > > passedDomain)
copy all values of "passedDomain" to this Domain
Definition lsDomain.hpp:124
unsigned getNumberOfSegments() const
returns the number of segments, the levelset is split into. This is useful for algorithm parallelisat...
Definition lsDomain.hpp:153
void print(std::ostream &out=std::cout)
prints basic information and all memebers of the levelset structure
Definition lsDomain.hpp:178
int getLevelSetWidth() const
Definition lsDomain.hpp:158
unsigned getNumberOfPoints() const
returns the number of defined points
Definition lsDomain.hpp:156
void setLevelSetWidth(int width)
Definition lsDomain.hpp:160
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:129
void apply()
Definition lsMakeGeometry.hpp:146
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:94
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:102
void apply()
Definition lsMarkVoidPoints.hpp:153
void setSaveComponentIds(bool scid)
Set whether the connected component IDs used to generate the void points should be saved....
Definition lsMarkVoidPoints.hpp:151
void setDetectLargestSurface(bool passedDetect)
Set whether the number of points of one connected surface should be used to detect void points....
Definition lsMarkVoidPoints.hpp:112
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:118
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 setMesh(SmartPointer< Mesh< N > > passedMesh)
Definition lsToDiskMesh.hpp:70
void setMaterialMap(SmartPointer< MaterialMap > passedMaterialMap)
Definition lsToDiskMesh.hpp:77
void apply()
Definition lsToDiskMesh.hpp:83
void setMaxValue(const T passedMaxValue)
Definition lsToDiskMesh.hpp:81
void setLevelSet(SmartPointer< Domain< T, D > > passedLevelSet)
Definition lsToDiskMesh.hpp:61
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:22
void setMaterialMap(SmartPointer< MaterialMap > passedMaterialMap)
Definition lsToMultiSurfaceMesh.hpp:79
void setMesh(SmartPointer< viennals::Mesh< T > > passedMesh)
Definition lsToMultiSurfaceMesh.hpp:71
void apply()
Definition lsToMultiSurfaceMesh.hpp:83
void insertNextLevelSet(SmartPointer< lsDomainType > passedLevelSet)
Definition lsToMultiSurfaceMesh.hpp:75
Extract an explicit Mesh<> instance from an lsDomain. The interface is then described by explicit sur...
Definition lsToSurfaceMesh.hpp:21
void setMesh(SmartPointer< Mesh< T > > passedMesh)
Definition lsToSurfaceMesh.hpp:41
void apply()
Definition lsToSurfaceMesh.hpp:45
void setLevelSet(SmartPointer< Domain< T, D > > passedlsDomain)
Definition lsToSurfaceMesh.hpp:37
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: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:80
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:36
FeatureDetectionEnum
Definition lsDetectFeatures.hpp:16
BooleanOperationEnum
Enumeration for the different types of boolean operations which are supported. When INVERT,...
Definition lsBooleanOperation.hpp:25
CurvatureEnum
Definition lsCalculateCurvatures.hpp:15
void bindApi(py::module &module)
Definition pyWrap.hpp:87
PYBIND11_DECLARE_HOLDER_TYPE(TemplateType, SmartPointer< TemplateType >)