Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / mesh / cfMesh / utilities / triSurfaceTools / triSurfaceCurvatureEstimator / triSurfaceCurvatureEstimator.C
blob450e803870aaa845000a7e2ac8c079b3fe272dd5
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | cfMesh: A library for mesh generation
4    \\    /   O peration     |
5     \\  /    A nd           | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6      \\/     M anipulation  | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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/>.
24 Description
26 \*---------------------------------------------------------------------------*/
28 #include "triSurfaceCurvatureEstimator.H"
29 #include "demandDrivenData.H"
31 //#define DEBUGMorph
33 # ifdef DEBUGMorph
34 #include <sstream>
35 # endif
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 namespace Foam
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 triSurfaceCurvatureEstimator::triSurfaceCurvatureEstimator
46     const triSurf& surface
49     surface_(surface),
50     edgePointCurvature_(),
51     patchPositions_(),
52     gaussianCurvature_(),
53     meanCurvature_(),
54     maxCurvature_(),
55     minCurvature_(),
56     maxCurvatureVector_(),
57     minCurvatureVector_()
59     calculateEdgeCurvature();
60     calculateSurfaceCurvatures();
61     //calculateGaussianCurvature();
62     //calculateMeanCurvature();
63     //calculateMinAndMaxCurvature();
66 triSurfaceCurvatureEstimator::~triSurfaceCurvatureEstimator()
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 scalar triSurfaceCurvatureEstimator::edgePointCurvature(const label pI) const
73     return edgePointCurvature_[pI];
76 scalar triSurfaceCurvatureEstimator::curvatureAtEdge(const label edgeI) const
78     const edge& edg = surface_.edges()[edgeI];
80     const scalar k1 = edgePointCurvature_[edg.start()];
81     const scalar k2 = edgePointCurvature_[edg.end()];
83     return (k1 + k2) / 2.0;
86 scalar triSurfaceCurvatureEstimator::gaussianCurvatureAtTriangle
88     const label triI
89 ) const
91     const labelledTri& tri = surface_[triI];
93     scalar curv(0.0);
94     for(label i=0;i<3;++i)
95         curv += gaussianCurvature_[tri[i]][patchPositions_(triI, i)];
96     curv /= 3.0;
98     return curv;
101 scalar triSurfaceCurvatureEstimator::meanCurvatureAtTriangle
103     const label triI
104 ) const
106     const labelledTri& tri = surface_[triI];
108     scalar curv(0.0);
109     for(label i=0;i<3;++i)
110         curv += meanCurvature_[tri[i]][patchPositions_(triI, i)];
111     curv /= 3.0;
113     return curv;
116 scalar triSurfaceCurvatureEstimator::maxCurvatureAtTriangle
118     const label triI
119 ) const
121     const labelledTri& tri = surface_[triI];
123     scalar curv(0.0);
124     for(label i=0;i<3;++i)
125         curv += maxCurvature_[tri[i]][patchPositions_(triI, i)];
126     curv /= 3.0;
128     return curv;
131 scalar triSurfaceCurvatureEstimator::minCurvatureAtTriangle
133     const label triI
134 ) const
136     const labelledTri& tri = surface_[triI];
138     scalar curv(0.0);
139     for(label i=0;i<3;++i)
140         curv += minCurvature_[tri[i]][patchPositions_(triI, i)];
141     curv /= 3.0;
143     return curv;
146 vector triSurfaceCurvatureEstimator::maxCurvatureVectorAtTriangle
148     const label triI
149 ) const
151     const labelledTri& tri = surface_[triI];
153     vector curv(vector::zero);
154     for(label i=0;i<3;++i)
155         curv += maxCurvatureVector_[tri[i]][patchPositions_(triI, i)];
156     curv /= 3.0;
158     return curv;
161 vector triSurfaceCurvatureEstimator::minCurvatureVectorAtTriangle
163     const label triI
164 ) const
166     const labelledTri& tri = surface_[triI];
168     vector curv(vector::zero);
169     for(label i=0;i<3;++i)
170         curv += minCurvatureVector_[tri[i]][patchPositions_(triI, i)];
171     curv /= 3.0;
173     return curv;
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 } // End namespace Foam
180 // ************************************************************************* //