Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::meshutil Namespace Reference

Enumerations

enum class  IncludeNormals { Yes , No }
 
enum class  CalculateMeshNormalsMode {
  PassThrough , NoWeighting , WeightArea , WeightAngle ,
  WeightNMax , PassThrough , NoWeighting , WeightArea ,
  WeightAngle , WeightNMax
}
 The weighting modes for calculating normals. More...
 
enum class  CalculateMeshNormalsMode {
  PassThrough , NoWeighting , WeightArea , WeightAngle ,
  WeightNMax , PassThrough , NoWeighting , WeightArea ,
  WeightAngle , WeightNMax
}
 The weighting modes for calculating normals. More...
 

Functions

IVW_CORE_API bool hasPickIDBuffer (const Mesh *mesh)
 
IVW_CORE_API bool hasRadiiBuffer (const Mesh *mesh)
 
IVW_MODULE_BASE_API std::pair< vec3, vec3 > axisAlignedBoundingBox (const std::vector< std::shared_ptr< const Mesh > > &meshes)
 Compute bounding box of meshes aligned to principal axes of world space.
 
IVW_MODULE_BASE_API std::pair< vec3, vec3 > axisAlignedBoundingBox (const Mesh &mesh)
 Compute bounding box of mesh aligned to principal axes of world space. Returns mesh offset in both min/max if the mesh does not have any vertices.
 
IVW_MODULE_BASE_API void centerViewOnMeshes (const std::vector< std::shared_ptr< const Mesh > > &meshes, CameraProperty &camera, float minMaxRatio=10.f)
 Set lookAt position of camera to the center point of the meshes and adjust near/far plane distances. Adjusts min/max parameters of lookTo and near/far plane according to the supplied minMaxRatio.
 
IVW_MODULE_BASE_API std::pair< float, float > computeNearFarPlanes (std::pair< vec3, vec3 > worldSpaceBoundingBox, const CameraProperty &camera, float nearFarRatio=1.f/10000.f)
 Compute near and far plane parameters covering the bounding box when maximally zoomed out.
 
IVW_MODULE_BASE_API std::shared_ptr< MeshclipMeshAgainstPlane (const Mesh &mesh, const Plane &worldSpacePlane, bool capClippedHoles=true)
 
std::unique_ptr< MeshtoPointMesh (const Mesh &mesh)
 
std::unique_ptr< MeshtoLineMesh (const Mesh &mesh)
 
IVW_MODULE_BASE_API std::shared_ptr< BasicMeshellipse (const vec3 &center, const vec3 &majorAxis, const vec3 &minorAxis, const vec4 &color=vec4(1.0f, 0.0f, 0.0f, 1.0f), const float &radius=0.001f, const size_t &segments=16)
 
IVW_MODULE_BASE_API std::shared_ptr< BasicMeshdisk (const vec3 &center, const vec3 &normal, const vec4 &color=vec4(1.0f, 0.0f, 0.0f, 1.0f), const float &radius=1.0f, const size_t &segments=16)
 
IVW_MODULE_BASE_API std::shared_ptr< BasicMeshcone (const vec3 &start, const vec3 &stop, const vec4 &color=vec4(1.0f, 0.0f, 0.0f, 1.0f), const float &radius=1.0f, const size_t &segments=16)
 
IVW_MODULE_BASE_API std::shared_ptr< BasicMeshcylinder (const vec3 &start, const vec3 &stop, const vec4 &color=vec4(1.0f, 0.0f, 0.0f, 1.0f), const float &radius=1.0f, const size_t &segments=16, bool caps=true, std::shared_ptr< BasicMesh > mesh=nullptr)
 
IVW_MODULE_BASE_API std::shared_ptr< BasicMeshline (const vec3 &start, const vec3 &stop, const vec3 &normal, const vec4 &color=vec4(1.0f, 0.0f, 0.0f, 1.0f), const float &width=1.0f, const ivec2 &res=ivec2(1))
 
IVW_MODULE_BASE_API std::shared_ptr< BasicMesharrow (const vec3 &start, const vec3 &stop, const vec4 &color=vec4(1.0f, 0.0f, 0.0f, 1.0f), const float &radius=1.0f, const float &arrowfraction=0.15f, const float &arrowRadius=2.0f, const size_t &segments=16)
 
IVW_MODULE_BASE_API std::shared_ptr< BasicMeshcolorsphere (const vec3 &center, const float &radius, std::shared_ptr< BasicMesh > mesh=nullptr)
 
IVW_MODULE_BASE_API std::shared_ptr< BasicMeshsphere (const vec3 &center, const float &radius, const vec4 &color, std::shared_ptr< BasicMesh > mesh=nullptr)
 
IVW_MODULE_BASE_API std::shared_ptr< BasicMeshsquare (const vec3 &center, const vec3 &normal, const vec2 &extent, const vec4 &color=vec4(1, 1, 1, 1), const ivec2 &segments=ivec2(1))
 
IVW_MODULE_BASE_API std::shared_ptr< BasicMeshcube (const mat4 &orientation, const vec4 &color=vec4(1, 1, 1, 1))
 
IVW_MODULE_BASE_API std::shared_ptr< BasicMeshcoordindicator (const vec3 &center, const float &size)
 
IVW_MODULE_BASE_API std::shared_ptr< BasicMeshboundingbox (const mat4 &basisandoffset, const vec4 &color)
 
IVW_MODULE_BASE_API std::shared_ptr< PosTexColorMeshboundingBoxAdjacency (const mat4 &basisandoffset, const vec4 &color)
 
IVW_MODULE_BASE_API std::shared_ptr< BasicMeshtorus (const vec3 &center, const vec3 &up=vec3(0, 1, 0), float r1=1.f, float r2=.3f, const ivec2 &subdivisions=ivec2(32, 8), vec4 color=vec4(1, 1, 1, 1))
 
IVW_MODULE_BASE_API std::shared_ptr< ColoredMeshcameraFrustum (const Camera &camera, vec4 color, std::shared_ptr< ColoredMesh > mesh=std::make_shared< ColoredMesh >())
 
IVW_MODULE_BASE_API std::shared_ptr< Meshparallelepiped (glm::vec3 origin, glm::vec3 p1, glm::vec3 p2, glm::vec3 p3, glm::vec4 color, glm::vec4 c1, glm::vec4 c2, glm::vec4 c3, IncludeNormals includeNormals)
 Create parallelepiped mesh.
 
template<typename Callback >
void forEachTriangle (const Mesh::MeshInfo &info, const IndexBuffer &ib, Callback callback)
 
template<typename Callback >
void forEachLineSegment (const Mesh::MeshInfo &info, const IndexBuffer &ib, Callback &&callback)
 
template<typename LineStartCallback , typename LinePointCallback , typename LineEndCallback >
void forEachLine (const Mesh::MeshInfo &info, const IndexBuffer &ib, LineStartCallback &&lineStartCallback, LinePointCallback &&linePointCallback, LineEndCallback &&lineEndCallback)
 
IVW_MODULE_OIT_API void calculateMeshNormals (Mesh &mesh, CalculateMeshNormalsMode mode=CalculateMeshNormalsMode::WeightNMax)
 
std::unique_ptr< MeshcalculateMeshNormals (const Mesh &mesh, CalculateMeshNormalsMode mode=CalculateMeshNormalsMode::WeightNMax)
 

Detailed Description

meshutil

Enumeration Type Documentation

◆ CalculateMeshNormalsMode [1/2]

The weighting modes for calculating normals.

Enumerator
PassThrough 

Pass through, mesh is not changed.

NoWeighting 

no weighting of the normals, simple average

WeightArea 

Weight = area of the triangle.

WeightAngle 

Weight based on the angle. As defined in "Computing vertex normals from polygonal facets" by Grit Thürmer and Charles A. Wüthrich 1998.

WeightNMax 

Based on "Weights for Computing Vertex Normals from Facet Normals", N. Max, 1999. This gives the best results in most cases.

PassThrough 

Pass through, mesh is not changed.

NoWeighting 

no weighting of the normals, simple average

WeightArea 

Weight = area of the triangle.

WeightAngle 

Weight based on the angle. As defined in "Computing vertex normals from polygonal facets" by Grit Thürmer and Charles A. Wüthrich 1998.

WeightNMax 

Based on "Weights for Computing Vertex Normals from Facet Normals", N. Max, 1999. This gives the best results in most cases.

◆ CalculateMeshNormalsMode [2/2]

The weighting modes for calculating normals.

Enumerator
PassThrough 

Pass through, mesh is not changed.

NoWeighting 

no weighting of the normals, simple average

WeightArea 

Weight = area of the triangle.

WeightAngle 

Weight based on the angle. As defined in "Computing vertex normals from polygonal facets" by Grit Thürmer and Charles A. Wüthrich 1998.

WeightNMax 

Based on "Weights for Computing Vertex Normals from Facet Normals", N. Max, 1999. This gives the best results in most cases.

PassThrough 

Pass through, mesh is not changed.

NoWeighting 

no weighting of the normals, simple average

WeightArea 

Weight = area of the triangle.

WeightAngle 

Weight based on the angle. As defined in "Computing vertex normals from polygonal facets" by Grit Thürmer and Charles A. Wüthrich 1998.

WeightNMax 

Based on "Weights for Computing Vertex Normals from Facet Normals", N. Max, 1999. This gives the best results in most cases.

Function Documentation

◆ axisAlignedBoundingBox() [1/2]

IVW_MODULE_BASE_API std::pair< vec3, vec3 > inviwo::meshutil::axisAlignedBoundingBox ( const Mesh & mesh)

Compute bounding box of mesh aligned to principal axes of world space. Returns mesh offset in both min/max if the mesh does not have any vertices.

Parameters
meshMesh to consider
Returns
Minimum and maximum vertex points of mesh in (x,y,z), or mesh offset if no vertices exist.

