ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
SaitoSquaredDistanceTransform.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Inspired from bil_edt.cxx (VXL) by Ricardo Fabbri (rfabbri), Brown University
11 // (rfabbri@lems.brown.edu)
12 
13 // Local
14 #include "Grid3D.h"
15 #include "MathTools.h"
16 
17 namespace cloudViewer {
18 class GenericProgressCallback;
19 class NormalizedProgress;
20 class GenericIndexedMesh;
21 class GenericCloud;
22 
26  public MathTools {
27 public:
30 
32 
35  inline bool initGrid(const Tuple3ui& gridSize) {
37  gridSize.x, gridSize.y, gridSize.z, 0,
38  0); // margin = 0 (we need continuous memory)
39  }
40 
42  inline bool initDT(GenericIndexedMesh* mesh,
43  PointCoordinateType cellLength,
44  const CCVector3& gridMinCorner,
45  GenericProgressCallback* progressCb = nullptr) {
46  return intersectWith(mesh, cellLength, gridMinCorner, 1, progressCb);
47  }
48 
50  inline bool initDT(GenericCloud* cloud,
51  PointCoordinateType cellLength,
52  const CCVector3& gridMinCorner,
53  GenericProgressCallback* progressCb = nullptr) {
54  return intersectWith(cloud, cellLength, gridMinCorner, 1, progressCb);
55  }
56 
58 
73  inline bool propagateDistance(
74  GenericProgressCallback* progressCb = nullptr) {
75  return SDT_3D(*this, progressCb);
76  }
77 
78 protected:
80  static bool EDT_1D(GridElement* slice, std::size_t r, std::size_t c);
82  static bool SDT_2D(Grid3D<GridElement>& image,
83  std::size_t sliceIndex,
84  const std::vector<GridElement>& sq);
86  static bool SDT_3D(Grid3D<GridElement>& image,
87  GenericProgressCallback* progressCb = nullptr);
88 };
89 
90 } // namespace cloudViewer
#define CV_CORE_LIB_API
Definition: CVCoreLibWin.h:15
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
std::shared_ptr< core::Tensor > image
Type y
Definition: CVGeom.h:137
Type x
Definition: CVGeom.h:137
Type z
Definition: CVGeom.h:137
A generic mesh with index-based vertex access.
Simple 3D grid structure.
Definition: Grid3D.h:32
bool init(unsigned di, unsigned dj, unsigned dk, unsigned margin, GridElement defaultCellValue=0)
Initializes the grid.
Definition: Grid3D.h:77
Empty class - for classification purpose only.
Definition: MathTools.h:15
bool initDT(GenericCloud *cloud, PointCoordinateType cellLength, const CCVector3 &gridMinCorner, GenericProgressCallback *progressCb=nullptr)
Initializes the distance transform with a cloud.
SaitoSquaredDistanceTransform()=default
Default constructor.
bool propagateDistance(GenericProgressCallback *progressCb=nullptr)
Computes the exact Squared Distance Transform on the whole grid.
bool initDT(GenericIndexedMesh *mesh, PointCoordinateType cellLength, const CCVector3 &gridMinCorner, GenericProgressCallback *progressCb=nullptr)
Initializes the distance transform with a mesh.
bool initGrid(const Tuple3ui &gridSize)
Initializes the grid.
Generic file read and write utility for python interface.