| 637 | } |
| 638 | |
| 639 | void streamTest(const std::string src) |
| 640 | { |
| 641 | Options ops; |
| 642 | ops.add("filename", src); |
| 643 | ops.add("resolution", 1); |
| 644 | |
| 645 | // Execute the reader in normal non-streaming mode. |
| 646 | EptReader normalReader; |
| 647 | normalReader.setOptions(ops); |
| 648 | PointTable normalTable; |
| 649 | const auto nodeIdDim = normalTable.layout()->registerOrAssignDim( |
| 650 | "EptNodeId", |
| 651 | Dimension::Type::Unsigned32); |
| 652 | const auto pointIdDim = normalTable.layout()->registerOrAssignDim( |
| 653 | "EptPointId", |
| 654 | Dimension::Type::Unsigned32); |
| 655 | normalReader.prepare(normalTable); |
| 656 | const auto views = normalReader.execute(normalTable); |
| 657 | PointView& normalView = **views.begin(); |
| 658 | |
| 659 | // A table that satisfies the streaming interface and simply adds the data |
| 660 | // to a normal PointView. We'll compare the result with the PointView |
| 661 | // resulting from standard execution. |
| 662 | class TestPointTable : public StreamPointTable |
| 663 | { |
| 664 | public: |
| 665 | TestPointTable(PointView& view) |
| 666 | : StreamPointTable(*view.table().layout(), 1024) |
| 667 | , m_view(view) |
| 668 | { } |
| 669 | |
| 670 | protected: |
| 671 | virtual void reset() override |
| 672 | { |
| 673 | m_offset += numPoints(); |
| 674 | } |
| 675 | |
| 676 | virtual char* getPoint(PointId index) override |
| 677 | { |
| 678 | return m_view.getOrAddPoint(m_offset + index); |
| 679 | } |
| 680 | |
| 681 | PointView& m_view; |
| 682 | PointId m_offset = 0; |
| 683 | }; |
| 684 | |
| 685 | // Execute the reder in streaming mode. |
| 686 | EptReader streamReader; |
| 687 | streamReader.setOptions(ops); |
| 688 | std::vector<char> streamBuffer; |
| 689 | PointTable streamTable; |
| 690 | PointView streamView(streamTable); |
| 691 | TestPointTable testTable(streamView); |
| 692 | const auto streamNodeIdDim = streamTable.layout()->registerOrAssignDim( |
| 693 | "EptNodeId", |
| 694 | Dimension::Type::Unsigned32); |
| 695 | const auto streamPointIdDim = streamTable.layout()->registerOrAssignDim( |
| 696 | "EptPointId", |