Inviwo  0.9.10.1
Inviwo documentation
inviwo::meshutil Namespace Reference

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. More...
 
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. More...
 
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. More...
 
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. 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) More...
 
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)
 [Using PosTexColorMesh]
 
IVW_MODULE_BASE_API std::shared_ptr< BasicMeshtorus (const vec3 &center, const vec3 &up_, float r1, float r2, const ivec2 &subdivisions, vec4 color)
 [Using PosTexColorMesh]
 
IVW_MODULE_BASE_API std::shared_ptr< ColoredMeshcameraFrustum (const Camera &camera, vec4 color, std::shared_ptr< ColoredMesh > mesh)
 [Using Colored 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)
 

Detailed Description

meshutil

Function Documentation

◆ axisAlignedBoundingBox() [1/2]

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.

◆ axisAlignedBoundingBox() [2/2]

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.

◆ centerViewOnMeshes()

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|)

◆ computeNearFarPlanes()

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
farNearRatioRatio between near and far plane. 1:10000 is commonly used by game engines.
Returns
Near and far plane distances.

◆ 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