| 153 | } |
| 154 | |
| 155 | inline bool ZeroValueSampleDataEqual(const PGLZeroValueSampleData &compA, const PGLZeroValueSampleData &compB) |
| 156 | { |
| 157 | if (compA.position.x != compB.position.x || compA.position.y != compB.position.y || compA.position.z != compB.position.z || |
| 158 | #ifndef PGL_USE_DIRECTION_COMPRESSION |
| 159 | compA.direction.x != compB.direction.x || compA.direction.y != compB.direction.y || compA.direction.z != compB.direction.z |
| 160 | #else |
| 161 | compA.direction != compB.direction |
| 162 | #endif |
| 163 | ) |
| 164 | { |
| 165 | return false; |
| 166 | } |
| 167 | return true; |
| 168 | } |
| 169 | |
| 170 | inline bool ZeroValueSampleDataLess(const PGLZeroValueSampleData &compA, const PGLZeroValueSampleData &compB) |
| 171 | { |
| 172 | return compA.position.x < compB.position.x || |
| 173 | (compA.position.x == compB.position.x && |
| 174 | (compA.position.y < compB.position.y || |
| 175 | (compA.position.y == compB.position.y && |
| 176 | (compA.position.z < compB.position.z || |
| 177 | (compA.position.z == compB.position.z |
| 178 | #ifndef PGL_USE_DIRECTION_COMPRESSION |
| 179 | && (compA.direction.x < compB.direction.x || |
| 180 | (compA.direction.x == compB.direction.x && |
| 181 | (compA.direction.y < compB.direction.y || |
| 182 | (compA.direction.y == compB.direction.y && (compA.direction.z < compB.direction.z || (compA.direction.z == compB.direction.z)))))) |
| 183 | #else |
| 184 | && compA.direction.compressed_direction < compB.direction.compressed_direction |
| 185 | #endif |
| 186 | ))))); |
| 187 | } |
| 188 | |
| 189 | inline SampleData *LoadSampleData(const std::string fileName, size_t &numData) |
| 190 | { |
| 191 | std::ifstream file; |
| 192 | file.open(fileName, std::ios::binary); |
| 193 | file.read((char *)&numData, sizeof(size_t)); |
| 194 | |
| 195 | SampleData *data = new SampleData[numData]; |
| 196 | file.read((char *)data, numData * sizeof(SampleData)); |
| 197 | file.close(); |
| 198 | |
| 199 | return data; |
| 200 | } |
| 201 | |
| 202 | inline void StoreSampleData(const std::string fileName, const SampleData *data, const size_t &numData) |
| 203 | { |
| 204 | std::ofstream file; |
| 205 | file.open(fileName, std::ios::binary); |
| 206 | |
| 207 | file.write((char *)&numData, sizeof(size_t)); |
| 208 | file.write((char *)&data, numData * sizeof(SampleData)); |
| 209 | file.close(); |
| 210 | } |
| 211 | |
| 212 | } // namespace openpgl |