Changeset 10040 for OpenSceneGraph/trunk/src/osgPlugins/ply/vertexData.cpp
- Timestamp:
- 04/13/09 11:35:52 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/ply/vertexData.cpp
r10012 r10040 158 158 float version; 159 159 bool result = false; 160 int nComments; 161 char** comments; 162 163 PlyFile* file = ply_open_for_reading( const_cast< char* >( filename ), 160 int nComments; 161 char** comments; 162 163 PlyFile* file = NULL; 164 165 // Try to open ply file as for reading 166 try{ 167 file = ply_open_for_reading( const_cast< char* >( filename ), 164 168 &nPlyElems, &elemNames, 165 169 &fileType, &version ); 170 } 171 // Catch the if any exception thrown 172 catch( exception& e ) 173 { 174 MESHERROR << "Unable to read PLY file, an exception occured: " 175 << e.what() << endl; 176 } 166 177 167 178 if( !file ) … … 173 184 174 185 MESHASSERT( elemNames != 0 ); 186 175 187 176 188 nComments = file->num_comments; … … 196 208 int nProps; 197 209 198 PlyProperty** props = ply_get_element_description( file, elemNames[i], 199 &nElems, &nProps ); 210 PlyProperty** props = NULL; 211 try{ 212 props = ply_get_element_description( file, elemNames[i], 213 &nElems, &nProps ); 214 } 215 catch( exception& e ) 216 { 217 MESHERROR << "Unable to get PLY file description, an exception occured: " 218 << e.what() << endl; 219 } 200 220 MESHASSERT( props != 0 ); 201 221 … … 222 242 if( ignoreColors ) 223 243 MESHINFO << "Colors in PLY file ignored per request." << endl; 224 225 // Read vertices and store in a std::vector array 226 readVertices( file, nElems, hasColors && !ignoreColors ); 227 // Check whether all vertices are loaded or not 228 MESHASSERT( _vertices->size() == static_cast< size_t >( nElems ) ); 229 // Check all color elements read or not 230 if( hasColors && !ignoreColors ) 231 MESHASSERT( _colors->size() == static_cast< size_t >( nElems ) ); 244 245 try { 246 // Read vertices and store in a std::vector array 247 readVertices( file, nElems, hasColors && !ignoreColors ); 248 // Check whether all vertices are loaded or not 249 MESHASSERT( _vertices->size() == static_cast< size_t >( nElems ) ); 250 // Check all color elements read or not 251 if( hasColors && !ignoreColors ) 252 MESHASSERT( _colors->size() == static_cast< size_t >( nElems ) ); 253 } 254 catch( exception& e ) 255 { 256 MESHERROR << "Unable to read vertex in PLY file, an exception occured: " 257 << e.what() << endl; 258 // stop for loop by setting the loop variable to break condition 259 // this way resources still get released even on error cases 260 i = nPlyElems; 261 262 } 232 263 } 233 264 // If the string is face means triangle info started
