diff --git a/tools/gen_marching_cubes_conf.py b/tools/gen_marching_cubes_conf.py index be40cad..bcfe01d 100644 --- a/tools/gen_marching_cubes_conf.py +++ b/tools/gen_marching_cubes_conf.py @@ -10,6 +10,15 @@ from functools import reduce import sys +PREAMBLE = """ +#include "MarchingCubes.hpp" + +typedef MarchingCubes::CubeTri Tri; +typedef std::vector TriVect; +typedef MarchingCubes::CubeEdge Edge; +""" + + class Vert: frnt_bot_l = (0, 0, 1) frnt_bot_r = (1, 0, 1) @@ -40,9 +49,9 @@ class Edge: def dump(self): def cbool(val): - return "true" if val else "false" + return "1" if val else "0" - return "MarchingCubes::CubeEdge({}, {}, {}, {}, {}, {})".format( + return "Edge({}, {}, {}, {}, {}, {})".format( cbool(self.vert[0][0]), cbool(self.vert[0][1]), cbool(self.vert[0][2]), @@ -108,8 +117,8 @@ class TriangulatedCube: def dump_tri(tri): - return ("MarchingCubes::CubeTri({{{}, {}, {}}})".format( - tri[0].dump(), tri[1].dump(), tri[2].dump)) + return ("Tri({}, {}, {})".format( + tri[0].dump(), tri[1].dump(), tri[2].dump())) def rot_general(vert, fixed, ax1, ax2): @@ -212,16 +221,16 @@ def do_main(base_cases): if has_unbound: raise RuntimeError("Some cases were not generated.") - print(("static const std::vector " - "edges_of_intersection[256] = {")) + print(PREAMBLE) + print(("static const TriVect edges_of_intersection[256] = {")) for (case_id, case) in enumerate(index): - print("\tstd::vector({") + print("\tTriVect({") for (tri_id, tri) in enumerate(case.triangles): - print(dump_tri(tri), - end=",\n" if tri_id == len(case.triangles) - 1 else '\n') - print('})', end=',\n' if case_id == len(base_cases) - 1 else '\n') + print('\t\t' + dump_tri(tri), + end=",\n" if tri_id != len(case.triangles) - 1 else '\n') + print('\t\t})', end=',\n' if case_id != len(index) - 1 else '\n') print("};")