/* ************************ Copyright Terrain Experts Inc. Terrain Experts Inc (TERREX) reserves all rights to this source code unless otherwise specified in writing by the President of TERREX. This copyright may be updated in the future, in which case that version supercedes this one. ------------------- Terrex Experts Inc. 4400 East Broadway #314 Tucson, AZ 85711 info@terrex.com Tel: (520) 323-7990 ************************ */ #include #include #include /* trpage_print.cpp Print out the contents of a TerraPage archive. This module provides an example of how to access each of the classes within a TerraPage archive. */ #include /* ****************************************** Print Buffer implementation The print buffer is a way to dump debugging data out to a file (or console). You can make your own subclass of trpgPrintBuffer if you have specific needs. ****************************************** */ trpgPrintBuffer::trpgPrintBuffer() { curIndent = 0; indentStr[0] = 0; } // Increase the current indent void trpgPrintBuffer::IncreaseIndent(int amount) { curIndent+=amount; updateIndent(); } // Decrease the current indent void trpgPrintBuffer::DecreaseIndent(int amount) { curIndent-=amount; curIndent = MAX(0,curIndent); updateIndent(); } // Reprint the indent string void trpgPrintBuffer::updateIndent() { int i; for (i=0;i= TRPG_NOMERGE_VERSION_MAJOR) && (verMinor >=TRPG_NOMERGE_VERSION_MINOR)) { sprintf(ls,"isMaster = %s, numRows = %d, numCols = %d",GetIsMaster()?"YES":"NO",rows,cols); buf.prnLine(ls); } sprintf(ls,"dbVerMinor = %d, dbVerMajor = %d",dbVerMinor,dbVerMajor); buf.prnLine(ls); sprintf(ls,"maxGroupID = %d",maxGroupID); buf.prnLine(ls); sprintf(ls,"sw = (%f,%f), ne = (%f,%f)",sw.x,sw.y,ne.x,ne.y); buf.prnLine(ls); sprintf(ls,"tileType = %d, origin = (%f,%f,%f)",tileType,origin.x,origin.y,origin.z); buf.prnLine(ls); sprintf(ls,"numLods = %d",numLods); buf.prnLine(ls); buf.IncreaseIndent(); for (int i=0;ifirst); buf.prnLine(ls); mat = (const_cast(this))->GetMaterialRef(0,itr->first); if(!mat) { sprintf(ls,"Error: Unable to load material!"); buf.prnLine(ls); } else mat->Print(buf); } buf.DecreaseIndent(2); return true; } /* Print out texture. */ bool trpgTexture::Print(trpgPrintBuffer &buf) const { char ls[1024]; buf.prnLine("----Texture----"); buf.IncreaseIndent(); sprintf(ls,"mode = %d, type = %d",mode,type); buf.prnLine(ls); sprintf(ls,"Name = %s",name); buf.prnLine(ls); sprintf(ls,"useCount = %d",useCount); buf.prnLine(ls); sprintf(ls,"sizeX = %d, sizeY = %d, sizeZ = %d",sizeX,sizeY,numLayer); buf.prnLine(ls); // sprintf(ls,"sensor band organization = %d",org); buf.prnLine(ls); // does this need to be added? sprintf(ls,"ismipmap = %d",isMipmap); buf.prnLine(ls); sprintf(ls,"addr.file = %d, addr.offset = %d",addr.file,addr.offset); buf.prnLine(ls); sprintf(ls,"addr.col = %d, addr.row = %d",addr.col,addr.row); buf.prnLine(ls); buf.DecreaseIndent(); buf.prnLine(); return true; } /* Print out texture table */ bool trpgTexTable::Print(trpgPrintBuffer &buf) const { char ls[1024]; buf.prnLine("----Texture Table----"); buf.IncreaseIndent(); TextureMapType::const_iterator itr = textureMap.begin(); for ( ; itr != textureMap.end( ); itr++) { sprintf(ls,"Texture %d",itr->first); buf.prnLine(ls); itr->second.Print(buf); } buf.DecreaseIndent(); buf.prnLine(); return true; } /* Print out model table */ bool trpgModelTable::Print(trpgPrintBuffer &buf) const { char ls[1024]; buf.prnLine("----Model Table----"); buf.IncreaseIndent(); ModelMapType::const_iterator itr = modelsMap.begin(); for ( ; itr != modelsMap.end( ); itr++) { sprintf(ls,"Model %d",itr->first); buf.prnLine(ls); itr->second.Print(buf); } buf.DecreaseIndent(); buf.prnLine(); return true; } /* Print out a model */ bool trpgModel::Print(trpgPrintBuffer &buf) const { char ls[1024]; buf.prnLine("----Model----"); buf.IncreaseIndent(); sprintf(ls,"type = %d",type); buf.prnLine(ls); if (name) { sprintf(ls,"name = %s",name); buf.prnLine(ls); } sprintf(ls,"diskRef = %d",(int)diskRef), buf.prnLine(ls); sprintf(ls,"useCount = %d",useCount); buf.prnLine(ls); buf.DecreaseIndent(); buf.prnLine(); return true; } /* Print out a tile header */ bool trpgTileHeader::Print(trpgPrintBuffer &buf) const { char ls[1024]; buf.prnLine("----Tile Header----"); buf.IncreaseIndent(); sprintf(ls,"matList size = %d",static_cast(matList.size())); buf.prnLine(ls); buf.IncreaseIndent(); unsigned int i; for (i=0;i(modelList.size())); buf.prnLine(ls); buf.IncreaseIndent(); for (i=0;i(locMats.size())); buf.prnLine(ls); buf.IncreaseIndent(); for (i=0;i(data.size())); buf.IncreaseIndent(); for (unsigned int i=0;i(floatData.size())); buf.prnLine(ls); buf.IncreaseIndent(); for (unsigned int i=0;i(doubleData.size())); buf.IncreaseIndent(); for (unsigned int i=0;i(materials.size())); buf.prnLine(ls); buf.IncreaseIndent(); ls[0] = 0; unsigned int i; for (i=0;i(primLength.size())); buf.prnLine(ls); buf.IncreaseIndent(); ls[0] = 0; for (i=0;i(vertDataFloat.size())); buf.prnLine(ls); buf.IncreaseIndent(); for (i=0;i(vertDataDouble.size())); buf.prnLine(ls); buf.IncreaseIndent(); for (i=0;i(normDataFloat.size())); buf.prnLine(ls); buf.IncreaseIndent(); for (i=0;i(normDataDouble.size())); buf.prnLine(ls); buf.IncreaseIndent(); for (i=0;i(colors.size())); buf.prnLine(ls); buf.IncreaseIndent(); for (i=0;i(texData.size())); buf.IncreaseIndent(); for (i=0;i(lodInfo.size())); buf.prnLine(ls); for (unsigned int i=0;i (ex,ey) = (%d,%d) -> (%d,%d)",sx,sy,ex,ey); buf.prnLine(ls); sprintf(ls,"dest (width,height) = (%d,%d)",destWidth,destHeight); buf.prnLine(ls); for (unsigned int i=0;ifirst); buf.prnLine(ls); itr->second.Print(buf); } buf.DecreaseIndent(); buf.prnLine(); return true; } /* Print out a light node */ bool trpgLight::Print(trpgPrintBuffer &buf) const { char ls[1024]; buf.prnLine("----Light----"); buf.IncreaseIndent(); sprintf(ls,"Light Index = %d",index); buf.prnLine(ls); sprintf(ls,"# Light Locations = %d",static_cast(lightPoints.size()) ); buf.prnLine(ls); buf.DecreaseIndent(); buf.prnLine(); return true; } /* Print out a single range */ bool trpgRange::Print(trpgPrintBuffer &buf) const { char ls[1024]; buf.IncreaseIndent(); sprintf(ls,"category = %s, subCategory = %s",category,subCategory); buf.prnLine(ls); sprintf(ls,"inLod = %f, outLod = %f",inLod,outLod); buf.prnLine(ls); sprintf(ls,"priority = %d",priority); buf.prnLine(ls); buf.DecreaseIndent(); return true; } /* Print out the whole range table */ bool trpgRangeTable::Print(trpgPrintBuffer &buf) const { char ls[1024]; buf.prnLine("----Range Table----"); buf.IncreaseIndent(); RangeMapType::const_iterator itr = rangeMap.begin(); for (int i = 0; itr != rangeMap.end( ); itr++, i++) { sprintf(ls,"----Range %d----",i); buf.prnLine(ls); itr->second.Print(buf); } buf.DecreaseIndent(); return true; } // Print out a label bool trpgLabel::Print(trpgPrintBuffer &buf) const { char ls[1024]; buf.prnLine("----Label----"); buf.IncreaseIndent(); sprintf(ls,"property ID = %d",propertyId); buf.prnLine(ls); sprintf(ls,"text = %s",text.c_str()); buf.prnLine(ls); sprintf(ls,"alignment = %d",alignment); buf.prnLine(ls); sprintf(ls,"tabSize = %d",tabSize); buf.prnLine(ls); sprintf(ls,"scale = %f",scale); buf.prnLine(ls); sprintf(ls,"thickness = %f",thickness); buf.prnLine(ls); sprintf(ls,"desc = %s",desc.c_str()); buf.prnLine(ls); sprintf(ls,"url = %s",url.c_str()); buf.prnLine(ls); sprintf(ls,"location: (%f %f %f)",location.x,location.y,location.z); buf.prnLine(ls); sprintf(ls,"%d support points",static_cast(supports.size())); buf.prnLine(ls); buf.IncreaseIndent(); for (unsigned int i=0;i(styleMap.size())); buf.prnLine(ls); buf.IncreaseIndent(); StyleMapType::const_iterator itr = styleMap.begin(); for (int i = 0; itr != styleMap.end( ); itr++, i++) { sprintf(ls,"Style %d",i); buf.prnLine(ls); itr->second.Print(buf); } buf.DecreaseIndent(); buf.DecreaseIndent(); return true; } // Print out a support style bool trpgSupportStyle::Print(trpgPrintBuffer &buf) const { char ls[1024]; buf.prnLine("----Support Style----"); buf.IncreaseIndent(); sprintf(ls,"Support Type = %d",type); buf.prnLine(ls); sprintf(ls,"material ID = %d",matId); buf.prnLine(ls); buf.DecreaseIndent(); return true; } // Print out the support style table bool trpgSupportStyleTable::Print(trpgPrintBuffer &buf) const { char ls[1024]; buf.prnLine(); buf.prnLine("----Support Style Table----"); buf.IncreaseIndent(); sprintf(ls,"numStyle = %d",static_cast(supportStyleMap.size())); buf.prnLine(ls); buf.IncreaseIndent(); SupportStyleMapType::const_iterator itr = supportStyleMap.begin(); for (int i = 0; itr != supportStyleMap.end( ); itr++, i++) { sprintf(ls,"Style %d",i); buf.prnLine(ls); itr->second.Print(buf); } buf.DecreaseIndent(); buf.DecreaseIndent(); return true; } // Print out a label property bool trpgLabelProperty::Print(trpgPrintBuffer &buf) const { char ls[1024]; buf.prnLine("----Label Property----"); buf.IncreaseIndent(); sprintf(ls,"font ID = %d", fontId); buf.prnLine(ls); sprintf(ls,"support ID = %d", supportId); buf.prnLine(ls); sprintf(ls,"label type = %d", type); buf.prnLine(ls); buf.DecreaseIndent(); return true; } // Print out the text style table bool trpgLabelPropertyTable::Print(trpgPrintBuffer &buf) const { char ls[1024]; buf.prnLine(); buf.prnLine("----Label Property Table----"); buf.IncreaseIndent(); sprintf(ls,"numProperty = %d",static_cast(labelPropertyMap.size())); buf.prnLine(ls); buf.IncreaseIndent(); LabelPropertyMapType::const_iterator itr = labelPropertyMap.begin(); for (int i = 0; itr != labelPropertyMap.end( ); itr++, i++) { sprintf(ls,"Property %d",i); buf.prnLine(ls); itr->second.Print(buf); } buf.DecreaseIndent(); buf.DecreaseIndent(); return true; }