◆ axisAlignedBoundingBox() [2/2]

IVW_MODULE_BASE_API std::pair< vec3, vec3 > inviwo::meshutil::axisAlignedBoundingBox ( const std::vector< std::shared_ptr< const Mesh > > & meshes)

Compute bounding box of meshes aligned to principal axes of world space.

Parameters
meshesMeshes to consider
Returns
Minimum and maximum vertex points of meshes in (x,y,z) world space, or zero if vector is empty.

◆ centerViewOnMeshes()

IVW_MODULE_BASE_API void inviwo::meshutil::centerViewOnMeshes ( const std::vector< std::shared_ptr< const Mesh > > & meshes,
CameraProperty & camera,
float minMaxRatio = 10.f )

Set lookAt position of camera to the center point of the meshes and adjust near/far plane distances. Adjusts min/max parameters of lookTo and near/far plane according to the supplied minMaxRatio.

Parameters
meshesMeshes to consider
cameraCamera to adjust
minMaxRatioAdjust min/max values to (value - minMaxRatio*|value|, value + minMaxRatio*|value|)

◆ clipMeshAgainstPlane()

IVW_MODULE_BASE_API std::shared_ptr< Mesh > inviwo::meshutil::clipMeshAgainstPlane ( const Mesh & mesh,
const Plane & worldSpacePlane,
bool capClippedHoles = true )

Clip mesh against plane using Sutherland-Hodgman. If holes should be closed, the input mesh must be manifold. Vertex attributes are interpolated. Floating types use linear interpolation, integer types use nearest. Connectivity types loop and fan are not handled.

Parameters
meshto clip
worldSpacePlanein world space coordinate system
capClippedHolesreplaces removed parts with triangles aligned with the plane
Exceptions
Exceptionif mesh is not supported.
Returns
Clipped Mesh

◆ computeNearFarPlanes()

IVW_MODULE_BASE_API std::pair< float, float > inviwo::meshutil::computeNearFarPlanes ( std::pair< vec3, vec3 > worldSpaceBoundingBox,
const CameraProperty & camera,
float nearFarRatio = 1.f/10000.f )

Compute near and far plane parameters covering the bounding box when maximally zoomed out.

Projects the bounding box onto the view direction and selects the distance furthest away as far plane (increased by 1% to make sure that mesh is not clipped). The view directions considered are lookFrom min/max -> lookTo. Near plane is computed as max(1e^-6, farPlaneDistance * farNearRatio)

Parameters
worldSpaceBoundingBoxMin and max points of geometry
cameraCamera used as basis for computation
nearFarRatioRatio between near and far plane. 1:10000 is commonly used by game engines.
Returns
Near and far plane distances.

◆ parallelepiped()

IVW_MODULE_BASE_API std::shared_ptr< Mesh > inviwo::meshutil::parallelepiped ( glm::vec3 origin,
glm::vec3 p1,
glm::vec3 p2,
glm::vec3 p3,
glm::vec4 color,
glm::vec4 c1,
glm::vec4 c2,
glm::vec4 c3,
IncludeNormals includeNormals )

Create parallelepiped mesh.

The parallelepiped is anchored at origin and spanned by p1, p2, and p2

*
*        6───────────────────▶7
*       ▲ ▲                  ▲ ▲
*      ╱   ╲                ╱   ╲
*     ╱     ╲              ╱     ╲
*    ╱       ╲            ╱       ╲
*   ╱         ╲          ╱         ╲
*  4───────────────────▶5           ╲
*   ▲           ╲        ▲           ╲
*    ╲           ╲        ╲           ╲
*     ╲           2────────╲──────────▶3
*      ╲         ▲          ╲         ▲
*    p3 ╲       ╱            ╲       ╱
*        ╲     ╱p2            ╲     ╱
*         ╲   ╱                ╲   ╱
*          ╲ ╱                  ╲ ╱
*           0───────────────────▶1
*          ▲         p1
*         ╱
*        ╱
*       ╱ Origin
*      ╱
*     ╱
*    ╱
* 
Parameters
originposition
p1basis vector 1
p2basis vector 2
p3basis vector 3
colorat origin
c1color at p1
c2color at p2
c3color at p3
includeNormalsAdd face normals to the mesh
Returns
parallelepiped mesh

◆ toLineMesh()

std::unique_ptr< Mesh > inviwo::meshutil::toLineMesh ( const Mesh & mesh)

Will construct a new mesh out of the given mesh with its position and color buffer, if existing. It will discard all IndexBuffes with DrawType equal to Points, copy all IndexBuffers with DrawType equal to Lines, and construct IndexBuffers with lines out of all IndexBuffers with DrawType equal to Triangles.

◆ toPointMesh()

std::unique_ptr< Mesh > inviwo::meshutil::toPointMesh ( const Mesh & mesh)

Will construct a new mesh out of the given mesh with its position and color buffer, if existing, and all index buffers but with the DrawMode set to Points