MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / calcFaceDistances

Function calcFaceDistances

source/MRMesh/MRFaceDistance.cpp:144–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142} // anonymous namespace
143
144std::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

Callers

nothing calls this directly

Calls 6

reportProgressFunction · 0.85
countMethod · 0.80
numValidFacesMethod · 0.80
takeDistancesMethod · 0.80
growOneEdgeMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected