Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoTangentElement.h
1/*=================================================================================
2*** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3*** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4*** ***
5*** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6*** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7*** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8*** ***
9*** RESTRICTED RIGHTS LEGEND ***
10*** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11*** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12*** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13*** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14*** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15*** ***
16*** COPYRIGHT (C) 1996-2019 BY FEI S.A.S, ***
17*** BORDEAUX, FRANCE ***
18*** ALL RIGHTS RESERVED ***
19=================================================================================*/
20
21#pragma once
22
23#include <Inventor/SbLinear.h>
24#include <Inventor/elements/SoReplacedElement.h>
25#include <Inventor/errors/SoDebugError.h>
26
40SoEXTENDER_Documented class SoTangentElement : public SoReplacedElement
41{
42 SO_ELEMENT_HEADER( SoTangentElement );
43
44public:
49 static void set( SoState* state, SoNode* node, int32_t numTangents, const SbVec3f* tangents );
50
54 static const SoTangentElement* getInstance( SoState* state )
55 {
56 return getConstElement<SoTangentElement>( state );
57 }
58
62 int32_t getNum() const
63 {
64 return m_numTangents;
65 }
66
70 const SbVec3f& get( int index ) const
71 {
72 if ( index < 0 || index >= m_numTangents )
73 {
74#if defined(_DEBUG)
75 SoDebugError::post( "SoTangentElement::get",
76 "Index (%d) is out of range 0 - %d",
77 index, m_numTangents - 1 );
78#endif
79 return s_defaultTangent;
80 }
81 return m_tangents[index];
82 }
83
87 virtual void print( FILE* fp ) const;
88
89private:
91 virtual void init( SoState* state );
92
93private:
94 // Initializes the SoTangentElement class
95 static void initClass();
96 static void exitClass();
97
98private:
99 int32_t m_numTangents;
100 const SbVec3f* m_tangents;
101
102 virtual ~SoTangentElement();
103
104private:
109 static SbVec3f s_defaultTangent;
110};
3D vector class.
Definition SbVec.h:932
static void post(const char *methodName, const char *formatString ...)
Posts an error.
Abstract base class for all database nodes.
Definition SoNode.h:145
Abstract base class for each state element whose value is replaced whenever it is set.
Traversal state.
Definition SoState.h:74
Allows read-only access to the top element in the state.
int32_t getNum() const
Returns the number of tangent vectors in an instance.
const SbVec3f & get(int index) const
Returns the indexed tangent from an element.
static void set(SoState *state, SoNode *node, int32_t numTangents, const SbVec3f *tangents)
Sets the current tangents.
virtual void print(FILE *fp) const
Prints element (for debugging).
static const SoTangentElement * getInstance(SoState *state)
Returns the top (current) instance of the element in the state.