61 class profiledResultData
65 std::string profiled_result_string;
66 std::string thread_debug_string;
68 void setResult(pthread_t
id,std::string result_profile)
70 if(!result_profile.empty())
71 {this->thread_id=id;this->profiled_result_string=result_profile;}
73 void setResult(pthread_t
id,std::string result_profile, std::string result_thread_debug)
75 if(!result_profile.empty())
78 this->profiled_result_string=result_profile;
79 this->thread_debug_string=result_thread_debug;
82 void setThread_debug(std::string result){this->thread_debug_string=result;}
83 bool isEmpty(){
return this->profiled_result_string.empty()&&this->thread_debug_string.empty();}
84 pthread_t getId(){
return thread_id;}
85 std::string getResult();
91 static string nvidia_graphics_options_file_url;
98 Scene( Inst< SFChildNode > _sceneRoot = 0,
99 Inst< MFWindow > _window = 0,
100 Inst< SFFloat > _frameRate = 0
103 Inst< MFString > _profiledResult = 0
105 ,Inst< SFFloat > _maxFrameRate= 0
108 Inst< SFNvidiaGraphicsOptions > _nvidiaGraphicsOptions = 0
117 return last_traverseinfo;
138 void loadSceneRoot(
const string &url );
141 void setSceneRoot( SAI::SAIScene *scene_info );
149 return shadow_caster.get();
156 static void mainLoop();
184 H3DUniquePtr< MFString > profiledResult;
186 Scene::profiledResultData H3D_scene_result;
187 Scene::profiledResultData haptic_result;
188 Scene::profiledResultData H3D_sofa_result;
191 std::string generateProfileResult();
193 struct ProfileNodeResult {
201 static bool compareRenderTime (
const ProfileNodeResult& lhs,
const ProfileNodeResult& rhs ) {
return lhs.render_time > rhs.render_time; }
202 static bool compareTraverseTime(
const ProfileNodeResult& lhs,
const ProfileNodeResult& rhs ) {
return lhs.traverse_time > rhs.traverse_time; }
204 typedef std::vector < ProfileNodeResult > ProfileNodeResultVec;
205 std::string exclusive_times_string;
206 H3DTime exclusive_times_update_time;
208 void computeExclusiveTimes( Node& _node, ProfileNodeResultVec& _result );
214 static H3DUniquePtr< SFTime >
time;
221 H3DUniquePtr<SFNvidiaGraphicsOptions> nvidiaGraphicsOptions;
242 callback_lock.lock();
243 callbacks.push_back( make_pair( func, data ) );
244 callback_lock.unlock();
248 struct ProgramSetting {
250 ProgramSetting(
Field *_field,
251 const string &_name =
"",
252 const string &_section =
""):
255 section( _section ) {}
264 typedef std::list< ProgramSetting > ProgramSettings;
277 static void addProgramSetting( Field *field,
278 const string &name =
"",
279 const string §ion =
"Main settings");
287 static bool removeProgramSetting(
const string &name,
288 const string §ion =
"Main settings" );
294 static bool removeProgramSetting( Field *field );
301 static Field *getProgramSetting(
const string &name,
302 const string §ion =
"Main settings" );
304 typedef ProgramSettings::iterator SettingsIterator;
308 static SettingsIterator programSettingsBegin();
311 static SettingsIterator programSettingsEnd();
316 } ProgramSettingsEvent;
319 typedef void (*ProgramSettingsCallbackFunc)( ProgramSettingsEvent event,
320 const ProgramSetting &settings,
323 typedef std::pair< ProgramSettingsCallbackFunc, void * > ProgramSettingsCallbackId;
327 static ProgramSettingsCallbackId addProgramSettingsCallback( ProgramSettingsCallbackFunc func,
331 static bool removeProgramSettingsCallback( ProgramSettingsCallbackId
id );
334 static void clearProgramSettingsCallbacks();
340 static H3D::Node* findNodeType(
H3D::Node *node,
const std::string &nodeType,
const std::string &nodeName=
"" );
342 typedef std::map < Node*, AutoRefVector<Node> > NodeParentsMap;
343 typedef std::map < std::string,std::vector < std::string > > SearchFieldNameMap;
344 typedef std::vector < std::string > StringVec;
402 template <
typename NodeType >
406 const std::string& _nodeName=
"",
407 NodeParentsMap* _parentMap= NULL,
408 SearchFieldNameMap* _searchFieldNames= NULL,
409 StringVec* _typeNames= NULL,
410 bool _exactNodeName=
true,
411 bool _verbose=
false,
413 StringVec* _ignoreTraverseNodeTypeNames= NULL ) {
416 if ( _ignoreTraverseNodeTypeNames &&
417 find ( _ignoreTraverseNodeTypeNames->begin(), _ignoreTraverseNodeTypeNames->end(), _node.
getTypeName() ) != _ignoreTraverseNodeTypeNames->end() ) {
422 if ( _typeNames == NULL ||
423 find ( _typeNames->begin(), _typeNames->end(), _node.
getTypeName() ) != _typeNames->end() ) {
424 if ( NodeType* n=
dynamic_cast < NodeType*
> ( &_node ) ) {
425 const std::string& node_name= n->getName();
426 if ( _nodeName.empty() ||
427 ( ( _exactNodeName && _nodeName == node_name) ||
428 (!_exactNodeName && node_name.find ( _nodeName ) != std::string::npos ) ) ) {
430 if ( _parentMap && _parent ) {
431 (*_parentMap)[n].push_back ( _parent );
438 std::vector<std::string> field_names;
439 if ( _searchFieldNames ) {
440 SearchFieldNameMap::iterator i= _searchFieldNames->find ( _node.
getTypeName() );
441 if ( i != _searchFieldNames->end() ) {
442 field_names= (*i).second;
454 Field *f = i.getField( &_node );
458 if ( _searchFieldNames ) {
459 if ( find ( field_names.begin(), field_names.end(), f->
getName() ) == field_names.end() ) {
466 Node* c= sf_node->getValue();
469 Console(LogLevel::Error) <<
"Node::findNodes(): " << _node.
getName() <<
" -> " << f->
getName() << endl;
471 findNodes ( *c, _result, _nodeName, _parentMap, _searchFieldNames, _typeNames, _exactNodeName, _verbose, &_node, _ignoreTraverseNodeTypeNames );
473 }
else if (
MFNode* mf_node=
dynamic_cast< MFNode *
>( f ) ) {
474 const NodeVector& children= mf_node->getValue();
479 Console(LogLevel::Error) <<
"Node::findNodes(): " << _node.
getName() <<
" -> " << f->
getName() << endl;
481 findNodes ( *c, _result, _nodeName, _parentMap, _searchFieldNames, _typeNames, _exactNodeName, _verbose, &_node, _ignoreTraverseNodeTypeNames );
491 SAI::Browser SAI_browser;
495 static ProgramSettings program_settings;
497 typedef std::list< std::pair< CallbackFunc, void * > > CallbackList;
498 typedef std::list< std::pair< ProgramSettingsCallbackFunc, void * > > ProgramSettingsCallbackList;
500 static CallbackList callbacks;
501 static ProgramSettingsCallbackList program_settings_callbacks;
510 setName(
"Scene::eventSink" );
515 virtual void update();
533 static bool NVOptions_applied;
537 H3DTime last_unused_texture_check;
541 callback_lock.
lock();
542 for( CallbackList::iterator i = callbacks.begin(); i != callbacks.end(); ++i ) {
543 if( (*i).second == data ) {
544 callbacks.erase( i );
Header file for H3DWindowNode.
Header file for NvidiaGraphicsOptions.
Header file for common SAI interface classes and functions for use by script engine implementations s...
Header file for ShadowCaster.
Header file for X3DChildNode, X3D scene-graph node.
const_iterator end() const
std::vector< RefCountedClassType * >::const_iterator const_iterator
void push_back(const value_type &x)
const_iterator begin() const
std::string getTypeName() const
std::string getName() const
The Field class.
Definition: Field.h:46
string getName()
Gets the name of the field.
Definition: Field.cpp:417
@ INPUT_ONLY
The value of the field can only set, not read.
Definition: Field.h:67
AccessType getAccessType()
Get the access type of the field.
Definition: Field.h:215
The FieldDBConstIterator is an iterator class used for iterating over the field instances in an H3DNo...
Definition: H3DNodeDatabase.h:217
MFNode is almost like any MField but it encapsulates a vector of Node pointers.
Definition: MFNode.h:44
Node is the base class for all classes that can be part of the H3D scene-graph.
Definition: Node.h:46
SFNode is almost like any SField but it encapsulates a pointer to a Node.
Definition: SFNode.h:45
The EventSink class makes all fields up-to-date what are routed to it, with the exception of Periodic...
Definition: Scene.h:506
EventSink()
Constructor.
Definition: Scene.h:509
The Scene node is topmost node that takes care of the rendering of the scene graph both haptically an...
Definition: Scene.h:56
static void addCallback(CallbackFunc func, void *data)
Add a callback function to be called after scene traversal and rendering.
Definition: Scene.h:241
static set< Scene * > scenes
All instances of Scene that has been created.
Definition: Scene.h:218
H3DUniquePtr< SFFloat > frameRate
The instantaneous frame rate of the scene.
Definition: Scene.h:172
bool isActive()
Returns if the Scene instance is active or not.
Definition: Scene.h:127
TraverseInfo * getLastTraverseInfo()
Returns the TraverseInfo from the previous sceneRoot traversal.
Definition: Scene.h:116
static void findNodes(Node &_node, AutoRefVector< NodeType > &_result, const std::string &_nodeName="", NodeParentsMap *_parentMap=NULL, SearchFieldNameMap *_searchFieldNames=NULL, StringVec *_typeNames=NULL, bool _exactNodeName=true, bool _verbose=false, Node *_parent=NULL, StringVec *_ignoreTraverseNodeTypeNames=NULL)
Finds all the nodes of a given type (and optional name) by searching downwards from _node through all...
Definition: Scene.h:403
H3DUniquePtr< SFChildNode > sceneRoot
The scene graph to render in this scene.
Definition: Scene.h:162
CallbackCode
Return code for callback functions.
Definition: Scene.h:228
@ CALLBACK_DONE
The callback is done and should not be called any more.
Definition: Scene.h:230
static H3DUniquePtr< EventSink > eventSink
Any field routed to this field will be updated once per frame.
Definition: Scene.h:520
H3DUniquePtr< SFFloat > maxFrameRate
A desired maximum frame rate (Hz).
Definition: Scene.h:182
SAI::Browser * getSAIBrowser()
Returns the SAI::Browser object for this Scene.
Definition: Scene.h:144
static void removeCallback(void *data)
Remove a callback function by finding a callback with the same data adress.
Definition: Scene.h:540
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: Scene.h:225
static H3DUniquePtr< SFTime > time
Current time within the simulation, updated during each graphic loop.
Definition: Scene.h:214
void setActive(bool _active)
Set whether this Scene instance should be active or not.
Definition: Scene.h:122
H3DUniquePtr< MFWindow > window
The windows to render into this scene.
Definition: Scene.h:167
The ShadowCaster node uses shadow volumes using stencil buffer to cast shadows from objects in a scen...
Definition: ShadowCaster.h:99
TraverseInfo is a structure that is passed along when traversing the scene graph.
Definition: TraverseInfo.h:57
Template to make sure that the Nodes that are added to a MFNode are of a specified Node type.
Definition: MFNode.h:221
Template to make sure that the Node that is set in a SFNode is of a specified Node type.
Definition: SFNode.h:97
This abstract node type indicates that concrete node types derived from it contain children nodes and...
Definition: X3DGroupingNode.h:53
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194
FieldDBConstIterator fieldDBEnd()
Returns an iterator pointing at the end of fields in the H3DNodeDatabase.
Definition: H3DNodeDatabase.h:435
FieldDBConstIterator fieldDBBegin()
Gets an iterator to the beginning first field in the H3DNodeDatabase.
Definition: H3DNodeDatabase.h:430
static H3DNodeDatabase * lookupNodeInstance(const Node *n)
Get the database for a specific node instance.
Definition: H3DNodeDatabase.cpp:386