win fixes + pybind11 improvementS
This commit is contained in:
@@ -589,19 +589,10 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
endif(FREECAD_USE_PCL)
|
||||
|
||||
# -------------------------------- PyBind11 -----------------------------
|
||||
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c
|
||||
"import pybind11; print(bool(pybind11))"
|
||||
OUTPUT_VARIABLE PYBIND11_FOUND OUTPUT_STRIP_TRAILING_WHITESPACE )
|
||||
|
||||
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c
|
||||
"import pybind11; print(pybind11.get_include())"
|
||||
OUTPUT_VARIABLE PYBIND11_INCLUDE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE )
|
||||
|
||||
if (PYBIND11_FOUND)
|
||||
message(STATUS "successfully found pybind11")
|
||||
message(STATUS "pybind11 include dir is: " ${PYBIND11_INCLUDE_DIR})
|
||||
OPTION(FREECAD_USE_PYBIND11 "Use pybind11" OFF)
|
||||
if (FREECAD_USE_PYBIND11)
|
||||
find_package(pybind11 REQUIRED)
|
||||
endif()
|
||||
|
||||
# -------------------------------- Boost --------------------------------
|
||||
|
||||
SET(_boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS})
|
||||
|
||||
@@ -81,18 +81,21 @@ SET_PYTHON_PREFIX_SUFFIX(MeshPart)
|
||||
INSTALL(TARGETS MeshPart DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
|
||||
if (PYBIND11_FOUND)
|
||||
################################ flat mesh ###############################
|
||||
################################ flat mesh ###############################
|
||||
if (FREECAD_USE_PYBIND11)
|
||||
SET(FLATMESH_SRCS
|
||||
MeshFlatteningPy.cpp
|
||||
MeshFlattening.cpp
|
||||
MeshFlattening.h
|
||||
MeshFlatteningNurbs.h
|
||||
MeshFlatteningNurbs.cpp
|
||||
MeshFlatteningLscmRelax.h
|
||||
MeshFlatteningLscmRelax.cpp
|
||||
MeshFlattening.cpp
|
||||
MeshFlattening.h
|
||||
MeshFlatteningNurbs.h
|
||||
MeshFlatteningNurbs.cpp
|
||||
MeshFlatteningLscmRelax.h
|
||||
MeshFlatteningLscmRelax.cpp
|
||||
)
|
||||
|
||||
SET(FLATMESH_SRCS
|
||||
${FLATMESH_SRCS}
|
||||
MeshFlatteningPy.cpp
|
||||
)
|
||||
|
||||
|
||||
add_library(flatmesh SHARED ${FLATMESH_SRCS})
|
||||
@@ -101,5 +104,5 @@ if (PYBIND11_FOUND)
|
||||
|
||||
SET_BIN_DIR(flatmesh flatmesh /Mod/MeshPart)
|
||||
install(TARGETS flatmesh DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
############################################################################
|
||||
endif()
|
||||
############################################################################
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <vector>
|
||||
#include <exception>
|
||||
|
||||
|
||||
std::vector<ColMat<double, 3>> getBoundaries(ColMat<double, 3> vertices, ColMat<long, 3> tris)
|
||||
{
|
||||
// get a hashtable for all edges
|
||||
@@ -172,7 +173,7 @@ FaceUnwrapper::FaceUnwrapper(const TopoDS_Face& face)
|
||||
void FaceUnwrapper::findFlatNodes(int steps, double val)
|
||||
{
|
||||
std::vector<long> fixed_pins; //TODO: INPUT
|
||||
LscmRelax mesh_flattener(this->xyz_nodes.transpose(), this->tris.transpose(), fixed_pins);
|
||||
lscmrelax::LscmRelax mesh_flattener(this->xyz_nodes.transpose(), this->tris.transpose(), fixed_pins);
|
||||
mesh_flattener.lscm();
|
||||
for (int j=0; j<steps; j++)
|
||||
mesh_flattener.relax(0.95);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "MeshFlatteningLscmRelax.h"
|
||||
#include <Eigen/IterativeLinearSolvers>
|
||||
#include<Eigen/SparseCholesky>
|
||||
#include <Eigen/SparseCholesky>
|
||||
#include <Eigen/SVD>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
@@ -39,6 +39,8 @@
|
||||
// area constrained (scale the final unwrapped mesh to the original area)
|
||||
// FEM approach
|
||||
|
||||
namespace lscmrelax
|
||||
{
|
||||
|
||||
typedef Eigen::Triplet<double> trip;
|
||||
typedef Eigen::SparseMatrix<double> spMat;
|
||||
@@ -565,3 +567,5 @@ std::vector<long> LscmRelax::get_fem_fixed_pins()
|
||||
}
|
||||
return std::vector<long>{min_x_index * 2, min_x_index * 2 + 1, max_x_index * 2 + 1};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
// 6: K.u=forces ->u
|
||||
// 7: x1, y1 += w * u
|
||||
|
||||
#include "MeshFlattening.h"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
@@ -42,20 +44,14 @@
|
||||
#include <Eigen/Geometry>
|
||||
#include <Eigen/IterativeLinearSolvers>
|
||||
|
||||
#include "MeshFlatteningLscmRelax.h"
|
||||
|
||||
typedef Eigen::SparseMatrix<double> spMat;
|
||||
|
||||
|
||||
namespace lscmrelax
|
||||
{
|
||||
|
||||
typedef Eigen::Vector3d Vector3;
|
||||
typedef Eigen::Vector2d Vector2;
|
||||
|
||||
template <typename type, unsigned int size>
|
||||
using ColMat = Eigen::Matrix<type, Eigen::Dynamic, size>;
|
||||
|
||||
template <typename type, unsigned int size>
|
||||
using RowMat = Eigen::Matrix<type, size, Eigen::Dynamic>;
|
||||
|
||||
class LscmRelax{
|
||||
private:
|
||||
ColMat<double, 3> q_l_g; // the position of the 3d triangles at there locale coord sys
|
||||
@@ -104,5 +100,6 @@ public:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
#include <ShapeFix_Edge.hxx>
|
||||
|
||||
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
const TopoDS_Face& getTopoDSFace(py::object* face)
|
||||
@@ -101,29 +100,30 @@ ColMat<double, 3> interpolateFlatFacePy(FaceUnwrapper& instance, py::object* fac
|
||||
}
|
||||
|
||||
|
||||
|
||||
PYBIND11_MODULE(flatmesh, m)
|
||||
{
|
||||
m.doc() = "functions to unwrapp faces/ meshes";
|
||||
|
||||
py::class_<LscmRelax>(m, "LscmRelax")
|
||||
py::class_<lscmrelax::LscmRelax>(m, "LscmRelax")
|
||||
.def(py::init<ColMat<double, 3>, ColMat<long, 3>, std::vector<long>>())
|
||||
.def("lscm", &LscmRelax::lscm)
|
||||
.def("relax", &LscmRelax::relax)
|
||||
.def("rotate_by_min_bound_area", &LscmRelax::rotate_by_min_bound_area)
|
||||
.def("transform", &LscmRelax::transform)
|
||||
.def_readonly("rhs", &LscmRelax::rhs)
|
||||
.def_readonly("MATRIX", &LscmRelax::MATRIX)
|
||||
.def_property_readonly("area", &LscmRelax::get_area)
|
||||
.def_property_readonly("flat_area", &LscmRelax::get_flat_area)
|
||||
.def_property_readonly("flat_vertices", [](LscmRelax& L){return L.flat_vertices.transpose();}, py::return_value_policy::copy)
|
||||
.def_property_readonly("flat_vertices_3D", &LscmRelax::get_flat_vertices_3D);
|
||||
.def("lscm", &lscmrelax::LscmRelax::lscm)
|
||||
.def("relax", &lscmrelax::LscmRelax::relax)
|
||||
.def("rotate_by_min_bound_area", &lscmrelax::LscmRelax::rotate_by_min_bound_area)
|
||||
.def("transform", &lscmrelax::LscmRelax::transform)
|
||||
.def_readonly("rhs", &lscmrelax::LscmRelax::rhs)
|
||||
.def_readonly("MATRIX", &lscmrelax::LscmRelax::MATRIX)
|
||||
.def_property_readonly("area", &lscmrelax::LscmRelax::get_area)
|
||||
.def_property_readonly("flat_area", &lscmrelax::LscmRelax::get_flat_area)
|
||||
.def_property_readonly("flat_vertices", [](lscmrelax::LscmRelax& L){return L.flat_vertices.transpose();}, py::return_value_policy::copy)
|
||||
.def_property_readonly("flat_vertices_3D", &lscmrelax::LscmRelax::get_flat_vertices_3D);
|
||||
|
||||
py::class_<nurbs::NurbsBase2D>(m, "NurbsBase2D")
|
||||
.def(py::init<Eigen::VectorXd, Eigen::VectorXd, Eigen::VectorXd, int, int>())
|
||||
.def_readonly("u_knots", &nurbs::NurbsBase2D::u_knots)
|
||||
.def_readonly("weights", &nurbs::NurbsBase2D::weights)
|
||||
.def_readonly("degree_u", &nurbs::NurbsBase2D::degree_u)
|
||||
.def_readonly("v_knots", &nurbs::NurbsBase2D::u_knots)
|
||||
// .def_readonly("v_knots", &nurbs::NurbsBase2D::u_knots)
|
||||
.def_readonly("degree_v", &nurbs::NurbsBase2D::degree_u)
|
||||
.def("getUVMesh", &nurbs::NurbsBase2D::getUVMesh)
|
||||
.def("computeFirstDerivatives", &nurbs::NurbsBase2D::computeFirstDerivatives)
|
||||
|
||||
Reference in New Issue
Block a user