Add carve library to support better mesh boolean operations

master
Jeremy Hu 2018-03-17 17:21:17 +08:00
parent a749324e79
commit 425962921e
1487 changed files with 586943 additions and 8 deletions

View File

@ -1,5 +1,9 @@
Build
--------
```
$ cd thirdparty/carve-1.4.0/build
$ cmake ../
$ make && make install
$ qmake -spec macx-xcode
```

View File

@ -42,5 +42,9 @@ SOURCES += src/main.cpp
INCLUDEPATH += ../meshlite/include
LIBS += -L../meshlite/target/debug -lmeshlite
INCLUDEPATH += thirdparty/carve-1.4.0/include
INCLUDEPATH += thirdparty/carve-1.4.0/build/include
LIBS += -Lthirdparty/carve-1.4.0/build/lib -lcarve
target.path = ./
INSTALLS += target

View File

@ -324,6 +324,7 @@ void SkeletonEditGraphicsView::setNextStartNodeItem(SkeletonEditNodeItem *item)
m_nextStartNodeItem = item;
if (m_nextStartNodeItem)
m_nextStartNodeItem->setIsNextStartNode(true);
applyAddNodeMode();
}
void SkeletonEditGraphicsView::updateBackgroundImage(const QImage &image)

View File

@ -3,8 +3,86 @@
#include "skeletoneditnodeitem.h"
#include "skeletoneditedgeitem.h"
#if defined(HAVE_CONFIG_H)
# include <carve_config.h>
#endif
#include <carve/carve.hpp>
#include <carve/csg.hpp>
#include <carve/input.hpp>
// Modified from https://wiki.qt.io/QThreads_general_usage
#define MAX_VERTICES_PER_FACE 100
carve::poly::Polyhedron *makeCarveMeshFromMeshlite(void *meshlite, int meshId)
{
carve::input::PolyhedronData data;
int vertexCount = meshlite_get_vertex_count(meshlite, meshId);
float *vertexPositions = new float[vertexCount * 3];
meshlite_get_vertex_position_array(meshlite, meshId, vertexPositions, vertexCount * 3);
int offset = 0;
for (int i = 0; i < vertexCount; i++) {
data.addVertex(carve::geom::VECTOR(
vertexPositions[offset + 0],
vertexPositions[offset + 1],
vertexPositions[offset + 2]));
offset += 3;
}
int faceCount = meshlite_get_face_count(meshlite, meshId);
int *faceVertexNumAndIndices = new int[faceCount * MAX_VERTICES_PER_FACE];
int filledLength = meshlite_get_face_index_array(meshlite, meshId, faceVertexNumAndIndices, faceCount * MAX_VERTICES_PER_FACE);
int i = 0;
while (i < filledLength) {
int num = faceVertexNumAndIndices[i++];
std::vector<int> faceIndices;
for (int j = 0; j < num; j++) {
int index = faceVertexNumAndIndices[i++];
faceIndices.push_back(index);
}
data.addFace(faceIndices.begin(), faceIndices.end());
}
delete[] faceVertexNumAndIndices;
delete[] vertexPositions;
return new carve::poly::Polyhedron(data.points, data.getFaceCount(), data.faceIndices);
}
int makeMeshliteMeshFromCarve(void *meshlite, carve::poly::Polyhedron *polyhedron)
{
int vertexCount = polyhedron->vertices.size();
float *vertexPositions = new float[vertexCount * 3];
int offset = 0;
std::map<const carve::poly::Geometry<3>::vertex_t *, int> vertexIndexMap;
for (int i = 0; i < vertexCount; i++) {
auto vertex = &polyhedron->vertices[i];
vertexPositions[offset++] = vertex->v.x;
vertexPositions[offset++] = vertex->v.y;
vertexPositions[offset++] = vertex->v.z;
vertexIndexMap[vertex] = i;
}
int faceCount = polyhedron->faces.size();
int *faceVertexNumAndIndices = new int[faceCount * MAX_VERTICES_PER_FACE];
offset = 0;
for (int i = 0; i < faceCount; i++) {
auto face = &polyhedron->faces[i];
faceVertexNumAndIndices[offset++] = face->vertices.size();
for (int j = 0; j < (int)face->vertices.size(); j++) {
faceVertexNumAndIndices[offset++] = vertexIndexMap[face->vertices[j]];
}
}
int meshId = meshlite_build(meshlite, vertexPositions, vertexCount, faceVertexNumAndIndices, offset);
delete[] vertexPositions;
delete[] faceVertexNumAndIndices;
return meshId;
}
carve::poly::Polyhedron *unionCarveMeshs(carve::poly::Polyhedron *first,
carve::poly::Polyhedron *second)
{
carve::csg::CSG csg;
carve::poly::Polyhedron *result = csg.compute(first, second, carve::csg::CSG::UNION, NULL, carve::csg::CSG::CLASSIFY_EDGE);
return new carve::poly::Polyhedron(*result);
}
struct NodeItemInfo
{
int index;
@ -148,21 +226,30 @@ void SkeletonToMesh::process()
group->meshId = meshlite_bmesh_generate_mesh(context, group->bmeshId, group->nodes[group->rootNode].bmeshNodeId);
}
int unionMeshId = m_groups[0].meshId;
carve::poly::Polyhedron *unionPolyhedron = makeCarveMeshFromMeshlite(context, m_groups[0].meshId);
for (size_t i = 1; i < m_groups.size(); i++) {
int newUnionMeshId = meshlite_union(context, m_groups[i].meshId, unionMeshId);
// TODO: destroy last unionMeshId
// ... ...
unionMeshId = newUnionMeshId;
carve::poly::Polyhedron *polyhedron = makeCarveMeshFromMeshlite(context, m_groups[i].meshId);
carve::poly::Polyhedron *newUnionPolyhedron = unionCarveMeshs(unionPolyhedron, polyhedron);
delete polyhedron;
delete unionPolyhedron;
unionPolyhedron = newUnionPolyhedron;
if (NULL == unionPolyhedron) {
break;
}
}
for (size_t i = 1; i < m_groups.size(); i++) {
meshlite_bmesh_destroy(context, m_groups[i].bmeshId);
}
int triangulate = meshlite_triangulate(context, unionMeshId);
meshlite_export(context, triangulate, "/Users/jeremy/testlib.obj");
m_mesh = new Mesh(context, triangulate);
if (unionPolyhedron) {
int meshIdGeneratedFromCarve = makeMeshliteMeshFromCarve(context, unionPolyhedron);
delete unionPolyhedron;
int triangulate = meshlite_triangulate(context, meshIdGeneratedFromCarve);
meshlite_export(context, triangulate, "/Users/jeremy/testlib.obj");
m_mesh = new Mesh(context, triangulate);
}
meshlite_destroy_context(context);
emit finished();
}

78
thirdparty/carve-1.4.0/.hgignore vendored Normal file
View File

@ -0,0 +1,78 @@
syntax: glob
# backup files, etc.
*~
*.sw?
# autotools generated
aclocal.m4
autom4te.cache/output.0
autom4te.cache/output.1
autom4te.cache/requests
autom4te.cache/traces.0
autom4te.cache/traces.1
config.log
config.status
configure
include/carve/config.h
include/carve/stamp-h2
include/carve_config.h
include/carve_config.h.in
include/stamp-h1
libtool
# cmake generated
CMakeFiles
# debug info
*.dSYM
# regression test results
regression/*/test_*
# produced by compilation
*.la
*.o
*.lo
*.Plo
*.a
*.Po
*.dylib
*.so
Makefile.in
Makefile
.libs
.deps
# generated executables
src/convert
src/custom_collector
src/cutgraph
src/intersect
src/problem
src/test_aabb
src/test_aabb_tri
src/test_csg_interpolate
src/test_eigen
src/test_geom
src/test_hole_incorporate
src/test_interpolate
src/test_intersect
src/test_rescale
src/test_slice
src/test_slice_classify
src/test_spacetree
src/test_triangulate
src/tetrahedron
src/texture_example
src/triangulate
src/view

1
thirdparty/carve-1.4.0/.hgtags vendored Normal file
View File

@ -0,0 +1 @@
7a324ce473d5b2da82292cf48a6ab076a91234b1 rev-1.4.0

1
thirdparty/carve-1.4.0/AUTHORS vendored Normal file
View File

@ -0,0 +1 @@
Toby Sargeant <tobias.sargeant@gmail.com>

118
thirdparty/carve-1.4.0/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,118 @@
cmake_minimum_required(VERSION 2.6)
project(carve)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(carve_VERSION_MAJOR 1)
set(carve_VERSION_MINOR 4)
set(carve_VERSION_PATCH 0)
set(CARVE_VERSION ${carve_VERSION_MAJOR}.${carve_VERSION_MINOR}.${carve_VERSION_PATCH})
option(BUILD_SHARED_LIBS "Compile libcarve as shared" ON)
option(CARVE_WITH_GUI "Compile gui code" OFF)
option(CARVE_SYSTEM_BOOST "Compile with system installed boost" OFF)
option(CARVE_BOOST_COLLECTIONS "Compile with boost collections" OFF)
option(CARVE_DEBUG "Compile in debug code" OFF)
option(CARVE_DEBUG_WRITE_PLY_DATA "Write geometry output during debug" OFF)
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE)
if(WIN32)
set(BUILD_SHARED_LIBS OFF) # until everything is exported
add_definitions(-D_USE_MATH_DEFINES)
add_definitions(-DNOMINMAX)
endif(WIN32)
set(HAVE_TR1_UNORDERED_COLLECTIONS FALSE)
set(HAVE_STD_UNORDERED_COLLECTIONS FALSE)
set(HAVE_LIBSTDCPP_UNORDERED_COLLECTIONS FALSE)
set(HAVE_BOOST_UNORDERED_COLLECTIONS FALSE)
if(CARVE_SYSTEM_BOOST)
find_package(BOOST 1.40)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
message(STATUS "Using system boost")
else(Boost_FOUND)
set(CARVE_SYSTEM_BOOST OFF)
endif(Boost_FOUND)
endif(CARVE_SYSTEM_BOOST)
if(CARVE_BOOST_COLLECTIONS)
set(HAVE_BOOST_UNORDERED_COLLECTIONS TRUE)
else(CARVE_BOOST_COLLECTIONS)
# attempt to work out which unordered collection implementation we can use
try_compile(_HAVE_STD_UNORDERED_COLLECTIONS
${CMAKE_BINARY_DIR}
"${carve_SOURCE_DIR}/cmake/test_std_unordered.cpp"
OUTPUT_VARIABLE OUTPUT)
try_compile(_HAVE_TR1_UNORDERED_COLLECTIONS
${CMAKE_BINARY_DIR}
"${carve_SOURCE_DIR}/cmake/test_tr1_unordered.cpp"
OUTPUT_VARIABLE OUTPUT)
try_compile(_HAVE_LIBSTDCPP_UNORDERED_COLLECTIONS
${CMAKE_BINARY_DIR}
"${carve_SOURCE_DIR}/cmake/test_libstdcpp_unordered.cpp"
OUTPUT_VARIABLE OUTPUT)
if(_HAVE_STD_UNORDERED_COLLECTIONS)
set(HAVE_STD_UNORDERED_COLLECTIONS TRUE)
message(STATUS "Using std::unordered_map")
elseif(_HAVE_TR1_UNORDERED_COLLECTIONS)
set(HAVE_TR1_UNORDERED_COLLECTIONS TRUE)
message(STATUS "Using tr1::unordered_map")
elseif(_HAVE_LIBSTDCPP_UNORDERED_COLLECTIONS)
set(HAVE_LIBSTDCPP_UNORDERED_COLLECTIONS TRUE)
message(STATUS "Using __gnu_cxx::unordered_map ")
endif(_HAVE_STD_UNORDERED_COLLECTIONS)
endif(CARVE_BOOST_COLLECTIONS)
if(CARVE_WITH_GUI)
find_package(OpenGL)
find_package(GLUT)
if(NOT OPENGL_FOUND)
message(WARNING "Unable to locate OpenGL")
set(CARVE_WITH_GUI OFF)
elseif(NOT GLUT_FOUND)
message(WARNING "Unable to locate GLUT")
set(CARVE_WITH_GUI OFF)
else(OPENGL_FOUND AND GLUT_FOUND)
message(STATUS "Found OpenGL and GLUT")
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${GLUT_INCLUDE_DIR})
if(WIN32)
add_definitions(-DGLUI_NO_LIB_PRAGMA)
add_definitions(-DGLUI_USE_STATIC_LIB)
add_definitions(-DGLEW_STATIC)
endif(WIN32)
add_subdirectory(external/GLEW)
add_subdirectory(external/GLUI)
endif(NOT OPENGL_FOUND)
endif(CARVE_WITH_GUI)
add_subdirectory(external/GLOOP)
add_subdirectory(external/gtest-1.5.0)
configure_file (
"${carve_SOURCE_DIR}/include/carve/cmake-config.h.in"
"${carve_BINARY_DIR}/include/carve/config.h"
)
include_directories(${carve_BINARY_DIR}/include)
add_subdirectory(lib)
add_subdirectory(include)
add_subdirectory(common)
add_subdirectory(src)
add_subdirectory(examples)
add_subdirectory(tests)

3
thirdparty/carve-1.4.0/ChangeLog vendored Normal file
View File

@ -0,0 +1,3 @@
2009-06-01 Tobias Sargeant <tobias.sargeant@gmail.com>
* Carve: initial GPL2 release.

229
thirdparty/carve-1.4.0/INSTALL vendored Normal file
View File

@ -0,0 +1,229 @@
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the `--target=TYPE' option to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
will cause the specified gcc to be used as the C compiler (unless it is
overridden in the site shell script).
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

361
thirdparty/carve-1.4.0/LICENSE.GPL2 vendored Normal file
View File

@ -0,0 +1,361 @@
GNU GENERAL PUBLIC LICENSE
The Qt GUI Toolkit is Copyright (C) 1994-2008 Trolltech ASA.
You may use, distribute and copy the Qt GUI Toolkit under the terms of
GNU General Public License version 2, which is displayed below.
-------------------------------------------------------------------------
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
-------------------------------------------------------------------------
In addition, as a special exception, Trolltech gives permission to link the
code of its release of Qt with the OpenSSL project's "OpenSSL" library (or
modified versions of it that use the same license as the "OpenSSL"
library), and distribute the linked executables. You must comply with the GNU
General Public License version 2 or the GNU General Public License version 3
in all respects for all of the code used other than the "OpenSSL" code. If
you modify this file, you may extend this exception to your version of the
file, but you are not obligated to do so. If you do not wish to do so,
delete this exception statement from your version of this file.

12
thirdparty/carve-1.4.0/Makefile.am vendored Normal file
View File

@ -0,0 +1,12 @@
ACLOCAL_AMFLAGS=-I m4
SUBDIRS=lib include external common src tests examples
EXTRA_DIST= win32/Carve.sln win32/carvelib/carvelib.vcproj \
win32/glew/glew.vcproj win32/gloop/gloop.vcproj \
win32/glui/glui.vcproj win32/intersect/intersect.vcproj \
win32/texture_example/texture_example.vcproj \
win32/fileformats/fileformats.vcproj win32/view/view.vcproj \
data/coneup.ply data/cylinderx.ply data/cylindery.ply \
data/cylinderz.ply data/ico.ply data/ico5.ply data/shells.ply \
data/sphere.ply data/sphere_one_point_moved.ply m4/ax_boost.m4 \
m4/ax_boost_base.m4

0
thirdparty/carve-1.4.0/NEWS vendored Normal file
View File

0
thirdparty/carve-1.4.0/README vendored Normal file
View File

216
thirdparty/carve-1.4.0/acinclude.m4 vendored Normal file
View File

@ -0,0 +1,216 @@
AC_DEFUN([CARVE_CHECK_OPENGL],[
have_GL=no
have_GLU=no
have_glut=no
case "$host" in
*darwin*)
if test x"${with_x}" != xyes; then
AC_MSG_NOTICE([Using OSX frameworks for GL])
GL_CFLAGS=""
GL_LIBS="-framework OpenGL"
GLUT_CFLAGS=""
GLUT_LIBS="-framework GLUT"
have_GL=yes
have_GLU=yes
have_glut=yes
else
AC_MSG_NOTICE([Not using OSX frameworks for GL])
fi
;;
esac
if test x"$have_GL" = xno; then
AC_PATH_XTRA
AC_LANG_SAVE
AC_LANG_C
GL_CFLAGS=""
GL_LIBS=""
GLUT_CFLAGS=""
GLUT_LIBS=""
GL_X_LIBS=""
if test x"$no_x" != xyes; then
GL_CFLAGS="$X_CFLAGS"
GL_X_LIBS="$X_PRE_LIBS $X_LIBS -lX11 -lXext -lXmu -lXt -lXi $X_EXTRA_LIBS"
fi
GL_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$GL_CFLAGS"
GL_save_LIBS="$LIBS"
LIBS="$GL_X_LIBS"
AC_CHECK_LIB([GL], [glAccum], have_GL=yes, have_GL=no)
AC_CHECK_LIB([GLU], [gluBeginCurve], have_GLU=yes, have_GLU=no)
AC_CHECK_LIB([glut], [glutInit], have_glut=yes, have_glut=no)
if test x"$have_GL" = xno; then
GL_LIBS="-lGL"
fi
if test x"$have_GLU" = xyes; then
GL_LIBS="$GL_LIBS -lGLU"
fi
if test x"$have_glut" = xyes; then
GLUT_LIBS="-lglut"
fi
GL_X_LIBS=""
LIBS="$GL_save_LIBS"
CPPFLAGS="$GL_save_CPPFLAGS"
AC_LANG_RESTORE
fi
])
AC_DEFUN([CARVE_CHECK_GLUI],[
AC_ARG_WITH(glui-prefix, [ --with-glui-prefix=PFX Prefix where GLUI is installed (optional)],
glui_prefix="$withval", glui_prefix="")
AC_ARG_WITH(glui-includes,[ --with-glui-includes=PATH Path to GLUI includes (optional)],
glui_includes="$withval", glui_includes="")
AC_ARG_WITH(glui-libs, [ --with-glui-libs=PATH Path to GLUI libs (optional)],
glui_libs="$withval", glui_libs="")
if test x"$glui_prefix" != x""; then
glui_libs="$glui_prefix/lib"
glui_includes="$glui_prefix/include"
fi
GLUI_CFLAGS=""
if test x"$glui_includes" != x""; then
GLUI_CFLAGS="-I$glui_includes"
fi
GLUI_LDFLAGS=""
if test x"$glui_libs" != x""; then
GLUI_LDFLAGS="-L$glui_libs"
fi
GLUI_LIBS="-lglui"
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
GLUI_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $GLUI_CFLAGS"
GLUI_save_LIBS="$LIBS"
LIBS="$LIBS $GLUI_LIBS"
GLUI_save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $GLUI_LDFLAGS"
have_GLUI=no
AC_CHECK_LIB(glui, main, [AC_CHECK_HEADER(GL/glui.h, [have_GLUI=yes])])
LDFLAGS="$GLUI_save_LDFLAGS"
LIBS="$GLUI_save_LIBS"
CPPFLAGS="$GLUI_save_CPPFLAGS"
AC_LANG_RESTORE
])
AC_DEFUN([CARVE_CHECK_GLEW],[
AC_ARG_WITH(glew-prefix, [ --with-glew-prefix=PFX Prefix where GLEW is installed (optional)],
glew_prefix="$withval", glew_prefix="")
AC_ARG_WITH(glew-includes,[ --with-glew-includes=PATH Path to GLEW includes (optional)],
glew_includes="$withval", glew_includes="")
AC_ARG_WITH(glew-libs, [ --with-glew-libs=PATH Path to GLEW libs (optional)],
glew_libs="$withval", glew_libs="")
if test x"$glew_prefix" != x""; then
glew_libs="$glew_prefix/lib"
glew_includes="$glew_prefix/include"
fi
GLEW_CFLAGS=""
if test x"$glew_includes" != x""; then
GLEW_CFLAGS="-I$glew_includes"
fi
GLEW_LDFLAGS=""
if test x"$glew_libs" != x""; then
GLEW_LDFLAGS="-L$glew_libs"
fi
GLEW_LIBS="-lglew"
AC_LANG_SAVE
AC_LANG_C
GLEW_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $GLEW_CFLAGS"
GLEW_save_LIBS="$LIBS"
LIBS="$LIBS $GLEW_LIBS"
GLEW_save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $GLEW_LDFLAGS"
have_GLEW=no
AC_CHECK_LIB(glew, glewInit, [AC_CHECK_HEADER(GL/glew.h, [have_GLEW=yes])])
LDFLAGS="$GLEW_save_LDFLAGS"
LIBS="$GLEW_save_LIBS"
CPPFLAGS="$GLEW_save_CPPFLAGS"
AC_LANG_RESTORE
])
AC_DEFUN([CARVE_CHECK_GLOOP],[
AC_ARG_WITH(gloop-prefix, [ --with-gloop-prefix=PFX Prefix where GLOOP is installed (optional)],
gloop_prefix="$withval", gloop_prefix="")
AC_ARG_WITH(gloop-includes,[ --with-gloop-includes=PATH Path to GLOOP includes (optional)],
gloop_includes="$withval", gloop_includes="")
AC_ARG_WITH(gloop-libs, [ --with-gloop-libs=PATH Path to GLOOP libs (optional)],
gloop_libs="$withval", gloop_libs="")
if test x"$gloop_prefix" != x""; then
gloop_libs="$gloop_prefix/lib"
gloop_includes="$gloop_prefix/include"
fi
GLOOP_CFLAGS=""
if test x"$gloop_includes" != x""; then
GLOOP_CFLAGS="-I$gloop_includes"
fi
GLOOP_LDFLAGS=""
if test x"$gloop_libs" != x""; then
GLOOP_LDFLAGS="-L$gloop_libs"
fi
GLOOP_LIBS="-lgloop"
GLOOP_MODEL_LIBS="-lgloop-model"
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
GLOOP_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $GLOOP_CFLAGS"
GLOOP_save_LIBS="$LIBS"
LIBS="$LIBS $GLOOP_LIBS $GLOOP_MODEL_LIBS"
GLOOP_save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $GLOOP_LDFLAGS"
have_gloop=no
AC_CHECK_HEADERS(gloop/gloop.hpp, [AC_CHECK_LIB(gloop, main, have_gloop=yes)])
LDFLAGS="$GLOOP_save_LDFLAGS"
LIBS="$GLOOP_save_LIBS"
CPPFLAGS="$GLOOP_save_CPPFLAGS"
AC_LANG_RESTORE
])

6
thirdparty/carve-1.4.0/autogen.sh vendored Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
aclocal -I m4
autoheader
libtoolize -f -c --automake
automake --foreign -c -a
autoconf

99
thirdparty/carve-1.4.0/build/autoconf/compile vendored Executable file
View File

@ -0,0 +1,99 @@
#! /bin/sh
# Wrapper for compilers which do not understand `-c -o'.
# Copyright 1999, 2000 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Usage:
# compile PROGRAM [ARGS]...
# `-o FOO.o' is removed from the args passed to the actual compile.
prog=$1
shift
ofile=
cfile=
args=
while test $# -gt 0; do
case "$1" in
-o)
# configure might choose to run compile as `compile cc -o foo foo.c'.
# So we do something ugly here.
ofile=$2
shift
case "$ofile" in
*.o | *.obj)
;;
*)
args="$args -o $ofile"
ofile=
;;
esac
;;
*.c)
cfile=$1
args="$args $1"
;;
*)
args="$args $1"
;;
esac
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no `-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# `.c' file was seen then we are probably linking. That is also
# ok.
exec "$prog" $args
fi
# Name of file we expect compiler to create.
cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
# Create the lock directory.
# Note: use `[/.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d
while true; do
if mkdir $lockdir > /dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir $lockdir; exit 1" 1 2 15
# Run the compile.
"$prog" $args
status=$?
if test -f "$cofile"; then
mv "$cofile" "$ofile"
fi
rmdir $lockdir
exit $status

File diff suppressed because it is too large Load Diff

1658
thirdparty/carve-1.4.0/build/autoconf/config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

479
thirdparty/carve-1.4.0/build/autoconf/depcomp vendored Executable file
View File

@ -0,0 +1,479 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
# Copyright 1999, 2000, 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# `libtool' can also be set to `yes' or `no'.
if test -z "$depfile"; then
base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
dir=`echo "$object" | sed 's,/.*$,/,'`
if test "$dir" = "$object"; then
dir=
fi
# FIXME: should be _deps on DOS.
depfile="$dir.deps/$base"
fi
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
stat=$?
if test -f "$tmpdepfile"; then :
else
stripped=`echo "$stripped" | sed 's,^.*/,,'`
tmpdepfile="$stripped.u"
fi
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
if test -f "$tmpdepfile"; then
outname="$stripped.o"
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
tmpdepfile1="$dir.libs/$base.lo.d"
tmpdepfile2="$dir.libs/$base.d"
"$@" -Wc,-MD
else
tmpdepfile1="$dir$base.o.d"
tmpdepfile2="$dir$base.d"
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
if test -f "$tmpdepfile1"; then
tmpdepfile="$tmpdepfile1"
else
tmpdepfile="$tmpdepfile2"
fi
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
"$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no
for arg in "$@"; do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E |
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
"$@" || exit $?
IFS=" "
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0

View File

