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 "triSurfacePatchManipulator.H"
29 #include "helperFunctions.H"
30 #include "demandDrivenData.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 void triSurfacePatchManipulator::allocateFeatureEdges()
45 const edgeLongList& edges = surf_.edges();
46 const VRWGraph& pEdges = surf_.pointEdges();
48 //- allocate featureEdges list
49 featureEdges_.setSize(edges.size());
50 featureEdges_ = direction(0);
52 const edgeLongList& featureEdges = surf_.featureEdges();
54 forAll(featureEdges, feI)
56 const edge& e = featureEdges[feI];
58 forAllRow(pEdges, e.start(), peI)
60 const label eI = pEdges(e.start(), peI);
63 featureEdges_[eI] |= 1;
68 void triSurfacePatchManipulator::createPatches()
71 facetInPatch_.setSize(surf_.size());
74 const VRWGraph& faceEdges = surf_.facetEdges();
75 const VRWGraph& edgeFaces = surf_.edgeFacets();
77 forAll(facetInPatch_, triI)
79 if( facetInPatch_[triI] != -1 )
84 facetInPatch_[triI] = nPatches_;
88 const label fLabel = front.removeLastElement();
90 const constRow fEdges = faceEdges[fLabel];
94 const label edgeI = fEdges[feI];
96 //- check if th edges is marked as a feature edge
97 if( featureEdges_[edgeI] )
100 const constRow eFaces = edgeFaces[edgeI];
102 //- stop at non-manifold edges
103 if( eFaces.size() != 2 )
106 label neiTri = eFaces[0];
107 if( neiTri == fLabel )
110 //- do not overwrite existing patch information
111 if( surf_[fLabel].region() != surf_[neiTri].region() )
113 if( facetInPatch_[neiTri] != -1 )
116 facetInPatch_[neiTri] = nPatches_;
117 front.append(neiTri);
124 Info << "Created " << nPatches_ << " surface patches" << endl;
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 } // End namespace Foam
131 // ************************************************************************* //