Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

bin/
debug/
depend/
include/
lib/
Expand Down
7 changes: 6 additions & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ Please contact the author at
gilbert@gilbertbernstein.com
if you would like to discuss licensing under other terms.

Triangle (used by Franky) is Copyright Jonathan Shewchuk according to the terms spelled out in the comments of triangle.c
The CDT constrained Delaunay triangulation library (src/isct/cdt) is
Copyright Artem Amirkhanov and is licensed under the Mozilla Public
License 2.0, see src/isct/cdt/LICENSE_CDT_MPL2.txt. Its bundled robust
geometric predicates (src/isct/cdt/predicates.h) are Copyright
William C. Lenthe under the BSD 3-Clause license, see the comments of
that file.


GNU LESSER GENERAL PUBLIC LICENSE
Expand Down
39 changes: 14 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ PLATFORM := $(shell uname)
# | Programs |
# +----------+
CPP11_FLAGS := -std=c++11
CC := clang
CXX := clang++
CC := gcc
CXX := g++
ifeq ($(PLATFORM),Darwin) # on mac
CPP11_FLAGS := $(CPP11_FLAGS) -stdlib=libc++ -Wno-c++11-extensions
endif
Expand Down Expand Up @@ -79,6 +79,12 @@ ifeq ($(PLATFORM),Darwin)
LINKD := $(LINK) -Wl,-no_pie
endif

ARCH = $(shell uname -m)

ifeq ($(findstring x86_64,$(ARCH)), x86_64)
CCFLAGS += -m64
CXXFLAGS+= -m64
endif

# ***********************
# * SOURCE DECLARATIONS *
Expand Down Expand Up @@ -112,8 +118,7 @@ UTIL_HEADERS := prelude.h memPool.h iterPool.h shortVec.h \
ISCT_HEADERS := unsafeRayTriIsct.h \
ext4.h fixext4.h gmpext4.h absext4.h \
quantization.h fixint.h \
empty3d.h \
triangle.h
empty3d.h
RAWMESH_HEADERS := rawMesh.h rawMesh.tpp
MESH_HEADERS := mesh.h mesh.decl.h \
mesh.tpp mesh.topoCache.tpp \
Expand Down Expand Up @@ -150,15 +155,11 @@ DEPENDS := $(addprefix depend/,$(addsuffix .d,$(ALL_SRCS)))
# | Object Aggregation for Targets |
# +--------------------------------+

OBJ := $(addprefix obj/,$(addsuffix .o,$(SRCS))) \
obj/isct/triangle.o
DEBUG := $(addprefix debug/,$(addsuffix .o,$(SRCS))) \
obj/isct/triangle.o
OBJ := $(addprefix obj/,$(addsuffix .o,$(SRCS)))
DEBUG := $(addprefix debug/,$(addsuffix .o,$(SRCS)))

MAIN_OBJ := $(addprefix obj/,$(addsuffix .o,$(MAIN_SRC))) \
obj/isct/triangle.o
MAIN_DEBUG := $(addprefix debug/,$(addsuffix .o,$(MAIN_SRC))) \
obj/isct/triangle.o
MAIN_OBJ := $(addprefix obj/,$(addsuffix .o,$(MAIN_SRC)))
MAIN_DEBUG := $(addprefix debug/,$(addsuffix .o,$(MAIN_SRC)))

LIB_TARGET_NAME := cork

Expand All @@ -181,24 +182,12 @@ lib/lib$(LIB_TARGET_NAME)debug.a: $(DEBUG)

bin/cork: $(MAIN_OBJ)
@echo "Linking cork command line tool"
@$(CXX) -o bin/cork $(MAIN_OBJ) $(LINK)
$(CXX) -o bin/cork $(MAIN_OBJ) $(LINK)

bin/off2obj: obj/off2obj.o
@echo "Linking off2obj"
@$(CXX) -o bin/off2obj obj/off2obj.o $(LINK)

# +------------------------------+
# | Specialized File Build Rules |
# +------------------------------+

obj/isct/triangle.o: src/isct/triangle.c
@echo "Compiling the Triangle library"
@$(CC) -O2 -DNO_TIMER \
-DREDUCED \
-DCDT_ONLY -DTRILIBRARY \
-Wall -DANSI_DECLARATORS \
-o obj/isct/triangle.o -c src/isct/triangle.c

