Marching: implement algorithm, still untested

This commit is contained in:
Théophile Bastian 2018-02-11 17:54:44 +01:00
parent 998c77f643
commit 3100ef520f
2 changed files with 27 additions and 1 deletions

View file

@ -54,7 +54,27 @@ Mesh MarchingCubes::operator()() {
const std::vector<CubeTri>& cur_triangles = const std::vector<CubeTri>& cur_triangles =
edges_of_intersection[intersections.value()]; edges_of_intersection[intersections.value()];
// TODO for(const CubeTri& cube_tri: cur_triangles) {
Point verts[3] = {
intersect_location(cube_tri.edge[0],
x, y, z),
intersect_location(cube_tri.edge[1],
x, y, z),
intersect_location(cube_tri.edge[2],
x, y, z),
};
size_t vert_ids[3];
for(int i=0; i < 3; ++i)
vert_ids[i] = output.add_vertice(verts[i]);
for(int i=0; i < 3; ++i) {
output.add_face(
vert_ids[i],
vert_ids[(i+1) % 3],
vert_ids[(i+2) % 3]);
}
}
} }
} }
} }

View file

@ -86,6 +86,12 @@ class MarchingCubes {
} }
bool x[2], y[2], z[2]; bool x[2], y[2], z[2];
const bool operator==(const CubeEdge& oth) const {
return x[0] == oth.x[0] && x[1] == oth.x[1]
&& y[0] == oth.y[0] && y[1] == oth.y[1]
&& z[0] == oth.z[0] && z[1] == oth.z[1];
}
/** Get the space point at a given position of [0,1] along the edge /** Get the space point at a given position of [0,1] along the edge
* when the base of the cube (ie. (0, 0, 0)) is given. */ * when the base of the cube (ie. (0, 0, 0)) is given. */
Point at(double pos, Point at(double pos,