Iray SDK API nvidia_logo_transpbg.gif Up
mi::neuraylib::ITriangle_connectivity Class Referenceabstract

A connectivity class for triangle mesh geometry and their attributes. More...

#include <itriangle_connectivity.h>

Inheritance diagram for mi::neuraylib::ITriangle_connectivity:

Public Member Functions

Methods related to the mapping represented by the connectivity
virtual Uint32 triangles_size () const =0
 Returns the number of triangles. More...
 
virtual Sint32 set_triangle_indices (Triangle_handle_struct t, const Uint32 *indices, Size n=1)=0
 Sets the vertex indices of a triangle (or a range of triangles). More...
 
virtual Sint32 set_triangle_indices (Triangle_handle_struct t, Uint32 v0, Uint32 v1, Uint32 v2)=0
 Sets the vertex indices of a triangle. More...
 
virtual Sint32 set_triangle_indices (Triangle_handle_struct t, const Triangle_point_indices_struct &triangle)=0
 Sets the vertex indices of a triangle. More...
 
virtual Uint32 get_triangle_index (Triangle_handle_struct t, Uint32 vertex) const =0
 Returns the index at the vertex vertex of triangle t. More...
 
virtual Triangle_point_indices_struct triangle_point_indices (Triangle_handle_struct t) const =0
 Returns the indices for all three vertices of triangle t. More...
 
virtual bool is_valid_connectivity () const =0
 Indicates whether this connectivity is valid. More...
 
Methods related to the attached mesh attributes
virtual bool has_attribute (Mesh_attribute_name name) const =0
 Indicates whether the connectivity has a particular mesh attribute. More...
 
virtual IAttribute_vectorcreate_attribute_vector (Mesh_attribute_name name, Uint32 dim=1) const =0
 Creates a non-per-primitive mesh attribute. More...
 
virtual const IAttribute_vectoraccess_attribute_vector (Mesh_attribute_name name) const =0
 Returns a non-per-primitive mesh attribute. More...
 
virtual IAttribute_vectoredit_attribute_vector (Mesh_attribute_name name)=0
 Detaches and returns a non-per-primitive mesh attribute. More...
 
virtual Sint32 attach_attribute_vector (IAttribute_vector *attr)=0
 Attaches a given non-per-primitive mesh attribute to the mesh. More...
 
virtual Sint32 remove_attribute_vector (Mesh_attribute_name name)=0
 Removes a non-per-primitive mesh attribute. More...
 
Miscellaneous methods
virtual Connectivity_map_type get_map_type () const =0
 Returns the type of the connectivity. More...
 
- Public Member Functions inherited from mi::base::IInterface
virtual Uint32 retain () const =0
 Increments the reference count. More...
 
virtual Uint32 release () const =0
 Decrements the reference count. More...
 
virtual const IInterfaceget_interface (const Uuid &interface_id) const =0
 Acquires a const interface from another. More...
 
template<class T>
const T * get_interface () const
 Acquires a const interface from another. More...
 
virtual IInterfaceget_interface (const Uuid &interface_id)=0
 Acquires a mutable interface from another. More...
 
template<class T>
T * get_interface ()
 Acquires a mutable interface from another. More...
 
virtual Uuid get_iid () const =0
 Returns the interface ID of the most derived interface. More...
 

Additional Inherited Members

- Public Types inherited from mi::base::Interface_declare< 0x47cf1faa, ... >
typedef Interface_declare< id1, ... > Self
 Own type. More...
 
typedef Uuid_t< id1, ... > IID
 Declares the interface ID (IID) of this interface. More...
 
- Public Types inherited from mi::base::IInterface
typedef Uuid_t<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0> IID
 Declares the interface ID (IID) of this interface. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0x47cf1faa, ... >
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 
- Static Public Member Functions inherited from mi::base::IInterface
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface. More...
 

Detailed Description

A connectivity class for triangle mesh geometry and their attributes.

A triangle connectivity maps vertices of a triangle mesh to indices. The vertices of the triangle mesh are identified by a pair of a triangle handle and a (local) vertex index in [0,3). Connectivities may have attached attribute vectors which use the connectivity information.

