Marching: implement algorithm, still untested
This commit is contained in:
parent
998c77f643
commit
3100ef520f
2 changed files with 27 additions and 1 deletions
|
@ -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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue