meshing/IO.cpp
///Import will try to determine the file type via the file extension
Import will try to determine the file type via the file extension
Import will try to determine the file type via the file extension
bool Import(const char* fn,TriMesh& tri,GeometryAppearance& app)
{
  const char* ext=FileExtension(fn);
  if(0==strcmp(ext,"tri")) {
    return LoadMultipleTriMeshes(fn,tri);
  }
  else {
#if HAVE_ASSIMP
    char* buf = new char[strlen(fn)+1];
    GetFilePath(fn,buf);
    gTexturePath = buf;
    delete [] buf;
    if(!LoadAssimp(fn,tri,app)) {
      LOG4CXX_ERROR(KrisLibrary::logger(),"Import(TriMesh): file "<<fn);
      return false;
    }
    else {
      return true;
    }
#else
    if(0==strcmp(ext,"obj")) {
      if(LoadOBJ(fn,tri,app))
        return true;
    }
    else if(0==strcmp(ext,"off")) {
      ifstream in(fn,ios::in);
      if(!in) return false;
      return LoadOFF(in,tri);
    }
    if(0==strcmp(ext,"wrl")) {
      ifstream in(fn,ios::in);
      if(!in) return false;
      return LoadVRML(in,tri);
    }
    else {
      LOG4CXX_ERROR(KrisLibrary::logger(),"Import(TriMesh): file extension "<<ext);
      return false;
    }
#endif
  }
}
bool Import ( const char * fn , TriMesh & tri , GeometryAppearance & app ) { const char * ext = FileExtension ( fn ) ; if ( 0 == strcmp ( ext , " " ) ) { return LoadMultipleTriMeshes ( fn , tri ) ; } else { #if HAVE_ASSIMP char * buf = new char [ strlen ( fn ) + 1 ] ; GetFilePath ( fn , buf ) ; gTexturePath = buf ; delete [ ] buf ; if ( ! LoadAssimp ( fn , tri , app ) ) { LOG4CXX_ERROR ( KrisLibrary :: logger ( ) , " " << fn ) ; return false ; } else { return true ; } #else if ( 0 == strcmp ( ext , " " ) ) { if ( LoadOBJ ( fn , tri , app ) ) return true ; } else if ( 0 == strcmp ( ext , " " ) ) { ifstream in ( fn , ios :: in ) ; if ( ! in ) return false ; return LoadOFF ( in , tri ) ; } if ( 0 == strcmp ( ext , " " ) ) { ifstream in ( fn , ios :: in ) ; if ( ! in ) return false ; return LoadVRML ( in , tri ) ; } else { LOG4CXX_ERROR ( KrisLibrary :: logger ( ) , " " << ext ) ; return false ; } #endif } }
Import will try to determine the file type via the file extension
Import will try to determine the file type via the file extension
//setup texture path to same directory as fn //do the loading