Skip to content

Commit

Permalink
Fix race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
pierotofy committed Nov 9, 2020
1 parent 755b960 commit 907800d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ typedef struct BoundingBox{
BoundingBox(Point2D min, Point2D max): max(max), min(min){}
} BoundingBox;

struct PlyPoint{
typedef struct PlyPoint{
float x;
float y;
float z;
} p;
} PlyPoint;
size_t psize = sizeof(float) * 3;

struct PlyFace{
typedef struct PlyFace{
uint32_t p1;
uint32_t p2;
uint32_t p3;
} face;
} PlyFace;
size_t fsize = sizeof(uint32_t) * 3;

int arr_width, arr_height;
Expand Down Expand Up @@ -143,13 +143,15 @@ void writePly(const std::string &filename, int thread){
<< "property list uchar int vertex_indices" << std::endl
<< "end_header" << std::endl;

PlyPoint p;
for(Simplify::Vertex &v : *Simplify::vertices[thread]){
p.x = static_cast<float>(v.p.x);
p.y = static_cast<float>(v.p.y);
p.z = static_cast<float>(v.p.z);
f.write(reinterpret_cast<char *>(&p), psize);
}

PlyFace face;
uint8_t three = 3;
for(Simplify::Triangle &t : *Simplify::triangles[thread]){
face.p1 = static_cast<uint32_t>(t.v[0]);
Expand All @@ -174,13 +176,15 @@ void writeBin(const std::string &filename, int blockWidth, int blockHeight, int
f.write(reinterpret_cast<char *>(&vsize), sizeof(vsize));
f.write(reinterpret_cast<char *>(&tsize), sizeof(tsize));

PlyPoint p;
for(Simplify::Vertex &v : *Simplify::vertices[thread]){
p.x = static_cast<float>(v.p.x);
p.y = static_cast<float>(v.p.y);
p.z = static_cast<float>(v.p.z);
f.write(reinterpret_cast<char *>(&p), psize);
}

PlyFace face;
for(Simplify::Triangle &t : *Simplify::triangles[thread]){
face.p1 = static_cast<uint32_t>(t.v[0]);
face.p2 = static_cast<uint32_t>(t.v[1]);
Expand Down

0 comments on commit 907800d

Please sign in to comment.