MCPcopy Create free account
hub / github.com/comaps/comaps / operator()

Method operator()

libs/coding/geometry_coding.cpp:387–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385}
386
387void TrianglesChainSaver::operator()(TPoint arr[3], std::vector<TEdge> edges)
388{
389 m_buffers.push_back(TBuffer());
390 MemWriter<TBuffer> writer(m_buffers.back());
391
392 WriteVarUint(writer, coding::EncodePointDeltaAsUint(arr[0], m_base));
393 WriteVarUint(writer, coding::EncodePointDeltaAsUint(arr[1], arr[0]));
394
395 TEdge curr = edges.front();
396 curr.m_delta = coding::EncodePointDeltaAsUint(arr[2], arr[1]);
397
398 sort(edges.begin(), edges.end(), edge_less_p0());
399
400 std::stack<TEdge> st;
401 while (true)
402 {
403 CHECK_EQUAL(curr.m_delta >> 62, 0, ());
404 uint64_t delta = curr.m_delta << 2;
405
406 // find next edges
407 int const nextNode = curr.m_p[1];
408 auto i = lower_bound(edges.begin(), edges.end(), nextNode, edge_less_p0());
409 bool const found = (i != edges.end() && i->m_p[0] == nextNode);
410 if (found)
411 {
412 // fill 2 tree-struct bites
413 ASSERT_NOT_EQUAL(i->m_side, -1, ());
414
415 uint64_t const one = 1;
416
417 // first child
418 delta |= (one << i->m_side);
419
420 std::vector<TEdge>::iterator j = i + 1;
421 if (j != edges.end() && j->m_p[0] == nextNode)
422 {
423 // second child
424 ASSERT_EQUAL(i->m_side, 0, ());
425 ASSERT_EQUAL(j->m_side, 1, ());
426
427 delta |= (one << j->m_side);
428
429 // push to stack for further processing
430 st.push(*j);
431 }
432
433 curr = *i;
434 }
435
436 // write delta for current element
437 WriteVarUint(writer, delta);
438
439 if (!found)
440 {
441 // end of chain - pop current from stack or exit
442 if (st.empty())
443 break;
444 else

Callers

nothing calls this directly

Calls 11

WriteVarUintFunction · 0.85
EncodePointDeltaAsUintFunction · 0.85
edge_less_p0Class · 0.85
backMethod · 0.80
frontMethod · 0.80
pushMethod · 0.80
popMethod · 0.80
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected