1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
11 cfMesh is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 3 of the License, or (at your
14 option) any later version.
16 cfMesh is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
28 A class for fitting a quadric surface through the set of points. It is
29 useful for curvature estimation and for calculating normals.
34 \*---------------------------------------------------------------------------*/
36 #ifndef quadricFitting_H
37 #define quadricFitting_H
41 #include "simpleMatrix.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 /*---------------------------------------------------------------------------*\
49 class quadricFitting Declaration
50 \*---------------------------------------------------------------------------*/
55 //- seed point for fitting the quadric surface
58 //- normal vector at the origin
61 //- x-coordinate vector for the transformed coordinate system
64 //- y-coordinate vector for the transformed coordinate system
68 DynList<point> otherPoints_;
70 //- transformed coordinates of other points
71 DynList<point> transformedPoints_;
73 //- coefficients of the quadric surface
74 scalarField coefficients_;
76 // Private member functions
77 //- initial estimate of the normal vector
78 void calculateNormalVector();
80 //- calculate transformed coordinate system
81 void calculateCoordinateSystem();
83 //- calculate coefficients of the quadric surface fit
84 void calculateQuadricCoeffs();
86 //- iterative procedure for updating normals
87 //- until the best fit is achieved
88 void calculateBestFit();
94 //- Construct from point, normal, and neighbouring points
95 template<class ListType>
96 inline quadricFitting(const point&, const vector, const ListType&);
98 //- Construct from point and other points
99 template<class ListType>
100 inline quadricFitting(const point&, const ListType&);
110 //- Return surface normal
111 inline const vector& normal() const;
113 //- Return min curvature
114 inline scalar minCurvature() const;
116 //- Return max curvature
117 inline scalar maxCurvature() const;
119 //- Return mean curvature
120 inline scalar meanCurvature() const;
122 //- Return Gaussian curvature
123 inline scalar gaussianCurvature() const;
125 //- Return min curvature vector
126 inline vector minCurvatureVector() const;
128 //- Return max curvature vector
129 inline vector maxCurvatureVector() const;
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 } // End namespace Foam
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 #include "quadricFittingI.H"
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 // ************************************************************************* //