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