Skip to content

Commit

Permalink
Force ordering of PointViews in sets to follow creation order.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Apr 1, 2015
1 parent 23b8e41 commit 89d77e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 11 additions & 3 deletions include/pdal/PointView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ class PointViewIter;
typedef std::shared_ptr<PointView> PointViewPtr;
typedef std::set<PointViewPtr> PointViewSet;


class PDAL_DLL PointView
{
friend class plang::BufferedInvocation;
friend class PointRef;
friend bool operator < (const PointViewPtr& p1, const PointViewPtr& p2);
public:
PointView(PointTableRef pointTable) : m_pointTable(pointTable), m_size(0)
{}
PointView(PointTableRef pointTable) : m_pointTable(pointTable),
m_size(0), m_id(0)
{
static int lastId = 0;
m_id = ++lastId;
}

virtual ~PointView()
{}
Expand Down Expand Up @@ -241,6 +245,7 @@ class PDAL_DLL PointView
// The index might be larger than the size to support temporary point
// references.
point_count_t m_size;
int m_id;
std::queue<PointId> m_temps;

private:
Expand All @@ -258,6 +263,9 @@ class PDAL_DLL PointView
{ m_temps.push(id); }
};

inline bool operator < (const PointViewPtr& p1, const PointViewPtr& p2)
{ return p1->m_id < p2->m_id; }


template <class T>
T PointView::getFieldInternal(Dimension::Id::Enum dim, PointId id) const
Expand Down
3 changes: 0 additions & 3 deletions test/unit/PointViewTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,13 @@ TEST(PointViewTest, bigfile)

PointView view(table);

std::cout << "SET" << std::endl;
for (PointId id = 0; id < NUM_PTS; ++id)
{
view.setField(Dimension::Id::X, id, id);
view.setField(Dimension::Id::Y, id, 2 * id);
view.setField(Dimension::Id::Z, id, -(int)id);
}

std::cout << "GET" << std::endl;
for (PointId id = 0; id < NUM_PTS; ++id)
{
EXPECT_EQ(
Expand All @@ -260,7 +258,6 @@ TEST(PointViewTest, bigfile)
EXPECT_EQ(
view.getFieldAs<int>(Dimension::Id::Z, id), -(int)id);
}
std::cout << "DONE" << std::endl;

// Test some random access.
std::unique_ptr<PointId[]> ids(new PointId[NUM_PTS]);
Expand Down

0 comments on commit 89d77e0

Please sign in to comment.