bool IniFormatter::writeToStream(const Node* root, Stream* stream, unsigned int tcount, unsigned int nameformat, unsigned int varformat) { if (root && stream) { UnicodeString temp; if (root->getParent() && root->getName().length()>0) { // cheap way of saying the node is not a root node writeTabs(stream, tcount, false); root->getNameFormatted(temp, nameformat); stream->writeChar16('['); temp.append(']'); stream->writeLine(temp); } Node* node; ValueVariable* value; for (VarList::const_iterator iter=root->begin(); iter!=root->end(); ++iter) { value=dynamic_cast<ValueVariable*>(*iter); node=dynamic_cast<Node*>(*iter); if (node) { writeToStream(node, stream, tcount, nameformat, varformat); } else if (value) { if (formatValue(*value, temp, nameformat, varformat)) { writeTabs(stream, tcount, false); stream->writeLine(temp); } } } return true; } return false; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::WorldBegin() { writeTabs(); m_ribFile<<"WorldBegin "<<std::endl; ++m_tabs; ++m_worldCount; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::TransformEnd() { --m_tabs; writeTabs(); m_ribFile<<"TransformEnd "<<std::endl; --m_transformCount; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::TransformBegin() { writeTabs(); m_ribFile<<"TransformBegin "<<std::endl; ++m_tabs; ++m_transformCount; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::WorldEnd() { --m_tabs; writeTabs(); m_ribFile<<"WorldEnd "<<std::endl; --m_worldCount; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::AttributeBegin() { writeTabs(); m_ribFile<<"AttributeBegin "<<std::endl; ++m_tabs; ++m_attribCount; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::AttributeEnd() { --m_tabs; writeTabs(); m_ribFile<<"AttributeEnd "<<std::endl; m_attribCount--; }
size_t write(uint8_t c) { size_t n = 0; if (isNewLine) n += writeTabs(); n += sink->write(c); isNewLine = c == '\n'; return n; }
void writeStream(std::ostream &stream, int tabCount) { for(ValueMap::iterator vi = values.begin(); vi != values.end(); ++vi) { writeTabs(stream, tabCount); stream << (*vi).first << " = " << (*vi).second << std::endl; } for(GroupMap::iterator gi = groups.begin(); gi != groups.end(); ++gi) { if((gi != groups.begin()) || (!values.empty())) stream << std::endl; writeTabs(stream, tabCount); stream << (*gi).first << std::endl; writeTabs(stream, tabCount); stream << "{" << std::endl; (*gi).second->writeStream(stream, tabCount + 1), writeTabs(stream, tabCount); stream << "}" << std::endl; } if(!lines.empty() && ((!groups.empty() || !values.empty()))) stream << std::endl; for(LineList::iterator li = lines.begin(); li != lines.end(); ++li) { writeTabs(stream, tabCount); std::string &f = (*li); stream << (*li) << std::endl; } }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::Scale(const Real _x, const Real _y, const Real _z ) { writeTabs(); m_ribFile<<"Scale "<<_x<<" "<<_y<<" "<<_z<<std::endl; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::Torus( const Real _major, const Real _minor, const Real _phiMin,const Real _phiMax, const Real _sweep ) { writeTabs(); m_ribFile<<"Torus "<<_major<<" "<<_minor<<" "<<_phiMin<<" "<<_phiMax<<" "<<_sweep<<std::endl; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::Disk( const Real _height,const Real _radius, const Real _sweep ) { writeTabs(); m_ribFile<<"Disk "<<_height<<" "<<_radius<<" "<<_sweep<<std::endl; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::Hyperboloid( const Real _p1, const Real _p2, const Real _sweep ) { writeTabs(); m_ribFile<<"Hyperboloid "<<_p1<<" "<<_p2<<" "<<_sweep<<std::endl; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::Paraboloid(const Real _topRad,const Real _zMin, const Real _zMax, const Real _sweep ) { writeTabs(); m_ribFile<<"Paraboloid "<<_topRad<<" "<<_zMin<<" "<<_zMax<<" "<<_sweep<<std::endl; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::Cylinder( const Real _radius, const Real _zMin, const Real _zMax, const Real _sweep ) { writeTabs(); m_ribFile<<"Cylinder "<<_radius<<" "<<_zMin<<" "<<_zMax<<" "<<_sweep<<std::endl; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::Sphere(const Real _radius, const Real _zMin,const Real _zMax, const Real _sweep ) { writeTabs(); m_ribFile<<"Sphere "<<_radius<<" "<<_zMin<<" "<<_zMax<<" "<<_sweep<<std::endl; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::Rotate(const Real _angle,const Real _x, const Real _y, const Real _z ) { writeTabs(); m_ribFile<<"Rotate "<<_angle<<" "<<_x<<" "<<_y<<" "<<_z<<std::endl; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::Translate( const Real _x, const Real _y, const Real _z ) { writeTabs(); m_ribFile<<"Translate "<<_x<<" "<<_y<<" "<<_z<<std::endl; }
//---------------------------------------------------------------------------------------------------------------------- void RibExport::writeToFile( std::string _string ) { writeTabs(); m_ribFile<<_string<<std::endl; }