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
@@ -0,0 +1 @@
build
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ option(CARVE_DEBUG "Compile in debug code"
option(CARVE_DEBUG_WRITE_PLY_DATA "Write geometry output during debug" OFF)
option(CARVE_USE_EXACT_PREDICATES "Use Shewchuk's exact predicates, where possible" OFF)
option(CARVE_INTERSECT_GLU_TRIANGULATOR "Include support for GLU triangulator in intersect" OFF)
option(CARVE_GTEST_TESTS "Complie gtest, and dependent tests" ON)
option(CARVE_GTEST_TESTS "Compile gtest, and dependent tests" ON)

if (MSVC)
# For MSVC, CMake sets certain flags to defaults we want to override.
Expand All @@ -33,10 +33,10 @@ if (MSVC)
# In hermetic build environments, tests may not have access to MS runtime
# DLLs, so this replaces /MD (CRT libraries in DLLs) with /MT (static CRT
# libraries).
string(REPLACE "/MD" "-MT" ${flag_var} "${${flag_var}}")
# string(REPLACE "/MD" "-MT" ${flag_var} "${${flag_var}}")
# We prefer more strict warning checking for building Google Test.
# Replaces /W3 with /W4 in defaults.
string(REPLACE "/W3" "-W4" ${flag_var} "${${flag_var}}")
# string(REPLACE "/W3" "-W4" ${flag_var} "${${flag_var}}")
endforeach()
endif()

Expand Down Expand Up @@ -66,6 +66,7 @@ if(OPENMP_FOUND)
endif()

if(CARVE_WITH_GUI)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL)
find_package(GLUT)
find_package(GLEW)
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

This fork of carve contains fixes to allow static library compilation for
* Windows MSVC2013 (express) & MSVC2019 (community) x64 compilers
* Linux Ubuntu GNU g++ x64

## Basic build instructions

* Use CMake Gui on both platforms, disable dev warning (Options menu)
* Enable only CARVE_USE_EXACT_PREDICATES
* Set "Where to build" ../carve/build
* Windows MSVC2013: Build using carve/build/carve.sln
* Static libs under build/lib/Release and build/lib/Debug
* Linux: Build with makefile under carve/build
* Static lib under build/lib

## Linux command line build with cmake

$ cd carve

$ cmake -B build -DBUILD_TESTING:BOOL="0" -DCARVE_USE_EXACT_PREDICATES:BOOL="1" -DCARVE_GTEST_TESTS:BOOL="0" -DCARVE_WITH_GUI:BOOL="0" -DBUILD_SHARED_LIBS:BOOL="0"

$ cd build

