]> Creatis software - creaVtk.git/blob - lib/creaVtk/vtkHausdorffDistancePointSetFilter.h
ddff5cfebbec432599821aa499c69ddf0113457d
[creaVtk.git] / lib / creaVtk / vtkHausdorffDistancePointSetFilter.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    vtkHausdorffDistancePointSetFilter.h
5
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13
14 =========================================================================*/
15 // Copyright (c) 2011 LTSI INSERM U642
16 // All rights reserved.
17 //
18 // Redistribution and use in source and binary forms, with or without modification,
19 // are permitted provided that the following conditions are met:
20 //
21 //     * Redistributions of source code must retain the above copyright notice,
22 // this list of conditions and the following disclaimer.
23 //     * Redistributions in binary form must reproduce the above copyright notice,
24 // this list of conditions and the following disclaimer in the documentation and/or
25 // other materials provided with the distribution.
26 //     * Neither name of LTSI, INSERM nor the names
27 // of any contributors may be used to endorse or promote products derived from this
28 // software without specific prior written permission.
29 //
30 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
31 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33 // DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
34 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
37 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
41 /** @class vtkHausdorffDistancePointSetFilter
42  *  @brief Compute Hausdorff distance between two point sets
43  *
44  * This class computes the relative and hausdorff distances from two point
45  * sets (input port 0 and input port 1). If no topology is specified (ie.
46  * vtkPointSet or vtkPolyData without vtkPolys), the distances are
47  * computed between point location. If polys exist (ie triangulation),
48  * the TargetDistanceMethod allows for an interpolation of the cells to
49  * ensure a better minimal distance exploration.
50  *
51  * The outputs (port 0 and 1) have the same geometry and topology as its
52  * respective input port. Two FieldData arrays are added : HausdorffDistance
53  * and RelativeDistance. The former is equal on both outputs whereas the
54  * latter may differ. A PointData containing the specific point minimal
55  * distance is also added to both outputs.
56  *
57  * @author Frederic Commandeur
58  * @author Jerome Velut
59  * @author LTSI
60  *
61  * @see https://www.vtkjournal.org/browse/publication/839
62  */
63
64 #ifndef vtkHausdorffDistancePointSetFilter_h
65 #define vtkHausdorffDistancePointSetFilter_h
66
67 #include "vtkFiltersModelingModule.h" // For export macro
68 #include "vtkPointSetAlgorithm.h"
69
70 class VTKFILTERSMODELING_EXPORT vtkHausdorffDistancePointSetFilter : public vtkPointSetAlgorithm
71 {
72 public:
73   ///@{
74   /**
75    * Standard methods for construction, type and printing.
76    */
77   static vtkHausdorffDistancePointSetFilter* New();
78   vtkTypeMacro(vtkHausdorffDistancePointSetFilter, vtkPointSetAlgorithm);
79   void PrintSelf(ostream& os, vtkIndent indent) override;
80   ///@}
81
82   ///@{
83   /**
84    * Get the Relative Distance from A to B and B to A.
85    */
86   vtkGetVector2Macro(RelativeDistance, double);
87   ///@}
88
89   ///@{
90   /**
91    * Get the Hausdorff Distance.
92    */
93   vtkGetMacro(HausdorffDistance, double);
94   ///@}
95
96   enum DistanceMethod
97   {
98     POINT_TO_POINT,
99     POINT_TO_CELL
100   };
101
102   ///@{
103   /**
104    * Specify the strategy for computing the distance. If no topology is specified (ie.
105    * vtkPointSet or vtkPolyData without vtkPolys), the distances are
106    * computed between point location. If polys exist (i.e. triangulation),
107    * the TargetDistanceMethod allows for an interpolation of the cells to
108    * ensure a better minimal distance exploration.
109    *
110    */
111   vtkSetMacro(TargetDistanceMethod, int);
112   vtkGetMacro(TargetDistanceMethod, int);
113   void SetTargetDistanceMethodToPointToPoint() { this->SetTargetDistanceMethod(POINT_TO_POINT); }
114   void SetTargetDistanceMethodToPointToCell() { this->SetTargetDistanceMethod(POINT_TO_CELL); }
115   const char* GetTargetDistanceMethodAsString();
116   ///@}
117
118 protected:
119   vtkHausdorffDistancePointSetFilter();
120   ~vtkHausdorffDistancePointSetFilter() override;
121
122   int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
123   int FillInputPortInformation(int port, vtkInformation* info) override;
124
125   int TargetDistanceMethod;   //!< point-to-point if 0, point-to-cell if 1
126   double RelativeDistance[2]; //!< relative distance between inputs
127   double HausdorffDistance;   //!< hausdorff distance (max(relative distance))
128
129 private:
130   vtkHausdorffDistancePointSetFilter(const vtkHausdorffDistancePointSetFilter&) = delete;
131   void operator=(const vtkHausdorffDistancePointSetFilter&) = delete;
132 };
133 inline const char* vtkHausdorffDistancePointSetFilter::GetTargetDistanceMethodAsString()
134 {
135   if (this->TargetDistanceMethod == POINT_TO_POINT)
136   {
137     return "PointToPoint";
138   }
139   else
140   {
141     return "PointToCell";
142   }
143 }
144 #endif
145