clean CMakeLists.txt + handle duplicates

This commit is contained in:
Paul Leroy
2025-09-18 10:26:16 +02:00
parent 488876e5b1
commit bd321fa4bb
3 changed files with 88 additions and 60 deletions
+33 -19
View File
@@ -22,36 +22,50 @@ target_sources(G3PointPlugin
add_subdirectory( src )
add_subdirectory( ui )
# target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) # for mlpack
# EIGEN
set( EIGEN_ROOT_DIR "" CACHE PATH "Eigen root (contains the Eigen directory)" )
if ( NOT EIGEN_ROOT_DIR )
message( SEND_ERROR "No Eigen root directory specified (EIGEN_ROOT_DIR)" )
else()
message( STATUS "EIGEN_ROOT_DIR " ${EIGEN_ROOT_DIR} )
endif()
target_include_directories( ${PROJECT_NAME} PRIVATE
C:/opt/eigen-3.4.0
C:/Users/PaulLeroy/miniconda3/envs/env_4_CloudCompare/include
C:/opt/open3d-devel-windows-amd64-0.19.0/include
C:/opt/GeometricTools/GTE
C:/opt/boost_1_77_0
)
# BOOST
find_package(Boost REQUIRED)
message(STATUS "Boost_VERSION: ${Boost_VERSION}")
message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
# OPEN3D
find_package( Open3D REQUIRED ) # Find installed Open3D, which exports Open3D::Open3D
message( "Open3D_DIR ${Open3D_DIR}" )
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set( OPENCV_DEP_DLL_FILES
${Open3D_DIR}/../bin/Open3D.dll
${Open3D_DIR}/../bin/tbb12_debug.dll)
elseif(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set( OPENCV_DEP_DLL_FILES
${Open3D_DIR}/../bin/Open3D.dll
${Open3D_DIR}/../bin/tbb12.dll)
endif()
copy_files( "${OPENCV_DEP_DLL_FILES}" "${CLOUDCOMPARE_DEST_FOLDER}" 1) #mind the quotes!
# may be needed for debug
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
#============
target_include_directories( ${PROJECT_NAME} PRIVATE
${GEOMETRIC_TOOLS_DIR}/GTE
${EIGEN_ROOT_DIR}
${Boost_INCLUDE_DIRS}
)
target_link_libraries( ${PROJECT_NAME} Open3D::Open3D )
# QCUSTOMPLOT
target_link_libraries(${PROJECT_NAME}
QCustomPlot
Qt5::PrintSupport
)
# Find installed Open3D, which exports Open3D::Open3D
find_package( Open3D REQUIRED )
target_link_libraries( ${PROJECT_NAME} Open3D::Open3D )
message( "Open3D_DIR ${Open3D_DIR}" )
set( OPENCV_DEP_DLL_FILES
${Open3D_DIR}/../bin/Open3D.dll
${Open3D_DIR}/../bin/tbb12.dll
)
copy_files( "${OPENCV_DEP_DLL_FILES}" "${CLOUDCOMPARE_DEST_FOLDER}" 1) #mind the quotes!
# Copy OpenGL shaders
copy_files( "${CMAKE_CURRENT_SOURCE_DIR}/shaders/DrawGrains.vs" "${CLOUDCOMPARE_DEST_FOLDER}/shaders/G3Point" 1) #mind the quotes!
copy_files( "${CMAKE_CURRENT_SOURCE_DIR}/shaders/DrawGrains.fs" "${CLOUDCOMPARE_DEST_FOLDER}/shaders/G3Point" 1) #mind the quotes!
+1 -1
View File
@@ -65,7 +65,7 @@ private:
bool checkStacks(const std::vector<std::vector<int>>& stacks, int count);
void addToStackBraunWillett(int index, const Eigen::ArrayXi& delta, const Eigen::ArrayXi& Di, std::vector<int>& stack, int local_maximum);
int segmentLabelsBraunWillett();
void getNeighborsDistancesSlopes(unsigned index);
void getNeighborsDistancesSlopes(unsigned index, std::vector<char>& duplicates);
void computeNodeSurfaces();
bool computeNormalsAndOrientThemWithCloudCompare();
void orientNormals(const Eigen::Vector3d &sensorCenter);
+19 -5
View File
@@ -1648,7 +1648,7 @@ int G3PointAction::segmentLabelsBraunWillett()
return nLabels;
}
void G3PointAction::getNeighborsDistancesSlopes(unsigned index)
void G3PointAction::getNeighborsDistancesSlopes(unsigned index, std::vector<char>& duplicates)
{
const CCVector3* P = m_cloud->getPoint(index);
@@ -1670,8 +1670,16 @@ void G3PointAction::getNeighborsDistancesSlopes(unsigned index)
float distance = (*P - *neighbor).norm();
m_neighborsDistances(index, k) = distance;
// compute the slope to the neighbor
if (distance != 0)
{
m_neighborsSlopes(index, k) = (P->z - neighbor->z) / distance;
}
else
{
m_neighborsSlopes(index, k) = 0.; // it is possible to have duplicates in the cloud
duplicates[index] = 1;
}
}
}
}
@@ -1838,8 +1846,8 @@ bool G3PointAction::queryNeighbors(ccPointCloud* cloud, ccMainAppInterface* appI
size_t nPoints = m_cloud->size();
CCCoreLib::DgmOctree::NearestNeighboursSearchStruct nNSS;
std::vector<unsigned> pointsIndexes;
pointsIndexes.resize(nPoints);
std::vector<unsigned> pointsIndexes(nPoints);
std::vector<char> duplicates(nPoints, 0);
if (useParallelStrategy)
{
@@ -1850,17 +1858,23 @@ bool G3PointAction::queryNeighbors(ccPointCloud* cloud, ccMainAppInterface* appI
int threadCount = std::max(1, ccQtHelpers::GetMaxThreadCount() - 2);
std::cout << "[query_neighbor] parallel strategy, thread count " << threadCount << std::endl;
QThreadPool::globalInstance()->setMaxThreadCount(threadCount);
QtConcurrent::blockingMap(pointsIndexes, [=](int index){getNeighborsDistancesSlopes(index);});
QtConcurrent::blockingMap(pointsIndexes, [&](int index){getNeighborsDistancesSlopes(index, duplicates);});
}
else
{
//manually call the static per-point method!
for (unsigned i = 0; i < nPoints; ++i)
{
getNeighborsDistancesSlopes(i);
getNeighborsDistancesSlopes(i, duplicates);
}
}
auto trueCount = std::count(duplicates.begin(), duplicates.end(), 1);
if (trueCount)
{
ccLog::Warning("[G3Point] You have duplicates (" + QString::number(trueCount) + "), the algorithm will continue but you may think of cleaning your cloud.");
}
return true;
}