Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/TIDOP-USAL/graphos into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanrdo committed May 7, 2024
2 parents 54caba6 + 499ce49 commit 1ab3b45
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/graphos/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
${CUDA_LIBRARIES}
${FREEIMAGE_LIBRARIES}
GLEW::glew
${Boost_PROGRAM_OPTIONS_LIBRARY})
${Boost_PROGRAM_OPTIONS_LIBRARY}
CGAL::CGAL)


set_target_properties(${PROJECT_NAME} PROPERTIES
Expand Down
41 changes: 38 additions & 3 deletions src/graphos/core/mesh/PoissonRecon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@

#include "PoissonRecon.h"

#include "graphos/core/AppStatus.h"

#include <tidop/core/exception.h>
#include <tidop/core/app.h>
#include <tidop/core/path.h>
#include <tidop/core/progress.h>
#include <tidop/core/chrono.h>

#include "AppStatus.h"
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/Point_set_3/IO.h>


using namespace CGAL;


namespace graphos
{
Expand Down Expand Up @@ -127,10 +135,33 @@ PoissonReconTask::~PoissonReconTask() = default;

void PoissonReconTask::poissonRecon(const tl::Path &app_path) const
{

using Kernel = Simple_cartesian<double>;
using Point = Kernel::Point_3;
using Point_set = Point_set_3<Point>;

try {

if (mOutput.exists()) tl::Path::removeFile(mOutput);

auto input = mInput.toString();

/// Para Law-Game
std::ifstream in(mInput.toString(), std::ios::binary);
Point_set pts;
in >> pts;
bool has_scalar_label = pts.has_property_map<float>("scalar_label");
if (has_scalar_label) {
pts.remove_property_map(pts.property_map<float>("scalar_label").first);

auto copy_point_cloud = mInput;
copy_point_cloud.replaceBaseName("temp");
input = copy_point_cloud.toString();
std::ofstream out(input, std::ios::binary);
CGAL::IO::set_binary_mode(out);
CGAL::IO::write_PLY(out, pts);
}

std::string boundary_type;

switch (boundaryType()) {
Expand All @@ -148,7 +179,7 @@ void PoissonReconTask::poissonRecon(const tl::Path &app_path) const
std::string cmd("\"");
cmd.append(app_path.parentPath().toString());
cmd.append("\\PoissonRecon.exe\" ");
cmd.append("--in \"").append(mInput.toString());
cmd.append("--in \"").append(input);
cmd.append("\" --out \"").append(mOutput.toString());
cmd.append("\" --depth ").append(std::to_string(depth()));
cmd.append(" --solveDepth ").append(std::to_string(solveDepth()));
Expand All @@ -163,6 +194,10 @@ void PoissonReconTask::poissonRecon(const tl::Path &app_path) const

process.run();

if (has_scalar_label) {
tl::Path::removeFile(input);
}

TL_ASSERT(process.status() == tl::Process::Status::finalized, "Poisson Reconstruction error. Process error.");

TL_ASSERT(mOutput.exists(), "Poisson Reconstruction error. The mesh has not been generated.");
Expand Down Expand Up @@ -214,7 +249,7 @@ void PoissonReconTask::execute(tl::Progress *progressBar)
if (progressBar) (*progressBar)();

} catch (...) {
TL_THROW_EXCEPTION_WITH_NESTED("Load images error");
TL_THROW_EXCEPTION_WITH_NESTED("Poisson reconstruction error");
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/graphos/core/ply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ bool Ply::hasNormals() const

bool Ply::hasScalarFields() const
{
return false;
return mHasScalarFields;
}

tl::Color Ply::color(size_t index) const
Expand Down

0 comments on commit 1ab3b45

Please sign in to comment.