add quadmesh

This commit is contained in:
AndreaRigoni
2026-03-14 10:28:16 +00:00
parent 6bf9eaf309
commit 20d4967356
13 changed files with 600 additions and 14 deletions

View File

@@ -15,6 +15,7 @@
#include "Math/StructuredGrid.h"
#include "Math/Transform.h"
#include "Math/TriangleMesh.h"
#include "Math/QuadMesh.h"
#include "Math/VoxImage.h"
#include "Math/VoxRaytracer.h"
@@ -431,6 +432,16 @@ void init_math(py::module_ &m) {
.def("Triangles", &TriangleMesh::Triangles,
py::return_value_policy::reference_internal);
py::class_<QuadMesh>(m, "QuadMesh")
.def(py::init<>())
.def("AddPoint", &QuadMesh::AddPoint)
.def("AddQuad",
py::overload_cast<const Vector4i &>(&QuadMesh::AddQuad))
.def("Points", &QuadMesh::Points,
py::return_value_policy::reference_internal)
.def("Quads", &QuadMesh::Quads,
py::return_value_policy::reference_internal);
py::class_<VoxRaytracer::RayData::Element>(m, "VoxRaytracerRayDataElement")
.def(py::init<>())
.def_readwrite("vox_id", &VoxRaytracer::RayData::Element::vox_id)

View File

@@ -155,6 +155,18 @@ class TestMathNewTypes(unittest.TestCase):
# SetValue(id, value) sets At(id).Value = value
self.assertAlmostEqual(img.GetValue([0, 0, 0]), 10.5)
def test_quad_mesh(self):
mesh = uLib.Math.QuadMesh()
mesh.AddPoint(uLib.Math.Vector3f([0, 0, 0]))
mesh.AddPoint(uLib.Math.Vector3f([1, 0, 0]))
mesh.AddPoint(uLib.Math.Vector3f([1, 1, 0]))
mesh.AddPoint(uLib.Math.Vector3f([0, 1, 0]))
mesh.AddQuad(uLib.Math.Vector4i([0, 1, 2, 3]))
self.assertEqual(len(mesh.Points()), 4)
self.assertEqual(len(mesh.Quads()), 1)
class TestMathVoxRaytracer(unittest.TestCase):
def test_raytracer(self):
grid = uLib.Math.StructuredGrid([10, 10, 10])