Open3D (C++ API)  0.20.0
Loading...
Searching...
No Matches
Smoothing.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// Copyright (c) 2018-2026 www.open3d.org
5// SPDX-License-Identifier: MIT
6// ----------------------------------------------------------------------------
7
8#pragma once
9
10#include <tbb/blocked_range.h>
11#include <tbb/parallel_for.h>
12
13// cppcheck-suppress missingIncludeSystem
14#include <Eigen/Core>
15
16// cppcheck-suppress missingIncludeSystem
17#include <vector>
18
20
21namespace open3d {
22namespace geometry {
23namespace smoothing {
24
25// Shared explicit Laplacian update used by mesh and point-cloud smoothers.
26// For each index i: x_i' = x_i + factor * (sum_j w_ij x_j / sum_j w_ij - x_i).
27// Neighbors and weights are supplied by the caller; vertices with no neighbors
28// are unchanged.
29template <typename ForEachNeighborFunc, typename ComputeWeightFunc>
31 const std::vector<Eigen::Vector3d> &reference_positions,
32 const std::vector<Eigen::Vector3d> &previous_values,
33 std::vector<Eigen::Vector3d> &next_values,
34 double factor,
35 const ForEachNeighborFunc &for_each_neighbor,
36 const ComputeWeightFunc &compute_weight) {
37 const int n_values = static_cast<int>(previous_values.size());
38 next_values.resize(previous_values.size());
39
40 tbb::parallel_for(
41 tbb::blocked_range<int>(0, n_values,
43 [&](const tbb::blocked_range<int> &range) {
44 for (int index = range.begin(); index < range.end(); ++index) {
45 Eigen::Vector3d weighted_sum = Eigen::Vector3d::Zero();
46 double total_weight = 0.0;
47 for_each_neighbor(index, [&](int neighbor_index) {
48 const double weight = compute_weight(
49 index, neighbor_index, reference_positions);
50 total_weight += weight;
51 weighted_sum +=
52 weight * previous_values[neighbor_index];
53 });
54
55 if (total_weight > 0.0) {
56 next_values[index] =
57 previous_values[index] +
58 factor * (weighted_sum / total_weight -
59 previous_values[index]);
60 } else {
61 next_values[index] = previous_values[index];
62 }
63 }
64 });
65}
66
67} // namespace smoothing
68} // namespace geometry
69} // namespace open3d
Real weight
Definition SurfaceReconstructionPoisson.cpp:270
void ApplyIndexedLaplacianUpdate(const std::vector< Eigen::Vector3d > &reference_positions, const std::vector< Eigen::Vector3d > &previous_values, std::vector< Eigen::Vector3d > &next_values, double factor, const ForEachNeighborFunc &for_each_neighbor, const ComputeWeightFunc &compute_weight)
Definition Smoothing.h:30
std::size_t & DefaultGrainSizeTBB() noexcept
Definition Parallel.cpp:31
Definition PinholeCameraIntrinsic.cpp:16