OpenVDB: openvdb/tools/LevelSetDilatedMesh.h Source File

OpenVDB 12.1.1

Loading...
Searching...
No Matches
LevelSetDilatedMesh.h
Go to the documentation of this file.
1// Copyright Contributors to the OpenVDB Project
2// SPDX-License-Identifier: Apache-2.0
3///
4/// @author Greg Hurst
5///
6/// @file LevelSetDilatedMesh.h
7///
8/// @brief Generate a narrow-band level set of a dilated surface mesh.
9///
10/// @note By definition a level set has a fixed narrow band width
11/// (the half width is defined by LEVEL_SET_HALF_WIDTH in Types.h),
12/// whereas an SDF can have a variable narrow band width.
13
14#ifndef OPENVDB_TOOLS_LEVELSETDILATEDMESH_HAS_BEEN_INCLUDED
15#define OPENVDB_TOOLS_LEVELSETDILATEDMESH_HAS_BEEN_INCLUDED
16
17#include <openvdb/Grid.h>
18#include <openvdb/openvdb.h>
19#include <openvdb/math/Math.h>
20#include <openvdb/util/NullInterrupter.h>
21
22#include <vector>
23
24
25namespace openvdb {
26 OPENVDB_USE_VERSION_NAMESPACE
27namespace OPENVDB_VERSION_NAME {
28namespace tools {
29
30/// @brief Return a grid of type @c GridType containing a narrow-band level set
31/// representation of a dilated triangle surface mesh (dilated by a radius in all directions).
32///
33/// @param vertices Vertices of the mesh in world units.
34/// @param triangles Triangle indices of the mesh.
35/// @param radius Dilation radius in world units.
36/// @param voxelSize Voxel size in world units.
37/// @param halfWidth Half the width of the narrow band, in voxel units.
38/// @param interrupter Interrupter adhering to the util::NullInterrupter interface.
39///
40/// @note @c GridType::ValueType must be a floating-point scalar.
41/// @note @c ScalarType represents the mesh vertex and radius type
42/// and must be a floating-point scalar.
43/// @note The input mesh is always treated as a surface, and so dilation occurs in every direction.
44/// This includes meshes that could represent valid BRep solids, dilation occurs both
45/// inward and outward, forming a 'shell' rather than only expanding outward.
46template <typename GridType, typename ScalarType, typename InterruptT = util::NullInterrupter>
47typename GridType::Ptr
48 createLevelSetDilatedMesh(
49 const std::vector<math::Vec3<ScalarType>>& vertices, const std::vector<Vec3I>& triangles,
50 ScalarType radius, float voxelSize, float halfWidth = float(LEVEL_SET_HALF_WIDTH),
51 InterruptT* interrupter = nullptr);
52
53/// @brief Return a grid of type @c GridType containing a narrow-band level set
54/// representation of a dilated quad surface mesh (dilated by a radius in all directions).
55///
56/// @param vertices Vertices of the mesh in world units.
57/// @param quads Quad indices of the mesh.
58/// @param radius Dilation radius in world units.
59/// @param voxelSize Voxel size in world units.
60/// @param halfWidth Half the width of the narrow band, in voxel units.
61/// @param interrupter Interrupter adhering to the util::NullInterrupter interface.
62///
63/// @note @c GridType::ValueType must be a floating-point scalar.
64/// @note @c ScalarType represents the mesh vertex and radius type
65/// and must be a floating-point scalar.
66/// @note The input mesh is always treated as a surface, and so dilation occurs in every direction.
67/// This includes meshes that could represent valid BRep solids, dilation occurs both
68/// inward and outward, forming a 'shell' rather than only expanding outward.
69template <typename GridType, typename ScalarType, typename InterruptT = util::NullInterrupter>
70typename GridType::Ptr
71 createLevelSetDilatedMesh(
72 const std::vector<math::Vec3<ScalarType>>& vertices, const std::vector<Vec4I>& quads,
73 ScalarType radius, float voxelSize, float halfWidth = float(LEVEL_SET_HALF_WIDTH),
74 InterruptT* interrupter = nullptr);
75
76/// @brief Return a grid of type @c GridType containing a narrow-band level set
77/// representation of a dilated triangle & quad surface mesh (dilated by a radius in all directions).
78///
79/// @param vertices Vertices of the mesh in world units.
80/// @param triangles Triangle indices of the mesh.
81/// @param quads Quad indices of the mesh.
82/// @param radius Dilation radius in world units.
83/// @param voxelSize Voxel size in world units.
84/// @param halfWidth Half the width of the narrow band, in voxel units.
85/// @param interrupter Interrupter adhering to the util::NullInterrupter interface.
86///
87/// @note @c GridType::ValueType must be a floating-point scalar.
88/// @note @c ScalarType represents the mesh vertex and radius type
89/// and must be a floating-point scalar.
90/// @note The input mesh is always treated as a surface, and so dilation occurs in every direction.
91/// This includes meshes that could represent valid BRep solids, dilation occurs both
92/// inward and outward, forming a 'shell' rather than only expanding outward.
93template <typename GridType, typename ScalarType, typename InterruptT = util::NullInterrupter>
94typename GridType::Ptr
95 createLevelSetDilatedMesh(const std::vector<math::Vec3<ScalarType>>& vertices,
96 const std::vector<Vec3I>& triangles, const std::vector<Vec4I>& quads,
97 ScalarType radius, float voxelSize, float halfWidth = float(LEVEL_SET_HALF_WIDTH),
98 InterruptT* interrupter = nullptr);
99
100
101////////////////////////////////////////
102
103
104// Explicit Template Instantiation
105
106#ifdef OPENVDB_USE_EXPLICIT_INSTANTIATION
107
108#ifdef OPENVDB_INSTANTIATE_LEVELSETDILATEDMESH
109#include <openvdb/util/ExplicitInstantiation.h>
110#endif
111
112#define _FUNCTION(TreeT) \
113 Grid<TreeT>::Ptr createLevelSetDilatedMesh<Grid<TreeT>>(const std::vector<Vec3s>&, \
114 const std::vector<Vec3I>&, float, float, float, util::NullInterrupter*)
115 OPENVDB_REAL_TREE_INSTANTIATE(_FUNCTION)
116#undef _FUNCTION
117
118#define _FUNCTION(TreeT) \
119 Grid<TreeT>::Ptr createLevelSetDilatedMesh<Grid<TreeT>>(const std::vector<Vec3s>&, \
120 const std::vector<Vec4I>&, float, float, float, util::NullInterrupter*)
121 OPENVDB_REAL_TREE_INSTANTIATE(_FUNCTION)
122#undef _FUNCTION
123
124#define _FUNCTION(TreeT) \
125 Grid<TreeT>::Ptr createLevelSetDilatedMesh<Grid<TreeT>>(const std::vector<Vec3s>&, \
126 const std::vector<Vec3I>&, const std::vector<Vec4I>&, float, float, float, \
127 util::NullInterrupter*)
128 OPENVDB_REAL_TREE_INSTANTIATE(_FUNCTION)
129#undef _FUNCTION
130
131#endif // OPENVDB_USE_EXPLICIT_INSTANTIATION
132
133} // namespace tools
134} // namespace OPENVDB_VERSION_NAME
135} // namespace openvdb
136
137#include "impl/LevelSetDilatedMeshImpl.h"
138
139#endif // OPENVDB_TOOLS_LEVELSETDILATEDMESH_HAS_BEEN_INCLUDED
ExplicitInstantiation.h
Grid.h
LevelSetDilatedMeshImpl.h
Generate a narrow-band level set of a dilated surface mesh.
Math.h
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
NullInterrupter.h
openvdb::v12_1::tools::createLevelSetDilatedMesh
GridType::Ptr createLevelSetDilatedMesh(const std::vector< math::Vec3< ScalarType > > &vertices, const std::vector< Vec3I > &triangles, ScalarType radius, float voxelSize, float halfWidth=float(LEVEL_SET_HALF_WIDTH), InterruptT *interrupter=nullptr)
Return a grid of type GridType containing a narrow-band level set representation of a dilated triangl...
Definition LevelSetDilatedMeshImpl.h:1520
openvdb
Definition Exceptions.h:13
openvdb.h
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:218
OPENVDB_REAL_TREE_INSTANTIATE
#define OPENVDB_REAL_TREE_INSTANTIATE(Function)
Definition version.h.in:162