# +------------------------------------+
# | Generic Source->Object Build Rules |
# +------------------------------------+
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,16 @@ Cork is licensed under the LGPL with an exception (from QT) to more easily allow

Of course, none of the above supercedes the actual COPYRIGHT.

Third-Party Code
================

Cork bundles the [CDT](https://github.com/artem-ogre/CDT) constrained
Delaunay triangulation library (`src/isct/cdt`), Copyright Artem
Amirkhanov, licensed under the Mozilla Public License 2.0 (see
`src/isct/cdt/LICENSE_CDT_MPL2.txt`). CDT's bundled robust geometric
predicates (`src/isct/cdt/predicates.h`) are Copyright William C.
Lenthe, licensed under the BSD 3-Clause license. CDT replaces the
Triangle library used by earlier versions of Cork, whose license did
not permit free redistribution.


56 changes: 56 additions & 0 deletions src/cork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ void computeUnion(

cmIn0.boolUnion(cmIn1);

if(out->remesh)
cmIn0.remesh();

corkMesh2CorkTriMesh(&cmIn0, out);
}

Expand All @@ -218,6 +221,9 @@ void computeDifference(

cmIn0.boolDiff(cmIn1);

if(out->remesh)
cmIn0.remesh();

corkMesh2CorkTriMesh(&cmIn0, out);
}

Expand All @@ -230,6 +236,9 @@ void computeIntersection(

cmIn0.boolIsct(cmIn1);

if(out->remesh)
cmIn0.remesh();

corkMesh2CorkTriMesh(&cmIn0, out);
}

Expand All @@ -242,6 +251,9 @@ void computeSymmetricDifference(

cmIn0.boolXor(cmIn1);

if(out->remesh)
cmIn0.remesh();

corkMesh2CorkTriMesh(&cmIn0, out);
}

Expand All @@ -255,6 +267,50 @@ void resolveIntersections(
cmIn0.disjointUnion(cmIn1);
cmIn0.resolveIntersections();

if(out->remesh){
cmIn0.remesh();
}
corkMesh2CorkTriMesh(&cmIn0, out);
}

void computeFirst(
CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out
) {
CorkMesh cmIn0, cmIn1;
corkTriMesh2CorkMesh(in0, &cmIn0);
corkTriMesh2CorkMesh(in1, &cmIn1);

cmIn0.boolFirst(cmIn1);

if(out->remesh)
cmIn0.remesh();

corkMesh2CorkTriMesh(&cmIn0, out);
}

void computeSecond(
CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out
) {
CorkMesh cmIn0, cmIn1;
corkTriMesh2CorkMesh(in0, &cmIn0);
corkTriMesh2CorkMesh(in1, &cmIn1);

cmIn1.boolFirst(cmIn0);

if(out->remesh)
cmIn1.remesh();

corkMesh2CorkTriMesh(&cmIn1, out);
}


void remeshTriangles(
CorkTriMesh in, CorkTriMesh *out
) {
CorkMesh cmIn;
corkTriMesh2CorkMesh(in, &cmIn);

cmIn.remesh();

corkMesh2CorkTriMesh(&cmIn, out);
}
7 changes: 7 additions & 0 deletions src/cork.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct CorkTriMesh
uint n_vertices;
uint *triangles;
float *vertices;
uint remesh;
};

void freeCorkTriMesh(CorkTriMesh *mesh);
Expand Down Expand Up @@ -72,3 +73,9 @@ void computeSymmetricDifference(
// such that the two surfaces are now connected.
void resolveIntersections(CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out);

// result = A cut by B
void computeFirst(CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out);
// result = B cut by A
void computeSecond(CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out);
// result = remesh(A)
void remeshTriangles(CorkTriMesh in, CorkTriMesh *out);
1 change: 1 addition & 0 deletions src/file_formats/off.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ int writeOFF(string filename, FileMesh *data)
int numfaces = data->triangles.size();
out << numvertices << ' ' << numfaces << ' ' << 0 << endl;

out.precision(18);
// vertex data
for(const auto &v : data->vertices) {
const Vec3d &p = v.pos;
Expand Down
Loading