Skip to content

Commit

Permalink
Delete log stream and cout output
Browse files Browse the repository at this point in the history
  • Loading branch information
minoue committed May 12, 2023
1 parent f6e0926 commit 7b47f33
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.13)
project(UDIMTextureImporter)

set(DLL_VERSION 2.1.3)
set(DLL_VERSION 2.1.4)

set(SOURCE_FILES
../UDIMTextureImporterData/src/udimTextureImporter.cpp
Expand Down
37 changes: 36 additions & 1 deletion UDIMTextureImporterData/src/goz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "goz.hpp"
#include "util.hpp"
#include "timer.hpp"


GoZ::GoZ() {};

Expand All @@ -26,6 +28,9 @@ void GoZ::write(std::string outPath)
void GoZ::computeVertexNormals()
{

Timer timer;
timer.start();

this->normals.resize(this->vertices.size());
Vector3f zeroVec(0, 0, 0);
std::fill(normals.begin(), normals.end(), zeroVec);
Expand Down Expand Up @@ -76,6 +81,9 @@ void GoZ::computeVertexNormals()
for (auto& n : this->normals) {
n.normalize();
}

timer.showDuration("Vertex normal calculated in ");

}

// https://stackoverflow.com/questions/5255806/how-to-calculate-tangent-and-binorma
Expand Down Expand Up @@ -117,6 +125,10 @@ void GoZ::computeTangentBasis(const Vector3f& A,

std::vector<Image> GoZ::initTextures(std::vector<std::string>& texture_paths)
{

Timer timer;
timer.start();

// Find out the last number of the UDIM images
int max_udim = 0;
for (auto& path : texture_paths) {
Expand All @@ -136,13 +148,19 @@ std::vector<Image> GoZ::initTextures(std::vector<std::string>& texture_paths)
int udim = stoi(texture_udim) - 1000;
textures[static_cast<size_t>(udim - 1)] = img;
}
std::cout << "Finished loading textures" << std::endl;

timer.showDuration("Finished loading textures in ");

return textures;
}

void GoZ::importVectorDisplacement(std::vector<std::string>& texture_paths)
{


Timer timer;
timer.start();

std::vector<Image> textures = initTextures(texture_paths);

// Vector Displacement
Expand Down Expand Up @@ -235,11 +253,16 @@ void GoZ::importVectorDisplacement(std::vector<std::string>& texture_paths)
}
}
this->vertices = outVertices;

timer.showDuration("Finished Vector Displacement in ");
}

void GoZ::importNormalDisplacement(std::vector<std::string>& texture_paths)
{

Timer timer;
timer.start();

std::vector<Image> textures = initTextures(texture_paths);

std::vector<std::vector<float>> outVertices = this->vertices;
Expand Down Expand Up @@ -293,11 +316,16 @@ void GoZ::importNormalDisplacement(std::vector<std::string>& texture_paths)
}
}
this->vertices = outVertices;

timer.showDuration("Finished Normal Displacement in ");
}

void GoZ::importVertexColor(std::vector<std::string>& texture_paths, double gamma)
{

Timer timer;
timer.start();

std::vector<Image> textures = initTextures(texture_paths);

size_t numFaces = this->faces.size();
Expand Down Expand Up @@ -350,11 +378,16 @@ void GoZ::importVertexColor(std::vector<std::string>& texture_paths, double gamm
}
}
}

timer.showDuration("Finished color to polypaint in ");
}

void GoZ::importMask(std::vector<std::string>& texture_paths)
{

Timer timer;
timer.start();

std::vector<Image> textures = initTextures(texture_paths);

// Init mask value array with 0.0
Expand Down Expand Up @@ -408,4 +441,6 @@ void GoZ::importMask(std::vector<std::string>& texture_paths)
}
}
this->mask = outMask;

timer.showDuration("Finished mask import in ");
}
19 changes: 0 additions & 19 deletions UDIMTextureImporterData/src/udimTextureImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,6 @@ int EXPORT ImportUDIM(char* GoZFilePath,
return 1;
}

// Create a path for the log file
std::filesystem::path logPath = gozPath.string();
logPath.replace_extension("log");

std::ofstream logOfs(logPath, std::ios::out);
if (!logOfs) {
strcpy(pOptBuffer2, "Failed to open the log file.");
return 1;
}

// Redirect all cout to log file
// https://www.quora.com/How-do-I-output-all-my-cout-s-to-a-text-file-in-C
auto cout_buff = std::cout.rdbuf();
std::cout.rdbuf(logOfs.rdbuf());

// Split/Convert the long texture path string to vector
// pOptBuffer1 comes in this format:
// "1#C:/path/image.1001.tif#C:/path/image.1002.tif#C:/path.image.1003.tif ....
Expand Down Expand Up @@ -98,10 +83,6 @@ int EXPORT ImportUDIM(char* GoZFilePath,
std::cout << "GoZ output path: " << gozPath.string() << std::endl;
obj.write(gozPath.string());

logOfs << "End dll" << std::endl;
logOfs.close();
std::cout.rdbuf(cout_buff);

return 0;
}

Expand Down

0 comments on commit 7b47f33

Please sign in to comment.