-
-
Notifications
You must be signed in to change notification settings - Fork 822
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1738 from alicevision/dev/meshsdfilter
MeshSDFilter: Remove submodule
- Loading branch information
Showing
14 changed files
with
2,506 additions
and
4 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Submodule MeshSDFilter
deleted from
f63adc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
|
||
project(SDFilter) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
set(CMAKE_VERBOSE_MAKEFILE ON) | ||
|
||
|
||
# Additional compiler flags | ||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | ||
message("Clang compiler found.") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") | ||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") | ||
message("AppleClang compiler found.") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") | ||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") | ||
message("GNU compiler found.") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") | ||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") | ||
message("MSVC compiler found.") | ||
add_definitions(/DUSE_MSVC) | ||
add_definitions(/D_USE_MATH_DEFINES) | ||
endif() | ||
|
||
# Detect OpenMP environment | ||
set(OPENMP ON CACHE BOOL "OpenMP") | ||
if(OPENMP) | ||
find_package(OpenMP QUIET) | ||
if(OPENMP_FOUND) | ||
message("OpenMP found. OpenMP activated in release.") | ||
add_definitions(-DUSE_OPENMP) | ||
|
||
else() | ||
message("OpenMP not found.") | ||
endif() | ||
endif() | ||
|
||
|
||
# Detect Eigen3 | ||
if(NOT EIGEN3_FOUND) | ||
find_package(Eigen3 REQUIRED) | ||
if(EIGEN3_FOUND) | ||
message("Found external Eigen. include: ${EIGEN3_INCLUDE_DIR}, version: ${EIGEN3_VERSION_STRING}.") | ||
endif() | ||
endif() | ||
|
||
find_package(OpenMesh REQUIRED) | ||
|
||
add_library(MeshSDLibrary INTERFACE) | ||
target_include_directories(MeshSDLibrary INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) | ||
target_link_libraries(MeshSDLibrary INTERFACE Eigen3::Eigen OpenMeshCore) | ||
|
||
|
||
# Executable for filtering | ||
add_executable(MeshSDFilter | ||
EigenTypes.h | ||
MeshTypes.h | ||
SDFilter.h | ||
MeshNormalFilter.h | ||
MeshSDFilter.cpp | ||
) | ||
target_link_libraries(MeshSDFilter MeshSDLibrary) | ||
|
||
|
||
# Executable for denoising | ||
add_executable(MeshDenoiser | ||
EigenTypes.h | ||
MeshTypes.h | ||
SDFilter.h | ||
MeshNormalFilter.h | ||
MeshNormalDenoising.h | ||
MeshDenoiser.cpp | ||
) | ||
target_link_libraries(MeshDenoiser MeshSDLibrary) | ||
|
||
|
||
if(OPENMP_FOUND) | ||
#target_compile_options(MeshSDLibrary PUBLIC "$<$<CONFIG:RELEASE>:${OpenMP_CXX_FLAGS}>") | ||
#target_compile_definitions(MeshSDLibrary PUBLIC "$<$<CONFIG:RELEASE>:USE_OPENMP>") | ||
#target_link_libraries(MeshSDLibrary "$<$<CONFIG:RELEASE>:${OpenMP_CXX_FLAGS}>") | ||
|
||
target_compile_options(MeshSDFilter PUBLIC "$<$<CONFIG:RELEASE>:${OpenMP_CXX_FLAGS}>") | ||
target_compile_definitions(MeshSDFilter PUBLIC "$<$<CONFIG:RELEASE>:USE_OPENMP>") | ||
target_link_libraries(MeshSDFilter "$<$<CONFIG:RELEASE>:${OpenMP_CXX_FLAGS}>") | ||
|
||
target_compile_options(MeshDenoiser PUBLIC "$<$<CONFIG:RELEASE>:${OpenMP_CXX_FLAGS}>") | ||
target_compile_definitions(MeshDenoiser PUBLIC "$<$<CONFIG:RELEASE>:USE_OPENMP>") | ||
target_link_libraries(MeshDenoiser "$<$<CONFIG:RELEASE>:${OpenMP_CXX_FLAGS}>") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#### Option file for SD filter based mesh denoising | ||
#### Lines starting with '#' are comments | ||
|
||
## Regularization weight, must be positive. | ||
Lambda 2 | ||
|
||
## Gaussian standard deviation for spatial weight, scaled by the average distance between adjacent face cetroids. Must be positive. | ||
Eta 1.5 | ||
|
||
## Gaussian standard deviation for guidance weight, must be positive. | ||
Mu 1.5 | ||
|
||
## Gaussian standard deviation for signal weight, must be positive | ||
Nu 0.3 | ||
|
||
## Closeness weight for mesh update, must be positive | ||
MeshUpdateClosenessWeight 0.001 | ||
|
||
## Iterations for mesh update, must be positive | ||
MeshUpdateIterations 20 | ||
|
||
## Outer iteration for denoising, must be positive integers | ||
OuterIterations 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// BSD 3-Clause License | ||
// | ||
// Copyright (c) 2017, Bailin Deng | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// * Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// | ||
// * Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation | ||
// and/or other materials provided with the distribution. | ||
// | ||
// * Neither the name of the copyright holder nor the names of its | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
#ifndef EIGENTYPES_H | ||
#define EIGENTYPES_H | ||
|
||
#include <Eigen/Dense> | ||
#include <Eigen/Sparse> | ||
|
||
|
||
namespace SDFilter | ||
{ | ||
|
||
// Define eigen matrix types | ||
typedef Eigen::Matrix<double, 3, Eigen::Dynamic> Matrix3X; | ||
typedef Eigen::Matrix<double, 2, Eigen::Dynamic> Matrix2X; | ||
typedef Eigen::Matrix<int, 2, Eigen::Dynamic> Matrix2Xi; | ||
typedef Eigen::Matrix<double, Eigen::Dynamic, 3> MatrixX3; | ||
typedef Eigen::Matrix<double, Eigen::Dynamic, 2> MatrixX2; | ||
typedef Eigen::Matrix<int, 3, Eigen::Dynamic> Matrix3Xi; | ||
typedef Eigen::Matrix<Eigen::Index, 2, Eigen::Dynamic> Matrix2XIdx; | ||
typedef Eigen::Matrix<Eigen::Index, Eigen::Dynamic, 1> VectorXIdx; | ||
typedef Eigen::SparseMatrix<double> SparseMatrixXd; | ||
typedef Eigen::Triplet<double> Triplet; | ||
|
||
// Conversion between a 3d vector type to Eigen::Vector3d | ||
template<typename Vec_T> | ||
inline Eigen::Vector3d to_eigen_vec3d(const Vec_T &vec) | ||
{ | ||
return Eigen::Vector3d(vec[0], vec[1], vec[2]); | ||
} | ||
|
||
|
||
template<typename Vec_T> | ||
inline Vec_T from_eigen_vec3d(const Eigen::Vector3d &vec) | ||
{ | ||
Vec_T v; | ||
v[0] = vec(0); | ||
v[1] = vec(1); | ||
v[2] = vec(2); | ||
|
||
return v; | ||
} | ||
|
||
} | ||
|
||
|
||
#endif // EIGENTYPES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#### Option file for SD filtering of mesh face normals | ||
#### Lines starting with '#' are comments | ||
|
||
## Regularization weight, must be positive. | ||
Lambda 10 | ||
|
||
## Gaussian standard deviation for spatial weight, scaled by the average distance between adjacent face cetroids. Must be positive. | ||
Eta 2.5 | ||
|
||
## Gaussian standard deviation for guidance weight, must be positive. | ||
Mu 20 | ||
|
||
## Gaussian standard deviation for signal weight, must be positive | ||
Nu 0.26 | ||
|
||
## Closeness weight for mesh update, must be positive | ||
MeshUpdateClosenessWeight 0.001 | ||
|
||
## Iterations for mesh update, must be positive | ||
MeshUpdateIterations 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2017, Bailin Deng | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// BSD 3-Clause License | ||
// | ||
// Copyright (c) 2017, Bailin Deng | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// * Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// | ||
// * Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation | ||
// and/or other materials provided with the distribution. | ||
// | ||
// * Neither the name of the copyright holder nor the names of its | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
|
||
#include "MeshTypes.h" | ||
#include "MeshNormalDenoising.h" | ||
#include <iostream> | ||
#include <fstream> | ||
#include <vector> | ||
|
||
|
||
|
||
int main(int argc, char **argv) | ||
{ | ||
if(argc != 4) | ||
{ | ||
std::cout << "Usage: MeshDenoiser OPTION_FILE INPUT_MESH OUTPUT_MESH" << std::endl; | ||
return 1; | ||
} | ||
|
||
TriMesh mesh; | ||
if(!OpenMesh::IO::read_mesh(mesh, argv[2])) | ||
{ | ||
std::cerr << "Error: unable to read input mesh from the file " << argv[2] << std::endl; | ||
return 1; | ||
} | ||
|
||
#ifdef USE_OPENMP | ||
Eigen::initParallel(); | ||
#endif | ||
|
||
// Load option file | ||
SDFilter::MeshDenoisingParameters param; | ||
if(!param.load(argv[1])){ | ||
std::cerr << "Error: unable to load option file " << argv[1] << std::endl; | ||
return 1; | ||
} | ||
if(!param.valid_parameters()){ | ||
std::cerr << "Invalid filter options. Aborting..." << std::endl; | ||
return 1; | ||
} | ||
param.output(); | ||
|
||
|
||
// Normalize the input mesh | ||
Eigen::Vector3d original_center; | ||
double original_scale; | ||
SDFilter::normalize_mesh(mesh, original_center, original_scale); | ||
|
||
// Filter the normals and construct the output mesh | ||
SDFilter::MeshNormalDenoising denoiser(mesh); | ||
TriMesh output_mesh; | ||
denoiser.denoise(param, output_mesh); | ||
|
||
SDFilter::restore_mesh(output_mesh, original_center, original_scale); | ||
|
||
// Save output mesh | ||
if(!SDFilter::write_mesh_high_accuracy(output_mesh, argv[3])){ | ||
std::cerr << "Error: unable to save the result mesh to file " << argv[3] << std::endl; | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.