void GenericMeshFileReader::read(IMeshBuilder& builder) { const filesystem::path filepath(impl->m_filename); const string extension = lower_case(filepath.extension().string()); if (extension == ".obj") { OBJMeshFileReader reader(impl->m_filename, impl->m_obj_options); reader.read(builder); } else if (extension == ".abc") { AlembicMeshFileReader reader(impl->m_filename); reader.read(builder); } else if (extension == ".binarymesh") { BinaryMeshFileReader reader(impl->m_filename); reader.read(builder); } else { throw ExceptionUnsupportedFileFormat(impl->m_filename.c_str()); } }
void GenericImageFileWriter::write( const char* filename, const ICanvas& image, const ImageAttributes& image_attributes) { const bf::path filepath(filename); const string extension = lower_case(filepath.extension().string()); if (extension == ".exr") { EXRImageFileWriter writer; writer.write(filename, image, image_attributes); } else if (extension == ".png") { PNGImageFileWriter writer; writer.write(filename, image, image_attributes); } else { throw ExceptionUnsupportedFileFormat(filename); } }
Image* GenericImageFileReader::read( const char* filename, ImageAttributes* image_attributes) { const filesystem::path filepath(filename); const string extension = lower_case(filepath.extension().string()); if (extension == ".exr") { EXRImageFileReader reader; return reader.read(filename, image_attributes); } else if (extension == ".png") { PNGImageFileReader reader; return reader.read(filename, image_attributes); } else { throw ExceptionUnsupportedFileFormat(filename); return 0; } }
void GenericProgressiveImageFileReader::open(const char* filename) { assert(filename); assert(!is_open()); const filesystem::path filepath(filename); const string extension = lower_case(filepath.extension().string()); if (extension == ".exr") { impl->m_reader.reset( impl->m_has_default_tile_size ? new ProgressiveEXRImageFileReader( impl->m_logger, impl->m_default_tile_width, impl->m_default_tile_height) : new ProgressiveEXRImageFileReader( impl->m_logger)); } else if (extension == ".png") { impl->m_reader.reset( impl->m_has_default_tile_size ? new ProgressivePNGImageFileReader( impl->m_logger, impl->m_default_tile_width, impl->m_default_tile_height) : new ProgressivePNGImageFileReader( impl->m_logger)); } else { throw ExceptionUnsupportedFileFormat(filename); } impl->m_reader->open(filename); }