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/>.
26 \*---------------------------------------------------------------------------*/
28 #include "triSurfaceDetectFeatureEdges.H"
29 #include "helperFunctions.H"
30 #include "demandDrivenData.H"
31 #include "labelPair.H"
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 void triSurfaceDetectFeatureEdges::detectFeatureEdgesAngleCriterion()
46 const scalar tol = Foam::cos(angleTolerance_*M_PI/180.0);
48 const vectorField& normals = surf_.facetNormals();
50 const VRWGraph& edgeFaces = surf_.edgeFacets();
53 # pragma omp parallel for schedule(dynamic, 40)
55 forAll(edgeFaces, edgeI)
57 const constRow eFaces = edgeFaces[edgeI];
59 if( edgeFaces.sizeOfRow(edgeI) != 2 )
61 featureEdges_[edgeI] |= 8;
66 (normals[eFaces[0]] & normals[eFaces[1]]) /
67 (mag(normals[eFaces[0]]) * mag(normals[eFaces[1]]) + VSMALL);
69 //- check the orientation of triangles at this edge
70 //- check the sign of the angle if the orientation is not consistent
71 const labelledTri& tri0 = surf_[edgeFaces(edgeI, 0)];
72 const labelledTri& tri1 = surf_[edgeFaces(edgeI, 1)];
73 DynList<labelPair> sharedIndices;
78 if( tri0[i] == tri1[j] )
79 sharedIndices.append(labelPair(i, j));
83 if( sharedIndices.size() == 2 )
85 const labelPair& pair0 = sharedIndices[0];
86 const labelPair& pair1 = sharedIndices[1];
87 if( ((pair0.first() + 1) % 3) == pair1.first() )
89 if( (pair0.second() + 1) % 3 == pair1.second() )
94 if( (pair1.second() + 1) % 3 == pair0.second() )
100 featureEdges_[edgeI] |= 1;
104 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 } // End namespace Foam
108 // ************************************************************************* //