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 "labelHashSet.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
00247
00248
00249 void findFeatures(const scalar includedAngle);
00250
00251
00252
00253 void trimFeatures(const scalar minLen, const label minElems);
00254
00255
00256 List<edgeStatus> toStatus() const;
00257
00258
00259 void setFromStatus(const List<edgeStatus>&);
00260
00261
00262
00263
00264
00265
00266
00267 Map<label> nearestSamples
00268 (
00269 const labelList& pointLabels,
00270 const pointField& samples,
00271 const scalarField& maxDist
00272 ) const;
00273
00274
00275
00276
00277
00278
00279 Map<label> nearestSamplesToFeatEdges
00280 (
00281 const pointField& samples,
00282 const scalarField& sampleDist,
00283 const scalarField& maxDist,
00284 const scalar minSampleDist = 0.1
00285 ) const;
00286
00287
00288
00289
00290 Map<pointIndexHit> nearestEdgesToFeatEdges
00291 (
00292 const edgeList& sampleEdges,
00293 const labelList& selectedSampleEdges,
00294 const pointField& samplePoints,
00295 const scalarField& sampleDist,
00296 const scalarField& maxDist,
00297 const scalar minSampleDist = 0.1
00298 ) const;
00299
00300
00301
00302
00303
00304
00305
00306
00307 void nearestSurfFeatures
00308 (
00309 const pointField& samples,
00310 const scalarField& maxDist,
00311 labelList& edgeLabel,
00312 labelList& edgeEndPoint,
00313 pointField& edgePoint
00314 ) const;
00315
00316
00317
00318
00319
00320
00321
00322 void nearestSurfFeatures
00323 (
00324 const edgeList& sampleEdges,
00325 const labelList& selectedSampleEdges,
00326 const pointField& samplePoints,
00327
00328 const vector& searchSpan,
00329 labelList& edgeLabel,
00330 pointField& pointOnEdge,
00331 pointField& pointOnFeature
00332 ) const;
00333
00334
00335
00336
00337
00338 void writeDict(Ostream&) const;
00339
00340
00341 void write(const fileName& fName) const;
00342
00343
00344
00345 void writeObj(const fileName& prefix) const;
00346
00347
00348
00349
00350
00351 void operator=(const surfaceFeatures&);
00352
00353
00354 };
00355
00356
00357
00358
00359 }
00360
00361
00362
00363 #endif
00364
00365