@ -0,0 +1,294 @@
#!/bin/sh
#
# install - install a program, script, or datafile
#
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd=$cpprog
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd=$stripprog
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "$0: no input file specified" >&2
exit 1
else
:
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d "$dst" ]; then
instcmd=:
chmodcmd=""
else
instcmd=$mkdirprog
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f "$src" ] || [ -d "$src" ]
then
:
else
echo "$0: $src does not exist" >&2
exit 1
fi
if [ x"$dst" = x ]
then
echo "$0: no destination specified" >&2
exit 1
else
:
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d "$dst" ]
then
dst=$dst/`basename "$src"`
else
:
fi
fi
## this sed command emulates the dirname command
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-$defaultIFS}"
oIFS=$IFS
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS=$oIFS
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp=$pathcomp$1
shift
if [ ! -d "$pathcomp" ] ;
then
$mkdirprog "$pathcomp"
else
:
fi
pathcomp=$pathcomp/
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd "$dst" &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename "$dst"`
else
dstfile=`basename "$dst" $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename "$dst"`
else
:
fi
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up temp files at exit.
trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
# Move or copy the file name to the temp name
$doit $instcmd "$src" "$dsttmp" &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
# Now remove or move aside any old file at destination location. We try this
# two ways since rm can't unlink itself on some systems and the destination
# file might be busy for other reasons. In this case, the final cleanup
# might fail but the new file should still install successfully.
{
if [ -f "$dstdir/$dstfile" ]
then
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
$doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
{
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
(exit 1); exit
}
else
:
fi
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
fi &&
# The final little trick to "correctly" pass the exit status to the exit trap.
{
(exit 0); exit
}

File diff suppressed because it is too large Load Diff

336
thirdparty/carve-1.4.0/build/autoconf/missing vendored Executable file
View File

@ -0,0 +1,336 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
case "$1" in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case "$1" in
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing 0.4 - GNU automake"
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
aclocal*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
fi
if [ -f "$file" ]; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit 1
fi
;;
makeinfo)
if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
# We have makeinfo, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
tar)
shift
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
fi
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case "$firstarg" in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case "$firstarg" in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0

View File

@ -0,0 +1,111 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain
errstatus=0
dirmode=""
usage="\
Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
# process command line arguments
while test $# -gt 0 ; do
case $1 in
-h | --help | --h*) # -h for help
echo "$usage" 1>&2
exit 0
;;
-m) # -m PERM arg
shift
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
dirmode=$1
shift
;;
--) # stop option processing
shift
break
;;
-*) # unknown option
echo "$usage" 1>&2
exit 1
;;
*) # first non-opt arg
break
;;
esac
done
for file
do
if test -d "$file"; then
shift
else
break
fi
done
case $# in
0) exit 0 ;;
esac
case $dirmode in
'')
if mkdir -p -- . 2>/dev/null; then
echo "mkdir -p -- $*"
exec mkdir -p -- "$@"
fi
;;
*)
if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
echo "mkdir -m $dirmode -p -- $*"
exec mkdir -m "$dirmode" -p -- "$@"
fi
;;
esac
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case $pathcomp in
-*) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
else
if test ! -z "$dirmode"; then
echo "chmod $dirmode $pathcomp"
lasterr=""
chmod "$dirmode" "$pathcomp" || lasterr=$?
if test ! -z "$lasterr"; then
errstatus=$lasterr
fi
fi
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# End:
# mkinstalldirs ends here

View File

@ -0,0 +1,9 @@
#include <ext/hash_set>
#include <ext/hash_map>
int main(int argc, char **argv) {
const __gnu_cxx::hash_map<int,int> a;
const __gnu_cxx::hash_set<int> b;
a.find(1);
b.find(1);
}

View File

@ -0,0 +1,9 @@
#include <unordered_set>
#include <unordered_map>
int main(int argc, char **argv) {
const std::unordered_map<int,int> a;
const std::unordered_set<int> b;
a.find(1);
b.find(1);
}

View File

@ -0,0 +1,10 @@
#include <tr1/unordered_set>
#include <tr1/unordered_map>
int main(int argc, char **argv) {
const std::tr1::unordered_map<int,int> a;
const std::tr1::unordered_set<int> b;
// make sure that the tr1 const find_node bug is fixed.
a.find(1);
b.find(1);
}

View File

@ -0,0 +1,10 @@
include_directories("${carve_SOURCE_DIR}/include")
include_directories("${carve_SOURCE_DIR}/external/GLOOP/include")
include_directories("${carve_SOURCE_DIR}/external/GLEW/include")
include_directories("${carve_SOURCE_DIR}/external/GLUI/include")
add_library(carve_fileformats STATIC read_ply.cpp write_ply.cpp)
add_library(carve_misc STATIC geometry.cpp)
if(CARVE_WITH_GUI)
add_library(carve_ui STATIC geom_draw.cpp scene.cpp)
endif(CARVE_WITH_GUI)

View File

@ -0,0 +1,29 @@
noinst_LTLIBRARIES = libcarve_fileformats.la libcarve_misc.la
noinst_HEADERS = geom_draw.hpp geometry.hpp opts.hpp read_ply.hpp rgb.hpp scene.hpp stringfuncs.hpp write_ply.hpp
CPPFLAGS += -I$(top_srcdir)/include @GL_CFLAGS@ @GLUT_CFLAGS@
CPPFLAGS += -I$(top_srcdir)/external/GLOOP/include
libcarve_fileformats_la_SOURCES = read_ply.cpp write_ply.cpp
libcarve_fileformats_la_LIBADD = $(top_srcdir)/external/GLOOP/libgloop-model.la
libcarve_fileformats_la_CPPFLAGS = -I$(top_srcdir)/external/GLOOP/include
libcarve_misc_la_SOURCES=geometry.cpp
if with_GUI
CPPFLAGS += -I$(top_srcdir)/external/GLEW/include
CPPFLAGS += -I$(top_srcdir)/external/GLUI/include
noinst_LTLIBRARIES += libcarve_ui.la
endif
libcarve_ui_la_SOURCES = geom_draw.cpp scene.cpp
libcarve_ui_la_LIBADD = $(top_srcdir)/external/GLUI/libglui.la

View File

@ -0,0 +1,615 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#if defined(HAVE_CONFIG_H)
# include <carve_config.h>
#endif
#include "geom_draw.hpp"
#include <carve/debug_hooks.hpp>
#include <gloop/gloopgl.hpp>
#include <gloop/gloopglu.hpp>
#include <gloop/gloopglut.hpp>
#include <fstream>
#include <string>
#include <time.h>
#if defined(__GNUC__)
#define __stdcall
#endif
#if defined(GLU_TESS_CALLBACK_VARARGS)
typedef GLvoid (_stdcall *GLUTessCallback)(...);
#else
typedef void (__stdcall *GLUTessCallback)();
#endif
carve::geom3d::Vector g_translation;
double g_scale = 1.0;
static inline void glVertex(double x, double y, double z) {
glVertex3f(g_scale * (x + g_translation.x),
g_scale * (y + g_translation.y),
g_scale * (z + g_translation.z));
}
static inline void glVertex(const carve::geom3d::Vector *v) {
glVertex3f(g_scale * (v->x + g_translation.x),
g_scale * (v->y + g_translation.y),
g_scale * (v->z + g_translation.z));
}
static inline void glVertex(const carve::geom3d::Vector &v) {
glVertex3f(g_scale * (v.x + g_translation.x),
g_scale * (v.y + g_translation.y),
g_scale * (v.z + g_translation.z));
}
static inline void glVertex(const carve::poly::Vertex<3> *v) {
glVertex(v->v);
}
static inline void glVertex(const carve::poly::Vertex<3> &v) {
glVertex(v.v);
}
class DebugHooks : public carve::csg::IntersectDebugHooks {
public:
virtual void drawIntersections(const carve::csg::VertexIntersections &vint);
virtual void drawOctree(const carve::csg::Octree &o);
virtual void drawPoint(const carve::geom3d::Vector *v,
float r, float g, float b, float a,
float rad);
virtual void drawEdge(const carve::geom3d::Vector *v1, const carve::geom3d::Vector *v2,
float rA, float gA, float bA, float aA,
float rB, float gB, float bB, float aB,
float thickness = 1.0);
virtual void drawFaceLoopWireframe(const std::vector<const carve::geom3d::Vector *> &face_loop,
const carve::geom3d::Vector &normal,
float r, float g, float b, float a,
bool inset = true);
virtual void drawFaceLoop(const std::vector<const carve::geom3d::Vector *> &face_loop,
const carve::geom3d::Vector &normal,
float r, float g, float b, float a,
bool offset = true,
bool lit = true);
virtual void drawFaceLoop2(const std::vector<const carve::geom3d::Vector *> &face_loop,
const carve::geom3d::Vector &normal,
float rF, float gF, float bF, float aF,
float rB, float gB, float bB, float aB,
bool offset = true,
bool lit = true);
};
void DebugHooks::drawPoint(const carve::geom3d::Vector *v,
float r, float g, float b, float a,
float rad) {
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glEnable(GL_POINT_SMOOTH);
glPointSize(rad);
glBegin(GL_POINTS);
glColor4f(r, g, b, a);
glVertex(v);
glEnd();
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
}
void DebugHooks::drawEdge(const carve::geom3d::Vector *v1, const carve::geom3d::Vector *v2,
float rA, float gA, float bA, float aA,
float rB, float gB, float bB, float aB,
float thickness) {
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glLineWidth(thickness);
glEnable(GL_LINE_SMOOTH);
glBegin(GL_LINES);
glColor4f(rA, gA, bA, aA);
glVertex(v1);
glColor4f(rB, gB, bB, aB);
glVertex(v2);
glEnd();
glDisable(GL_LINE_SMOOTH);
glLineWidth(1.0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
}
void DebugHooks::drawIntersections(const carve::csg::VertexIntersections &vint) {
glEnable(GL_POINT_SMOOTH);
glDisable(GL_DEPTH_TEST);
for (carve::csg::VertexIntersections::const_iterator
i = vint.begin(), e = vint.end();
i != e;
++i) {
float sz = 4.0 + (*i).second.size() * 3.0;
for (carve::csg::VertexIntersections::mapped_type::const_iterator
j = (*i).second.begin(), je = (*i).second.end(); j != je; ++j) {
glPointSize(sz);
sz -= 3.0;
switch ((*j).first.obtype | (*j).second.obtype) {
case 0: glColor4f(0,0,0,1); break;
case 1: glColor4f(0,0,1,1); break; // VERTEX - VERTEX
case 2: glColor4f(0,1,1,1); break; // EDGE - EDGE
case 3: glColor4f(1,0,0,1); break; // EDGE - VERTEX
case 4: glColor4f(0,0,0,1); break;
case 5: glColor4f(1,1,0,1); break; // FACE - VERTEX
case 6: glColor4f(0,1,0,1); break; // FACE - EDGE
case 7: glColor4f(0,0,0,1); break;
}
glBegin(GL_POINTS);
glVertex((*i).first);
glEnd();
}
}
glEnable(GL_DEPTH_TEST);
}
void drawCube(const carve::geom3d::Vector &a, const carve::geom3d::Vector &b) {
glBegin(GL_QUADS);
glNormal3f(0,0,-1);
glVertex(a.x, a.y, a.z);
glVertex(b.x, a.y, a.z);
glVertex(b.x, b.y, a.z);
glVertex(a.x, b.y, a.z);
glNormal3f(0,0,1);
glVertex(a.x, b.y, b.z);
glVertex(b.x, b.y, b.z);
glVertex(b.x, a.y, b.z);
glVertex(a.x, a.y, b.z);
glNormal3f(-1,0,0);
glVertex(a.x, a.y, a.z);
glVertex(a.x, b.y, a.z);
glVertex(a.x, b.y, b.z);
glVertex(a.x, a.y, b.z);
glNormal3f(1,0,0);
glVertex(b.x, a.y, b.z);
glVertex(b.x, b.y, b.z);
glVertex(b.x, b.y, a.z);
glVertex(b.x, a.y, a.z);
glNormal3f(0,-1,0);
glVertex(a.x, a.y, a.z);
glVertex(b.x, a.y, a.z);
glVertex(b.x, a.y, b.z);
glVertex(a.x, a.y, b.z);
glNormal3f(0,1,0);
glVertex(a.x, b.y, b.z);
glVertex(b.x, b.y, b.z);
glVertex(b.x, b.y, a.z);
glVertex(a.x, b.y, a.z);
glEnd();
}
static void drawCell(int level, carve::csg::Octree::Node *node) {
// we only want to draw leaf nodes
if (!node->hasChildren() && node->hasGeometry()) {
glColor3f(1,0,0);
drawCube(node->min, node->max);
}
}
void drawOctree(const carve::csg::Octree &o) {
glDisable(GL_LIGHTING);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDisable(GL_CULL_FACE);
o.iterateNodes(&drawCell);
glEnable(GL_LIGHTING);
}
void DebugHooks::drawOctree(const carve::csg::Octree &o) {
::drawOctree(o);
}
static void __stdcall _faceBegin(GLenum type, void *data) {
carve::poly::Face<3> *face = static_cast<carve::poly::Face<3> *>(data);
glBegin(type);
glNormal3f(face->plane_eqn.N.x, face->plane_eqn.N.y, face->plane_eqn.N.z);
}
static void __stdcall _faceVertex(void *vertex_data, void *data) {
std::pair<carve::geom3d::Vector, cRGBA> &vd(*static_cast<std::pair<carve::geom3d::Vector, cRGBA> *>(vertex_data));
glColor4f(vd.second.r, vd.second.g, vd.second.b, vd.second.a);
glVertex3f(vd.first.x, vd.first.y, vd.first.z);
}
static void __stdcall _faceEnd(void *data) {
glEnd();
}
void drawColourFace(carve::poly::Face<3> *face, const std::vector<cRGBA> &vc, bool offset) {
if (offset) {
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0.5, 0.5);
}
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
GLUtesselator *tess = gluNewTess();
gluTessCallback(tess, GLU_TESS_BEGIN_DATA, (GLUTessCallback)_faceBegin);
gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (GLUTessCallback)_faceVertex);
gluTessCallback(tess, GLU_TESS_END_DATA, (GLUTessCallback)_faceEnd);
gluTessBeginPolygon(tess, (void *)face);
gluTessBeginContour(tess);
std::vector<std::pair<carve::geom3d::Vector, cRGBA> > v;
v.resize(face->nVertices());
for (size_t i = 0, l = face->nVertices(); i != l; ++i) {
v[i] = std::make_pair(g_scale * (face->vertex(i)->v + g_translation), vc[i]);
gluTessVertex(tess, (GLdouble *)v[i].first.v, (GLvoid *)&v[i]);
}
gluTessEndContour(tess);
gluTessEndPolygon(tess);
gluDeleteTess(tess);
if (offset) {
glDisable(GL_POLYGON_OFFSET_FILL);
}
}
void drawFace(carve::poly::Face<3> *face, cRGBA fc, bool offset) {
if (offset) {
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0.5, 0.5);
}
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
GLUtesselator *tess = gluNewTess();
gluTessCallback(tess, GLU_TESS_BEGIN_DATA, (GLUTessCallback)_faceBegin);
gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (GLUTessCallback)_faceVertex);
gluTessCallback(tess, GLU_TESS_END_DATA, (GLUTessCallback)_faceEnd);
gluTessBeginPolygon(tess, (void *)face);
gluTessBeginContour(tess);
std::vector<std::pair<carve::geom3d::Vector, cRGBA> > v;
v.resize(face->nVertices());
for (size_t i = 0, l = face->nVertices(); i != l; ++i) {
v[i] = std::make_pair(g_scale * (face->vertex(i)->v + g_translation), fc);
gluTessVertex(tess, (GLdouble *)v[i].first.v, (GLvoid *)&v[i]);
}
gluTessEndContour(tess);
gluTessEndPolygon(tess);
gluDeleteTess(tess);
if (offset) {
glDisable(GL_POLYGON_OFFSET_FILL);
}
}
void drawFaceWireframe(carve::poly::Face<3> *face, bool normal, float r, float g, float b) {
glDisable(GL_LIGHTING);
glDepthMask(GL_FALSE);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDisable(GL_CULL_FACE);
glColor4f(r, g, b ,1.0);
glBegin(GL_POLYGON);
glColor4f(r, g, b, 0.1f);
for (size_t i = 0, l = face->nVertices(); i != l; ++i) {
glVertex(face->vertex(i));
}
glEnd();
glDisable(GL_DEPTH_TEST);
glColor4f(r, g, b ,0.01);
glBegin(GL_POLYGON);
glColor4f(r, g, b, 0.01f);
for (size_t i = 0, l = face->nVertices(); i != l; ++i) {
glVertex(face->vertex(i));
}
glEnd();
glLineWidth(3.0f);
glColor4f(1.0, 0.0, 0.0, 1.0);
glBegin(GL_LINES);
for (size_t i = 0, l = face->nEdges(); i != l; ++i) {
if (static_cast<const carve::poly::Polyhedron *>(face->owner)->connectedFace(face, face->edge(i)) == NULL) {
glVertex(face->edge(i)->v1);
glVertex(face->edge(i)->v2);
}
}
glEnd();
glLineWidth(1.0f);
glEnable(GL_DEPTH_TEST);
if (normal) {
glBegin(GL_LINES);
glColor4f(1.0, 1.0, 0.0, 1.0);
glVertex(face->centroid());
glColor4f(1.0, 1.0, 0.0, 0.0);
glVertex(face->centroid() + 1 / g_scale * face->plane_eqn.N);
glEnd();
}
glDepthMask(GL_TRUE);
glEnable(GL_LIGHTING);
}
void drawFaceWireframe(carve::poly::Face<3> *face, bool normal) {
drawFaceWireframe(face, normal, 0,0,0);
}
void drawFaceNormal(carve::poly::Face<3> *face, float r, float g, float b) {
glDisable(GL_LIGHTING);
glDepthMask(GL_FALSE);
glLineWidth(1.0f);
glEnable(GL_DEPTH_TEST);
glBegin(GL_LINES);
glColor4f(1.0, 1.0, 0.0, 1.0);
glVertex(face->centroid());
glColor4f(1.0, 1.0, 0.0, 0.0);
glVertex(face->centroid() + 1 / g_scale * face->plane_eqn.N);
glEnd();
glDepthMask(GL_TRUE);
glEnable(GL_LIGHTING);
}
void drawFaceNormal(carve::poly::Face<3> *face) {
drawFaceNormal(face, 0,0,0);
}
void DebugHooks::drawFaceLoopWireframe(const std::vector<const carve::geom3d::Vector *> &face_loop,
const carve::geom3d::Vector &normal,
float r, float g, float b, float a,
bool inset) {
glDisable(GL_DEPTH_TEST);
const size_t S = face_loop.size();
double INSET = 0.005;
if (inset) {
glColor4f(r, g, b, a / 2.0);
glBegin(GL_LINE_LOOP);
for (size_t i = 0; i < S; ++i) {
size_t i_pre = (i + S - 1) % S;
size_t i_post = (i + 1) % S;
carve::geom3d::Vector v1 = (*face_loop[i] - *face_loop[i_pre]).normalized();
carve::geom3d::Vector v2 = (*face_loop[i] - *face_loop[i_post]).normalized();
carve::geom3d::Vector n1 = cross(normal, v1);
carve::geom3d::Vector n2 = cross(v2, normal);
carve::geom3d::Vector v = *face_loop[i];
carve::geom3d::Vector p1 = v + INSET * n1;
carve::geom3d::Vector p2 = v + INSET * n2;
carve::geom3d::Vector i1 , i2;
double mu1, mu2;
carve::geom3d::Vector p;
if (carve::geom3d::rayRayIntersection(carve::geom3d::Ray(v1, p1), carve::geom3d::Ray(v2, p2), i1, i2, mu1, mu2)) {
p = (i1 + i2) / 2;
} else {
p = (p1 + p2) / 2;
}
glVertex(&p);
}
glEnd();
}
glColor4f(r, g, b, a);
glBegin(GL_LINE_LOOP);
for (unsigned i = 0; i < S; ++i) {
glVertex(face_loop[i]);
}
glEnd();
glColor4f(r, g, b, a);
glPointSize(3.0);
glBegin(GL_POINTS);
for (unsigned i = 0; i < S; ++i) {
carve::geom3d::Vector p = *face_loop[i];
glVertex(face_loop[i]);
}
glEnd();
glEnable(GL_DEPTH_TEST);
}
void DebugHooks::drawFaceLoop(const std::vector<const carve::geom3d::Vector *> &face_loop,
const carve::geom3d::Vector &normal,
float r, float g, float b, float a,
bool offset,
bool lit) {
if (lit) glEnable(GL_LIGHTING); else glDisable(GL_LIGHTING);
if (offset) {
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0.5, 0.5);
}
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
GLUtesselator *tess = gluNewTess();
gluTessCallback(tess, GLU_TESS_BEGIN, (GLUTessCallback)glBegin);
gluTessCallback(tess, GLU_TESS_VERTEX, (GLUTessCallback)glVertex3dv);
gluTessCallback(tess, GLU_TESS_END, (GLUTessCallback)glEnd);
glNormal3f(normal.x, normal.y, normal.z);
glColor4f(r, g, b, a);
gluTessBeginPolygon(tess, (void *)NULL);
gluTessBeginContour(tess);
std::vector<carve::geom3d::Vector> v;
v.resize(face_loop.size());
for (size_t i = 0, l = face_loop.size(); i != l; ++i) {
v[i] = g_scale * (*face_loop[i] + g_translation);
gluTessVertex(tess, (GLdouble *)v[i].v, (GLvoid *)v[i].v);
}
gluTessEndContour(tess);
gluTessEndPolygon(tess);
gluDeleteTess(tess);
if (offset) {
glDisable(GL_POLYGON_OFFSET_FILL);
}
glEnable(GL_LIGHTING);
}
void DebugHooks::drawFaceLoop2(const std::vector<const carve::geom3d::Vector *> &face_loop,
const carve::geom3d::Vector &normal,
float rF, float gF, float bF, float aF,
float rB, float gB, float bB, float aB,
bool offset,
bool lit) {
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
drawFaceLoop(face_loop, normal, rF, gF, bF, aF, offset, lit);
glCullFace(GL_FRONT);
drawFaceLoop(face_loop, normal, rB, gB, bB, aB, offset, lit);
glCullFace(GL_BACK);
}
void drawPolyhedron(carve::poly::Polyhedron *poly, float r, float g, float b, float a, bool offset, int group) {
if (offset) {
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0.5, 0.5);
}
glColor4f(r, g, b, a);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBegin(GL_TRIANGLES);
for (size_t i = 0, l = poly->faces.size(); i != l; ++i) {
carve::poly::Face<3> &f = poly->faces[i];
if (group == -1 || f.manifold_id == group) {
if (f.nVertices() == 3) {
glNormal3dv(f.plane_eqn.N.v);
glVertex(f.vertex(0));
glVertex(f.vertex(1));
glVertex(f.vertex(2));
}
}
}
glEnd();
for (size_t i = 0, l = poly->faces.size(); i != l; ++i) {
carve::poly::Face<3> &f = poly->faces[i];
if (group == -1 || f.manifold_id == group) {
if (f.nVertices() != 3) {
drawFace(&poly->faces[i], cRGBA(r, g, b, a), false);
}
}
}
if (offset) {
glDisable(GL_POLYGON_OFFSET_FILL);
}
}
void drawEdges(carve::poly::Polyhedron *poly, double alpha, int group) {
glBegin(GL_LINES);
for (size_t i = 0, l = poly->edges.size(); i != l; ++i) {
if (group == -1 || poly->edgeOnManifold(&poly->edges[i], group)) {
const std::vector<const carve::poly::Polyhedron::face_t *> &ef = poly->connectivity.edge_to_face[i];
if (std::find(ef.begin(), ef.end(), (carve::poly::Polyhedron::face_t *)NULL) != ef.end()) {
glColor4f(1.0, 1.0, 0.0, alpha);
} else if (ef.size() > 2) {
glColor4f(0.0, 1.0, 1.0, alpha);
} else {
glColor4f(1.0, 0.0, 0.0, alpha);
}
glVertex(poly->edges[i].v1->v);
glVertex(poly->edges[i].v2->v);
}
}
glEnd();
}
void drawPolyhedronWireframe(carve::poly::Polyhedron *poly, bool normal, int group) {
if (normal) {
for (size_t i = 0, l = poly->faces.size(); i != l; ++i) {
carve::poly::Face<3> &f = poly->faces[i];
if (group == -1 || f.manifold_id == group) {
drawFaceNormal(&f);
}
}
}
glDisable(GL_LIGHTING);
glDepthMask(GL_FALSE);
glDisable(GL_DEPTH_TEST);
drawEdges(poly, 0.2, group);
glEnable(GL_DEPTH_TEST);
drawEdges(poly, 0.8, group);
glDepthMask(GL_TRUE);
glEnable(GL_LIGHTING);
}
void installDebugHooks() {
if (carve::csg::intersect_debugEnabled()) {
carve::csg::intersect_installDebugHooks(new DebugHooks());
}
}

View File

@ -0,0 +1,41 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/vector.hpp>
#include <carve/poly.hpp>
#include <carve/octree_decl.hpp>
#include <carve/octree_impl.hpp>
#include "rgb.hpp"
void drawPolyhedronWireframe(carve::poly::Polyhedron *poly, bool normal = true, int group = -1);
void drawPolyhedron(carve::poly::Polyhedron *poly, float r, float g, float b, float a, bool offset = false, int group = -1);
void drawFace(carve::poly::Face<3> *face, cRGBA fc, bool offset);
void drawColourFace(carve::poly::Face<3> *face, const std::vector<cRGBA> &vc, bool offset);
void installDebugHooks();
void drawCube(const carve::geom3d::Vector &, const carve::geom3d::Vector &);
void drawOctree(const carve::csg::Octree &);
extern carve::geom3d::Vector g_translation;
extern double g_scale;

View File

@ -0,0 +1,244 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#if defined(HAVE_CONFIG_H)
# include <carve_config.h>
#endif
#include "geometry.hpp"
#include <carve/input.hpp>
carve::poly::Polyhedron *makeCube(const carve::math::Matrix &transform) {
carve::input::PolyhedronData data;
data.addVertex(transform * carve::geom::VECTOR(+1.0, +1.0, +1.0));
data.addVertex(transform * carve::geom::VECTOR(-1.0, +1.0, +1.0));
data.addVertex(transform * carve::geom::VECTOR(-1.0, -1.0, +1.0));
data.addVertex(transform * carve::geom::VECTOR(+1.0, -1.0, +1.0));
data.addVertex(transform * carve::geom::VECTOR(+1.0, +1.0, -1.0));
data.addVertex(transform * carve::geom::VECTOR(-1.0, +1.0, -1.0));
data.addVertex(transform * carve::geom::VECTOR(-1.0, -1.0, -1.0));
data.addVertex(transform * carve::geom::VECTOR(+1.0, -1.0, -1.0));
data.addFace(0, 1, 2, 3);
data.addFace(7, 6, 5, 4);
data.addFace(0, 4, 5, 1);
data.addFace(1, 5, 6, 2);
data.addFace(2, 6, 7, 3);
data.addFace(3, 7, 4, 0);
return new carve::poly::Polyhedron(data.points, data.getFaceCount(), data.faceIndices);
}
static bool _all(int x, int y, int z) {
return true;
}
carve::poly::Polyhedron *makeSubdividedCube(int sub_x, int sub_y, int sub_z,
bool (*inc)(int, int, int), const carve::math::Matrix &transform) {
carve::input::PolyhedronData data;
if (inc == NULL) inc = _all;
data.reserveVertices((sub_x + 1) * (sub_y + 1) * (sub_z + 1));
for (int _z = 0; _z < sub_z + 1; ++_z) {
double z = 1.0 - 2.0 * _z / sub_z;
for (int _y = 0; _y < sub_y + 1; ++_y) {
double y = 1.0 - 2.0 * _y / sub_y;
for (int _x = 0; _x < sub_x + 1; ++_x) {
double x = 1.0 - 2.0 * _x / sub_x;
data.addVertex(transform * carve::geom::VECTOR(x, y, z));
}
}
}
#define OK(x, y, z) ((x) >= 0 && (x) < sub_x && (y) >= 0 && (y) < sub_y && (z) >= 0 && (z) < sub_z)
#define I(x, y, z) ((x) + (y) * (sub_x + 1) + (z) * ((sub_x + 1) * (sub_y + 1)))
#define FACE(a, b, c, d) data.addFace(idx[a], idx[b], idx[c], idx[d])
for (int _z = 0; _z < sub_z; ++_z) {
for (int _y = 0; _y < sub_y; ++_y) {
for (int _x = 0; _x < sub_x; ++_x) {
int idx[8] = {
I(_x, _y, _z),
I(_x+1, _y, _z),
I(_x+1, _y+1, _z),
I(_x, _y+1, _z),
I(_x, _y, _z+1),
I(_x+1, _y, _z+1),
I(_x+1, _y+1, _z+1),
I(_x, _y+1, _z+1)
};
if (!inc(_x, _y, _z)) continue;
if (!OK(_x - 1, _y, _z) || !inc(_x - 1, _y, _z)) FACE(3, 7, 4, 0);
if (!OK(_x + 1, _y, _z) || !inc(_x + 1, _y, _z)) FACE(1, 5, 6, 2);
if (!OK(_x, _y - 1, _z) || !inc(_x, _y - 1, _z)) FACE(0, 4, 5, 1);
if (!OK(_x, _y + 1, _z) || !inc(_x, _y + 1, _z)) FACE(2, 6, 7, 3);
if (!OK(_x, _y, _z - 1) || !inc(_x, _y, _z - 1)) FACE(0, 1, 2, 3);
if (!OK(_x, _y, _z + 1) || !inc(_x, _y, _z + 1)) FACE(7, 6, 5, 4);
}
}
}
return data.create();
}
carve::poly::Polyhedron *makeDoubleCube(const carve::math::Matrix &transform) {
carve::input::PolyhedronData data;
data.addVertex(transform * carve::geom::VECTOR(-1.0, -1.0, -0.5));
data.addVertex(transform * carve::geom::VECTOR(-1.0, -1.0, +0.5));
data.addVertex(transform * carve::geom::VECTOR(+0.0, -1.0, -0.5));
data.addVertex(transform * carve::geom::VECTOR(+0.0, -1.0, +0.5));
data.addVertex(transform * carve::geom::VECTOR(-1.0, +0.0, -0.5));
data.addVertex(transform * carve::geom::VECTOR(-1.0, +0.0, +0.5));
data.addVertex(transform * carve::geom::VECTOR(+0.0, +0.0, -0.5));
data.addVertex(transform * carve::geom::VECTOR(+0.0, +0.0, +0.5));
data.addVertex(transform * carve::geom::VECTOR(+0.0, +1.0, -0.5));
data.addVertex(transform * carve::geom::VECTOR(+0.0, +1.0, +0.5));
data.addVertex(transform * carve::geom::VECTOR(+1.0, +0.0, -0.5));
data.addVertex(transform * carve::geom::VECTOR(+1.0, +0.0, +0.5));
data.addVertex(transform * carve::geom::VECTOR(+1.0, +1.0, -0.5));
data.addVertex(transform * carve::geom::VECTOR(+1.0, +1.0, +0.5));
data.addFace(0, 4, 6, 2);
data.addFace(6, 8, 12, 10);
data.addFace(1, 3, 7, 5);
data.addFace(7, 11, 13, 9);
data.addFace(1, 5, 4, 0);
data.addFace(3, 1, 0, 2);
data.addFace(7, 3, 2, 6);
data.addFace(5, 7, 6, 4);
data.addFace(11, 7, 6, 10);
data.addFace(13, 11, 10, 12);
data.addFace(9, 13, 12, 8);
data.addFace(7, 9, 8, 6);
return data.create();
}
carve::poly::Polyhedron *makeTorus(int slices,
int rings,
double rad1,
double rad2,
const carve::math::Matrix &transform) {
carve::input::PolyhedronData data;
data.reserveVertices(slices * rings);
for (int i = 0; i < slices; i++) {
double a1 = i * M_PI * 2.0 / slices;
double dy = cos(a1);
double dx = sin(a1);
for (int j = 0; j < rings; j++) {
double a2 = j * M_PI * 2.0 / rings;
double x = dx * (rad1 + cos(a2) * rad2);
double y = dy * (rad1 + cos(a2) * rad2);
double z = sin(a2) * rad2;
data.addVertex(transform * carve::geom::VECTOR(x, y, z));
}
}
#define V(i, j) ((i) * rings + (j))
data.reserveFaces(slices * rings, 4);
for (int i = 0; i < slices; i++) {
int i2 = (i + 1) % slices;
for (int j = 0; j < rings; j++) {
int j2 = (j + 1) % rings;
data.addFace(V(i, j), V(i, j2), V(i2, j2), V(i2, j));
}
}
#undef V
return data.create();
}
carve::poly::Polyhedron *makeCylinder(int slices,
double rad,
double height,
const carve::math::Matrix &transform) {
carve::input::PolyhedronData data;
data.reserveVertices(slices * 2 + 2);
data.addVertex(transform * carve::geom::VECTOR(0, 0, +height/2));
data.addVertex(transform * carve::geom::VECTOR(0, 0, -height/2));
for (int i = 0; i < slices; i++) {
double a1 = i * M_PI * 2.0 / slices;
double y = cos(a1) * rad;
double x = sin(a1) * rad;
data.addVertex(transform * carve::geom::VECTOR(x, y, +height/2));
data.addVertex(transform * carve::geom::VECTOR(x, y, -height/2));
}
data.reserveFaces(slices * 3, 4);
for (int i = 0; i < slices; i++) {
data.addFace(0,
2 + ((i+1) % slices) * 2,
2 + i * 2);
}
for (int i = 0; i < slices; i++) {
data.addFace(2 + i * 2,
2 + ((i+1) % slices) * 2,
3 + ((i+1) % slices) * 2,
3 + i * 2);
}
for (int i = 0; i < slices; i++) {
data.addFace(1,
3 + i * 2,
3 + ((i+1) % slices) * 2);
}
return data.create();
}
carve::poly::Polyhedron *makeCone(int slices,
double rad,
double height,
const carve::math::Matrix &transform) {
carve::input::PolyhedronData data;
data.reserveVertices(slices + 2);
data.addVertex(transform * carve::geom::VECTOR(0, 0, +height/2));
data.addVertex(transform * carve::geom::VECTOR(0, 0, -height/2));
for (int i = 0; i < slices; i++) {
double a1 = i * M_PI * 2.0 / slices;
double y = cos(a1) * rad;
double x = sin(a1) * rad;
data.addVertex(transform * carve::geom::VECTOR(x, y, -height/2));
}
data.reserveFaces(slices * 2, 3);
for (int i = 0; i < slices; i++) {
data.addFace(0,
2 + ((i+1) % slices),
2 + i);
}
for (int i = 0; i < slices; i++) {
data.addFace(1,
2 + i,
2 + ((i+1) % slices));
}
return data.create();
}

View File

@ -0,0 +1,46 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/poly.hpp>
#include <carve/matrix.hpp>
#ifdef WIN32
#undef rad1
#undef rad2
#endif
carve::poly::Polyhedron *makeCube(const carve::math::Matrix &transform = carve::math::Matrix());
carve::poly::Polyhedron *makeSubdividedCube(int sub_x = 3, int sub_y = 3, int sub_z = 3,
bool (*inc)(int, int, int) = NULL, const carve::math::Matrix &transform = carve::math::Matrix());
carve::poly::Polyhedron *makeDoubleCube(const carve::math::Matrix &transform = carve::math::Matrix());
carve::poly::Polyhedron *makeTorus(int slices,
int rings,
double rad1,
double rad2,
const carve::math::Matrix &transform = carve::math::Matrix());
carve::poly::Polyhedron *makeCylinder(int slices,
double rad,
double height,
const carve::math::Matrix &transform = carve::math::Matrix());
carve::poly::Polyhedron *makeCone(int slices,
double rad,
double height,
const carve::math::Matrix &transform = carve::math::Matrix());

246
thirdparty/carve-1.4.0/common/opts.hpp vendored Normal file
View File

@ -0,0 +1,246 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <string>
#include <list>
#include <vector>
#include <iomanip>
#include <iostream>
#include "stringfuncs.hpp"
namespace opt {
struct Help {
std::string long_opt;
std::string short_opt;
bool arg;
std::string text;
Help(const std::string &_long_opt, const std::string &_short_opt, bool _arg, const std::string &_text) :
long_opt(_long_opt), short_opt(_short_opt), arg(_arg), text(_text) {
}
};
struct Short {
char ch;
bool arg;
std::string help;
Short(char _ch, bool _arg, const std::string &_help) : ch(_ch), arg(_arg), help(_help) {}
};
struct Long {
std::string str;
bool arg;
std::string help;
Long(const std::string &_str, bool _arg, const std::string &_help) : str(_str), arg(_arg), help(_help) {}
};
struct exception {
private:
mutable std::string err;
mutable std::ostringstream accum;
public:
exception(const std::string &e) : err(e), accum() { }
exception() : err(), accum() { }
exception(const exception &e) : err(e.str()), accum() { }
const std::string &str() const {
if (accum.tellp()) {
err = accum.str();
accum.str("");
}
return err;
}
template<typename T>
exception &operator<<(const T &t) {
accum << t;
return *this;
}
};
class Parser {
protected:
std::list<Short> short_opts;
std::list<Long> long_opts;
std::list<Help> help_text;
std::string progname;
virtual void help(std::ostream &out) {
size_t max_long = 0;
size_t max_short = 0;
for (std::list<Help>::iterator i = help_text.begin(); i != help_text.end(); ++i) {
max_long = std::max(max_long, (*i).long_opt.size());
max_short = std::max(max_short, (*i).short_opt.size());
}
out << usageStr() << std::endl;
out << std::setfill(' ');
for (std::list<Help>::iterator i = help_text.begin(); i != help_text.end(); ++i) {
out.setf(std::ios::left);
out << std::setw(max_long + 1) << (*i).long_opt << std::setw(max_short + 1) << (*i).short_opt;
if ((*i).arg) {
out << "{arg} ";
} else {
out << " ";
}
out << (*i).text << std::endl;
}
}
virtual std::string usageStr() {
return std::string ("Usage: ") + progname + std::string(" [options] [args]");
};
virtual void optval(const std::string &o, const std::string &v) {
}
virtual void arg(const std::string &a) {
}
void long_opt(std::vector<std::string>::const_iterator &i, const std::vector<std::string>::const_iterator &e) {
const std::string &a(*i);
std::string opt, val;
bool has_argopt;
std::string::size_type eq = a.find('=');
has_argopt = eq != std::string::npos;
if (has_argopt) {
opt = a.substr(2, eq - 2);
val = a.substr(eq + 1);
} else {
opt = a.substr(2);
val = "";
}
for (std::list<Long>::iterator j = long_opts.begin(), je = long_opts.end(); j != je; ++j) {
if ((*j).str == opt) {
if (!(*j).arg && has_argopt) throw exception() << "unexpected argument for option --" << (*j).str << ".";
if ((*j).arg) {
if (++i == e) throw exception() << "missing argument for option --" << (*j).str << ".";
val = *i;
}
optval("--" + opt, val);
++i;
return;
}
}
throw exception() << "unrecognised option --" << opt << ".";
}
void short_opt(std::vector<std::string>::const_iterator &i, const std::vector<std::string>::const_iterator &e) {
const std::string &a(*i);
for (std::string::size_type j = 1; j < a.size(); ++j) {
for (std::list<Short>::iterator k = short_opts.begin(), ke = short_opts.end(); k != ke; ++k) {
if ((*k).ch == a[j]) {
if ((*k).arg) {
if (j < a.size() - 1) {
optval("-" + a.substr(j, 1), a.substr(j + 1));
j = a.size() - 1;
} else {
if (++i == e) throw exception() << "missing argument for option -" << a[j] << ".";
optval("-" + a.substr(j, 1), *i);
}
} else {
optval("-" + a.substr(j, 1), "");
}
goto found;
}
}
throw exception() << "unrecognised option -" << a[j] << ".";
found:;
}
++i;
}
public:
Parser() {
}
virtual ~Parser() {
}
Parser &option(const std::string &str, char ch, bool arg, const std::string &help) {
long_opts.push_back(Long(str, arg, help));
short_opts.push_back(Short(ch, arg, help));
help_text.push_back(Help("--" + str, std::string("-") + ch, arg, help));
return *this;
}
Parser &option(const std::string &str, bool arg, const std::string &help) {
long_opts.push_back(Long(str, arg, help));
help_text.push_back(Help("--" + str, "", arg, help));
return *this;
}
Parser &option(char ch, bool arg, const std::string &help) {
short_opts.push_back(Short(ch, arg, help));
help_text.push_back(Help("", std::string("-") + ch, arg, help));
return *this;
}
bool parse(const std::string &pn, const std::vector<std::string> &opts) {
try {
progname = pn;
std::vector<std::string>::const_iterator i = opts.begin();
std::vector<std::string>::const_iterator e = opts.end();
while (i != e) {
const std::string &a(*i);
if (a[0] == '-') {
if (a == "-" || a == "--") { ++i; break; }
if (a[1] == '-') {
long_opt(i, e);
} else {
short_opt(i, e);
}
} else {
break;
}
}
while (i != e) { arg(*i++); }
return true;
} catch (exception e) {
std::cerr << e.str() << std::endl;
help(std::cerr);
return false;
}
}
bool parse(int argc, char **argv) {
std::vector<std::string> opts(argc-1);
for (int i = 1; i < argc; ++i) {
opts[i-1] = argv[i];
}
return parse(argv[0], opts);
}
};
}

View File

@ -0,0 +1,355 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#if defined(HAVE_CONFIG_H)
# include <carve_config.h>
#endif
#include <carve/input.hpp>
#include <gloop/model/stream.hpp>
#include <gloop/model/ply_format.hpp>
#include <gloop/model/obj_format.hpp>
#include <gloop/model/vtk_format.hpp>
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#ifndef WIN32
# include <stdint.h>
#endif
namespace {
struct line : public gloop::stream::null_reader {
carve::input::PolylineSetData *data;
line(carve::input::PolylineSetData *_data) : data(_data) { }
virtual void length(int len) {
}
virtual void next() {
data->beginPolyline();
}
virtual void end() {
}
carve::input::PolylineSetData::polyline_data_t &curr() const {
return data->polylines.back();
}
};
struct line_closed : public gloop::stream::reader<bool> {
line *l;
line_closed(line *_l) : l(_l) { }
virtual void value(bool val) { l->curr().first = val; }
};
struct line_idx : public gloop::stream::reader<int> {
line *l;
line_idx(line *_l) : l(_l) { }
virtual void length(size_t len) { if (l) l->curr().second.reserve(len); }
virtual void value(int val) { l->curr().second.push_back(val); }
};
template<typename container_t>
struct vertex : public gloop::stream::null_reader {
container_t &container;
vertex(container_t &_container) : container(_container) {
}
virtual void next() {
container.push_back(carve::geom3d::Vector());
}
virtual void length(int l) {
if (l > 0) container.reserve(container.size() + l);
}
virtual void end() {
}
carve::geom3d::Vector &curr() const {
return container.back();
}
};
template<typename container_t>
vertex<container_t> *vertex_inserter(container_t &container) { return new vertex<container_t>(container); }
template<int idx, typename curr_t>
struct vertex_component : public gloop::stream::reader<double> {
const curr_t *i;
vertex_component(const curr_t *_i) : i(_i) { }
virtual void value(double val) { i->curr().v[idx] = val; }
};
template<int idx, typename curr_t>
vertex_component<idx, curr_t> *vertex_component_inserter(const curr_t *i) { return new vertex_component<idx, curr_t>(i); }
struct face : public gloop::stream::null_reader {
carve::input::PolyhedronData *data;
face(carve::input::PolyhedronData *_data) : data(_data) {
}
virtual void length(int l) {
if (l > 0) data->reserveFaces(l, 3);
}
};
struct face_idx : public gloop::stream::reader<int> {
carve::input::PolyhedronData *data;
mutable std::vector<int> vidx;
face_idx(carve::input::PolyhedronData *_data) : data(_data), vidx() { }
virtual void length(int l) { vidx.clear(); vidx.reserve(l); }
virtual void value(int val) { vidx.push_back(val); }
virtual void end() { data->addFace(vidx.begin(), vidx.end()); }
};
struct tristrip_idx : public gloop::stream::reader<int> {
carve::input::PolyhedronData *data;
mutable int a, b, c;
mutable bool clk;
tristrip_idx(carve::input::PolyhedronData *_data) : data(_data), a(-1), b(-1), c(-1), clk(true) { }
virtual void value(int val) {
a = b; b = c; c = val;
if (a == -1 || b == -1 || c == -1) {
clk = true;
} else {
if (clk) {
data->addFace(a, b, c);
} else {
data->addFace(c, b, a);
}
clk = !clk;
}
}
virtual void length(int len) {
data->reserveFaces(len - 2, 3);
}
};
struct begin_pointset : public gloop::stream::null_reader {
gloop::stream::model_reader &sr;
carve::input::Input &inputs;
carve::input::PointSetData *data;
begin_pointset(gloop::stream::model_reader &_sr, carve::input::Input &_inputs) : sr(_sr), inputs(_inputs) {
}
~begin_pointset() {
}
virtual void begin() {
data = new carve::input::PointSetData();
vertex<std::vector<carve::geom3d::Vector> > *vi = vertex_inserter(data->points);
sr.addReader("pointset.vertex", vi);
sr.addReader("pointset.vertex.x", vertex_component_inserter<0>(vi));
sr.addReader("pointset.vertex.y", vertex_component_inserter<1>(vi));
sr.addReader("pointset.vertex.z", vertex_component_inserter<2>(vi));
}
virtual void end() {
std::cerr << "pointset complete" << std::endl;
inputs.addDataBlock(data);
}
virtual void fail() {
delete data;
}
};
struct begin_polyline : public gloop::stream::null_reader {
gloop::stream::model_reader &sr;
carve::input::Input &inputs;
carve::input::PolylineSetData *data;
begin_polyline(gloop::stream::model_reader &_sr, carve::input::Input &_inputs) : sr(_sr), inputs(_inputs) {
}
~begin_polyline() {
}
virtual void begin() {
data = new carve::input::PolylineSetData();
vertex<std::vector<carve::geom3d::Vector> > *vi = vertex_inserter(data->points);
sr.addReader("polyline.vertex", vi);
sr.addReader("polyline.vertex.x", vertex_component_inserter<0>(vi));
sr.addReader("polyline.vertex.y", vertex_component_inserter<1>(vi));
sr.addReader("polyline.vertex.z", vertex_component_inserter<2>(vi));
line *li = new line(data);
sr.addReader("polyline.polyline", li);
sr.addReader("polyline.polyline.closed", new line_closed(li));
sr.addReader("polyline.polyline.vertex_indices", new line_idx(li));
}
virtual void end() {
inputs.addDataBlock(data);
}
virtual void fail() {
delete data;
}
};
struct begin_polyhedron : public gloop::stream::null_reader {
gloop::stream::model_reader &sr;
carve::input::Input &inputs;
carve::input::PolyhedronData *data;
begin_polyhedron(gloop::stream::model_reader &_sr, carve::input::Input &_inputs) : sr(_sr), inputs(_inputs) {
}
~begin_polyhedron() {
}
virtual void begin() {
data = new carve::input::PolyhedronData();
vertex<std::vector<carve::geom3d::Vector> > *vi = vertex_inserter(data->points);
sr.addReader("polyhedron.vertex", vi);
sr.addReader("polyhedron.vertex.x", vertex_component_inserter<0>(vi));
sr.addReader("polyhedron.vertex.y", vertex_component_inserter<1>(vi));
sr.addReader("polyhedron.vertex.z", vertex_component_inserter<2>(vi));
sr.addReader("polyhedron.face", new face(data));
sr.addReader("polyhedron.face.vertex_indices", new face_idx(data));
sr.addReader("polyhedron.tristrips.vertex_indices", new tristrip_idx(data));
}
virtual void end() {
inputs.addDataBlock(data);
}
virtual void fail() {
delete data;
}
};
void modelSetup(carve::input::Input &inputs, gloop::stream::model_reader &model) {
model.addReader("polyhedron", new begin_polyhedron(model, inputs));
model.addReader("polyline", new begin_polyline(model, inputs));
model.addReader("pointset", new begin_pointset(model, inputs));
}
}
template<typename filetype_t>
bool readFile(std::istream &in, carve::input::Input &inputs, const carve::math::Matrix &transform) {
filetype_t f;
modelSetup(inputs, f);
if (!f.read(in)) return false;
inputs.transform(transform);
return true;
}
template<typename filetype_t>
carve::poly::Polyhedron *readFile(std::istream &in, const carve::math::Matrix &transform) {
carve::input::Input inputs;
if (!readFile<filetype_t>(in, inputs, transform)) {
return false;
}
for (std::list<carve::input::Data *>::const_iterator i = inputs.input.begin(); i != inputs.input.end(); ++i) {
carve::poly::Polyhedron *poly = inputs.create<carve::poly::Polyhedron>(*i);
if (poly) return poly;
}
return NULL;
}
template<typename filetype_t>
bool readFile(const std::string &in_file,
carve::input::Input &inputs,
const carve::math::Matrix &transform = carve::math::Matrix::IDENT()) {
std::ifstream in(in_file.c_str(),std::ios_base::binary | std::ios_base::in);
if (!in.is_open()) {
std::cerr << "File '" << in_file << "' could not be opened." << std::endl;
return false;
}
std::cerr << "Loading " << in_file << "'" << std::endl;
return readFile<filetype_t>(in, inputs, transform);
}
template<typename filetype_t>
carve::poly::Polyhedron* readFile(const std::string &in_file,
const carve::math::Matrix &transform = carve::math::Matrix::IDENT()) {
std::ifstream in(in_file.c_str(),std::ios_base::binary | std::ios_base::in);
if (!in.is_open()) {
std::cerr << "File '" << in_file << "' could not be opened." << std::endl;
return NULL;
}
std::cerr << "Loading '" << in_file << "'" << std::endl;
return readFile<filetype_t>(in, transform);
}
bool readPLY(std::istream &in, carve::input::Input &inputs, const carve::math::Matrix &transform) {
return readFile<gloop::ply::PlyReader>(in, inputs, transform);
}
carve::poly::Polyhedron *readPLY(std::istream &in, const carve::math::Matrix &transform) {
return readFile<gloop::ply::PlyReader>(in, transform);
}
bool readPLY(const std::string &in_file, carve::input::Input &inputs, const carve::math::Matrix &transform) {
return readFile<gloop::ply::PlyReader>(in_file, inputs, transform);
}
carve::poly::Polyhedron *readPLY(const std::string &in_file, const carve::math::Matrix &transform) {
return readFile<gloop::ply::PlyReader>(in_file, transform);
}
bool readOBJ(std::istream &in, carve::input::Input &inputs, const carve::math::Matrix &transform) {
return readFile<gloop::obj::ObjReader>(in, inputs, transform);
}
carve::poly::Polyhedron *readOBJ(std::istream &in, const carve::math::Matrix &transform) {
return readFile<gloop::obj::ObjReader>(in, transform);
}
bool readOBJ(const std::string &in_file, carve::input::Input &inputs, const carve::math::Matrix &transform) {
return readFile<gloop::obj::ObjReader>(in_file, inputs, transform);
}
carve::poly::Polyhedron *readOBJ(const std::string &in_file, const carve::math::Matrix &transform) {
return readFile<gloop::obj::ObjReader>(in_file, transform);
}
bool readVTK(std::istream &in, carve::input::Input &inputs, const carve::math::Matrix &transform) {
return readFile<gloop::vtk::VtkReader>(in, inputs, transform);
}
carve::poly::Polyhedron *readVTK(std::istream &in, const carve::math::Matrix &transform) {
return readFile<gloop::vtk::VtkReader>(in, transform);
}
bool readVTK(const std::string &in_file, carve::input::Input &inputs, const carve::math::Matrix &transform) {
return readFile<gloop::vtk::VtkReader>(in_file, inputs, transform);
}
carve::poly::Polyhedron *readVTK(const std::string &in_file, const carve::math::Matrix &transform) {
return readFile<gloop::vtk::VtkReader>(in_file, transform);
}

View File

@ -0,0 +1,55 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/poly.hpp>
#include <carve/matrix.hpp>
#include <istream>
#include <fstream>
#include <carve/input.hpp>
bool readPLY(std::istream &in, carve::input::Input &inputs, const carve::math::Matrix &transform = carve::math::Matrix::IDENT());
bool readPLY(const std::string &in_file, carve::input::Input &inputs, const carve::math::Matrix &transform = carve::math::Matrix::IDENT());
carve::poly::Polyhedron *readPLY(std::istream &in, const carve::math::Matrix &transform = carve::math::Matrix::IDENT());
carve::poly::Polyhedron *readPLY(const std::string &in_file, const carve::math::Matrix &transform = carve::math::Matrix::IDENT());
bool readOBJ(std::istream &in, carve::input::Input &inputs, const carve::math::Matrix &transform = carve::math::Matrix::IDENT());
bool readOBJ(const std::string &in_file, carve::input::Input &inputs, const carve::math::Matrix &transform = carve::math::Matrix::IDENT());
carve::poly::Polyhedron *readOBJ(std::istream &in, const carve::math::Matrix &transform = carve::math::Matrix::IDENT());
carve::poly::Polyhedron *readOBJ(const std::string &in_file, const carve::math::Matrix &transform = carve::math::Matrix::IDENT());
bool readVTK(std::istream &in, carve::input::Input &inputs, const carve::math::Matrix &transform = carve::math::Matrix::IDENT());
bool readVTK(const std::string &in_file, carve::input::Input &inputs, const carve::math::Matrix &transform = carve::math::Matrix::IDENT());
carve::poly::Polyhedron *readVTK(std::istream &in, const carve::math::Matrix &transform = carve::math::Matrix::IDENT());
carve::poly::Polyhedron *readVTK(const std::string &in_file, const carve::math::Matrix &transform = carve::math::Matrix::IDENT());

101
thirdparty/carve-1.4.0/common/rgb.hpp vendored Normal file
View File

@ -0,0 +1,101 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <functional>
struct cRGB {
typedef float value_type;
value_type r, g, b;
cRGB() : r(0), g(0), b(0) { }
template <typename T>
cRGB(T _r, T _g, T _b) : r((value_type)_r), g((value_type)_g), b((value_type)_b) { }
};
struct cRGBA {
typedef float value_type;
value_type r, g, b, a;
cRGBA() : r(0),g(0),b(0),a(1) { }
template <typename T>
cRGBA(T _r, T _g, T _b, T _a = T(1)) : r((value_type)_r), g((value_type)_g), b((value_type)_b), a((value_type)_a) { }
cRGBA(const cRGB &rgb) : r(rgb.r), g(rgb.g), b(rgb.b), a(1) { }
};
static inline cRGB operator+(const cRGB &a, const cRGB &b) {
return cRGB(a.r + b.r, a.g + b.g, a.b + b.b);
}
static inline cRGB &operator+=(cRGB &a, const cRGB &b) {
a.r += b.r; a.g += b.g; a.b += b.b;
return a;
}
static inline cRGB operator*(double s, const cRGB &a) {
return cRGB(s * a.r, s * a.g, s * a.b);
}
static inline cRGBA operator+(const cRGBA &a, const cRGBA &b) {
return cRGBA(a.r + b.r, a.g + b.g, a.b + b.b, a.a + b.a);
}
static inline cRGBA &operator+=(cRGBA &a, const cRGBA &b) {
a.r += b.r; a.g += b.g; a.b += b.b; a.a += b.a;
return a;
}
static inline cRGBA operator*(double s, const cRGBA &a) {
return cRGBA(s * a.r, s * a.g, s * a.b, s * a.a);
}
static inline cRGB HSV2RGB(float H, float S, float V) {
H = 6.0f * H;
if (S < 5.0e-6) {
cRGB(V, V, V);
} else {
int i = (int)H;
float f = H - i;
float p1 = V * (1.0f - S);
float p2 = V * (1.0f - S * f);
float p3 = V * (1.0f - S * (1.0f - f));
switch (i) {
case 0: return cRGB(V, p3, p1);
case 1: return cRGB(p2, V, p1);
case 2: return cRGB(p1, V, p3);
case 3: return cRGB(p1, p2, V);
case 4: return cRGB(p3, p1, V);
case 5: return cRGB(V, p1, p2);
}
}
return cRGB(0, 0, 0);
}
struct colour_clamp_t {
cRGB operator()(const cRGB &c) const {
return cRGB(std::min(std::max(c.r, 0.0f), 1.0f),
std::min(std::max(c.g, 0.0f), 1.0f),
std::min(std::max(c.b, 0.0f), 1.0f));
}
cRGBA operator()(const cRGBA &c) const {
return cRGBA(std::min(std::max(c.r, 0.0f), 1.0f),
std::min(std::max(c.g, 0.0f), 1.0f),
std::min(std::max(c.b, 0.0f), 1.0f),
std::min(std::max(c.a, 0.0f), 1.0f));
}
};

480
thirdparty/carve-1.4.0/common/scene.cpp vendored Normal file
View File

@ -0,0 +1,480 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#if defined(HAVE_CONFIG_H)
# include <carve_config.h>
#endif
#include "scene.hpp"
#include <carve/matrix.hpp>
#include <carve/geom3d.hpp>
#include <GL/glui.h>
static int lastx = 0, lasty = 0;
static unsigned buttons;
static int lastbutton = 0;
static Scene *g_scene = NULL;
static int g_mainWindow = NULL;
static GLUI *g_rightPanel = NULL;
static double near_plane = 0.2;
static double far_plane = 200;
carve::math::Matrix g_projection, g_modelview;
void Scene::updateDisplay() {
if (CAM_ELEVATION < -90.0) CAM_ELEVATION = -90;
if (CAM_ELEVATION > 90.0) CAM_ELEVATION = 90;
if (CAM_DIST < 0.05) {
CAM_DIST = 0.05;
}
glutPostWindowRedisplay(g_mainWindow);
glutPostRedisplay();
}
carve::geom3d::Vector rotateWithVector(const carve::geom3d::Vector &x, carve::geom3d::Vector u, float ang) {
carve::geom3d::Vector h,v,uxx;
u.normalize();
uxx = cross(u, x) * (float)sin(ang);
h = u * (dot(x,u));
v = (x - h) * (float)cos(ang);
return (h + v) + uxx;
}
// Our world is Z up.
const carve::geom3d::Vector WORLD_RIGHT = carve::geom::VECTOR(1,0,0);
const carve::geom3d::Vector WORLD_UP = carve::geom::VECTOR(0,0,1);
const carve::geom3d::Vector WORLD_IN = carve::geom::VECTOR(0,1,0);
void getCameraVectors(float rot, float elev, carve::geom3d::Vector &right, carve::geom3d::Vector &up, carve::geom3d::Vector &in) {
right = WORLD_RIGHT;
up = WORLD_UP;
in = WORLD_IN;
right = rotateWithVector(right, WORLD_RIGHT, carve::math::radians(elev));
up = rotateWithVector(up, WORLD_RIGHT, carve::math::radians(elev));
in = rotateWithVector(in, WORLD_RIGHT, carve::math::radians(elev));
right = rotateWithVector(right, WORLD_UP, carve::math::radians(rot));
up = rotateWithVector(up, WORLD_UP, carve::math::radians(rot));
in = rotateWithVector(in, WORLD_UP, carve::math::radians(rot));
}
GLvoid Scene::_drag(int x, int y) {
int dx = x - lastx;
int dy = y - lasty;
if (buttons == 0x04) {
CAM_DIST *= 1.0 + 0.01 * (y - lasty);
CAM_DIST_REAL *= 1.0 + 0.01 * (y - lasty);
updateDisplay();
} else if (buttons == 0x01) {
CAM_ELEVATION += 0.5 * (y-lasty);
CAM_ROT -= 0.5 * (x - lastx);
updateDisplay();
} else if (buttons == 0x02) {
carve::geom3d::Vector right, up, in;
getCameraVectors(CAM_ROT, CAM_ELEVATION, right, up, in);
right.scaleBy(2 * dx * CAM_DIST / WIDTH);
up.scaleBy(2 * dy * CAM_DIST / HEIGHT);
CAM_LOOK += right;
CAM_LOOK += up;
CAM_LOOK_REAL += right;
CAM_LOOK_REAL += up;
updateDisplay();
}
lastx = x;
lasty = y;
}
GLvoid Scene::_click(int button, int state, int x, int y) {
unsigned mask = 1 << button;
if (state) {
buttons &= ~mask;
} else {
buttons |= mask;
}
lastx = x;
lasty = y;
click(button, state, x, y);
}
GLvoid Scene::_key(unsigned char k, int x, int y) {
double rate = 1.0;
if (isupper(k)) { rate = 0.1; k = tolower(k); }
switch (k) {
case 'q':
exit(0);
break;
case 'g':
disp_grid = !disp_grid;
break;
case 'h':
disp_axes = !disp_axes;
break;
case 'w':
if (CAM_ELEVATION > -85.0) CAM_ELEVATION -= 5.0 * rate;
break;
case 's':
if (CAM_ELEVATION < 85.0) CAM_ELEVATION += 5.0 * rate;
break;
case 'a':
CAM_ROT += 5.0 * rate;
break;
case 'd':
CAM_ROT -= 5.0 * rate;
break;
case 'r':
CAM_DIST += 2.0 * rate;
break;
case 'f':
CAM_DIST -= 2.0 * rate;
break;
case 'i':
CAM_LOOK.x -= cos(carve::math::radians(CAM_ROT)) * 2.0 * rate;
CAM_LOOK.z -= sin(carve::math::radians(CAM_ROT)) * 2.0 * rate;
break;
case 'j':
CAM_LOOK.x -= sin(carve::math::radians(CAM_ROT)) * 2.0 * rate;
CAM_LOOK.z += cos(carve::math::radians(CAM_ROT)) * 2.0 * rate;
break;
case 'k':
CAM_LOOK.x += cos(carve::math::radians(CAM_ROT)) * 2.0 * rate;
CAM_LOOK.z += sin(carve::math::radians(CAM_ROT)) * 2.0 * rate;
break;
case 'l':
CAM_LOOK.x += sin(carve::math::radians(CAM_ROT)) * 2.0 * rate;
CAM_LOOK.z -= cos(carve::math::radians(CAM_ROT)) * 2.0 * rate;
break;
case 'z':
near_plane *= 1.1;
break;
case 'x':
near_plane /= 1.1;
break;
case 'c':
far_plane *= 1.1;
break;
case 'v':
far_plane /= 1.1;
break;
default: {
if (!key(k, x, y)) goto skip_redisplay;
break;
}
}
updateDisplay();
skip_redisplay:;
}
GLvoid Scene::_draw() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
double w = WIDTH;
double h = HEIGHT;
if (h == 0) h = 1;
glViewport(0, 0, WIDTH, HEIGHT);
if (w > h) {
double r = w / h;
glFrustum(-0.2 * r, 0.2 * r, -0.2, 0.2, near_plane, far_plane);
} else {
double r = h / w;
glFrustum(-0.2, 0.2, -0.2 * r, 0.2 * r, near_plane, far_plane);
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
CAM_LOOK_REAL = (CAM_LOOK_REAL * 4 + CAM_LOOK) / 5;
CAM_DIST_REAL = (CAM_DIST_REAL * 4 + CAM_DIST) / 5;
// if they are far apart post another redisplay
if ((CAM_LOOK_REAL - CAM_LOOK).length() > 0.001) {
glutPostRedisplay();
} else {
CAM_LOOK_REAL = CAM_LOOK;
}
if (fabs(CAM_DIST_REAL - CAM_DIST) > 0.001) {
glutPostRedisplay();
} else {
CAM_DIST_REAL = CAM_DIST;
}
carve::geom3d::Vector right, up, in;
getCameraVectors(CAM_ROT, CAM_ELEVATION, right, up, in);
in = CAM_DIST_REAL * in;
gluLookAt(CAM_LOOK_REAL.x + in.x, CAM_LOOK_REAL.y + in.y, CAM_LOOK_REAL.z + in.z,
CAM_LOOK_REAL.x, CAM_LOOK_REAL.y, CAM_LOOK_REAL.z,
up.x, up.y, up.z);
glGetDoublev(GL_MODELVIEW_MATRIX, g_modelview.v);
glGetDoublev(GL_PROJECTION_MATRIX, g_projection.v);
glShadeModel(GL_SMOOTH);
glClearDepth(1.0);
glClearColor(0.05f, 0.075f, 0.2f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
{
const float amb[] = {0.05f, 0.05f, 0.05f, 1.0f};
const float diff[] = {1.0f, 0.8f, 0.5f, 1.0f};
const float spec[] = {0.4f, 0.4f, 0.4f, 1.0f};
const float pos[] = {-40.0f, 40.0f, 80.0f, 0.0f};
glLightfv(GL_LIGHT0, GL_AMBIENT, amb);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diff);
glLightfv(GL_LIGHT0, GL_SPECULAR, spec);
glLightfv(GL_LIGHT0, GL_POSITION, pos);
}
{
const float amb[] = {0.05f, 0.05f, 0.05f, 1.0f};
const float diff[] = {0.8f, 0.8f, 1.0f, 1.0f};
const float spec[] = {0.4f, 0.4f, 0.4f, 1.0f};
const float pos[] = {+50.0f, -10.0f, 10.0f, 0.0f};
glLightfv(GL_LIGHT1, GL_AMBIENT, amb);
glLightfv(GL_LIGHT1, GL_DIFFUSE, diff);
glLightfv(GL_LIGHT1, GL_SPECULAR, spec);
glLightfv(GL_LIGHT1, GL_POSITION, pos);
}
glCullFace(GL_BACK);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glEnable(GL_LIGHTING);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH);
if (disp_grid) {
glBegin(GL_LINE_LOOP);
glColor4f(1,1,1,0.5);
glVertex3f(-30,-30,0);
glVertex3f(+30,-30,0);
glVertex3f(+30,+30,0);
glVertex3f(-30,+30,0);
glEnd();
glBegin(GL_LINES);
glColor4f(1.0f, 1.0f, 1.0f, 0.3f);
for (int i = 0; i < 30; i++) {
glVertex3f(i * 2.0f - 30.0f, -30.0f, 0.0f);
glVertex3f(i * 2.0f - 30.0f, +30.0f, 0.0f);
glVertex3f(-30.0f, i * 2.0f - 30.0f, 0.0f);
glVertex3f(+30.0f, i * 2.0f - 30.0f, 0.0f);
}
glEnd();
}
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glDepthFunc(GL_LESS);
glDepthMask(GL_TRUE);
draw();
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
if (disp_axes) {
glBegin(GL_LINES);
glColor4f(1,0,0,1); glVertex3f(0,0,0); glVertex3f(10,0,0);
glColor4f(0,1,0,1); glVertex3f(0,0,0); glVertex3f(0,10,0);
glColor4f(0,0,1,1); glVertex3f(0,0,0); glVertex3f(0,0,10);
glEnd();
}
glPopMatrix();
glutSwapBuffers();
}
bool Scene::key(unsigned char k, int x, int y) {
return false;
}
GLvoid Scene::draw() {
}
void Scene::click(int button, int state, int x, int y) {
}
GLvoid Scene::_resize(int w, int h) {
int tx, ty, tw, th;
GLUI_Master.get_viewport_area(&tx, &ty, &tw, &th);
WIDTH = tw;
HEIGHT = th;
}
void control_cb(int control) {
glutPostRedisplay();
glutPostWindowRedisplay(g_mainWindow);
}
#define WIREFRAME_ENABLED_ID 200
int wireframe = 0;
static std::map<OptionGroup*, GLUI_Rollout *> groupToRollouts;
static std::map<Option*, GLUI_Checkbox *> optionToCheckboxes;
OptionGroup* Scene::createOptionGroup(const char *caption) {
// make sure our UI has been initialised.
init();
// Create a rollout GUI item.
OptionGroup *group = new OptionGroup();
GLUI_Rollout *rollout = new GLUI_Rollout(g_rightPanel, caption);
groupToRollouts[group] = rollout;
return group;
}
Option* OptionGroup::createOption(const char *caption, bool initialValue) {
GLUI_Rollout *rollout = groupToRollouts[this];
if (rollout == NULL) {
return NULL;
}
GLUI_Checkbox *cb = new GLUI_Checkbox(rollout, caption, NULL, 1, control_cb);
cb->set_int_val(initialValue);
Option *option = new Option();
optionToCheckboxes[option] = cb;
return option;
}
bool Option::isChecked() {
GLUI_Checkbox *cb = optionToCheckboxes[this];
if (cb != NULL) {
return cb->get_int_val();
} else {
return false;
}
}
void Option::setChecked(bool value) {
GLUI_Checkbox *cb = optionToCheckboxes[this];
if (cb != NULL) {
return cb->set_int_val(value);
}
}
void Scene::init() {
if (!initialised) {
initialised = true;
GLUI_Master.set_glutDisplayFunc(s_draw);
GLUI_Master.set_glutReshapeFunc(s_resize);
GLUI_Master.set_glutKeyboardFunc(s_key);
GLUI_Master.set_glutSpecialFunc(NULL);
GLUI_Master.set_glutMouseFunc(s_click);
GLUI_Master.set_glutMotionFunc(s_drag);
g_rightPanel = GLUI_Master.create_glui_subwindow(g_mainWindow, GLUI_SUBWINDOW_RIGHT);
this->_init();
}
}
carve::geom3d::Ray Scene::getRay(int x, int y) {
carve::geom3d::Vector from, to;
GLint view[4];
glGetIntegerv(GL_VIEWPORT, view);
gluUnProject(x, view[3] - y, 0, g_modelview.v, g_projection.v, view, &from.x, &from.y, &from.z);
gluUnProject(x, view[3] - y, 50, g_modelview.v, g_projection.v, view, &to.x, &to.y, &to.z);
return carve::geom3d::Ray((to - from).normalized(), from);
}
void Scene::zoomTo(carve::geom3d::Vector pos, double dist) {
CAM_LOOK = pos;
CAM_DIST = dist;
updateDisplay();
}
void Scene::_init() {
}
GLvoid Scene::s_draw() { g_scene->_draw(); }
GLvoid Scene::s_resize(int w, int h) { g_scene->_resize(w, h); }
GLvoid Scene::s_drag(int x, int y) { g_scene->_drag(x, y); }
GLvoid Scene::s_click(int button, int state, int x, int y) { g_scene->_click(button, state, x, y); }
GLvoid Scene::s_key(unsigned char k, int x, int y) { g_scene->_key(k, x, y); }
Scene::Scene(int argc, char **argv) {
CAM_ROT = 0.0;
CAM_ELEVATION = 45.0;
CAM_DIST = 70.0;
CAM_DIST_REAL = 10000;
WIDTH = 1024;
HEIGHT = 768;
disp_grid = true;
disp_axes = true;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(WIDTH, HEIGHT);
g_mainWindow = glutCreateWindow("Main");
initialised = false;
g_scene = this;
}
Scene::~Scene() {
g_scene = NULL;
}
void Scene::run() {
init();
glutMainLoop();
}

87
thirdparty/carve-1.4.0/common/scene.hpp vendored Normal file
View File

@ -0,0 +1,87 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/geom3d.hpp>
#include <gloop/gloopgl.hpp>
#include <gloop/gloopglu.hpp>
#include <gloop/gloopglut.hpp>
class Option {
public:
bool isChecked();
void setChecked(bool value);
};
class OptionGroup {
public:
Option* createOption(const char *caption, bool initialValue);
};
class Scene {
static GLvoid s_drag(int x, int y);
static GLvoid s_click(int button, int state, int x, int y);
static GLvoid s_key(unsigned char k, int x, int y);
static GLvoid s_draw();
static GLvoid s_resize(int w, int h);
carve::geom3d::Vector CAM_LOOK;
double CAM_ROT;
double CAM_ELEVATION;
double CAM_DIST;
carve::geom3d::Vector CAM_LOOK_REAL;
double CAM_DIST_REAL;
int WIDTH;
int HEIGHT;
bool initialised;
bool disp_grid;
bool disp_axes;
GLvoid _drag(int x, int y);
GLvoid _click(int button, int state, int x, int y);
GLvoid _key(unsigned char k, int x, int y);
GLvoid _draw();
GLvoid _resize(int w, int h);
virtual void _init();
void updateDisplay();
protected:
virtual bool key(unsigned char k, int x, int y);
virtual GLvoid draw();
virtual void click(int button, int state, int x, int y);
public:
Scene(int argc, char **argv);
virtual ~Scene();
virtual void run();
void init();
carve::geom3d::Ray getRay(int x, int y);
void zoomTo(carve::geom3d::Vector pos, double dist);
OptionGroup* createOptionGroup(const char *title);
};

View File

@ -0,0 +1,73 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <string>
namespace str {
static inline bool startswith(const std::string &a, const std::string &b) {
if (b.size() > a.size()) return false;
return a.compare(0, b.size(), b) == 0;
}
template<typename strip_t>
static inline std::string rstrip(const std::string &a, const strip_t stripchars) {
std::string::size_type p = a.find_last_not_of(stripchars);
if (p == std::string::npos) return "";
return a.substr(0, p + 1);
}
static inline std::string rstrip(const std::string &a) {
std::string::size_type p = a.size();
while (p && isspace(a[p-1])) p--;
if (!p) return "";
return a.substr(0, p);
}
template<typename strip_t>
static inline std::string lstrip(const std::string &a, const strip_t stripchars) {
std::string::size_type p = a.find_first_not_of(stripchars);
if (p == std::string::npos) return "";
return a.substr(p);
}
static inline std::string lstrip(const std::string &a) {
std::string::size_type p = 0;
while (p < a.size() && isspace(a[p])) p++;
if (p == a.size()) return "";
return a.substr(p);
}
template<typename strip_t>
static inline std::string strip(const std::string &a, const strip_t stripchars) {
std::string::size_type p = a.find_first_not_of(stripchars);
if (p == std::string::npos) return "";
std::string::size_type q = a.find_last_not_of(stripchars);
return a.substr(p, q-p);
}
static inline std::string strip(const std::string &a) {
std::string::size_type p = 0;
while (p < a.size() && isspace(a[p])) p++;
if (p == a.size()) return "";
std::string::size_type q = a.size();
while (q>p && isspace(a[q-1])) q--;
return a.substr(p, q-p);
}
}

View File

@ -0,0 +1,281 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#if defined(HAVE_CONFIG_H)
# include <carve_config.h>
#endif
#include "write_ply.hpp"
#include <gloop/model/ply_format.hpp>
#include <gloop/model/obj_format.hpp>
#include <gloop/model/vtk_format.hpp>
#include <stdlib.h>
#include <stdio.h>
#include <iomanip>
#ifndef WIN32
# include <stdint.h>
#endif
namespace {
struct vertex_base : public gloop::stream::null_writer {
virtual const carve::geom3d::Vector &curr() const =0;
};
template<typename container_t>
struct vertex : public vertex_base {
const container_t &cnt;
int i;
vertex(const container_t &_cnt) : cnt(_cnt), i(-1) { }
virtual void next() { ++i; }
virtual int length() { return cnt.size(); }
virtual const carve::geom3d::Vector &curr() const { return cnt[i].v; }
};
typedef vertex<std::vector<carve::point::Vertex> > pointset_vertex;
typedef vertex<std::vector<carve::poly::Vertex<3> > > poly_vertex;
typedef vertex<std::vector<carve::line::Vertex> > line_vertex;
template<int idx>
struct vertex_component : public gloop::stream::writer<double> {
vertex_base &r;
vertex_component(vertex_base &_r) : r(_r) { }
virtual double value() { return r.curr().v[idx]; }
};
struct face : public gloop::stream::null_writer {
const carve::poly::Polyhedron *poly;
int i;
face(const carve::poly::Polyhedron *_poly) : poly(_poly), i(-1) { }
virtual void next() { ++i; }
virtual int length() { return poly->faces.size(); }
const carve::poly::Face<3> *curr() const { return &poly->faces[i]; }
};
struct face_idx : public gloop::stream::writer<size_t> {
face &r;
const carve::poly::Face<3> *f;
size_t i;
gloop::stream::Type data_type;
int max_length;
face_idx(face &_r, gloop::stream::Type _data_type, int _max_length) :
r(_r), f(NULL), i(0), data_type(_data_type), max_length(_max_length) {
}
virtual void begin() { f = r.curr(); i = 0; }
virtual int length() { return f->nVertices(); }
virtual bool isList() { return true; }
virtual gloop::stream::Type dataType() { return data_type; }
virtual int maxLength() { return max_length; }
virtual size_t value() { return static_cast<const carve::poly::Polyhedron *>(f->owner)->vertexToIndex_fast(f->vertex(i++)); }
};
struct lineset : public gloop::stream::null_writer {
const carve::line::PolylineSet *polyline;
carve::line::PolylineSet::const_line_iter c;
carve::line::PolylineSet::const_line_iter n;
lineset(const carve::line::PolylineSet *_polyline) : polyline(_polyline) { n = polyline->lines.begin(); }
virtual void next() { c = n; ++n; }
virtual int length() { return polyline->lines.size(); }
const carve::line::Polyline *curr() const { return *c; }
};
struct line_closed : public gloop::stream::writer<bool> {
lineset &ls;
line_closed(lineset &_ls) : ls(_ls) { }
virtual gloop::stream::Type dataType() { return gloop::stream::U8; }
virtual bool value() { return ls.curr()->isClosed(); }
};
struct line_vi : public gloop::stream::writer<size_t> {
lineset &ls;
const carve::line::Polyline *l;
size_t i;
gloop::stream::Type data_type;
int max_length;
line_vi(lineset &_ls, gloop::stream::Type _data_type, int _max_length) :
ls(_ls), l(NULL), i(0), data_type(_data_type), max_length(_max_length) {
}
virtual bool isList() { return true; }
virtual gloop::stream::Type dataType() { return data_type; }
virtual int maxLength() { return max_length; }
virtual void begin() { l = ls.curr(); i = 0; }
virtual int length() { return l->vertexCount(); }
virtual size_t value() { return ls.polyline->vertexToIndex_fast(l->vertex(i++)); }
};
void setup(gloop::stream::model_writer &file, const carve::poly::Polyhedron *poly) {
size_t face_max = 0;
for (size_t i = 0; i < poly->faces.size(); ++i) face_max = std::max(face_max, poly->faces[i].nVertices());
file.newBlock("polyhedron");
poly_vertex *vi = new poly_vertex(poly->vertices);
file.addWriter("polyhedron.vertex", vi);
file.addWriter("polyhedron.vertex.x", new vertex_component<0>(*vi));
file.addWriter("polyhedron.vertex.y", new vertex_component<1>(*vi));
file.addWriter("polyhedron.vertex.z", new vertex_component<2>(*vi));
face *fi = new face(poly);
file.addWriter("polyhedron.face", fi);
file.addWriter("polyhedron.face.vertex_indices",
new face_idx(*fi,
gloop::stream::smallest_type(poly->vertices.size()),
face_max));
}
void setup(gloop::stream::model_writer &file, const carve::line::PolylineSet *lines) {
size_t line_max = 0;
for (std::list<carve::line::Polyline *>::const_iterator
i = lines->lines.begin(),
e = lines->lines.end();
i != e;
++i) {
line_max = std::max(line_max, (*i)->vertexCount());
}
file.newBlock("polyline");
line_vertex *vi = new line_vertex(lines->vertices);
file.addWriter("polyline.vertex", vi);
file.addWriter("polyline.vertex.x", new vertex_component<0>(*vi));
file.addWriter("polyline.vertex.y", new vertex_component<1>(*vi));
file.addWriter("polyline.vertex.z", new vertex_component<2>(*vi));
lineset *pi = new lineset(lines);
file.addWriter("polyline.polyline", pi);
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));
}
void setup(gloop::stream::model_writer &file, const carve::point::PointSet *points) {
file.newBlock("pointset");
pointset_vertex *vi = new pointset_vertex(points->vertices);
file.addWriter("pointset.vertex", vi);
file.addWriter("pointset.vertex.x", new vertex_component<0>(*vi));
file.addWriter("pointset.vertex.y", new vertex_component<1>(*vi));
file.addWriter("pointset.vertex.z", new vertex_component<2>(*vi));
}
}
void writePLY(std::ostream &out, const carve::poly::Polyhedron *poly, bool ascii) {
gloop::ply::PlyWriter file(!ascii, false);
if (ascii) out << std::setprecision(30);
setup(file, poly);
file.write(out);
}
void writePLY(std::string &out_file, const carve::poly::Polyhedron *poly, bool ascii) {
std::ofstream out(out_file.c_str(), std::ios_base::binary);
if (!out.is_open()) { std::cerr << "File '" << out_file << "' could not be opened." << std::endl; return; }
writePLY(out, poly, ascii);
}
void writePLY(std::ostream &out, const carve::line::PolylineSet *lines, bool ascii) {
gloop::ply::PlyWriter file(!ascii, false);
if (ascii) out << std::setprecision(30);
setup(file, lines);
file.write(out);
}
void writePLY(std::string &out_file, const carve::line::PolylineSet *lines, bool ascii) {
std::ofstream out(out_file.c_str(), std::ios_base::binary);
if (!out.is_open()) { std::cerr << "File '" << out_file << "' could not be opened." << std::endl; return; }
writePLY(out, lines, ascii);
}
void writePLY(std::ostream &out, const carve::point::PointSet *points, bool ascii) {
gloop::ply::PlyWriter file(!ascii, false);
if (ascii) out << std::setprecision(30);
setup(file, points);
file.write(out);
}
void writePLY(std::string &out_file, const carve::point::PointSet *points, bool ascii) {
std::ofstream out(out_file.c_str(), std::ios_base::binary);
if (!out.is_open()) { std::cerr << "File '" << out_file << "' could not be opened." << std::endl; return; }
writePLY(out, points, ascii);
}
void writeOBJ(std::ostream &out, const carve::poly::Polyhedron *poly) {
gloop::obj::ObjWriter file;
setup(file, poly);
file.write(out);
}
void writeOBJ(std::string &out_file, const carve::poly::Polyhedron *poly) {
std::ofstream out(out_file.c_str(), std::ios_base::binary);
if (!out.is_open()) { std::cerr << "File '" << out_file << "' could not be opened." << std::endl; return; }
writeOBJ(out, poly);
}
void writeOBJ(std::ostream &out, const carve::line::PolylineSet *lines) {
gloop::obj::ObjWriter file;
setup(file, lines);
file.write(out);
}
void writeOBJ(std::string &out_file, const carve::line::PolylineSet *lines, bool ascii) {
std::ofstream out(out_file.c_str(), std::ios_base::binary);
if (!out.is_open()) { std::cerr << "File '" << out_file << "' could not be opened." << std::endl; return; }
writeOBJ(out, lines);
}
void writeVTK(std::ostream &out, const carve::poly::Polyhedron *poly) {
gloop::vtk::VtkWriter file(gloop::vtk::VtkWriter::ASCII);
setup(file, poly);
file.write(out);
}
void writeVTK(std::string &out_file, const carve::poly::Polyhedron *poly) {
std::ofstream out(out_file.c_str(), std::ios_base::binary);
if (!out.is_open()) { std::cerr << "File '" << out_file << "' could not be opened." << std::endl; return; }
writeVTK(out, poly);
}
void writeVTK(std::ostream &out, const carve::line::PolylineSet *lines) {
gloop::vtk::VtkWriter file(gloop::vtk::VtkWriter::ASCII);
setup(file, lines);
file.write(out);
}
void writeVTK(std::string &out_file, const carve::line::PolylineSet *lines, bool ascii) {
std::ofstream out(out_file.c_str(), std::ios_base::binary);
if (!out.is_open()) { std::cerr << "File '" << out_file << "' could not be opened." << std::endl; return; }
writeVTK(out, lines);
}

View File

@ -0,0 +1,49 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/poly.hpp>
#include <carve/polyline.hpp>
#include <carve/pointset.hpp>
#include <ostream>
#include <fstream>
void writePLY(std::ostream &out, const carve::line::PolylineSet *lines, bool ascii = false);
void writePLY(std::ostream &out, const carve::poly::Polyhedron *poly, bool ascii = false);
void writePLY(std::ostream &out, const carve::point::PointSet *points, bool ascii = false);
void writePLY(std::string &out_file, const carve::line::PolylineSet *lines, bool ascii = false);
void writePLY(std::string &out_file, const carve::poly::Polyhedron *poly, bool ascii = false);
void writePLY(std::string &out_file, const carve::point::PointSet *points, bool ascii = false);
void writeOBJ(std::ostream &out, const carve::line::PolylineSet *lines);
void writeOBJ(std::ostream &out, const carve::poly::Polyhedron *poly);
void writeOBJ(std::string &out_file, const carve::line::PolylineSet *lines);
void writeOBJ(std::string &out_file, const carve::poly::Polyhedron *poly);
void writeVTK(std::ostream &out, const carve::line::PolylineSet *lines);
void writeVTK(std::ostream &out, const carve::poly::Polyhedron *poly);
void writeVTK(std::string &out_file, const carve::line::PolylineSet *lines);
void writeVTK(std::string &out_file, const carve::poly::Polyhedron *poly);

196
thirdparty/carve-1.4.0/configure.ac vendored Normal file
View File

@ -0,0 +1,196 @@
AC_INIT(README)
AC_CONFIG_AUX_DIR(build/autoconf)
AC_SUBST(ac_aux_dir)
AC_CANONICAL_SYSTEM
AC_CONFIG_SRCDIR([src])
AM_CONFIG_HEADER(include/carve_config.h include/carve/config.h)
AM_INIT_AUTOMAKE(carve, 1.4.0, tobias.sargeant@gmail.com)
AC_DEFINE_UNQUOTED(CARVE_VERSION, ["${VERSION}"], [Carve version number])
AC_PROG_CC
AC_PROG_CPP
AM_PROG_LIBTOOL
AC_PROG_CXX
AM_MAINTAINER_MODE
AC_HEADER_STDC
AC_CHECK_HEADERS([stdint.h stdlib.h string.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_HEADER_STDBOOL
AC_C_BIGENDIAN
AC_TYPE_SIZE_T
AC_LANG_CPLUSPLUS
# Checks for library functions.
# AC_CHECK_FUNCS([floor getcwd getservbyname getaddrinfo gethostbyname gettimeofday memset select setlocale socket sqrt strerror strtoul inet_ntop inet_pton])
AC_CHECK_FUNCS([isatty])
AC_ARG_WITH(tr1-collections,
AC_HELP_STRING([--with-tr1-collections], [use tr1 collections, where available]),
with_TR1="$withval",
with_TR1="yes")
AC_ARG_WITH(boost-collections,
AC_HELP_STRING([--with-boost-collections], [use boost collections]),
with_BOOST="$withval",
with_BOOST="no")
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug], [compile in debug hooks [default=no]]))
AC_ARG_ENABLE(intersect-glu-triangulator,
AC_HELP_STRING([--enable-intersect-glu-triangulator], [compile GLU-based triangulation code into intersect [default=yes]]),
enable_GLU_tri="$enableval",
enable_GLU_tri="yes")
AC_ARG_WITH(gui,
AC_HELP_STRING([--with-gui], [compile gui code]),
with_GUI="$withval",
with_GUI="yes")
AC_MSG_CHECKING([for std collections])
AC_TRY_COMPILE([
#include <unordered_set>
#include <unordered_map>
], [
const std::unordered_map<int,int> a;
const std::unordered_set<int> b;
a.find(1);
b.find(1);
], [
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_STD_UNORDERED_COLLECTIONS], [], [Define if std::unordered_map and std::unordered_set are supported by your compiler.])
with_TR1=no
], [
AC_MSG_RESULT([no])
])
AC_MSG_CHECKING([for gnu libstdc++ collections])
AC_TRY_COMPILE([
#include <ext/hash_set>
#include <ext/hash_map>
], [
const __gnu_cxx::hash_map<int,int> a;
const __gnu_cxx::hash_set<int> b;
a.find(1);
b.find(1);
], [
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_LIBSTDCPP_UNORDERED_COLLECTIONS], [], [Define if using gnu libstdc++.])
with_TR1=no
], [
AC_MSG_RESULT([no])
])
if test "x$with_TR1" = "xyes"; then
AC_MSG_CHECKING([for TR1 collections])
AC_TRY_COMPILE([
#include <tr1/unordered_set>
#include <tr1/unordered_map>
],[
std::tr1::unordered_map<int,int> a;
std::tr1::unordered_set<int> b;
], [
AC_TRY_COMPILE([
#include <tr1/unordered_set>
#include <tr1/unordered_map>
],[
const std::tr1::unordered_map<int,int> a;
const std::tr1::unordered_set<int> b;
a.find(1);
b.find(1);
], [
AC_MSG_RESULT([yes])
with_TR1=yes
], [
AC_MSG_RESULT([yes, but unusable (const issues)])
with_TR1=no
])], [
AC_MSG_RESULT([no])
with_TR1=no
])
fi
if test "x$with_TR1" = "xyes"; then
AC_DEFINE([HAVE_TR1_UNORDERED_COLLECTIONS], [], [Define if TR1 collections are supportted by your compiler.])
fi
if test "x$with_BOOST" != "xno"; then
AC_DEFINE([HAVE_BOOST_UNORDERED_COLLECTIONS], [], [Define if using boost collections.])
CARVE_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="${CPPFLAGS} -I$ac_confdir/include"
AC_MSG_CHECKING([for boost collections])
AC_TRY_COMPILE([
#include <carve/collection/external/boost/unordered_set.hpp>
#include <carve/collection/external/boost/unordered_map.hpp>
],[
const boost::unordered_map<int,int> a;
const boost::unordered_set<int> b;
a.find(1);
b.find(1);
], [
AC_MSG_RESULT([yes])
with_BOOST=yes
], [
AC_MSG_RESULT([no])
with_BOOST=no
])
CPPFLAGS=$CARVE_save_CPPFLAGS
fi
if test x$enable_debug = xyes; then
CPPFLAGS="${CPPFLAGS} -DDEBUG"
fi
CARVE_CHECK_OPENGL
if test x"$have_GL" = xno; then AC_MSG_NOTICE([missing GL]); with_GUI=no; fi
if test x"$have_GLU" = xno; then AC_MSG_NOTICE([missing GLU]); with_GUI=no; fi
if test x"$have_glut" = xno; then AC_MSG_NOTICE([missing glut]); with_GUI=no; fi
if test x"$have_GLU" = xyes; then
AC_MSG_CHECKING([glu callback prototype])
AC_TRY_COMPILE([
#if defined(__APPLE__)
#include <OpenGL/glu.h>
#else
#include <GL/glu.h>
#endif
],[
typedef GLvoid (*GLUTessCallback)(...);
gluTessCallback((GLUtesselator *)NULL, GLU_TESS_END_DATA, (GLUTessCallback)NULL);
], [
AC_MSG_RESULT([varargs])
AC_DEFINE([GLU_TESS_CALLBACK_VARARGS], [], [Define if gluTessCallback callback prototype needs (...).])
], [
AC_MSG_RESULT([no varargs])
])
fi
AM_CONDITIONAL(enable_GLU_tri, test "x$enable_GLU_tri" = "xyes")
AM_CONDITIONAL(with_GUI, test "x$with_GUI" = "xyes")
AM_CONDITIONAL(with_BOOST, test "x$with_BOOST" != "xno")
AC_SUBST(GL_CFLAGS)
AC_SUBST(GL_LIBS)
AC_SUBST(GLUT_CFLAGS)
AC_SUBST(GLUT_LIBS)
AC_OUTPUT([
Makefile lib/Makefile common/Makefile src/Makefile
tests/Makefile examples/Makefile
external/Makefile
external/GLEW/Makefile external/GLOOP/Makefile
external/GLUI/Makefile include/Makefile include/carve/Makefile
include/carve/collection/Makefile
include/carve/collection/unordered/Makefile
])

Binary file not shown.

BIN
thirdparty/carve-1.4.0/data/bunny2.ply vendored Normal file

Binary file not shown.

BIN
thirdparty/carve-1.4.0/data/case2_A.ply vendored Executable file

Binary file not shown.

View File

@ -0,0 +1,9 @@
ply
format binary_little_endian 1.0
element vertex 0
property double x
property double y
property double z
element face 0
property list uchar uchar vertex_indices
end_header

BIN
thirdparty/carve-1.4.0/data/case2_B.ply vendored Executable file

Binary file not shown.

122
thirdparty/carve-1.4.0/data/conedown.ply vendored Normal file
View File

@ -0,0 +1,122 @@
ply
format ascii 1.0
element vertex 39
property double x
property double y
property double z
element face 74
property list uchar uchar vertex_indices
end_header
-0.494999999999999995559107901499 -0.0413874231151109966964085629115 200
-0.494999999999999995559107901499 0.0413874231000000009084160979 200
-0.480866355004785972493408507944 -0.125316851986600003021621319022 200
-0.480866354997726008768665906246 0.125316852013504009821787121837 200
-0.450845059114832025226604628187 -0.209372724678484001259448632482 200
-0.450845059006611981189394100511 0.20937272498862399827679325881 200
-0.404523252922430021083499696033 0.289071153133462988016333383712 200
-0.404523252781063991090348963553 -0.289071153252449974946358679517 200
-0.343189517120469023137019348724 0.359793787905108020108713162699 200
-0.343189516935544003395364143216 -0.359793788074322995473863784355 200
-0.26981275608929200515717639064 -0.41759188495350302305908485323 200
-0.269812755966678974317574102315 0.417591885026246001366700966173 200
-0.18858395204169500769530998241 0.459889827987183974489227011873 200
-0.188583951970679009058073916094 -0.459889828015268009586691277946 200
-0.104160784034585993107491219689 -0.485839705995682991090944824464 200
-0.10416078396171199460518153046 0.485839706011769012494738717578 200
-0.0307741189559969999245403471377 0.494999999999999995559107901499 200
-0.0307741189026270005324459333451 -0.494999999999999995559107901499 200
0 0 -1
0.0100849045556969992704088312507 -0.494999999999999995559107901499 200
0.0100849045897920003983516679114 0.494999999999999995559107901499 200
0.062137555078774997507906618921 0.49287812500452499175906950768 200
0.0621375552145759998956542347059 -0.492878124990966004492776164625 200
0.146484821838305995234108536351 0.474893355034476993825620638745 200
0.146484821860212999222738972094 -0.474893355043605025489483750789 200
0.229889933133993001890260643449 0.440772940913512989435929512183 200
0.229889933136291996218503186356 -0.440772940928581991038015530648 200
0.307765227800700980065329304125 -0.390507867152336984872817993164 200
0.307765227980898004034315817989 0.390507867012329978884110914805 200
0.375583330013183003259769066062 0.325826383981538014733558838998 200
0.375583330169319995484045193734 -0.325826383836102018154434745156 200
0.429683015914633981147119357047 -0.250061312166508009635634834922 200
0.429683016004424989109367061246 0.250061311993802992681423802424 200
0.467904598976019991951602605695 -0.16759724006988099831438887577 200
0.467904598998025000877731827131 0.167597240007610004397520242492 200
0.489834868960314973040937047699 0.0830808390746820002448203013046 200
0.489834868989419025542275676344 -0.0830808390164750054651676691719 200
0.494999999999999995559107901499 -0.0203414705465549995599960908521 200
0.494999999999999995559107901499 0.0203414704883469986407273921714 200
3 18 36 33
3 18 31 30
3 32 34 18
3 18 27 26
3 28 29 18
3 18 24 22
3 23 25 18
3 18 19 17
3 20 21 18
3 18 14 13
3 15 16 18
3 18 10 9
3 11 12 18
3 18 7 4
3 6 8 18
3 18 2 0
3 3 5 18
3 0 1 18
3 18 1 3
3 4 2 18
3 18 5 6
3 9 7 18
3 18 8 11
3 13 10 18
3 18 12 15
3 17 14 18
3 18 16 20
3 22 19 18
3 18 21 23
3 26 24 18
3 18 25 28
3 30 27 18
3 18 29 32
3 33 31 18
3 34 35 18
3 18 38 37
3 18 37 36
3 35 38 18
3 38 35 37
3 34 32 35
3 29 28 32
3 25 23 28
3 21 20 23
3 16 15 20
3 12 11 15
3 8 6 11
3 5 3 6
3 1 0 3
3 2 4 0
3 7 9 4
3 10 13 9
3 14 17 13
3 19 22 17
3 24 26 22
3 27 30 26
3 31 33 30
3 36 37 33
3 35 32 37
3 28 23 32
3 20 15 23
3 11 6 15
3 3 0 6
3 4 9 0
3 13 17 9
3 22 26 17
3 30 33 26
3 37 32 33
3 32 23 33
3 15 6 23
3 0 9 6
3 17 26 9
3 33 23 26
3 23 6 26
3 9 26 6

122
thirdparty/carve-1.4.0/data/coneup.ply vendored Normal file
View File

@ -0,0 +1,122 @@
ply
format ascii 1.0
element vertex 39
property double x
property double y
property double z
element face 74
property list uchar uchar vertex_indices
end_header
-0.494999999999999995559107901499 -0.0413874231151109966964085629115 -200
-0.494999999999999995559107901499 0.0413874231000000009084160979 -200
-0.480866355004785972493408507944 -0.125316851986600003021621319022 -200
-0.480866354997726008768665906246 0.125316852013504009821787121837 -200
-0.450845059114832025226604628187 -0.209372724678484001259448632482 -200
-0.450845059006611981189394100511 0.20937272498862399827679325881 -200
-0.404523252922430021083499696033 0.289071153133462988016333383712 -200
-0.404523252781063991090348963553 -0.289071153252449974946358679517 -200
-0.343189517120469023137019348724 0.359793787905108020108713162699 -200
-0.343189516935544003395364143216 -0.359793788074322995473863784355 -200
-0.26981275608929200515717639064 -0.41759188495350302305908485323 -200
-0.269812755966678974317574102315 0.417591885026246001366700966173 -200
-0.18858395204169500769530998241 0.459889827987183974489227011873 -200
-0.188583951970679009058073916094 -0.459889828015268009586691277946 -200
-0.104160784034585993107491219689 -0.485839705995682991090944824464 -200
-0.10416078396171199460518153046 0.485839706011769012494738717578 -200
-0.0307741189559969999245403471377 0.494999999999999995559107901499 -200
-0.0307741189026270005324459333451 -0.494999999999999995559107901499 -200
0 0 1
0.0100849045556969992704088312507 -0.494999999999999995559107901499 -200
0.0100849045897920003983516679114 0.494999999999999995559107901499 -200
0.062137555078774997507906618921 0.49287812500452499175906950768 -200
0.0621375552145759998956542347059 -0.492878124990966004492776164625 -200
0.146484821838305995234108536351 0.474893355034476993825620638745 -200
0.146484821860212999222738972094 -0.474893355043605025489483750789 -200
0.229889933133993001890260643449 0.440772940913512989435929512183 -200
0.229889933136291996218503186356 -0.440772940928581991038015530648 -200
0.307765227800700980065329304125 -0.390507867152336984872817993164 -200
0.307765227980898004034315817989 0.390507867012329978884110914805 -200
0.375583330013183003259769066062 0.325826383981538014733558838998 -200
0.375583330169319995484045193734 -0.325826383836102018154434745156 -200
0.429683015914633981147119357047 -0.250061312166508009635634834922 -200
0.429683016004424989109367061246 0.250061311993802992681423802424 -200
0.467904598976019991951602605695 -0.16759724006988099831438887577 -200
0.467904598998025000877731827131 0.167597240007610004397520242492 -200
0.489834868960314973040937047699 0.0830808390746820002448203013046 -200
0.489834868989419025542275676344 -0.0830808390164750054651676691719 -200
0.494999999999999995559107901499 -0.0203414705465549995599960908521 -200
0.494999999999999995559107901499 0.0203414704883469986407273921714 -200
3 36 18 33
3 31 18 30
3 34 32 18
3 27 18 26
3 29 28 18
3 24 18 22
3 25 23 18
3 19 18 17
3 21 20 18
3 14 18 13
3 16 15 18
3 10 18 9
3 12 11 18
3 7 18 4
3 8 6 18
3 2 18 0
3 5 3 18
3 1 0 18
3 1 18 3
3 2 4 18
3 5 18 6
3 7 9 18
3 8 18 11
3 10 13 18
3 12 18 15
3 14 17 18
3 16 18 20
3 19 22 18
3 21 18 23
3 24 26 18
3 25 18 28
3 27 30 18
3 29 18 32
3 31 33 18
3 35 34 18
3 38 18 37
3 37 18 36
3 38 35 18
3 35 38 37
3 32 34 35
3 28 29 32
3 23 25 28
3 20 21 23
3 15 16 20
3 11 12 15
3 6 8 11
3 3 5 6
3 0 1 3
3 4 2 0
3 9 7 4
3 13 10 9
3 17 14 13
3 22 19 17
3 26 24 22
3 30 27 26
3 33 31 30
3 37 36 33
3 32 35 37
3 23 28 32
3 15 20 23
3 6 11 15
3 0 3 6
3 9 4 0
3 17 13 9
3 26 22 17
3 33 30 26
3 32 37 33
3 23 32 33
3 6 15 23
3 9 0 6
3 26 17 9
3 23 33 26
3 6 23 26
3 26 9 6

BIN
thirdparty/carve-1.4.0/data/cow.ply vendored Normal file

Binary file not shown.

BIN
thirdparty/carve-1.4.0/data/cow2.ply vendored Normal file

Binary file not shown.

29
thirdparty/carve-1.4.0/data/cube.ply vendored Normal file
View File

@ -0,0 +1,29 @@
ply
format ascii 1.0
element vertex 8
property double x
property double y
property double z
element face 12
property list uchar uchar vertex_indices
end_header
-1 -1 -1
-1 -1 1
-1 1 -1
-1 1 1
1 -1 -1
1 -1 1
1 1 -1
1 1 1
3 7 3 1
3 7 1 5
3 4 0 2
3 4 2 6
3 7 6 2
3 7 2 3
3 3 2 0
3 3 0 1
3 1 0 4
3 1 4 5
3 5 4 6
3 5 6 7

View File

@ -0,0 +1,233 @@
ply
format ascii 1.0
element vertex 76
property double x
property double y
property double z
element face 148
property list uchar uchar vertex_indices
end_header
-0.5 -0.494999999999999995559107901499 -0.0203414706000000014562978378763
-0.5 -0.494999999999999995559107901499 0.0203414706000010006570200005172
-0.5 -0.489834869000000006078465730752 -0.0830808390000000035469085446493
-0.5 -0.489834869000000006078465730752 0.0830808390000000035469085446493
-0.5 -0.467904598999999976616237518101 -0.167597240000000008430802722614
-0.5 -0.467904598999999976616237518101 0.167597240000000008430802722614
-0.5 -0.429683015999999973200118574823 -0.250061311999999980049125269943
-0.5 -0.429683015999999973200118574823 0.250061311999999980049125269943
-0.5 -0.37558332999999999302076503227 -0.325826384000000024432353029624
-0.5 -0.37558332999999999302076503227 0.325826384000000024432353029624
-0.5 -0.307765228000001000996377342744 -0.390507867000000008506077620041
-0.5 -0.307765228000000001795655180103 0.390507867000000008506077620041
-0.5 -0.229889932999999990759221191183 0.440772940999999973676892750518
-0.5 -0.229889932999998991558499028542 -0.440772940999999973676892750518
-0.5 -0.146484822000001013719838738325 -0.474893355000000016996608565023
-0.5 -0.146484821999999986763540960055 0.474893355000000016996608565023
-0.5 -0.0621375550999999984314037249078 -0.49287812500000000026645352591
-0.5 -0.0621375550999999984314037249078 0.49287812500000000026645352591
-0.5 -0.0100849045000009993749978676192 -0.494999999999999995559107901499
-0.5 -0.0100849045000009993749978676192 0.494999999999999995559107901499
-0.5 0.0307741189000010004206409064409 -0.494999999999999995559107901499
-0.5 0.0307741189000010004206409064409 0.494999999999999995559107901499
-0.5 0.104160783999998993176738792954 -0.485839705999999982299897283156
-0.5 0.104160783999998993176738792954 0.485839705999999982299897283156
-0.5 0.188583952000000998339146462968 -0.45988982800000000050744120017
-0.5 0.188583952000000998339146462968 0.45988982800000000050744120017
-0.5 0.269812755999998987732624300406 0.417591884999999995997654878011
-0.5 0.269812755999999986933346463047 -0.417591884999999995997654878011
-0.5 0.343189516999999999491421931452 -0.359793788000000003268752379881
-0.5 0.343189517000000998692144094093 0.35979378799999900406803021724
-0.5 0.404523253000000027057581064582 -0.289071153000000025112825596807
-0.5 0.404523253000000027057581064582 0.289071153000000025112825596807
-0.5 0.450845058999999992455087749477 -0.209372725000000009520917387817
-0.5 0.450845058999999992455087749477 0.209372725000000009520917387817
-0.5 0.48086635500000002307885438313 -0.12531685200000000635078833966
-0.5 0.48086635500000002307885438313 0.125316851999999007150066177019
-0.5 0.494999999999999995559107901499 -0.0413874231000000009084160979
-0.5 0.494999999999999995559107901499 0.0413874231000010001091382605409
0.5 -0.494999999999999995559107901499 -0.0203414706000000014562978378763
0.5 -0.494999999999999995559107901499 0.0203414706000010006570200005172
0.5 -0.489834869000000006078465730752 -0.0830808390000000035469085446493
0.5 -0.489834869000000006078465730752 0.0830808390000000035469085446493
0.5 -0.467904598999999976616237518101 -0.167597240000000008430802722614
0.5 -0.467904598999999976616237518101 0.167597240000000008430802722614
0.5 -0.429683015999999973200118574823 -0.250061311999999980049125269943
0.5 -0.429683015999999973200118574823 0.250061311999999980049125269943
0.5 -0.37558332999999999302076503227 -0.325826384000000024432353029624
0.5 -0.37558332999999999302076503227 0.325826384000000024432353029624
0.5 -0.307765228000001000996377342744 0.390507867000000008506077620041
0.5 -0.307765228000000001795655180103 -0.390507867000000008506077620041
0.5 -0.229889932999999990759221191183 -0.440772940999999973676892750518
0.5 -0.229889932999998991558499028542 0.440772940999999973676892750518
0.5 -0.146484822000001013719838738325 0.474893355000000016996608565023
0.5 -0.146484821999999986763540960055 -0.474893355000000016996608565023
0.5 -0.0621375550999999984314037249078 -0.49287812500000000026645352591
0.5 -0.0621375550999999984314037249078 0.49287812500000000026645352591
0.5 -0.0100849045000009993749978676192 -0.494999999999999995559107901499
0.5 -0.0100849045000009993749978676192 0.494999999999999995559107901499
0.5 0.0307741189000010004206409064409 -0.494999999999999995559107901499
0.5 0.0307741189000010004206409064409 0.494999999999999995559107901499
0.5 0.104160783999998993176738792954 -0.485839705999999982299897283156
0.5 0.104160783999998993176738792954 0.485839705999999982299897283156
0.5 0.188583951999999999138424300327 -0.45988982800000000050744120017
0.5 0.188583952000000998339146462968 0.45988982800000000050744120017
0.5 0.269812755999998987732624300406 0.417591884999999995997654878011
0.5 0.269812755999999986933346463047 -0.417591884999999995997654878011
0.5 0.343189516999999999491421931452 -0.359793788000000003268752379881
0.5 0.343189516999999999491421931452 0.359793788000000003268752379881
0.5 0.404523253000000027057581064582 -0.289071153000000025112825596807
0.5 0.404523253000000027057581064582 0.289071153000000025112825596807
0.5 0.450845058999999992455087749477 -0.209372725000000009520917387817
0.5 0.450845058999999992455087749477 0.209372725000000009520917387817
0.5 0.48086635500000002307885438313 -0.12531685200000000635078833966
0.5 0.48086635500000002307885438313 0.12531685200000000635078833966
0.5 0.494999999999999995559107901499 -0.0413874231000010001091382605409
0.5 0.494999999999999995559107901499 0.0413874231000000009084160979
3 23 61 63
3 63 25 23
3 60 58 20
3 20 22 60
3 26 64 67
3 67 29 26
3 65 62 24
3 24 27 65
3 33 31 69
3 69 71 33
3 68 66 28
3 28 30 68
3 37 35 73
3 73 75 37
3 72 70 32
3 32 34 72
3 75 74 36
3 36 37 75
3 34 36 74
3 74 72 34
3 71 73 35
3 35 33 71
3 30 32 70
3 70 68 30
3 67 69 31
3 31 29 67
3 27 28 66
3 66 65 27
3 64 26 25
3 25 63 64
3 22 24 62
3 62 60 22
3 21 59 61
3 61 23 21
3 41 3 1
3 1 39 41
3 0 38 39
3 39 1 0
3 43 5 3
3 3 41 43
3 2 40 38
3 38 0 2
3 45 7 5
3 5 43 45
3 4 42 40
3 40 2 4
3 47 9 7
3 7 45 47
3 6 44 42
3 42 4 6
3 48 11 9
3 9 47 48
3 8 46 44
3 44 6 8
3 51 12 11
3 11 48 51
3 8 10 49
3 49 46 8
3 52 15 12
3 12 51 52
3 10 13 50
3 50 49 10
3 55 17 15
3 15 52 55
3 13 14 53
3 53 50 13
3 57 19 17
3 17 55 57
3 14 16 54
3 54 53 14
3 19 57 59
3 59 21 19
3 16 18 56
3 56 54 16
3 53 54 56
3 49 50 53
3 44 46 49
3 40 42 44
3 39 38 40
3 43 41 39
3 47 45 43
3 51 48 47
3 55 52 51
3 59 57 55
3 63 61 59
3 67 64 63
3 71 69 67
3 75 73 71
3 72 74 75
3 68 70 72
3 65 66 68
3 60 62 65
3 56 58 60
3 49 53 56
3 40 44 49
3 43 39 40
3 51 47 43
3 59 55 51
3 67 63 59
3 75 71 67
3 68 72 75
3 60 65 68
3 49 56 60
3 40 49 60
3 51 43 40
3 67 59 51
3 68 75 67
3 40 60 68
3 51 40 68
3 68 67 51
3 58 56 18
3 18 20 58
3 20 18 16
3 16 14 13
3 13 10 8
3 8 6 4
3 4 2 0
3 0 1 3
3 3 5 7
3 7 9 11
3 11 12 15
3 15 17 19
3 19 21 23
3 23 25 26
3 26 29 31
3 31 33 35
3 35 37 36
3 36 34 32
3 32 30 28
3 28 27 24
3 24 22 20
3 20 16 13
3 13 8 4
3 4 0 3
3 3 7 11
3 11 15 19
3 19 23 26
3 26 31 35
3 35 36 32
3 32 28 24
3 24 20 13
3 24 13 4
3 4 3 11
3 11 19 26
3 26 35 32
3 32 24 4
3 32 4 11
3 11 26 32

View File

@ -0,0 +1,233 @@
ply
format ascii 1.0
element vertex 76
property double x
property double y
property double z
element face 148
property list uchar uchar vertex_indices
end_header
-0.494999999999999995559107901499 -0.5 -0.0413874231000000009084160979
-0.494999999999999995559107901499 -0.5 0.0413874231000010001091382605409
-0.494999999999999995559107901499 0.5 -0.0413874231000010001091382605409
-0.494999999999999995559107901499 0.5 0.0413874231000000009084160979
-0.48086635500000002307885438313 -0.5 -0.12531685200000000635078833966
-0.48086635500000002307885438313 -0.5 0.125316851999999007150066177019
-0.48086635500000002307885438313 0.5 -0.12531685200000000635078833966
-0.48086635500000002307885438313 0.5 0.12531685200000000635078833966
-0.450845058999999992455087749477 -0.5 -0.209372725000000009520917387817
-0.450845058999999992455087749477 -0.5 0.209372725000000009520917387817
-0.450845058999999992455087749477 0.5 -0.209372725000000009520917387817
-0.450845058999999992455087749477 0.5 0.209372725000000009520917387817
-0.404523253000000027057581064582 -0.5 -0.289071153000000025112825596807
-0.404523253000000027057581064582 -0.5 0.289071153000000025112825596807
-0.404523253000000027057581064582 0.5 -0.289071153000000025112825596807
-0.404523253000000027057581064582 0.5 0.289071153000000025112825596807
-0.343189517000000998692144094093 -0.5 0.35979378799999900406803021724
-0.343189516999999999491421931452 -0.5 -0.359793788000000003268752379881
-0.343189516999999999491421931452 0.5 -0.359793788000000003268752379881
-0.343189516999999999491421931452 0.5 0.359793788000000003268752379881
-0.269812755999999986933346463047 -0.5 -0.417591884999999995997654878011
-0.269812755999999986933346463047 0.5 -0.417591884999999995997654878011
-0.269812755999998987732624300406 -0.5 0.417591884999999995997654878011
-0.269812755999998987732624300406 0.5 0.417591884999999995997654878011
-0.188583952000000998339146462968 -0.5 -0.45988982800000000050744120017
-0.188583952000000998339146462968 -0.5 0.45988982800000000050744120017
-0.188583952000000998339146462968 0.5 0.45988982800000000050744120017
-0.188583951999999999138424300327 0.5 -0.45988982800000000050744120017
-0.104160783999998993176738792954 -0.5 -0.485839705999999982299897283156
-0.104160783999998993176738792954 -0.5 0.485839705999999982299897283156
-0.104160783999998993176738792954 0.5 -0.485839705999999982299897283156
-0.104160783999998993176738792954 0.5 0.485839705999999982299897283156
-0.0307741189000010004206409064409 -0.5 -0.494999999999999995559107901499
-0.0307741189000010004206409064409 -0.5 0.494999999999999995559107901499
-0.0307741189000010004206409064409 0.5 -0.494999999999999995559107901499
-0.0307741189000010004206409064409 0.5 0.494999999999999995559107901499
0.0100849045000009993749978676192 -0.5 -0.494999999999999995559107901499
0.0100849045000009993749978676192 -0.5 0.494999999999999995559107901499
0.0100849045000009993749978676192 0.5 -0.494999999999999995559107901499
0.0100849045000009993749978676192 0.5 0.494999999999999995559107901499
0.0621375550999999984314037249078 -0.5 -0.49287812500000000026645352591
0.0621375550999999984314037249078 -0.5 0.49287812500000000026645352591
0.0621375550999999984314037249078 0.5 -0.49287812500000000026645352591
0.0621375550999999984314037249078 0.5 0.49287812500000000026645352591
0.146484821999999986763540960055 -0.5 0.474893355000000016996608565023
0.146484821999999986763540960055 0.5 -0.474893355000000016996608565023
0.146484822000001013719838738325 -0.5 -0.474893355000000016996608565023
0.146484822000001013719838738325 0.5 0.474893355000000016996608565023
0.229889932999998991558499028542 -0.5 -0.440772940999999973676892750518
0.229889932999998991558499028542 0.5 0.440772940999999973676892750518
0.229889932999999990759221191183 -0.5 0.440772940999999973676892750518
0.229889932999999990759221191183 0.5 -0.440772940999999973676892750518
0.307765228000000001795655180103 -0.5 0.390507867000000008506077620041
0.307765228000000001795655180103 0.5 -0.390507867000000008506077620041
0.307765228000001000996377342744 -0.5 -0.390507867000000008506077620041
0.307765228000001000996377342744 0.5 0.390507867000000008506077620041
0.37558332999999999302076503227 -0.5 -0.325826384000000024432353029624
0.37558332999999999302076503227 -0.5 0.325826384000000024432353029624
0.37558332999999999302076503227 0.5 -0.325826384000000024432353029624
0.37558332999999999302076503227 0.5 0.325826384000000024432353029624
0.429683015999999973200118574823 -0.5 -0.250061311999999980049125269943
0.429683015999999973200118574823 -0.5 0.250061311999999980049125269943
0.429683015999999973200118574823 0.5 -0.250061311999999980049125269943
0.429683015999999973200118574823 0.5 0.250061311999999980049125269943
0.467904598999999976616237518101 -0.5 -0.167597240000000008430802722614
0.467904598999999976616237518101 -0.5 0.167597240000000008430802722614
0.467904598999999976616237518101 0.5 -0.167597240000000008430802722614
0.467904598999999976616237518101 0.5 0.167597240000000008430802722614
0.489834869000000006078465730752 -0.5 -0.0830808390000000035469085446493
0.489834869000000006078465730752 -0.5 0.0830808390000000035469085446493
0.489834869000000006078465730752 0.5 -0.0830808390000000035469085446493
0.489834869000000006078465730752 0.5 0.0830808390000000035469085446493
0.494999999999999995559107901499 -0.5 -0.0203414706000000014562978378763
0.494999999999999995559107901499 -0.5 0.0203414706000010006570200005172
0.494999999999999995559107901499 0.5 -0.0203414706000000014562978378763
0.494999999999999995559107901499 0.5 0.0203414706000010006570200005172
3 29 31 26
3 26 25 29
3 30 34 32
3 32 28 30
3 22 23 19
3 19 16 22
3 21 27 24
3 24 20 21
3 13 15 11
3 11 9 13
3 18 17 12
3 12 14 18
3 5 7 3
3 3 1 5
3 10 8 4
3 4 6 10
3 2 0 1
3 1 3 2
3 0 2 6
3 6 4 0
3 7 5 9
3 9 11 7
3 8 10 14
3 14 12 8
3 15 13 16
3 16 19 15
3 20 17 18
3 18 21 20
3 23 22 25
3 25 26 23
3 28 24 27
3 27 30 28
3 33 35 31
3 31 29 33
3 75 71 69
3 69 73 75
3 73 72 74
3 74 75 73
3 71 67 65
3 65 69 71
3 72 68 70
3 70 74 72
3 67 63 61
3 61 65 67
3 68 64 66
3 66 70 68
3 63 59 57
3 57 61 63
3 64 60 62
3 62 66 64
3 55 52 57
3 57 59 55
3 60 56 58
3 58 62 60
3 49 50 52
3 52 55 49
3 56 54 53
3 53 58 56
3 47 44 50
3 50 49 47
3 54 48 51
3 51 53 54
3 43 41 44
3 44 47 43
3 48 46 45
3 45 51 48
3 39 37 41
3 41 43 39
3 46 40 42
3 42 45 46
3 37 39 35
3 35 33 37
3 40 36 38
3 38 42 40
3 45 42 38
3 53 51 45
3 62 58 53
3 70 66 62
3 75 74 70
3 67 71 75
3 59 63 67
3 49 55 59
3 43 47 49
3 35 39 43
3 26 31 35
3 19 23 26
3 11 15 19
3 3 7 11
3 6 2 3
3 14 10 6
3 21 18 14
3 30 27 21
3 38 34 30
3 53 45 38
3 70 62 53
3 67 75 70
3 49 59 67
3 35 43 49
3 19 26 35
3 3 11 19
3 14 6 3
3 30 21 14
3 53 38 30
3 70 53 30
3 49 67 70
3 19 35 49
3 14 3 19
3 70 30 14
3 49 70 14
3 14 19 49
3 34 38 36
3 36 32 34
3 32 36 40
3 40 46 48
3 48 54 56
3 56 60 64
3 64 68 72
3 72 73 69
3 69 65 61
3 61 57 52
3 52 50 44
3 44 41 37
3 37 33 29
3 29 25 22
3 22 16 13
3 13 9 5
3 5 1 0
3 0 4 8
3 8 12 17
3 17 20 24
3 24 28 32
3 32 40 48
3 48 56 64
3 64 72 69
3 69 61 52
3 52 44 37
3 37 29 22
3 22 13 5
3 5 0 8
3 8 17 24
3 24 32 48
3 24 48 64
3 64 69 52
3 52 37 22
3 22 5 8
3 8 24 64
3 8 64 52
3 52 22 8

View File

@ -0,0 +1,233 @@
ply
format ascii 1.0
element vertex 76
property double x
property double y
property double z
element face 148
property list uchar uchar vertex_indices
end_header
-0.494999999999999995559107901499 -0.0413874231000010001091382605409 -0.5
-0.494999999999999995559107901499 -0.0413874231000000009084160979 0.5
-0.494999999999999995559107901499 0.0413874231000000009084160979 -0.5
-0.494999999999999995559107901499 0.0413874231000010001091382605409 0.5
-0.48086635500000002307885438313 -0.12531685200000000635078833966 0.5
-0.48086635500000002307885438313 -0.125316851999999007150066177019 -0.5
-0.48086635500000002307885438313 0.12531685200000000635078833966 -0.5
-0.48086635500000002307885438313 0.12531685200000000635078833966 0.5
-0.450845058999999992455087749477 -0.209372725000000009520917387817 -0.5
-0.450845058999999992455087749477 -0.209372725000000009520917387817 0.5
-0.450845058999999992455087749477 0.209372725000000009520917387817 -0.5
-0.450845058999999992455087749477 0.209372725000000009520917387817 0.5
-0.404523253000000027057581064582 -0.289071153000000025112825596807 -0.5
-0.404523253000000027057581064582 -0.289071153000000025112825596807 0.5
-0.404523253000000027057581064582 0.289071153000000025112825596807 -0.5
-0.404523253000000027057581064582 0.289071153000000025112825596807 0.5
-0.343189517000000998692144094093 -0.35979378799999900406803021724 -0.5
-0.343189516999999999491421931452 -0.359793788000000003268752379881 0.5
-0.343189516999999999491421931452 0.359793788000000003268752379881 -0.5
-0.343189516999999999491421931452 0.359793788000000003268752379881 0.5
-0.269812755999999986933346463047 0.417591884999999995997654878011 -0.5
-0.269812755999999986933346463047 0.417591884999999995997654878011 0.5
-0.269812755999998987732624300406 -0.417591884999999995997654878011 -0.5
-0.269812755999998987732624300406 -0.417591884999999995997654878011 0.5
-0.188583952000000998339146462968 -0.45988982800000000050744120017 -0.5
-0.188583952000000998339146462968 -0.45988982800000000050744120017 0.5
-0.188583952000000998339146462968 0.45988982800000000050744120017 -0.5
-0.188583951999999999138424300327 0.45988982800000000050744120017 0.5
-0.104160783999998993176738792954 -0.485839705999999982299897283156 -0.5
-0.104160783999998993176738792954 -0.485839705999999982299897283156 0.5
-0.104160783999998993176738792954 0.485839705999999982299897283156 -0.5
-0.104160783999998993176738792954 0.485839705999999982299897283156 0.5
-0.0307741189000010004206409064409 -0.494999999999999995559107901499 -0.5
-0.0307741189000010004206409064409 -0.494999999999999995559107901499 0.5
-0.0307741189000010004206409064409 0.494999999999999995559107901499 -0.5
-0.0307741189000010004206409064409 0.494999999999999995559107901499 0.5
0.0100849045000009993749978676192 -0.494999999999999995559107901499 -0.5
0.0100849045000009993749978676192 -0.494999999999999995559107901499 0.5
0.0100849045000009993749978676192 0.494999999999999995559107901499 -0.5
0.0100849045000009993749978676192 0.494999999999999995559107901499 0.5
0.0621375550999999984314037249078 -0.49287812500000000026645352591 -0.5
0.0621375550999999984314037249078 -0.49287812500000000026645352591 0.5
0.0621375550999999984314037249078 0.49287812500000000026645352591 -0.5
0.0621375550999999984314037249078 0.49287812500000000026645352591 0.5
0.146484821999999986763540960055 -0.474893355000000016996608565023 -0.5
0.146484821999999986763540960055 0.474893355000000016996608565023 0.5
0.146484822000001013719838738325 -0.474893355000000016996608565023 0.5
0.146484822000001013719838738325 0.474893355000000016996608565023 -0.5
0.229889932999998991558499028542 -0.440772940999999973676892750518 0.5
0.229889932999998991558499028542 0.440772940999999973676892750518 -0.5
0.229889932999999990759221191183 -0.440772940999999973676892750518 -0.5
0.229889932999999990759221191183 0.440772940999999973676892750518 0.5
0.307765228000000001795655180103 -0.390507867000000008506077620041 -0.5
0.307765228000000001795655180103 0.390507867000000008506077620041 0.5
0.307765228000001000996377342744 -0.390507867000000008506077620041 0.5
0.307765228000001000996377342744 0.390507867000000008506077620041 -0.5
0.37558332999999999302076503227 -0.325826384000000024432353029624 -0.5
0.37558332999999999302076503227 -0.325826384000000024432353029624 0.5
0.37558332999999999302076503227 0.325826384000000024432353029624 -0.5
0.37558332999999999302076503227 0.325826384000000024432353029624 0.5
0.429683015999999973200118574823 -0.250061311999999980049125269943 -0.5
0.429683015999999973200118574823 -0.250061311999999980049125269943 0.5
0.429683015999999973200118574823 0.250061311999999980049125269943 -0.5
0.429683015999999973200118574823 0.250061311999999980049125269943 0.5
0.467904598999999976616237518101 -0.167597240000000008430802722614 -0.5
0.467904598999999976616237518101 -0.167597240000000008430802722614 0.5
0.467904598999999976616237518101 0.167597240000000008430802722614 -0.5
0.467904598999999976616237518101 0.167597240000000008430802722614 0.5
0.489834869000000006078465730752 -0.0830808390000000035469085446493 -0.5
0.489834869000000006078465730752 -0.0830808390000000035469085446493 0.5
0.489834869000000006078465730752 0.0830808390000000035469085446493 -0.5
0.489834869000000006078465730752 0.0830808390000000035469085446493 0.5
0.494999999999999995559107901499 -0.0203414706000010006570200005172 -0.5
0.494999999999999995559107901499 -0.0203414706000010006570200005172 0.5
0.494999999999999995559107901499 0.0203414706000000014562978378763 -0.5
0.494999999999999995559107901499 0.0203414706000000014562978378763 0.5
3 28 29 25
3 25 24 28
3 31 35 34
3 34 30 31
3 22 23 17
3 17 16 22
3 21 27 26
3 26 20 21
3 12 13 9
3 9 8 12
3 19 18 14
3 14 15 19
3 5 4 1
3 1 0 5
3 11 10 6
3 6 7 11
3 3 2 0
3 0 1 3
3 2 3 7
3 7 6 2
3 4 5 8
3 8 9 4
3 10 11 15
3 15 14 10
3 13 12 16
3 16 17 13
3 20 18 19
3 19 21 20
3 23 22 24
3 24 25 23
3 30 26 27
3 27 31 30
3 32 33 29
3 29 28 32
3 73 69 68
3 68 72 73
3 72 74 75
3 75 73 72
3 69 65 64
3 64 68 69
3 74 70 71
3 71 75 74
3 65 61 60
3 60 64 65
3 70 66 67
3 67 71 70
3 61 57 56
3 56 60 61
3 66 62 63
3 63 67 66
3 54 52 56
3 56 57 54
3 62 58 59
3 59 63 62
3 48 50 52
3 52 54 48
3 58 55 53
3 53 59 58
3 46 44 50
3 50 48 46
3 55 49 51
3 51 53 55
3 41 40 44
3 44 46 41
3 49 47 45
3 45 51 49
3 37 36 40
3 40 41 37
3 47 42 43
3 43 45 47
3 36 37 33
3 33 32 36
3 42 38 39
3 39 43 42
3 43 39 35
3 35 31 27
3 27 21 19
3 19 15 11
3 11 7 3
3 3 1 4
3 4 9 13
3 13 17 23
3 23 25 29
3 29 33 37
3 37 41 46
3 46 48 54
3 54 57 61
3 61 65 69
3 69 73 75
3 75 71 67
3 67 63 59
3 59 53 51
3 51 45 43
3 43 35 27
3 27 19 11
3 11 3 4
3 4 13 23
3 23 29 37
3 37 46 54
3 54 61 69
3 69 75 67
3 67 59 51
3 51 43 27
3 51 27 11
3 11 4 23
3 23 37 54
3 54 69 67
3 67 51 11
3 67 11 23
3 23 54 67
3 35 39 38
3 38 34 35
3 30 34 38
3 20 26 30
3 14 18 20
3 6 10 14
3 0 2 6
3 8 5 0
3 16 12 8
3 24 22 16
3 32 28 24
3 40 36 32
3 50 44 40
3 56 52 50
3 64 60 56
3 72 68 64
3 70 74 72
3 62 66 70
3 55 58 62
3 47 49 55
3 38 42 47
3 20 30 38
3 6 14 20
3 8 0 6
3 24 16 8
3 40 32 24
3 56 50 40
3 72 64 56
3 62 70 72
3 47 55 62
3 20 38 47
3 6 20 47
3 24 8 6
3 56 40 24
3 62 72 56
3 6 47 62
3 24 6 62
3 62 56 24

BIN
thirdparty/carve-1.4.0/data/elephant.ply vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
thirdparty/carve-1.4.0/data/hippo.ply vendored Normal file

Binary file not shown.

BIN
thirdparty/carve-1.4.0/data/horse2.ply vendored Normal file

Binary file not shown.

44
thirdparty/carve-1.4.0/data/ico.ply vendored Normal file
View File

@ -0,0 +1,44 @@
ply
format ascii 1.0
element vertex 12
property float32 x
property float32 y
property float32 z
property float32 nx
property float32 ny
property float32 nz
element face 20
property list uint8 int32 vertex_indices
end_header
-0.276385 -0.850640 -0.447215 -0.276376 -0.850642 -0.447188
0.000000 0.000000 -1.000000 0.000000 0.000000 -1.000000
0.723600 -0.525720 -0.447215 0.723594 -0.525712 -0.447188
0.723600 0.525720 -0.447215 0.723594 0.525712 -0.447188
-0.894425 0.000000 -0.447215 -0.894406 0.000000 -0.447188
-0.276385 0.850640 -0.447215 -0.276376 0.850642 -0.447188
0.894425 0.000000 0.447215 0.894406 0.000000 0.447188
0.276385 -0.850640 0.447215 0.276376 -0.850642 0.447188
-0.723600 -0.525720 0.447215 -0.723594 -0.525712 0.447188
-0.723600 0.525720 0.447215 -0.723594 0.525712 0.447188
0.276385 0.850640 0.447215 0.276376 0.850642 0.447188
0.000000 0.000000 1.000000 0.000000 0.000000 1.000000
3 0 1 2
3 2 1 3
3 4 1 0
3 5 1 4
3 3 1 5
3 2 3 6
3 0 2 7
3 4 0 8
3 5 4 9
3 3 5 10
3 6 7 2
3 7 8 0
3 8 9 4
3 9 10 5
3 10 6 3
3 7 6 11
3 8 7 11
3 9 8 11
3 10 9 11
3 6 10 11

134
thirdparty/carve-1.4.0/data/ico2.ply vendored Normal file
View File

@ -0,0 +1,134 @@
ply
format ascii 1.0
element vertex 42
property float32 x
property float32 y
property float32 z
property float32 nx
property float32 ny
property float32 nz
element face 80
property list uint8 int32 vertex_indices
end_header
0.601497 -0.437008 -1.203007 0.425306 -0.309000 -0.850642
0.371753 -1.144115 -0.743505 0.262856 -0.808985 -0.525712
-0.229747 -0.707100 -1.203007 -0.162450 -0.499985 -0.850642
0.601497 0.437008 -1.203007 0.425306 0.309000 -0.850642
1.202998 0.000000 -0.743503 0.850642 0.000000 -0.525712
-0.973247 -0.707102 -0.743503 -0.688162 -0.499985 -0.525712
-0.743494 0.000000 -1.203003 -0.525712 0.000000 -0.850642
-0.973247 0.707102 -0.743503 -0.688162 0.499985 -0.525712
-0.229747 0.707100 -1.203007 -0.162450 0.499985 -0.850642
0.371753 1.144115 -0.743505 0.262856 0.808985 -0.525712
1.344999 0.437010 0.000000 0.951048 0.309000 0.000000
1.344999 -0.437010 0.000000 0.951048 -0.309000 0.000000
0.831254 -1.144122 0.000000 0.587756 -0.809015 0.000000
0.000000 -1.414214 0.000000 0.000000 -1.000000 0.000000
-0.831254 -1.144122 0.000000 -0.587756 -0.809015 0.000000
-1.344999 -0.437010 0.000000 -0.951048 -0.309000 0.000000
-1.344999 0.437010 0.000000 -0.951048 0.309000 0.000000
-0.831254 1.144122 0.000000 -0.587756 0.809015 0.000000
0.000000 1.414214 0.000000 0.000000 1.000000 0.000000
0.831254 1.144122 0.000000 0.587756 0.809015 0.000000
0.973247 -0.707102 0.743503 0.688162 -0.499985 0.525712
-0.371753 -1.144115 0.743505 -0.262856 -0.808985 0.525712
-1.202998 0.000000 0.743503 -0.850642 0.000000 0.525712
-0.371753 1.144115 0.743505 -0.262856 0.808985 0.525712
0.973247 0.707102 0.743503 0.688162 0.499985 0.525712
0.743494 0.000000 1.203003 0.525712 0.000000 0.850642
0.229747 -0.707100 1.203007 0.162450 -0.499985 0.850642
-0.601497 -0.437008 1.203007 -0.425306 -0.309000 0.850642
-0.601497 0.437008 1.203007 -0.425306 0.309000 0.850642
0.229747 0.707100 1.203007 0.162450 0.499985 0.850642
0.390867 1.202987 0.632457 0.276376 0.850642 0.447188
0.000000 0.000000 1.414214 0.000000 0.000000 1.000000
1.264908 0.000000 0.632457 0.894406 0.000000 0.447188
-1.023325 0.743480 0.632457 -0.723594 0.525712 0.447188
-1.023325 -0.743480 0.632457 -0.723594 -0.525712 0.447188
0.390867 -1.202987 0.632457 0.276376 -0.850642 0.447188
1.023325 0.743480 -0.632457 0.723594 0.525712 -0.447188
-0.390867 1.202987 -0.632457 -0.276376 0.850642 -0.447188
-1.264908 0.000000 -0.632457 -0.894406 0.000000 -0.447188
-0.390867 -1.202987 -0.632457 -0.276376 -0.850642 -0.447188
1.023325 -0.743480 -0.632457 0.723594 -0.525712 -0.447188
0.000000 0.000000 -1.414214 0.000000 0.000000 -1.000000
3 0 1 2
3 0 3 4
3 2 5 6
3 6 7 8
3 8 9 3
3 4 10 11
3 1 12 13
3 5 14 15
3 7 16 17
3 9 18 19
3 11 20 12
3 13 21 14
3 15 22 16
3 17 23 18
3 19 24 10
3 20 25 26
3 21 26 27
3 22 27 28
3 23 28 29
3 24 29 25
3 30 29 24
3 31 25 29
3 32 24 25
3 33 28 23
3 31 29 28
3 30 23 29
3 34 27 22
3 31 28 27
3 33 22 28
3 35 26 21
3 31 27 26
3 34 21 27
3 32 25 20
3 31 26 25
3 35 20 26
3 36 19 10
3 32 10 24
3 30 24 19
3 37 17 18
3 30 18 23
3 33 23 17
3 38 15 16
3 33 16 22
3 34 22 15
3 39 13 14
3 34 14 21
3 35 21 13
3 40 11 12
3 35 12 20
3 32 20 11
3 37 18 9
3 30 19 18
3 36 9 19
3 38 16 7
3 33 17 16
3 37 7 17
3 39 14 5
3 34 15 14
3 38 5 15
3 40 12 1
3 35 13 12
3 39 1 13
3 36 10 4
3 32 11 10
3 40 4 11
3 41 8 3
3 36 3 9
3 37 9 8
3 41 6 8
3 37 8 7
3 38 7 6
3 41 2 6
3 38 6 5
3 39 5 2
3 41 3 0
3 36 4 3
3 40 0 4
3 41 0 2
3 39 2 1
3 40 1 0

494
thirdparty/carve-1.4.0/data/ico3.ply vendored Normal file
View File

@ -0,0 +1,494 @@
ply
format ascii 1.0
element vertex 162
property float32 x
property float32 y
property float32 z
property float32 nx
property float32 ny
property float32 nz
element face 320
property list uint8 int32 vertex_indices
end_header
0.361804 -0.587779 -0.723612 0.350017 -0.587725 -0.729423
0.512753 -0.693775 -0.505727 0.523881 -0.686819 -0.503769
0.262869 -0.809012 -0.525738 0.262856 -0.808985 -0.525712
0.597194 -0.433882 -0.674615 0.604358 -0.439100 -0.664754
0.425323 -0.309011 -0.850654 0.425306 -0.309000 -0.850642
0.723600 -0.525720 -0.447215 0.723594 -0.525712 -0.447218
0.138197 -0.425320 -0.894430 0.141789 -0.436445 -0.888455
0.052790 -0.688185 -0.723612 0.062288 -0.681204 -0.729423
-0.162456 -0.499995 -0.850654 -0.162450 -0.499985 -0.850642
-0.228103 -0.702042 -0.674615 -0.230842 -0.710471 -0.664754
-0.007026 -0.862665 -0.505728 -0.020112 -0.863582 -0.503769
-0.276385 -0.850640 -0.447215 -0.276376 -0.850642 -0.447218
-0.084442 -0.259889 -0.961939 -0.080477 -0.247719 -0.965453
0.221076 -0.160619 -0.961939 0.210730 -0.153081 -0.965453
0.000000 0.000000 -1.000000 0.000000 0.000000 -1.000000
0.670817 -0.162457 -0.723611 0.667104 -0.151250 -0.729423
0.850648 0.000000 -0.525736 0.850642 0.000000 -0.525712
0.818272 -0.273262 -0.505726 0.815088 -0.285989 -0.503769
0.447210 0.000000 -0.894429 0.458907 0.000000 -0.888455
0.670817 0.162457 -0.723611 0.667104 0.151250 -0.729423
0.425323 0.309011 -0.850654 0.425306 0.309000 -0.850642
0.597194 0.433882 -0.674615 0.604358 0.439100 -0.664754
0.723600 0.525720 -0.447215 0.723594 0.525712 -0.447218
0.818272 0.273262 -0.505726 0.815088 0.285989 -0.503769
0.221076 0.160619 -0.961939 0.210730 0.153081 -0.965453
-0.447211 -0.525727 -0.723612 -0.450789 -0.514481 -0.729423
-0.501373 -0.702043 -0.505727 -0.491317 -0.710471 -0.503769
-0.688189 -0.499997 -0.525736 -0.688162 -0.499985 -0.525712
-0.361800 -0.262863 -0.894429 -0.371258 -0.269723 -0.888455
-0.638195 -0.262864 -0.723609 -0.628620 -0.269723 -0.729423
-0.525730 0.000000 -0.850652 -0.525712 0.000000 -0.850642
-0.738174 0.000000 -0.674610 -0.747032 0.000000 -0.664754
-0.822618 -0.259890 -0.505724 -0.827540 -0.247719 -0.503769
-0.894425 0.000000 -0.447215 -0.894406 0.000000 -0.447188
-0.273266 0.000000 -0.961939 -0.260475 0.000000 -0.965453
-0.638195 0.262864 -0.723609 -0.628620 0.269723 -0.729423
-0.822618 0.259890 -0.505724 -0.827540 0.247719 -0.503769
-0.688189 0.499997 -0.525736 -0.688162 0.499985 -0.525712
-0.361800 0.262863 -0.894429 -0.371258 0.269723 -0.888455
-0.447211 0.525727 -0.723612 -0.450789 0.514481 -0.729423
-0.162456 0.499995 -0.850654 -0.162450 0.499985 -0.850642
-0.228103 0.702042 -0.674615 -0.230842 0.710471 -0.664754
-0.501373 0.702043 -0.505727 -0.491317 0.710471 -0.503769
-0.276385 0.850640 -0.447215 -0.276376 0.850642 -0.447218
-0.084442 0.259889 -0.961939 -0.080477 0.247719 -0.965453
0.052790 0.688185 -0.723612 0.062288 0.681204 -0.729423
-0.007026 0.862665 -0.505728 -0.020112 0.863582 -0.503769
0.262869 0.809012 -0.525738 0.262856 0.808985 -0.525712
0.138197 0.425320 -0.894430 0.141789 0.436445 -0.888455
0.361804 0.587779 -0.723612 0.350017 0.587725 -0.729423
0.512753 0.693775 -0.505727 0.523881 0.686819 -0.503769
0.947213 -0.162458 -0.276396 0.950743 -0.151250 -0.270486
0.951058 -0.309013 0.000000 0.951048 -0.309000 0.000000
0.870465 -0.433883 -0.232456 0.864834 -0.439100 -0.243294
0.947213 0.162458 -0.276396 0.950743 0.151250 -0.270486
1.000000 0.000000 0.000000 0.999908 0.000000 -0.013123
0.951058 0.309013 0.000000 0.951048 0.309000 0.000000
0.959253 0.160620 0.232455 0.957793 0.153081 0.243263
0.894425 0.000000 0.447215 0.894406 0.000000 0.447188
0.959253 -0.160620 0.232455 0.957793 -0.153081 0.243263
0.870465 0.433883 -0.232456 0.864834 0.439100 -0.243294
0.138199 -0.951055 -0.276397 0.149937 -0.950957 -0.270486
0.000000 -1.000000 0.000000 0.000000 -1.000000 0.000000
-0.143661 -0.961938 -0.232456 -0.150334 -0.958220 -0.243294
0.447216 -0.850648 -0.276397 0.437666 -0.857479 -0.270486
0.309017 -0.951056 0.000000 0.308969 -0.950957 -0.013123
0.587786 -0.809017 0.000000 0.587756 -0.809015 0.000000
0.449185 -0.862668 0.232457 0.441572 -0.863582 0.243294
0.276385 -0.850640 0.447215 0.276376 -0.850642 0.447218
0.143661 -0.961938 0.232456 0.150334 -0.958220 0.243294
0.681641 -0.693779 -0.232457 0.684866 -0.686819 -0.243294
-0.861804 -0.425322 -0.276396 -0.858089 -0.436445 -0.270486
-0.951058 -0.309013 0.000000 -0.951048 -0.309000 0.000000
-0.959253 -0.160620 -0.232455 -0.957793 -0.153081 -0.243263
-0.670820 -0.688190 -0.276396 -0.680258 -0.681204 -0.270486
-0.809018 -0.587783 0.000000 -0.808924 -0.587725 -0.013123
-0.587786 -0.809017 0.000000 -0.587756 -0.809015 0.000000
-0.681641 -0.693779 0.232457 -0.684866 -0.686819 0.243294
-0.723600 -0.525720 0.447215 -0.723594 -0.525712 0.447218
-0.870465 -0.433883 0.232456 -0.864834 -0.439100 0.243294
-0.449185 -0.862668 -0.232457 -0.441572 -0.863582 -0.243294
-0.670820 0.688190 -0.276396 -0.680258 0.681204 -0.270486
-0.587786 0.809017 0.000000 -0.587756 0.809015 0.000000
-0.449185 0.862668 -0.232457 -0.441572 0.863582 -0.243294
-0.861804 0.425322 -0.276396 -0.858089 0.436445 -0.270486
-0.809018 0.587783 0.000000 -0.808924 0.587725 -0.013123
-0.951058 0.309013 0.000000 -0.951048 0.309000 0.000000
-0.870465 0.433883 0.232456 -0.864834 0.439100 0.243294
-0.723600 0.525720 0.447215 -0.723594 0.525712 0.447218
-0.681641 0.693779 0.232457 -0.684866 0.686819 0.243294
-0.959253 0.160620 -0.232455 -0.957793 0.153081 -0.243263
0.447216 0.850648 -0.276397 0.437666 0.857479 -0.270486
0.587786 0.809017 0.000000 0.587756 0.809015 0.000000
0.681641 0.693779 -0.232457 0.684866 0.686819 -0.243294
0.138199 0.951055 -0.276397 0.149937 0.950957 -0.270486
0.309017 0.951056 0.000000 0.308969 0.950957 -0.013123
0.000000 1.000000 0.000000 0.000000 1.000000 0.000000
0.143661 0.961938 0.232456 0.150334 0.958220 0.243294
0.276385 0.850640 0.447215 0.276376 0.850642 0.447218
0.449185 0.862668 0.232457 0.441572 0.863582 0.243294
-0.143661 0.961938 -0.232456 -0.150334 0.958220 -0.243294
0.861804 -0.425322 0.276396 0.858089 -0.436445 0.270486
0.822618 -0.259890 0.505724 0.827540 -0.247719 0.503769
0.688189 -0.499997 0.525736 0.688162 -0.499985 0.525712
0.809018 -0.587783 0.000000 0.808924 -0.587725 0.013123
0.670820 -0.688190 0.276396 0.680258 -0.681204 0.270486
0.501373 -0.702043 0.505727 0.491317 -0.710471 0.503769
-0.138199 -0.951055 0.276397 -0.149937 -0.950957 0.270486
0.007026 -0.862665 0.505728 0.020112 -0.863582 0.503769
-0.262869 -0.809012 0.525738 -0.262856 -0.808985 0.525712
-0.309017 -0.951056 0.000000 -0.308969 -0.950957 0.013123
-0.447216 -0.850648 0.276397 -0.437666 -0.857479 0.270486
-0.512753 -0.693775 0.505727 -0.523881 -0.686819 0.503769
-0.947213 -0.162458 0.276396 -0.950743 -0.151250 0.270486
-0.818272 -0.273262 0.505726 -0.815088 -0.285989 0.503769
-0.850648 0.000000 0.525736 -0.850642 0.000000 0.525712
-1.000000 0.000000 0.000000 -0.999908 0.000000 0.013123
-0.947213 0.162458 0.276396 -0.950743 0.151250 0.270486
-0.818272 0.273262 0.505726 -0.815088 0.285989 0.503769
-0.447216 0.850648 0.276397 -0.437666 0.857479 0.270486
-0.512753 0.693775 0.505727 -0.523881 0.686819 0.503769
-0.262869 0.809012 0.525738 -0.262856 0.808985 0.525712
-0.309017 0.951056 0.000000 -0.308969 0.950957 0.013123
-0.138199 0.951055 0.276397 -0.149937 0.950957 0.270486
0.007026 0.862665 0.505728 0.020112 0.863582 0.503769
0.670820 0.688190 0.276396 0.680258 0.681204 0.270486
0.501373 0.702043 0.505727 0.491317 0.710471 0.503769
0.688189 0.499997 0.525736 0.688162 0.499985 0.525712
0.809018 0.587783 0.000000 0.808924 0.587725 0.013123
0.861804 0.425322 0.276396 0.858089 0.436445 0.270486
0.822618 0.259890 0.505724 0.827540 0.247719 0.503769
0.447211 -0.525727 0.723612 0.450789 -0.514481 0.729423
0.162456 -0.499995 0.850654 0.162450 -0.499985 0.850642
0.228103 -0.702042 0.674615 0.230842 -0.710471 0.664754
0.638195 -0.262864 0.723609 0.628620 -0.269723 0.729423
0.361800 -0.262863 0.894429 0.371258 -0.269723 0.888455
0.525730 0.000000 0.850652 0.525712 0.000000 0.850642
0.273266 0.000000 0.961939 0.260475 0.000000 0.965453
0.000000 0.000000 1.000000 0.000000 0.000000 1.000000
0.084442 -0.259889 0.961939 0.080477 -0.247719 0.965453
0.738174 0.000000 0.674610 0.747032 0.000000 0.664754
-0.361804 -0.587779 0.723612 -0.350017 -0.587725 0.729423
-0.425323 -0.309011 0.850654 -0.425306 -0.309000 0.850642
-0.597194 -0.433882 0.674615 -0.604358 -0.439100 0.664754
-0.052790 -0.688185 0.723612 -0.062288 -0.681204 0.729423
-0.138197 -0.425320 0.894430 -0.141789 -0.436445 0.888455
-0.221076 -0.160619 0.961939 -0.210730 -0.153081 0.965453
-0.670817 0.162457 0.723611 -0.667104 0.151250 0.729423
-0.425323 0.309011 0.850654 -0.425306 0.309000 0.850642
-0.597194 0.433882 0.674615 -0.604358 0.439100 0.664754
-0.670817 -0.162457 0.723611 -0.667104 -0.151250 0.729423
-0.447210 0.000000 0.894429 -0.458907 0.000000 0.888455
-0.221076 0.160619 0.961939 -0.210730 0.153081 0.965453
-0.052790 0.688185 0.723612 -0.062288 0.681204 0.729423
0.162456 0.499995 0.850654 0.162450 0.499985 0.850642
0.228103 0.702042 0.674615 0.230842 0.710471 0.664754
-0.361804 0.587779 0.723612 -0.350017 0.587725 0.729423
-0.138197 0.425320 0.894430 -0.141789 0.436445 0.888455
0.084442 0.259889 0.961939 0.080477 0.247719 0.965453
0.638195 0.262864 0.723609 0.628620 0.269723 0.729423
0.447211 0.525727 0.723612 0.450789 0.514481 0.729423
0.361800 0.262863 0.894429 0.371258 0.269723 0.888455
3 0 1 2
3 1 0 3
3 4 3 0
3 3 5 1
3 0 6 4
3 6 0 7
3 2 7 0
3 7 8 6
3 9 10 11
3 10 9 7
3 8 7 9
3 7 2 10
3 12 6 8
3 6 12 13
3 14 13 12
3 13 4 6
3 15 16 17
3 17 3 15
3 4 15 3
3 3 17 5
3 15 4 18
3 18 19 15
3 16 15 19
3 19 18 20
3 21 22 23
3 23 19 21
3 20 21 19
3 19 23 16
3 24 20 18
3 18 13 24
3 14 24 13
3 13 18 4
3 25 26 27
3 26 25 9
3 8 9 25
3 9 11 26
3 25 28 8
3 28 25 29
3 27 29 25
3 29 30 28
3 31 32 33
3 32 31 29
3 30 29 31
3 29 27 32
3 34 28 30
3 28 34 12
3 14 12 34
3 12 8 28
3 35 36 37
3 36 35 31
3 30 31 35
3 31 33 36
3 35 38 30
3 38 35 39
3 37 39 35
3 39 40 38
3 41 42 43
3 42 41 39
3 40 39 41
3 39 37 42
3 44 38 40
3 38 44 34
3 14 34 44
3 34 30 38
3 45 46 47
3 46 45 41
3 40 41 45
3 41 43 46
3 45 48 40
3 48 45 49
3 47 49 45
3 49 20 48
3 21 50 22
3 50 21 49
3 20 49 21
3 49 47 50
3 24 48 20
3 48 24 44
3 14 44 24
3 44 40 48
3 51 52 53
3 53 17 51
3 16 51 17
3 17 53 5
3 51 16 54
3 54 55 51
3 52 51 55
3 55 54 56
3 57 58 59
3 59 55 57
3 56 57 55
3 55 59 52
3 60 56 54
3 54 23 60
3 22 60 23
3 23 54 16
3 61 62 63
3 63 10 61
3 2 61 10
3 10 63 11
3 61 2 64
3 64 65 61
3 62 61 65
3 65 64 66
3 67 68 69
3 69 65 67
3 66 67 65
3 65 69 62
3 70 66 64
3 64 1 70
3 5 70 1
3 1 64 2
3 71 72 73
3 73 32 71
3 27 71 32
3 32 73 33
3 71 27 74
3 74 75 71
3 72 71 75
3 75 74 76
3 77 78 79
3 79 75 77
3 76 77 75
3 75 79 72
3 80 76 74
3 74 26 80
3 11 80 26
3 26 74 27
3 81 82 83
3 83 42 81
3 37 81 42
3 42 83 43
3 81 37 84
3 84 85 81
3 82 81 85
3 85 84 86
3 87 88 89
3 89 85 87
3 86 87 85
3 85 89 82
3 90 86 84
3 84 36 90
3 33 90 36
3 36 84 37
3 91 92 93
3 93 50 91
3 47 91 50
3 50 93 22
3 91 47 94
3 94 95 91
3 92 91 95
3 95 94 96
3 97 98 99
3 99 95 97
3 96 97 95
3 95 99 92
3 100 96 94
3 94 46 100
3 43 100 46
3 46 94 47
3 101 102 103
3 102 101 59
3 52 59 101
3 59 58 102
3 101 104 52
3 104 101 105
3 103 105 101
3 105 66 104
3 67 106 68
3 106 67 105
3 66 105 67
3 105 103 106
3 70 104 66
3 104 70 53
3 5 53 70
3 53 52 104
3 107 108 109
3 108 107 69
3 62 69 107
3 69 68 108
3 107 110 62
3 110 107 111
3 109 111 107
3 111 76 110
3 77 112 78
3 112 77 111
3 76 111 77
3 111 109 112
3 80 110 76
3 110 80 63
3 11 63 80
3 63 62 110
3 113 114 115
3 114 113 79
3 72 79 113
3 79 78 114
3 113 116 72
3 116 113 117
3 115 117 113
3 117 86 116
3 87 118 88
3 118 87 117
3 86 117 87
3 117 115 118
3 90 116 86
3 116 90 73
3 33 73 90
3 73 72 116
3 119 120 121
3 120 119 89
3 82 89 119
3 89 88 120
3 119 122 82
3 122 119 123
3 121 123 119
3 123 96 122
3 97 124 98
3 124 97 123
3 96 123 97
3 123 121 124
3 100 122 96
3 122 100 83
3 43 83 100
3 83 82 122
3 125 126 127
3 126 125 99
3 92 99 125
3 99 98 126
3 125 128 92
3 128 125 129
3 127 129 125
3 129 56 128
3 57 130 58
3 130 57 129
3 56 129 57
3 129 127 130
3 60 128 56
3 128 60 93
3 22 93 60
3 93 92 128
3 131 132 133
3 133 106 131
3 103 131 106
3 106 133 68
3 131 103 134
3 134 135 131
3 132 131 135
3 135 134 136
3 137 138 139
3 139 135 137
3 136 137 135
3 135 139 132
3 140 136 134
3 134 102 140
3 58 140 102
3 102 134 103
3 141 142 143
3 143 112 141
3 109 141 112
3 112 143 78
3 141 109 144
3 144 145 141
3 142 141 145
3 145 144 132
3 139 138 146
3 146 145 139
3 132 139 145
3 145 146 142
3 133 132 144
3 144 108 133
3 68 133 108
3 108 144 109
3 147 148 149
3 149 118 147
3 115 147 118
3 118 149 88
3 147 115 150
3 150 151 147
3 148 147 151
3 151 150 142
3 146 138 152
3 152 151 146
3 142 146 151
3 151 152 148
3 143 142 150
3 150 114 143
3 78 143 114
3 114 150 115
3 153 154 155
3 155 124 153
3 121 153 124
3 124 155 98
3 153 121 156
3 156 157 153
3 154 153 157
3 157 156 148
3 152 138 158
3 158 157 152
3 148 152 157
3 157 158 154
3 149 148 156
3 156 120 149
3 88 149 120
3 120 156 121
3 159 136 140
3 140 130 159
3 127 159 130
3 130 140 58
3 159 127 160
3 160 161 159
3 136 159 161
3 161 160 154
3 158 138 137
3 137 161 158
3 154 158 161
3 161 137 136
3 155 154 160
3 160 126 155
3 98 155 126
3 126 160 127

1934
thirdparty/carve-1.4.0/data/ico4.ply vendored Normal file

File diff suppressed because it is too large Load Diff

7694
thirdparty/carve-1.4.0/data/ico5.ply vendored Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

153649
thirdparty/carve-1.4.0/data/shells.ply vendored Normal file

File diff suppressed because it is too large Load Diff

14711
thirdparty/carve-1.4.0/data/sphere.ply vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

0
thirdparty/carve-1.4.0/doc/TODO.txt vendored Normal file
View File

134
thirdparty/carve-1.4.0/doc/carve.cls vendored Normal file
View File

@ -0,0 +1,134 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{carve}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{memoir}}
\ProcessOptions\relax
\LoadClass[12pt,a4paper,twoside,openright]{memoir}
% Extra packages
\usepackage{setspace}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{ifthen}
\usepackage{calc}
\usepackage{listings}
\usepackage{color}
\usepackage{graphicx}
\usepackage{pgf}
\usepackage{fontspec,xltxtra,xunicode}
\definecolor{codebg}{cmyk}{0.09,0.06,0.00,0.00} % E3E7F5
\definecolor{codeframe}{cmyk}{1.00,0.57,0.00,0.40} % E3E7F5
\definecolor{codekwd}{cmyk}{1.00,0.57,0.00,0.40} % 00447c
\definecolor{codecomment}{cmyk}{0.81,0.58,0.35,0.13} % 3F607C
\definecolor{headingcolour}{cmyk}{1.00,0.57,0.00,0.40}% 00447c
\definecolor{headingtext}{gray}{1.0}
\defaultfontfeatures{Mapping=tex-text,Fractions=Off,Scale=MatchLowercase}
\settypeblocksize{237mm}{427pt}{*}
\setlrmargins{*}{*}{2}
\setulmargins{*}{*}{2}
\checkandfixthelayout
\typeoutlayout
\typeoutstandardlayout
\setromanfont[
ItalicFont={Frutiger LT Std 46 Light Italic},
BoldFont={Frutiger LT Std 55 Roman},
BoldItalicFont={Frutiger LT Std 56 Italic},
]{Frutiger LT Std 45 Light}
\setsansfont[
ItalicFont={Frutiger LT Std 46 Light Italic},
BoldFont={Frutiger LT Std 55 Roman},
BoldItalicFont={Frutiger LT Std 56 Italic},
]{Frutiger LT Std 45 Light}
\setmonofont[
ItalicFont={Letter Gothic Std Slanted},
BoldFont={Letter Gothic Std Bold},
BoldItalicFont={Letter Gothic Std Bold Slanted},
]{Letter Gothic Std Medium}
\newfontfamily\condensedfont[
ItalicFont={Frutiger LT Std 47 Light Condensed},
BoldFont={Frutiger LT Std 57 Condensed},
BoldItalicFont={Frutiger LT Std 57 Condensed},
]{Frutiger LT Std 47 Light Condensed}
\newfontfamily\boldcondensedfont[
ItalicFont={Frutiger LT Std 67 Bold Condensed},
BoldFont={Frutiger LT Std 77 Black Condensed},
BoldItalicFont={Frutiger LT Std 77 Black Condensed},
]{Frutiger LT Std 67 Bold Condensed}
\newfontfamily\headingfont[
ItalicFont={Frutiger LT Std 66 Bold Italic},
]{Frutiger LT Std 65 Bold}
\newfontfamily\codefont[]{Bitstream Vera Sans Mono}
\newfontfamily\codekwdfont[]{Bitstream Vera Sans Mono Bold}
\newfontfamily\codecommentfont[]{Bitstream Vera Sans Mono Oblique}
\lstset{frame=tblr,
rulecolor=\color{codeframe},
basicstyle=\codefont\small,
keywordstyle=\codekwdfont\color{codekwd},
commentstyle=\codecommentfont\color{codecomment},
columns=fixed,
captionpos=b,
xleftmargin=2ex,xrightmargin=2ex,
framexleftmargin=2ex,framexrightmargin=2ex
}
\newcommand\code[1]{{\codefont\mbox{#1}}}
\newsavebox{\sb@titlegfx}
\begin{lrbox}{\sb@titlegfx}\makebox[0mm][l]{\includegraphics{title-page.pdf}}\end{lrbox}
\usepackage[absolute,overlay]{textpos}
\textblockorigin{-6.33mm}{-1.14mm}
\setlength{\TPHorizModule}{210mm}
\setlength{\TPVertModule}{297mm}
\renewcommand\maketitle{\begin{textblock}{1}(0,0)\usebox\sb@titlegfx\end{textblock}~\clearpage}
\newlength{\leftmar}
\newlength{\@pad}
\newsavebox{\sb@chapnum}
\newsavebox{\sb@chaptitle}
\newsavebox{\sb@title}
\newcommand{\checkmargin}{
\strictpagechecktrue\checkoddpage
\ifoddpage\setlength{\leftmar}{1.0\spinemargin}\else\setlength{\leftmar}{1.0\foremargin}\fi
}
\newif\ifNoChapNumber
\makeatletter
\makechapterstyle{VZ34}{
\renewcommand\chapternamenum{}
\renewcommand\printchaptername{}
\renewcommand\printchapternum{}
\renewcommand\chapnumfont{\Large}
\renewcommand\chaptitlefont{\headingfont\Large}
\renewcommand\printchaptertitle[1]{%
\begingroup%
\setlength{\parindent}{0pt}
\checkmargin%
\color{headingtext}%
\begin{lrbox}{\sb@title}
\hspace{-1.0\leftmar}\begin{minipage}{210mm}
\colorbox{headingcolour}{\vspace{5pt}\begin{tabular}{@{}b{\leftmar-2ex}@{\vrule width 1pt}b{210mm+2ex-\leftmar}}
\chapnumfont \raggedleft \ifNoChapNumber \relax \else \thechapter. \fi \hspace{1ex} &
\chaptitlefont \raggedright \hspace{.5ex} ##1
\end{tabular}\vspace{2pt}}
\end{minipage}
\end{lrbox}
\usebox\sb@title
\NoChapNumberfalse
\endgroup%
}
\renewcommand\printchapternonum{\NoChapNumbertrue}
}
\chapterstyle{VZ34}

BIN
thirdparty/carve-1.4.0/doc/carve.pdf vendored Normal file

Binary file not shown.

361
thirdparty/carve-1.4.0/doc/carve.tex vendored Normal file
View File

@ -0,0 +1,361 @@
\documentclass{carve}
\begin{document}
\title{Carve Documentation}
\author{Tobias Sargeant}
\frontmatter
\maketitle
\cleardoublepage\tableofcontents
\cleardoublepage\listoffigures
\cleardoublepage\listoftables
\cleardoublepage\lstlistoflistings
\mainmatter
\chapter{Representation of polyhedra}
Carve polyhedra are defined by collections of vertices (instances of
\code{carve::poly::Vertex}) that define points in 3-dimensional space,
and collections of faces (instances of \code{carve::poly::Face}) that
define the connectivity of vertices. Because faces refer to vertices
by pointer, vertex identity is determined by address rather than by
location in 3-dimensional space.
Faces are oriented anticlockwise in a right handed coordinate
system. Although a face may consist of more than three vertices, all
vertices of any given face must lie on a single plane.
A polyhedron defined by a set of faces and vertices consists of one or
more connected surfaces. The decomposition of a set of faces into
surfaces is computed automatically, and shared vertices
(\fref{fig:polyhedron-shared-vertex}) and edges
(\fref{fig:polyhedron-shared-edge}) are handled correctly. A
polyhedron may not, however, be self intersecting.
Each surface is either ``closed'' or ``open''. A closed surface obeys
the property that for every edge (determined by a pair of consecutive
vertices forming part of a face) there exists an edge of the opposite
orientation that is part of some other face.
A closed surface bounds a non-zero (possibly infinite) volume of
space. The space defined by a surface depends upon the orientation of
its defining faces. By inverting the vertex order of all faces of a
closed surface, the complementary volume is created. For example, a
cube with faces ordered clockwise in a right-handed coordinate system
describes the infinite volume consisting of all space except that
delimited by the cube.
Used carefully, more than one closed surface may be combined to create
a shell. A surface representing an infinite volume enclosed within a
surface representing a finite volume represents a hollow solid, and
such solids are handled correctly during CSG operations.
\begin{figure}
\begin{center}\includegraphics[width=3.453in]{polyhedra/shared-vertex.png}\end{center}
\caption{A polyhedron consisting of two surfaces sharing a vertex}
\label{fig:polyhedron-shared-vertex}
\end{figure}
\begin{figure}
\begin{center}\includegraphics[width=3.453in]{polyhedra/shared-edge.png}\end{center}
\caption{A polyhedron consisting of two surfaces sharing an edge}
\label{fig:polyhedron-shared-edge}
\end{figure}
\begin{section}{Construction of Polyhedra}
A polyhedron may be constructed in a number of ways.
In the first case (Listing \ref{code:poly-ctor-1}) a vector of faces
and a vector of vertices is provided. The vertices pointed to by the
faces in \code{\_faces} must be members of the vector of vertices,
\code{\_vertices}. Ownership is taken of the face and vertex vectors,
so as to avoid unnecessary copies. On return, both vectors will be
empty.
\begin{lstlisting}[language=C++,float,caption=\code{carve::poly::Polyhedron} constructor 1,label=code:poly-ctor-1]
carve::poly::Polyhedron(
std::vector<carve::poly::Face *> &_faces,
std::vector<carve::poly::Vertex> &_vertices,
bool _recalc = false);
\end{lstlisting}
\begin{lstlisting}[language=C++,float,caption=\code{carve::poly::Polyhedron} constructor 2,label=code:poly-ctor-2]
carve::poly::Polyhedron(
std::vector<carve::poly::Face *> &_faces,
bool _recalc = false);
\end{lstlisting}
\begin{lstlisting}[language=C++,float,caption=\code{carve::poly::Polyhedron} constructor 3,label=code:poly-ctor-3]
carve::poly::Polyhedron(
std::list<carve::poly::Face *> &_faces,
bool _recalc = false);
\end{lstlisting}
\begin{lstlisting}[language=C++,float,caption=\code{carve::poly::Polyhedron} constructor 4,label=code:poly-ctor-4]
carve::poly::Polyhedron(
const std::vector<carve::geom3d::Vector> &vertices,
int n_faces,
const std::vector<int> &face_indices);
\end{lstlisting}
\begin{lstlisting}[float,language=C++,caption=Constructing a cube directly,label=code:cube-direct]
#include <carve/polyhedron.hpp>
carve::poly::Polyhedron *makeCube(
const carve::math::Matrix &t = carve::math::Matrix()) {
std::vector<carve::poly::Vertex> verts;
std::vector<carve::poly::Face *> faces;
verts.reserve(8);
faces.reserve(6);
verts.push_back(
carve::poly::Vertex(t * carve::geom::VECTOR(+1.0, +1.0, +1.0)));
verts.push_back(
carve::poly::Vertex(t * carve::geom::VECTOR(-1.0, +1.0, +1.0)));
verts.push_back(
carve::poly::Vertex(t * carve::geom::VECTOR(-1.0, -1.0, +1.0)));
verts.push_back(
carve::poly::Vertex(t * carve::geom::VECTOR(+1.0, -1.0, +1.0)));
verts.push_back(
carve::poly::Vertex(t * carve::geom::VECTOR(+1.0, +1.0, -1.0)));
verts.push_back(
carve::poly::Vertex(t * carve::geom::VECTOR(-1.0, +1.0, -1.0)));
verts.push_back(
carve::poly::Vertex(t * carve::geom::VECTOR(-1.0, -1.0, -1.0)));
verts.push_back(
carve::poly::Vertex(t * carve::geom::VECTOR(+1.0, -1.0, -1.0)));
faces.push_back(
new Face(&verts[0], &verts[1], &verts[2], &verts[3]));
faces.push_back(
new Face(&verts[7], &verts[6], &verts[5], &verts[4]));
faces.push_back(
new Face(&verts[0], &verts[4], &verts[5], &verts[1]));
faces.push_back(
new Face(&verts[1], &verts[5], &verts[6], &verts[2]));
faces.push_back(
new Face(&verts[2], &verts[6], &verts[7], &verts[3]));
faces.push_back(
new Face(&verts[3], &verts[7], &verts[4], &verts[0]));
// note that carve::poly::Polyhedron takes ownership of face
// pointers and the contents of the vertex array.
return new carve::poly::Polyhedron(faces, vertices);
}
\end{lstlisting}
\begin{lstlisting}[float,language=C++,caption=Constructing a cube using {\codefont carve::input::PolyhedronData}]
#include <carve/input.hpp>
#include <carve/polyhedron.hpp>
carve::poly::Polyhedron *makeCube(
const carve::math::Matrix &t = carve::math::Matrix()) {
carve::input::PolyhedronData data;
data.addVertex(t * carve::geom::VECTOR(+1.0, +1.0, +1.0));
data.addVertex(t * carve::geom::VECTOR(-1.0, +1.0, +1.0));
data.addVertex(t * carve::geom::VECTOR(-1.0, -1.0, +1.0));
data.addVertex(t * carve::geom::VECTOR(+1.0, -1.0, +1.0));
data.addVertex(t * carve::geom::VECTOR(+1.0, +1.0, -1.0));
data.addVertex(t * carve::geom::VECTOR(-1.0, +1.0, -1.0));
data.addVertex(t * carve::geom::VECTOR(-1.0, -1.0, -1.0));
data.addVertex(t * carve::geom::VECTOR(+1.0, -1.0, -1.0));
data.addFace(0, 1, 2, 3);
data.addFace(7, 6, 5, 4);
data.addFace(0, 4, 5, 1);
data.addFace(1, 5, 6, 2);
data.addFace(2, 6, 7, 3);
data.addFace(3, 7, 4, 0);
return data.create();
}
\end{lstlisting}
\end{section}
\chapter{CSG Operations}
The \code{carve::csg::CSG} class is responsible for managing CSG
calculations. It provides methods for CSG binary computations between
both closed and open polyhedra, as well as divison of polyhedra by
their common line of intersection. The operation computed by methods
of the \code{carve::csg::CSG} class may be chosen from the standard
primitive binary operations or may be defined by the caller.
The CSG computation may be influenced by the registration of hook
objects that can be used to perform such tasks as triangulation of
result faces and transfer and interpolation of attributes from source
polyhedra to the result.
\begin{section}{CSG Operations on Closed Manifolds}
The \code{compute} method of \code{carve::csg::CSG} has two prototypes:
\begin{lstlisting}[language=C++]
carve::poly::Polyhedron *compute(
const carve::poly::Polyhedron *a,
const carve::poly::Polyhedron *b,
carve::csg::CSG::OP op,
carve::csg::V2Set *shared_edges = NULL,
carve::csg::CSG::CLASSIFY_TYPE classify_type = CLASSIFY_NORMAL);
\end{lstlisting}
\begin{lstlisting}[language=C++]
carve::poly::Polyhedron *compute(
const carve::poly::Polyhedron *a,
const carve::poly::Polyhedron *b,
carve::csg::CSG::Collector &collector,
carve::csg::V2Set *shared_edges = NULL,
carve::csg::CSG::CLASSIFY_TYPE classify_type = CLASSIFY_NORMAL);
\end{lstlisting}
These methods compute a boolean operation between polyhedra \code{a}
and \code{b}. In the first case, the operation is determined by the
enumeration \code{carve::csg::CSG::OP}, which can take the values:
\begin{itemize}
\item \code{UNION}
\item \code{INTERSECTION}
\item \code{A\_MINUS\_B}
\item \code{B\_MINUS\_A}
\item \code{SYMMETRIC\_DIFFERENCE}
\end{itemize}
\noindent Results for these boolean operations are shown in
\tref{tab:input-polyhedra} and \tref{tab:csg-results}.
\begin{table}
\begin{center}
\begin{tabular}{m{2.2in}m{3in}}
\includegraphics[width=2.167in]{ops/a.png} & \vfill Manifold A \vfill \\
\includegraphics[width=2.167in]{ops/b.png} & Manifold B \\
\end{tabular}
\end{center}
\caption{Input polyhedra.}
\label{tab:input-polyhedra}
\end{table}
\begin{table}
\begin{center}
\begin{tabular}{m{2.2in}m{3in}}
\includegraphics[width=2.167in]{ops/a_union_b.png} &
Operation: Union (A | B) \newline Enumeration: \code{carve::CSG::UNION} \\
\includegraphics[width=2.167in]{ops/a_intersection_b.png} &
Operation: Intersection (A \& B) \newline Enumeration: \code{carve::CSG::INTERSECTION} \\
\includegraphics[width=2.167in]{ops/a_minus_b.png} &
Operation: Difference (A - B) \newline Enumeration: \code{carve::CSG::A\_MINUS\_B} \\
\includegraphics[width=2.167in]{ops/b_minus_a.png} &
Operation: Difference (B - A) \newline Enumeration: \code{carve::CSG::B\_MINUS\_A} \\
\includegraphics[width=2.167in]{ops/a_xor_b.png} &
Operation: Symmetric Difference (A B) \newline Enumeration: \code{carve::CSG::SYMMETRIC\_DIFFERENCE} \\
\end{tabular}
\end{center}
\caption{The result of predefined CSG operations.}
\label{tab:csg-results}
\end{table}
In the second case, the result is determined by a custom
collector. Custom collectors allow the caller to programatically
define which regions of the intersected input polyhedra appear in the
output.
The \code{shared\_edges} parameter provides a way to access the
computed set of edges that defines the point of intersection of the
two polyhedra.
The algorithm used to classify connected components of the intersected
polyhedra is determined by the parameter \code{classify\_type}. The
type of \code{classify\_type} is an enumeration taking values from the
set \{\code{CLASSIFY\_NORMAL}, \code{CLASSIFY\_EDGE}\}.
The classifier is responsible for classifying portions of each
polyhedron bounded by the line of intersection as either:
\begin{itemize}
\item \code{carve::csg::FACE\_OUT} \newline
The group is outside the space defined by the opposing polyhedron.
\item \code{carve::csg::FACE\_IN} \newline
The group is inside the space defined by the opposing polyhedron.
\item \code{carve::csg::FACE\_ON\_ORIENT\_IN} \newline
The group is lying on the surface of the opposing polyhedron, oriented towards its interior.
\item \code{carve::csg::FACE\_ON\_ORIENT\_OUT} \newline
The group is lying on the surface of the opposing polyhedron, oriented towards its exterior.
\end{itemize}
\noindent with respect to (each surface of) the opposing polyhedron.
\end{section}
\begin{section}{CSG Operations on Open Manifolds}
\end{section}
\chapter{Attribute Interpolation}
\begin{lstlisting}[float,language=C++,caption=Associating texture coordinates with a cube]
#include <carve/interpolator.hpp>
struct tex_t {
float u, v;
tex_t() : u(0.0f), v(0.0f) { }
tex_t(float _u, float _v) : u(_u), v(_v) { }
};
// interpolated attributes must support scalar multiplication.
tex_t operator*(double s, const tex_t &t) {
return tex_t(t.u * s, t.v * s);
}
// interpolated attributes must support operator+=.
tex_t &operator+=(tex_t &t1, const tex_t &t2) {
t1.u += t2.u; t1.v += t2.v;
return t1;
}
void associateTextureVertices(
carve::poly::Polyhedron *cube,
carve::interpolate::FaceVertexAttr<tex_t> &fv_tex) {
fv_tex.setAttribute(cube->faces[0], 0, tex_t(1.0f, 1.0f));
fv_tex.setAttribute(cube->faces[0], 1, tex_t(0.0f, 1.0f));
fv_tex.setAttribute(cube->faces[0], 2, tex_t(0.0f, 0.0f));
fv_tex.setAttribute(cube->faces[0], 3, tex_t(1.0f, 0.0f));
// ... continue to record other texture coordinates by
// face pointer and vertex number.
}
\end{lstlisting}
\begin{lstlisting}[float,language=C++,caption=Interpolating texture coordinates during a CSG operation]
#include <carve/csg.hpp>
carve::poly::Polyhedron *doCSG() {
carve::poly::Polyhedron *result;
carve::poly::Polyhedron *cube_1 = makeCube();
carve::poly::Polyhedron *cube_2 = makeCube(
carve::math::Matrix::ROT(.4, .2, .3, .4));
carve::interpolate::FaceVertexAttr<tex_t> fv_tex;
associateTextureVertices(cube_1, fv_tex);
carve::csg::CSG csg;
fv_tex.installHooks(csg);
result = csg.compute(cube_1, cube_2, carve::csg::CSG::A_MINUS_B);
}
\end{lstlisting}
\appendix
\backmatter
\end{document}

BIN
thirdparty/carve-1.4.0/doc/ops/a.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
thirdparty/carve-1.4.0/doc/ops/a.tiff vendored Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

BIN
thirdparty/carve-1.4.0/doc/ops/b.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
thirdparty/carve-1.4.0/doc/ops/b.tiff vendored Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

View File

@ -0,0 +1,20 @@
This is XeTeXk, Version 3.141592-2.2-0.996 (Web2C 7.5.6) (format=xelatex 2008.5.12) 29 SEP 2008 15:50
entering extended mode
%&-line parsing enabled.
**carve.tex
! Emergency stop.
<*> carve.tex
End of file on the terminal!
Here is how much of TeX's memory you used:
2 strings out of 94863
15 string characters out of 1171490
46799 words of memory out of 1500000
3287 multiletter control sequences out of 10000+50000
3640 words of font info for 14 fonts, out of 1200000 for 2000
605 hyphenation exceptions out of 8191
0i,0n,0p,1b,6s stack positions out of 5000i,500n,6000p,200000b,5000s
No pages of output.

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

13107
thirdparty/carve-1.4.0/doc/title-page.pdf vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,17 @@
include_directories("${carve_SOURCE_DIR}/include")
include_directories("${carve_SOURCE_DIR}/external/GLOOP/include")
include_directories("${carve_SOURCE_DIR}/external/GLEW/include")
include_directories("${carve_SOURCE_DIR}/external/GLUI/include")
include_directories("${carve_SOURCE_DIR}/common")
include_directories(${OPENGL_INCLUDE_DIR})
link_directories("${gloop_BINARY_DIR}")
link_directories("${carve_BINARY_DIR}/common")
if(CARVE_WITH_GUI)
add_executable (custom_collector custom_collector.cpp)
target_link_libraries(custom_collector carve carve_ui carve_misc glui carve_fileformats gloop_model ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
add_executable (texture_example texture_example.cpp)
target_link_libraries(texture_example carve carve_ui carve_misc glui carve_fileformats gloop_model ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
endif(CARVE_WITH_GUI)

View File

@ -0,0 +1,17 @@
noinst_PROGRAMS =
noinst_HEADERS = brick_texture.h carve_texture.h leaf_texture.h
CPPFLAGS += -I$(top_srcdir)/common -I$(top_srcdir)/include @GL_CFLAGS@ @GLUT_CFLAGS@
CPPFLAGS += -I$(top_srcdir)/external/GLOOP/include
if with_GUI
CPPFLAGS += -I$(top_srcdir)/external/GLEW/include
CPPFLAGS += -I$(top_srcdir)/external/GLUI/include
noinst_PROGRAMS += custom_collector texture_example
endif
custom_collector_SOURCES=custom_collector.cpp
custom_collector_LDADD=../common/libcarve_fileformats.la ../common/libcarve_ui.la ../common/libcarve_misc.la ../lib/libintersect.la @GL_LIBS@ @GLUT_LIBS@
texture_example_SOURCES=texture_example.cpp
texture_example_LDADD=../common/libcarve_fileformats.la ../common/libcarve_ui.la ../common/libcarve_misc.la ../lib/libintersect.la @GL_LIBS@ @GLUT_LIBS@

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,175 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#if defined(HAVE_CONFIG_H)
# include <carve_config.h>
#endif
#include <carve/csg.hpp>
#include "scene.hpp"
#include "geom_draw.hpp"
#include "geometry.hpp"
#include <carve/input.hpp>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#endif
#include <fstream>
#include <string>
#include <utility>
#include <set>
#include <time.h>
struct TestScene : public Scene {
GLuint draw_list_base;
std::vector<bool> draw_flags;
virtual bool key(unsigned char k, int x, int y) {
const char *t;
static const char *l = "1234567890!@#$%^&*()";
t = strchr(l, k);
if (t != NULL) {
int layer = t - l;
if (layer < draw_flags.size()) {
draw_flags[layer] = !draw_flags[layer];
}
}
return true;
}
virtual GLvoid draw() {
for (int i = 0; i < draw_flags.size(); ++i) {
if (draw_flags[i]) glCallList(draw_list_base + i);
}
}
TestScene(int argc, char **argv, int n_dlist) : Scene(argc, argv) {
draw_list_base = glGenLists(n_dlist);
draw_flags.resize(n_dlist, false);
}
virtual ~TestScene() {
glDeleteLists(draw_list_base, draw_flags.size());
}
};
#define DIM 60
class Between : public carve::csg::CSG::Collector {
Between();
Between(const Between &);
Between &operator=(const Between &);
public:
std::list<carve::poly::Face<3> > faces;
const carve::poly::Polyhedron *src_a;
const carve::poly::Polyhedron *src_b;
Between(const carve::poly::Polyhedron *_src_a,
const carve::poly::Polyhedron *_src_b) : carve::csg::CSG::Collector(), src_a(_src_a), src_b(_src_b) {
}
virtual ~Between() {
}
virtual void collect(carve::csg::FaceLoopGroup *grp, carve::csg::CSG::Hooks &hooks) {
if (grp->face_loops.head->orig_face->owner != src_a) return;
if (grp->classificationAgainst(src_b, 1) != carve::csg::FACE_IN) return;
if (grp->classificationAgainst(src_b, 0) != carve::csg::FACE_OUT) return;
for (carve::csg::FaceLoop *f = grp->face_loops.head; f; f = f->next) {
faces.push_back(carve::poly::Face<3>());
faces.back().init(f->orig_face, f->vertices, false);
}
}
virtual carve::poly::Polyhedron *done(carve::csg::CSG::Hooks &hooks) {
return new carve::poly::Polyhedron(faces);
}
};
int main(int argc, char **argv) {
carve::poly::Polyhedron *a = makeTorus(30, 30, 2.0, 0.8, carve::math::Matrix::ROT(0.5, 1.0, 1.0, 1.0));
carve::input::PolyhedronData data;
for (int i = 0; i < DIM; i++) {
double x = -3.0 + 6.0 * i / double(DIM - 1);
for (int j = 0; j < DIM; j++) {
double y = -3.0 + 6.0 * j / double(DIM - 1);
double z = -1.0 + 2.0 * cos(sqrt(x * x + y * y) * 2.0) / sqrt(1.0 + x * x + y * y);
size_t n = data.addVertex(carve::geom::VECTOR(x, y, z));
if (i && j) {
data.addFace(n - DIM - 1, n - 1, n - DIM);
data.addFace(n - 1, n, n - DIM);
}
}
}
for (int i = 0; i < DIM; i++) {
double x = -3.0 + 6.0 * i / double(DIM - 1);
for (int j = 0; j < DIM; j++) {
double y = -3.0 + 6.0 * j / double(DIM - 1);
double z = 1.0 + 2.0 * cos(sqrt(x * x + y * y) * 2.0) / sqrt(1.0 + x * x + y * y);
size_t n = data.addVertex(carve::geom::VECTOR(x, y, z));
if (i && j) {
data.addFace(n - DIM - 1, n - 1, n - DIM);
data.addFace(n - 1, n, n - DIM);
}
}
}
carve::poly::Polyhedron *b = data.create();
Between between_collector(a, b);
carve::poly::Polyhedron *c = carve::csg::CSG().compute(a, b, between_collector, NULL, carve::csg::CSG::CLASSIFY_EDGE);
TestScene *scene = new TestScene(argc, argv, 3);
glNewList(scene->draw_list_base + 0, GL_COMPILE);
drawPolyhedron(a, .4, .6, .8, 1.0, false);
glEndList();
glNewList(scene->draw_list_base + 1, GL_COMPILE);
drawPolyhedron(b, .8, .6, .4, 1.0, false);
glEndList();
glNewList(scene->draw_list_base + 2, GL_COMPILE);
drawPolyhedron(c, .2, .2, .8, 1.0, true);
drawPolyhedronWireframe(c);
glEndList();
scene->run();
delete scene;
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,354 @@
// Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#if defined(HAVE_CONFIG_H)
# include <carve_config.h>
#endif
#include <carve/interpolator.hpp>
#include <carve/csg_triangulator.hpp>
#include <carve/csg.hpp>
#include "carve_texture.h"
#include "brick_texture.h"
#include "leaf_texture.h"
#include "scene.hpp"
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#endif
#include <fstream>
#include <string>
#include <utility>
#include <set>
#include <time.h>
#if defined(__GNUC__)
#define __stdcall
#endif
#if defined(GLU_TESS_CALLBACK_VARARGS)
typedef GLvoid (__stdcall *GLUTessCallback)(...);
#else
typedef void (__stdcall *GLUTessCallback)();
#endif
typedef carve::poly::Polyhedron poly_t;
carve::geom3d::Vector g_translation;
double g_scale;
static inline void glVertex(const carve::geom3d::Vector &v) {
glVertex3f(g_scale * (v.x + g_translation.x),
g_scale * (v.y + g_translation.y),
g_scale * (v.z + g_translation.z));
}
struct tex_t {
float u;
float v;
tex_t() : u(0.0f), v(0.0f) { }
tex_t(float _u, float _v) : u(_u), v(_v) { }
};
tex_t operator*(double s, const tex_t &t) {
return tex_t(t.u * s, t.v * s);
}
tex_t &operator+=(tex_t &t1, const tex_t &t2) {
t1.u += t2.u;
t1.v += t2.v;
return t1;
}
struct vt_t {
double x, y, z;
float u, v;
};
void __stdcall tess_vertex(vt_t *v, bool *is_textured) {
if (*is_textured) {
glTexCoord2f(v->u, v->v);
}
glVertex3d(v->x, v->y, v->z);
}
void drawTexturedPolyhedron(poly_t *poly,
carve::interpolate::FaceVertexAttr<tex_t> &fv_tex,
carve::interpolate::FaceAttr<GLuint> &f_tex_num) {
glEnable(GL_TEXTURE_2D);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GLUtesselator *tess = gluNewTess();
gluTessCallback(tess, GLU_TESS_BEGIN, (GLUTessCallback)glBegin);
gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (GLUTessCallback)tess_vertex);
gluTessCallback(tess, GLU_TESS_END, (GLUTessCallback)glEnd);
for (size_t i = 0, l = poly->faces.size(); i != l; ++i) {
poly_t::face_t &f = poly->faces[i];
std::vector<vt_t> vc(f.nVertices());
bool textured = true;
for (size_t j = 0; j < f.nVertices(); ++j) {
vc[j].x = g_scale * (f.vertex(j)->v.x + g_translation.x);
vc[j].y = g_scale * (f.vertex(j)->v.y + g_translation.y);
vc[j].z = g_scale * (f.vertex(j)->v.z + g_translation.z);
if (fv_tex.hasAttribute(&f, j)) {
tex_t t = fv_tex.getAttribute(&f, j);
vc[j].u = t.u;
vc[j].v = t.v;
} else {
textured = false;
}
}
if (textured) {
GLuint tex_num = f_tex_num.getAttribute(&f, 0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tex_num);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
} else {
glColor4f(0.5f, 0.6f, 0.7f, 1.0f);
}
glNormal3dv(f.plane_eqn.N.v);
gluTessBeginPolygon(tess, (void *)&textured);
gluTessBeginContour(tess);
for (size_t j = 0; j != vc.size(); ++j) {
gluTessVertex(tess, (GLdouble *)&vc[j], (GLvoid *)&vc[j]);
}
gluTessEndContour(tess);
gluTessEndPolygon(tess);
}
gluDeleteTess(tess);
glDisable(GL_TEXTURE_2D);
}
void drawWireframePolyhedron(poly_t *poly) {
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glDisable(GL_LIGHTING);
for (size_t i = 0, l = poly->faces.size(); i != l; ++i) {
poly_t::face_t &f = poly->faces[i];
glBegin(GL_LINE_LOOP);
for (size_t j = 0; j < f.nVertices(); ++j) {
double x = g_scale * (f.vertex(j)->v.x + g_translation.x);
double y = g_scale * (f.vertex(j)->v.y + g_translation.y);
double z = g_scale * (f.vertex(j)->v.z + g_translation.z);
glVertex3d(x, y, z);
}
glEnd();
}
glEnable(GL_LIGHTING);
}
poly_t *texturedCube(
carve::interpolate::FaceVertexAttr<tex_t> &fv_tex,
carve::interpolate::FaceAttr<GLuint> &f_tex_num,
GLuint tex,
const carve::math::Matrix &transform = carve::math::Matrix::IDENT()) {
std::vector<poly_t::vertex_t> v;
v.push_back(poly_t::vertex_t(transform * carve::geom::VECTOR(+1.0, +1.0, +1.0)));
v.push_back(poly_t::vertex_t(transform * carve::geom::VECTOR(-1.0, +1.0, +1.0)));
v.push_back(poly_t::vertex_t(transform * carve::geom::VECTOR(-1.0, -1.0, +1.0)));
v.push_back(poly_t::vertex_t(transform * carve::geom::VECTOR(+1.0, -1.0, +1.0)));
v.push_back(poly_t::vertex_t(transform * carve::geom::VECTOR(+1.0, +1.0, -1.0)));
v.push_back(poly_t::vertex_t(transform * carve::geom::VECTOR(-1.0, +1.0, -1.0)));
v.push_back(poly_t::vertex_t(transform * carve::geom::VECTOR(-1.0, -1.0, -1.0)));
v.push_back(poly_t::vertex_t(transform * carve::geom::VECTOR(+1.0, -1.0, -1.0)));
std::vector<poly_t::face_t> faces;
faces.reserve(6);
faces.push_back(poly_t::face_t(&v[0], &v[1], &v[2], &v[3]));
faces.push_back(poly_t::face_t(&v[7], &v[6], &v[5], &v[4]));
faces.push_back(poly_t::face_t(&v[0], &v[4], &v[5], &v[1]));
faces.push_back(poly_t::face_t(&v[1], &v[5], &v[6], &v[2]));
faces.push_back(poly_t::face_t(&v[2], &v[6], &v[7], &v[3]));
faces.push_back(poly_t::face_t(&v[3], &v[7], &v[4], &v[0]));
for (size_t i = 0; i < 6; ++i) {
fv_tex.setAttribute(&faces[i], 0, tex_t(0.0f, 1.0f));
fv_tex.setAttribute(&faces[i], 1, tex_t(1.0f, 1.0f));
fv_tex.setAttribute(&faces[i], 2, tex_t(1.0f, 0.0f));
fv_tex.setAttribute(&faces[i], 3, tex_t(0.0f, 0.0f));
f_tex_num.setAttribute(&faces[i], tex);
}
poly_t *poly = new poly_t(faces);
return poly;
}
struct TestScene : public Scene {
GLuint draw_list_base;
std::vector<bool> draw_flags;
virtual bool key(unsigned char k, int x, int y) {
const char *t;
static const char *l = "1234567890!@#$%^&*()";
t = strchr(l, k);
if (t != NULL) {
int layer = t - l;
if (layer < draw_flags.size()) {
draw_flags[layer] = !draw_flags[layer];
}
}
return true;
}
virtual GLvoid draw() {
for (size_t i = 0; i < draw_flags.size(); ++i) {
if (draw_flags[i]) glCallList(draw_list_base + i);
}
}
TestScene(int argc, char **argv, int n_dlist) : Scene(argc, argv) {
draw_list_base = glGenLists(n_dlist);
draw_flags.resize(n_dlist, false);
}
virtual ~TestScene() {
glDeleteLists(draw_list_base, draw_flags.size());
}
};
GLuint initTexture(GLuint w, GLuint h, const unsigned char *data) {
GLuint tex;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGB,
w,
h,
0,
GL_RGB,
GL_UNSIGNED_BYTE,
data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
return tex;
}
void destroyTexture(GLuint tex) {
glDeleteTextures(1, &tex);
}
int main(int argc, char **argv) {
TestScene *scene = new TestScene(argc, argv, 2);
GLuint tex_1 = initTexture(128, 128, carve_texture);
GLuint tex_2 = initTexture(128, 128, brick_texture);
GLuint tex_3 = initTexture(128, 128, leaf_texture);
g_scale = 10.0;
carve::interpolate::FaceVertexAttr<tex_t> fv_tex;
carve::interpolate::FaceAttr<GLuint> f_tex_num;
poly_t *base = NULL;
bool b = true;
for (int x = -10; x <= +10; x += 5) {
for (int y = -10; y <= +10; y += 5) {
for (int z = -10; z <= +10; z += 5) {
double rot = x * .17 + y * .06 + z * .09;
poly_t *r = texturedCube(fv_tex, f_tex_num, b ? tex_2 : tex_3,
carve::math::Matrix::TRANS(x/2.5, y/2.5, z/2.5) *
carve::math::Matrix::ROT(rot, 1,2,3));
b = !b;
if (base) {
poly_t *temp = base;
carve::csg::CSG csg;
fv_tex.installHooks(csg);
f_tex_num.installHooks(csg);
base = csg.compute(temp, r, carve::csg::CSG::UNION);
delete temp;
delete r;
} else {
base = r;
}
}
}
}
poly_t *r1 = texturedCube(fv_tex, f_tex_num, tex_1,
carve::math::Matrix::TRANS(0,0,4) *
carve::math::Matrix::SCALE(4,4,4));
poly_t *r2 = texturedCube(fv_tex, f_tex_num, tex_1,
carve::math::Matrix::TRANS(0,0,5) *
carve::math::Matrix::SCALE(2, 2, 2));
carve::csg::CSG csg;
fv_tex.installHooks(csg);
f_tex_num.installHooks(csg);
poly_t *r3 = csg.compute(base, r1, carve::csg::CSG::INTERSECTION);
poly_t *r4 = csg.compute(r3, r2, carve::csg::CSG::UNION);
glNewList(scene->draw_list_base, GL_COMPILE);
drawTexturedPolyhedron(r4, fv_tex, f_tex_num);
glEndList();
glNewList(scene->draw_list_base+1, GL_COMPILE);
drawWireframePolyhedron(r3);
glEndList();
scene->draw_flags[0] = true;
scene->draw_flags[1] = true;
scene->run();
destroyTexture(tex_1);
destroyTexture(tex_2);
destroyTexture(tex_3);
delete scene;
return 0;
}

Some files were not shown because too many files have changed in this diff Show More