14#include <lagrange/raycasting/api.h>
15#include <lagrange/scene/SimpleScene.h>
16#include <lagrange/utils/ProgressCallback.h>
17#include <lagrange/utils/function_ref.h>
18#include <lagrange/utils/value_ptr.h>
62template <
typename Scalar,
typename Index>
78 function_ref<bool(Index mesh_index, Index instance_index)> is_occluder = [](Index, Index) {
82 ~OccludedInstanceSampler();
83 OccludedInstanceSampler(OccludedInstanceSampler&&) noexcept;
84 OccludedInstanceSampler& operator=(OccludedInstanceSampler&&) noexcept;
87 void run_batch(uint64_t num_rays);
90 [[nodiscard]]
bool is_visible(Index mesh_index, Index instance_index) const;
95 [[nodiscard]]
double visibility_measure(Index mesh_index, Index instance_index) const;
98 [[nodiscard]] uint64_t num_rays_cast(Index mesh_index, Index instance_index) const;
101 [[nodiscard]] Index num_instances() const;
105 [[nodiscard]] Index num_retired() const;
109 [[nodiscard]] std::pair<Index, uint64_t> progress() const;
166template <
typename Scalar,
typename Index>
167LA_RAYCASTING_API std::vector<std::vector<double>> estimate_occluded_instance_measures(
169 const RemoveOccludedInstancesOptions& options,
171 function_ref<
bool(Index mesh_index, Index instance_index)> is_occluder =
172 [](Index, Index) {
return true; },
173 const std::atomic_bool* cancel =
nullptr);
191template <
typename Scalar,
typename Index>
192LA_RAYCASTING_API scene::SimpleScene<Scalar, Index, 3> remove_occluded_instances(
193 const scene::SimpleScene<Scalar, Index, 3>& scene,
194 const RemoveOccludedInstancesOptions& options,
195 ProgressCallback& progress,
196 function_ref<
bool(Index mesh_index, Index instance_index)> is_occluder =
197 [](Index, Index) {
return true; },
198 const std::atomic_bool* cancel =
nullptr);
205template <
typename Scalar,
typename Index>
206[[deprecated(
"Use estimate_occluded_instance_measures().")]]
208 const scene::SimpleScene<Scalar, Index, 3>& scene,
209 function_ref<
void(Index mesh_index, Index instance_index)> callback,
210 const OccludedInstanceEstimateOptions& options,
211 ProgressCallback& progress,
212 function_ref<
bool(Index mesh_index, Index instance_index)> is_occluder =
213 [](Index, Index) {
return true; },
214 const std::atomic_bool* cancel =
nullptr);
222template <
typename Scalar,
typename Index>
223[[deprecated(
"Use the remove_occluded_instances overload taking RemoveOccludedInstancesOptions.")]]
225 const scene::SimpleScene<Scalar, Index, 3>& scene,
226 const OccludedInstanceEstimateOptions& options,
227 ProgressCallback& progress,
228 function_ref<
bool(Index mesh_index, Index instance_index)> is_occluder =
229 [](Index, Index) {
return true; },
230 const std::atomic_bool* cancel =
nullptr);
A simple thread-safe progress callback.
Definition ProgressCallback.h:27
A lightweight non-owning reference to a callable.
Definition function_ref.h:45
OccludedInstanceSampler(const scene::SimpleScene< Scalar, Index, 3 > &scene, const OccludedInstanceSamplerOptions &options={}, function_ref< bool(Index mesh_index, Index instance_index)> is_occluder=[](Index, Index) { return true;})
Build the ray caster and per-instance precomputation.
Simple scene container for instanced meshes.
Definition SimpleScene.h:62
Smart pointer with value semantics.
Definition value_ptr.h:133
scene::SimpleScene< Scalar, Index, 3 > remove_occluded_instances(const scene::SimpleScene< Scalar, Index, 3 > &scene, const RemoveOccludedInstancesOptions &options, ProgressCallback &progress, function_ref< bool(Index mesh_index, Index instance_index)> is_occluder=[](Index, Index) { return true;}, const std::atomic_bool *cancel=nullptr)
Remove instances whose visibility measure is below options.sampler_options.threshold.
Definition remove_occluded_instances.cpp:454
void estimate_occluded_instances(const scene::SimpleScene< Scalar, Index, 3 > &scene, function_ref< void(Index mesh_index, Index instance_index)> callback, const OccludedInstanceEstimateOptions &options, ProgressCallback &progress, function_ref< bool(Index mesh_index, Index instance_index)> is_occluder=[](Index, Index) { return true;}, const std::atomic_bool *cancel=nullptr)
Definition remove_occluded_instances.cpp:483
Raycasting operations.
Definition compute_local_feature_size.h:20
Loop options for estimate_occluded_instances() and remove_occluded_instances().
Definition remove_occluded_instances.h:122
uint64_t num_rays
Total ray budget.
Definition remove_occluded_instances.h:125
bool until_converged
After the initial batch, stop when a batch confidently retires no new instances.
Definition remove_occluded_instances.h:132
uint64_t batch_size
Rays per batch. Cancellation, progress, and convergence are checked at batch boundaries.
Definition remove_occluded_instances.h:128
Options for OccludedInstanceSampler.
Definition remove_occluded_instances.h:35
double size_influence
Exponent on area / R in the measure above.
Definition remove_occluded_instances.h:42
double confidence
Per-instance confidence used by each batch-end early-keep test.
Definition remove_occluded_instances.h:47
double threshold
Keep-threshold for M = mean_visibility * (area / R)^size_influence, where mean_visibility is the cosi...
Definition remove_occluded_instances.h:38
Options for remove_occluded_instances() and estimate_occluded_instance_measures().
Definition remove_occluded_instances.h:139
OccludedInstanceEstimateOptions estimate_options
Estimate-loop options.
Definition remove_occluded_instances.h:144
OccludedInstanceSamplerOptions sampler_options
Sampler options (keep-threshold, size influence, confidence).
Definition remove_occluded_instances.h:141