1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 Finds feature edges and corners of a triangulated surface
27 \*---------------------------------------------------------------------------*/
32 #include "triSurfModifier.H"
38 #include "triSurfaceDetectFeatureEdges.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 int main(int argc, char *argv[])
46 argList::noParallel();
47 argList::validArgs.clear();
48 argList::validArgs.append("input surface file");
49 argList::validArgs.append("output surface file");
50 argList::validArgs.append("x-neg");
51 argList::validArgs.append("x-pos");
52 argList::validArgs.append("y-neg");
53 argList::validArgs.append("y-pos");
54 argList::validArgs.append("z-neg");
55 argList::validArgs.append("z-pos");
57 argList args(argc, argv);
59 fileName inFileName(args.args()[1]);
60 fileName outFileName(args.args()[2]);
62 if (outFileName == inFileName)
64 FatalErrorIn(args.executable())
65 << "Output file " << outFileName
66 << " would overwrite the input file."
70 triSurf origSurface(inFileName);
71 triSurfModifier sMod(origSurface);
72 pointField& points = sMod.pointsAccess();
74 const boundBox bb(points);
76 vector negOffset, posOffset;
77 for(label i=3;i<9;++i)
87 negOffset[(i-3)/2] = s;
91 posOffset[(i-3)/2] = s;
95 Info << "Neg offset " << negOffset << endl;
96 Info << "Pos offset " << posOffset << endl;
98 const boundBox newBB(bb.min()-negOffset, bb.max()+posOffset);
99 Info << "Surface bounding box " << bb << endl;
100 Info << "Generated bounding box " << newBB << endl;
102 //- generate bounding box points
103 const label nPoints = points.size();
104 points.setSize(nPoints + 8);
106 points[nPoints] = newBB.min();
108 point(newBB.max().x(), newBB.min().y(), newBB.min().z());
110 point(newBB.min().x(), newBB.max().y(), newBB.min().z());
112 point(newBB.max().x(), newBB.max().y(), newBB.min().z());
114 point(newBB.min().x(), newBB.min().y(), newBB.max().z());
116 point(newBB.max().x(), newBB.min().y(), newBB.max().z());
118 point(newBB.min().x(), newBB.max().y(), newBB.max().z());
119 points[nPoints+7] = newBB.max();
121 //- generate bounding bound triangles
122 const label nTriangles = origSurface.size();
123 LongList<labelledTri>& newTriangles = sMod.facetsAccess();
124 newTriangles.setSize(nTriangles + 12);
127 geometricSurfacePatchList& newPatches = sMod.patchesAccess();
128 const label nPatches = origSurface.patches().size();
129 newPatches.setSize(nPatches + 6);
131 newPatches[nPatches].name() = "xMin";
132 newPatches[nPatches+1].name() = "xMax";
133 newPatches[nPatches+2].name() = "yMin";
134 newPatches[nPatches+3].name() = "yMax";
135 newPatches[nPatches+4].name() = "zMin";
136 newPatches[nPatches+5].name() = "zMax";
138 //- negative x direction
139 newTriangles[nTriangles] =
140 labelledTri(nPoints, nPoints+6, nPoints+2, nPatches);
141 newTriangles[nTriangles+1] =
142 labelledTri(nPoints, nPoints+4, nPoints+6, nPatches);
143 //- positive x direction
144 newTriangles[nTriangles+2] =
145 labelledTri(nPoints+1, nPoints+3, nPoints+7, nPatches+1);
146 newTriangles[nTriangles+3] =
147 labelledTri(nPoints+1, nPoints+7, nPoints+5, nPatches+1);
148 //- negative y direction
149 newTriangles[nTriangles+4] =
150 labelledTri(nPoints, nPoints+1, nPoints+5, nPatches+2);
151 newTriangles[nTriangles+5] =
152 labelledTri(nPoints, nPoints+5, nPoints+4, nPatches+2);
153 //- positive y direction
154 newTriangles[nTriangles+6] =
155 labelledTri(nPoints+2, nPoints+7, nPoints+3, nPatches+3);
156 newTriangles[nTriangles+7] =
157 labelledTri(nPoints+2, nPoints+6, nPoints+7, nPatches+3);
158 //- negative z direction
159 newTriangles[nTriangles+8] =
160 labelledTri(nPoints, nPoints+2, nPoints+3, nPatches+4);
161 newTriangles[nTriangles+9] =
162 labelledTri(nPoints, nPoints+3, nPoints+1, nPatches+4);
163 //- positive z direction
164 newTriangles[nTriangles+10] =
165 labelledTri(nPoints+4, nPoints+7, nPoints+6, nPatches+5);
166 newTriangles[nTriangles+11] =
167 labelledTri(nPoints+4, nPoints+5, nPoints+7, nPatches+5);
169 //- write the surface
170 origSurface.writeSurface(outFileName);
172 Info << "End\n" << endl;
178 // ************************************************************************* //