partial rewrite part 2, the project now fully compiles again
parent
1d39bd053f
commit
a5035b6b10
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <mitsuba/mitsuba.h>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <mitsuba/mitsuba.h>
|
||||
#include <mitsuba/core/stream.h>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
@ -53,9 +53,6 @@ public:
|
|||
/// Return the file path
|
||||
inline const fs::path &getPath() const { return m_path; }
|
||||
|
||||
/// Check whether a file exists
|
||||
static bool exists(const std::string &filename);
|
||||
|
||||
/// Open a file with a given open mode
|
||||
void open(const fs::path &filename, EFileMode mode = EReadOnly);
|
||||
|
||||
|
|
|
@ -45,21 +45,9 @@ extern MTS_EXPORT_CORE std::string indent(const std::string &string, int amount=
|
|||
/// Convert a time difference (in ms) to a string representation
|
||||
extern MTS_EXPORT_CORE std::string timeToString(Float time);
|
||||
|
||||
/// Convert a string to lower case
|
||||
extern MTS_EXPORT_CORE std::string toLowerCase(const std::string &string);
|
||||
|
||||
/// Convert a string to upper case
|
||||
extern MTS_EXPORT_CORE std::string toUpperCase(const std::string &string);
|
||||
|
||||
/// Trim spaces (' ', '\\n', '\\r', '\\t') from the ends of a string
|
||||
extern MTS_EXPORT_CORE std::string trim(const std::string& str);
|
||||
|
||||
/// Determines whether a string starts with the string given as second parameter
|
||||
extern MTS_EXPORT_CORE bool startsWith(const std::string& str, const std::string& start);
|
||||
|
||||
/// Determines whether a string ends with the string given as second parameter
|
||||
extern MTS_EXPORT_CORE bool endsWith(const std::string& str, const std::string& end);
|
||||
|
||||
/// Allocate an aligned region of memory
|
||||
extern MTS_EXPORT_CORE void * __restrict allocAligned(size_t size);
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
|
||||
#include <mitsuba/render/sampler.h>
|
||||
#include <mitsuba/render/renderproc_wr.h>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -55,7 +58,7 @@ public:
|
|||
virtual void toBitmap(Bitmap *bitmap) const = 0;
|
||||
|
||||
/// Develop the film and write the result to the specified filename
|
||||
virtual void develop(const std::string &fileName) = 0;
|
||||
virtual void develop(const fs::path &fileName) = 0;
|
||||
|
||||
/// Ignoring the crop window, return the resolution of the underlying sensor
|
||||
inline const Vector2i &getSize() const { return m_size; }
|
||||
|
@ -89,7 +92,7 @@ public:
|
|||
virtual void serialize(Stream *stream, InstanceManager *manager) const;
|
||||
|
||||
/// Does the destination already exist?
|
||||
virtual bool destinationExists(const std::string &baseName) const = 0;
|
||||
virtual bool destinationExists(const fs::path &baseName) const = 0;
|
||||
|
||||
/// Return the properties of this film
|
||||
inline const Properties &getProperties() const { return m_properties; }
|
||||
|
|
|
@ -372,13 +372,13 @@ public:
|
|||
inline const std::vector<ConfigurableObject *> &getReferencedObjects() const { return m_objects; }
|
||||
|
||||
/// Return the name of the file containing the original description of this scene
|
||||
inline const std::string getSourceFile() const { return m_sourceFile; }
|
||||
inline const fs::path getSourceFile() const { return m_sourceFile; }
|
||||
/// Set the name of the file containing the original description of this scene
|
||||
void setSourceFile(const std::string &name) { m_sourceFile = name; }
|
||||
void setSourceFile(const fs::path &name) { m_sourceFile = name; }
|
||||
/// Return the render output filename
|
||||
inline const std::string getDestinationFile() const { return m_destinationFile; }
|
||||
inline const fs::path getDestinationFile() const { return m_destinationFile; }
|
||||
/// Set the render output filename
|
||||
void setDestinationFile(const std::string &name) { m_destinationFile = name; }
|
||||
void setDestinationFile(const fs::path &name) { m_destinationFile = name; }
|
||||
/// Does the destination file already exist?
|
||||
inline bool destinationExists() const { return m_camera->getFilm()->destinationExists(m_destinationFile); }
|
||||
|
||||
|
@ -416,8 +416,8 @@ private:
|
|||
std::vector<Subsurface *> m_ssIntegrators;
|
||||
std::vector<ConfigurableObject *> m_objects;
|
||||
std::vector<NetworkedObject *> m_netObjects;
|
||||
std::string m_sourceFile;
|
||||
std::string m_destinationFile;
|
||||
fs::path m_sourceFile;
|
||||
fs::path m_destinationFile;
|
||||
DiscretePDF m_luminairePDF;
|
||||
AABB m_aabb;
|
||||
BSphere m_bsphere;
|
||||
|
|
|
@ -122,7 +122,7 @@ protected:
|
|||
private:
|
||||
struct TestResult {
|
||||
bool success;
|
||||
std::string input, output;
|
||||
fs::path input, output;
|
||||
std::string message;
|
||||
};
|
||||
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
*/
|
||||
|
||||
#include <mitsuba/render/bsdf.h>
|
||||
#include <mitsuba/render/texture.h>
|
||||
#include <mitsuba/render/consttexture.h>
|
||||
#include <mitsuba/core/properties.h>
|
||||
#include <mitsuba/hw/renderer.h>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
/**
|
||||
* Simple one-sided Lambertian (i.e. perfectly diffuse) material
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <mitsuba/render/bsdf.h>
|
||||
#include <mitsuba/render/texture.h>
|
||||
#include <mitsuba/render/consttexture.h>
|
||||
#include <mitsuba/hw/renderer.h>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <mitsuba/render/bsdf.h>
|
||||
#include <mitsuba/render/texture.h>
|
||||
#include <mitsuba/render/consttexture.h>
|
||||
#include <mitsuba/hw/gpuprogram.h>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <mitsuba/render/bsdf.h>
|
||||
#include <mitsuba/render/texture.h>
|
||||
#include <mitsuba/render/consttexture.h>
|
||||
#include <mitsuba/hw/gpuprogram.h>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <mitsuba/render/bsdf.h>
|
||||
#include <mitsuba/render/texture.h>
|
||||
#include <mitsuba/render/consttexture.h>
|
||||
#include <mitsuba/hw/gpuprogram.h>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
|
|
@ -26,11 +26,9 @@
|
|||
#include <dae.h>
|
||||
#include <dom/domCOLLADA.h>
|
||||
#include <dom/domProfile_COMMON.h>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <fstream>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(__OSX__)
|
||||
#include <OpenGL/glu.h>
|
||||
|
@ -809,11 +807,12 @@ void loadImage(GeometryConverter *cvt, std::ostream &os, const fs::path &texture
|
|||
idToTexture[identifier] = identifier;
|
||||
fileToId[filename] = identifier;
|
||||
|
||||
boost::filesystem::path path = boost::filesystem::path(filename, boost::filesystem::native);
|
||||
fs::path path = fs::path(filename);
|
||||
fs::path targetPath = textureDir / path.leaf();
|
||||
fs::path resolved = filename;
|
||||
|
||||
if (endsWith(filename, ".rgb"))
|
||||
std::string extension = boost::to_lower_copy(fs::extension(path));
|
||||
if (extension == ".rgb")
|
||||
SLog(EWarn, "Maya RGB images must be converted to PNG, EXR or JPEG! The 'imgcvt' "
|
||||
"utility found in the Maya binary directory can be used to do this.");
|
||||
|
||||
|
@ -823,10 +822,9 @@ void loadImage(GeometryConverter *cvt, std::ostream &os, const fs::path &texture
|
|||
resolved = fRes->resolve(path.leaf());
|
||||
if (!fs::exists(resolved)) {
|
||||
SLog(EWarn, "Found neither \"%s\" nor \"%s\"!", filename.c_str(), resolved.file_string().c_str());
|
||||
std::string result = cvt->locateResource(filename);
|
||||
if (result == "")
|
||||
resolved = cvt->locateResource(filename);
|
||||
if (resolved.empty())
|
||||
SLog(EError, "Unable to locate a resource -- aborting conversion.");
|
||||
resolved = result;
|
||||
}
|
||||
}
|
||||
ref<FileStream> input = new FileStream(resolved, FileStream::EReadOnly);
|
||||
|
@ -1094,16 +1092,17 @@ GLvoid __stdcall tessError(GLenum error) {
|
|||
GLvoid __stdcall tessEdgeFlag(GLboolean) {
|
||||
}
|
||||
|
||||
void GeometryConverter::convertCollada(const std::string &inputFile,
|
||||
void GeometryConverter::convertCollada(const fs::path &inputFile,
|
||||
std::ostream &os,
|
||||
const fs::path &textureDirectory,
|
||||
const fs::path &meshesDirectory) {
|
||||
DAE *dae = new DAE();
|
||||
SLog(EInfo, "Loading \"%s\" ..", inputFile.c_str());
|
||||
if (dae->load(inputFile.c_str()) != DAE_OK)
|
||||
SLog(EError, "Could not load \"%s\"!", inputFile.c_str());
|
||||
SLog(EInfo, "Loading \"%s\" ..", inputFile.leaf().c_str());
|
||||
if (dae->load(inputFile.file_string().c_str()) != DAE_OK)
|
||||
SLog(EError, "Could not load \"%s\"!",
|
||||
inputFile.file_string().c_str());
|
||||
|
||||
domCOLLADA *document = dae->getDom(inputFile.c_str());
|
||||
domCOLLADA *document = dae->getDom(inputFile.file_string().c_str());
|
||||
domVisual_scene *visualScene = daeSafeCast<domVisual_scene>
|
||||
(document->getDescendant("visual_scene"));
|
||||
if (!visualScene)
|
||||
|
|
|
@ -29,12 +29,10 @@
|
|||
#include <xercesc/framework/Wrapper4InputSource.hpp>
|
||||
#include <xercesc/framework/LocalFileFormatTarget.hpp>
|
||||
#include <xercesc/util/XMLUni.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <mitsuba/mitsuba.h>
|
||||
#include <fstream>
|
||||
#include <mitsuba/core/fresolver.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <set>
|
||||
|
||||
XERCES_CPP_NAMESPACE_USE
|
||||
|
@ -129,21 +127,19 @@ bool cleanupPass(DOMNode *node, const std::set<std::string> &removals) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void GeometryConverter::convert(const std::string &inputFile,
|
||||
const std::string &outputDirectory,
|
||||
const std::string &sceneName,
|
||||
const std::string &adjustmentFile) {
|
||||
void GeometryConverter::convert(const fs::path &inputFile,
|
||||
const fs::path &outputDirectory,
|
||||
const fs::path &sceneName,
|
||||
const fs::path &adjustmentFile) {
|
||||
|
||||
fs::path textureDirectory = "textures";
|
||||
fs::path meshesDirectory = "meshes";
|
||||
fs::path outputFile = sceneName;
|
||||
|
||||
if (outputDirectory != "") {
|
||||
fs::path outPath (outputDirectory);
|
||||
|
||||
textureDirectory = outPath / "textures";
|
||||
meshesDirectory = outPath / "meshes";
|
||||
outputFile = outPath / sceneName;
|
||||
if (!outputDirectory.empty()) {
|
||||
textureDirectory = outputDirectory / "textures";
|
||||
meshesDirectory = outputDirectory / "meshes";
|
||||
outputFile = outputDirectory / sceneName;
|
||||
}
|
||||
|
||||
SLog(EInfo, "Creating directories ..");
|
||||
|
@ -155,15 +151,18 @@ void GeometryConverter::convert(const std::string &inputFile,
|
|||
|
||||
std::ostringstream os;
|
||||
SLog(EInfo, "Beginning conversion ..");
|
||||
if (endsWith(toLowerCase(inputFile), ".dae") || endsWith(toLowerCase(inputFile), ".zae")) {
|
||||
|
||||
std::string extension = boost::to_lower_copy(fs::extension(inputFile));
|
||||
|
||||
if (extension == ".dae" || extension == ".zae") {
|
||||
convertCollada(inputFile, os, textureDirectory, meshesDirectory);
|
||||
} else if (endsWith(toLowerCase(inputFile), ".obj")) {
|
||||
} else if (extension == ".obj") {
|
||||
convertOBJ(inputFile, os, textureDirectory, meshesDirectory);
|
||||
} else {
|
||||
SLog(EError, "Unknown input format (must end in either .DAE, .ZAE or .OBJ)");
|
||||
}
|
||||
|
||||
if (adjustmentFile != "") {
|
||||
if (adjustmentFile.empty()) {
|
||||
SLog(EInfo, "Applying adjustments ..");
|
||||
static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
|
||||
DOMImplementationLS *impl = DOMImplementationRegistry::getDOMImplementation(gLS);
|
||||
|
@ -178,8 +177,8 @@ void GeometryConverter::convert(const std::string &inputFile,
|
|||
xmlString.length(), "bufID", false);
|
||||
Wrapper4InputSource *wrapper = new Wrapper4InputSource(memBufIS, false);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc = parser->parse(wrapper);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *adj = parser->parseURI(adjustmentFile.c_str());
|
||||
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *adj = parser->parseURI(adjustmentFile.file_string().c_str());
|
||||
|
||||
std::set<std::string> removals, emptyList;
|
||||
cleanupPass(adj, emptyList);
|
||||
findRemovals(adj, removals);
|
||||
|
@ -236,6 +235,6 @@ void GeometryConverter::convert(const std::string &inputFile,
|
|||
ofile << os.str();
|
||||
ofile.close();
|
||||
}
|
||||
m_filename = outputFile.file_string();
|
||||
m_filename = outputFile;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,29 +30,29 @@ public:
|
|||
m_fov = -1;
|
||||
}
|
||||
|
||||
void convert(const std::string &inputFile,
|
||||
const std::string &outputDirectory,
|
||||
const std::string &sceneName,
|
||||
const std::string &adjustmentFile);
|
||||
void convert(const fs::path &inputFile,
|
||||
const fs::path &outputDirectory,
|
||||
const fs::path &sceneName,
|
||||
const fs::path &adjustmentFile);
|
||||
|
||||
virtual std::string locateResource(const std::string &resource) = 0;
|
||||
virtual fs::path locateResource(const fs::path &resource) = 0;
|
||||
|
||||
inline void setSRGB(bool srgb) { m_srgb = srgb; }
|
||||
inline void setMapSmallerSide(bool mapSmallerSide) { m_mapSmallerSide = mapSmallerSide; }
|
||||
inline void setResolution(int xres, int yres) { m_xres = xres; m_yres = yres; }
|
||||
inline void setSamplesPerPixel(int samplesPerPixel) { m_samplesPerPixel = samplesPerPixel; }
|
||||
inline void setFov(Float fov) { m_fov = fov; }
|
||||
inline const std::string &getFilename() const { return m_filename; }
|
||||
inline const fs::path &getFilename() const { return m_filename; }
|
||||
private:
|
||||
void convertCollada(const std::string &inputFile, std::ostream &os,
|
||||
void convertCollada(const fs::path &inputFile, std::ostream &os,
|
||||
const fs::path &textureDirectory,
|
||||
const fs::path &meshesDirectory);
|
||||
void convertOBJ(const std::string &inputFile, std::ostream &os,
|
||||
void convertOBJ(const fs::path &inputFile, std::ostream &os,
|
||||
const fs::path &textureDirectory,
|
||||
const fs::path &meshesDirectory);
|
||||
public:
|
||||
bool m_srgb, m_mapSmallerSide;
|
||||
int m_xres, m_yres, m_samplesPerPixel;
|
||||
Float m_fov;
|
||||
std::string m_filename;
|
||||
fs::path m_filename;
|
||||
};
|
||||
|
|
|
@ -46,8 +46,8 @@ public:
|
|||
inline ConsoleGeometryConverter() {
|
||||
}
|
||||
|
||||
std::string locateResource(const std::string &resource) {
|
||||
return "";
|
||||
fs::path locateResource(const fs::path &resource) {
|
||||
return fs::path();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
std::string copyTexture(GeometryConverter *cvt, const fs::path &textureDir, std::string filename) {
|
||||
SLog(EInfo, "Copying texture \"%s\" ..", filename.c_str());
|
||||
|
||||
boost::filesystem::path path = boost::filesystem::path(filename, boost::filesystem::native);
|
||||
boost::filesystem::path path = boost::filesystem::path(filename);
|
||||
fs::path targetPath = textureDir / path.leaf();
|
||||
fs::path resolved = filename;
|
||||
|
||||
|
@ -38,10 +38,9 @@ std::string copyTexture(GeometryConverter *cvt, const fs::path &textureDir, std:
|
|||
resolved = fRes->resolve(path.leaf());
|
||||
if (!fs::exists(resolved)) {
|
||||
SLog(EWarn, "Found neither \"%s\" nor \"%s\"!", filename.c_str(), resolved.file_string().c_str());
|
||||
std::string result = cvt->locateResource(filename);
|
||||
if (result == "")
|
||||
resolved = cvt->locateResource(filename);
|
||||
if (resolved.empty())
|
||||
SLog(EError, "Unable to locate a resource -- aborting conversion.");
|
||||
resolved = result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,22 +131,22 @@ void parseMaterials(GeometryConverter *cvt, std::ostream &os, const fs::path &te
|
|||
addMaterial(cvt, os, mtlName, texturesDir, diffuse, diffuseMap, maskMap);
|
||||
}
|
||||
|
||||
void GeometryConverter::convertOBJ(const std::string &inputFile,
|
||||
void GeometryConverter::convertOBJ(const fs::path &inputFile,
|
||||
std::ostream &os,
|
||||
const fs::path &textureDirectory,
|
||||
const fs::path &meshesDirectory) {
|
||||
|
||||
std::ifstream is(inputFile.c_str());
|
||||
fs::ifstream is(inputFile);
|
||||
if (is.bad() || is.fail())
|
||||
SLog(EError, "Could not open OBJ file '%s'!", inputFile.c_str());
|
||||
|
||||
SLog(EError, "Could not open OBJ file '%s'!", inputFile.file_string().c_str());
|
||||
|
||||
os << "<?xml version=\"1.0\" encoding=\"utf-8\"?>" << endl << endl;
|
||||
os << "<!--" << endl << endl;
|
||||
os << "\tAutomatically converted from Wavefront OBJ" << endl << endl;
|
||||
os << "-->" << endl << endl;
|
||||
os << "<scene>" << endl;
|
||||
os << "\t<integrator id=\"integrator\" type=\"direct\"/>" << endl << endl;
|
||||
|
||||
|
||||
std::string buf, line;
|
||||
while (is >> buf) {
|
||||
if (buf == "mtllib") {
|
||||
|
@ -167,7 +166,7 @@ void GeometryConverter::convertOBJ(const std::string &inputFile,
|
|||
}
|
||||
|
||||
Properties objProps("obj");
|
||||
objProps.setString("filename", inputFile);
|
||||
objProps.setString("filename", inputFile.file_string());
|
||||
|
||||
ref<Shape> rootShape = static_cast<Shape *> (PluginManager::getInstance()->
|
||||
createObject(Shape::m_theClass, objProps));
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <mitsuba/render/film.h>
|
||||
#include <mitsuba/core/fstream.h>
|
||||
#include <mitsuba/core/bitmap.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include "banner.h"
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
@ -152,7 +153,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void develop(const std::string &destFile) {
|
||||
void develop(const fs::path &destFile) {
|
||||
Log(EDebug, "Developing film ..");
|
||||
ref<Bitmap> bitmap = new Bitmap(m_cropSize.x, m_cropSize.y, 128);
|
||||
float *targetPixels = bitmap->getFloatData();
|
||||
|
@ -190,19 +191,21 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
std::string filename = destFile;
|
||||
if (!endsWith(filename, ".exr"))
|
||||
filename += ".exr";
|
||||
Log(EInfo, "Writing image to \"%s\" ..", filename.c_str());
|
||||
fs::path filename = destFile;
|
||||
std::string extension = boost::to_lower_copy(fs::extension(filename));
|
||||
if (extension != ".exr")
|
||||
filename.replace_extension(".exr");
|
||||
|
||||
Log(EInfo, "Writing image to \"%s\" ..", filename.leaf().c_str());
|
||||
ref<FileStream> stream = new FileStream(filename, FileStream::ETruncWrite);
|
||||
bitmap->save(Bitmap::EEXR, stream);
|
||||
}
|
||||
|
||||
bool destinationExists(const std::string &baseName) const {
|
||||
std::string filename = baseName;
|
||||
if (!endsWith(filename, ".exr"))
|
||||
filename += ".exr";
|
||||
return FileStream::exists(filename);
|
||||
bool destinationExists(const fs::path &baseName) const {
|
||||
fs::path filename = baseName;
|
||||
if (boost::to_lower_copy(filename.extension()) != ".exr")
|
||||
filename.replace_extension(".exr");
|
||||
return fs::exists(filename);
|
||||
}
|
||||
|
||||
std::string toString() const {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <mitsuba/render/film.h>
|
||||
#include <mitsuba/core/bitmap.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -169,14 +170,15 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void develop(const std::string &destFile) {
|
||||
std::string filename = destFile;
|
||||
if (!endsWith(filename, ".m"))
|
||||
filename += ".m";
|
||||
void develop(const fs::path &destFile) {
|
||||
fs::path filename = destFile;
|
||||
std::string extension = boost::to_lower_copy(fs::extension(filename));
|
||||
if (extension != ".m")
|
||||
filename.replace_extension(".m");
|
||||
|
||||
Log(EInfo, "Writing image to \"%s\" ..", filename.c_str());
|
||||
Log(EInfo, "Writing image to \"%s\" ..", filename.leaf().c_str());
|
||||
|
||||
FILE *f = fopen(filename.c_str(), "w");
|
||||
FILE *f = fopen(filename.file_string().c_str(), "w");
|
||||
if (!f)
|
||||
Log(EError, "Output file cannot be created!");
|
||||
|
||||
|
@ -216,11 +218,11 @@ public:
|
|||
fclose(f);
|
||||
}
|
||||
|
||||
bool destinationExists(const std::string &baseName) const {
|
||||
std::string filename = baseName;
|
||||
if (!endsWith(filename, ".m"))
|
||||
filename += ".m";
|
||||
return FileStream::exists(filename);
|
||||
bool destinationExists(const fs::path &baseName) const {
|
||||
fs::path filename = baseName;
|
||||
if (boost::to_lower_copy(filename.extension()) != ".m")
|
||||
filename.replace_extension(".m");
|
||||
return fs::exists(filename);
|
||||
}
|
||||
|
||||
std::string toString() const {
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include <mitsuba/render/film.h>
|
||||
#include <mitsuba/core/bitmap.h>
|
||||
#include <mitsuba/core/fstream.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include "banner.h"
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
@ -180,7 +182,7 @@ public:
|
|||
- (Float) 0.055;
|
||||
}
|
||||
|
||||
void develop(const std::string &destFile) {
|
||||
void develop(const fs::path &destFile) {
|
||||
Log(EDebug, "Developing film ..");
|
||||
ref<Bitmap> bitmap = new Bitmap(m_cropSize.x, m_cropSize.y, m_bpp);
|
||||
uint8_t *targetPixels = bitmap->getData();
|
||||
|
@ -314,23 +316,25 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
std::string filename = destFile;
|
||||
if (!endsWith(filename, ".png"))
|
||||
filename += ".png";
|
||||
fs::path filename = destFile;
|
||||
std::string extension = boost::to_lower_copy(fs::extension(filename));
|
||||
if (extension != ".png")
|
||||
filename.replace_extension(".png");
|
||||
|
||||
Log(EInfo, "Writing image to \"%s\" ..", filename.c_str());
|
||||
Log(EInfo, "Writing image to \"%s\" ..", filename.leaf().c_str());
|
||||
ref<FileStream> stream = new FileStream(filename, FileStream::ETruncWrite);
|
||||
bitmap->setGamma(m_gamma);
|
||||
bitmap->save(Bitmap::EPNG, stream);
|
||||
}
|
||||
|
||||
bool destinationExists(const std::string &baseName) const {
|
||||
std::string filename = baseName;
|
||||
if (!endsWith(filename, ".png"))
|
||||
filename += ".png";
|
||||
return FileStream::exists(filename);
|
||||
bool destinationExists(const fs::path &baseName) const {
|
||||
fs::path filename = baseName;
|
||||
if (boost::to_lower_copy(filename.extension()) != ".png")
|
||||
filename.replace_extension(".png");
|
||||
return fs::exists(filename);
|
||||
}
|
||||
|
||||
|
||||
std::string toString() const {
|
||||
std::ostringstream oss;
|
||||
oss << "PNGFilm[" << std::endl
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <mitsuba/core/plugin.h>
|
||||
#include <mitsuba/core/statistics.h>
|
||||
#include "irrcache_proc.h"
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mitsuba/core/statistics.h>
|
||||
#include <mitsuba/hw/vpl.h>
|
||||
#include <mitsuba/hw/session.h>
|
||||
#include <mitsuba/hw/device.h>
|
||||
|
|
|
@ -48,21 +48,6 @@ std::string FileStream::toString() const {
|
|||
return oss.str();
|
||||
}
|
||||
|
||||
bool FileStream::exists(const std::string &filename) {
|
||||
#ifdef WIN32
|
||||
WIN32_FIND_DATA lpFindFileData;
|
||||
HANDLE hFind = FindFirstFile(filename.c_str(), &lpFindFileData);
|
||||
if (hFind == INVALID_HANDLE_VALUE) {
|
||||
return false;
|
||||
} else {
|
||||
FindClose(hFind);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
return (access(filename.c_str(), F_OK) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void FileStream::open(const fs::path &path, EFileMode mode) {
|
||||
AssertEx(m_file == 0, "A file has already been opened using this stream");
|
||||
|
||||
|
|
|
@ -148,26 +148,6 @@ std::string trim(const std::string& str) {
|
|||
end == std::string::npos ? str.length() - 1 : end - start + 1);
|
||||
}
|
||||
|
||||
std::string toLowerCase(const std::string &string) {
|
||||
std::string result;
|
||||
result.reserve(string.length());
|
||||
|
||||
for (unsigned int i=0; i<string.length(); i++)
|
||||
result += std::tolower(string[i]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string toUpperCase(const std::string &string) {
|
||||
std::string result;
|
||||
result.reserve(string.length());
|
||||
|
||||
for (unsigned int i=0; i<string.length(); i++)
|
||||
result += toupper(string[i]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string indent(const std::string &string, int amount) {
|
||||
/* This could probably be done faster (is not
|
||||
really speed-critical though) */
|
||||
|
|
|
@ -112,7 +112,7 @@ void RenderJob::run() {
|
|||
if (!m_scene->render(m_queue, this, m_sceneResID, m_cameraResID, m_samplerResID)) {
|
||||
cancelled = true;
|
||||
Log(EWarn, "Rendering of scene \"%s\" did not complete successfully!",
|
||||
m_scene->getSourceFile().c_str());
|
||||
m_scene->getSourceFile().leaf().c_str());
|
||||
}
|
||||
m_scene->postprocess(m_queue, this, m_sceneResID, m_cameraResID, m_samplerResID);
|
||||
|
||||
|
@ -120,7 +120,7 @@ void RenderJob::run() {
|
|||
m_testSupervisor->analyze(m_scene);
|
||||
} catch (const std::exception &ex) {
|
||||
Log(EWarn, "Rendering of scene \"%s\" did not complete successfully, caught exception: %s",
|
||||
m_scene->getSourceFile().c_str(), ex.what());
|
||||
m_scene->getSourceFile().leaf().c_str(), ex.what());
|
||||
cancelled = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <xercesc/parsers/SAXParser.hpp>
|
||||
#include <mitsuba/render/shandler.h>
|
||||
#include <mitsuba/core/fresolver.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -101,7 +102,7 @@ void SceneHandler::startElement(const XMLCh* const xmlName,
|
|||
void SceneHandler::endElement(const XMLCh* const xmlName) {
|
||||
std::string name = transcode(xmlName);
|
||||
ParseContext &context = m_context.top();
|
||||
std::string type = toLowerCase(context.attributes["type"]);
|
||||
std::string type = boost::to_lower_copy(context.attributes["type"]);
|
||||
context.properties.setPluginName(type);
|
||||
if (context.attributes.find("id") != context.attributes.end())
|
||||
context.properties.setID(context.attributes["id"]);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <mitsuba/render/scene.h>
|
||||
#include <mitsuba/render/testcase.h>
|
||||
#include <boost/math/distributions/students_t.hpp>
|
||||
#include <fstream>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -172,21 +172,25 @@ void TestSupervisor::analyze(const Scene *scene) {
|
|||
TestResult result;
|
||||
|
||||
result.input = scene->getSourceFile();
|
||||
result.output = scene->getDestinationFile() + ".m";
|
||||
result.output = scene->getDestinationFile();
|
||||
result.output.replace_extension(".m");
|
||||
result.success = false;
|
||||
std::string refFilename = scene->getDestinationFile() + ".ref";
|
||||
fs::path refFilename = scene->getDestinationFile();
|
||||
refFilename.replace_extension(".ref");
|
||||
|
||||
std::ifstream is(result.output.c_str());
|
||||
std::ifstream is_ref(refFilename.c_str());
|
||||
fs::ifstream is(result.output);
|
||||
fs::ifstream is_ref(refFilename);
|
||||
if (is.fail()) {
|
||||
result.message = formatString("Could not open '%s'!", result.output.c_str());
|
||||
result.message = formatString("Could not open '%s'!",
|
||||
result.output.file_string().c_str());
|
||||
m_mutex->lock();
|
||||
m_numFailed++; m_results.push_back(result);
|
||||
m_mutex->unlock();
|
||||
return;
|
||||
}
|
||||
if (is_ref.fail()) {
|
||||
result.message = formatString("Could not open '%s'!", refFilename.c_str());
|
||||
result.message = formatString("Could not open '%s'!",
|
||||
refFilename.file_string().c_str());
|
||||
m_mutex->lock();
|
||||
m_numFailed++; m_results.push_back(result);
|
||||
m_mutex->unlock();
|
||||
|
@ -265,7 +269,7 @@ void TestSupervisor::printSummary() const {
|
|||
if (result.success)
|
||||
continue;
|
||||
Log(EWarn, "============================================================");
|
||||
Log(EWarn, " Failure: Test case %zi (\"%s\")", i+1, result.input.c_str());
|
||||
Log(EWarn, " Failure: Test case %zi (\"%s\")", i+1, result.input.file_string().c_str());
|
||||
Log(EWarn, " Message: \"%s\"", result.message.c_str());
|
||||
Log(EWarn, "============================================================");
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <mitsuba/render/scene.h>
|
||||
#include <mitsuba/render/texture.h>
|
||||
#include <mitsuba/render/consttexture.h>
|
||||
#include <mitsuba/hw/gpuprogram.h>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
|
|
@ -238,7 +238,7 @@ public:
|
|||
m_D.normalize();
|
||||
|
||||
SHVector4D phaseExpansion;
|
||||
if (FileStream::exists("flake-phase.dat")) {
|
||||
if (fs::exists("flake-phase.dat")) {
|
||||
stream = new FileStream("flake-phase.dat", FileStream::EReadOnly);
|
||||
phaseExpansion = SHVector4D(stream);
|
||||
stream->close();
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <mitsuba/render/scene.h>
|
||||
#include <mitsuba/render/volume.h>
|
||||
#include <mitsuba/core/fstream.h>
|
||||
#include <mitsuba/core/shvector4d.h>
|
||||
#include <fstream>
|
||||
|
||||
|
@ -164,7 +165,7 @@ public:
|
|||
Log(EInfo, " sampling recursions = %i", m_samplingRecursions);
|
||||
|
||||
bool computePhaseProjection = true;
|
||||
if (FileStream::exists("flake-phase.dat")) {
|
||||
if (fs::exists("flake-phase.dat")) {
|
||||
/* Avoid recomputing this every time */
|
||||
stream = new FileStream("flake-phase.dat", FileStream::EReadOnly);
|
||||
unsigned int header = stream->readUInt();
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <mitsuba/render/scene.h>
|
||||
#include <mitsuba/core/fresolver.h>
|
||||
#include <fstream>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
@ -95,16 +96,16 @@ public:
|
|||
}
|
||||
|
||||
|
||||
std::string volData = props.getString("filename");
|
||||
volData = FileResolver::getInstance()->resolve(volData);
|
||||
fs::path volData = Thread::getThread()->getFileResolver()->resolve(
|
||||
props.getString("filename"));
|
||||
|
||||
/* Medium to world transformation - can't have nonuniform scales. Also note
|
||||
that a uniform scale factor of 100 will not reduce densities by that
|
||||
amount */
|
||||
m_mediumToWorld = props.getTransform("toWorld", Transform());
|
||||
|
||||
Log(EInfo, "Loading volume data from \"%s\" ..", volData.c_str());
|
||||
std::ifstream is(volData.c_str());
|
||||
Log(EInfo, "Loading volume data from \"%s\" ..", volData.file_string().c_str());
|
||||
fs::ifstream is(volData);
|
||||
if (is.bad() || is.fail())
|
||||
Log(EError, "Invalid medium data file specified");
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <mitsuba/render/util.h>
|
||||
#include <mitsuba/render/renderjob.h>
|
||||
#include <mitsuba/render/shandler.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
#include <sys/types.h>
|
||||
|
@ -89,7 +90,7 @@ void help() {
|
|||
|
||||
while ((dirinfo = readdir(directory)) != NULL) {
|
||||
std::string fname(dirinfo->d_name);
|
||||
if (!endsWith(fname, ".dylib") && !endsWith(fname, ".so"))
|
||||
if (!boost::ends_with(fname, ".dylib") && !boost::ends_with(fname, ".so"))
|
||||
continue;
|
||||
std::string fullName = dirPath + "/" + fname;
|
||||
#else
|
||||
|
@ -110,7 +111,7 @@ void help() {
|
|||
Plugin utility(shortName, fullName);
|
||||
if (!utility.isUtility())
|
||||
continue;
|
||||
if (startsWith(shortName, "test_")) {
|
||||
if (boost::starts_with(shortName, "test_")) {
|
||||
testcases << "\t" << shortName;
|
||||
for (int i=0; i<22-(int) shortName.length(); ++i)
|
||||
testcases << ' ';
|
||||
|
@ -287,7 +288,7 @@ int ubi_main(int argc, char **argv) {
|
|||
|
||||
while ((dirinfo = readdir(directory)) != NULL) {
|
||||
std::string fname(dirinfo->d_name);
|
||||
if (!endsWith(fname, ".dylib") && !endsWith(fname, ".so"))
|
||||
if (!boost::ends_with(fname, ".dylib") && !boost::ends_with(fname, ".so"))
|
||||
continue;
|
||||
std::string fullName = dirPath + "/" + fname;
|
||||
#else
|
||||
|
@ -302,7 +303,7 @@ int ubi_main(int argc, char **argv) {
|
|||
std::string fullName = dirPath + "\\" + fname;
|
||||
#endif
|
||||
std::string shortName = fname.substr(0, strrchr(fname.c_str(), '.') - fname.c_str());
|
||||
if (!startsWith(shortName, "test_") || seen.find(shortName) != seen.end())
|
||||
if (!boost::starts_with(shortName, "test_") || seen.find(shortName) != seen.end())
|
||||
continue;
|
||||
seen.insert(shortName);
|
||||
Plugin plugin(shortName, fullName);
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
|
||||
#include <mitsuba/render/medium.h>
|
||||
#include <mitsuba/core/properties.h>
|
||||
#include <mitsuba/core/frame.h>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include <mitsuba/render/medium.h>
|
||||
#include <mitsuba/core/random.h>
|
||||
#include <mitsuba/core/properties.h>
|
||||
#include <mitsuba/core/frame.h>
|
||||
#include <boost/math/special_functions/gamma.hpp>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
|
|
@ -150,13 +150,13 @@ void ImportDialog::accept() {
|
|||
dialog->hide();
|
||||
delete dialog;
|
||||
|
||||
if (importingThread->getResult().length() > 0) {
|
||||
if (!importingThread->getResult().empty()) {
|
||||
size_t warningCount = logger->getWarningCount() - initialWarningCount;
|
||||
if (warningCount > 0)
|
||||
QMessageBox::warning(this, tr("Scene Import"),
|
||||
tr("Encountered %1 warnings while importing -- please see "
|
||||
"the log for details.").arg(warningCount), QMessageBox::Ok);
|
||||
((MainWindow *) parent())->loadFile(QString(importingThread->getResult().c_str()));
|
||||
((MainWindow *) parent())->loadFile(QString(importingThread->getResult().file_string().c_str()));
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("Scene Import"),
|
||||
tr("Conversion failed -- please see the log for details."),
|
||||
|
|
|
@ -25,21 +25,21 @@ public:
|
|||
inline GUIGeometryConverter(QWidget *parent) : m_parent(parent) {
|
||||
}
|
||||
|
||||
std::string locateResource(const std::string &resource) {
|
||||
LocateResourceDialog locateResource(m_parent, resource.c_str());
|
||||
fs::path locateResource(const fs::path &resource) {
|
||||
LocateResourceDialog locateResource(m_parent, resource.file_string().c_str());
|
||||
locateResource.setWindowModality(Qt::ApplicationModal);
|
||||
if (locateResource.exec())
|
||||
return locateResource.getFilename().toStdString();
|
||||
if (locateResource.exec())
|
||||
return fs::path(locateResource.getFilename().toStdString());
|
||||
|
||||
return "";
|
||||
return fs::path();
|
||||
}
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
};
|
||||
|
||||
SceneImporter::SceneImporter(QWidget *parent, FileResolver *resolver,
|
||||
const std::string &sourceFile, const std::string &directory,
|
||||
const std::string &targetScene, const std::string &adjustmentFile,
|
||||
const fs::path &sourceFile, const fs::path &directory,
|
||||
const fs::path &targetScene, const fs::path &adjustmentFile,
|
||||
bool sRGB)
|
||||
: Thread("impt"), m_parent(parent), m_resolver(resolver),
|
||||
m_sourceFile(sourceFile), m_directory(directory),
|
||||
|
|
|
@ -21,32 +21,33 @@
|
|||
|
||||
#include <QtGui>
|
||||
#include <mitsuba/core/lock.h>
|
||||
#include <mitsuba/core/fresolver.h>
|
||||
|
||||
using namespace mitsuba;
|
||||
|
||||
class SceneImporter : public Thread {
|
||||
public:
|
||||
SceneImporter(QWidget *parent, FileResolver *resolver,
|
||||
const std::string &sourceFile, const std::string &directory,
|
||||
const std::string &targetScene, const std::string &adjustmentFile,
|
||||
const fs::path &sourceFile, const fs::path &directory,
|
||||
const fs::path &targetScene, const fs::path &adjustmentFile,
|
||||
bool sRGB);
|
||||
|
||||
void run();
|
||||
|
||||
inline void wait(int ms) { m_wait->wait(ms); }
|
||||
|
||||
inline const std::string &getResult() const { return m_result; }
|
||||
inline const fs::path &getResult() const { return m_result; }
|
||||
protected:
|
||||
virtual ~SceneImporter();
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
ref<FileResolver> m_resolver;
|
||||
ref<WaitFlag> m_wait;
|
||||
std::string m_sourceFile;
|
||||
std::string m_directory;
|
||||
std::string m_targetScene;
|
||||
std::string m_adjustmentFile;
|
||||
std::string m_result;
|
||||
fs::path m_sourceFile;
|
||||
fs::path m_directory;
|
||||
fs::path m_targetScene;
|
||||
fs::path m_adjustmentFile;
|
||||
fs::path m_result;
|
||||
bool m_srgb;
|
||||
};
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <mitsuba/render/shandler.h>
|
||||
#include <mitsuba/core/fresolver.h>
|
||||
#include <mitsuba/core/fstream.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
SceneLoader::SceneLoader(FileResolver *resolver, const std::string &filename)
|
||||
: Thread("load"), m_resolver(resolver), m_filename(filename) {
|
||||
|
@ -54,7 +55,7 @@ void SceneLoader::run() {
|
|||
m_result->diffuseSources = settings.value("preview_diffuseSources", true).toBool();
|
||||
m_result->diffuseReceivers = settings.value("preview_diffuseReceivers", false).toBool();
|
||||
|
||||
if (endsWith(lowerCase, ".exr")) {
|
||||
if (boost::ends_with(lowerCase, ".exr")) {
|
||||
/* This is an image, not a scene */
|
||||
ref<FileStream> fs = new FileStream(m_filename, FileStream::EReadOnly);
|
||||
ref<Bitmap> bitmap = new Bitmap(Bitmap::EEXR, fs);
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <mitsuba/core/plugin.h>
|
||||
#include <mitsuba/core/fresolver.h>
|
||||
#include <mitsuba/core/properties.h>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
|
|
|
@ -18,7 +18,10 @@
|
|||
|
||||
#include <mitsuba/render/trimesh.h>
|
||||
#include <mitsuba/core/plugin.h>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <mitsuba/core/fresolver.h>
|
||||
#include <mitsuba/render/luminaire.h>
|
||||
#include <mitsuba/render/bsdf.h>
|
||||
#include <mitsuba/render/subsurface.h>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -34,13 +37,13 @@ public:
|
|||
};
|
||||
|
||||
WavefrontOBJ(const Properties &props) : Shape(props) {
|
||||
ref<FileResolver> fResolver = Thread::getThread()->getFileResolver();
|
||||
fs::path path = fresolver->resolve(props.getString("filename"));
|
||||
m_name = path.filename();
|
||||
FileResolver *fResolver = Thread::getThread()->getFileResolver();
|
||||
fs::path path = fResolver->resolve(props.getString("filename"));
|
||||
m_name = path.stem();
|
||||
|
||||
/* Load the geometry */
|
||||
Log(EInfo, "Loading geometry from \"%s\" ..", m_name.c_str());
|
||||
std::ifstream is(path);
|
||||
Log(EInfo, "Loading geometry from \"%s\" ..", path.leaf().c_str());
|
||||
fs::ifstream is(path);
|
||||
if (is.bad() || is.fail())
|
||||
Log(EError, "Geometry file '%s' not found!", path.file_string().c_str());
|
||||
|
||||
|
@ -97,10 +100,9 @@ public:
|
|||
} else if (buf == "mtllib") {
|
||||
std::string line;
|
||||
std::getline(is, line);
|
||||
std::string mtlName = trim(line.substr(1, line.length()-1));
|
||||
ref<FileResolver> frClone = fResolver->clone();
|
||||
frClone->addPathFromFile(path);
|
||||
fs::path mtlName = frClone->resolve(mtlName);
|
||||
frClone->addPath(fs::complete(path).parent_path());
|
||||
fs::path mtlName = frClone->resolve(trim(line.substr(1, line.length()-1)));
|
||||
if (fs::exists(mtlName))
|
||||
parseMaterials(mtlName);
|
||||
else
|
||||
|
@ -183,9 +185,10 @@ public:
|
|||
|
||||
void parseMaterials(const fs::path &mtlPath) {
|
||||
Log(EInfo, "Loading OBJ materials from \"%s\" ..", mtlPath.filename().c_str());
|
||||
std::ifstream is(mtlPath);
|
||||
fs::ifstream is(mtlPath);
|
||||
if (is.bad() || is.fail())
|
||||
Log(EError, "Unexpected I/O error while accessing material file '%s'!", mtlFileName.c_str());
|
||||
Log(EError, "Unexpected I/O error while accessing material file '%s'!",
|
||||
mtlPath.file_string().c_str());
|
||||
std::string buf;
|
||||
std::string mtlName;
|
||||
Spectrum diffuse;
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
*/
|
||||
|
||||
#include <mitsuba/render/trimesh.h>
|
||||
#include <mitsuba/core/properties.h>
|
||||
#include <mitsuba/core/fstream.h>
|
||||
#include <mitsuba/core/fresolver.h>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -26,12 +29,13 @@ MTS_NAMESPACE_BEGIN
|
|||
class SerializedMesh : public TriMesh {
|
||||
public:
|
||||
SerializedMesh(const Properties &props) : TriMesh(props) {
|
||||
m_name = props.getString("filename");
|
||||
std::string filePath = FileResolver::getInstance()->resolve(m_name);
|
||||
fs::path filePath = Thread::getThread()->getFileResolver()->resolve(
|
||||
props.getString("filename"));
|
||||
m_name = filePath.stem();
|
||||
|
||||
/* Load the geometry */
|
||||
Log(EInfo, "Loading geometry from \"%s\" ..", m_name.c_str());
|
||||
ref<FileStream> stream = new FileStream(filePath.c_str(), FileStream::EReadOnly);
|
||||
Log(EInfo, "Loading geometry from \"%s\" ..", filePath.leaf().c_str());
|
||||
ref<FileStream> stream = new FileStream(filePath, FileStream::EReadOnly);
|
||||
stream->setByteOrder(Stream::ENetworkByteOrder);
|
||||
ref<TriMesh> mesh = new TriMesh(stream);
|
||||
m_triangleCount = mesh->getTriangleCount();
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
*/
|
||||
|
||||
#include <mitsuba/render/shape.h>
|
||||
#include <mitsuba/render/bsdf.h>
|
||||
#include <mitsuba/render/luminaire.h>
|
||||
#include <mitsuba/render/subsurface.h>
|
||||
#include <mitsuba/core/properties.h>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
|
||||
#include <mitsuba/core/bitmap.h>
|
||||
#include <mitsuba/core/fresolver.h>
|
||||
#include <mitsuba/core/fstream.h>
|
||||
#include <mitsuba/core/mstream.h>
|
||||
#include <mitsuba/core/sched.h>
|
||||
#include <mitsuba/render/texture.h>
|
||||
|
@ -24,6 +26,7 @@
|
|||
#include <mitsuba/hw/renderer.h>
|
||||
#include <mitsuba/hw/gputexture.h>
|
||||
#include <mitsuba/hw/gpuprogram.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -33,24 +36,24 @@ MTS_NAMESPACE_BEGIN
|
|||
class LDRTexture : public Texture {
|
||||
public:
|
||||
LDRTexture(const Properties &props) : Texture(props) {
|
||||
m_filename = props.getString("filename");
|
||||
m_filename = FileResolver::getInstance()->resolve(m_filename);
|
||||
m_filename = Thread::getThread()->getFileResolver()->resolve(
|
||||
props.getString("filename"));
|
||||
m_gamma = props.getFloat("gamma", -1); /* -1 means sRGB */
|
||||
Log(EInfo, "Loading texture \"%s\"", m_filename.c_str());
|
||||
Log(EInfo, "Loading texture \"%s\"", m_filename.leaf().c_str());
|
||||
|
||||
ref<FileStream> fs = new FileStream(m_filename, FileStream::EReadOnly);
|
||||
std::string lower = toLowerCase(m_filename);
|
||||
std::string extension = boost::to_lower_copy(m_filename.extension());
|
||||
|
||||
if (endsWith(lower, ".jpg") || endsWith(lower, ".jpeg"))
|
||||
if (extension == ".jpg" || extension == ".jpeg")
|
||||
m_format = Bitmap::EJPEG;
|
||||
else if (endsWith(lower, ".png"))
|
||||
else if (extension == ".png")
|
||||
m_format = Bitmap::EPNG;
|
||||
else if (endsWith(lower, ".tga"))
|
||||
else if (extension == ".tga")
|
||||
m_format = Bitmap::ETGA;
|
||||
else if (endsWith(lower, ".bmp"))
|
||||
else if (extension == ".bmp")
|
||||
m_format = Bitmap::EBMP;
|
||||
else
|
||||
Log(EError, "Cannot deduce the file type of '%s'!", m_filename.c_str());
|
||||
Log(EError, "Cannot deduce the file type of '%s'!", m_filename.file_string().c_str());
|
||||
|
||||
ref<Bitmap> bitmap = new Bitmap(m_format, fs);
|
||||
initializeFrom(bitmap);
|
||||
|
@ -59,7 +62,7 @@ public:
|
|||
LDRTexture(Stream *stream, InstanceManager *manager)
|
||||
: Texture(stream, manager) {
|
||||
m_filename = stream->readString();
|
||||
Log(EInfo, "Unserializing texture \"%s\"", m_filename.c_str());
|
||||
Log(EInfo, "Unserializing texture \"%s\"", m_filename.leaf().c_str());
|
||||
m_gamma = stream->readFloat();
|
||||
m_format = static_cast<Bitmap::EFileFormat>(stream->readInt());
|
||||
unsigned int size = stream->readUInt();
|
||||
|
@ -70,7 +73,7 @@ public:
|
|||
initializeFrom(bitmap);
|
||||
|
||||
if (Scheduler::getInstance()->hasRemoteWorkers()
|
||||
&& !FileStream::exists(m_filename)) {
|
||||
&& !fs::exists(m_filename)) {
|
||||
/* This code is running on a machine different from
|
||||
the one that created the stream. Because we might
|
||||
later have to handle a call to serialize(), the
|
||||
|
@ -159,7 +162,7 @@ public:
|
|||
|
||||
void serialize(Stream *stream, InstanceManager *manager) const {
|
||||
Texture::serialize(stream, manager);
|
||||
stream->writeString(m_filename);
|
||||
stream->writeString(m_filename.file_string());
|
||||
stream->writeFloat(m_gamma);
|
||||
stream->writeInt(m_format);
|
||||
if (m_stream.get()) {
|
||||
|
@ -201,7 +204,7 @@ public:
|
|||
protected:
|
||||
ref<MIPMap> m_mipmap;
|
||||
ref<MemoryStream> m_stream;
|
||||
std::string m_filename;
|
||||
fs::path m_filename;
|
||||
Bitmap::EFileFormat m_format;
|
||||
Spectrum m_average, m_maximum;
|
||||
Float m_gamma;
|
||||
|
@ -255,7 +258,7 @@ private:
|
|||
};
|
||||
|
||||
Shader *LDRTexture::createShader(Renderer *renderer) const {
|
||||
return new LDRTextureShader(renderer, m_filename, m_mipmap->getLDRBitmap());
|
||||
return new LDRTextureShader(renderer, m_filename.leaf(), m_mipmap->getLDRBitmap());
|
||||
}
|
||||
|
||||
MTS_IMPLEMENT_CLASS_S(LDRTexture, false, Texture)
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
|
||||
#include <mitsuba/render/volume.h>
|
||||
#include <mitsuba/core/plugin.h>
|
||||
#include <mitsuba/core/properties.h>
|
||||
#include <mitsuba/core/fstream.h>
|
||||
#include <mitsuba/core/fresolver.h>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -65,7 +68,7 @@ public:
|
|||
}
|
||||
|
||||
void loadDictionary(const std::string &filename) {
|
||||
std::string resolved = FileResolver::getInstance()->resolve(filename);
|
||||
fs::path resolved = Thread::getThread()->getFileResolver()->resolve(filename);
|
||||
Log(EInfo, "Loading hierarchical grid dictionary \"%s\"", filename.c_str());
|
||||
ref<FileStream> stream = new FileStream(resolved, FileStream::EReadOnly);
|
||||
stream->setByteOrder(Stream::ELittleEndian);
|
||||
|
|
Loading…
Reference in New Issue