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 #ifndef surfaceFeatures_H
00048 #define surfaceFeatures_H
00049
00050 #include <OpenFOAM/pointField.H>
00051 #include <OpenFOAM/Map.H>
00052 #include <OpenFOAM/HashSet.H>
00053 #include <meshTools/pointIndexHit.H>
00054 #include <OpenFOAM/edgeList.H>
00055 #include <OpenFOAM/typeInfo.H>
00056
00057
00058
00059 namespace Foam
00060 {
00061
00062
00063 class triSurface;
00064
00065
00066
00067
00068
00069 class surfaceFeatures
00070 {
00071 public:
00072
00073 enum edgeStatus
00074 {
00075 NONE,
00076 REGION,
00077 EXTERNAL,
00078 INTERNAL
00079 };
00080
00081
00082 private:
00083
00084
00085 class labelScalar
00086 {
00087 public:
00088 label n_;
00089 scalar len_;
00090
00091 labelScalar(const label n, const scalar len)
00092 :
00093 n_(n),
00094 len_(len)
00095 {}
00096 };
00097
00098
00099
00100
00101
00102 const triSurface& surf_;
00103
00104
00105 labelList featurePoints_;
00106
00107
00108 labelList featureEdges_;
00109
00110
00111 label externalStart_;
00112
00113
00114 label internalStart_;
00115
00116
00117
00118
00119
00120
00121
00122 static pointIndexHit edgeNearest
00123 (
00124 const point& start,
00125 const point& end,
00126 const point& sample
00127 );
00128
00129
00130
00131 void calcFeatPoints(const List<edgeStatus>&);
00132
00133
00134 label nextFeatEdge
00135 (
00136 const List<edgeStatus>& edgeStat,
00137 const labelList& featVisited,
00138 const label unsetVal,
00139 const label prevEdgeI,
00140 const label vertI
00141 ) const;
00142
00143
00144 labelScalar walkSegment
00145 (
00146 const bool mark,
00147 const List<edgeStatus>& edgeStat,
00148 const label startEdgeI,
00149 const label startPointI,
00150 const label currentFeatI,
00151 labelList& featVisited
00152 );
00153
00154 public:
00155
00156 ClassName("surfaceFeatures");
00157
00158
00159
00160
00161 surfaceFeatures(const triSurface&);
00162
00163
00164 surfaceFeatures
00165 (
00166 const triSurface&,
00167 const labelList& featurePoints,
00168 const labelList& featureEdges,
00169 const label externalStart,
00170 const label internalStart
00171 );
00172
00173
00174
00175 surfaceFeatures
00176 (
00177 const triSurface&,
00178 const scalar includedAngle,
00179 const scalar minLen = 0,
00180 const label minElems = 0
00181 );
00182
00183
00184 surfaceFeatures(const triSurface&, const dictionary& dict);
00185
00186
00187 surfaceFeatures(const triSurface&, const fileName& fName);
00188
00189
00190 surfaceFeatures(const surfaceFeatures&);
00191
00192
00193
00194
00195
00196
00197 inline const triSurface& surface() const
00198 {
00199 return surf_;
00200 }
00201
00202
00203 inline const labelList& featurePoints() const
00204 {
00205 return featurePoints_;
00206 }
00207
00208
00209 inline const labelList& featureEdges() const
00210 {
00211 return featureEdges_;
00212 }
00213
00214
00215 inline label externalStart() const
00216 {
00217 return externalStart_;
00218 }
00219
00220
00221 inline label internalStart() const
00222 {
00223 return internalStart_;
00224 }
00225
00226
00227 inline label nRegionEdges() const
00228 {
00229 return externalStart_;
00230 }
00231
00232
00233 inline label nExternalEdges() const
00234 {
00235 return internalStart_ - externalStart_;
00236 }
00237
00238
00239 inline label nInternalEdges() const
00240 {
00241 return featureEdges_.size() - internalStart_;
00242 }
00243
00244
00245 labelList selectFeatureEdges
00246 (
00247 const bool regionEdges,
00248 const bool externalEdges,
00249 const bool internalEdges
00250 ) const;
00251
00252
00253
00254
00255
00256 void findFeatures(const scalar includedAngle);
00257
00258
00259
00260 void trimFeatures(const scalar minLen, const label minElems);
00261
00262
00263 List<edgeStatus> toStatus() const;
00264
00265
00266 void setFromStatus(const List<edgeStatus>&);
00267
00268
00269
00270
00271
00272
00273
00274
00275 Map<label> nearestSamples
00276 (
00277 const labelList& selectedPoints,
00278 const pointField& samples,
00279 const scalarField& maxDist
00280 ) const;
00281
00282
00283
00284
00285
00286
00287 Map<label> nearestSamples
00288 (
00289 const labelList& selectedEdges,
00290 const pointField& samples,
00291 const scalarField& sampleDist,
00292 const scalarField& maxDist,
00293 const scalar minSampleDist = 0.1
00294 ) const;
00295
00296
00297
00298
00299 Map<pointIndexHit> nearestEdges
00300 (
00301 const labelList& selectedEdges,
00302 const edgeList& sampleEdges,
00303 const labelList& selectedSampleEdges,
00304 const pointField& samplePoints,
00305 const scalarField& sampleDist,
00306 const scalarField& maxDist,
00307 const scalar minSampleDist = 0.1
00308 ) const;
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318 void nearestSurfEdge
00319 (
00320 const labelList& selectedEdges,
00321 const pointField& samples,
00322 const vector& searchSpan,
00323 labelList& edgeLabel,
00324 labelList& edgeEndPoint,
00325 pointField& edgePoint
00326 ) const;
00327
00328
00329
00330
00331
00332
00333
00334
00335 void nearestSurfEdge
00336 (
00337 const labelList& selectedEdges,
00338 const edgeList& sampleEdges,
00339 const labelList& selectedSampleEdges,
00340 const pointField& samplePoints,
00341 const vector& searchSpan,
00342
00343 labelList& edgeLabel,
00344 pointField& pointOnEdge,
00345 pointField& pointOnFeature
00346 ) const;
00347
00348
00349
00350
00351
00352 void writeDict(Ostream&) const;
00353
00354
00355 void write(const fileName& fName) const;
00356
00357
00358
00359 void writeObj(const fileName& prefix) const;
00360
00361
00362
00363
00364
00365 void operator=(const surfaceFeatures&);
00366
00367
00368 };
00369
00370
00371
00372
00373 }
00374
00375
00376
00377 #endif
00378
00379