The meaning of the index associated with each vertex of the mesh is as follows: If the connectivity is the mesh connectivity, then this index identifies the point that belongs to a given vertex. Otherwise, the connectivity is called custom connectivity, and the index identifies an entry in an attribute vector that is associated with the given vertex. Note that attribute vectors can also be attached to the mesh connectivity (in which case an entry in the attribute vector is associated with the point mapped to the given vertex).

Attributes that have the same topological layout as the geometry typically use the mesh connectivity, e.g., normals for every point in the mesh. It is also possible to use an attribute connectivity with the same mapping as the mesh connectivity, however, using the mesh connectivity is more efficient. The use of a separate custom connectivity is necessary if the topological layout of the attribute is different from the geometry, e.g., for texture spaces with seams. Custom connectivities can also be useful to reduce the size of the attribute vector by sharing the same attribute value, e.g., for sharing the same normal between many points because of flat regions in the mesh.

Since the number of triangles is dictated by the mesh that the connectivity is associated with, it can only be changed by corresponding calls to the mi::neuraylib::ITriangle_mesh instance. It is possible to add points and triangles and to set the indices of the connectivities in alternating order, if so desired. The only constraint is that the largest connectivity index is smaller than the number of points (for the mesh connectivity) and smaller than the sizes of the attached attribute vectors (for all connectivities).

To create mesh attributes with the same connectivity, you can use a single connectivity and attach all these attributes to the same connectivity. However, when the mesh is retrieved from the DB no guarantee is given whether the attributes still share the connectivity or not.

Note
You must not release the mesh from which this connectivity was obtained before you release the connectivity.
See also
mi::neuraylib::ITriangle_mesh
mi::neuraylib::IAttribute_vector

Member Function Documentation

 access_attribute_vector()

virtual const IAttribute_vector * mi::neuraylib::ITriangle_connectivity::access_attribute_vector ( Mesh_attribute_name  name) const
pure virtual

Returns a non-per-primitive mesh attribute.

Parameters
nameThe name of the attribute, see Mesh_attribute_name. The attribute must not be a per-primitive attribute.
Returns
The requested attribute vector, or NULL in case of failure.

 attach_attribute_vector()

virtual Sint32 mi::neuraylib::ITriangle_connectivity::attach_attribute_vector ( IAttribute_vector attr)
pure virtual

Attaches a given non-per-primitive mesh attribute to the mesh.

The attribute vector must not be used any longer after it has been attached.

See also
create_attribute_vector(), edit_attribute_vector()
Returns
  • 0: Success.
  • -1: Invalid parameters (NULL pointer).
  • -2: The attribute vector has not been acquired from this connectivity.
  • -3: An attribute of the same name is already attached to the mesh (or to one of its connectivities).
  • -4: The connectivity is invalid.
  • -5: The attribute vector is too small for this connectivity.

 create_attribute_vector()

virtual IAttribute_vector * mi::neuraylib::ITriangle_connectivity::create_attribute_vector ( Mesh_attribute_name  name,
Uint32  dim = 1 
) const
pure virtual

Creates a non-per-primitive mesh attribute.

The attribute is not yet attached to the connectivity. It needs to be attached before it is released.

Note
It is possible to create multiple attribute vectors on the same connectivity. If this connectivity is not the mesh connectivity, i.e., the attribute is not per point, but per vertex, then the connectivity information will eventually be duplicated such that each attribute vector has its own copy. This duplication happens after re-attaching the connectivity, but before it is stored in the database or the edit cycle ends.
See also
attach_attribute_vector()
Parameters
nameThe name of the attribute, see Mesh_attribute_name. The attribute must not be a per-primitive attribute.
dimDimension of an attribute value. Only used for those attributes that have user specifiable dimensions.
Returns
The requested attribute vector, or NULL in case of failure.

 edit_attribute_vector()

virtual IAttribute_vector * mi::neuraylib::ITriangle_connectivity::edit_attribute_vector ( Mesh_attribute_name  name)
pure virtual

Detaches and returns a non-per-primitive mesh attribute.

The attribute needs to be reattached before it is released. Otherwise, the attribute is effectively removed from the connectivity.

See also
attach_attribute_vector()
Parameters
nameThe name of the attribute, see Mesh_attribute_name. The attribute must not be a per-primitive attribute.
Returns
The requested attribute vector, or NULL in case of failure.

 get_map_type()

