| 93 | } |
| 94 | |
| 95 | void compareFiles(const std::string& name1, const std::string& name2) |
| 96 | { |
| 97 | //read las file |
| 98 | Options o1; |
| 99 | o1.add("filename", name1); |
| 100 | |
| 101 | LasReader r1; |
| 102 | r1.setOptions(o1); |
| 103 | |
| 104 | PointTable t1; |
| 105 | r1.prepare(t1); |
| 106 | PointViewSet s1 = r1.execute(t1); |
| 107 | |
| 108 | PointViewPtr v1 = *s1.begin(); |
| 109 | DimTypeList d1 = v1->dimTypes(); |
| 110 | point_count_t size1 = v1->size(); |
| 111 | std::vector<char> buf1(size1); |
| 112 | |
| 113 | //read draco file |
| 114 | Options o2; |
| 115 | o2.add("filename", name2); |
| 116 | |
| 117 | DracoReader r2; |
| 118 | r2.setOptions(o2); |
| 119 | |
| 120 | PointTable t2; |
| 121 | r2.prepare(t2); |
| 122 | PointViewSet s2 = r2.execute(t2); |
| 123 | |
| 124 | PointViewPtr v2 = *s2.begin(); |
| 125 | DimTypeList d2 = v2->dimTypes(); |
| 126 | point_count_t size2 = v2->size(); |
| 127 | std::vector<char> buf2(size2); |
| 128 | |
| 129 | |
| 130 | //compare the two point clouds point count |
| 131 | EXPECT_EQ(size1, size2); |
| 132 | |
| 133 | //Iterate through all the dimensions in the las file to make sure they |
| 134 | //all exist in the draco file. Because draco adds texture dims to their |
| 135 | //files we can't do a straight comparison. |
| 136 | bool flag = true; |
| 137 | for (auto& dim1: d1) { |
| 138 | for (unsigned long i = 0; i < d2.size(); ++i) { |
| 139 | //dimension is found, break |
| 140 | if (dim1.m_id == d2[i].m_id && dim1.m_type == d2[i].m_type) break; |
| 141 | //if not, and we're at the end of the vector, set flag to false |
| 142 | if (i == (d2.size() - 1)) flag = false; |
| 143 | } |
| 144 | if (flag == false) break; |
| 145 | } |
| 146 | EXPECT_TRUE(flag); |
| 147 | |
| 148 | //go through all position points and make sure XYZ are the same |
| 149 | for (PointId i = 0; i < (std::min)(size1, size2); i += 1) { |
| 150 | std::vector<double> data1(3, 0.0); |
| 151 | data1[0] = v1->getFieldAs<double>(Dimension::Id::X, i); |
| 152 | data1[1] = v1->getFieldAs<double>(Dimension::Id::Y, i); |