$ make
30 changes: 30 additions & 0 deletions build_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
echo building the carve library for Linux...
# by Carsten Arnholm, December 2020
#
# Requirements
# 1) cmake must be installed and defined in system PATH
#
# Output is found in "build" folder
# only carve static library is built
#
# Using the library:
# include paths:
# carve/include
# carve/build/include
#
# lib path:
# carve/build/lib
#
cmake -B build \
-DBUILD_TESTING:BOOL="0" \
-DCARVE_USE_EXACT_PREDICATES:BOOL="1" \
-DBUILD_SHARED_LIBS:BOOL="0" \
-DCARVE_GTEST_TESTS:BOOL="0" \
-DCARVE_WITH_GUI:BOOL="0" \
-DBUILD_SHARED_LIBS:BOOL="0"
#
cd build
make carve
ls -l ./lib/*.a
echo Carve build script ended
32 changes: 32 additions & 0 deletions build_windows_msvc.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@echo off
echo building the carve library for MSVC...
REM by Carsten Arnholm, December 2020
REM
REM Requirements
REM 1) Must be executed from "MSVC Developer Command Prompt"
REM 2) cmake must be installed and defined in system PATH
REM
REM Output is found in "build" folder
REM only carve static library is built
REM
REM Using the library
REM include paths:
REM carve/include
REM
REM lib path:
REM carve/build/lib/Release (for release builds)
REM carve/build/lib/Debug (for debug builds)
REM
cmake -B build ^
-DBUILD_TESTING:BOOL="0" ^
-DCARVE_USE_EXACT_PREDICATES:BOOL="1" ^
-DBUILD_SHARED_LIBS:BOOL="0" ^
-DCARVE_GTEST_TESTS:BOOL="0" ^
-DCARVE_WITH_GUI:BOOL="0" ^
-DBUILD_SHARED_LIBS:BOOL="0"
REM
cd build
msbuild carve.sln -target:carve /p:Platform="x64" /p:Configuration=Release /m
msbuild carve.sln -target:carve /p:Platform="x64" /p:Configuration=Debug /m
dir .\lib\Debug,.\lib\release
echo Carve build script ended
26 changes: 13 additions & 13 deletions common/write_ply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct vertex : public vertex_base {
int i;
vertex(const container_t& _cnt) : cnt(_cnt), i(-1) {}
void next() override { ++i; }
int length() override { return cnt.size(); }
int length() override { return static_cast<int>(cnt.size()); }
const carve::geom3d::Vector& curr() const override { return cnt[i].v; }
};

Expand All @@ -74,7 +74,7 @@ struct mesh_face : public gloop::stream::null_writer {
std::copy(poly->faceBegin(), poly->faceEnd(), std::back_inserter(faces));
}
void next() override { ++i; }
int length() override { return faces.size(); }
int length() override { return static_cast<int>(faces.size()); }
const carve::mesh::MeshSet<3>::face_t* curr() const { return faces[i]; }
};

Expand All @@ -91,7 +91,7 @@ struct mesh_face_idx : public gloop::stream::writer<size_t> {
f = r.curr();
i = f->begin();
}
int length() override { return f->nVertices(); }
int length() override { return static_cast<int>(f->nVertices()); }

bool isList() override { return true; }
gloop::stream::Type dataType() override { return data_type; }
Expand All @@ -108,7 +108,7 @@ struct face : public gloop::stream::null_writer {
int i;
face(const carve::poly::Polyhedron* _poly) : poly(_poly), i(-1) {}
void next() override { ++i; }
int length() override { return poly->faces.size(); }
int length() override { return static_cast<int>(poly->faces.size()); }
const carve::poly::Face<3>* curr() const { return &poly->faces[i]; }
};

Expand All @@ -129,7 +129,7 @@ struct face_idx : public gloop::stream::writer<size_t> {
f = r.curr();
i = 0;
}
int length() override { return f->nVertices(); }
int length() override { return static_cast<int>(f->nVertices()); }

bool isList() override { return true; }
gloop::stream::Type dataType() override { return data_type; }
Expand All @@ -152,7 +152,7 @@ struct lineset : public gloop::stream::null_writer {
c = n;
++n;
}
int length() override { return polyline->lines.size(); }
int length() override { return static_cast<int>(polyline->lines.size()); }
const carve::line::Polyline* curr() const { return *c; }
};

Expand Down Expand Up @@ -183,7 +183,7 @@ struct line_vi : public gloop::stream::writer<size_t> {
l = ls.curr();
i = 0;
}
int length() override { return l->vertexCount(); }
int length() override { return static_cast<int>(l->vertexCount()); }
size_t value() override {
return ls.polyline->vertexToIndex_fast(l->vertex(i++));
}
Expand All @@ -208,8 +208,8 @@ void setup(gloop::stream::model_writer& file,
file.addWriter("polyhedron.face", fi);
file.addWriter("polyhedron.face.vertex_indices",
new mesh_face_idx(*fi, gloop::stream::smallest_type(
poly->vertex_storage.size()),
face_max));
static_cast<uint32_t>(poly->vertex_storage.size())),
static_cast<int>(face_max)));
}

void setup(gloop::stream::model_writer& file,
Expand All @@ -230,8 +230,8 @@ void setup(gloop::stream::model_writer& file,
file.addWriter("polyhedron.face", fi);
file.addWriter(
"polyhedron.face.vertex_indices",
new face_idx(*fi, gloop::stream::smallest_type(poly->vertices.size()),
face_max));
new face_idx(*fi, gloop::stream::smallest_type(static_cast<uint32_t>(poly->vertices.size())),
static_cast<int>(face_max)));
}

void setup(gloop::stream::model_writer& file,
Expand All @@ -256,8 +256,8 @@ void setup(gloop::stream::model_writer& file,
file.addWriter("polyline.polyline.closed", new line_closed(*pi));
file.addWriter(
"polyline.polyline.vertex_indices",
new line_vi(*pi, gloop::stream::smallest_type(lines->vertices.size()),
line_max));
new line_vi(*pi, gloop::stream::smallest_type(static_cast<uint32_t>(lines->vertices.size())),
static_cast<int>(line_max)));
}

void setup(gloop::stream::model_writer& file,
Expand Down
4 changes: 2 additions & 2 deletions external/GLOOP/include/gloop/model/stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <gloop/exceptions.hpp>
#include <gloop/ref.hpp>

#ifdef WIN32
#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER < 1800

typedef char int8_t;
typedef short int16_t;
Expand Down Expand Up @@ -153,7 +153,7 @@ namespace gloop {
void send_sequence(reader_base *rd, size_t n, iter_t begin, iter_t end) {
if (rd) {
rd->begin();
rd->length(n);
rd->length(static_cast<int>(n));
while (begin != end) {
rd->next();
rd->_val(*begin++);
Expand Down
10 changes: 5 additions & 5 deletions external/GLOOP/src/model/obj_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <iostream>
#include <iomanip>
#include <iterator>

#include <algorithm>

namespace gloop {
namespace obj {
Expand Down Expand Up @@ -101,7 +101,7 @@ namespace gloop {
for (size_t i = 0; i < std::min(rd_count, r1.size()); ++i) {
if (v_rd[i] && r1[i].size()) {
v_rd[i]->begin();
v_rd[i]->length(blocks.size());
v_rd[i]->length(static_cast<int>(blocks.size()));
}
}

Expand Down Expand Up @@ -317,19 +317,19 @@ namespace {
uint32_t idx;
v_prop->wt->next();
v_prop->wt->_val(idx);
idx += v_base;
idx += static_cast<uint32_t>(v_base);
s << idx;
if (vt_prop || vn_prop) s << "/";
if (vt_prop) {
vt_prop->wt->next();
vt_prop->wt->_val(idx);
idx += vt_base;
idx += static_cast<uint32_t>(vt_base);
s << idx;
}
if (vn_prop) {
vn_prop->wt->next();
vn_prop->wt->_val(idx);
idx += vn_base;
idx += static_cast<uint32_t>(vn_base);
s << "/" << idx;
}
}
Expand Down
8 changes: 4 additions & 4 deletions external/GLOOP/src/model/ply_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <stdarg.h>
#include <stdio.h>

#ifdef WIN32
#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER < 1800

typedef char int8_t;
typedef short int16_t;
Expand Down Expand Up @@ -403,7 +403,7 @@ namespace {
in.seekg(len * sz, std::ios_base::cur);
} else {
rd->begin();
rd->length(len);
rd->length(static_cast<int>(len));
for (size_t i = 0; i < len; ++i) {
rd->next();
in.read(buf, sz);
Expand All @@ -426,7 +426,7 @@ namespace {
}
if (rd != NULL) {
rd->begin();
rd->length(len);
rd->length(static_cast<int>(len));
for (size_t i = 0; i < len; ++i) {
rd->next();
if (!prop_read(in, type, rd)) {
Expand Down Expand Up @@ -503,7 +503,7 @@ namespace {
in >> s_count;
if (!in.fail()) {
name = s_name;
count = s_count;
count = static_cast<int>(s_count);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions external/GLOOP/src/model/vtk_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace gloop {
stream::reader_base *z_rd = findReader(base, "vertex", "z");
if (e_rd) {
e_rd->begin();
e_rd->length(point_data.size());
e_rd->length(static_cast<int>(point_data.size()));
}
// std::cerr << "emitting " << point_data.size() << " points" << std::endl;
for (size_t i = 0; i < point_data.size(); ++i) {
Expand Down Expand Up @@ -184,7 +184,7 @@ namespace gloop {

if (e_rd) {
e_rd->begin();
e_rd->length(num);
e_rd->length(static_cast<int>(num));
}

size_t x = 0;
Expand Down Expand Up @@ -226,7 +226,7 @@ namespace gloop {

if (e_rd) {
e_rd->begin();
e_rd->length(num);
e_rd->length(static_cast<int>(num));
}

size_t x = 0;
Expand Down
1 change: 1 addition & 0 deletions include/carve/aabb_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <carve/geom.hpp>

#include <vector>
#include <algorithm>

namespace carve {
namespace geom {
Expand Down
2 changes: 1 addition & 1 deletion include/carve/csg_triangulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class CarveTriangulationImprover : public csg::CSG::Hook {
} else {
v = (*j).second;
}
tri.v[i.idx()] = v;
tri.v[i.idx()] = static_cast<unsigned int>(v);
}
result.push_back(tri);
delete face;
Expand Down
8 changes: 4 additions & 4 deletions include/carve/exact.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ static inline void prod_2_1(const double* a, const double* b, double* r) {
double t3[2];
op<1, 1>::add(t1 + 1, t2, t3);
r[1] = t3[0];
double t4[2];
// double t4[2];
op<1, 1>::add_fast(t2 + 1, t3 + 1, r + 2);
}

Expand Down Expand Up @@ -510,15 +510,15 @@ static inline void square_2(const double* a, double* r) {
r[1] = t4[0];
double t5[2];
square(a[1], t5);
double t6[4];
// double t6[4];
op<2, 2>::add(t5, t4 + 1, r + 2);
}
} // namespace detail

void exact_t::compress() {
double sum[2];

int j = size() - 1;
size_t j = size() - 1;
double Q = (*this)[j];
for (int i = (int)size() - 2; i >= 0; --i) {
detail::op<1, 1>::add_fast(&Q, &(*this)[i], sum);
Expand All @@ -530,7 +530,7 @@ void exact_t::compress() {
}
}
int j2 = 0;
for (int i = j + 1; i < (int)size(); ++i) {
for (size_t i = j + 1; i < size(); ++i) {
detail::op<1, 1>::add_fast(&(*this)[i], &Q, sum);
if (sum[0] != 0) {
(*this)[j2++] = sum[0];
Expand Down
Loading