surfaceAutoPatch.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "triangle.H"
00034 #include "triSurface.H"
00035 #include "argList.H"
00036 #include "surfaceFeatures.H"
00037 #include "treeBoundBox.H"
00038 #include "meshTools.H"
00039 #include "OFstream.H"
00040
00041 using namespace Foam;
00042
00043
00044
00045
00046
00047 int main(int argc, char *argv[])
00048 {
00049 argList::noParallel();
00050 argList::validArgs.clear();
00051 argList::validArgs.append("input surface file");
00052 argList::validArgs.append("output surface file");
00053 argList::validArgs.append("included angle [0..180]");
00054 argList args(argc, argv);
00055
00056 fileName inFileName(args.additionalArgs()[0]);
00057 fileName outFileName(args.additionalArgs()[1]);
00058 scalar includedAngle(readScalar(IStringStream(args.additionalArgs()[2])()));
00059
00060 Pout<< "Surface : " << inFileName << nl
00061 << endl;
00062
00063
00064
00065
00066
00067 Info << "Reading : " << inFileName << endl;
00068 triSurface surf(inFileName);
00069
00070 Info<< "Read surface:" << endl;
00071 surf.writeStats(Info);
00072 Info<< endl;
00073
00074
00075
00076
00077
00078
00079 Info<< "Constructing feature set from included angle " << includedAngle
00080 << endl;
00081
00082 surfaceFeatures set(surf, includedAngle);
00083
00084 Pout<< nl
00085 << "Feature set:" << nl
00086 << " feature points : " << set.featurePoints().size() << nl
00087 << " feature edges : " << set.featureEdges().size() << nl
00088 << " of which" << nl
00089 << " region edges : " << set.nRegionEdges() << nl
00090 << " external edges : " << set.nExternalEdges() << nl
00091 << " internal edges : " << set.nInternalEdges() << nl
00092 << endl;
00093
00094
00095 boolList borderEdge(surf.nEdges(), false);
00096 forAll(set.featureEdges(), i)
00097 {
00098 borderEdge[set.featureEdges()[i]] = true;
00099 }
00100
00101 labelList faceRegion(surf.size());
00102 label nRegions = surf.markZones(borderEdge, faceRegion);
00103
00104
00105 forAll(surf, i)
00106 {
00107 surf[i].region() = faceRegion[i];
00108 }
00109
00110
00111 surf.patches().setSize(nRegions);
00112
00113 forAll(surf.patches(), patchI)
00114 {
00115 surf.patches()[patchI].name() = "patch" + Foam::name(patchI);
00116 surf.patches()[patchI].geometricType() = "empty";
00117 }
00118
00119
00120 Info << "Writing : " << outFileName << endl;
00121 surf.write(outFileName, true);
00122
00123 Info<< "End\n" << endl;
00124
00125 return 0;
00126 }
00127
00128
00129
Copyright © 2000-2009 OpenCFD Ltd