vtkCurvatures.h 5.19 KB
 John Biddiscombe committed Oct 30, 2002 1 2 3 4 5 /*========================================================================= Program: Visualization Toolkit Module: vtkCurvatures.h  Brad King committed Jan 08, 2004 6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen  John Biddiscombe committed Oct 30, 2002 7 8 9 10 11 12 13 14  All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/  David E. DeMarle committed Sep 23, 2016 15 16 17 18 19 20 21 22 23 /** * @class vtkCurvatures * @brief compute curvatures (Gauss and mean) of a Polydata object * * vtkCurvatures takes a polydata input and computes the curvature of the * mesh at each point. Four possible methods of computation are available : * * Gauss Curvature * discrete Gauss curvature (K) computation,  Guillaume Jacquenot committed Jan 09, 2018 24 25 26  * \f$K(\text{vertex v}) = 2*\pi - \sum_{\text{facet neighbs f of v}} (\text{angle_f at v})\f$. * The contribution of every facet is for the moment weighted by \f$Area(facet)/3\f$. * The units of Gaussian Curvature are \f$[1/m^2]\f$.  David E. DeMarle committed Sep 23, 2016 27 28  * * Mean Curvature  Guillaume Jacquenot committed Jan 09, 2018 29 30 31  * \f$H(vertex v) = \text{average over edges neighbs e of H(e)}\f$, * \f$H(edge e) = length(e) * dihedral\_angle(e)\f$. *  David E. DeMarle committed Sep 23, 2016 32 33  * NB: dihedral_angle is the ORIENTED angle between -PI and PI, * this means that the surface is assumed to be orientable  Guillaume Jacquenot committed Jan 09, 2018 34 35  * the computation creates the orientation. * The units of Mean Curvature are [1/m].  David E. DeMarle committed Sep 23, 2016 36  *  Guillaume Jacquenot committed Jan 09, 2018 37 38 39 40 41 42 43 44  * Maximum (\f$k_\max\f$) and Minimum (\f$k_\min\f$) Principal Curvatures * \f$k_\max = H + \sqrt{H^2 - K}\f$, * \f$k_\min = H - \sqrt{H^2 - K}\f$ * Excepting spherical and planar surfaces which have equal principal * curvatures, the curvature at a point on a surface varies with the direction * one "sets off" from the point. For all directions, the curvature will pass * through two extrema: a minimum (\f$k_\min\f$) and a maximum (\f$k_\max\f$) * which occur at mutually orthogonal directions to each other.  David E. DeMarle committed Sep 23, 2016 45  *  Guillaume Jacquenot committed Jan 09, 2018 46 47 48 49  * NB. The sign of the Gauss curvature is a geometric invariant, it should be * positive when the surface looks like a sphere, negative when it looks like a * saddle, however the sign of the Mean curvature is not, it depends on the * convention for normals. This code assumes that normals point outwards (i.e.  David E. DeMarle committed Sep 23, 2016 50 51 52 53 54 55 56 57 58 59 60 61 62  * from the surface of a sphere outwards). If a given mesh produces curvatures * of opposite senses then the flag InvertMeanCurvature can be set and the * Curvature reported by the Mean calculation will be inverted. * * @par Thanks: * Philip Batchelor philipp.batchelor@kcl.ac.uk for creating and contributing * the class and Andrew Maclean a.maclean@acfr.usyd.edu.au for cleanups and * fixes. Thanks also to Goodwin Lawlor for contributing patch to calculate * principal curvatures * * * */  John Biddiscombe committed Oct 30, 2002 63   Sean McBride committed Dec 18, 2014 64 65 #ifndef vtkCurvatures_h #define vtkCurvatures_h  John Biddiscombe committed Oct 30, 2002 66   VTK Developers committed Apr 09, 2012 67 #include "vtkFiltersGeneralModule.h" // For export macro  Amy Squillacote committed Nov 24, 2004 68 #include "vtkPolyDataAlgorithm.h"  John Biddiscombe committed Oct 30, 2002 69 70 71  #define VTK_CURVATURE_GAUSS 0 #define VTK_CURVATURE_MEAN 1  Mathieu Malaterre committed Jul 14, 2004 72 73 #define VTK_CURVATURE_MAXIMUM 2 #define VTK_CURVATURE_MINIMUM 3  John Biddiscombe committed Oct 30, 2002 74   VTK Developers committed Apr 09, 2012 75 class VTKFILTERSGENERAL_EXPORT vtkCurvatures : public vtkPolyDataAlgorithm  John Biddiscombe committed Oct 30, 2002 76 77 { public:  Mark Olesen committed Apr 23, 2010 78  vtkTypeMacro(vtkCurvatures,vtkPolyDataAlgorithm);  Kitware Robot committed Oct 02, 2017 79  void PrintSelf(ostream& os, vtkIndent indent) override;  John Biddiscombe committed Oct 30, 2002 80   David E. DeMarle committed Sep 23, 2016 81 82 83  /** * Construct with curvature type set to Gauss */  John Biddiscombe committed Oct 30, 2002 84 85  static vtkCurvatures *New();  David E. DeMarle committed Sep 23, 2016 86 87 88 89 90 91 92 93  //@{ /** * Set/Get Curvature type * VTK_CURVATURE_GAUSS: Gaussian curvature, stored as * DataArray "Gauss_Curvature" * VTK_CURVATURE_MEAN : Mean curvature, stored as * DataArray "Mean_Curvature" */  John Biddiscombe committed Oct 30, 2002 94 95 96 97 98 99  vtkSetMacro(CurvatureType,int); vtkGetMacro(CurvatureType,int); void SetCurvatureTypeToGaussian() { this->SetCurvatureType(VTK_CURVATURE_GAUSS); } void SetCurvatureTypeToMean() { this->SetCurvatureType(VTK_CURVATURE_MEAN); }  Mathieu Malaterre committed Jul 14, 2004 100 101 102 103  void SetCurvatureTypeToMaximum() { this->SetCurvatureType(VTK_CURVATURE_MAXIMUM); } void SetCurvatureTypeToMinimum() { this->SetCurvatureType(VTK_CURVATURE_MINIMUM); }  David E. DeMarle committed Sep 23, 2016 104  //@}  John Biddiscombe committed Oct 30, 2002 105   David E. DeMarle committed Sep 23, 2016 106 107 108 109 110  //@{ /** * Set/Get the flag which inverts the mean curvature calculation for * meshes with inward pointing normals (default false) */  Sean McBride committed Dec 01, 2017 111 112 113  vtkSetMacro(InvertMeanCurvature,vtkTypeBool); vtkGetMacro(InvertMeanCurvature,vtkTypeBool); vtkBooleanMacro(InvertMeanCurvature,vtkTypeBool);  David Gobbi committed Sep 26, 2016 114 115  //@}  John Biddiscombe committed Oct 30, 2002 116 117 118 119 protected: vtkCurvatures(); // Usual data generation method  Kitware Robot committed Oct 02, 2017 120  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;  John Biddiscombe committed Oct 30, 2002 121   David E. DeMarle committed Sep 23, 2016 122 123 124 125  /** * discrete Gauss curvature (K) computation, * cf http://www-ipg.umds.ac.uk/p.batchelor/curvatures/curvatures.html */  Amy Squillacote committed Nov 24, 2004 126  void GetGaussCurvature(vtkPolyData *output);  John Biddiscombe committed Oct 30, 2002 127 128 129  // discrete Mean curvature (H) computation, // cf http://www-ipg.umds.ac.uk/p.batchelor/curvatures/curvatures.html  Amy Squillacote committed Nov 24, 2004 130  void GetMeanCurvature(vtkPolyData *output);  VTK Developers committed Apr 09, 2012 131   David E. DeMarle committed Sep 23, 2016 132 133 134  /** * Maximum principal curvature \f$k_max = H + sqrt(H^2 -K)\f$ */  Amy Squillacote committed Nov 24, 2004 135  void GetMaximumCurvature(vtkPolyData *input, vtkPolyData *output);  VTK Developers committed Apr 09, 2012 136   David E. DeMarle committed Sep 23, 2016 137 138 139  /** * Minimum principal curvature \f$k_min = H - sqrt(H^2 -K)\f$ */  Amy Squillacote committed Nov 24, 2004 140  void GetMinimumCurvature(vtkPolyData *input, vtkPolyData *output);  VTK Developers committed Apr 09, 2012 141   John Biddiscombe committed Oct 30, 2002 142 143 144  // Vars int CurvatureType;  Sean McBride committed Dec 01, 2017 145  vtkTypeBool InvertMeanCurvature;  John Biddiscombe committed Oct 30, 2002 146 147  private:  Kitware Robot committed Oct 04, 2017 148 149  vtkCurvatures(const vtkCurvatures&) = delete; void operator=(const vtkCurvatures&) = delete;  John Biddiscombe committed Oct 30, 2002 150 151 152 153 154 155  }; #endif