23 #define _USE_MATH_DEFINES
38 static inline int streq(
const char* a,
const char* b )
40 return strcmp( a, b ) == 0;
79 std::cerr <<
"SMF: Malformed annotation [" << cmd <<
"]" << std::endl;
88 : mdbImpl( impl ), mCurrentMeshHandle( 0 ), lineNo( 0 ), commandNo( 0 ), versionMajor( 0 ), versionMinor( 0 )
109 std::vector< int >& ,
119 const Tag* file_id_tag )
134 std::string partition_tag_name;
135 result = opts.
get_option(
"PARTITION", partition_tag_name );
138 std::ifstream smfFile( filename );
164 std::vector< double* > arrays;
166 start_handle_out = 0;
177 arrays[1][i] =
_coords[i3 + 1];
178 arrays[2][i] =
_coords[i3 + 2];
183 start_handle_elem_out = 0;
187 MB_START_ID, start_handle_elem_out, conn_array_out );
190 conn_array_out[j] =
_connec[j];
213 if(
streq( cmd,
"SMF" ) )
235 else if(
streq( cmd,
"vertices" ) )
237 if( argv.size() == 1 )
242 else if(
streq( cmd,
"faces" ) )
244 if( argv.size() == 1 )
249 else if(
streq( cmd,
"BBox" ) )
252 else if(
streq( cmd,
"BSphere" ) )
255 else if(
streq( cmd,
"PXform" ) )
257 if( argv.size() == 16 )
264 else if(
streq( cmd,
"MXform" ) )
266 if( argv.size() == 16 )
280 std::vector< std::string > argv;
283 while( *ln ==
' ' || *ln ==
'\t' )
287 if( ln[0] ==
'\n' || ln[0] ==
'\0' )
return MB_SUCCESS;
290 if( ln[0] ==
'#' && ln[1] !=
'$' )
return MB_SUCCESS;
293 cmd = strtok( ln,
" \t\n" );
295 while( ( s = strtok( NULL,
" \t\n" ) ) )
297 std::string stg( s );
298 argv.push_back( stg );
302 if( cmd[0] ==
'#' && cmd[1] ==
'$' )
310 bool handled =
false;
312 while( entry->
name && !handled )
316 err = ( this->*( entry->
cmd ) )( argv );
343 if( ( argv.size() < (
unsigned)count ) || ( argv.size() > (
unsigned)count && argv[count][0] !=
'#' ) )
357 for(
int i = 0; i < count; i++ )
359 results[i] = strtod( argv[i].c_str(), &endptr );
375 state.back().vertex( v );
378 for(
int j = 0; j < 3; j++ )
406 for(
unsigned int i = 0; i < argv.size(); i++ )
408 vert[i] = strtol( argv[i].c_str(), &endptr, 0 );
417 for(
int j = 0; j < 3; j++ )
436 if(
state.size() == 1 )
448 if( argv.size() < 2 || argv[0] !=
"vertex_coorection" )
return MB_SUCCESS;
451 int val = strtol( argv[1].c_str(), &endptr, 0 );
457 state.back().set_vertex_correction( val );
482 state.back().mmult( M );
495 state.back().mmult( M );
505 double axis[3] = { 0., 0., 0. };
506 std::string axisname = argv.front();
507 argv.erase( argv.begin() );
508 if( axisname.size() != 1 )
512 switch( axisname[0] )
530 angle *= M_PI / 180.0;
533 state.back().mmult( M );
544 state.back().mmult( mat );
555 state.back().mload( mat );