Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 74fd1491 authored by CERUTTI Guillaume's avatar CERUTTI Guillaume
Browse files

define cpp class + first cmake attempt

parent 3f6e6d28
Branches
No related tags found
1 merge request!7basic tetrahedral mesh class
Pipeline #947904 passed
...@@ -9,24 +9,33 @@ project( ...@@ -9,24 +9,33 @@ project(
VERSION ${SKBUILD_PROJECT_VERSION} VERSION ${SKBUILD_PROJECT_VERSION}
LANGUAGES CXX) LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Find the module development requirements (requires FindPython from 3.17 or # Find the module development requirements (requires FindPython from 3.17 or
# scikit-build-core's built-in backport) # scikit-build-core's built-in backport)
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module) find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
find_package(pybind11 CONFIG REQUIRED) find_package(pybind11 CONFIG REQUIRED)
find_package(CGAL REQUIRED COMPONENTS ImageIO) find_package(CGAL REQUIRED COMPONENTS ImageIO)
add_library(_cpp SHARED cpp/LabelledTetrahedralMesh.h cpp/LabelledTetrahedralMesh.cpp)
# Add a library using FindPython's tooling (pybind11 also provides a helper like # Add a library using FindPython's tooling (pybind11 also provides a helper like
# this) # this)
python_add_library(_core MODULE src/main.cpp WITH_SOABI) pybind11_add_module(_core MODULE src/main.cpp)
target_link_libraries(_core PRIVATE pybind11::headers)
# This is passing in the version as a define just as an example # This is passing in the version as a define just as an example
target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION}) target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION})
python_add_library(_cgal MODULE src/cgal_example.cpp WITH_SOABI) pybind11_add_module(_cgal MODULE src/cgal_example.cpp)
target_link_libraries(_cgal PRIVATE pybind11::headers)
target_link_libraries(_cgal PRIVATE CGAL::CGAL) target_link_libraries(_cgal PRIVATE CGAL::CGAL)
# The install directory is the output (wheel) directory # The install directory is the output (wheel) directory
install(TARGETS _core DESTINATION pybind_example) install(TARGETS _core DESTINATION pybind_example)
install(TARGETS _cgal DESTINATION pybind_example) install(TARGETS _cgal DESTINATION pybind_example)
pybind11_add_module(_wrp MODULE wrp/LabelledTetrahedralMeshWrapper.cpp)
target_include_directories(_wrp PRIVATE ${CMAKE_SOURCE_DIR}/cpp/)
target_link_libraries(_wrp PUBLIC _cpp)
install(TARGETS _wrp DESTINATION pybind_example)
\ No newline at end of file
#include "LabelledTetrahedralMesh.h"
std::vector< std::vector<double> > LabelledTetrahedralMesh::vertexPoints(void) const
{
std::vector< std::vector<double> > points;
return points;
}
#pragma once
#include <vector>
class LabelledTetrahedralMesh
{
public:
LabelledTetrahedralMesh(void) = default;
~LabelledTetrahedralMesh(void) = default;
public:
std::vector< std::vector<double> > vertexPoints(void) const;
};
\ No newline at end of file
from ._wrp import LabelledTetrahedralMesh
\ No newline at end of file
#include <pybind11/pybind11.h>
#include <pybind11/stl.h> // This header is needed to work with STL containers like std::vector
#include "LabelledTetrahedralMesh.h"
namespace py = pybind11;
PYBIND11_MODULE(_wrp, m) {
py::class_<LabelledTetrahedralMesh>(m, "LabelledTetrahedralMesh")
.def(py::init<>())
.def("vertex_points", &LabelledTetrahedralMesh::vertexPoints);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment