void X3D_MODEL_PARSER::readTransform( wxXmlNode* aTransformNode ) { NODE_LIST childnodes; GetChildsByName( aTransformNode, wxT( "Material" ), childnodes ); for( NODE_LIST::iterator node = childnodes.begin(); node != childnodes.end(); node++ ) { readMaterial( *node ); } childnodes.clear(); PROPERTY_MAP properties; GetNodeProperties( aTransformNode, properties ); GetChildsByName( aTransformNode, wxT( "IndexedFaceSet" ), childnodes ); for( NODE_LIST::iterator node = childnodes.begin(); node != childnodes.end(); node++ ) { readIndexedFaceSet( *node, properties ); } childnodes.clear(); }
PatriciaTrieNode<S,T>* PatriciaTrie<S,T>::find_bitindex_node (PatriciaTrieNode<S,T>* root, int bitindex) { // // is the head-pseudo-node requested? // if (bitindex == -1) return head; // // check all the normal nodes // NODE_LIST nodes = GetNodeList (root); NODE_LIST_ITERATOR i = nodes.begin (); NODE_LIST_ITERATOR iend = nodes.end (); for ( ; i != iend; i++) { PatriciaTrieNode<S,T>* node = *i; if (node->bit_index == bitindex) return node; } return NULL; }
bool X3D_MODEL_PARSER::Load( const wxString& aFilename ) { wxLogTrace( traceX3DParser, wxT( "Loading: %s" ), GetChars( aFilename ) ); wxXmlDocument doc; if( !doc.Load( aFilename ) ) { wxLogTrace( traceX3DParser, wxT( "Error while parsing file: %s" ), GetChars( aFilename ) ); return false; } if( doc.GetRoot()->GetName() != wxT( "X3D" ) ) { wxLogTrace( traceX3DParser, wxT( "Filetype is not X3D: %s" ), GetChars( aFilename ) ); return false; } // Switch the locale to standard C (needed to print floating point numbers) LOCALE_IO toggle; childs.clear(); // Shapes are inside of Transform nodes // Transform node contains information about // transition, scale and rotation of the shape NODE_LIST transforms; GetChildsByName( doc.GetRoot(), wxT( "Transform" ), transforms ); for( NODE_LIST::iterator node_it = transforms.begin(); node_it != transforms.end(); node_it++ ) { m_model.reset( new S3D_MESH() ); childs.push_back( m_model ); wxXmlNode* node = *node_it; wxXmlAttribute* prop = node->GetAttributes(); wxLogTrace( traceX3DParser, wxT( "Transform: %s %s" ), prop->GetName(), prop->GetValue() ); readTransform( node ); } return true; }
PatriciaTrie<S,T>* PatriciaTrie<S,T>::Copy (PatriciaTrieNode<S,T>* root) { PatriciaTrieNode<S,T>* newNode = new PatriciaTrieNode<S,T> (); bool recursiveHead = (root == NULL); if (root == NULL) root = head; newNode->bit_index = root->bit_index; newNode->data = root->data; newNode->key = root->key; // // create the subtrees and wire my children to it // or (if there are no subtrees) wire the children to myself // later we will wire the children correctly with some backedges // if (root->left != NULL && root->left->bit_index > root->bit_index) { PatriciaTrie<S,T>* leftTrie = Copy (root->left); newNode->left = leftTrie->head; leftTrie->head = NULL; delete leftTrie; } else { newNode->left = newNode; } if (root->right != NULL && root->right->bit_index > root->bit_index) { PatriciaTrie<S,T>* rightTrie = Copy (root->right); newNode->right = rightTrie->head; rightTrie->head = NULL; delete rightTrie; } else { newNode->right = newNode; } PatriciaTrie<S,T>* newTrie = new PatriciaTrie<S,T> (); newTrie->head = newNode; // // need to adapt the back edges // if (recursiveHead) { NODE_LIST origNodes = GetNodeList (); NODE_LIST newNodes = newTrie->GetNodeList (); assert (origNodes.size() == newNodes.size()); NODE_LIST_ITERATOR iorigBegin = origNodes.begin (); NODE_LIST_ITERATOR iorigEnd = origNodes.end (); NODE_LIST_ITERATOR inewBegin = newNodes.begin (); NODE_LIST_ITERATOR inewEnd = newNodes.end (); for ( ; iorigBegin != iorigEnd && inewBegin != inewEnd; iorigBegin++, inewBegin++) { PatriciaTrieNode<S,T>* origNode = *iorigBegin; PatriciaTrieNode<S,T>* newNode = *inewBegin; // // make some checks that everything went fine // assert (origNode != newNode && origNode->key == newNode->key && origNode->bit_index == newNode->bit_index && origNode->data == newNode->data ); // // if the original node has backedges: // find the correct backedge node in the new trie // and wire the children correctly // if (origNode->left->bit_index < origNode->bit_index) newNode->left = newTrie->find_bitindex_node (newTrie->head, origNode->left->bit_index); if (origNode->right->bit_index < origNode->bit_index) newNode->right = newTrie->find_bitindex_node (newTrie->head, origNode->right->bit_index); } // for ( ; iorigBegin != iorigEnd && inewBegin != inewEnd; iorigBegin++, inewBegin++) } // if (recursiveHead) return newTrie; }