Skip to content

Commit

Permalink
Merge pull request #672 from mcneel/luis/testRelatedFixes
Browse files Browse the repository at this point in the history
some changes related to findings from testing the python samples in r…
  • Loading branch information
fraguada authored Jan 27, 2025
2 parents 1bc3ddf + 08e173f commit 104d298
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ std::string ToStdString(const py::str& str)
BND_TUPLE CreateTuple(int count)
{
#if defined(ON_PYTHON_COMPILE)
BND_TUPLE rc = py::make_tuple(count);
BND_TUPLE rc = py::tuple(count);
#else
emscripten::val rc(emscripten::val::array());
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/bindings/bnd_extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2010,12 +2010,12 @@ void initExtensionsBindings(rh3dmpymodule& m)
.def_static("Read", &BND_ONXModel::Read, py::arg("path"))
.def_static("ReadNotes", &BND_ONXModel::ReadNotes, py::arg("path"))
.def_static("ReadArchiveVersion", &BND_ONXModel::ReadArchiveVersion, py::arg("path"))
/*
#if !defined(NANOBIND)
.def_static("FromByteArray", [](py::buffer b) {
py::buffer_info info = b.request();
return BND_ONXModel::FromByteArray(static_cast<int>(info.size), info.ptr);
})
*/
#endif
.def("Write", &BND_ONXModel::Write, py::arg("path"), py::arg("version")=0)
.def_property("StartSectionComments", &BND_ONXModel::GetStartSectionComments, &BND_ONXModel::SetStartSectionComments)
.def_property("ApplicationName", &BND_ONXModel::GetApplicationName, &BND_ONXModel::SetApplicationName)
Expand Down
42 changes: 38 additions & 4 deletions tests/python/test_PointCloud.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import rhino3dm
import unittest

#objective: to test that passing a list of points or a Point3dList to the PointCloud ctor returns the same Point Cloud

# objective: to test that passing a list of points or a Point3dList to the PointCloud ctor returns the same Point Cloud
class TestPointCloud(unittest.TestCase):
def test_ctor(self):

Expand All @@ -15,9 +16,42 @@ def test_ctor(self):
pcFromArray = rhino3dm.PointCloud(pointArray)
pcFromList = rhino3dm.PointCloud(pointList)

self.assertEqual( pcFromArray.ClosestPoint(rhino3dm.Point3d(0,0,0)), pcFromArray.ClosestPoint(rhino3dm.Point3d(0,0,0)) )
self.assertEqual(
pcFromArray.ClosestPoint(rhino3dm.Point3d(0, 0, 0)),
pcFromArray.ClosestPoint(rhino3dm.Point3d(0, 0, 0)),
)

def test_members(self):

pc = rhino3dm.PointCloud()

# pc.Add(rhino3dm.Point3d(0, 0, 0))
# pc.Add(rhino3dm.Point3d(0, 0, 0), rhino3dm.Vector3d(0, 0, 1))
# pc.Add(rhino3dm.Point3d(0, 0, 0), (255, 0, 0, 0))
# pc.Add(rhino3dm.Point3d(0, 0, 0), rhino3dm.Vector3d(0, 1, 1), (255, 0, 0, 0))
# pc.Add(rhino3dm.Point3d(0, 0, 0), 1.234)
pc.Add(rhino3dm.Point3d(0, 0, 0), rhino3dm.Vector3d(0, 1, 1), (255, 0, 0, 0), 1.234)
print(len(pc))
pc.Add(rhino3dm.Point3d(0, 0, 0), rhino3dm.Vector3d(0, 1, 1), (255, 0, 0, 0), 1.234)
print(len(pc))
pc.Add(rhino3dm.Point3d(0, 0, 0), rhino3dm.Vector3d(0, 1, 1), (255, 0, 0, 0), 1.234)
print(len(pc))
pc.Add(rhino3dm.Point3d(0, 0, 0), rhino3dm.Vector3d(0, 1, 1), (255, 0, 0, 0), 1.234)
print(len(pc))

pts = pc.GetPoints()
print(pts)
nrmls = pc.GetNormals()
print(nrmls)
cols = pc.GetColors()
print(cols)
vals = pc.GetValues()
print(vals)




if __name__ == '__main__':
if __name__ == "__main__":
print("running tests")
unittest.main()
print("tests complete")
print("tests complete")

0 comments on commit 104d298

Please sign in to comment.