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