From 8d11d49b813040af8e02796d4467637a77e921f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Sun, 11 Feb 2018 18:34:00 +0100 Subject: [PATCH] Marching: add compilation process Also fix minor bugs --- .gitignore | 1 + Makefile | 9 ++++++++- MarchingCubes.cpp | 6 +++--- MarchingCubes.hpp | 2 +- tools/gen_marching_cubes_conf.py | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 2530b6d..98d9c1b 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ *.bin __pycache__ +_gen diff --git a/Makefile b/Makefile index e19eac1..9452c5f 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ OBJS=Implicit.o \ Mesh.o \ util/ObjParser.o \ MarchingCubes.o \ + _gen/marching_cubes_data.o \ render/GlutRender.o all: $(TARGETS:=.bin) @@ -18,12 +19,18 @@ all: $(TARGETS:=.bin) %.bin: main_%.o $(OBJS) $(CXX) $(CXXFLAGS) $(CXXLIBS) $(OBJS) $< -o $@ +_gen/marching_cubes_data.cpp: tools/gen_marching_cubes_conf.py _gen + python3 $< > $@ + %.o: %.cpp $(CXX) $(CXXFLAGS) -c $< -o $@ +_gen: + mkdir -p _gen + ############################################################ .PHONY: clean clean: - rm -rf $(OBJS) $(TARGETS:=.bin) + rm -rf $(OBJS) $(TARGETS:=.bin) _gen diff --git a/MarchingCubes.cpp b/MarchingCubes.cpp index bccdb6c..49f41ab 100644 --- a/MarchingCubes.cpp +++ b/MarchingCubes.cpp @@ -95,9 +95,9 @@ Point MarchingCubes::CubeEdge::at(double pos, bz + z[1] * resolution); return Point( - 0.5 * (p1.x + p2.x), - 0.5 * (p1.y + p2.y), - 0.5 * (p1.z + p2.z)); + pos * (p1.x + p2.x), + pos * (p1.y + p2.y), + pos * (p1.z + p2.z)); } Point MarchingCubes::intersect_location(const CubeEdge& edge, diff --git a/MarchingCubes.hpp b/MarchingCubes.hpp index 97d1855..f47dab5 100644 --- a/MarchingCubes.hpp +++ b/MarchingCubes.hpp @@ -86,7 +86,7 @@ class MarchingCubes { } bool x[2], y[2], z[2]; - const bool operator==(const CubeEdge& oth) 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]; diff --git a/tools/gen_marching_cubes_conf.py b/tools/gen_marching_cubes_conf.py index 6d96965..3d80016 100644 --- a/tools/gen_marching_cubes_conf.py +++ b/tools/gen_marching_cubes_conf.py @@ -11,7 +11,7 @@ import sys PREAMBLE = """ -#include "MarchingCubes.hpp" +#include "../MarchingCubes.hpp" typedef MarchingCubes::CubeTri Tri; typedef std::vector TriVect;