Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Weighted Sample Elimination #8554

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

afabri
Copy link
Member

@afabri afabri commented Oct 17, 2024

Summary of Changes

For some other package we need a uniform sampling on a triangle mesh. There is a nice code for that in cyCodeBase.

See also the publication at http://www.cemyuksel.com/research/sampleelimination/.

To get started I only add an example that exposes the cy-API, so that we can use the console application right away.

Release Management

  • Affected package(s): PMP
  • Feature/Small Feature (if any):
  • Link to compiled documentation (obligatory for small feature) wrong link name to be changed
  • License and copyright ownership: GeometryFactory for the wrapper to come. cyCodeBase has a MIT license.

@afabri afabri added this to the 6.1-beta milestone Nov 5, 2024
renamed weight_functor to weight_function
changed some default values of named parameters
@soesau soesau force-pushed the PMP-PoissonDiskSampling-GF branch from 530a4ee to 679146f Compare February 12, 2025 09:37
continue;

const Point p2 = get(ipm, res[n]);
double d2 = CGAL::to_double((p - p2).squared_length());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an approximate_something() ?? @sloriot

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CGAL::approximate_sqrt

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more wondering if we have an approximate_squared_distance(p,q)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am now using Kernel::compute_squared_distance_(2/3)_object or squared_distance_d_object depending on the Ambient_dimension of the Kernel.

@soesau
Copy link
Member

soesau commented Feb 14, 2025

/build:v0

Copy link

The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/8554/v0/Manual/index.html

The Poisson sample elimination is a greedy downsampling method that calculates a weight for each input point based on the density of its local neighborhood. Subsequently, the point with the highest weight is removed and the weights of the remaining points around it are updated until the target size is reached. A custom function to calculate the weight of a point can be provided.

The Poisson sample elimination has the following parameters:
- *dimensions*: The dimensions parameter specifies the dimension of the sampling domain of the point cloud, e.g., 2 if the point cloud is sampled from a surface, while the ambient dimension is typically 3. The default value is 2.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- *dimensions*: The dimensions parameter specifies the dimension of the sampling domain of the point cloud, e.g., 2 if the point cloud is sampled from a surface, while the ambient dimension is typically 3. The default value is 2.
- *dimension*: The dimension of the sampling domain of the point cloud, e.g., 2 if the point cloud is sampled from a surface, while the ambient dimension is typically 3. The default value is 2.


The Poisson sample elimination has the following parameters:
- *dimensions*: The dimensions parameter specifies the dimension of the sampling domain of the point cloud, e.g., 2 if the point cloud is sampled from a surface, while the ambient dimension is typically 3. The default value is 2.
- *weight_function*: A custom *weight_function* can be provided to calculate the weight between two points. The type of the functor is as follows:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- *weight_function*: A custom *weight_function* can be provided to calculate the weight between two points. The type of the functor is as follows:
- *weight_function*: A custom function can be provided to calculate the weight between two points. The type of the functor is as follows:

double(*func)(const Point &p, const Point &n, double squared_distance, double r_max)
\endcode
The default weight is \f$\left(1 - \frac{d_{p,n}}{2r_{max}}\right)^8\f$ with \f$d_{p,n}\f$ being the distance between the point p and its neighbor n.
- \f$r_{max}\f$: The \f$r_{max}\f$ parameter specifies the radius of the neighborhood, i.e., the neighboring points that are used to calculate the weight of a point. r_max has to be provided if a custom *weight_function* is used. Only points within a distance of \f$r_{max}\f$ are used to calculate the weight of a point. A large value can thus cause a large running time. The default is calculated based in the bounding volume \f$V\f$ of the input points, the *dimensions* parameter and the number of input points \f$N\f$:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- \f$r_{max}\f$: The \f$r_{max}\f$ parameter specifies the radius of the neighborhood, i.e., the neighboring points that are used to calculate the weight of a point. r_max has to be provided if a custom *weight_function* is used. Only points within a distance of \f$r_{max}\f$ are used to calculate the weight of a point. A large value can thus cause a large running time. The default is calculated based in the bounding volume \f$V\f$ of the input points, the *dimensions* parameter and the number of input points \f$N\f$:
- \f$r_{max}\f$: The \f$r_{max}\f$ parameter specifies the radius of the neighborhood, i.e., the neighboring points that are used to calculate the weight of a point. \f$r_{max}\f$ has to be provided if a custom *weight_function* is used. Only points within a distance of \f$r_{max}\f$ are used to calculate the weight of a point. A large value can thus cause a large running time. The default is calculated based in the bounding volume \f$V\f$ of the input points, the *dimensions* parameter and the number of input points \f$N\f$:


/**
\ingroup PkgPointSetProcessing3Algorithms
Performs poisson disk elimination with a desired output size. A greedy method that calculates a weight based on the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Performs poisson disk elimination with a desired output size. A greedy method that calculates a weight based on the
performs poisson disk elimination with a desired output size. A greedy method that calculates a weight based on the

\cgalNamedParamsEnd
*/
template<class PointRange, class OutputIterator, class NamedParameters = parameters::Default_named_parameters>
void poisson_eliminate(PointRange &points, std::size_t number_of_points, OutputIterator output, const NamedParameters& np = parameters::default_values()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if eliminate is the right word since output points are copied. Also, why is PointRange not const? is it reordered?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants