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
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #include <OpenFOAM/triangle.H>
00058 #include <triSurface/triSurface.H>
00059 #include <OpenFOAM/argList.H>
00060 #include <meshTools/surfaceFeatures.H>
00061 #include <meshTools/treeBoundBox.H>
00062 #include <meshTools/meshTools.H>
00063 #include <OpenFOAM/OFstream.H>
00064
00065 using namespace Foam;
00066
00067
00068
00069
00070
00071 int main(int argc, char *argv[])
00072 {
00073 argList::noParallel();
00074 argList::validArgs.clear();
00075 argList::validArgs.append("input surface file");
00076 argList::validArgs.append("output surface file");
00077 argList::validArgs.append("included angle [0..180]");
00078 argList args(argc, argv);
00079
00080 fileName inFileName(args.additionalArgs()[0]);
00081 fileName outFileName(args.additionalArgs()[1]);
00082 scalar includedAngle(readScalar(IStringStream(args.additionalArgs()[2])()));
00083
00084 Pout<< "Surface : " << inFileName << nl
00085 << endl;
00086
00087
00088
00089
00090
00091 Info << "Reading : " << inFileName << endl;
00092 triSurface surf(inFileName);
00093
00094 Info<< "Read surface:" << endl;
00095 surf.writeStats(Info);
00096 Info<< endl;
00097
00098
00099
00100
00101
00102
00103 Info<< "Constructing feature set from included angle " << includedAngle
00104 << endl;
00105
00106 surfaceFeatures set(surf, includedAngle);
00107
00108 Pout<< nl
00109 << "Feature set:" << nl
00110 << " feature points : " << set.featurePoints().size() << nl
00111 << " feature edges : " << set.featureEdges().size() << nl
00112 << " of which" << nl
00113 << " region edges : " << set.nRegionEdges() << nl
00114 << " external edges : " << set.nExternalEdges() << nl
00115 << " internal edges : " << set.nInternalEdges() << nl
00116 << endl;
00117
00118
00119 boolList borderEdge(surf.nEdges(), false);
00120 forAll(set.featureEdges(), i)
00121 {
00122 borderEdge[set.featureEdges()[i]] = true;
00123 }
00124
00125 labelList faceRegion(surf.size());
00126 label nRegions = surf.markZones(borderEdge, faceRegion);
00127
00128
00129 forAll(surf, i)
00130 {
00131 surf[i].region() = faceRegion[i];
00132 }
00133
00134
00135 surf.patches().setSize(nRegions);
00136
00137 forAll(surf.patches(), patchI)
00138 {
00139 surf.patches()[patchI].name() = "patch" + Foam::name(patchI);
00140 surf.patches()[patchI].geometricType() = "empty";
00141 }
00142
00143
00144 Info << "Writing : " << outFileName << endl;
00145 surf.write(outFileName, true);
00146
00147 Info<< "End\n" << endl;
00148
00149 return 0;
00150 }
00151
00152
00153