neuray API Programmer's Manual

itriangle_connectivity.h File Reference

Description

Triangle connectivities and associated helper classes.

Code Example

itriangle_connectivity.h

‎/***************************************************************************************************
 * Copyright 2023 NVIDIA Corporation. All rights reserved.
 **************************************************************************************************/

#ifndef MI_NEURAYLIB_ITRIANGLE_CONNECTIVITY_H
#define MI_NEURAYLIB_ITRIANGLE_CONNECTIVITY_H

#include <mi/neuraylib/iattribute_vector.h>
#include <mi/neuraylib/identifier.h>

namespace mi {

namespace neuraylib {




struct Triangle_point_indices_struct
{
    Uint32 index[3];
};

class Triangle_point_indices : public Triangle_point_indices_struct
{
public:
    Triangle_point_indices() { index[0] = 0; index[1] = 0; index[2] = 0; }

    Triangle_point_indices( Uint32 e1, Uint32 e2, Uint32 e3)
    {
        index[0] = e1;
        index[1] = e2;
        index[2] = e3;
    }

    Triangle_point_indices( const Triangle_point_indices_struct& other)
    {
        index[0] = other.index[0];
        index[1] = other.index[1];
        index[2] = other.index[2];
    }

    Uint32&        operator[]( Uint32 i)       { return index[i]; }

    const Uint32&  operator[]( Uint32 i) const { return index[i]; }

    int compare( const Triangle_point_indices& other) const
    {
        if ( index[0] < other.index[0]) return -1;
        if ( index[0] > other.index[0]) return 1;
        if ( index[1] < other.index[1]) return -1;
        if ( index[1] > other.index[1]) return 1;
        if ( index[2] < other.index[2]) return -1;
        if ( index[2] > other.index[2]) return 1;
        return 0;
    }

    bool operator==( const Triangle_point_indices& other) const { return compare(other) == 0; }

    bool operator!=( const Triangle_point_indices& other) const { return compare(other) != 0; }

    bool operator< ( const Triangle_point_indices& other) const { return compare(other) <  0; }

    bool operator< =( const Triangle_point_indices& other) const { return compare(other) <= 0; }

    bool operator>( const Triangle_point_indices& other) const { return compare(other) >  0; }

    bool operator>=( const Triangle_point_indices& other) const { return compare(other) >= 0; }
};

class ITriangle_connectivity :
    public base::Interface_declare<0x47cf1faa,0x609d,0x44ee,0xa3,0x6a,0xca,0x02,0x92,0xf7,0x6a,0x40>
{
public:


    virtual Uint32 
               triangles_size() const = 0;

    virtual Sint32 
               set_triangle_indices(
        Triangle_handle_struct t, const Uint32* indices, Size n = 1) = 0;

    virtual Sint32 
               set_triangle_indices(
        Triangle_handle_struct t, Uint32 v0, Uint32 v1, Uint32 v2) = 0;

    virtual Sint32 
               set_triangle_indices(
        Triangle_handle_struct t, const Triangle_point_indices_struct &triangle) = 0;

    virtual Uint32 
               get_triangle_index( Triangle_handle_struct t, Uint32 vertex) const = 0;

    virtual Triangle_point_indices_struct 
               triangle_point_indices(
        Triangle_handle_struct t) const = 0;

    virtual bool is_valid_connectivity() const = 0;




    virtual bool has_attribute( Mesh_attribute_name name) const = 0;

    virtual IAttribute_vector* create_attribute_vector(
        Mesh_attribute_name name, Uint32 dim = 1) const = 0;

    virtual const IAttribute_vector* access_attribute_vector( Mesh_attribute_name name) const = 0;

    virtual IAttribute_vector* edit_attribute_vector( Mesh_attribute_name name) = 0;

    virtual Sint32 
               attach_attribute_vector( IAttribute_vector* attr) = 0;

    virtual Sint32 
               remove_attribute_vector( Mesh_attribute_name name) = 0;




    virtual Connectivity_map_type 
               get_map_type() const = 0;

};
 // end group mi_neuray_leaf_nodes

} // namespace neuraylib

} // namespace mi

#endif // MI_NEURAYLIB_ITRIANGLE_CONNECTIVITY_H

Namespaces

namespace 
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH. More...
namespace 
Namespace for the neuray API. More...

Classes

class 
A connectivity class for triangle mesh geometry and their attributes. More...
class 
A triangle defined by three point indices, starting at index 0. More...
struct 
A triangle defined by three point indices, starting at index 0. More...