GithubHelp home page GithubHelp logo

zarquon42b / rvcg Goto Github PK

View Code? Open in Web Editor NEW
25.0 25.0 10.0 23.53 MB

R-package providing mesh manipulation routines from VCGLIB

License: Other

R 0.70% Shell 0.01% C++ 95.68% C 3.15% QMake 0.14% HTML 0.03% CSS 0.01% CMake 0.21% GLSL 0.10%

rvcg's People

Contributors

dfsp-spirit avatar jefferis avatar zarquon42b avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rvcg's Issues

Adding conda-forge recipe

@zarquon42b I'm adding your package Rvcg to conda-forge (conda-forge/staged-recipes#22073). The goal is to allow conda users to install Rvcg via conda install --channel conda-forge r-rvcg

Can I add you to the maintainer list of that recipe in case there are any changes (such as dependence or compilers), you can edit and update the recipe? Normally you won't need to do anything when updating your package on CRAN. Conda-forge will automatically resolve and update the feedstock.

signed distances are not calculated if distance is >1e5

I am working with some electron microscopy data calibrated in nm. I am using signed distance with vcgClostKD to determine if points are inside a mesh. Some of my distances from points outside the mesh are greater than 1E5.

Unfortunately 1E5 is being used as a signalling value in some contexts to mean out of range. The lines below effectively assumes that all distances are <1E5.

Rvcg/src/RvcgKD.h

Lines 188 to 193 in d689603

if (sign && (distances[i] < 1e5)) {
Point3f dif = clost - currp;
//float sign = dif.dot(vertexnormal);
if (dif.dot(vertexnormal) < 0)
distances[i] = -distances[i];
}

would it perhaps be possible to use a NAN/Inf or other signalling procedure?

Make the title shorter

This title is a bit too large, it should be in the descrition. Suggested alternative: VCGlib functions for R.

Manipulations of triangular meshes (smoothing, quadric edge collapse decimation, im- and export of various mesh file-formats, cleaning, etc.) based on the VCGLIB API.

std::bad_alloc with vcgIsolated

Hello,

I have a very large mesh3d, with ~60 millions triangles. When I run vcgIsolated(mymesh, diameter=0) on this mesh, an error is generated: std::bad_alloc. Do you know a workaround, or an alternative ? (I took a look at RvtkStatismo, but I saw nothing about the connected components).

vcgClost retunring infinite distances

vcgClost returning infinite distances for certain points, from mesh3d objects?

E.g. for the following points and mesh:

points  =structure(c(53.5116, 68.248, 66.9674, 80.7424, 83.315, 82.3042, 
                     140.15, 140, 142.85), .Dim = c(3L, 3L), .Dimnames = list(NULL, 
                                                                              c("X", "Y", "Z")))
