Marching: add compilation process

Also fix minor bugs
This commit is contained in:
Théophile Bastian 2018-02-11 18:34:00 +01:00
parent 3100ef520f
commit 8d11d49b81
5 changed files with 14 additions and 6 deletions

1
.gitignore vendored
View File

@ -29,3 +29,4 @@
*.bin
__pycache__
_gen

View File

@ -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

View File

@ -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,

View File

@ -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];

View File

@ -11,7 +11,7 @@ import sys
PREAMBLE = """
#include "MarchingCubes.hpp"
#include "../MarchingCubes.hpp"
typedef MarchingCubes::CubeTri Tri;
typedef std::vector<Tri> TriVect;