virtual Connectivity_map_type mi::neuraylib::ITriangle_connectivity::get_map_type ( ) const
pure virtual

Returns the type of the connectivity.

Currently, only one type is supported.

 get_triangle_index()

virtual Uint32 mi::neuraylib::ITriangle_connectivity::get_triangle_index ( Triangle_handle_struct  t,
Uint32  vertex 
) const
pure virtual

Returns the index at the vertex vertex of triangle t.

Returns
The requested vertex index, or 0 if t is out of bounds, or vertex is not in the range [0,3).

 has_attribute()

virtual bool mi::neuraylib::ITriangle_connectivity::has_attribute ( Mesh_attribute_name  name) const
pure virtual

Indicates whether the connectivity has a particular mesh attribute.

Parameters
nameThe name of the attribute to query, see Mesh_attribute_name.
Returns
true if the connectivity has this attribute, false otherwise.

 is_valid_connectivity()

virtual bool mi::neuraylib::ITriangle_connectivity::is_valid_connectivity ( ) const
pure virtual

Indicates whether this connectivity is valid.

A connectivity becomes invalid after it has been (re)attached to the corresponding mesh and may no longer been used.

 remove_attribute_vector()

virtual Sint32 mi::neuraylib::ITriangle_connectivity::remove_attribute_vector ( Mesh_attribute_name  name)
pure virtual

Removes a non-per-primitive mesh attribute.

Parameters
nameThe name of the attribute, see Mesh_attribute_name. The attribute must not be a per-primitive attribute.
Returns
  • 0: Success.
  • -1: There is no mesh attribute of that name on this connectivity, or the connectivity is invalid.

 set_triangle_indices() [1/3]

virtual Sint32 mi::neuraylib::ITriangle_connectivity::set_triangle_indices ( Triangle_handle_struct  t,
const Triangle_point_indices_struct triangle 
)
pure virtual

Sets the vertex indices of a triangle.

Note
For best performance it is recommended to sort the triangles by their material index such that when looping over all triangles the material index changes as infrequently as possible.
Parameters
tThe triangle to modify.
triangleThe new indices for triangle t.
Returns
  • 0: Success.
  • -3: t is out of bounds.
  • -4: The connectivity is no longer valid.

 set_triangle_indices() [2/3]

virtual Sint32 mi::neuraylib::ITriangle_connectivity::set_triangle_indices ( Triangle_handle_struct  t,
const Uint32 indices,
Size  n = 1 
)
pure virtual

Sets the vertex indices of a triangle (or a range of triangles).

Note
For best performance it is recommended to sort the triangles by their material index such that when looping over all triangles the material index changes as infrequently as possible.
Parameters
tThe triangle to modify.
indicesThe new indices for triangle t.
nThe number of triangles to modify.
Returns
  • 0: Success.
  • -1: Invalid parameters (NULL pointer).
  • -3: t is out of bounds.
  • -4: The connectivity is no longer valid.
  • -5: n is too large, i.e., t+n-1 is out of bounds.

 set_triangle_indices() [3/3]

virtual Sint32 mi::neuraylib::ITriangle_connectivity::set_triangle_indices ( Triangle_handle_struct  t,
Uint32  v0,
Uint32  v1,
Uint32  v2 
)
pure virtual

Sets the vertex indices of a triangle.

Note
For best performance it is recommended to sort the triangles by their material index such that when looping over all triangles the material index changes as infrequently as possible.
Parameters
tThe triangle to modify.
v0The first new index of triangle t.
v1The second new index of triangle t.
v2The third new index of triangle t.
Returns
  • 0: Success.
  • -3: t is out of bounds.
  • -4: The connectivity is no longer valid.

 triangle_point_indices()

virtual Triangle_point_indices_struct mi::neuraylib::ITriangle_connectivity::triangle_point_indices ( Triangle_handle_struct  t) const
pure virtual

Returns the indices for all three vertices of triangle t.

Returns
The requested indices, or a defaulted constructed return value if t is out of bounds.

 triangles_size()

virtual Uint32 mi::neuraylib::ITriangle_connectivity::triangles_size ( ) const
pure virtual

Returns the number of triangles.