Browse Source

Marching: add compilation process

Also fix minor bugs
marching_cubes
Théophile Bastian 5 years ago
parent
commit
8d11d49b81
  1. 1
      .gitignore
  2. 9
      Makefile
  3. 6
      MarchingCubes.cpp
  4. 2
      MarchingCubes.hpp
  5. 2
      tools/gen_marching_cubes_conf.py

1
.gitignore vendored

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

9
Makefile

@ -11,6 +11,7 @@ OBJS=Implicit.o \ @@ -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) @@ -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

6
MarchingCubes.cpp

@ -95,9 +95,9 @@ Point MarchingCubes::CubeEdge::at(double pos, @@ -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,

2
MarchingCubes.hpp

@ -86,7 +86,7 @@ class MarchingCubes { @@ -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];

2
tools/gen_marching_cubes_conf.py

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

Loading…
Cancel
Save