From 1dece061a3e2a1199464f80ad77011cb2d820e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Fri, 9 Feb 2018 00:53:47 +0100 Subject: [PATCH] march generator: add reverse activated points --- tools/gen_marching_cubes_conf.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tools/gen_marching_cubes_conf.py b/tools/gen_marching_cubes_conf.py index 899a462..8c76a14 100644 --- a/tools/gen_marching_cubes_conf.py +++ b/tools/gen_marching_cubes_conf.py @@ -83,6 +83,19 @@ class TriangulatedCube: n_act.add(transf(act)) return TriangulatedCube(n_act, n_tri) + def reverse_activated(self): + all_elts = { + Vert.frnt_bot_l, + Vert.frnt_bot_r, + Vert.frnt_top_l, + Vert.frnt_top_r, + Vert.back_bot_l, + Vert.back_bot_r, + Vert.back_top_l, + Vert.back_top_r, + } + self.activated = all_elts - self.activated + def activated_code(self): out = 0 for act in self.activated: @@ -181,11 +194,14 @@ def do_main(base_cases): index[code] = case for transf in transforms: - for case in base_cases: - tr_case = case.transform(transf) - code = tr_case.activated_code() - if index[code] is None: - index[code] = tr_case + for rev_activated in [False, True]: + for case in base_cases: + tr_case = case.transform(transf) + if rev_activated: + tr_case.reverse_activated() + code = tr_case.activated_code() + if index[code] is None: + index[code] = tr_case for (val, tri) in enumerate(index): if tri is None: