Mentions légales du service

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

use eigen for native numpy output

parent e374cb18
No related branches found
No related tags found
1 merge request!7basic tetrahedral mesh class
Pipeline #949157 passed
......@@ -17,6 +17,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
find_package(pybind11 CONFIG REQUIRED)
find_package(CGAL REQUIRED COMPONENTS ImageIO)
find_package(Eigen3 3.3 REQUIRED NO_MODULE)
# make cache variables for install destinations
include(GNUInstallDirs)
......
......@@ -12,5 +12,6 @@ add_library(${PROJECT_NAME} SHARED
${${PROJECT_NAME}_HEADERS}
${${PROJECT_NAME}_SOURCES}
)
target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen)
install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
\ No newline at end of file
#include "LabelledTetrahedralMesh.h"
std::vector< std::vector<double> > LabelledTetrahedralMesh::vertexPoints(void) const
Eigen::ArrayX3d LabelledTetrahedralMesh::vertexPoints(void) const
{
return this->_vertex_points;
Eigen::ArrayX3d vertex_points(this->_vertex_points.size(), 3);
for (int i=0; i<this->_vertex_points.size(); i++) {
for (int dim=0; dim<3; dim++) {
vertex_points(i, dim) = this->_vertex_points[i][dim];
}
}
return vertex_points;
}
void LabelledTetrahedralMesh::addPoint(const std::vector<double>& point)
void LabelledTetrahedralMesh::addPoint(Eigen::Array3d point)
{
this->_vertex_points.push_back(point);
std::vector<double> _point = std::vector<double> {point(0, 0), point(0, 1), point(0, 2)};
this->_vertex_points.push_back(_point);
}
#pragma once
#include <vector>
#include <Eigen/Dense>
class LabelledTetrahedralMesh
{
......@@ -9,8 +10,8 @@ public:
~LabelledTetrahedralMesh(void) = default;
public:
std::vector< std::vector<double> > vertexPoints(void) const;
void addPoint(const std::vector<double>& point);
Eigen::ArrayX3d vertexPoints(void) const;
void addPoint(Eigen::Array3d point);
private:
std::vector< std::vector<double> > _vertex_points;
......
......@@ -13,4 +13,4 @@ class TestTetrahedralMesh(unittest.TestCase):
mesh = LabelledTetrahedralMesh()
mesh.add_point([0, 0, 0])
points = mesh.vertex_points()
assert len(points) == 1
assert points.shape == (1, 3)
#include <pybind11/pybind11.h>
#include <pybind11/stl.h> // This header is needed to work with STL containers like std::vector
#include <pybind11/eigen.h>
#include "LabelledTetrahedralMesh.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment