MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / lookup

Method lookup

tools/Wires/Inflator/GeometryCorrectionTable.cpp:196–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196Vector2F GeometryCorrectionTable::lookup(Float half_width, Float half_height) {
197 const size_t num_entries = m_measurements.size();
198 assert(m_design_sizes.size() == num_entries);
199 Vector2F target(half_width*2, half_height*2);
200
201 std::vector<Float> dist(num_entries);
202 std::vector<size_t> indices(num_entries);
203 for (size_t i=0; i<num_entries; i++) {
204 const Vector2F& measure = m_measurements[i];
205 dist[i] = (target - measure).squaredNorm();
206 indices[i] = i;
207 }
208
209 auto index_compare = [=](size_t i, size_t j) { return dist[i] < dist[j]; };
210 std::sort(indices.begin(), indices.end(), index_compare);
211
212 return interpolate(target, indices[0], indices[1], indices[2]) * 0.5;
213}
214
215Vector2F GeometryCorrectionTable::interpolate(const Vector2F& target,
216 size_t idx1, size_t idx2, size_t idx3) {

Callers 3

update_face_sourcesMethod · 0.45
update_face_sourcesMethod · 0.45

Calls 3

sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected