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 "triSurfaceExtrude2DEdges.H"
29 #include "triSurfModifier.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 triSurfaceExtrude2DEdges::triSurfaceExtrude2DEdges(const triSurf& surface)
44 triSurfaceExtrude2DEdges::~triSurfaceExtrude2DEdges()
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 void triSurfaceExtrude2DEdges::extrudeSurface(triSurf& newSurf) const
51 triSurfModifier sMod(newSurf);
54 geometricSurfacePatchList& patches = sMod.patchesAccess();
57 patches[0].name() = "patch0";
58 patches[0].geometricType() = "patch";
60 //- check if the edges are in the x-y plane
61 const pointField& sPoints = surf_.points();
62 const boundBox bb(sPoints);
64 if( Foam::mag(bb.max().z() - bb.min().z()) > SMALL )
67 "void triSurfaceExtrude2DEdges::extrudeSurface(triSurf&) const"
68 ) << "Cannot extrude edges which are not in the x-y plane!"
72 pointField& pts = sMod.pointsAccess();
73 pts.setSize(2 * sPoints.size());
75 const label nOffset = sPoints.size();
76 const scalar zOffset = 0.1 * bb.mag();
80 pts[pI] = pts[pI+nOffset] = sPoints[pI];
81 pts[pI+sPoints.size()].z() += zOffset;
84 //- create triangles from feature edges
85 LongList<labelledTri>& triangles = sMod.facetsAccess();
86 const edgeLongList& edges = surf_.featureEdges();
88 triangles.setSize(2 * edges.size());
91 const edge& e = edges[eI];
92 const label tI = 2 * eI;
93 triangles[tI] = labelledTri(e[0], e[1], e[1]+nOffset, 0);
94 triangles[tI + 1] = labelledTri(e[0], e[1]+nOffset, e[0]+nOffset, 0);
98 const triSurf* triSurfaceExtrude2DEdges::extrudeSurface() const
100 triSurf* sPtr = new triSurf();
102 extrudeSurface(*sPtr);
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 } // End namespace Foam
111 // ************************************************************************* //