Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoInventorBase.h
Go to the documentation of this file.
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-2017 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : David Beilloin (MMM yyyy)
22**=======================================================================*/
23
24#ifndef _SO_INVENTOR_BASE_
25#define _SO_INVENTOR_BASE_
26
27#include <Inventor/SbBase.h>
28#include <Inventor/STL/set>
29#include <Inventor/STL/map>
30
32
33class SbThreadRWMutex;
34
53{
54public:
60 static void init();
61
68 static void finish();
69
74 static bool isInitialized();
75
76private:
78 enum PowerState
79 {
81 RUNNING,
83 RESUME,
85 SUSPEND
86 };
87
89 static void setPowerState(PowerState state);
90
92 static PowerState getPowerState();
93
94 // We are able to manage 2 multi-threads cases on MS Windows platforms:
95 // 1- standard case where all threads share common global objects
96 // and can interact each other (notification/rendering/multiGPU...)
97 //
98 // => this mode is enabled by default
99 //
100 // 2- Experimental case where each threads can be considered as a separate Open Inventor application
101 // each thread do not share anything, and then are independent from each other.
102 // The following objects are thread specific:
103 // - SoSensorManager::m_pThreadSensorMgr : SoSensorManagerThread handling notification queues
104 // - SoDB::SoGlobalDBInfos : main globalField, realTimeSensor sensor, realTime field
105 // - SoGlobalField::nameDict : globalField's dictionnary
106 // -
107 // IMPORTANT: When using this mode, no notification MUST be done from a a thread to anoher.
108 // (ie, it is not allowed to modified an Open Inventor field/node/scenegraph... from another
109 // thread than the one who created the given object.
110 //
111 // => this mode is enabled through envvar OIV_MULTITHREAD_APPLICATION
112 //
113 static SbBool isMultiThreadApplication()
114 {
115 if (s_isMultiThreadApplicationSet)
116 return s_isMultiThreadApplication;
117 return checkMultiThreadApplicationMode();
118 }
119
120#if 1 SoDEPRECATED
122 static void threadInit();
123SoDEPRECATED
125 static void threadFinish();
126#endif
128 static bool checkMultithread()
129 { return s_checkMultithread; }
130
131 // globalMutex provides a way for any application to use a global mutex.
132 // It is also used inside OIV in some instances
133 static SbThreadRWMutex* getGlobalMutex()
134 { return globalMutex; }
135
136 // returns true if OIV_MULTITHREAD_APPLICATION_DISABLE_LOCK is set, it allows to disable
137 // any mutex lock and do internal performance test with OIV_MULTITHREAD_APPLICATION mode set
138 static SbBool forceShouldCreateMutex();
139
140 // global lock for init/finish operation
141 static SbThreadMutex s_initFinishLock;
142
143 // returns TRUE if we should use double precision math internally
144 // see also SoPreference (OIV_DOUBLE_PRECISION)
145 static inline bool useDoublePrecision()
146 { return s_doublePrecision; }
147
148 static inline void setDoublePrecision( bool val )
149 { s_doublePrecision = val; }
150
151 // returns TRUE if we should print debug msg when getting Zero vector length
152 // see also SoPreference (OIV_REPORT_ZERO_VECTORS)
153 static inline bool useReportZeroVector()
154 { return s_reportZeroVectors; }
155
156 // returns the current intersection epsilon value to use (OIV_INTERSECT_EPSILON)
157 static inline double getIntersectionEpsilon()
158 { return s_intersectionEpsilon; }
159
160 // returns the current intersection epsilon value to use (OIV_INTERSECT_EPSILON)
161 static inline double getIntersectionEpsilonSquared()
162 { return s_intersectionEpsilonSquared; }
163
164 static inline void setIntersectionEpsilon(double epsilon)
165 { s_intersectionEpsilon = epsilon; s_intersectionEpsilonSquared = epsilon*epsilon;}
166
167 //return true if finish is on the run
168 static bool isFinishing();
169
170private:
171 // library usage counter
172 static int s_initRefCount;
173
174 // The isMultithreadedApplication flag can be set to true or false only one time, that's
175 // why we need a threadApplicationModeIsSet flag.
176 static bool checkMultiThreadApplicationMode();
177 static bool s_isMultiThreadApplication;
178 static bool s_isMultiThreadApplicationSet;
179
180 static const char *s_versionString;
181 // Global mutex
182 static SbThreadRWMutex *globalMutex;
183
184 static bool s_checkMultithread;
185
186 // Use double precision math internally? (OIV_DOUBLE_PRECISION)
187 static bool s_doublePrecision;
188
189 // see SoPreference::OIV_REPORT_ZERO_VECTORS envvar
190 static bool s_reportZeroVectors;
191
192 // see SoPreferences::OIV_INTERSECT_EPSILON
193 static double s_intersectionEpsilon;
194 static double s_intersectionEpsilonSquared;
195
196 static bool s_isFinishing;
197
199 static PowerState s_powerState;
200};
201
202#endif /* _SO_INVENTOR_BASE_ */
203
204
static void finish()
General basic object database.
static bool isInitialized()
Returns TRUE if database is initialized (for error checking)
static void init()
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Portable mutex c...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Portable readers...
int SbBool
Boolean type.
Definition SbBase.h:87