From 81f1fb44da5baeda220658124e887aa597a2b20f Mon Sep 17 00:00:00 2001 From: me <66961093+EvilCultist@users.noreply.github.com> Date: Thu, 22 May 2025 09:15:43 +0530 Subject: [PATCH] added cmake support --- AttachWeights/CMakeLists.txt | 35 +++++++++++++++ CMakeLists.txt | 20 +++++++++ DemoUI/CMakeLists.txt | 28 ++++++++++++ Pinocchio/CMakeLists.txt | 38 ++++++++++++++++ Pinocchio/quaddisttree.h | 2 +- Pinocchio/rect.h | 44 ++++++++++--------- Pinocchio/vector.h | 2 + PinocchioStatic/CMakeLists.txt | 80 ++++++++++++++++++++++++++++++++++ 8 files changed, 227 insertions(+), 22 deletions(-) create mode 100644 AttachWeights/CMakeLists.txt create mode 100644 CMakeLists.txt create mode 100644 DemoUI/CMakeLists.txt create mode 100644 Pinocchio/CMakeLists.txt create mode 100644 PinocchioStatic/CMakeLists.txt diff --git a/AttachWeights/CMakeLists.txt b/AttachWeights/CMakeLists.txt new file mode 100644 index 0000000..4486b80 --- /dev/null +++ b/AttachWeights/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.10) +project(AttachWeights) + +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_CXX_FLAGS "-O3 -Wall -fPIC") + +# Detect OS +if(APPLE) + add_definitions(-DOSX) + set(TARGET_EXT Mac) +elseif(UNIX) + add_definitions(-DLINUX) + set(TARGET_EXT Linux) +endif() + +include_directories(${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/Pinocchio) + +link_directories(${CMAKE_BINARY_DIR}/Pinocchio) + +set(BINARY_FILES + stdafx.cpp + AttachWeights.cpp +) + +add_executable(AttachWeights ${BINARY_FILES}) + +target_link_libraries(AttachWeights + pinocchio + stdc++ +) + +target_link_libraries(AttachWeights + ${CMAKE_BINARY_DIR}/Pinocchio/libpinocchio.a + stdc++ +) diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6f34221 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.10) +project(PinocchioProject) + +add_compile_options(-Wno-deprecated) + +# Define directories +set(DIRS + Pinocchio + AttachWeights + DemoUI + PinocchioStatic +) + +# Add subdirectories (analogous to `makePerDir`) +foreach(DIR ${DIRS}) + add_subdirectory(${DIR}) +endforeach() + +# Optional: Add a custom clean target (though `make clean` is usually provided automatically) + diff --git a/DemoUI/CMakeLists.txt b/DemoUI/CMakeLists.txt new file mode 100644 index 0000000..37807fc --- /dev/null +++ b/DemoUI/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.10) +project(DemoUI) + +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_CXX_FLAGS "-Wall -O3") + +include_directories(../Pinocchio) + +link_directories(../Pinocchio) + +set(SOURCE_FILES + demoUI.cpp + MyWindow.cpp + defmesh.cpp + processor.cpp + motion.cpp + filter.cpp +) + +add_executable(DemoUI ${SOURCE_FILES}) + +target_link_libraries(DemoUI + pinocchio + OpenGL + fltk + fltk_gl + m +) diff --git a/Pinocchio/CMakeLists.txt b/Pinocchio/CMakeLists.txt new file mode 100644 index 0000000..922c66f --- /dev/null +++ b/Pinocchio/CMakeLists.txt @@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 3.10) +project(pinocchio) + +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_CXX_FLAGS "-O3 -Wall -fPIC") + +set(SOURCE_FILES + attachment.cpp + discretization.cpp + indexer.cpp + lsqSolver.cpp + mesh.cpp + graphutils.cpp + intersector.cpp + matrix.cpp + skeleton.cpp + embedding.cpp + pinocchioApi.cpp + refinement.cpp +) + +set(OBJECT_FILES + attachment.o + discretization.o + indexer.o + lsqSolver.o + mesh.o + graphutils.o + intersector.o + matrix.o + skeleton.o + embedding.o + pinocchioApi.o + refinement.o +) + +add_library(pinocchio STATIC ${SOURCE_FILES}) +target_link_libraries(pinocchio m) diff --git a/Pinocchio/quaddisttree.h b/Pinocchio/quaddisttree.h index f9e759d..520c607 100644 --- a/Pinocchio/quaddisttree.h +++ b/Pinocchio/quaddisttree.h @@ -36,7 +36,7 @@ class DistFunction : public Multilinear template void initFunc(const Eval &eval, const MyRect &rect) { for(int i = 0; i < (1 << Dim); ++i) { - setValue(i, eval(rect.getCorner(i))); + this->setValue(i, eval(rect.getCorner(i))); } return; } diff --git a/Pinocchio/rect.h b/Pinocchio/rect.h index 8389361..499a7a4 100644 --- a/Pinocchio/rect.h +++ b/Pinocchio/rect.h @@ -147,17 +147,6 @@ class RectOp template friend class RectOp; template friend class Rect; - template - static R distSq(const RRD &r, const VRD &v) - { - R out = Next::distSq(r, v); - if(r.getLo()[last] > v[last]) - return out + SQR(r.getLo()[last] - v[last]); - if(r.getHi()[last] < v[last]) - return out + SQR(v[last] - r.getHi()[last]); - return out; - } - template static R distSq(const RRD &r, const RRD &r2) { @@ -169,6 +158,18 @@ class RectOp return out; } +public: + template + static R distSq(const RRD &r, const VRD &v) + { + R out = Next::distSq(r, v); + if(r.getLo()[last] > v[last]) + return out + SQR(r.getLo()[last] - v[last]); + if(r.getHi()[last] < v[last]) + return out + SQR(v[last] - r.getHi()[last]); + return out; + } + }; template <> @@ -177,16 +178,6 @@ class RectOp<1> private: template friend class RectOp; - template - static R distSq(const RRD &r, const VRD &v) - { - if(r.getLo()[0] > v[0]) - return SQR(r.getLo()[0] - v[0]); - if(r.getHi()[0] < v[0]) - return SQR(v[0] - r.getHi()[0]); - return R(); - } - template static R distSq(const RRD &r, const RRD &r2) { @@ -197,6 +188,17 @@ class RectOp<1> return R(); } +public: + template + static R distSq(const RRD &r, const VRD &v) + { + if(r.getLo()[0] > v[0]) + return SQR(r.getLo()[0] - v[0]); + if(r.getHi()[0] < v[0]) + return SQR(v[0] - r.getHi()[0]); + return R(); + } + }; } //namespace _RectPrivate diff --git a/Pinocchio/vector.h b/Pinocchio/vector.h index 491dd57..f00cd69 100644 --- a/Pinocchio/vector.h +++ b/Pinocchio/vector.h @@ -235,6 +235,7 @@ class VecOp typedef VecOp Next; template friend class VecOp; template friend class Vector; + template friend class ::Vector; template static void assign(const VRD1 &from, VRD &to) { to[last] = from[last]; Next::assign(from, to); } @@ -272,6 +273,7 @@ class VecOp<1> { private: template friend class VecOp; + template friend class ::Vector; template static void assign(const VRD1 &from, VRD &to) { to[0] = from[0]; } diff --git a/PinocchioStatic/CMakeLists.txt b/PinocchioStatic/CMakeLists.txt new file mode 100644 index 0000000..27eaec9 --- /dev/null +++ b/PinocchioStatic/CMakeLists.txt @@ -0,0 +1,80 @@ +project(PinocchioStatic) + +# Gather all source files +set(PINOCCHIO_SRC + ../Pinocchio/attachment.cpp + ../Pinocchio/discretization.cpp + ../Pinocchio/embedding.cpp + ../Pinocchio/graphutils.cpp + ../Pinocchio/indexer.cpp + ../Pinocchio/intersector.cpp + ../Pinocchio/lsqSolver.cpp + ../Pinocchio/matrix.cpp + ../Pinocchio/mesh.cpp + ../Pinocchio/pinocchioApi.cpp + ../Pinocchio/refinement.cpp + ../Pinocchio/skeleton.cpp +) + +# Gather all header files (optional but useful for IDEs) +set(PINOCCHIO_HEADERS + ../Pinocchio/attachment.h + ../Pinocchio/debugging.h + ../Pinocchio/deriv.h + ../Pinocchio/dtree.h + ../Pinocchio/graphutils.h + ../Pinocchio/hashutils.h + ../Pinocchio/indexer.h + ../Pinocchio/intersector.h + ../Pinocchio/lsqSolver.h + ../Pinocchio/mathutils.h + ../Pinocchio/matrix.h + ../Pinocchio/mesh.h + ../Pinocchio/multilinear.h + ../Pinocchio/Pinocchio.h + ../Pinocchio/pinocchioApi.h + ../Pinocchio/pointprojector.h + ../Pinocchio/quaddisttree.h + ../Pinocchio/rect.h + ../Pinocchio/skeleton.h + ../Pinocchio/transform.h + ../Pinocchio/utils.h + ../Pinocchio/vector.h + ../Pinocchio/vecutils.h +) + +# Define the static library +add_library(PinocchioStatic STATIC ${PINOCCHIO_SRC} ${PINOCCHIO_HEADERS}) + +# Include directories +target_include_directories(PinocchioStatic PUBLIC + ${CMAKE_SOURCE_DIR}/Pinocchio +) + +# Define preprocessor macros +target_compile_definitions(PinocchioStatic PRIVATE + _LIB + PINOCCHIO_STATIC +) + +# Compiler options for debug and release +target_compile_options(PinocchioStatic PRIVATE + $<$:/Od /Zi /RTC1> # Optimization off, debug info, runtime checks + $<$:/O2 /DNDEBUG> # Optimization on, no debug +) + +if(CMAKE_BUILD_TYPE MATCHES Debug) + target_compile_definitions(PinocchioStatic PRIVATE _DEBUG) + target_compile_options(PinocchioStatic PRIVATE -g -O0 -Wall) +else() + target_compile_definitions(PinocchioStatic PRIVATE NDEBUG) + target_compile_options(PinocchioStatic PRIVATE -O2 -Wall) +endif() + +# Set the runtime library (matches Visual Studio project: /MDd for Debug, /MD for Release) +# Use MSVC_RUNTIME_LIBRARY only with CMake 3.15+ +if(MSVC) + set_property(TARGET PinocchioStatic PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif() +