Closed dwoll closed 2 years ago
Hi, The centroid is nothing but the average vertex, I think.
The average vertex would be drawn towards regions with high mesh resolution (and thus higher number of vertices). Both CGAL as well as libigl do more complicated things:
If you'd like, I can try to do a pull request with an interface to CGAL::PMP::centroid()
.
Ah ok. The point embarassing me is that this package will never be on CRAN (because it is big and there are some warnings). As you have seen, I started to split it: PolygonSoup and Boov. I'm wondering where I could add the centroid feature. I'm ok for doing a new package but what could be its main purpose? Maybe a package MeshesUtilities? In which I could implement: volume, centroid, convex parts, clipping. What do you think? I also plan to do another package for the Minkowski addition.
Splitting up for different sub-tasks seems like a good idea. Just how to carve the big library into pieces, I'm not sure, I don't know CGAL (or mesh processing for that matter) well enough to understand how coherent sets of functions could be defined. There certainly needs to be a "tools" or "utils" or "base" package for basic tasks that are re-used multiple times in more complex processing operations.
MeshesTools sounds nice. I implemented the centroid now: MeshesTools.
Many thanks!
Hi @dwoll
I'm preparing a new package: cgalMeshes. It would contain everything included in the previous packages. Its advantage is that a R6 class is used to represent a mesh, that makes the package more comfortable for the user. Moreover, once you define a new mesh, it stays in memory, whereas with the other packages, the mesh was re-processed for each operation.
Example:
# read mesh from file
mesh <- cgalMesh$new("myfile.ply")
# triangulation
mesh$triangulate()
# volume
mesh$volume()
# centroid
mesh$centroid()
Thanks for the heads up about your development plans! I've now written a first version of the Shiny front-end to your packages (and Rvcg) dedicated to calculate agreement measures for 3D meshes: https://github.com/dwoll/MeshAgreement (Shiny app in inst/MeshAgreement)
The package currently uses your packages SurfaceReconstruction, PolygonSoup, MeshesTools, and Boov. I'll follow along as you update these. One thing I haven't fully grasped is the difference between PolygonSoup and MeshesTools - both seem to have similar scope.
Many thanks for a brisk pace in bringing your packages to a stable state and pushing to CRAN! It's really nice to just have to write some front-end code for them to get a useful practical application.
PolygonSoup only allows to get a consistent mesh from a polygon soup. And it contains the two functions toRGL
and plotEdges
, which are imported by the other packages. In MeshesTools I implemented the volume, the area, the distance from a point, the clipping, and the convex parts.
Hi @dwoll
uses your packages SurfaceReconstruction, PolygonSoup, MeshesTools, and Boov.
Now you can abandon all these packages. I won't further develop these ones. Everything is contained in cgalMeshes. Except the surface reconstruction, but there's a new feature for the removal of self-intersections. It is experimental but it works fine with your two PLY files:
library(cgalMeshes)
mesh1 <- cgalMesh$new("inst/essais/mesh_1.ply")
mesh1$selfIntersects() # TRUE
mesh1$removeSelfIntersections()
mesh1$selfIntersects() # FALSE
mesh2 <- cgalMesh$new("inst/essais/mesh_2.ply")
mesh2$selfIntersects() # TRUE
mesh2$removeSelfIntersections()
mesh2$selfIntersects() # FALSE
# union
umesh <- mesh1$union(mesh2)
rglumesh <- umesh$getMesh(normals = FALSE)
rgl::shade3d(rglumesh, color = "orange")
MeshesOperations
currently provides an interface toCGAL::PMP::volume()
which is very convenient. It would be very nice to also have an interface toCGAL::PMP::centroid()
. My use case is mesh similarity measures. The distance between the mesh centroids is one such measure, and could be derived from having the centroid. Many thanks in advance!