![]() |
Inviwo 0.9.12-pre
Inviwo documentation
|
#include <inviwo/core/datastructures/geometry/typedmesh.h>
Public Types | |
| using | Traits = std::tuple<BufferTraits...> |
| using | Vertex = std::tuple<typename BufferTraits::type...> |
| Public Types inherited from inviwo::Mesh | |
| using | BufferVector = std::vector<std::pair<BufferInfo, std::shared_ptr<BufferBase>>> |
| using | IndexVector = std::vector<std::pair<MeshInfo, std::shared_ptr<IndexBuffer>>> |
| Public Types inherited from inviwo::DataGroup< Mesh, MeshRepresentation > | |
| using | repr |
| using | self |
Public Member Functions | |
| template<typename... Args> | |
| uint32_t | addVertex (Args &&... args) |
| Adds a vertex. | |
| uint32_t | addVertex (const Vertex &vertex) |
| void | addVertices (const std::vector< Vertex > &vertices) |
| Adds a vector of vertices to the mesh. | |
| void | append (const TypedMesh *mesh) |
| Append another TypedMesh to the current TypedMesh. | |
| virtual TypedMesh * | clone () const override |
| template<typename BT> | |
| auto | getTypedBuffer () |
| Returns a specific buffer. The following example shows how to get the color buffer: | |
| template<typename BT> | |
| auto | getTypedBuffer () const |
| template<typename BT> | |
| auto & | getTypedDataContainer () |
| template<typename BT> | |
| auto & | getTypedDataContainer () const |
| template<typename BT> | |
| auto | getTypedEditableRAMRepresentation () |
| template<typename BT> | |
| auto | getTypedRAMRepresentation () const |
| TypedMesh & | operator= (const TypedMesh &that) |
| template<typename... Args> | |
| void | setVertex (size_t index, Args &&... args) |
| Sets a specific vertex. | |
| template<typename BT> | |
| void | setVertex (size_t index, const typename BT::type &v) |
| Updates the a specific value in specific buffer. | |
| void | setVertex (size_t index, const Vertex &vertex) |
| TypedMesh (const TypedMesh &rhs) | |
| TypedMesh (DrawType dt, ConnectivityType ct, const std::vector< Vertex > &vertices, const std::vector< std::uint32_t > &indices) | |
| TypedMesh (DrawType dt, ConnectivityType ct, const std::vector< Vertex > &vertices, std::vector< std::uint32_t > &&indices) | |
| TypedMesh (DrawType dt=DrawType::Points, ConnectivityType ct=ConnectivityType::None) | |
| Public Member Functions inherited from inviwo::Mesh | |
| void | addBuffer (BufferInfo info, std::shared_ptr< BufferBase > buffer) |
| void | addBuffer (BufferType type, std::shared_ptr< BufferBase > buffer) |
| void | addBuffers (const BufferVector &buffers) |
| std::shared_ptr< IndexBufferRAM > | addIndexBuffer (DrawType dt, ConnectivityType ct) |
| void | addIndices (const IndexVector &indices) |
| void | addIndices (MeshInfo info, std::shared_ptr< IndexBuffer > ind) |
| void | addIndicies (MeshInfo info, std::shared_ptr< IndexBuffer > ind) |
| void | append (const Mesh &mesh) |
| Append another mesh to this mesh. | |
| std::pair< BufferBase *, int > | findBuffer (BufferType type) |
| std::pair< const BufferBase *, int > | findBuffer (BufferType type) const |
| virtual const Axis * | getAxis (size_t index) const override |
| BufferBase * | getBuffer (BufferType type) |
| BufferBase * | getBuffer (size_t idx) |
| const BufferBase * | getBuffer (size_t idx) const |
| BufferInfo | getBufferInfo (BufferBase *buffer) const |
| BufferInfo | getBufferInfo (size_t idx) const |
| const BufferVector & | getBuffers () const |
| MeshInfo | getDefaultMeshInfo () const |
| const IndexVector & | getIndexBuffers () const |
| MeshInfo | getIndexMeshInfo (size_t idx) const |
| IndexBuffer * | getIndices (size_t idx) |
| const IndexBuffer * | getIndices (size_t idx) const |
| virtual Document | getInfo () const |
| size_t | getNumberOfBuffers () const |
| size_t | getNumberOfIndices () const |
| size_t | getNumberOfIndicies () const |
| bool | hasBuffer (BufferType type) const |
| Mesh (const BufferVector &buffers, const IndexVector &indices) | |
| Mesh (const Mesh &rhs) | |
| Mesh (const Mesh &rhs, NoData) | |
| Mesh (DrawType dt, ConnectivityType ct) | |
| Mesh (Mesh::MeshInfo meshInfo) | |
| Mesh & | operator= (const Mesh &that) |
| std::pair< BufferInfo, std::shared_ptr< BufferBase > > | removeBuffer (BufferBase *buffer) |
| std::pair< BufferInfo, std::shared_ptr< BufferBase > > | removeBuffer (size_t idx) |
| void | removeIndexBuffer (size_t idx) |
| std::pair< BufferInfo, std::shared_ptr< BufferBase > > | replaceBuffer (BufferBase *old, BufferInfo info, std::shared_ptr< BufferBase > buffer) |
| std::pair< BufferInfo, std::shared_ptr< BufferBase > > | replaceBuffer (size_t idx, BufferInfo info, std::shared_ptr< BufferBase > buffer) |
| void | reserveIndexBuffers (size_t size) |
| void | reserveSizeInVertexBuffer (size_t size) |
| void | setBuffer (size_t idx, BufferInfo info, std::shared_ptr< BufferBase > buffer) |
| void | setBufferInfo (BufferBase *buffer, BufferInfo info) |
| void | setBufferInfo (size_t idx, BufferInfo info) |
| void | setDefaultMeshInfo (MeshInfo) |
| Public Member Functions inherited from inviwo::DataGroup< Mesh, MeshRepresentation > | |
| void | clearRepresentations () |
| T * | getEditableRepresentation () |
| const T * | getRepresentation () const |
| bool | hasRepresentation () const |
| bool | hasRepresentations () const |
| Public Member Functions inherited from inviwo::SpatialEntity | |
| glm::mat3 | getBasis () const |
| virtual const SpatialCoordinateTransformer & | getCoordinateTransformer () const |
| virtual const SpatialCameraCoordinateTransformer & | getCoordinateTransformer (const Camera &camera) const |
| glm::mat4 | getModelMatrix () const |
| glm::vec3 | getOffset () const |
| glm::mat4 | getWorldMatrix () const |
| SpatialEntity & | operator= (const SpatialEntity &that) |
| void | setBasis (const glm::mat3 &basis) |
| void | setModelMatrix (const glm::mat4 &modelMatrix) |
| void | setOffset (const glm::vec3 &offset) |
| void | setWorldMatrix (const glm::mat4 &worldMatrix) |
| SpatialEntity (const glm::mat4 &modelMatrix) | |
| SpatialEntity (const glm::mat4 &modelMatrix, const glm::mat4 &worldMatrix) | |
| SpatialEntity (const SpatialEntity &rhs) | |
| Public Member Functions inherited from inviwo::MetaDataOwner | |
| void | copyMetaDataFrom (const MetaDataOwner &src) |
| void | copyMetaDataTo (MetaDataOwner &dst) |
|
template<typename T> requires std::derived_from<T, MetaData> | |
| T * | createMetaData (std::string_view key) |
| void | deserialize (Deserializer &d) |
|
template<typename T> requires std::derived_from<T, MetaData> | |
| T * | getMetaData (std::string_view key) |
|
template<typename T> requires std::derived_from<T, MetaData> | |
| const T * | getMetaData (std::string_view key) const |
|
template<typename T, typename U> requires std::derived_from<T, MetaData> && Gettable<T, U> | |
| U | getMetaData (std::string_view key, U val) const |
| MetaDataMap * | getMetaDataMap () |
| const MetaDataMap * | getMetaDataMap () const |
|
template<typename T> requires std::derived_from<T, MetaData> | |
| bool | hasMetaData (std::string_view key) const |
| bool | hasMetaData (std::string_view key) const |
| MetaDataOwner (const MetaDataOwner &rhs)=default | |
| MetaDataOwner (MetaDataOwner &rhs)=default | |
| MetaDataOwner & | operator= (const MetaDataOwner &rhs)=default |
| MetaDataOwner & | operator= (MetaDataOwner &)=default |
| void | serialize (Serializer &s) const |
|
template<typename T, typename U> requires std::derived_from<T, MetaData> && Settable<T, U> | |
| void | setMetaData (std::string_view key, U value) |
| template<typename T> requires std::derived_from<T, MetaData> | |
| bool | unsetMetaData (std::string_view key) |
| unset, i.e. remove the metadata entry matching the given key and type | |
Additional Inherited Members | |
| Public Attributes inherited from inviwo::Mesh | |
| std::array< Axis, 3 > | axes |
| Static Public Attributes inherited from inviwo::Mesh | |
| static constexpr std::string_view | classIdentifier {"org.inviwo.Mesh"} |
| static constexpr uvec3 | colorCode {188, 188, 101} |
| static constexpr std::string_view | dataName {"Mesh"} |
| Protected Member Functions inherited from inviwo::DataGroup< Mesh, MeshRepresentation > | |
| DataGroup< Mesh, MeshRepresentation > & | operator= (const DataGroup< Mesh, MeshRepresentation > &rhs) |
| Protected Attributes inherited from inviwo::Mesh | |
| BufferVector | buffers_ |
| IndexVector | indices_ |
| MeshInfo | meshInfo_ |
| Protected Attributes inherited from inviwo::DataGroup< Mesh, MeshRepresentation > | |
| std::mutex | mutex_ |
| std::unordered_map< std::type_index, std::shared_ptr< MeshRepresentation > > | representations_ |
| Protected Attributes inherited from inviwo::SpatialEntity | |
| std::unique_ptr< SpatialCameraCoordinateTransformer > | cameraTransformer_ |
| glm::mat4 | modelMatrix_ |
| std::unique_ptr< SpatialCoordinateTransformer > | transformer_ |
| glm::mat4 | worldMatrix_ |
| Protected Attributes inherited from inviwo::MetaDataOwner | |
| MetaDataMap | metaData_ |
TypedMesh is a templated data structure for creating meshes with a custom amount of vertex buffers. It uses a variadic set of BufferTraits to define its interface. For example, a Mesh with a position and color per vertex would be defined as TypedMesh<PositionsBufferTrait,ColorsBufferTrait>. Depending on the Traits specified in the declaration the interface towards the class is updated.
If texture coordinates are also needed for each vertex in the mesh then one could instead use:
For meshes with more than a couple of vertices, it is more efficient to add all vertices to the mesh at the same time. This can be done by using a std::vector containing TypedMesh::Vertex instead, as described by the following example:
When creating meshes it is very common to also have Index buffers, in addition to the vertex buffers. To add a index buffer to the mesh you can use the function addIndexBuffer as demonstrated by the following example.
The following code snippet uses a SimpleMesh2 to create bounding box for a given basisandoffset matrix. It is the code used in meshutil::boundingBoxAdjacency
The following code snippet is another example where we create a camera frustum mesh for a given camera. It is the code used in meshutil::cameraFrustum
| uint32_t inviwo::TypedMesh< BufferTraits >::addVertex | ( | Args &&... | args | ) |
Adds a vertex.
Adds a vertex to the mesh. The arguments to the function are automatically determined by the buffers of the mesh. For example:
| args | the arguments, needs to match the buffers of the mesh |
| void inviwo::TypedMesh< BufferTraits >::addVertices | ( | const std::vector< Vertex > & | vertices | ) |
Adds a vector of vertices to the mesh.
This method is often faster than adding the vertices one at a time with TypedMesh::addVertex()
|
inline |
Append another TypedMesh to the current TypedMesh.
| mesh | The mesh to append |
|
inlineoverridevirtual |
Reimplemented from inviwo::Mesh.
|
inline |
Returns a specific buffer. The following example shows how to get the color buffer:
|
inline |
Returns a specific buffer
|
inline |
Returns the Data Container of a specific buffer.
|
inline |
Returns the Data Container of a specific buffer.
|
inline |
Returns the Editable RAM Representation of a specific buffer.
|
inline |
Returns the RAM Representation of a specific buffer.
| void inviwo::TypedMesh< BufferTraits >::setVertex | ( | size_t | index, |
| Args &&... | args ) |
Sets a specific vertex.
The arguments to the function are automatically determined by the buffers of the mesh.
| index | vertex index to update |
| args | the arguments, needs to match the buffers of the mesh |
|
inline |
Updates the a specific value in specific buffer.
The following example will set the color of vertex with index 5 to read:
| index | vertex index to update |
| v | the new value |