mesh = structure(list(vb = structure(c(23.959, 35.3856, 62.5, 1, 22.4086, 
                                                35.0246, 58.35, 1, 24.3751, 35.1405, 58.8, 1, 21.66, 19.2135, 
                                                61.1, 1, 22.1122, 23.4194, 62.55, 1, 19.9899, 24.5575, 61.95, 
                                                1, 22.9634, 16.587, 58.4, 1, 20.7157, 17.4439, 54.3, 1, 22.0951, 
                                                16.6858, 53.4, 1, 21.2192, 17.4667, 58.5, 1, 23.4536, 28.5893, 
                                                63.65, 1, 24.6772, 27.208, 63.1, 1, 24.0616, 28.747, 63.5, 1, 
                                                23.6417, 25.1351, 63.05, 1, 21.0482, 30.9092, 62.1, 1, 22.3174, 
                                                33.1474, 62.85, 1, 17.6681, 31.9219, 57.45, 1, 20.9152, 27.4246, 
                                                63.3, 1, 17.1152, 28.2416, 58.15, 1, 25.764, 20.3528, 61.85, 
                                                1, 20.3205, 17.7536, 54.05, 1, 19.9253, 18.1849, 54.8, 1, 21.3617, 
                                                17.6168, 50.35, 1, 21.2743, 18.411, 49.1, 1, 21.6334, 18.5326, 
                                                48.25, 1, 21.0501, 18.1013, 50.1, 1, 17.1684, 22.8779, 48.75, 
                                                1, 19.1634, 23.3054, 44.1, 1, 20.1324, 18.8119, 57.65, 1, 19.8113, 
                                                19.7448, 59.15, 1, 22.1977, 34.8992, 54.85, 1, 15.0366, 28.8876, 
                                                50, 1, 15.1696, 29.6609, 51, 1, 15.8479, 29.6343, 49.1, 1, 16.4084, 
                                                28.3879, 45.05, 1, 26.1858, 16.986, 56.15, 1, 27.075, 19.8056, 
                                                53.9, 1, 28.1466, 21.6942, 58.2, 1, 28.1505, 21.28, 60.05, 1, 
                                                25.2358, 33.9758, 55.45, 1, 27.4189, 31.3713, 58.15, 1, 26.2979, 
                                                29.6381, 54.1, 1, 23.6512, 27.1263, 45.35, 1, 21.4586, 22.3744, 
                                                43.7, 1, 22.3307, 22.591, 43.95, 1, 21.3826, 22.7829, 43.75, 
                                                1, 18.9544, 26.2504, 43.65, 1, 23.1116, 22.1825, 44.65, 1, 24.0008, 
                                                20.1096, 46.2, 1, 23.6094, 22.6746, 45.25, 1, 23.6525, 18.499, 
                                                45.95, 1, 28.1229, 28.1495, 59.4, 1, 26.847, 26.638, 54.5, 1, 
                                                27.7713, 25.1764, 57.65, 1, 28.0222, 22.9017, 58, 1, 28.4943, 
                                                27.1662, 60.7, 1, 26.3929, 28.9389, 53.9, 1, 25.9274, 25.2016, 
                                                51.65, 1, 27.0332, 22.6062, 54.5, 1, 27.4816, 22.23, 55.85, 1, 
                                                25.0648, 26.6684, 49.15, 1, 24.2516, 20.3053, 46.6, 1, 25.0819, 
                                                18.0918, 48.45, 1, 24.1908, 22.3687, 46.1, 1, 25.6462, 23.8469, 
                                                50.65, 1, 25.0154, 22.3706, 48.5, 1, 26.0756, 19.4826, 51.1, 
                                                1, 17.6928, 24.7095, 44.4, 1, 16.7409, 24.9318, 45.95, 1, 15.2019, 
                                                28.4829, 51.4, 1, 15.0704, 27.84, 50.7, 1, 16.9062, 27.9642, 
                                                57.7, 1, 20.549, 23.097, 43.6, 1, 19.4427, 23.9153, 43.8, 1, 
                                                16.6174, 26.695, 44.1, 1, 18.0424, 30.8997, 46.2, 1, 20.5998, 
                                                33.972, 60.2, 1, 22.3668, 33.5768, 62.55, 1, 18.0101, 21.7132, 
                                                56.6, 1, 18.0861, 21.9792, 57.75, 1, 17.0164, 23.0204, 54.05, 
                                                1, 16.4065, 26.4936, 44.7, 1, 22.3744, 32.3228, 49.35, 1, 21.546, 
                                                32.604, 49.7, 1, 23.7728, 32.6116, 63.3, 1, 24.4644, 16.5148, 
                                                52.45, 1, 23.332, 16.4274, 55.5, 1, 23.3472, 16.5604, 50.2, 1, 
                                                22.0115, 29.7483, 63.35, 1, 23.4547, 17.6297, 47.55, 1, 26.0756, 
                                                16.9537, 55.9, 1, 24.3808, 17.062, 48, 1, 16.7599, 32.8491, 54.7, 
                                                1, 16.074, 32.0017, 54.3, 1, 16.2944, 31.787, 55.5, 1, 18.1117, 
                                                23.9163, 59.3, 1, 20.246, 19.5923, 59.95, 1, 22.9254, 19.893, 
                                                44.95, 1, 16.1804, 26.5202, 45.2, 1, 16.0816, 26.5886, 45.5, 
                                                1, 21.5517, 34.7738, 58.95, 1, 17.4382, 33.383, 53.2, 1, 17.0544, 
                                                33.0733, 54.6, 1, 27.3144, 28.4079, 56.65, 1, 22.8779, 18.6542, 
                                                61.15, 1, 16.8378, 23.1249, 53.1, 1, 26.1554, 17.898, 53.3, 1, 
                                                16.1462, 27.2251, 45.3, 1, 23.9451, 33.4487, 52.75, 1, 20.6948, 
                                                29.2486, 45.15, 1, 19.9956, 27.6906, 44.35, 1, 20.8658, 17.6852, 
                                                51.35, 1, 23.2629, 16.8451, 59.2, 1, 22.2547, 17.0848, 59.45, 
                                                1, 22.914, 32.6724, 63.1, 1, 15.0841, 27.3999, 49.15, 1, 24.5055, 
                                                17.7619, 60.95, 1, 24.6402, 17.1332, 59.1, 1, 25.4904, 17.2976, 
                                                58.7, 1, 25.7146, 17.0126, 57.3, 1, 28.5399, 27.056, 60.9, 1, 
                                                18.8613, 24.947, 60.55, 1, 24.5081, 32.3551, 63.05, 1, 16.682, 
                                                24.3884, 55.25, 1, 25.6025, 18.2704, 60.9, 1, 28.1577, 30.4592, 
                                                60.7, 1), .Dim = c(4L, 126L)), it = structure(c(1, 2, 3, 2, 3, 
                                                                                                31, 2, 15, 42, 2, 15, 101, 2, 17, 42, 2, 17, 101, 4, 5, 6, 5, 
                                                                                                6, 18, 5, 30, 60, 5, 30, 80, 5, 54, 60, 5, 54, 122, 5, 80, 96, 
                                                                                                5, 96, 122, 7, 10, 87, 7, 87, 120, 8, 9, 87, 8, 10, 22, 8, 10, 
                                                                                                87, 8, 21, 22, 9, 86, 87, 9, 86, 88, 10, 22, 29, 10, 29, 30, 
                                                                                                11, 12, 13, 11, 12, 14, 12, 13, 126, 12, 14, 121, 12, 15, 18, 
                                                                                                12, 15, 104, 12, 18, 122, 12, 104, 122, 12, 121, 126, 13, 123, 
                                                                                                126, 14, 20, 121, 15, 16, 77, 15, 16, 89, 15, 17, 19, 15, 17, 
                                                                                                77, 15, 17, 101, 15, 18, 19, 15, 18, 89, 15, 18, 122, 15, 19, 
                                                                                                122, 15, 42, 104, 17, 19, 72, 17, 42, 109, 17, 72, 95, 17, 77, 
                                                                                                101, 17, 93, 95, 17, 93, 103, 17, 95, 103, 17, 101, 103, 17, 
                                                                                                103, 109, 19, 72, 122, 21, 22, 106, 21, 106, 112, 22, 29, 79, 
                                                                                                22, 79, 81, 22, 81, 106, 23, 24, 25, 23, 24, 26, 23, 26, 112, 
                                                                                                24, 25, 27, 24, 26, 27, 25, 27, 28, 25, 28, 98, 25, 51, 98, 26, 
                                                                                                27, 112, 27, 28, 69, 27, 61, 106, 27, 61, 110, 27, 71, 106, 27, 
                                                                                                71, 116, 27, 106, 112, 27, 110, 116, 28, 68, 69, 28, 68, 74, 
                                                                                                29, 30, 79, 30, 60, 80, 30, 80, 96, 30, 96, 97, 31, 84, 102, 
                                                                                                31, 84, 109, 31, 101, 103, 31, 102, 103, 32, 33, 34, 32, 33, 
                                                                                                70, 32, 34, 116, 32, 70, 71, 33, 70, 94, 34, 35, 116, 34, 61, 
                                                                                                84, 34, 61, 110, 34, 70, 71, 34, 70, 84, 34, 71, 116, 34, 110, 
                                                                                                116, 35, 75, 111, 35, 76, 111, 35, 108, 116, 36, 37, 38, 36, 
                                                                                                38, 39, 36, 39, 120, 36, 91, 107, 36, 91, 120, 37, 59, 60, 37, 
                                                                                                59, 67, 37, 67, 107, 38, 39, 55, 38, 55, 60, 39, 55, 121, 39, 
                                                                                                119, 120, 39, 119, 125, 40, 41, 42, 40, 42, 109, 41, 42, 104, 
                                                                                                42, 57, 61, 42, 57, 84, 42, 57, 104, 42, 61, 83, 42, 83, 109, 
                                                                                                42, 84, 109, 43, 45, 46, 43, 45, 50, 43, 46, 111, 43, 61, 83, 
                                                                                                44, 45, 46, 44, 46, 73, 45, 48, 50, 46, 47, 73, 46, 47, 111, 
                                                                                                47, 68, 74, 47, 68, 75, 47, 73, 74, 47, 75, 111, 48, 49, 64, 
                                                                                                48, 49, 98, 48, 50, 64, 49, 51, 62, 49, 51, 98, 49, 62, 64, 51, 
                                                                                                62, 63, 52, 54, 56, 52, 54, 104, 53, 54, 59, 53, 54, 104, 53, 
                                                                                                57, 58, 53, 58, 59, 54, 55, 60, 54, 55, 121, 54, 56, 121, 54, 
                                                                                                59, 60, 54, 104, 122, 57, 58, 61, 57, 61, 84, 58, 59, 65, 58, 
                                                                                                59, 79, 58, 61, 65, 58, 61, 106, 58, 79, 81, 58, 81, 106, 59, 
                                                                                                60, 80, 59, 65, 67, 59, 79, 80, 61, 64, 66, 61, 65, 66, 62, 63, 
                                                                                                66, 62, 64, 66, 63, 66, 67, 63, 67, 107, 63, 86, 92, 63, 86, 
                                                                                                107, 65, 66, 67, 70, 71, 106, 70, 71, 124, 70, 72, 94, 70, 72, 
                                                                                                124, 70, 84, 102, 70, 94, 95, 70, 94, 102, 70, 106, 124, 72, 
                                                                                                94, 95, 72, 96, 122, 75, 82, 108, 76, 84, 102, 79, 80, 96, 79, 
                                                                                                80, 124, 79, 81, 124, 79, 96, 124, 82, 99, 108, 83, 84, 109, 
                                                                                                84, 102, 109, 86, 91, 107, 87, 91, 120, 94, 95, 102, 95, 102, 
                                                                                                103, 102, 103, 109, 34, 35, 76, 35, 75, 108, 99, 100, 108, 69, 
                                                                                                99, 100, 85, 89, 115, 19, 72, 96, 76, 83, 84, 5, 14, 20, 11, 
                                                                                                13, 85, 117, 118, 119, 20, 105, 117, 86, 87, 91, 93, 94, 95, 
                                                                                                93, 94, 102, 1, 77, 78, 1, 16, 78, 27, 69, 116, 13, 85, 123, 
                                                                                                1, 3, 126, 31, 40, 109, 8, 9, 112, 76, 83, 110, 33, 34, 102, 
                                                                                                34, 76, 102, 3, 41, 126, 23, 25, 90, 51, 63, 92, 43, 50, 64, 
                                                                                                17, 19, 95, 70, 72, 95, 1, 2, 101, 36, 37, 107, 28, 44, 73, 44, 
                                                                                                45, 98, 4, 5, 105, 1, 77, 101, 1, 16, 85, 7, 10, 114, 20, 39, 
                                                                                                125, 19, 96, 122, 9, 88, 112, 27, 106, 116, 32, 71, 116, 1, 123, 
                                                                                                126, 8, 21, 112, 28, 73, 74, 5, 14, 18, 6, 18, 122, 7, 118, 120, 
                                                                                                11, 18, 89, 11, 14, 18, 11, 85, 89, 25, 51, 90, 23, 88, 112, 
                                                                                                23, 88, 90, 51, 90, 92, 43, 83, 110, 43, 110, 111, 43, 61, 64, 
                                                                                                117, 119, 125, 7, 113, 118, 20, 117, 125, 33, 94, 102, 2, 31, 
                                                                                                101, 93, 102, 103, 1, 85, 123, 16, 85, 115, 4, 6, 97, 6, 96, 
                                                                                                97, 10, 30, 97, 4, 105, 114, 105, 114, 117, 7, 113, 114, 4, 97, 
                                                                                                114, 76, 110, 111, 80, 96, 124, 16, 89, 115, 56, 121, 126, 6, 
                                                                                                96, 122, 71, 106, 124, 81, 106, 124, 71, 106, 116, 69, 100, 116, 
                                                                                                100, 108, 116, 68, 75, 82, 68, 69, 82, 69, 82, 99, 30, 79, 80, 
                                                                                                18, 19, 122, 37, 38, 60, 20, 39, 121, 52, 56, 126, 53, 57, 104, 
                                                                                                72, 96, 124, 41, 52, 126, 41, 52, 104, 86, 88, 92, 88, 90, 92, 
                                                                                                118, 119, 120, 113, 117, 118, 19, 72, 95, 3, 40, 41, 3, 31, 40, 
                                                                                                28, 44, 98, 45, 48, 98, 5, 20, 105, 16, 77, 78, 113, 114, 117, 
                                                                                                10, 97, 114), .Dim = c(3L, 307L)), primitivetype = "triangle", 
                               material = NULL, normals = NULL, texcoords = NULL), .Names = c("vb", 
                                                                                              "it", "primitivetype", "material", "normals", "texcoords"), class = c("mesh3d", 

Wish: 95% Hausdorff distance in vcgMetro()

Again, thanks for developing Rvcg! While vcgMetro() provides relevant distance-based similarity metrics, I think that the 95% Hausdorff distance is currently not returned. As this metric is increasingly used, would it be possible to return it as well in the ForwardSampling and BackwardSampling components of vcgMetro()?

Thanks in advance for considering!

Geodesic distances

Thanks for making Rvcg! I wanted to ask whether you could consider adding geodesic distance computation.

A vcglib example from the official docs is here and here.

I tried to do it myself and submit a PR, but my knowledge on C++ template programming and Rcpp is very limited and I could not get it to work.

I asked you about this a while ago in an RvtkStatismo issue and got it to work, but the installation required quite some effort and I cannot make RvtkStatismo a dependency of my package that is on CRAN.

vcgGeodesicPath segfaulting on some systems

CRAN checks report segfaults running the example of vcgGeodesicPath on some systems.

Version: 0.20
Check: examples
Result: ERROR
Running examples in ‘Rvcg-Ex.R’ failed
The error most likely occurred in:

> ### Name: vcgGeodesicPath
> ### Title: Compute geodesic path and path length between vertices on a mesh
> ### Aliases: vcgGeodesicPath
>
> ### ** Examples
>
> data(humface)
> p = vcgGeodesicPath(humface,50,c(500,5000))

 *** caught segfault ***
address (nil), cause 'memory not mapped'

Traceback:
 1: vcgGeodesicPath(humface, 50, c(500, 5000))
An irrecoverable exception occurred. R is aborting now ...

Flavor: r-devel-linux-x86_64-fedora-clang

Rvcg::vcgCurve returns zeros

OS: Windows 10
R version 4.2.0

For an unknown reason, vcgCurve returns arrays of zeros regardless of the surface used as mesh

Here is a reproductible example:

library(Rvcg)
data(humface)
curv <- vcgCurve(humface)

summary(curv$meanitmax)
summary(curv$gaussitmax)
summary(curv$K1) #edit: works normally
summary(curv$k2) #edit: works normally

Uniform remesh quality

Hi, I'm wondering if you can help me understand an issue I am having with vcgUniformRemesh. I am trying to retopologise a mesh (~200k vertices) and am getting very different results depending on the software I use. When using the Instant Meshes app (https://github.com/wjakob/instant-meshes), I get a nice clean mesh, but when using vcgUniformRemesh I get some artefacts. I assume this is something to do with the different remeshing algorithms the two methods may be using, but do you know if there is a way to achieve smoother results with vcgUniformRemesh (vcgSmooth didn't have much effect).
Thanks,
Aaron.
Screen Shot 2020-04-30 at 17 38 31

Import mesh file

Hi there,
I want to use a package and this is its description:
Cube counting for 3D mesh
Usage
cubes(mesh, L0, cubes, plot = FALSE)
Arguments
mesh 3D mesh with vertices
L0 (Optional) The grain or resolution (i.e., smallest cube size)
cubes (Optional) A vector of number of cubes to be fitted at different scales.
plot Plot number of filled cubes at different scales
how can I import my 3D mesh file (stl format)?
I tried to use rgl package (readSTL(con = "E:/mesh", ascii = FALSE, plot = FALSE))
but I got following error: Error in file(con, if (ascii) "rt" else "rb") :
cannot open the connection In addition: Warning message: In file(con, if (ascii) "rt" else "rb") : cannot open file 'E:/mesh': Permission denied
Thanks!

vcgUpdateNormals integer check

You check if the arguments are integers by using

!prod(is.integer(pointcloud))

but that will be triggered by your own standard arguments, since R does not default to integer when giving a number without further context.
See:

> typeof(1)
[1] "double"
> typeof(1L)
[1] "integer"

So with values like c(30,1), the output will not change, and the function will always use c(10,0).

I would propose one of two ways to solve this:
1. Changing the default parameter to c(10L,0L) and state the requirement in the help file more explicit, plus a stop("Please state pointcloud parameters in explicit integers, i.e. c(10L,0L)") in the if TRUE statement.
2. Changing the check to a forced coercion via as.integer and warn the users in the help file about it.

Since RupdateNormals does not seem to throw an error, even though the standard submitted argument is of type double, the check may even not be necessary?

calculate mesh volume

Hello @zarquon42b, I was wondering if you might consider adding calculation of mesh volume some time. It looks fairly straightforward using vcg the code here as an example:

https://github.com/cnr-isti-vclab/vcglib/blob/a8e87662b63ee9f4ded5d4699b28d74183040803/apps/trimeshinfo/trimeshinfo.cpp#L815-L824

after checking for manifold status like so:

https://github.com/cnr-isti-vclab/vcglib/blob/a8e87662b63ee9f4ded5d4699b28d74183040803/apps/trimeshinfo/trimeshinfo.cpp#L786-L787

I know that Rvtkstatismo can do this, but it is still a bit of a beast to install – especially for end users. Thanks for considering!

Please tag the current master state

Not an issue, I just wanted to ask you a favor: could you please tag the current master state? E.g.:

cd <your_local_Rvcg_repo>
git checkout master
git log --oneline

To see the latest commit hash, should be ef2f78a0.

Then tag and push it:

git tag v0.19.3.rc1 ef2f78a0
git push --tags

Replace v0.19.3.rc1 with something you consider appropriate.

The background is that I would like to write installation instructions for the latest fsbrain version, which requires Rvcg from GitHub until a new version is published on CRAN. And this way, it looks a bit more professional than to make people install a version from a commit hash.

And are there any plans for a new CRAN release? I know its a pain, just asking.

Wish: Calculate centroid

First of all, many thanks for developing Rvcg! It proves extremely useful in radiation oncology where comparison of target structures as contoured by AI vs. experts is currently an important issue. Would it be possible to add a function to obtain the centroid of a mesh, similar to the vcgVolume() function? Example calculations based on other libraries are here:

https://github.com/CGAL/cgal/blob/40fdc6c6bc48eec140353fca3e930f578745f18b/Principal_component_analysis_LGPL/include/CGAL/centroid.h#L516

https://github.com/libigl/libigl/blob/574ab1a3a819b3798cf452fa44bcb47704a529c6/include/igl/centroid.cpp#L11

Thanks in advance for considering!

Angle of `vcgSphericalCap`

Hello,

I find strange the angle of vcgSphericalCap. For me, vcgSphericalCap(angleRad = pi/2) should produce a hemisphere, while I expect that the effective result corresponds to an angle of pi/4. This is in agreement with the so-called contact angle of the spherical cap.

`vcgUniformRemesh` freezes

Hello,

This is the parameterization of the Boy surface.

fx <- function(u,v){
  0.5*((2*(cos(u)*sin(v))^2-(sin(u)*sin(v))^2-(cos(v))^2)*((cos(u)*sin(v))^2+(sin(u)*sin(v))^2+(cos(v))^2)+2*(sin(u)*sin(v))*(cos(v))*((sin(u)*sin(v))^2-(cos(v))^2)+(cos(u)*sin(v))*(cos(v))*((cos(u)*sin(v))^2-(cos(v))^2)+(cos(u)*sin(v))*(sin(u)*sin(v))*((sin(u)*sin(v))^2-(cos(u)*sin(v))^2))
}
fy <- function(u,v){
  0.5*(sqrt(3)*(((sin(u)*sin(v))^2-(cos(v))^2)*((cos(u)*sin(v))^2+(sin(u)*sin(v))^2+(cos(v))^2)+(cos(v))*(cos(u)*sin(v))*((cos(v))^2-(cos(u)*sin(v))^2)+(cos(u)*sin(v))*(sin(u)*sin(v))*((sin(u)*sin(v))^2-(cos(u)*sin(v))^2)))
}
fz <- function(u,v){
  0.125*((cos(u)*sin(v))+(sin(u)*sin(v))+(cos(v)))*(((cos(u)*sin(v))+(sin(u)*sin(v))+(cos(v)))^3+4*((sin(u)*sin(v))-(cos(u)*sin(v)))*((cos(v))-(sin(u)*sin(v)))*((cos(u)*sin(v))-(cos(v))))
}

library(misc3d)
library(rgl)
tris <- parametric3d(fx, fy, fz,
             umin=0, umax=2*pi, vmin=0, vmax=2*pi, n=50, 
             engine = "none")

mesh00 <- misc3d:::t2ve(tris)
mesh0 <- tmesh3d(mesh00$vb, mesh00$ib)
mesh <- Rvcg::vcgUniformRemesh(mesh0)

At the last step, R is frozen.

Question: Find vertices adjacent to a given vertex?

Is there any fast way to find all vertices incident on a given vertex, or even for all vertices (that would be an adjacency list representation of the mesh?

I only found Rvcg::vcgVFadj which gives the adjacent faces of a vertex. I want the vertices.

If there is nothing, I would give it a try myself and do a PR.

Large volume & vcgIsosurface

Thresholding followed by mesh registration is really convenient to make quick segmentations but for large volumes, which happen quite often, it requires too much RAM.
Then, the idea, would be to :

  • split the volume into subvolumes (250 px cube for e.g.)
  • apply the marching cubes algorithm (vcgIsosurface) for each of them separately
  • merge meshes into a single one
  • merge closed vertices
  • clean everything

That's what I did but maybe there is a more suitable solution directly implemented in the vcg lib.

Rmetro SamplingFlags: silent vs. OCTREE

Thanks again for developing Rvcg!
I think I've found a bug in the SamplingFlags for Rmetro, defined here:

SILENT = 0x7000

SILENT is 0x7000 which is binary 111000000000. However, USE_OCTREE is 0x2000 which is binary 10000000000. Therefore, setting silent=TRUE in vcgMetro() also enables searchStruct="OCTREE".

Consider

vcg_m1 <- vcgPlyRead("/path/to/Obs01_AOKL.ply")
vcg_m2 <- vcgPlyRead("/path/to/Obs02_AOKL.ply")
metro1 <- vcgMetro(vcg_m1, vcg_m2, silent=FALSE) # searchStruct default: "SGRID"
metro2 <- vcgMetro(vcg_m1, vcg_m2, silent=TRUE)
metro3 <- vcgMetro(vcg_m1, vcg_m2, silent=FALSE, searchStruct="OCTREE")

metro1[["ForwardSampling"]][["maxdist"]]
## [1] 2.811558
metro2[["ForwardSampling"]][["maxdist"]]
## [1] 3.784452
metro3[["ForwardSampling"]][["maxdist"]]
## [1] 3.784452

Obs01_AOKL.txt
Obs02_AOKL.txt

This may not be noticeable for large meshes where both searchStruct settings lead to the same result.

Namespace resolve issue

Calling Rvcg::vcgBary(mesh) throws

Error in .Call("Rbarycenter", mesh) : 
  "Rbarycenter" not resolved from current namespace (Rvcg)

on MacOS 12.1 (M1 chip). Installing from the GitHub source instead of CRAN did not solve the issue. This issue is sometimes resolved after re-installing Rvcg, but only during that R session (reoccurs for a new R session).

Reproducible example:

library(rgl)
library(Rvcg)

B = matrix(c(
  0,  0,
  1, 0,
  0.5,  sqrt(3)/2),
  ncol=2, byrow=TRUE
)
b = rgl::tmesh3d(t(cbind(B, 0, 1)),
                 indices = 1:3)
b_subdivision = rgl::subdivision3d(b, depth=3, deform=FALSE, normalize=TRUE)
b_subdivision_center_coordinates = Rvcg::vcgBary(b_subdivision)

vcgCurve gives slightly different results than before

Hello,
After the last correction to vcgCurve (thank you again!) I would like to report a difference with the previous behavior of the function... though I honnestly don't know if it can be qualified as an issue:

  • before, when I used Rvcg to display the mean curvature of a groovy surface, it returned negative values
  • now, when I do the same, most of the groove is negative but some spots have positive values

Here is the reproducible example with mean curvature, look closely inside the grooves:


mesh <- doolkit::dkmodel$complex
curv <- Rvcg::vcgCurve(mesh)$meanitmax
curvsign <- sign(curv)
doolkit::dkmap(mesh, curvsign, col = c("white", "red"), col.levels = 3)

I tried with gauss curvature, and it looks even more confusing to me:


mesh <- doolkit::dkmodel$complex
curv <- Rvcg::vcgCurve(mesh)$gaussitmax
curvsign <- sign(curv)
doolkit::dkmap(mesh, curvsign, col = c("white", "red"), col.levels = 3)

OS: Windows 10
R: 4.2.0

Keep vcgSmooth quiet

vcgSmooth and some other functions produce cat-output that can only be surpressed by nasty capture.output gymnastics. By default, all functions should be quiet. An option verbose could be added to force chatty mode.

Not really an issue, probably more of a question...

Dear Dr. Schlager,

I am trying to implement the mesh pipeline as implemented by Peter Claes et al. in Meshmonk into R. For this, I am borrowing heavily on Rvcg, Morpho and mesheR. The aim is to apply elastic deformation of a template facial mask on patient's faces, but with some specific algorithmic requirements (weighted KNN, geometrically stable sampling, and 'double convolution', i.e. viscous and elastic deformation. The meshes were generated using a custom-built stereoprohotgrammetry setup: https://www.researchgate.net/project/THREE-DIMENSIONAL-FACIAL-CAPTURE-USING-A-CUSTOM-BUILT-PHOTOGRAMMETRY-SETUP-A-PRELIMINARY-REPORT-ON-DESIGN-PERFORMANCE-AND-COST

Now to my (simple) question: When running vcgKDtree to find say k = 30 neirest neighbours per point, it provides a list of the indices and corresponding distances. I assumed (never a good idea) the list would contain the k neirest points per sampled vertex sequentially, but this is not the case. Can you 'enlighten' this poor simpleton on how the indices are ordered in the list?

With kind regards,
Hans Wellens

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.