Changeset 657 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 02/20/06 19:06:03 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r508 r657 61 61 // StdInParseHandlers: Constructors and Destructor 62 62 // --------------------------------------------------------------------------- 63 X3dParseHandlers::X3dParseHandlers(SceneGraphNode *root ):63 X3dParseHandlers::X3dParseHandlers(SceneGraphNode *root, const bool loadPolygonsAsMeshes): 64 64 mElementCount(0) 65 65 , mAttrCount(0) 66 66 , mCharacterCount(0) 67 67 , mSpaceCount(0) 68 // , mCurrentObjectId(0)68 , mLoadPolygonsAsMeshes(loadPolygonsAsMeshes) 69 69 { 70 70 mCurrentNode = root; … … 124 124 if (ptr == endptr || index == -1) { 125 125 if (vertices.size() > 2) { 126 Face *face = new Face(vertices); 127 mCurrentMesh->mFaces.push_back(face); 126 Face *face = new Face(vertices); 127 128 mCurrentMesh->mFaces.push_back(face); 129 130 // every polygon is a mesh => store in mesh instance and create new mesh 131 if (mLoadPolygonsAsMeshes) 132 { 133 mCurrentMesh->Preprocess(); 134 135 // make an instance of this mesh 136 MeshInstance *mi = new MeshInstance(mCurrentMesh); 137 mCurrentNode->mGeometry.push_back(mi); 138 139 mCurrentMesh = new Mesh(); 140 } 141 128 142 } 129 143 vertices.clear(); … … 163 177 AttributeList& attributes) 164 178 { 165 int len = attributes.getLength(); 166 int i; 167 VertexContainer vertices; 168 for (i=0; i < len; i++) { 169 string attrName(StrX(attributes.getName(i)).LocalForm()); 170 if (attrName == "point") { 171 StrX attrValue(attributes.getValue(i)); 172 const char *ptr = attrValue.LocalForm(); 173 char *endptr; 174 while(1) { 175 float x = (float)strtod(ptr, &endptr); 176 if (ptr == endptr) 177 break; 178 ptr = endptr; 179 float y = (float)strtod(ptr, &endptr); 180 if (ptr == endptr) 181 break; 182 ptr = endptr; 183 float z = (float)strtod(ptr, &endptr); 184 if (ptr == endptr) 185 break; 186 ptr = endptr; 187 if (*ptr == ',') 188 ptr++; 189 Vector3 v(x, y, z); 190 vertices.push_back(v); 191 } 192 mCurrentMesh->mVertices = vertices; 193 } 194 } 179 int len = attributes.getLength(); 180 181 int i; 182 VertexContainer vertices; 183 184 for (i=0; i < len; i++) 185 { 186 string attrName(StrX(attributes.getName(i)).LocalForm()); 187 188 if (attrName == "point") 189 { 190 StrX attrValue(attributes.getValue(i)); 191 192 193 const char *ptr = attrValue.LocalForm(); 194 char *endptr; 195 196 197 while(1) 198 { 199 float x = (float)strtod(ptr, &endptr); 200 201 if (ptr == endptr) 202 break; 203 204 ptr = endptr; 205 206 float y = (float)strtod(ptr, &endptr); 207 208 if (ptr == endptr) 209 break; 210 211 ptr = endptr; 212 213 float z = (float)strtod(ptr, &endptr); 214 if (ptr == endptr) 215 break; 216 217 ptr = endptr; 218 219 if (*ptr == ',') 220 ptr ++; 221 222 Vector3 v(x, y, z); 223 vertices.push_back(v); 224 } 225 mCurrentMesh->mVertices = vertices; 226 } 227 } 195 228 } 196 229 … … 284 317 bool 285 318 X3dParser::ParseFile(const string filename, 286 SceneGraphNode **root) 319 SceneGraphNode **root, 320 const bool loadPolygonsAsMeshes) 287 321 { 288 322 // Initialize the XML4C system … … 317 351 // 318 352 *root = new SceneGraphNode; 319 X3dParseHandlers handler(*root );353 X3dParseHandlers handler(*root, loadPolygonsAsMeshes); 320 354 parser->setDocumentHandler(&handler); 321 355 parser->setErrorHandler(&handler); … … 389 423 // --------------------------------------------------------------------------- 390 424 X3dViewCellsParseHandlers::X3dViewCellsParseHandlers(ViewCellsManager *viewCellsManager, 391 float viewCellHeight):425 const float viewCellHeight): 392 426 mElementCount(0), 393 427 mAttrCount(0), -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.h
r490 r657 12 12 X3dParser():Parser(), mViewCellHeight(5.0f) {} 13 13 14 bool ParseFile(const string filename, SceneGraphNode **root );14 bool ParseFile(const string filename, SceneGraphNode **root, const bool loadPolygonsAsMeshes = false); 15 15 bool ParseFile(const string filename, ViewCellsManager &viewCells); 16 16 -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParserXerces.h
r490 r657 24 24 // Constructors and Destructor 25 25 // ----------------------------------------------------------------------- 26 X3dParseHandlers(SceneGraphNode *root );26 X3dParseHandlers(SceneGraphNode *root, const bool loadPolygonsAsMeshes = false); 27 27 ~X3dParseHandlers(); 28 28 … … 64 64 Mesh *mCurrentMesh; 65 65 Material *mCurrentMaterial; 66 //int mCurrentObjectId;66 bool mLoadPolygonsAsMeshes; 67 67 68 68 // Handlers for X3D … … 117 117 // ----------------------------------------------------------------------- 118 118 X3dViewCellsParseHandlers(ViewCellsManager *viewCellsManager, 119 float viewCellHeight);119 const float viewCellHeight); 120 120 ~X3dViewCellsParseHandlers(); 121 121 … … 156 156 ViewCellsManager *mViewCellsManager; 157 157 float mViewCellHeight; 158 158 159 159 160 VertexIndexContainer mCurrentVertexIndices;
Note: See TracChangeset
for help on using the changeset viewer.