Exemple #1
0
//-*****************************************************************************
static Abc::IArchive* mkIArchive( const std::string &iName )
{
    Abc::IArchive archive;
    AbcF::IFactory factory;
    factory.setPolicy(Abc::ErrorHandler::kQuietNoopPolicy);
    AbcF::IFactory::CoreType coreType;
    archive = factory.getArchive(iName, coreType);

    if ( coreType == AbcF::IFactory::kUnknown ) {
        throwPythonException( "Unknown core type" );
    }
    return new Abc::IArchive( archive );
}
Exemple #2
0
//-*****************************************************************************
static std::string getCoreType( Abc::IArchive& archive )
{
    AbcF::IFactory factory;
    factory.setPolicy(Abc::ErrorHandler::kQuietNoopPolicy);
    AbcF::IFactory::CoreType coreType;
    archive = factory.getArchive(archive.getName(), coreType);

    if ( coreType == AbcF::IFactory::kOgawa ) {
        return kOgawa;
    } else if ( coreType == AbcF::IFactory::kHDF5 ) {
        return kHDF5;
    } else {
        return kUnknown;
    };
}
Exemple #3
0
PyObject * iArchive_new(PyObject * self, PyObject * args)
{
   ALEMBIC_TRY_STATEMENT
   /*if(getNbOArchives() > 0)
   {
      PyErr_SetString(getError(), "Can only create iArchives if all oArchives are closed!");
      return NULL;
   }*/

   // parse the args
   char * fileName = NULL;
   if(!PyArg_ParseTuple(args, "s", &fileName))
   {
      PyErr_SetString(getError(), "No filename specified!");
      return NULL;
   }

   // NEW check if the archive is already open as an iArchive or oArchive
   if (isIArchiveOpened(fileName) || isOArchiveOpened(fileName))
   {
      PyErr_SetString(getError(), "This archive is already opened");
      return NULL;
   }

   // check if the filename exists
   FILE * file = fopen(fileName,"rb");
   if(file == NULL)
   {
      PyErr_SetString(getError(), "File does not exist!");
      return NULL;
   }
   fclose(file);

   iArchive * object = PyObject_NEW(iArchive, &iArchive_Type);
   if (object != NULL)
   {
	   AbcF::IFactory iFactory;
      object->mArchive = new Abc::IArchive( iFactory.getArchive( fileName, object->oType ));
      setIArchiveOpened(fileName);
      gNbIArchives++;
   }
   return (PyObject *)object;
   ALEMBIC_PYOBJECT_CATCH_STATEMENT
}
Alembic::Abc::IArchive* getArchiveFromID(std::string const& path)
{
  ESS_PROFILE_SCOPE("getArchiveFromID-1");
  std::map<std::string, AlembicArchiveInfo>::iterator it;
  std::string resolvedPath = resolvePath(path);
  it = gArchives.find(resolvedPath);
  if (it == gArchives.end()) {
    // check if the file exists

    if (!boost::filesystem::exists(resolvedPath.c_str())) {
      ESS_LOG_ERROR("Can't find Alembic file.  Path: "
                    << path << "  Resolved path: " << resolvedPath);
      return NULL;
    }

    FILE* file = fopen(resolvedPath.c_str(), "rb");
    if (file == NULL) {
      return NULL;
    }
    else {
      fclose(file);

      AbcF::IFactory iFactory;
      AbcF::IFactory::CoreType oType;
      addArchive(new Abc::IArchive(iFactory.getArchive(resolvedPath, oType)));

      // addArchive(new Abc::IArchive( Alembic::AbcCoreHDF5::ReadArchive(),
      // resolvedPath));

      Abc::IArchive* pArchive = gArchives.find(resolvedPath)->second.archive;
      EC_LOG_INFO("Opening Abc Archive: " << pArchive->getName());
      return pArchive;
    }
  }
  return it->second.archive;
}