You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I modified the sample code region_growing_planes_on_point_set_3.cpp and used an array to assign the instance input_range instead of reading the point cloud directly from the file. When I ran the code, an message "-wrongvalue:-nan" appeared, as well as an incorrect result. I located the specific location of the error, which was generated when region_growing.detect(std::back_inserter(result.regions)) was executed. Is it because the point cloud instance input_range is not initialized correctly? Please help me determine the source of the problem.
Describe your issue. Please be specific (compilation error, runtime error, unexpected behavior, wrong results, etc.).
Source Code
RegionGrowingResult pcRegionGrowing(
const pybind11::array_t<double>& points_np,
double pc_distance_to_plane,
double pc_accepted_angle,
std::size_t pc_minimum_region_size = 1,
std::size_t knn = 10
)
{
// Default parameter.const std::size_t k = knn;
const FT max_distance_to_plane = FT(pc_distance_to_plane);
const FT max_accepted_angle = FT(pc_accepted_angle);
const std::size_t min_region_size = pc_minimum_region_size;
CGAL::Timer timer;
timer.start();
// Get the pointer to the dataauto points_buf = points_np.request();
auto points_ptr = static_cast<double*>(points_buf.ptr);
if (points_buf.ndim != 2 || points_buf.shape[1] != 3) {
throwstd::runtime_error("Input points array must be of shape (n, 3)");
}
constbool with_normal_map = true;
Input_range input_range(with_normal_map);
// Create the input point set from the numpy arrayfor (ssize_t i = 0; i < points_buf.shape[0]; ++i) {
input_range.insert(Point_3(points_ptr[i * 3], points_ptr[i * 3 + 1], points_ptr[i * 3 + 2]));
}
std::cout << "* Point clouds with " << input_range.number_of_points() << " vertices is loaded" << std::endl;
// auto points = points_np.unchecked<2>();// for (ssize_t i = 0; i < points.shape(0); ++i) {// input_range.insert(Point_3(points(i, 0), points(i, 1), points(i, 2)));// }
RegionGrowingResult result(input_range.number_of_points());
// Create instances of the classes Neighbor_query and Region_type.
Neighbor_query_pc neighbor_query(
input_range,
k,
input_range.point_map());
Region_type_pc region_type(
input_range,
max_distance_to_plane, max_accepted_angle, min_region_size,
input_range.point_map(), input_range.normal_map());
// Create an instance of the region growing class.
Region_growing_pc region_growing(input_range, neighbor_query, region_type);
std::cout << "* " << " regions have been found in " << input_range.size() << std::endl;
// Run the algorithm.
region_growing.detect(std::back_inserter(result.regions));
timer.stop();
// Print the number of found regions.
std::cout << "* " << result.regions.size() <<
" regions have been found in " << timer.time() << " seconds"
<< std::endl;
// Get all unassigned items.
Region unassigned_items;
region_growing.unassigned_items(std::back_inserter(unassigned_items));
// Print the number of unassigned items.
std::cout << "* " << unassigned_items.size() <<
" points do not belong to any region"
<< std::endl;
for (std::size_t rg_ind = 0; rg_ind < result.regions.size(); ++rg_ind) {
for (constauto& index : result.regions[rg_ind]) {
if (index < result.incomponent.size()) {
result.incomponent[index] = static_cast<int32_t>(rg_ind);
} else {
std::cerr << "Warning: Face index " << index << " out of range." << std::endl;
}
}
}
return result;
}
Environment
Operating system (Windows/Mac/Linux, 32/64 bits): Ubuntu 18.04 64
Compiler: gcc 7.5.0
Release or debug mode: Release
Specific flags used (if any):
CGAL version: v5.5
Boost version: 1.78.0
Other libraries versions if used (Eigen, TBB, etc.):
The text was updated successfully, but these errors were encountered:
The error message "-wrongvalue:-nan" is not created from CGAL, do you know where it may come from?
Please provide a self contained example for us to reproduce the error.
Issue Details
I modified the sample code
region_growing_planes_on_point_set_3.cpp
and used an array to assign the instanceinput_range
instead of reading the point cloud directly from the file. When I ran the code, an message "-wrongvalue:-nan" appeared, as well as an incorrect result. I located the specific location of the error, which was generated whenregion_growing.detect(std::back_inserter(result.regions))
was executed. Is it because the point cloud instance input_range is not initialized correctly? Please help me determine the source of the problem.Describe your issue. Please be specific (compilation error, runtime error, unexpected behavior, wrong results, etc.).
Source Code
Environment
The text was updated successfully, but these errors were encountered: