Replies: 2 comments 6 replies
-
|
You are making a copy. You need to take a reference like |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Here is the full code: Rcpp::XPtr<Alpha_shape_3> AS_cpp(Rcpp::NumericMatrix pts) {
// make list of points
const int npoints = pts.ncol();
std::list<Point3> points;
for(int i = 0; i < npoints; i++) {
const Rcpp::NumericVector pt_i = pts(Rcpp::_, i);
points.push_back(Point3(pt_i(0), pt_i(1), pt_i(2)));
}
// compute alpha shape
Alpha_shape_3 as(points.begin(), points.end());
// returns R pointer
Rcpp::XPtr<Alpha_shape_3> as_xptr(&as, false);
return as_xptr;
}
void optimalAlpha_cpp(Rcpp::XPtr<Alpha_shape_3> as_xptr, int nc) {
Alpha_shape_3& as = *(as_xptr.get());
Alpha_iterator opt = as.find_optimal_alpha(nc);
Rcpp::Rcout << *opt;
}If I apply |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have a poor knowledge in C/C++ and I don't know whether I'm doing something bad.
I have a R pointer (
Rcpp:Xptr) to anAlpha_shape_3. I can get the ordinary pointer to theAlpha_shape_3from it, but when I try to dereference it, the code does not compile : it throws an error "is private within this context".The following code compiles but it returns a wrong optimal alpha which makes no sense (a huge number):
Why I can't dereference the pointer?
Beta Was this translation helpful? Give feedback.
All reactions