MeshLib C++ Docs
Loading...
Searching...
No Matches
MRFillingSurface.h
Go to the documentation of this file.
1#pragma once
2
3#include <MRMesh/MRMeshFwd.h>
4#include <MRMesh/MRExpected.h>
5#include <MRMesh/MRVector3.h>
7
8#include <variant>
9#include <optional>
10
12{
13
14namespace TPMS
15{
16
17
28
30MRVOXELS_API std::vector<std::string> getTypeNames();
31
33MRVOXELS_API std::vector<std::string> getTypeTooltips();
34
37
38
40{
42 float frequency = 1.f;
43 float resolution = 5.f;
44};
45
47{
48 float iso = 0.6f;
49 bool decimate = true;
50};
51
55MRVOXELS_API FunctionVolume buildVolume( const Vector3f& size, const VolumeParams& params );
56
58MRVOXELS_API Expected<Mesh> build( const Vector3f& size, const MeshParams& params, ProgressCallback cb = {} );
59
61MRVOXELS_API Expected<Mesh> fill( const Mesh& mesh, const MeshParams& params, ProgressCallback cb = {} );
62
64MRVOXELS_API size_t getNumberOfVoxels( const Mesh& mesh, float frequency, float resolution );
65
67MRVOXELS_API size_t getNumberOfVoxels( const Vector3f& size, float frequency, float resolution );
68
72MRVOXELS_API float estimateIso( Type type, float targetDensity );
73
77MRVOXELS_API float estimateDensity( Type type, float targetIso );
78
80MRVOXELS_API float getMinimalResolution( Type type, float iso );
81
82}
83
84
85
87{
88
90enum class Type : int
91{
94};
95
96struct Params
97{
99 Vector3f period = Vector3f::diagonal( 1.f );
100 Vector3f width = Vector3f::diagonal( 0.3f );
101 float r = 0.f;
102
105 bool highRes = false;
106
112 bool preserveTips = false;
113};
114
115MRVOXELS_API std::vector<std::string> getTypeNames();
116
117
119MRVOXELS_API Expected<Mesh> build( const Vector3f& size, const Params& params, const ProgressCallback& cb = {} );
120
122MRVOXELS_API Expected<Mesh> fill( const Mesh& mesh, const Params& params, const ProgressCallback& cb = {} );
123
125MRVOXELS_API float estimateDensity( float period, float width, float r );
126
130MRVOXELS_API std::optional<float> estimateWidth( float period, float r, float targetDensity );
131
132}
133
134
136enum class Kind : int
137{
138 TPMS = 0,
140};
141MRVOXELS_API std::vector<std::string> getKindNames();
142
143using MeshParamsRef = std::variant
144 < std::reference_wrapper<TPMS::MeshParams>
145 , std::reference_wrapper<CellularSurface::Params>
146 >;
147
148using ConstMeshParamsRef = std::variant
149 < std::reference_wrapper<const TPMS::MeshParams>
150 , std::reference_wrapper<const CellularSurface::Params>
151 >;
152
156
157
159template <typename T>
161{
163
164 Vector3f getPeriod() const
165 {
166 return std::visit( overloaded{
167 [] ( const TPMS::MeshParams& p ){ return Vector3f::diagonal( 1.f / p.frequency ); },
168 [] ( const CellularSurface::Params& p ) { return p.period; }
169 }, params );
170 }
171};
172
175
176}
#define MRVOXELS_API
see explanation in MRMesh/MRMeshFwd.h
Definition MRVoxelsFwd.h:14
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:753
auto width(const Box< V > &box)
returns size along x axis
Definition MRBox.h:354
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:32
MRVOXELS_CLASS FunctionVolume
Definition MRVoxelsFwd.h:46
tl::expected< T, E > Expected
Definition MRExpected.h:31
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:13
Surface of cylinders in a grid.
Definition MRFillingSurface.h:87
Expected< Mesh > build(const Vector3f &size, const Params &params, const ProgressCallback &cb={})
Build a cellular surface of size size.
Expected< Mesh > fill(const Mesh &mesh, const Params &params, const ProgressCallback &cb={})
Fill given mesh with a cellular surface.
std::optional< float > estimateWidth(float period, float r, float targetDensity)
std::vector< std::string > getTypeNames()
Returns the names for each type of filling.
float estimateDensity(float period, float width, float r)
Estimate the density of the cellular surface.
Type
Type of cellular surface base element.
Definition MRFillingSurface.h:91
@ Cylinder
Definition MRFillingSurface.h:92
@ Rect
Definition MRFillingSurface.h:93
Triply Periodic Minimal Surface.
Definition MRFillingSurface.h:15
Expected< Mesh > build(const Vector3f &size, const MeshParams &params, ProgressCallback cb={})
Constructs TPMS level-set and then convert it to mesh.
std::vector< std::string > getTypeNames()
Returns the names for each type of filling.
size_t getNumberOfVoxels(const Mesh &mesh, float frequency, float resolution)
Returns number of voxels that would be used to perform fillWithTPMS.
std::vector< std::string > getTypeTooltips()
Returns the tooltips for each type of filling.
float getMinimalResolution(Type type, float iso)
Returns minimal reasonable resolution for given parameters.
Expected< Mesh > fill(const Mesh &mesh, const MeshParams &params, ProgressCallback cb={})
Constructs TPMS-filling for the given mesh.
FunctionVolume buildVolume(const Vector3f &size, const VolumeParams &params)
bool isThick(Type type)
Returns true if the type is thick.
Type
Supported types of TPMS (Triply Periodic Minimal Surfaces)
Definition MRFillingSurface.h:20
@ ThickSchwartzP
Definition MRFillingSurface.h:22
@ DoubleGyroid
Definition MRFillingSurface.h:23
@ ThickGyroid
Definition MRFillingSurface.h:24
@ SchwartzP
Definition MRFillingSurface.h:21
@ Count
Definition MRFillingSurface.h:26
float estimateIso(Type type, float targetDensity)
float estimateDensity(Type type, float targetIso)
Definition MRFillingSurface.h:12
std::vector< std::string > getKindNames()
MR_BIND_IGNORE Expected< Mesh > build(const Vector3f &size, ConstMeshParamsRef params, ProgressCallback cb={})
Unified functions to build and fill using the specified filling structures.
std::variant< std::reference_wrapper< const TPMS::MeshParams >, std::reference_wrapper< const CellularSurface::Params > > ConstMeshParamsRef
Definition MRFillingSurface.h:148
ParamsFacade(MeshParamsRef) -> ParamsFacade< MeshParamsRef >
Kind
Different kinds of filling surface.
Definition MRFillingSurface.h:137
@ Cellular
Definition MRFillingSurface.h:139
MR_BIND_IGNORE Expected< Mesh > fill(const Mesh &mesh, ConstMeshParamsRef params, ProgressCallback cb={})
std::variant< std::reference_wrapper< TPMS::MeshParams >, std::reference_wrapper< CellularSurface::Params > > MeshParamsRef
Definition MRFillingSurface.h:143
Definition MRFillingSurface.h:97
bool preserveTips
Definition MRFillingSurface.h:112
Type type
the type of the base element
Definition MRFillingSurface.h:98
float r
the radius of uniting spheres
Definition MRFillingSurface.h:101
Vector3f period
the distance between consecutive cylinders in each direction
Definition MRFillingSurface.h:99
Vector3f width
the width of cylinders in each direction
Definition MRFillingSurface.h:100
bool highRes
Definition MRFillingSurface.h:105
A helper to access parameters common for different kind of surfaces.
Definition MRFillingSurface.h:161
Vector3f getPeriod() const
Definition MRFillingSurface.h:164
T params
Definition MRFillingSurface.h:162
Definition MRFillingSurface.h:47
bool decimate
Definition MRFillingSurface.h:49
float iso
Definition MRFillingSurface.h:48
Definition MRFillingSurface.h:40
float resolution
Frequency of oscillations (determines size of the "cells" in the "grid")
Definition MRFillingSurface.h:43
Type type
Definition MRFillingSurface.h:41
float frequency
Type of the surface.
Definition MRFillingSurface.h:42
Definition MRMesh.h:23
Definition MRMeshFwd.h:785