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

Method next_element

source/MRMesh/miniply.cpp:654–801  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

652
653
654 void PLYReader::next_element()
655 {
656 if (!has_element()) {
657 return;
658 }
659
660 // If the element was loaded, the read buffer should already be positioned at
661 // the start of the next element.
662 PLYElement& elem = m_elements[m_currentElement];
663 m_currentElement++;
664
665 if (m_elementLoaded) {
666 // Clear any temporary storage used for list properties in the current element.
667 for (PLYProperty& prop : elem.properties) {
668 if (prop.countType == PLYPropertyType::None) {
669 continue;
670 }
671 prop.listData.clear();
672 prop.listData.shrink_to_fit();
673 prop.rowCount.clear();
674 prop.rowCount.shrink_to_fit();
675 }
676
677 // Clear temporary storage for the non-list properties in the current element.
678 m_elementData.clear();
679 m_elementLoaded = false;
680 return;
681 }
682
683 // If the element wasn't loaded, we have to move the file pointer past its
684 // contents. How we do that depends on whether this is an ASCII or binary
685 // file and, if it's a binary, whether the element is fixed or variable
686 // size.
687 if (m_fileType == PLYFileType::ASCII) {
688 for (uint32_t row = 0; row < elem.count; row++) {
689 next_line();
690 }
691 }
692 else if (elem.fixedSize) {
693 int64_t elementStart = static_cast<int64_t>(m_pos - m_buf);
694 int64_t elementSize = static_cast<int64_t>(elem.rowStride) * static_cast<int64_t>(elem.count);
695 int64_t elementEnd = elementStart + elementSize;
696 if (elementEnd >= kPLYReadBufferSize) {
697 m_bufOffset += elementEnd;
698 in_.seekg( m_bufOffset );
699 m_bufEnd = m_buf + kPLYReadBufferSize;
700 m_pos = m_bufEnd;
701 m_end = m_bufEnd;
702 refill_buffer();
703 }
704 else {
705 m_pos = m_buf + elementEnd;
706 m_end = m_pos;
707 }
708 }
709 else if (m_fileType == PLYFileType::Binary) {
710 for (uint32_t row = 0; row < elem.count; row++) {
711 for (const PLYProperty& prop : elem.properties) {

Callers 1

loadPlyFunction · 0.80

Calls 4

copy_and_convert_toFunction · 0.85
endian_swapFunction · 0.85
shrink_to_fitMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected