neuray API Programmer's Manual

identifier.h File Reference

Description

Simple integer-based handles used by mesh interfaces.

Code Example

identifier.h

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

#ifndef MI_NEURAYLIB_IDENTIFIER_H
#define MI_NEURAYLIB_IDENTIFIER_H

#include <mi/base/types.h>

namespace mi {

namespace neuraylib {


enum Identifier_name {
    HND_TRIANGLE,          
    HND_POLY,              
    HND_SURFACE,           
    HND_CURVE,             
    HND_CURVE_SEGMENT,     
    HND_TEXTURE_SURFACE,   
    HND_FIBER,             
    HND_SCENE_GRAPH_VERSION,
    HND_SCENE_GRAPH_NODE,
    HND_SCENE_GRAPH_OBJECT_NODE,
    HND_SCENE_GRAPH_LIGHT_NODE,
    HND_SCENE_GRAPH_MESH,
    HND_SCENE_GRAPH_MATERIAL,
    HND_SCENE_GRAPH_DECAL_NODE,
    HND_SCENE_GRAPH_PROJECTOR_NODE,
    HND_SCENE_GRAPH_SECTION_OBJECT_NODE
};

template <typename T> struct Invalid_identifier { };
template <> struct Invalid_identifier<Uint32>
{
    static inline Uint32 value( ) { return 0xffffffff; }
};

template <> struct Invalid_identifier<Uint64>
{
    static inline Uint64 value( ) { return 0xffffffffffffffffull; }
};

template <Identifier_name name, typename Int_type = Uint32>
struct Identifier_struct
{
    Int_type m_id;
};

template <Identifier_name name, typename Int_type = Uint32>
class Identifier : public Identifier_struct<name, Int_type>
{
public:
    Identifier( ) { this->m_id = Invalid_identifier<Int_type>::value(); }

    explicit Identifier( Int_type h ) { this->m_id =  h; }

    Identifier( Identifier_struct< name,  Int_type> h ) { this->m_id = h.m_id; }

    operator Int_type() const { return this->m_id; }

    Int_type operator*() const { return this->m_id; }

    bool is_valid( ) const { return this->m_id != Invalid_identifier<Int_type>::value(); }

    Identifier& operator++() { ++this->m_id; return *this; }

    Identifier 
               operator++(int) { Identifier h(*this); ++this->m_id; return h; }

    Identifier& operator--() { --this->m_id; return *this; }

    Identifier 
               operator--(int) { Identifier h(*this); --this->m_id; return h; }

    bool operator< ( const Identifier &other ) const { return  this->m_id < other.m_id; }

    bool operator< =( const Identifier &other ) const { return  this->m_id <= other.m_id; }

    bool operator>( const Identifier &other ) const { return  this->m_id > other.m_id; }

    bool operator>=( const Identifier &other ) const { return  this->m_id >= other.m_id; }
};
 // end group mi_neuray




typedef Identifier_struct< HND_TRIANGLE> 
               Triangle_handle_struct;

typedef Identifier_struct< HND_POLY> 
               Polygon_handle_struct;

typedef Identifier_struct< HND_SURFACE> 
               Surface_handle_struct;

typedef Identifier_struct< HND_CURVE> 
               Curve_handle_struct;

typedef Identifier_struct< HND_CURVE_SEGMENT> 
               Curve_segment_handle_struct;

typedef Identifier_struct< HND_TEXTURE_SURFACE> 
               Texture_surface_handle_struct;

typedef Identifier_struct< HND_FIBER,  Uint64> 
               Fiber_handle_struct;

typedef Identifier< HND_TRIANGLE> 
               Triangle_handle;

typedef Identifier< HND_POLY> 
               Polygon_handle;

typedef Identifier< HND_SURFACE> 
               Surface_handle;

typedef Identifier< HND_CURVE> 
               Curve_handle;

typedef Identifier< HND_CURVE_SEGMENT> 
               Curve_segment_handle;

typedef Identifier< HND_TEXTURE_SURFACE> 
               Texture_surface_handle;

typedef Identifier< HND_FIBER> 
               Fiber_handle;

} // namespace neuraylib

} // namespace mi

#endif // MI_NEURAYLIB_IDENTIFIER_H

Namespaces

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

Classes

class 
Handle class for type-safety. More...
struct 
Handle class for type-safety. More...

Typedefs

typedef Identifier< HND_CURVE>  
Handle for curve More...
typedef Identifier_struct< HND_CURVE>  
Handle for curves More...
typedef Identifier< HND_CURVE_SEGMENT>  
Handle for curve segments More...
typedef Identifier_struct< HND_CURVE_SEGMENT>  
Handle for curve segments More...
typedef Identifier< HND_FIBER>  
Handle for fibers More...
typedef Identifier_struct< HND_FIBER, Uint64>  
Handle for fibers More...
typedef Identifier< HND_POLY>  
Handle for polygons More...
typedef Identifier_struct< HND_POLY>  
Handle for polygons More...
typedef Identifier< HND_SURFACE>  
Handle for surfaces More...
typedef Identifier_struct< HND_SURFACE>  
Handle for surfaces More...
typedef Identifier< HND_TEXTURE_SURFACE>  
Handle for texture surfaces More...
typedef Identifier_struct< HND_TEXTURE_SURFACE>  
Handle for texture surfaces More...
typedef Identifier< HND_TRIANGLE>  
Handle for triangles More...
typedef Identifier_struct< HND_TRIANGLE>  
Handle for triangles More...

Enumerations

enum  {HND_TRIANGLE, HND_POLY, HND_SURFACE, HND_CURVE, HND_CURVE_SEGMENT, HND_TEXTURE_SURFACE, HND_FIBER, HND_SCENE_GRAPH_VERSION, HND_SCENE_GRAPH_NODE, HND_SCENE_GRAPH_OBJECT_NODE, HND_SCENE_GRAPH_LIGHT_NODE, HND_SCENE_GRAPH_MESH, HND_SCENE_GRAPH_MATERIAL, HND_SCENE_GRAPH_DECAL_NODE, HND_SCENE_GRAPH_PROJECTOR_NODE, HND_SCENE_GRAPH_SECTION_OBJECT_NODE }
Various handle types. More...