Added overflow check in normalsDirectionCount

pull/542/head
Piero Toffanin 2017-04-08 10:42:39 -04:00
rodzic 7f44885bfd
commit e1a3fedd4e
2 zmienionych plików z 7 dodań i 2 usunięć

Wyświetl plik

@ -25,7 +25,11 @@ void PlyInterpreter::process_line(CGAL::Ply_reader& reader) {
Point3 p(x, y, z);
Vector3 n(nx, ny, nz);
zNormalsDirectionCount += nz >= 0 ? 1 : -1;
if (nz >= 0 && zNormalsDirectionCount < std::numeric_limits<long>::max()){
zNormalsDirectionCount++;
}else if (nz < 0 && zNormalsDirectionCount > std::numeric_limits<long>::min()){
zNormalsDirectionCount--;
}
points.push_back(std::make_pair(p, n));
}

Wyświetl plik

@ -3,6 +3,7 @@
#include <utility>
#include <vector>
#include <fstream>
#include <limits>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>
@ -19,7 +20,7 @@ typedef std::pair<Point3, Vector3> Pwn;
class PlyInterpreter {
std::vector<Pwn>& points;
int zNormalsDirectionCount;
long zNormalsDirectionCount;
public:
PlyInterpreter (std::vector<Pwn>& points)