| 142 | } // anonymous namespace |
| 143 | |
| 144 | std::optional<FaceScalars> calcFaceDistances( const MeshTopology & topology, const EdgeMetric & metric, const FaceBitSet & starts, |
| 145 | const FaceDistancesSettings & settings ) |
| 146 | { |
| 147 | MR_TIMER; |
| 148 | DualEdgePathsBuider builder( topology, metric, starts ); |
| 149 | float localMaxDist = 0; |
| 150 | size_t numDone = settings.progress ? starts.count() : 0; |
| 151 | const float rTotal = 1.0f / topology.numValidFaces(); |
| 152 | if ( !reportProgress( settings.progress, numDone * rTotal ) ) |
| 153 | return {}; |
| 154 | |
| 155 | FaceScalars order; |
| 156 | if ( settings.out == FaceDistancesSettings::OutputFaceValues::SeqOrder ) |
| 157 | order = builder.distances(); |
| 158 | int lastSeq = 0; |
| 159 | for (;;) |
| 160 | { |
| 161 | const auto c = builder.growOneEdge(); |
| 162 | if ( !c.f ) |
| 163 | break; |
| 164 | localMaxDist = c.penalty; |
| 165 | if ( settings.out == FaceDistancesSettings::OutputFaceValues::SeqOrder && !starts.test( c.f ) ) |
| 166 | order[c.f] = float( ++lastSeq ); |
| 167 | if ( !reportProgress( settings.progress, [&]() { return numDone * rTotal; }, ++numDone, 16384 ) ) |
| 168 | return {}; |
| 169 | } |
| 170 | if ( settings.out == FaceDistancesSettings::OutputFaceValues::SeqOrder ) |
| 171 | { |
| 172 | if ( settings.maxDist ) |
| 173 | *settings.maxDist = float( lastSeq ); |
| 174 | return order; |
| 175 | } |
| 176 | if ( settings.maxDist ) |
| 177 | *settings.maxDist = localMaxDist; |
| 178 | return builder.takeDistances(); |
| 179 | } |
| 180 | |
| 181 | } // namespace MR |
nothing calls this directly
no test coverage detected