diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b6654920150..0f8fc883f36f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,7 @@ IF(MESHLIB_PYTHON_SUPPORT AND NOT MR_EMSCRIPTEN) ENDIF() IF($ENV{MESHLIB_PYTHON_VERSION}) - set(MR_PYTHON_VERSION $ENV{MESHLIB_PYTHON_VERSION}) + set(MESHLIB_PYTHON_VERSION $ENV{MESHLIB_PYTHON_VERSION}) ENDIF() IF(DEFINED MESHLIB_PYTHON_VERSION) diff --git a/source/MRMesh/MRPython.h b/source/MRMesh/MRPython.h index c2bcc784231f..10d18bfdb822 100644 --- a/source/MRMesh/MRPython.h +++ b/source/MRMesh/MRPython.h @@ -93,8 +93,8 @@ MR_ADD_PYTHON_CUSTOM_DEF( moduleName, name##_inst_, [] ( pybind11::module_& modu * @endcode * See also \ref MR_ADD_PYTHON_VEC and \ref MR_ADD_PYTHON_MAP macros for customized class definition examples. */ -#define MR_ADD_PYTHON_CUSTOM_CLASS( moduleName, name, type ) \ -MR_ADD_PYTHON_CUSTOM_CLASS_DECL( moduleName, name, type ) \ +#define MR_ADD_PYTHON_CUSTOM_CLASS( moduleName, name, ... ) \ +MR_ADD_PYTHON_CUSTOM_CLASS_DECL( moduleName, name, __VA_ARGS__ ) \ MR_ADD_PYTHON_CUSTOM_CLASS_INST( moduleName, name ) #define MR_ADD_PYTHON_VEC( moduleName, name, type) \ diff --git a/source/mrmeshpy/MRPythonBooleanExposing.cpp b/source/mrmeshpy/MRPythonBooleanExposing.cpp index 0a5a7a77fb73..2c1c7a34502c 100644 --- a/source/mrmeshpy/MRPythonBooleanExposing.cpp +++ b/source/mrmeshpy/MRPythonBooleanExposing.cpp @@ -4,17 +4,29 @@ #include "MRMesh/MRMeshBoolean.h" #include "MRMesh/MRUniteManyMeshes.h" #include "MRMesh/MRId.h" + #include + #include +MR_ADD_PYTHON_CUSTOM_CLASS( mrmeshpy, EdgeTri, MR::EdgeTri ) + +MR_ADD_PYTHON_CUSTOM_CLASS( mrmeshpy, VariableEdgeTri, MR::VariableEdgeTri, MR::EdgeTri ) + +MR_ADD_PYTHON_CUSTOM_CLASS( mrmeshpy, OneMeshIntersection, MR::OneMeshIntersection ) + +MR_ADD_PYTHON_CUSTOM_CLASS( mrmeshpy, OneMeshContour, MR::OneMeshContour ) + MR_ADD_PYTHON_CUSTOM_DEF( mrmeshpy, MeshIntersectinosTypes, [] ( pybind11::module_& m ) { - pybind11::class_( m, "EdgeTri", "edge from one mesh and triangle from another mesh" ). + MR_PYTHON_CUSTOM_CLASS( EdgeTri ).doc() = + "edge from one mesh and triangle from another mesh"; + MR_PYTHON_CUSTOM_CLASS( EdgeTri ). def( pybind11::init<>() ). def_readwrite( "edge", &MR::EdgeTri::edge ). def_readwrite( "tri", &MR::EdgeTri::tri ); - pybind11::class_( m, "VariableEdgeTri" ). + MR_PYTHON_CUSTOM_CLASS( VariableEdgeTri ). def( pybind11::init<>() ). def_readwrite( "isEdgeATriB", &MR::VariableEdgeTri::isEdgeATriB ); @@ -31,7 +43,9 @@ MR_ADD_PYTHON_CUSTOM_DEF( mrmeshpy, MeshIntersectinosTypes, [] ( pybind11::modul def( "getEdge", [] ( const OneMeshIntersectionVariant& self ) { return std::get( self ); } ). def( "getVert", [] ( const OneMeshIntersectionVariant& self ) { return std::get( self ); } ); - pybind11::class_( m, "OneMeshIntersection", "Simple point on mesh, represented by primitive id and coordinate in mesh space" ). + MR_PYTHON_CUSTOM_CLASS( OneMeshIntersection ).doc() = + "Simple point on mesh, represented by primitive id and coordinate in mesh space"; + MR_PYTHON_CUSTOM_CLASS( OneMeshIntersection ). def( pybind11::init<>() ). def_readwrite( "primitiveId", &MR::OneMeshIntersection::primitiveId ). def_readwrite( "coordinate", &MR::OneMeshIntersection::coordinate ); @@ -53,9 +67,11 @@ MR_ADD_PYTHON_VEC( mrmeshpy, ContinuousContours, MR::ContinuousContour ) MR_ADD_PYTHON_VEC( mrmeshpy, vectorOneMeshIntersection, MR::OneMeshIntersection ) -MR_ADD_PYTHON_CUSTOM_DEF( mrmeshpy, MeshIntersectinosTypes2, [] ( pybind11::module_& m ) +MR_ADD_PYTHON_CUSTOM_DEF( mrmeshpy, MeshIntersectinosTypes2, [] ( pybind11::module_& ) { - pybind11::class_( m, "OneMeshContour", "One contour on mesh" ). + MR_PYTHON_CUSTOM_CLASS( OneMeshContour ).doc() = + "One contour on mesh"; + MR_PYTHON_CUSTOM_CLASS( OneMeshContour ). def( pybind11::init<>() ). def_readwrite( "intersections", &MR::OneMeshContour::intersections ). def_readwrite( "closed", &MR::OneMeshContour::closed );