diff --git a/core/src/BarycentricCoordinates.cpp b/core/src/BarycentricCoordinates.cpp index daf8bde9c..2e756472c 100644 --- a/core/src/BarycentricCoordinates.cpp +++ b/core/src/BarycentricCoordinates.cpp @@ -57,7 +57,7 @@ auto vc::BarycentricNormalInterpolation( const cv::Vec3d& nC) -> cv::Vec3d { return cv::normalize( - (1 - uvw[0] - uvw[1]) * nA + uvw[1] * nB + uvw[2] * nC); + uvw[0] * nA + uvw[1] * nB + (1. - uvw[0] - uvw[1]) * nC); } bool vc::CartesianPointIsInTriangle( diff --git a/utils/src/PPMToPointSet.cpp b/utils/src/PPMToPointSet.cpp index 027ffeaec..dbdb0b455 100644 --- a/utils/src/PPMToPointSet.cpp +++ b/utils/src/PPMToPointSet.cpp @@ -5,7 +5,7 @@ #include #include "vc/core/filesystem.hpp" -#include "vc/core/io/OBJWriter.hpp" +#include "vc/core/io/MeshIO.hpp" #include "vc/core/types/ITKMesh.hpp" #include "vc/core/types/PerPixelMap.hpp" #include "vc/core/util/String.hpp" @@ -23,9 +23,9 @@ struct ROI { }; // Converts ROI string to ROI struct -ROI ParseROI(const std::string& opt); +auto ParseROI(const std::string& opt) -> ROI; -int main(int argc, char* argv[]) +auto main(int argc, char* argv[]) -> int { ///// Parse the command line options ///// // All command line options @@ -35,9 +35,9 @@ int main(int argc, char* argv[]) ("help,h", "Show this message") ("ppm,p", po::value()->required(), "Input PPM file") ("output-mesh,o", po::value()->required(), - "Output OBJ mesh file") + "Output mesh file") ("roi", po::value(), "String describing origin and width " - "and height of region-of-interest. Format: X+Y+WxH"); + "and height of region-of-interest. Format: WxH+X+Y"); po::options_description all("Usage"); all.add(required); @@ -93,25 +93,23 @@ int main(int argc, char* argv[]) } auto id = mesh->GetNumberOfPoints(); - auto pos = ppm.getAsPixelMap(y, x).pos; - mesh->SetPoint(id, pos.val); + auto pt = ppm.getAsPixelMap(y, x); + mesh->SetPoint(id, pt.pos.val); + mesh->SetPointData(id, pt.normal.val); } } // Write the mesh std::cout << "Write OBJ file..." << std::endl; fs::path outputPath = parsed["output-mesh"].as(); - vc::io::OBJWriter writer; - writer.setPath(outputPath); - writer.setMesh(mesh); - writer.write(); + vc::WriteMesh(outputPath, mesh); } // Convert ROI string to ROI struct -ROI ParseROI(const std::string& opt) +auto ParseROI(const std::string& opt) -> ROI { // Match against regex - std::regex roiRegex{"^[0-9]*\\+[0-9]*\\+[0-9]*x[0-9]*$"}; + std::regex roiRegex{"^[0-9]*x[0-9]*\\+[0-9]*\\+[0-9]*$"}; if (!std::regex_match(opt.begin(), opt.end(), roiRegex)) { std::cerr << "Cannot parse ROI: " << opt << std::endl; exit(EXIT_FAILURE); @@ -128,6 +126,6 @@ ROI ParseROI(const std::string& opt) } return { - std::stoull(strs[0]), std::stoull(strs[1]), std::stoull(strs[2]), - std::stoull(strs[3])}; + std::stoull(strs[2]), std::stoull(strs[3]), std::stoull(strs[0]), + std::stoull(strs[1])}; } \ No newline at end of file