Skip to content

Commit

Permalink
Merge branch 'devel' into embree
Browse files Browse the repository at this point in the history
  • Loading branch information
alemuntoni committed Jan 17, 2023
2 parents 348930e + faa2e43 commit 9b23828
Show file tree
Hide file tree
Showing 14 changed files with 694 additions and 368 deletions.
23 changes: 18 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,42 @@ cmake_minimum_required(VERSION 3.10)
project(VCGLib)

# Eigen options
option(ALLOW_BUNDLED_EIGEN "Allow use of bundled Eigen source" ON)
option(ALLOW_SYSTEM_EIGEN "Allow use of system-provided Eigen" ON)
option(VCG_ALLOW_BUNDLED_EIGEN "Allow use of bundled Eigen source" ON)
option(VCG_ALLOW_SYSTEM_EIGEN "Allow use of system-provided Eigen" ON)

# VCG options
option(VCG_HEADER_ONLY "Use VCG library in header only mode" ON)
option(VCG_BUILD_EXAMPLES "Build a set of examples of the library" OFF)
option(VCG_USE_OPENMP "Allow VCG to find and link OpenMP if detected" ON)

set (VCG_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR})
set (VCG_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR} PARENT_SCOPE)

### Build settings
set(CMAKE_CXX_STANDARD 11)

### OpenMP
if (VCG_USE_OPENMP)
find_package(OpenMP)
if (APPLE AND OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
endif()

### Eigen
set(VCG_EIGEN_DIR ${CMAKE_CURRENT_LIST_DIR}/eigenlib)

if(ALLOW_SYSTEM_EIGEN AND EIGEN3_INCLUDE_DIR)
if(VCG_ALLOW_SYSTEM_EIGEN AND EIGEN3_INCLUDE_DIR)
message(STATUS "- Eigen - using system-provided library")
set(EIGEN_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
elseif(ALLOW_BUNDLED_EIGEN AND EXISTS "${VCG_EIGEN_DIR}/Eigen/Eigen")
elseif(VCG_ALLOW_BUNDLED_EIGEN AND EXISTS "${VCG_EIGEN_DIR}/Eigen/Eigen")
message(STATUS "- Eigen - using bundled source")
set(EIGEN_INCLUDE_DIRS ${VCG_EIGEN_DIR})
else()
message(
FATAL_ERROR
"Eigen is required - at least one of ALLOW_SYSTEM_EIGEN or ALLOW_BUNDLED_EIGEN must be enabled and found.")
"Eigen is required - at least one of VCG_ALLOW_SYSTEM_EIGEN or VCG_ALLOW_BUNDLED_EIGEN must be enabled and found.")
endif()

### VCGLib headers and sources
Expand Down Expand Up @@ -285,6 +295,9 @@ if (VCG_HEADER_ONLY)
vcglib INTERFACE
${CMAKE_CURRENT_LIST_DIR}
${EIGEN_INCLUDE_DIRS})
if(OPENMP_FOUND)
target_link_libraries(vcglib INTERFACE OpenMP::OpenMP_CXX)
endif()

#just to show headers in ide
add_custom_target(vcglib_ide SOURCES ${VCG_HEADERS})
Expand Down
10 changes: 4 additions & 6 deletions apps/sample/trimesh_clustering/trimesh_clustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,11 @@ int main(int argc, char **argv)
vcg::tri::UpdateBounding<MyMesh>::Box(m);
vcg::tri::UpdateNormal<MyMesh>::PerFace(m);
printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN());
vcg::tri::Clustering<MyMesh, vcg::tri::AverageColorCell<MyMesh> > Grid;
Grid.DuplicateFaceParam=DupFace;
Grid.Init(m.bbox,CellNum,CellSize);
vcg::tri::Clustering<MyMesh, vcg::tri::AverageColorCell<MyMesh> > Grid(m.bbox,CellNum,CellSize, DupFace);

printf("Clustering to %i cells\n",Grid.Grid.siz[0]*Grid.Grid.siz[1]*Grid.Grid.siz[2] );
printf("Grid of %i x %i x %i cells\n",Grid.Grid.siz[0],Grid.Grid.siz[1],Grid.Grid.siz[2]);
printf("with cells size of %.2f x %.2f x %.2f units\n",Grid.Grid.voxel[0],Grid.Grid.voxel[1],Grid.Grid.voxel[2]);
printf("Clustering to %i cells\n",Grid.gridSize()[0]*Grid.gridSize()[1]*Grid.gridSize()[2] );
printf("Grid of %i x %i x %i cells\n",Grid.gridSize()[0],Grid.gridSize()[1],Grid.gridSize()[2]);
printf("with cells size of %.2f x %.2f x %.2f units\n",Grid.gridVoxel()[0],Grid.gridVoxel()[1],Grid.gridVoxel()[2]);

Grid.AddMesh(m);
Grid.ExtractMesh(m);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ int main( int argc, char **argv )
printf("Sampled %i vertices in %5.2f\n",subM.VN(), float(pp.pds.pruneTime+pp.pds.gridTime)/float(CLOCKS_PER_SEC));

int t0=clock();
tri::Clustering<MyMesh, vcg::tri::AverageColorCell<MyMesh> > ClusteringGrid;
ClusteringGrid.Init(m.bbox,100000,radius*sqrt(2.0f));
tri::Clustering<MyMesh, vcg::tri::AverageColorCell<MyMesh> > ClusteringGrid(
m.bbox,100000,radius*sqrt(2.0f));
ClusteringGrid.AddPointSet(m);
ClusteringGrid.ExtractMesh(cluM);
int t1=clock();
Expand Down
Loading

0 comments on commit 9b23828

Please sign in to comment.