├── .gitmodules ├── .hgignore ├── AUTHORS ├── CMakeLists.txt ├── ChangeLog ├── INSTALL ├── LICENSE ├── NEWS ├── README ├── common ├── CMakeLists.txt ├── geom_draw.cpp ├── geom_draw.hpp ├── geometry.cpp ├── geometry.hpp ├── opts.hpp ├── read_ply.cpp ├── read_ply.hpp ├── rgb.hpp ├── scene.cpp ├── scene.hpp ├── stringfuncs.hpp ├── write_ply.cpp └── write_ply.hpp ├── data ├── armadillo.ply ├── bunny2.ply ├── case2_A.ply ├── case2_A_intersect_B.ply ├── case2_B.ply ├── conedown.ply ├── coneup.ply ├── cow.ply ├── cow2.ply ├── cube.ply ├── cylinderx.ply ├── cylindery.ply ├── cylinderz.ply ├── elephant.ply ├── elephant2.ply ├── hippo.ply ├── horse2.ply ├── ico.ply ├── ico2.ply ├── ico3.ply ├── ico4.ply ├── ico5.ply ├── maxplanck.ply ├── shells.ply ├── sphere.ply └── sphere_one_point_moved.ply ├── doc ├── TODO.txt ├── carve.cls ├── carve.pdf ├── carve.tex ├── ops │ ├── a.png │ ├── a.tiff │ ├── a_intersection_b.png │ ├── a_intersection_b.tiff │ ├── a_minus_b.png │ ├── a_minus_b.tiff │ ├── a_union_b.png │ ├── a_union_b.tiff │ ├── a_xor_b.png │ ├── a_xor_b.tiff │ ├── b.png │ ├── b.tiff │ ├── b_minus_a.png │ ├── b_minus_a.tiff │ └── texput.log ├── polyhedra │ ├── shared-edge.png │ ├── shared-edge.tif │ ├── shared-vertex.png │ └── shared-vertex.tif └── title-page.pdf ├── examples ├── CMakeLists.txt ├── brick_texture.h ├── carve_texture.h ├── custom_collector.cpp ├── detail_clip.cpp ├── leaf_texture.h └── texture_example.cpp ├── external ├── GLEW │ ├── CMakeLists.txt │ ├── include │ │ └── GL │ │ │ ├── glew.h │ │ │ ├── glxew.h │ │ │ └── wglew.h │ └── src │ │ └── glew.c ├── GLOOP │ ├── CMakeLists.txt │ ├── include │ │ └── gloop │ │ │ ├── exceptions.hpp │ │ │ ├── gl.hpp │ │ │ ├── gl │ │ │ ├── fbo.hpp │ │ │ ├── shader.hpp │ │ │ ├── surface.hpp │ │ │ ├── texparam.hpp │ │ │ ├── vbo.hpp │ │ │ └── vertexformat.hpp │ │ │ ├── gloop-gl.hpp │ │ │ ├── gloop-image.hpp │ │ │ ├── gloop-math.hpp │ │ │ ├── gloop-model.hpp │ │ │ ├── gloop.hpp │ │ │ ├── glu.hpp │ │ │ ├── glut.hpp │ │ │ ├── image │ │ │ └── radiance.hpp │ │ │ ├── math │ │ │ ├── matrix.hpp │ │ │ ├── quaternion.hpp │ │ │ └── vector.hpp │ │ │ ├── model │ │ │ ├── obj_format.hpp │ │ │ ├── ply_format.hpp │ │ │ ├── stream.hpp │ │ │ └── vtk_format.hpp │ │ │ ├── ref.hpp │ │ │ └── stringfuncs.hpp │ └── src │ │ ├── fbo.cpp │ │ ├── matrix.cpp │ │ ├── model │ │ ├── obj_format.cpp │ │ ├── ply_format.cpp │ │ ├── stream.cpp │ │ └── vtk_format.cpp │ │ ├── quaternion.cpp │ │ ├── radiance.cpp │ │ ├── shader.cpp │ │ ├── surface.cpp │ │ ├── texparam.cpp │ │ └── vbo.cpp ├── GLUI │ ├── CMakeLists.txt │ ├── include │ │ └── GL │ │ │ └── glui.h │ └── src │ │ ├── algebra3.cpp │ │ ├── algebra3.h │ │ ├── arcball.cpp │ │ ├── arcball.h │ │ ├── glui.cpp │ │ ├── glui_add_controls.cpp │ │ ├── glui_bitmap_img_data.cpp │ │ ├── glui_bitmaps.cpp │ │ ├── glui_button.cpp │ │ ├── glui_checkbox.cpp │ │ ├── glui_column.cpp │ │ ├── glui_commandline.cpp │ │ ├── glui_control.cpp │ │ ├── glui_edittext.cpp │ │ ├── glui_filebrowser.cpp │ │ ├── glui_img_checkbox_0.c │ │ ├── glui_img_checkbox_0_dis.c │ │ ├── glui_img_checkbox_1.c │ │ ├── glui_img_checkbox_1_dis.c │ │ ├── glui_img_downarrow.c │ │ ├── glui_img_leftarrow.c │ │ ├── glui_img_listbox_down.c │ │ ├── glui_img_listbox_up.c │ │ ├── glui_img_listbox_up_dis.c │ │ ├── glui_img_radiobutton_0.c │ │ ├── glui_img_radiobutton_0_dis.c │ │ ├── glui_img_radiobutton_1.c │ │ ├── glui_img_radiobutton_1_dis.c │ │ ├── glui_img_rightarrow.c │ │ ├── glui_img_spindown_0.c │ │ ├── glui_img_spindown_1.c │ │ ├── glui_img_spindown_dis.c │ │ ├── glui_img_spinup_0.c │ │ ├── glui_img_spinup_1.c │ │ ├── glui_img_spinup_dis.c │ │ ├── glui_img_uparrow.c │ │ ├── glui_internal.h │ │ ├── glui_internal_control.h │ │ ├── glui_list.cpp │ │ ├── glui_listbox.cpp │ │ ├── glui_mouse_iaction.cpp │ │ ├── glui_node.cpp │ │ ├── glui_panel.cpp │ │ ├── glui_radio.cpp │ │ ├── glui_rollout.cpp │ │ ├── glui_rotation.cpp │ │ ├── glui_scrollbar.cpp │ │ ├── glui_separator.cpp │ │ ├── glui_spinner.cpp │ │ ├── glui_statictext.cpp │ │ ├── glui_string.cpp │ │ ├── glui_textbox.cpp │ │ ├── glui_translation.cpp │ │ ├── glui_tree.cpp │ │ ├── glui_treepanel.cpp │ │ ├── glui_window.cpp │ │ ├── quaternion.cpp │ │ ├── quaternion.h │ │ ├── viewmodel.cpp │ │ └── viewmodel.h ├── README.GLEW ├── README.GLOOP └── README.GLUI ├── include ├── CMakeLists.txt └── carve │ ├── aabb.hpp │ ├── aabb_impl.hpp │ ├── carve.hpp │ ├── cbrt.h │ ├── classification.hpp │ ├── cmake-config.h.in │ ├── collection.hpp │ ├── collection_types.hpp │ ├── colour.hpp │ ├── config.h.in │ ├── convex_hull.hpp │ ├── csg.hpp │ ├── csg_triangulator.hpp │ ├── debug_hooks.hpp │ ├── djset.hpp │ ├── edge_decl.hpp │ ├── edge_impl.hpp │ ├── exact.hpp │ ├── face_decl.hpp │ ├── face_impl.hpp │ ├── faceloop.hpp │ ├── geom.hpp │ ├── geom2d.hpp │ ├── geom3d.hpp │ ├── geom_impl.hpp │ ├── heap.hpp │ ├── input.hpp │ ├── interpolator.hpp │ ├── intersection.hpp │ ├── iobj.hpp │ ├── kd_node.hpp │ ├── math.hpp │ ├── math_constants.hpp │ ├── matrix.hpp │ ├── mesh.hpp │ ├── mesh_impl.hpp │ ├── mesh_ops.hpp │ ├── mesh_simplify.hpp │ ├── octree_decl.hpp │ ├── octree_impl.hpp │ ├── pointset.hpp │ ├── pointset_decl.hpp │ ├── pointset_impl.hpp │ ├── pointset_iter.hpp │ ├── poly.hpp │ ├── poly_decl.hpp │ ├── poly_impl.hpp │ ├── polyhedron_base.hpp │ ├── polyhedron_decl.hpp │ ├── polyhedron_impl.hpp │ ├── polyline.hpp │ ├── polyline_decl.hpp │ ├── polyline_impl.hpp │ ├── polyline_iter.hpp │ ├── rescale.hpp │ ├── rtree.hpp │ ├── shewchuk_predicates.hpp │ ├── spacetree.hpp │ ├── tag.hpp │ ├── timing.hpp │ ├── tree.hpp │ ├── triangle_intersection.hpp │ ├── triangulator.hpp │ ├── triangulator_impl.hpp │ ├── util.hpp │ ├── vcpp_config.h │ ├── vector.hpp │ ├── vertex_decl.hpp │ ├── vertex_impl.hpp │ ├── win32.h │ └── xcode_config.h ├── lib ├── CMakeLists.txt ├── aabb.cpp ├── carve.cpp ├── convex_hull.cpp ├── csg.cpp ├── csg_collector.cpp ├── csg_collector.hpp ├── csg_data.hpp ├── csg_detail.hpp ├── edge.cpp ├── face.cpp ├── geom.cpp ├── geom2d.cpp ├── geom3d.cpp ├── intersect.cpp ├── intersect_classify_common.hpp ├── intersect_classify_common_impl.hpp ├── intersect_classify_edge.cpp ├── intersect_classify_group.cpp ├── intersect_classify_simple.cpp ├── intersect_common.hpp ├── intersect_debug.cpp ├── intersect_debug.hpp ├── intersect_face_division.cpp ├── intersect_group.cpp ├── intersect_half_classify_group.cpp ├── intersection.cpp ├── math.cpp ├── mesh.cpp ├── octree.cpp ├── pointset.cpp ├── polyhedron.cpp ├── polyline.cpp ├── shewchuk_predicates.cpp ├── tag.cpp ├── timing.cpp ├── triangle_intersection.cpp └── triangulator.cpp ├── regression ├── compare_runs.py ├── run_tests.py ├── test-cylinders ├── test-spheres-1 ├── test-spheres-2 ├── test-spheres-3 ├── test-spheres-4 └── tests ├── src ├── CMakeLists.txt ├── close_manifold.cpp ├── convert.cpp ├── cut.cpp ├── extrude.cpp ├── face_merge.cpp ├── glu_triangulator.cpp ├── glu_triangulator.hpp ├── intersect.cpp ├── intersection.ply ├── mesh_simplify.cpp ├── selfintersect.cpp ├── slice.cpp ├── triangulate.cpp └── view.cpp ├── tests ├── CMakeLists.txt ├── coords.h ├── exact_unittest.cpp ├── geom2d_unittest.cpp ├── geom3d_unittest.cpp ├── heap_unittest.cpp ├── hook_unittest.cpp ├── leaf.txt ├── mersenne_twister.h ├── mesh_triangulate_unittest.cpp ├── mesh_unittest.cpp ├── offset.cpp ├── problem.cpp ├── shewchuk_unittest.cpp ├── test.txt ├── test_aabb.cpp ├── test_aabb_tri.cpp ├── test_carve_polyhedrons_2.cpp ├── test_csg_edge_interpolate.cpp ├── test_csg_interpolate.cpp ├── test_eigen.cpp ├── test_geom.cpp ├── test_hole_incorporate.cpp ├── test_interpolate.cpp ├── test_intersect.cpp ├── test_rescale.cpp ├── test_slice.cpp ├── test_slice_classify.cpp ├── test_spacetree.cpp ├── test_tri_pt_dist.cpp ├── test_triangulate.cpp ├── tetrahedron.cpp ├── tri_point_distance_unittest.cpp ├── triangle_intersection_unittest.cpp └── triangulate_unittest.cpp └── win32 ├── Carve.sln ├── carvelib └── carvelib.vcproj ├── fileformats └── fileformats.vcproj ├── glew └── glew.vcproj ├── gloop └── gloop.vcproj ├── glui └── glui.vcproj ├── intersect └── intersect.vcproj ├── texture_example └── texture_example.vcproj └── view └── view.vcproj /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/googletest"] 2 | path = external/googletest 3 | url = https://github.com/google/googletest.git 4 | -------------------------------------------------------------------------------- /.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | 3 | # backup files, etc. 4 | 5 | *~ 6 | *.sw? 7 | 8 | # autotools generated 9 | 10 | aclocal.m4 11 | autom4te.cache/output.0 12 | autom4te.cache/output.1 13 | autom4te.cache/requests 14 | autom4te.cache/traces.0 15 | autom4te.cache/traces.1 16 | config.log 17 | config.status 18 | configure 19 | include/carve/config.h 20 | include/carve/stamp-h2 21 | include/carve_config.h 22 | include/carve_config.h.in 23 | include/stamp-h1 24 | libtool 25 | 26 | # cmake generated 27 | 28 | CMakeFiles 29 | 30 | # debug info 31 | 32 | *.dSYM 33 | 34 | # regression test results 35 | 36 | regression/*/test_* 37 | 38 | # produced by compilation 39 | 40 | *.la 41 | *.o 42 | *.lo 43 | *.Plo 44 | *.a 45 | *.Po 46 | *.dylib 47 | *.so 48 | Makefile.in 49 | Makefile 50 | 51 | .libs 52 | .deps 53 | 54 | # generated executables 55 | 56 | src/convert 57 | src/custom_collector 58 | src/cutgraph 59 | src/intersect 60 | src/problem 61 | src/test_aabb 62 | src/test_aabb_tri 63 | src/test_csg_interpolate 64 | src/test_eigen 65 | src/test_geom 66 | src/test_hole_incorporate 67 | src/test_interpolate 68 | src/test_intersect 69 | src/test_rescale 70 | src/test_slice 71 | src/test_slice_classify 72 | src/test_spacetree 73 | src/test_triangulate 74 | src/tetrahedron 75 | src/texture_example 76 | src/triangulate 77 | src/view 78 | 79 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Toby Sargeant 2 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2009-06-01 Tobias Sargeant 2 | 3 | * Carve: initial GPL2 release. 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/NEWS -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/README -------------------------------------------------------------------------------- /common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories("${carve_SOURCE_DIR}/include") 2 | include_directories("${carve_SOURCE_DIR}/external/GLOOP/include") 3 | include_directories("${carve_SOURCE_DIR}/external/GLEW/include") 4 | include_directories("${carve_SOURCE_DIR}/external/GLUI/include") 5 | 6 | add_library(carve_fileformats STATIC read_ply.cpp write_ply.cpp) 7 | add_library(carve_misc STATIC geometry.cpp) 8 | if(CARVE_WITH_GUI) 9 | add_library(carve_ui STATIC geom_draw.cpp scene.cpp) 10 | endif(CARVE_WITH_GUI) 11 | -------------------------------------------------------------------------------- /common/geom_draw.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | #include "rgb.hpp" 36 | 37 | void drawMeshSetWireframe(carve::mesh::MeshSet<3>* poly, int group, 38 | bool draw_normal, bool draw_edgeconn); 39 | void drawMeshSet(carve::mesh::MeshSet<3>* poly, float r, float g, float b, 40 | float a, int group = -1); 41 | 42 | void drawColourPoly(const carve::geom3d::Vector& normal, 43 | std::vector >& v); 44 | void drawColourFace(carve::mesh::Face<3>* face, const std::vector& vc); 45 | void drawFace(carve::mesh::Face<3>* face, cRGBA fc); 46 | 47 | void installDebugHooks(); 48 | void drawTri(const carve::geom::tri<3>&); 49 | void drawSphere(const carve::geom::sphere<3>&); 50 | void drawCube(const carve::geom3d::Vector&, const carve::geom3d::Vector&); 51 | void drawSphere(const carve::geom3d::Vector&, double); 52 | void drawOctree(const carve::csg::Octree&); 53 | 54 | extern carve::geom3d::Vector g_translation; 55 | extern double g_scale; 56 | -------------------------------------------------------------------------------- /common/geometry.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #ifdef WIN32 33 | #undef rad1 34 | #undef rad2 35 | #endif 36 | 37 | carve::mesh::MeshSet<3>* makeCube( 38 | const carve::math::Matrix& transform = carve::math::Matrix()); 39 | 40 | carve::mesh::MeshSet<3>* makeSubdividedCube( 41 | int sub_x = 3, int sub_y = 3, int sub_z = 3, 42 | bool (*inc)(int, int, int) = nullptr, 43 | const carve::math::Matrix& transform = carve::math::Matrix()); 44 | 45 | carve::mesh::MeshSet<3>* makeDoubleCube( 46 | const carve::math::Matrix& transform = carve::math::Matrix()); 47 | 48 | carve::mesh::MeshSet<3>* makeTorus( 49 | int slices, int rings, double rad1, double rad2, 50 | const carve::math::Matrix& transform = carve::math::Matrix()); 51 | 52 | carve::mesh::MeshSet<3>* makeCylinder( 53 | int slices, double rad, double height, 54 | const carve::math::Matrix& transform = carve::math::Matrix()); 55 | 56 | carve::mesh::MeshSet<3>* makeCone( 57 | int slices, double rad, double height, 58 | const carve::math::Matrix& transform = carve::math::Matrix()); 59 | -------------------------------------------------------------------------------- /common/scene.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | class Option { 36 | public: 37 | bool isChecked(); 38 | void setChecked(bool value); 39 | }; 40 | 41 | class OptionGroup { 42 | public: 43 | Option* createOption(const char* caption, bool initialValue); 44 | }; 45 | 46 | class Scene { 47 | static GLvoid s_drag(int x, int y); 48 | static GLvoid s_click(int button, int state, int x, int y); 49 | static GLvoid s_key(unsigned char k, int x, int y); 50 | static GLvoid s_draw(); 51 | static GLvoid s_resize(int w, int h); 52 | 53 | carve::geom3d::Vector CAM_LOOK; 54 | double CAM_ROT; 55 | double CAM_ELEVATION; 56 | double CAM_DIST; 57 | carve::geom3d::Vector CAM_LOOK_REAL; 58 | double CAM_DIST_REAL; 59 | 60 | int WIDTH; 61 | int HEIGHT; 62 | 63 | bool initialised; 64 | bool disp_grid; 65 | bool disp_axes; 66 | 67 | GLvoid _drag(int x, int y); 68 | GLvoid _click(int button, int state, int x, int y); 69 | GLvoid _key(unsigned char k, int x, int y); 70 | GLvoid _draw(); 71 | GLvoid _resize(int w, int h); 72 | virtual void _init(); 73 | 74 | void updateDisplay(); 75 | 76 | protected: 77 | virtual bool key(unsigned char k, int x, int y); 78 | virtual GLvoid draw(); 79 | virtual void click(int button, int state, int x, int y); 80 | 81 | public: 82 | Scene(int argc, char** argv); 83 | virtual ~Scene(); 84 | virtual void run(); 85 | void init(); 86 | 87 | carve::geom3d::Ray getRay(int x, int y); 88 | void zoomTo(carve::geom3d::Vector pos, double dist); 89 | OptionGroup* createOptionGroup(const char* title); 90 | }; 91 | -------------------------------------------------------------------------------- /data/armadillo.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/data/armadillo.ply -------------------------------------------------------------------------------- /data/bunny2.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/data/bunny2.ply -------------------------------------------------------------------------------- /data/case2_A.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/data/case2_A.ply -------------------------------------------------------------------------------- /data/case2_A_intersect_B.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format binary_little_endian 1.0 3 | element vertex 0 4 | property double x 5 | property double y 6 | property double z 7 | element face 0 8 | property list uchar uchar vertex_indices 9 | end_header 10 | -------------------------------------------------------------------------------- /data/case2_B.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/data/case2_B.ply -------------------------------------------------------------------------------- /data/cow.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/data/cow.ply -------------------------------------------------------------------------------- /data/cow2.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/data/cow2.ply -------------------------------------------------------------------------------- /data/cube.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | element vertex 8 4 | property double x 5 | property double y 6 | property double z 7 | element face 12 8 | property list uchar uchar vertex_indices 9 | end_header 10 | -1 -1 -1 11 | -1 -1 1 12 | -1 1 -1 13 | -1 1 1 14 | 1 -1 -1 15 | 1 -1 1 16 | 1 1 -1 17 | 1 1 1 18 | 3 7 3 1 19 | 3 7 1 5 20 | 3 4 0 2 21 | 3 4 2 6 22 | 3 7 6 2 23 | 3 7 2 3 24 | 3 3 2 0 25 | 3 3 0 1 26 | 3 1 0 4 27 | 3 1 4 5 28 | 3 5 4 6 29 | 3 5 6 7 30 | -------------------------------------------------------------------------------- /data/elephant.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/data/elephant.ply -------------------------------------------------------------------------------- /data/elephant2.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/data/elephant2.ply -------------------------------------------------------------------------------- /data/hippo.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/data/hippo.ply -------------------------------------------------------------------------------- /data/horse2.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/data/horse2.ply -------------------------------------------------------------------------------- /data/ico.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | element vertex 12 4 | property float32 x 5 | property float32 y 6 | property float32 z 7 | property float32 nx 8 | property float32 ny 9 | property float32 nz 10 | element face 20 11 | property list uint8 int32 vertex_indices 12 | end_header 13 | -0.276385 -0.850640 -0.447215 -0.276376 -0.850642 -0.447188 14 | 0.000000 0.000000 -1.000000 0.000000 0.000000 -1.000000 15 | 0.723600 -0.525720 -0.447215 0.723594 -0.525712 -0.447188 16 | 0.723600 0.525720 -0.447215 0.723594 0.525712 -0.447188 17 | -0.894425 0.000000 -0.447215 -0.894406 0.000000 -0.447188 18 | -0.276385 0.850640 -0.447215 -0.276376 0.850642 -0.447188 19 | 0.894425 0.000000 0.447215 0.894406 0.000000 0.447188 20 | 0.276385 -0.850640 0.447215 0.276376 -0.850642 0.447188 21 | -0.723600 -0.525720 0.447215 -0.723594 -0.525712 0.447188 22 | -0.723600 0.525720 0.447215 -0.723594 0.525712 0.447188 23 | 0.276385 0.850640 0.447215 0.276376 0.850642 0.447188 24 | 0.000000 0.000000 1.000000 0.000000 0.000000 1.000000 25 | 3 0 1 2 26 | 3 2 1 3 27 | 3 4 1 0 28 | 3 5 1 4 29 | 3 3 1 5 30 | 3 2 3 6 31 | 3 0 2 7 32 | 3 4 0 8 33 | 3 5 4 9 34 | 3 3 5 10 35 | 3 6 7 2 36 | 3 7 8 0 37 | 3 8 9 4 38 | 3 9 10 5 39 | 3 10 6 3 40 | 3 7 6 11 41 | 3 8 7 11 42 | 3 9 8 11 43 | 3 10 9 11 44 | 3 6 10 11 45 | -------------------------------------------------------------------------------- /data/maxplanck.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/data/maxplanck.ply -------------------------------------------------------------------------------- /doc/TODO.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/TODO.txt -------------------------------------------------------------------------------- /doc/carve.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/carve.pdf -------------------------------------------------------------------------------- /doc/ops/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/ops/a.png -------------------------------------------------------------------------------- /doc/ops/a.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/ops/a.tiff -------------------------------------------------------------------------------- /doc/ops/a_intersection_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/ops/a_intersection_b.png -------------------------------------------------------------------------------- /doc/ops/a_intersection_b.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/ops/a_intersection_b.tiff -------------------------------------------------------------------------------- /doc/ops/a_minus_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/ops/a_minus_b.png -------------------------------------------------------------------------------- /doc/ops/a_minus_b.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/ops/a_minus_b.tiff -------------------------------------------------------------------------------- /doc/ops/a_union_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/ops/a_union_b.png -------------------------------------------------------------------------------- /doc/ops/a_union_b.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/ops/a_union_b.tiff -------------------------------------------------------------------------------- /doc/ops/a_xor_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/ops/a_xor_b.png -------------------------------------------------------------------------------- /doc/ops/a_xor_b.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/ops/a_xor_b.tiff -------------------------------------------------------------------------------- /doc/ops/b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/ops/b.png -------------------------------------------------------------------------------- /doc/ops/b.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/ops/b.tiff -------------------------------------------------------------------------------- /doc/ops/b_minus_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/ops/b_minus_a.png -------------------------------------------------------------------------------- /doc/ops/b_minus_a.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/ops/b_minus_a.tiff -------------------------------------------------------------------------------- /doc/ops/texput.log: -------------------------------------------------------------------------------- 1 | This is XeTeXk, Version 3.141592-2.2-0.996 (Web2C 7.5.6) (format=xelatex 2008.5.12) 29 SEP 2008 15:50 2 | entering extended mode 3 | %&-line parsing enabled. 4 | **carve.tex 5 | 6 | ! Emergency stop. 7 | <*> carve.tex 8 | 9 | End of file on the terminal! 10 | 11 | 12 | Here is how much of TeX's memory you used: 13 | 2 strings out of 94863 14 | 15 string characters out of 1171490 15 | 46799 words of memory out of 1500000 16 | 3287 multiletter control sequences out of 10000+50000 17 | 3640 words of font info for 14 fonts, out of 1200000 for 2000 18 | 605 hyphenation exceptions out of 8191 19 | 0i,0n,0p,1b,6s stack positions out of 5000i,500n,6000p,200000b,5000s 20 | No pages of output. 21 | -------------------------------------------------------------------------------- /doc/polyhedra/shared-edge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/polyhedra/shared-edge.png -------------------------------------------------------------------------------- /doc/polyhedra/shared-edge.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/polyhedra/shared-edge.tif -------------------------------------------------------------------------------- /doc/polyhedra/shared-vertex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/polyhedra/shared-vertex.png -------------------------------------------------------------------------------- /doc/polyhedra/shared-vertex.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/polyhedra/shared-vertex.tif -------------------------------------------------------------------------------- /doc/title-page.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/doc/title-page.pdf -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories("${carve_SOURCE_DIR}/include") 2 | include_directories("${carve_SOURCE_DIR}/external/GLOOP/include") 3 | include_directories("${carve_SOURCE_DIR}/external/GLEW/include") 4 | include_directories("${carve_SOURCE_DIR}/external/GLUI/include") 5 | include_directories("${carve_SOURCE_DIR}/common") 6 | include_directories(${OPENGL_INCLUDE_DIR}) 7 | 8 | link_directories("${gloop_BINARY_DIR}") 9 | link_directories("${carve_BINARY_DIR}/common") 10 | 11 | if(CARVE_WITH_GUI) 12 | add_executable (custom_collector custom_collector.cpp) 13 | target_link_libraries(custom_collector carve carve_ui carve_misc glui carve_fileformats gloop_model ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES}) 14 | 15 | add_executable (texture_example texture_example.cpp) 16 | target_link_libraries(texture_example carve carve_ui carve_misc glui carve_fileformats gloop_model ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES}) 17 | 18 | add_executable (detail_clip detail_clip.cpp) 19 | target_link_libraries(detail_clip carve carve_misc carve_fileformats gloop_model) 20 | endif(CARVE_WITH_GUI) 21 | -------------------------------------------------------------------------------- /external/GLEW/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | 3 | project(glew) 4 | 5 | find_package(OpenGL) 6 | 7 | include_directories("${glew_SOURCE_DIR}/include") 8 | 9 | add_library(glew STATIC src/glew.c) 10 | 11 | add_definitions(-DGLEW_STATIC) 12 | 13 | include_directories(${OPENGL_INCLUDE_DIR}) 14 | 15 | target_link_libraries(glew ${OPENGL_LIBRARIES}) 16 | -------------------------------------------------------------------------------- /external/GLOOP/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | 3 | project(gloop) 4 | 5 | include_directories("${gloop_SOURCE_DIR}/include") 6 | include_directories("${glew_SOURCE_DIR}/include") 7 | 8 | find_package(OpenGL) 9 | include_directories(${OPENGL_INCLUDE_DIR}) 10 | 11 | add_library(gloop_math STATIC src/matrix.cpp src/quaternion.cpp) 12 | 13 | add_library(gloop_image STATIC src/radiance.cpp) 14 | 15 | add_library(gloop_model STATIC src/model/stream.cpp src/model/ply_format.cpp src/model/obj_format.cpp src/model/vtk_format.cpp) 16 | 17 | if(CARVE_WITH_GUI) 18 | add_library(gloop STATIC src/shader.cpp src/surface.cpp src/texparam.cpp src/vbo.cpp src/fbo.cpp) 19 | target_link_libraries(gloop ${OPENGL_LIBRARIES}) 20 | endif(CARVE_WITH_GUI) 21 | -------------------------------------------------------------------------------- /external/GLOOP/include/gloop/exceptions.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Tobias Sargeant 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the 13 | // distribution. The names of its contributors may be used to endorse 14 | // or promote products derived from this software without specific 15 | // prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | // OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #pragma once 31 | 32 | #include 33 | #include 34 | 35 | namespace gloop { 36 | 37 | struct exception { 38 | private: 39 | mutable std::string err; 40 | 41 | public: 42 | exception(const std::string &e) : err(e) { } 43 | exception() : err() { } 44 | 45 | const std::string &str() const { 46 | return err; 47 | } 48 | }; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /external/GLOOP/include/gloop/gl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Tobias Sargeant 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the 13 | // distribution. The names of its contributors may be used to endorse 14 | // or promote products derived from this software without specific 15 | // prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | // OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #pragma once 31 | 32 | #include 33 | -------------------------------------------------------------------------------- /external/GLOOP/include/gloop/gl/fbo.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | namespace gloop { 31 | class FrameBuffer { 32 | static std::vector s_bound_fbo; 33 | 34 | GLuint fbo; 35 | unsigned width; 36 | unsigned height; 37 | 38 | std::pair depth; 39 | std::pair stencil; 40 | std::vector > colour; 41 | 42 | bool _attach(GLenum target, const Surface::Ptr &surf, GLenum attachment, int mipmap_level); 43 | 44 | public: 45 | FrameBuffer(unsigned _width, unsigned _height); 46 | 47 | void add(GLenum target, const Surface::Ptr &surf); 48 | void add(const Surface::Ptr &surf); 49 | void init(); 50 | void pushBind(); 51 | void bind(); 52 | static void popBind(); 53 | void attach(int mipmap_level = 0); 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /external/GLOOP/include/gloop/gl/vertexformat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Tobias Sargeant 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the 13 | // distribution. The names of its contributors may be used to endorse 14 | // or promote products derived from this software without specific 15 | // prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | // OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #pragma once 31 | 32 | #include 33 | 34 | namespace gloop { 35 | 36 | namespace vf { 37 | struct V3F_N3F { 38 | typedef V3F_N3F self; 39 | 40 | V3 v, n; 41 | 42 | static inline void install() { 43 | const static void *_off_v = (const void *)offsetof(self, v); 44 | const static void *_off_n = (const void *)offsetof(self, n); 45 | glEnableClientState(GL_NORMAL_ARRAY); 46 | glNormalPointer(GL_FLOAT, sizeof(self), _off_n); 47 | 48 | glEnableClientState(GL_VERTEX_ARRAY); 49 | glVertexPointer(3, GL_FLOAT, sizeof(self), _off_v); 50 | } 51 | static inline void uninstall() { 52 | glDisableClientState(GL_VERTEX_ARRAY); 53 | glDisableClientState(GL_NORMAL_ARRAY); 54 | } 55 | }; 56 | }; 57 | 58 | } 59 | -------------------------------------------------------------------------------- /external/GLOOP/include/gloop/gloop-gl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Tobias Sargeant 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the 13 | // distribution. The names of its contributors may be used to endorse 14 | // or promote products derived from this software without specific 15 | // prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | // OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #pragma once 31 | 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | 40 | #include 41 | #include 42 | -------------------------------------------------------------------------------- /external/GLOOP/include/gloop/gloop-image.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Tobias Sargeant 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the 13 | // distribution. The names of its contributors may be used to endorse 14 | // or promote products derived from this software without specific 15 | // prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | // OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | -------------------------------------------------------------------------------- /external/GLOOP/include/gloop/gloop-math.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Tobias Sargeant 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the 13 | // distribution. The names of its contributors may be used to endorse 14 | // or promote products derived from this software without specific 15 | // prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | // OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #pragma once 31 | 32 | #include 33 | #include 34 | #include 35 | -------------------------------------------------------------------------------- /external/GLOOP/include/gloop/gloop-model.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Tobias Sargeant 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the 13 | // distribution. The names of its contributors may be used to endorse 14 | // or promote products derived from this software without specific 15 | // prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | // OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #pragma once 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | -------------------------------------------------------------------------------- /external/GLOOP/include/gloop/gloop.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Tobias Sargeant 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the 13 | // distribution. The names of its contributors may be used to endorse 14 | // or promote products derived from this software without specific 15 | // prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | // OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #pragma once 31 | 32 | #if defined(_MSC_VER) 33 | # pragma warning(disable:4201) 34 | #endif 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | -------------------------------------------------------------------------------- /external/GLOOP/include/gloop/glu.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #if defined(__APPLE__) 28 | #include 29 | #else 30 | #include 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /external/GLOOP/include/gloop/glut.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #if defined(__APPLE__) 28 | #include 29 | #else 30 | #include 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /external/GLOOP/include/gloop/model/obj_format.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Tobias Sargeant 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the 13 | // distribution. The names of its contributors may be used to endorse 14 | // or promote products derived from this software without specific 15 | // prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | // OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #pragma once 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | namespace gloop { 39 | namespace obj { 40 | 41 | // an obj file is an ascii format. 42 | // comment lines are denoted by # 43 | // primitives are presented one per line, with \ representing a continuation. 44 | // the first whitespace delimted token on each line denotes the type of element represented on the line. 45 | 46 | class ObjReader : public stream::model_reader { 47 | 48 | bool readDoubles(std::istream &in, 49 | stream::reader_base *e_rd, 50 | stream::reader_base **v_rd, 51 | size_t min_count, 52 | size_t rd_count, 53 | const double *defaults); 54 | bool readIntLists(std::istream &in, 55 | stream::reader_base *e_rd, 56 | stream::reader_base **v_rd, 57 | size_t rd_count); 58 | 59 | public: 60 | ObjReader() : stream::model_reader() { 61 | } 62 | 63 | virtual ~ObjReader() { 64 | } 65 | 66 | virtual bool read(std::istream &in); 67 | }; 68 | 69 | class ObjWriter : public stream::model_writer { 70 | 71 | public: 72 | 73 | ObjWriter() : stream::model_writer() { 74 | } 75 | 76 | virtual ~ObjWriter() { 77 | } 78 | 79 | virtual bool write(std::ostream &in); 80 | }; 81 | 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /external/GLOOP/include/gloop/model/ply_format.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Tobias Sargeant 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the 13 | // distribution. The names of its contributors may be used to endorse 14 | // or promote products derived from this software without specific 15 | // prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | // OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #pragma once 31 | 32 | #include 33 | 34 | #include 35 | 36 | #include 37 | #include 38 | 39 | namespace gloop { 40 | namespace ply { 41 | 42 | class PlyReader : public stream::model_reader { 43 | public: 44 | PlyReader() : stream::model_reader() { 45 | } 46 | 47 | virtual ~PlyReader() { 48 | } 49 | 50 | virtual bool read(std::istream &in); 51 | }; 52 | 53 | class PlyWriter : public stream::model_writer { 54 | public: 55 | bool binary; 56 | bool byteswap; 57 | 58 | PlyWriter(bool _binary, bool _byteswap) : stream::model_writer(), binary(_binary), byteswap(_byteswap) { 59 | } 60 | 61 | virtual ~PlyWriter() { 62 | } 63 | 64 | virtual bool write(std::ostream &in); 65 | }; 66 | 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /external/GLOOP/include/gloop/model/vtk_format.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Tobias Sargeant 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the 13 | // distribution. The names of its contributors may be used to endorse 14 | // or promote products derived from this software without specific 15 | // prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | // OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #pragma once 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | namespace gloop { 39 | namespace vtk { 40 | 41 | class VtkReader : public stream::model_reader { 42 | struct point_t { double x, y, z; }; 43 | 44 | void emitPoints(const std::vector &point_data, const std::string &base); 45 | 46 | bool readASCII(std::istream &in); 47 | bool readBinary(std::istream &in); 48 | bool readPlain(std::istream &in); 49 | bool readXML(std::istream &in); 50 | 51 | public: 52 | VtkReader() : stream::model_reader() { 53 | } 54 | 55 | virtual ~VtkReader() { 56 | } 57 | 58 | virtual bool read(std::istream &in); 59 | }; 60 | 61 | class VtkWriter : public stream::model_writer { 62 | public: 63 | enum Fmt { ASCII, BINARY, XML }; 64 | 65 | protected: 66 | Fmt fmt; 67 | 68 | public: 69 | VtkWriter(Fmt _fmt) : stream::model_writer(), fmt(_fmt) { 70 | } 71 | 72 | virtual ~VtkWriter() { 73 | } 74 | 75 | virtual bool write(std::ostream &in); 76 | }; 77 | 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /external/GLOOP/src/matrix.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Tobias Sargeant 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the 13 | // distribution. The names of its contributors may be used to endorse 14 | // or promote products derived from this software without specific 15 | // prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | // OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | #include 32 | 33 | namespace gloop { 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /external/GLOOP/src/texparam.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Tobias Sargeant 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the 13 | // distribution. The names of its contributors may be used to endorse 14 | // or promote products derived from this software without specific 15 | // prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | // OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | namespace gloop { 35 | 36 | GLfloat TextureParam::s_max_anisotropy = 0.0; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /external/GLOOP/src/vbo.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Tobias Sargeant 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the 13 | // distribution. The names of its contributors may be used to endorse 14 | // or promote products derived from this software without specific 15 | // prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | // OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | namespace gloop { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /external/GLUI/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | 3 | find_package(OpenGL) 4 | find_package(GLUT) 5 | 6 | project(glui) 7 | 8 | include_directories("${glui_SOURCE_DIR}/include") 9 | 10 | add_definitions(-DGLUI_NO_LIB_PRAGMA) 11 | add_definitions(-DGLUI_USE_STATIC_LIB) 12 | 13 | include_directories(${OPENGL_INCLUDE_DIR}) 14 | include_directories(${GLUT_INCLUDE_DIR}) 15 | 16 | add_library(glui STATIC 17 | src/algebra3.cpp 18 | src/arcball.cpp 19 | src/arcball.h 20 | src/glui.cpp 21 | src/glui_add_controls.cpp 22 | src/glui_bitmap_img_data.cpp 23 | src/glui_bitmaps.cpp 24 | src/glui_button.cpp 25 | src/glui_checkbox.cpp 26 | src/glui_column.cpp 27 | src/glui_commandline.cpp 28 | src/glui_control.cpp 29 | src/glui_edittext.cpp 30 | src/glui_filebrowser.cpp 31 | src/glui_list.cpp 32 | src/glui_listbox.cpp 33 | src/glui_mouse_iaction.cpp 34 | src/glui_node.cpp 35 | src/glui_panel.cpp 36 | src/glui_radio.cpp 37 | src/glui_rollout.cpp 38 | src/glui_rotation.cpp 39 | src/glui_scrollbar.cpp 40 | src/glui_separator.cpp 41 | src/glui_spinner.cpp 42 | src/glui_statictext.cpp 43 | src/glui_string.cpp 44 | src/glui_textbox.cpp 45 | src/glui_translation.cpp 46 | src/glui_tree.cpp 47 | src/glui_treepanel.cpp 48 | src/glui_window.cpp 49 | src/quaternion.cpp 50 | src/viewmodel.cpp) 51 | 52 | target_link_libraries(glui ${OPENGL_LIBRARIES} ${GLUT_LIBRARY}) 53 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_checkbox_0.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_checkbox_0[] = { 13, 13, /* width, height */ 4 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 5 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 6 | 255,255,255, 255,255,255, 255,255,255, 128,128,128, 192,192,192, 7 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 8 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 9 | 255,255,255, 128,128,128, 0, 0, 0, 255,255,255, 255,255,255, 10 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 11 | 255,255,255, 255,255,255, 192,192,192, 255,255,255, 128,128,128, 12 | 0, 0, 0, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 13 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 14 | 192,192,192, 255,255,255, 128,128,128, 0, 0, 0, 255,255,255, 15 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 16 | 255,255,255, 255,255,255, 255,255,255, 192,192,192, 255,255,255, 17 | 128,128,128, 0, 0, 0, 255,255,255, 255,255,255, 255,255,255, 18 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 19 | 255,255,255, 192,192,192, 255,255,255, 128,128,128, 0, 0, 0, 20 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 21 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 192,192,192, 22 | 255,255,255, 128,128,128, 0, 0, 0, 255,255,255, 255,255,255, 23 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 24 | 255,255,255, 255,255,255, 192,192,192, 255,255,255, 128,128,128, 25 | 0, 0, 0, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 26 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 27 | 192,192,192, 255,255,255, 128,128,128, 0, 0, 0, 255,255,255, 28 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 29 | 255,255,255, 255,255,255, 255,255,255, 192,192,192, 255,255,255, 30 | 128,128,128, 0, 0, 0, 255,255,255, 255,255,255, 255,255,255, 31 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 32 | 255,255,255, 192,192,192, 255,255,255, 128,128,128, 0, 0, 0, 33 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192,192,192, 35 | 255,255,255, 128,128,128, 128,128,128, 128,128,128, 128,128,128, 36 | 128,128,128, 128,128,128, 128,128,128, 128,128,128, 128,128,128, 37 | 128,128,128, 128,128,128, 128,128,128, 255,255,255, 38 | }; 39 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_checkbox_0_dis.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_checkbox_0_dis[] = { 13, 13, /* width, height */ 4 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 5 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 6 | 255,255,255, 255,255,255, 255,255,255, 128,128,128, 192,192,192, 7 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 8 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 9 | 255,255,255, 128,128,128, 64, 64, 64, 192,192,192, 192,192,192, 10 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 11 | 192,192,192, 192,192,192, 192,192,192, 255,255,255, 128,128,128, 12 | 64, 64, 64, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 13 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 14 | 192,192,192, 255,255,255, 128,128,128, 64, 64, 64, 192,192,192, 15 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 16 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 255,255,255, 17 | 128,128,128, 64, 64, 64, 192,192,192, 192,192,192, 192,192,192, 18 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 19 | 192,192,192, 192,192,192, 255,255,255, 128,128,128, 64, 64, 64, 20 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 21 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 22 | 255,255,255, 128,128,128, 64, 64, 64, 192,192,192, 192,192,192, 23 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 24 | 192,192,192, 192,192,192, 192,192,192, 255,255,255, 128,128,128, 25 | 64, 64, 64, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 26 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 27 | 192,192,192, 255,255,255, 128,128,128, 64, 64, 64, 192,192,192, 28 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 29 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 255,255,255, 30 | 128,128,128, 64, 64, 64, 192,192,192, 192,192,192, 192,192,192, 31 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 32 | 192,192,192, 192,192,192, 255,255,255, 128,128,128, 64, 64, 64, 33 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 34 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 192,192,192, 35 | 255,255,255, 128,128,128, 128,128,128, 128,128,128, 128,128,128, 36 | 128,128,128, 128,128,128, 128,128,128, 128,128,128, 128,128,128, 37 | 128,128,128, 128,128,128, 128,128,128, 255,255,255, 38 | }; 39 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_checkbox_1.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_checkbox_1[] = { 13, 13, /* width, height */ 4 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 5 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 6 | 255,255,255, 255,255,255, 255,255,255, 128,128,128, 192,192,192, 7 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 8 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 9 | 255,255,255, 128,128,128, 0, 0, 0, 255,255,255, 255,255,255, 10 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 11 | 255,255,255, 255,255,255, 192,192,192, 255,255,255, 128,128,128, 12 | 0, 0, 0, 255,255,255, 255,255,255, 255,255,255, 0, 0, 0, 13 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 14 | 192,192,192, 255,255,255, 128,128,128, 0, 0, 0, 255,255,255, 15 | 255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,255,255, 16 | 255,255,255, 255,255,255, 255,255,255, 192,192,192, 255,255,255, 17 | 128,128,128, 0, 0, 0, 255,255,255, 0, 0, 0, 0, 0, 0, 18 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,255,255, 255,255,255, 19 | 255,255,255, 192,192,192, 255,255,255, 128,128,128, 0, 0, 0, 20 | 255,255,255, 0, 0, 0, 0, 0, 0, 255,255,255, 0, 0, 0, 21 | 0, 0, 0, 0, 0, 0, 255,255,255, 255,255,255, 192,192,192, 22 | 255,255,255, 128,128,128, 0, 0, 0, 255,255,255, 0, 0, 0, 23 | 255,255,255, 255,255,255, 255,255,255, 0, 0, 0, 0, 0, 0, 24 | 0, 0, 0, 255,255,255, 192,192,192, 255,255,255, 128,128,128, 25 | 0, 0, 0, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 26 | 255,255,255, 255,255,255, 0, 0, 0, 0, 0, 0, 255,255,255, 27 | 192,192,192, 255,255,255, 128,128,128, 0, 0, 0, 255,255,255, 28 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 29 | 255,255,255, 0, 0, 0, 255,255,255, 192,192,192, 255,255,255, 30 | 128,128,128, 0, 0, 0, 255,255,255, 255,255,255, 255,255,255, 31 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 32 | 255,255,255, 192,192,192, 255,255,255, 128,128,128, 0, 0, 0, 33 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192,192,192, 35 | 255,255,255, 128,128,128, 128,128,128, 128,128,128, 128,128,128, 36 | 128,128,128, 128,128,128, 128,128,128, 128,128,128, 128,128,128, 37 | 128,128,128, 128,128,128, 128,128,128, 255,255,255, 38 | }; 39 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_checkbox_1_dis.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_checkbox_1_dis[] = { 13, 13, /* width, height */ 4 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 5 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 6 | 255,255,255, 255,255,255, 255,255,255, 128,128,128, 192,192,192, 7 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 8 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 9 | 255,255,255, 128,128,128, 64, 64, 64, 192,192,192, 192,192,192, 10 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 11 | 192,192,192, 192,192,192, 192,192,192, 255,255,255, 128,128,128, 12 | 64, 64, 64, 192,192,192, 192,192,192, 192,192,192, 64, 64, 64, 13 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 14 | 192,192,192, 255,255,255, 128,128,128, 64, 64, 64, 192,192,192, 15 | 192,192,192, 64, 64, 64, 64, 64, 64, 64, 64, 64, 192,192,192, 16 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 255,255,255, 17 | 128,128,128, 64, 64, 64, 192,192,192, 64, 64, 64, 64, 64, 64, 18 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 192,192,192, 192,192,192, 19 | 192,192,192, 192,192,192, 255,255,255, 128,128,128, 64, 64, 64, 20 | 192,192,192, 64, 64, 64, 64, 64, 64, 192,192,192, 64, 64, 64, 21 | 64, 64, 64, 64, 64, 64, 192,192,192, 192,192,192, 192,192,192, 22 | 255,255,255, 128,128,128, 64, 64, 64, 192,192,192, 64, 64, 64, 23 | 192,192,192, 192,192,192, 192,192,192, 64, 64, 64, 64, 64, 64, 24 | 64, 64, 64, 192,192,192, 192,192,192, 255,255,255, 128,128,128, 25 | 64, 64, 64, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 26 | 192,192,192, 192,192,192, 64, 64, 64, 64, 64, 64, 192,192,192, 27 | 192,192,192, 255,255,255, 128,128,128, 64, 64, 64, 192,192,192, 28 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 29 | 192,192,192, 64, 64, 64, 192,192,192, 192,192,192, 255,255,255, 30 | 128,128,128, 64, 64, 64, 192,192,192, 192,192,192, 192,192,192, 31 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 32 | 192,192,192, 192,192,192, 255,255,255, 128,128,128, 64, 64, 64, 33 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 34 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 192,192,192, 35 | 255,255,255, 128,128,128, 128,128,128, 128,128,128, 128,128,128, 36 | 128,128,128, 128,128,128, 128,128,128, 128,128,128, 128,128,128, 37 | 128,128,128, 128,128,128, 128,128,128, 255,255,255, 38 | }; 39 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_listbox_down.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_listbox_down[] = { 11, 17, /* width, height */ 4 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6 | 0, 0, 0, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 7 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 8 | 127,127,127, 0, 0, 0, 127,127,127, 191,191,191, 191,191,191, 9 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 10 | 191,191,191, 127,127,127, 0, 0, 0, 127,127,127, 191,191,191, 11 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 12 | 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 127,127,127, 13 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 14 | 191,191,191, 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 15 | 127,127,127, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 16 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 127,127,127, 17 | 0, 0, 0, 127,127,127, 191,191,191, 191,191,191, 191,191,191, 18 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 19 | 127,127,127, 0, 0, 0, 127,127,127, 191,191,191, 191,191,191, 20 | 191,191,191, 191,191,191, 127,127,127, 191,191,191, 191,191,191, 21 | 191,191,191, 127,127,127, 0, 0, 0, 127,127,127, 191,191,191, 22 | 191,191,191, 191,191,191, 127,127,127, 127,127,127, 127,127,127, 23 | 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 127,127,127, 24 | 191,191,191, 191,191,191, 127,127,127, 127,127,127, 127,127,127, 25 | 127,127,127, 127,127,127, 191,191,191, 127,127,127, 0, 0, 0, 26 | 127,127,127, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 27 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 127,127,127, 28 | 0, 0, 0, 127,127,127, 191,191,191, 191,191,191, 191,191,191, 29 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 30 | 127,127,127, 0, 0, 0, 127,127,127, 191,191,191, 191,191,191, 31 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 32 | 191,191,191, 127,127,127, 0, 0, 0, 127,127,127, 191,191,191, 33 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 34 | 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 127,127,127, 35 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 36 | 191,191,191, 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 37 | 127,127,127, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 38 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 127,127,127, 39 | 0, 0, 0, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 40 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 41 | 127,127,127, 0, 0, 0, 42 | }; 43 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_listbox_up.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_listbox_up[] = { 11, 17, /* width, height */ 4 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6 | 0, 0, 0, 191,191,191, 127,127,127, 127,127,127, 127,127,127, 7 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 8 | 127,127,127, 0, 0, 0, 191,191,191, 255,255,255, 191,191,191, 9 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 10 | 191,191,191, 127,127,127, 0, 0, 0, 191,191,191, 255,255,255, 11 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 12 | 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 191,191,191, 13 | 255,255,255, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 14 | 191,191,191, 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 15 | 191,191,191, 255,255,255, 191,191,191, 191,191,191, 191,191,191, 16 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 127,127,127, 17 | 0, 0, 0, 191,191,191, 255,255,255, 191,191,191, 191,191,191, 18 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 19 | 127,127,127, 0, 0, 0, 191,191,191, 255,255,255, 191,191,191, 20 | 191,191,191, 191,191,191, 0, 0, 0, 191,191,191, 191,191,191, 21 | 191,191,191, 127,127,127, 0, 0, 0, 191,191,191, 255,255,255, 22 | 191,191,191, 191,191,191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23 | 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 191,191,191, 24 | 255,255,255, 191,191,191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25 | 0, 0, 0, 0, 0, 0, 191,191,191, 127,127,127, 0, 0, 0, 26 | 191,191,191, 255,255,255, 191,191,191, 191,191,191, 191,191,191, 27 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 127,127,127, 28 | 0, 0, 0, 191,191,191, 255,255,255, 191,191,191, 191,191,191, 29 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 30 | 127,127,127, 0, 0, 0, 191,191,191, 255,255,255, 191,191,191, 31 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 32 | 191,191,191, 127,127,127, 0, 0, 0, 191,191,191, 255,255,255, 33 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 34 | 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 191,191,191, 35 | 255,255,255, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 36 | 191,191,191, 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 37 | 191,191,191, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 38 | 255,255,255, 255,255,255, 255,255,252, 255,255,255, 127,127,127, 39 | 0, 0, 0, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 40 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 41 | 191,191,191, 0, 0, 0, 42 | }; 43 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_listbox_up_dis.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_listbox_up_dis[] = { 11, 17, /* width, height */ 4 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 5 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 6 | 127,127,127, 191,191,191, 127,127,127, 127,127,127, 127,127,127, 7 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 8 | 127,127,127, 127,127,127, 191,191,191, 255,255,255, 191,191,191, 9 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 10 | 191,191,191, 127,127,127, 127,127,127, 191,191,191, 255,255,255, 11 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 12 | 191,191,191, 191,191,191, 127,127,127, 127,127,127, 191,191,191, 13 | 255,255,255, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 14 | 191,191,191, 191,191,191, 191,191,191, 127,127,127, 127,127,127, 15 | 191,191,191, 255,255,255, 191,191,191, 191,191,191, 191,191,191, 16 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 127,127,127, 17 | 127,127,127, 191,191,191, 255,255,255, 191,191,191, 191,191,191, 18 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 19 | 127,127,127, 127,127,127, 191,191,191, 255,255,255, 191,191,191, 20 | 191,191,191, 191,191,191, 254,254,254, 191,191,191, 191,191,191, 21 | 191,191,191, 127,127,127, 127,127,127, 191,191,191, 255,255,255, 22 | 191,191,191, 191,191,191, 127,127,127, 127,127,127, 254,254,254, 23 | 191,191,191, 191,191,191, 127,127,127, 127,127,127, 191,191,191, 24 | 255,255,255, 191,191,191, 127,127,127, 127,127,127, 127,127,127, 25 | 127,127,127, 254,254,254, 191,191,191, 127,127,127, 127,127,127, 26 | 191,191,191, 255,255,255, 191,191,191, 191,191,191, 191,191,191, 27 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 127,127,127, 28 | 127,127,127, 191,191,191, 255,255,255, 191,191,191, 191,191,191, 29 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 30 | 127,127,127, 127,127,127, 191,191,191, 255,255,255, 191,191,191, 31 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 32 | 191,191,191, 127,127,127, 127,127,127, 191,191,191, 255,255,255, 33 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 34 | 191,191,191, 191,191,191, 127,127,127, 127,127,127, 191,191,191, 35 | 255,255,255, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 36 | 191,191,191, 191,191,191, 191,191,191, 127,127,127, 127,127,127, 37 | 191,191,191, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 38 | 255,255,255, 255,255,255, 255,255,252, 255,255,255, 127,127,127, 39 | 127,127,127, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 40 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 41 | 191,191,191, 127,127,127, 42 | }; 43 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_radiobutton_0.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_radiobutton_0[] = { 14, 14, /* width, height */ 4 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 5 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 6 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 7 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 255,255,255, 8 | 255,255,255, 255,255,255, 255,255,255, 192,192,192, 192,192,192, 9 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 10 | 192,192,192, 255,255,255, 255,255,255, 192,192,192, 192,192,192, 11 | 192,192,192, 192,192,192, 255,255,255, 255,255,255, 192,192,192, 12 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 128,128,128, 13 | 192,192,192, 192,192,192, 255,255,255, 255,255,255, 255,255,255, 14 | 255,255,255, 192,192,192, 192,192,192, 255,255,255, 192,192,192, 15 | 192,192,192, 192,192,192, 192,192,192, 128,128,128, 0, 0, 0, 16 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 17 | 255,255,255, 192,192,192, 255,255,255, 192,192,192, 192,192,192, 18 | 192,192,192, 128,128,128, 0, 0, 0, 255,255,255, 255,255,255, 19 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 20 | 255,255,255, 192,192,192, 255,255,255, 192,192,192, 192,192,192, 21 | 128,128,128, 0, 0, 0, 255,255,255, 255,255,255, 255,255,255, 22 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 23 | 192,192,192, 255,255,255, 192,192,192, 192,192,192, 128,128,128, 24 | 0, 0, 0, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 25 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 192,192,192, 26 | 255,255,255, 192,192,192, 192,192,192, 128,128,128, 0, 0, 0, 27 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 28 | 255,255,255, 255,255,255, 255,255,255, 192,192,192, 255,255,255, 29 | 192,192,192, 192,192,192, 192,192,192, 128,128,128, 0, 0, 0, 30 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 31 | 255,255,255, 192,192,192, 255,255,255, 192,192,192, 192,192,192, 32 | 192,192,192, 192,192,192, 128,128,128, 0, 0, 0, 0, 0, 0, 33 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 0, 0, 0, 34 | 0, 0, 0, 255,255,255, 192,192,192, 192,192,192, 192,192,192, 35 | 192,192,192, 192,192,192, 128,128,128, 128,128,128, 0, 0, 0, 36 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 128,128,128, 128,128,128, 37 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 38 | 192,192,192, 192,192,192, 192,192,192, 128,128,128, 128,128,128, 39 | 128,128,128, 128,128,128, 192,192,192, 192,192,192, 192,192,192, 40 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 41 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 42 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 43 | 192,192,192, 44 | }; 45 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_radiobutton_1.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_radiobutton_1[] = { 14, 14, /* width, height */ 4 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 5 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 6 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 7 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 255,255,255, 8 | 255,255,255, 255,255,255, 255,255,255, 192,192,192, 192,192,192, 9 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 10 | 192,192,192, 255,255,255, 255,255,255, 192,192,192, 192,192,192, 11 | 192,192,192, 192,192,192, 255,255,255, 255,255,255, 192,192,192, 12 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 128,128,128, 13 | 192,192,192, 192,192,192, 255,255,255, 255,255,255, 255,255,255, 14 | 255,255,255, 192,192,192, 192,192,192, 255,255,255, 192,192,192, 15 | 192,192,192, 192,192,192, 192,192,192, 128,128,128, 0, 0, 0, 16 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 17 | 255,255,255, 192,192,192, 255,255,255, 192,192,192, 192,192,192, 18 | 192,192,192, 128,128,128, 0, 0, 0, 255,255,255, 255,255,255, 19 | 255,255,255, 0, 0, 0, 0, 0, 0, 255,255,255, 255,255,255, 20 | 255,255,255, 192,192,192, 255,255,255, 192,192,192, 192,192,192, 21 | 128,128,128, 0, 0, 0, 255,255,255, 255,255,255, 0, 0, 0, 22 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,255,255, 255,255,255, 23 | 192,192,192, 255,255,255, 192,192,192, 192,192,192, 128,128,128, 24 | 0, 0, 0, 255,255,255, 255,255,255, 0, 0, 0, 0, 0, 0, 25 | 0, 0, 0, 0, 0, 0, 255,255,255, 255,255,255, 192,192,192, 26 | 255,255,255, 192,192,192, 192,192,192, 128,128,128, 0, 0, 0, 27 | 255,255,255, 255,255,255, 255,255,255, 0, 0, 0, 0, 0, 0, 28 | 255,255,255, 255,255,255, 255,255,255, 192,192,192, 255,255,255, 29 | 192,192,192, 192,192,192, 192,192,192, 128,128,128, 0, 0, 0, 30 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 31 | 255,255,255, 192,192,192, 255,255,255, 192,192,192, 192,192,192, 32 | 192,192,192, 192,192,192, 128,128,128, 0, 0, 0, 0, 0, 0, 33 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 0, 0, 0, 34 | 0, 0, 0, 255,255,255, 192,192,192, 192,192,192, 192,192,192, 35 | 192,192,192, 192,192,192, 128,128,128, 128,128,128, 0, 0, 0, 36 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 128,128,128, 128,128,128, 37 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 38 | 192,192,192, 192,192,192, 192,192,192, 128,128,128, 128,128,128, 39 | 128,128,128, 128,128,128, 192,192,192, 192,192,192, 192,192,192, 40 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 41 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 42 | 192,192,192, 192,192,192, 192,192,192, 192,192,192, 192,192,192, 43 | 192,192,192, 44 | }; 45 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_spindown_0.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_spindown_0[] = { 12, 8, /* width, height */ 4 | 255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6 | 0, 0, 0, 0, 0, 0, 255,255,255, 127,127,127, 127,127,127, 7 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 8 | 127,127,127, 127,127,127, 127,127,127, 0, 0, 0, 255,255,255, 9 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 10 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 127,127,127, 11 | 0, 0, 0, 255,255,255, 191,191,191, 191,191,191, 191,191,191, 12 | 191,191,191, 0, 0, 0, 127,127,127, 191,191,191, 191,191,191, 13 | 191,191,191, 127,127,127, 0, 0, 0, 255,255,255, 191,191,191, 14 | 191,191,191, 191,191,191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15 | 127,127,127, 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 16 | 255,255,255, 191,191,191, 191,191,191, 0, 0, 0, 0, 0, 0, 17 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 127,127,127, 191,191,191, 18 | 127,127,127, 0, 0, 0, 255,255,255, 191,191,191, 191,191,191, 19 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 20 | 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 255,255,255, 21 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 22 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 23 | 0, 0, 0, 24 | }; 25 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_spindown_1.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_spindown_1[] = { 12, 8, /* width, height */ 4 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 5 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 6 | 255,255,255, 255,255,255, 0, 0, 0, 127,127,127, 191,191,191, 7 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 8 | 191,191,191, 191,191,191, 191,191,191, 255,255,255, 0, 0, 0, 9 | 127,127,127, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 10 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 11 | 255,255,255, 0, 0, 0, 127,127,127, 191,191,191, 191,191,191, 12 | 191,191,191, 127,127,127, 0, 0, 0, 191,191,191, 191,191,191, 13 | 191,191,191, 191,191,191, 255,255,255, 0, 0, 0, 127,127,127, 14 | 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 0, 0, 0, 15 | 0, 0, 0, 191,191,191, 191,191,191, 191,191,191, 255,255,255, 16 | 0, 0, 0, 127,127,127, 191,191,191, 127,127,127, 0, 0, 0, 17 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191,191,191, 18 | 191,191,191, 255,255,255, 0, 0, 0, 127,127,127, 191,191,191, 19 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 20 | 191,191,191, 191,191,191, 191,191,191, 255,255,255, 0, 0, 0, 21 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 22 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 191,191,191, 23 | 255,255,255, 24 | }; 25 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_spindown_dis.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_spindown_dis[] = { 12, 8, /* width, height */ 4 | 255,255,255, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 5 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 6 | 64, 64, 64, 64, 64, 64, 255,255,255, 127,127,127, 127,127,127, 7 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 8 | 127,127,127, 127,127,127, 127,127,127, 64, 64, 64, 255,255,255, 9 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 10 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 127,127,127, 11 | 64, 64, 64, 255,255,255, 191,191,191, 191,191,191, 191,191,191, 12 | 191,191,191, 127,127,127, 255,255,255, 191,191,191, 191,191,191, 13 | 191,191,191, 127,127,127, 64, 64, 64, 255,255,255, 191,191,191, 14 | 191,191,191, 191,191,191, 127,127,127, 127,127,127, 127,127,127, 15 | 255,255,255, 191,191,191, 191,191,191, 127,127,127, 64, 64, 64, 16 | 255,255,255, 191,191,191, 191,191,191, 127,127,127, 127,127,127, 17 | 127,127,127, 127,127,127, 127,127,127, 255,255,255, 191,191,191, 18 | 127,127,127, 64, 64, 64, 255,255,255, 191,191,191, 191,191,191, 19 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 20 | 191,191,191, 191,191,191, 127,127,127, 64, 64, 64, 255,255,255, 21 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 22 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 23 | 64, 64, 64, 24 | }; 25 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_spinup_0.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_spinup_0[] = { 12, 8, /* width, height */ 4 | 255,255,255, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 5 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 6 | 127,127,127, 0, 0, 0, 255,255,255, 191,191,191, 191,191,191, 7 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 8 | 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 255,255,255, 9 | 191,191,191, 191,191,191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10 | 0, 0, 0, 0, 0, 0, 127,127,127, 191,191,191, 127,127,127, 11 | 0, 0, 0, 255,255,255, 191,191,191, 191,191,191, 191,191,191, 12 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 127,127,127, 191,191,191, 13 | 191,191,191, 127,127,127, 0, 0, 0, 255,255,255, 191,191,191, 14 | 191,191,191, 191,191,191, 191,191,191, 0, 0, 0, 127,127,127, 15 | 191,191,191, 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 16 | 255,255,255, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 17 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 18 | 127,127,127, 0, 0, 0, 255,255,255, 191,191,191, 191,191,191, 19 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 20 | 191,191,191, 191,191,191, 191,191,191, 0, 0, 0, 255,255,255, 21 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 22 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 23 | 255,255,255, 24 | }; 25 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_spinup_1.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_spinup_1[] = { 12, 8, /* width, height */ 4 | 0, 0, 0, 127,127,127, 255,255,255, 255,255,255, 255,255,255, 5 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 6 | 255,255,255, 255,255,255, 0, 0, 0, 127,127,127, 191,191,191, 7 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 8 | 191,191,191, 191,191,191, 191,191,191, 255,255,255, 0, 0, 0, 9 | 127,127,127, 191,191,191, 127,127,127, 0, 0, 0, 0, 0, 0, 10 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 191,191,191, 191,191,191, 11 | 255,255,255, 0, 0, 0, 127,127,127, 191,191,191, 191,191,191, 12 | 127,127,127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191,191,191, 13 | 191,191,191, 191,191,191, 255,255,255, 0, 0, 0, 127,127,127, 14 | 191,191,191, 191,191,191, 191,191,191, 127,127,127, 0, 0, 0, 15 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 255,255,255, 16 | 0, 0, 0, 127,127,127, 191,191,191, 191,191,191, 191,191,191, 17 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 18 | 191,191,191, 255,255,255, 0, 0, 0, 127,127,127, 127,127,127, 19 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 20 | 127,127,127, 127,127,127, 191,191,191, 255,255,255, 0, 0, 0, 21 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23 | 255,255,255, 24 | }; 25 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_img_spinup_dis.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | int glui_img_spinup_dis[] = { 12, 8, /* width, height */ 4 | 255,255,255, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 5 | 127,127,127, 127,127,127, 127,127,127, 127,127,127, 127,127,127, 6 | 127,127,127, 64, 64, 64, 255,255,255, 191,191,191, 191,191,191, 7 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 8 | 191,191,191, 191,191,191, 127,127,127, 64, 64, 64, 255,255,255, 9 | 191,191,191, 191,191,191, 127,127,127, 127,127,127, 127,127,127, 10 | 127,127,127, 127,127,127, 255,255,255, 191,191,191, 127,127,127, 11 | 64, 64, 64, 255,255,255, 191,191,191, 191,191,191, 191,191,191, 12 | 127,127,127, 127,127,127, 127,127,127, 255,255,255, 191,191,191, 13 | 191,191,191, 127,127,127, 64, 64, 64, 255,255,255, 191,191,191, 14 | 191,191,191, 191,191,191, 191,191,191, 127,127,127, 255,255,255, 15 | 191,191,191, 191,191,191, 191,191,191, 127,127,127, 64, 64, 64, 16 | 255,255,255, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 17 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 18 | 127,127,127, 64, 64, 64, 255,255,255, 191,191,191, 191,191,191, 19 | 191,191,191, 191,191,191, 191,191,191, 191,191,191, 191,191,191, 20 | 191,191,191, 191,191,191, 191,191,191, 64, 64, 64, 255,255,255, 21 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 22 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 23 | 255,255,255, 24 | }; 25 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_internal_control.h: -------------------------------------------------------------------------------- 1 | /* 2 | Header file for use by GLUI controls. 3 | Everything you need is right here. 4 | 5 | 6 | */ 7 | #ifndef __GLUI_INTERNAL_CONTROL_H 8 | #define __GLUI_INTERNAL_CONTROL_H 9 | 10 | /* This is the main GLUI external header */ 11 | #include "GL/glui.h" 12 | 13 | /* Here's some utility routines */ 14 | #include "glui_internal.h" 15 | 16 | 17 | /** 18 | A GLUI_Control-drawing sentinal object. 19 | On creation, saves the current draw buffer and window. 20 | On destruction, restores draw buffer and window. 21 | This is way nicer than calling save/restore manually. 22 | */ 23 | class GLUI_DrawingSentinal { 24 | int orig_buf, orig_win; 25 | GLUI_Control *c; 26 | public: 27 | /** The constructor sets up the drawing system */ 28 | GLUI_DrawingSentinal(GLUI_Control *c_); 29 | /** The destructor cleans up drawing back how it was */ 30 | ~GLUI_DrawingSentinal(); 31 | 32 | // Do-nothing routine to avoid compiler warning about unused variable 33 | inline void avoid_warning(void) {} 34 | }; 35 | /** Just drop a GLUI_DRAWINGSENTINAL_IDIOM at the start of your draw methods, 36 | and they'll return if we can't be drawn, and 37 | automatically save and restore all needed state. 38 | */ 39 | #define GLUI_DRAWINGSENTINAL_IDIOM if (NOT can_draw()) return; GLUI_DrawingSentinal drawSentinal(this); drawSentinal.avoid_warning(); 40 | 41 | 42 | /** Return the time, in seconds. */ 43 | inline double GLUI_Time(void) {return 0.001*glutGet(GLUT_ELAPSED_TIME);} 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_separator.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | GLUI User Interface Toolkit 4 | --------------------------- 5 | 6 | glui_separator.cpp - GLUI_Separator control class 7 | 8 | 9 | -------------------------------------------------- 10 | 11 | Copyright (c) 1998 Paul Rademacher 12 | 13 | WWW: http://sourceforge.net/projects/glui/ 14 | Forums: http://sourceforge.net/forum/?group_id=92496 15 | 16 | This library is free software; you can redistribute it and/or 17 | modify it under the terms of the GNU Lesser General Public 18 | License as published by the Free Software Foundation; either 19 | version 2.1 of the License, or (at your option) any later version. 20 | 21 | This library is distributed in the hope that it will be useful, 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24 | Lesser General Public License for more details. 25 | 26 | You should have received a copy of the GNU Lesser General Public 27 | License along with this library; if not, write to the Free Software 28 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 29 | 30 | *****************************************************************************/ 31 | 32 | #include "glui_internal_control.h" 33 | 34 | /****************************** GLUI_Separator::GLUI_Separator() **********/ 35 | 36 | GLUI_Separator::GLUI_Separator( GLUI_Node *parent ) 37 | { 38 | common_init(); 39 | parent->add_control( this ); 40 | } 41 | 42 | /****************************** GLUI_Separator::draw() **********/ 43 | 44 | void GLUI_Separator::draw( int x, int y ) 45 | { 46 | GLUI_DRAWINGSENTINAL_IDIOM 47 | 48 | int width, indent; 49 | int cont_x, cont_y, cont_w, cont_h, cont_x_off, cont_y_off; 50 | 51 | if ( parent() != NULL ) { 52 | get_this_column_dims(&cont_x, &cont_y, &cont_w, &cont_h, 53 | &cont_x_off, &cont_y_off); 54 | 55 | width = cont_w - cont_x_off*2; 56 | } 57 | else { 58 | width = this->w; 59 | } 60 | 61 | indent = (int) floor(width * .05); 62 | 63 | glLineWidth( 1.0 ); 64 | glBegin( GL_LINES ); 65 | glColor3f( .5, .5, .5 ); 66 | glVertex2i( indent, GLUI_SEPARATOR_HEIGHT/2-1 ); 67 | glVertex2i( width-indent, GLUI_SEPARATOR_HEIGHT/2-1 ); 68 | 69 | glColor3f( 1., 1., 1. ); 70 | glVertex2i( indent, GLUI_SEPARATOR_HEIGHT/2 ); 71 | glVertex2i( width-indent, GLUI_SEPARATOR_HEIGHT/2 ); 72 | glEnd(); 73 | } 74 | 75 | 76 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_string.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | GLUI User Interface Toolkit 4 | --------------------------- 5 | 6 | glui.cpp 7 | 8 | 9 | -------------------------------------------------- 10 | 11 | Copyright (c) 1998 Paul Rademacher (this file, Bill Baxter 2005) 12 | 13 | This library is free software; you can redistribute it and/or modify 14 | it under the terms of the GNU Lesser General Public License as 15 | published by the Free Software Foundation; either version 2.1 of the 16 | License, or (at your option) any later version. 17 | 18 | This library is distributed in the hope that it will be useful, but 19 | WITHOUT ANY WARRANTY; without even the implied warranty of 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | Lesser General Public License for more details. 22 | 23 | You should have received a copy of the GNU Lesser General Public 24 | License along with this library; if not, write to the Free Software 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 26 | USA 27 | 28 | This program is -not- in the public domain. 29 | 30 | *****************************************************************************/ 31 | 32 | #include "GL/glui.h" 33 | #include 34 | 35 | #ifdef _MSC_VER 36 | #define vsnprintf _vsnprintf 37 | #endif 38 | 39 | GLUI_String& glui_format_str(GLUI_String& str, const char* fmt, ...) 40 | { 41 | const size_t ISIZE = 128; 42 | char stackbuf[ISIZE]; 43 | size_t bufsz = ISIZE; 44 | char *buf = stackbuf; 45 | str = ""; 46 | va_list arg; 47 | while (1) { 48 | va_start(arg, fmt); 49 | int ret = vsnprintf(buf,299,fmt,arg); 50 | va_end(arg); 51 | if (ret>=0) { 52 | break; 53 | } 54 | // else make a bigger buf, try again 55 | bufsz <<= 1; 56 | if (buf==stackbuf) buf = (char*)malloc(sizeof(char)*bufsz); 57 | else buf = (char*)realloc(buf, sizeof(char)*bufsz); 58 | } 59 | if (buf!=stackbuf) free(buf); 60 | str=buf; 61 | return str; 62 | } 63 | -------------------------------------------------------------------------------- /external/GLUI/src/glui_window.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | glui_window.cpp - GLUI_Button control class 4 | 5 | GLUI User Interface Toolkit (LGPL) 6 | Copyright (c) 1998 Paul Rademacher 7 | 8 | WWW: http://sourceforge.net/projects/glui/ 9 | Forums: http://sourceforge.net/forum/?group_id=92496 10 | 11 | This library is free software; you can redistribute it and/or 12 | modify it under the terms of the GNU Lesser General Public 13 | License as published by the Free Software Foundation; either 14 | version 2.1 of the License, or (at your option) any later version. 15 | 16 | This library is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | Lesser General Public License for more details. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this library; if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | 25 | */ 26 | 27 | #include "GL/glui.h" 28 | #include "glui_internal.h" 29 | 30 | GLUI_Glut_Window::GLUI_Glut_Window() 31 | : GLUI_Node(), 32 | 33 | glut_window_id(0), 34 | glut_keyboard_CB(NULL), 35 | glut_special_CB(NULL), 36 | glut_reshape_CB(NULL), 37 | glut_passive_motion_CB(NULL), 38 | glut_mouse_CB(NULL), 39 | glut_visibility_CB(NULL), 40 | glut_motion_CB(NULL), 41 | glut_display_CB(NULL), 42 | glut_entry_CB(NULL) 43 | { 44 | } 45 | -------------------------------------------------------------------------------- /external/README.GLOOP: -------------------------------------------------------------------------------- 1 | GLOOP 2 | 3 | Copyright (c) 2006, Tobias Sargeant 4 | All rights reserved. 5 | 6 | Distributed under the following license: 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions 10 | are met: 11 | 12 | Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the 17 | distribution. The names of its contributors may be used to endorse 18 | or promote products derived from this software without specific 19 | prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 32 | OF THE POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /external/README.GLUI: -------------------------------------------------------------------------------- 1 | GLUI 2.3 2 | 3 | http://glui.sourceforge.net/ 4 | 5 | Distributed under the following license: 6 | 7 | GLUI User Interface Toolkit (LGPL) 8 | Copyright (c) 1998 Paul Rademacher 9 | Feb 1998, Paul Rademacher (rademach@cs.unc.edu) 10 | Oct 2003, Nigel Stewart - GLUI Code Cleaning 11 | 12 | 13 | WWW: http://sourceforge.net/projects/glui/ 14 | Forums: http://sourceforge.net/forum/?group_id=92496 15 | 16 | This library is free software; you can redistribute it and/or 17 | modify it under the terms of the GNU Lesser General Public 18 | License as published by the Free Software Foundation; either 19 | version 2.1 of the License, or (at your option) any later version. 20 | 21 | This library is distributed in the hope that it will be useful, 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24 | Lesser General Public License for more details. 25 | 26 | You should have received a copy of the GNU Lesser General Public 27 | License along with this library; if not, write to the Free Software 28 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 29 | 30 | -------------------------------------------------------------------------------- /include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | install(DIRECTORY carve 2 | DESTINATION "${CMAKE_INSTALL_PREFIX}/include" 3 | FILES_MATCHING 4 | PATTERN "*.hpp" 5 | PATTERN "internal" EXCLUDE 6 | ) 7 | -------------------------------------------------------------------------------- /include/carve/cbrt.h: -------------------------------------------------------------------------------- 1 | // N.B. only appropriate for IEEE doubles. 2 | // Cube root implementation obtained from code with the following notice: 3 | 4 | /* @(#)s_cbrt.c 1.3 95/01/18 */ 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | * 15 | */ 16 | 17 | /* Sometimes it's necessary to define __LITTLE_ENDIAN explicitly 18 | but these catch some common cases. */ 19 | 20 | #if defined(i386) || defined(i486) || \ 21 | defined(intel) || defined(x86) || defined(i86pc) || \ 22 | defined(__alpha) || defined(__osf__) 23 | #define __LITTLE_ENDIAN 24 | #endif 25 | 26 | #ifdef __LITTLE_ENDIAN 27 | #define __HI(x) *(1+(int*)&x) 28 | #define __LO(x) *(int*)&x 29 | #define __HIp(x) *(1+(int*)x) 30 | #define __LOp(x) *(int*)x 31 | #else 32 | #define __HI(x) *(int*)&x 33 | #define __LO(x) *(1+(int*)&x) 34 | #define __HIp(x) *(int*)x 35 | #define __LOp(x) *(1+(int*)x) 36 | #endif 37 | 38 | /* cbrt(x) 39 | * Return cube root of x 40 | */ 41 | 42 | inline double cbrt(double x) { 43 | 44 | static const unsigned 45 | B1 = 715094163, /* B1 = (682-0.03306235651)*2**20 */ 46 | B2 = 696219795; /* B2 = (664-0.03306235651)*2**20 */ 47 | static const double 48 | C = 5.42857142857142815906e-01, /* 19/35 = 0x3FE15F15, 0xF15F15F1 */ 49 | D = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */ 50 | E = 1.41428571428571436819e+00, /* 99/70 = 0x3FF6A0EA, 0x0EA0EA0F */ 51 | F = 1.60714285714285720630e+00, /* 45/28 = 0x3FF9B6DB, 0x6DB6DB6E */ 52 | G = 3.57142857142857150787e-01; /* 5/14 = 0x3FD6DB6D, 0xB6DB6DB7 */ 53 | 54 | int hx; 55 | double r,s,t=0.0,w; 56 | unsigned sign; 57 | 58 | hx = __HI(x); /* high word of x */ 59 | sign=hx&0x80000000; /* sign= sign(x) */ 60 | hx ^=sign; 61 | if(hx>=0x7ff00000) return(x+x); /* cbrt(NaN,INF) is itself */ 62 | if((hx|__LO(x))==0) 63 | return(x); /* cbrt(0) is itself */ 64 | 65 | __HI(x) = hx; /* x <- |x| */ 66 | /* rough cbrt to 5 bits */ 67 | if(hx<0x00100000) /* subnormal number */ 68 | {__HI(t)=0x43500000; /* set t= 2**54 */ 69 | t*=x; __HI(t)=__HI(t)/3+B2; 70 | } 71 | else 72 | __HI(t)=hx/3+B1; 73 | 74 | 75 | /* new cbrt to 23 bits, may be implemented in single precision */ 76 | r=t*t/x; 77 | s=C+r*t; 78 | t*=G+F/(s+E+D/s); 79 | 80 | /* chopped to 20 bits and make it larger than cbrt(x) */ 81 | __LO(t)=0; __HI(t)+=0x00000001; 82 | 83 | /* one step newton iteration to 53 bits with error less than 0.667 ulps */ 84 | s=t*t; /* t*t is exact */ 85 | r=x/s; 86 | w=t+t; 87 | r=(r-t)/(w+r); /* r-s is exact */ 88 | t=t+t*r; 89 | 90 | /* retore the sign bit */ 91 | __HI(t) |= sign; 92 | return(t); 93 | } 94 | -------------------------------------------------------------------------------- /include/carve/cmake-config.h.in: -------------------------------------------------------------------------------- 1 | #define CARVE_VERSION "@CARVE_VERSION@" 2 | 3 | #cmakedefine CARVE_DEBUG 4 | #cmakedefine CARVE_DEBUG_WRITE_PLY_DATA 5 | 6 | #cmakedefine CARVE_USE_EXACT_PREDICATES 7 | -------------------------------------------------------------------------------- /include/carve/collection.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | namespace carve { 28 | 29 | template 30 | class set_insert_iterator 31 | : public std::iterator { 32 | protected: 33 | set_t* set; 34 | 35 | public: 36 | set_insert_iterator(set_t& s) : set(&s) {} 37 | 38 | set_insert_iterator& operator=(typename set_t::const_reference value) { 39 | set->insert(value); 40 | return *this; 41 | } 42 | 43 | set_insert_iterator& operator*() { return *this; } 44 | set_insert_iterator& operator++() { return *this; } 45 | set_insert_iterator& operator++(int) { return *this; } 46 | }; 47 | 48 | template 49 | inline set_insert_iterator set_inserter(set_t& s) { 50 | return set_insert_iterator(s); 51 | } 52 | } // namespace carve 53 | -------------------------------------------------------------------------------- /include/carve/collection_types.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 3 | // 4 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 5 | // 6 | // Permission is hereby granted, free of charge, to any person 7 | // obtaining a copy of this software and associated documentation 8 | // files (the "Software"), to deal in the Software without 9 | // restriction, including without limitation the rights to use, copy, 10 | // modify, merge, publish, distribute, sublicense, and/or sell copies 11 | // of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be 15 | // included in all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | #pragma once 27 | 28 | #include 29 | 30 | #include 31 | 32 | namespace carve { 33 | namespace csg { 34 | 35 | typedef std::pair::vertex_t*, 36 | carve::mesh::MeshSet<3>::vertex_t*> 37 | V2; 38 | 39 | typedef std::pair::face_t*, 40 | carve::mesh::MeshSet<3>::face_t*> 41 | F2; 42 | 43 | static inline V2 ordered_edge(carve::mesh::MeshSet<3>::vertex_t* a, 44 | carve::mesh::MeshSet<3>::vertex_t* b) { 45 | return V2(std::min(a, b), std::max(a, b)); 46 | } 47 | 48 | static inline V2 flip(const V2& v) { 49 | return V2(v.second, v.first); 50 | } 51 | 52 | // include/carve/csg.hpp include/carve/faceloop.hpp 53 | // lib/intersect.cpp lib/intersect_classify_common_impl.hpp 54 | // lib/intersect_classify_edge.cpp 55 | // lib/intersect_classify_group.cpp 56 | // lib/intersect_classify_simple.cpp 57 | // lib/intersect_face_division.cpp lib/intersect_group.cpp 58 | // lib/intersect_half_classify_group.cpp 59 | typedef std::unordered_set V2Set; 60 | 61 | // include/carve/csg.hpp include/carve/polyhedron_decl.hpp 62 | // lib/csg_collector.cpp lib/intersect.cpp 63 | // lib/intersect_common.hpp lib/intersect_face_division.cpp 64 | // lib/polyhedron.cpp 65 | typedef std::unordered_map::vertex_t*, 66 | carve::mesh::MeshSet<3>::vertex_t*> 67 | VVMap; 68 | } // namespace csg 69 | } // namespace carve 70 | -------------------------------------------------------------------------------- /include/carve/colour.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | namespace carve { 31 | namespace colour { 32 | static inline void HSV2RGB(float H, float S, float V, float& r, float& g, 33 | float& b) { 34 | H = 6.0f * H; 35 | if (S < 5.0e-6) { 36 | r = g = b = V; 37 | return; 38 | } else { 39 | int i = (int)H; 40 | float f = H - i; 41 | float p1 = V * (1.0f - S); 42 | float p2 = V * (1.0f - S * f); 43 | float p3 = V * (1.0f - S * (1.0f - f)); 44 | switch (i) { 45 | case 0: 46 | r = V; 47 | g = p3; 48 | b = p1; 49 | return; 50 | case 1: 51 | r = p2; 52 | g = V; 53 | b = p1; 54 | return; 55 | case 2: 56 | r = p1; 57 | g = V; 58 | b = p3; 59 | return; 60 | case 3: 61 | r = p1; 62 | g = p2; 63 | b = V; 64 | return; 65 | case 4: 66 | r = p3; 67 | g = p1; 68 | b = V; 69 | return; 70 | case 5: 71 | r = V; 72 | g = p1; 73 | b = p2; 74 | return; 75 | } 76 | } 77 | r = g = b = 0.0; 78 | } 79 | } // namespace colour 80 | } // namespace carve 81 | -------------------------------------------------------------------------------- /include/carve/config.h.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /include/carve/convex_hull.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #include 34 | 35 | namespace carve { 36 | namespace geom { 37 | std::vector convexHull(const std::vector& points); 38 | 39 | template 40 | std::vector convexHull(const project_t& project, 41 | const polygon_container_t& points) { 42 | std::vector proj; 43 | proj.reserve(points.size()); 44 | for (typename polygon_container_t::const_iterator i = points.begin(); 45 | i != points.end(); ++i) { 46 | proj.push_back(project(*i)); 47 | } 48 | return convexHull(proj); 49 | } 50 | 51 | template 52 | std::vector convexHull(const project_t& project, iter_t beg, iter_t end, 53 | size_t size_hint = 0) { 54 | std::vector proj; 55 | if (size_hint) { 56 | proj.reserve(size_hint); 57 | } 58 | for (; beg != end; ++beg) { 59 | proj.push_back(project(*beg)); 60 | } 61 | return convexHull(proj); 62 | } 63 | } // namespace geom 64 | } // namespace carve 65 | -------------------------------------------------------------------------------- /include/carve/edge_decl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | namespace carve { 36 | namespace poly { 37 | 38 | struct Object; 39 | 40 | template 41 | class Vertex; 42 | 43 | template 44 | class Edge : public tagable { 45 | public: 46 | typedef Vertex vertex_t; 47 | typedef typename Vertex::vector_t vector_t; 48 | typedef Object obj_t; 49 | 50 | const vertex_t *v1, *v2; 51 | const obj_t* owner; 52 | 53 | Edge(const vertex_t* _v1, const vertex_t* _v2, const obj_t* _owner) 54 | : tagable(), v1(_v1), v2(_v2), owner(_owner) {} 55 | 56 | ~Edge() {} 57 | }; 58 | 59 | struct hash_edge_ptr { 60 | template 61 | size_t operator()(const Edge* const& e) const { 62 | return (size_t)e; 63 | } 64 | }; 65 | } // namespace poly 66 | } // namespace carve 67 | -------------------------------------------------------------------------------- /include/carve/edge_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | namespace carve { 28 | namespace poly {} 29 | } 30 | -------------------------------------------------------------------------------- /include/carve/math.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | 31 | #include 32 | 33 | namespace carve { 34 | namespace geom { 35 | template 36 | struct vector; 37 | } 38 | } 39 | 40 | namespace carve { 41 | namespace math { 42 | struct Matrix3; 43 | int cubic_roots(double c3, double c2, double c1, double c0, double* roots); 44 | 45 | void eigSolveSymmetric(const Matrix3& m, double& l1, carve::geom::vector<3>& e1, 46 | double& l2, carve::geom::vector<3>& e2, double& l3, 47 | carve::geom::vector<3>& e3); 48 | 49 | void eigSolve(const Matrix3& m, double& l1, double& l2, double& l3); 50 | 51 | static inline bool ZERO(double x) { 52 | return fabs(x) < carve::EPSILON; 53 | } 54 | 55 | static inline double radians(double deg) { 56 | return deg * M_PI / 180.0; 57 | } 58 | static inline double degrees(double rad) { 59 | return rad * 180.0 / M_PI; 60 | } 61 | 62 | static inline double ANG(double x) { 63 | return (x < 0) ? x + M_TWOPI : x; 64 | } 65 | 66 | template 67 | static inline const T& clamp(const T& val, const T& min, const T& max) { 68 | if (val < min) { 69 | return min; 70 | } 71 | if (val > max) { 72 | return max; 73 | } 74 | return val; 75 | } 76 | } // namespace math 77 | } // namespace carve 78 | -------------------------------------------------------------------------------- /include/carve/math_constants.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #ifndef M_SQRT_3 30 | #define M_SQRT_3 1.73205080756887729352 31 | #endif 32 | 33 | #ifndef M_PI 34 | #define M_PI 3.14159265358979323846 35 | #endif 36 | 37 | #ifndef M_TWOPI 38 | #define M_TWOPI (M_PI + M_PI) 39 | #endif 40 | -------------------------------------------------------------------------------- /include/carve/pointset.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | -------------------------------------------------------------------------------- /include/carve/pointset_decl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | namespace carve { 40 | namespace point { 41 | 42 | struct Vertex : public tagable { 43 | carve::geom3d::Vector v; 44 | }; 45 | 46 | struct vec_adapt_vertex_ptr { 47 | const carve::geom3d::Vector& operator()(const Vertex* const& v) { 48 | return v->v; 49 | } 50 | carve::geom3d::Vector& operator()(Vertex*& v) { return v->v; } 51 | }; 52 | 53 | struct PointSet { 54 | std::vector vertices; 55 | carve::geom3d::AABB aabb; 56 | 57 | PointSet(const std::vector& points); 58 | PointSet() {} 59 | 60 | void sortVertices(const carve::geom3d::Vector& axis); 61 | 62 | size_t vertexToIndex_fast(const Vertex* v) const; 63 | }; 64 | } // namespace point 65 | } // namespace carve 66 | -------------------------------------------------------------------------------- /include/carve/pointset_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | namespace carve { 37 | namespace point { 38 | 39 | inline size_t PointSet::vertexToIndex_fast(const Vertex* v) const { 40 | return (size_t)(v - &vertices[0]); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /include/carve/pointset_iter.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | -------------------------------------------------------------------------------- /include/carve/poly.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | 31 | #include 32 | -------------------------------------------------------------------------------- /include/carve/poly_decl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | -------------------------------------------------------------------------------- /include/carve/poly_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | -------------------------------------------------------------------------------- /include/carve/polyline.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | -------------------------------------------------------------------------------- /include/carve/shewchuk_predicates.hpp: -------------------------------------------------------------------------------- 1 | 2 | namespace shewchuk { 3 | double orient2dfast(const double* pa, const double* pb, const double* pc); 4 | double orient2dexact(const double* pa, const double* pb, const double* pc); 5 | double orient2dslow(const double* pa, const double* pb, const double* pc); 6 | double orient2dadapt(const double* pa, const double* pb, const double* pc, 7 | double detsum); 8 | double orient2d(const double* pa, const double* pb, const double* pc); 9 | 10 | double orient3dfast(const double* pa, const double* pb, const double* pc, 11 | const double* pd); 12 | double orient3dexact(const double* pa, const double* pb, const double* pc, 13 | const double* pd); 14 | double orient3dslow(const double* pa, const double* pb, const double* pc, 15 | const double* pd); 16 | double orient3dadapt(const double* pa, const double* pb, const double* pc, 17 | const double* pd, double permanent); 18 | double orient3d(const double* pa, const double* pb, const double* pc, 19 | const double* pd); 20 | 21 | double incirclefast(const double* pa, const double* pb, const double* pc, 22 | const double* pd); 23 | double incircleexact(const double* pa, const double* pb, const double* pc, 24 | const double* pd); 25 | double incircleslow(const double* pa, const double* pb, const double* pc, 26 | const double* pd); 27 | double incircleadapt(const double* pa, const double* pb, const double* pc, 28 | const double* pd, double permanent); 29 | double incircle(const double* pa, const double* pb, const double* pc, 30 | const double* pd); 31 | 32 | double inspherefast(const double* pa, const double* pb, const double* pc, 33 | const double* pd, const double* pe); 34 | double insphereexact(const double* pa, const double* pb, const double* pc, 35 | const double* pd, const double* pe); 36 | double insphereslow(const double* pa, const double* pb, const double* pc, 37 | const double* pd, const double* pe); 38 | double insphereadapt(const double* pa, const double* pb, const double* pc, 39 | const double* pd, const double* pe, double permanent); 40 | double insphere(const double* pa, const double* pb, const double* pc, 41 | const double* pd, const double* pe); 42 | } // namespace shewchuk 43 | -------------------------------------------------------------------------------- /include/carve/tag.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | namespace carve { 30 | 31 | class tagable { 32 | private: 33 | static int s_count; 34 | 35 | protected: 36 | mutable int __tag; 37 | 38 | public: 39 | tagable(const tagable&) : __tag(s_count - 1) {} 40 | tagable& operator=(const tagable&) { return *this; } 41 | 42 | tagable() : __tag(s_count - 1) {} 43 | 44 | void tag() const { __tag = s_count; } 45 | void untag() const { __tag = s_count - 1; } 46 | bool is_tagged() const { return __tag == s_count; } 47 | bool tag_once() const { 48 | if (__tag == s_count) { 49 | return false; 50 | } 51 | __tag = s_count; 52 | return true; 53 | } 54 | 55 | static void tag_begin() { s_count++; } 56 | }; 57 | } // namespace carve 58 | -------------------------------------------------------------------------------- /include/carve/triangle_intersection.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include 30 | 31 | namespace carve { 32 | namespace geom { 33 | 34 | enum TriangleIntType { TR_TYPE_NONE = 0, TR_TYPE_TOUCH = 1, TR_TYPE_INT = 2 }; 35 | 36 | enum TriangleInt { 37 | TR_INT_NONE = 0, // no intersection. 38 | TR_INT_INT = 1, // intersection. 39 | TR_INT_VERT = 2, // intersection due to shared vertex. 40 | TR_INT_EDGE = 3, // intersection due to shared edge. 41 | TR_INT_TRI = 4 // intersection due to identical triangle. 42 | }; 43 | 44 | TriangleInt triangle_intersection(const vector<2> tri_a[3], 45 | const vector<2> tri_b[3]); 46 | TriangleInt triangle_intersection(const vector<3> tri_a[3], 47 | const vector<3> tri_b[3]); 48 | 49 | bool triangle_intersection_simple(const vector<2> tri_a[3], 50 | const vector<2> tri_b[3]); 51 | bool triangle_intersection_simple(const vector<3> tri_a[3], 52 | const vector<3> tri_b[3]); 53 | 54 | TriangleIntType triangle_intersection_exact(const vector<2> tri_a[3], 55 | const vector<2> tri_b[3]); 56 | TriangleIntType triangle_intersection_exact(const vector<3> tri_a[3], 57 | const vector<3> tri_b[3]); 58 | 59 | TriangleIntType triangle_linesegment_intersection_exact( 60 | const vector<2> tri_a[3], const vector<2> line_b[2]); 61 | TriangleIntType triangle_point_intersection_exact(const vector<2> tri_a[3], 62 | const vector<2>& pt_b); 63 | } // namespace geom 64 | } // namespace carve 65 | -------------------------------------------------------------------------------- /include/carve/util.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | namespace carve { 28 | namespace util { 29 | struct min_functor { 30 | template 31 | const T& operator()(const T& a, const T& b) const { 32 | return std::min(a, b); 33 | } 34 | }; 35 | struct max_functor { 36 | template 37 | const T& operator()(const T& a, const T& b) const { 38 | return std::max(a, b); 39 | } 40 | }; 41 | } // namespace util 42 | } // namespace carve 43 | -------------------------------------------------------------------------------- /include/carve/vcpp_config.h: -------------------------------------------------------------------------------- 1 | /* include/carve/config.h. Generated from config.h.in by configure. */ 2 | #pragma once 3 | 4 | #include 5 | 6 | #if defined(_MSC_VER) 7 | #pragma warning(disable : 4201) 8 | #endif 9 | 10 | #include 11 | 12 | static inline double round(double value) { 13 | return (value >= 0) ? floor(value + 0.5) : ceil(value - 0.5); 14 | } 15 | -------------------------------------------------------------------------------- /include/carve/vertex_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | namespace carve { 28 | namespace poly {} 29 | } 30 | -------------------------------------------------------------------------------- /include/carve/win32.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Tobias Sargeant (toby@permuted.net) 2 | // All rights reserved. 3 | #pragma once 4 | 5 | #pragma warning (disable : 4996) 6 | #pragma warning (disable : 4786) 7 | 8 | #include 9 | #include 10 | 11 | inline int strcasecmp(const char *a, const char *b) { 12 | return _stricmp(a,b); 13 | } 14 | 15 | inline void srandom(unsigned long input) { 16 | srand(input); 17 | } 18 | 19 | inline long random() { 20 | return rand(); 21 | } 22 | 23 | #if defined(_MSC_VER) 24 | # include 25 | 26 | #if _MSC_VER < 1300 27 | // intptr_t is an integer type that is big enough to hold a pointer 28 | // It is not defined in VC6 so include a definition here for the older compiler 29 | typedef long intptr_t; 30 | typedef unsigned long uintptr_t; 31 | #endif 32 | 33 | # if _MSC_VER < 1600 34 | // stdint.h is not available before VS2010 35 | typedef char int8_t; 36 | typedef short int16_t; 37 | typedef long int32_t; 38 | 39 | typedef unsigned char uint8_t; 40 | typedef unsigned short uint16_t; 41 | typedef unsigned long uint32_t; 42 | 43 | typedef __int64 int64_t; 44 | typedef unsigned __int64 uint64_t; 45 | # else 46 | # include 47 | # endif 48 | #endif 49 | -------------------------------------------------------------------------------- /include/carve/xcode_config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Choose one of the following four options. 4 | 5 | // Other options. 6 | 7 | // Define to include debugging output in carve. 8 | // #define CARVE_DEBUG 9 | 10 | // Write intermediate debugging info in .ply format. 11 | // #define CARVE_DEBUG_WRITE_PLY_DATA 12 | 13 | // Define to make carve use exact predicates where available. 14 | // #cmakedefine CARVE_USE_EXACT_PREDICATES 15 | -------------------------------------------------------------------------------- /lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories("${carve_SOURCE_DIR}/include") 2 | 3 | add_library(carve 4 | aabb.cpp 5 | carve.cpp 6 | convex_hull.cpp 7 | csg.cpp 8 | csg_collector.cpp 9 | edge.cpp 10 | face.cpp 11 | geom.cpp 12 | geom2d.cpp 13 | geom3d.cpp 14 | intersect.cpp 15 | intersect_classify_edge.cpp 16 | intersect_classify_group.cpp 17 | intersect_debug.cpp 18 | intersect_face_division.cpp 19 | intersect_group.cpp 20 | intersect_half_classify_group.cpp 21 | intersection.cpp 22 | math.cpp 23 | mesh.cpp 24 | octree.cpp 25 | pointset.cpp 26 | polyhedron.cpp 27 | polyline.cpp 28 | tag.cpp 29 | timing.cpp 30 | triangulator.cpp 31 | triangle_intersection.cpp 32 | shewchuk_predicates.cpp) 33 | 34 | set_target_properties(carve PROPERTIES 35 | VERSION "${carve_VERSION_MAJOR}.${carve_VERSION_MINOR}.${carve_VERSION_PATCH}" 36 | SOVERSION "${carve_VERSION_MAJOR}.${carve_VERSION_MINOR}") 37 | 38 | install(TARGETS carve 39 | LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" 40 | ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") 41 | -------------------------------------------------------------------------------- /lib/aabb.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(HAVE_CONFIG_H) 26 | #include 27 | #endif 28 | 29 | #include 30 | #include 31 | 32 | namespace carve { 33 | namespace geom3d {} 34 | } 35 | -------------------------------------------------------------------------------- /lib/carve.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(HAVE_CONFIG_H) 26 | #include 27 | #endif 28 | 29 | #include 30 | 31 | #define DEF_EPSILON 1.4901161193847656e-08 32 | 33 | namespace carve { 34 | double EPSILON = DEF_EPSILON; 35 | double EPSILON2 = DEF_EPSILON * DEF_EPSILON; 36 | } 37 | -------------------------------------------------------------------------------- /lib/csg_collector.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | namespace carve { 26 | namespace csg { 27 | CSG::Collector* makeCollector(CSG::OP op, const carve::mesh::MeshSet<3>* poly_a, 28 | const carve::mesh::MeshSet<3>* poly_b); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/csg_data.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include "csg_detail.hpp" 30 | 31 | struct carve::csg::detail::Data { 32 | // * @param[out] vmap A mapping from vertex pointer to intersection 33 | // point. 34 | // * @param[out] emap A mapping from edge pointer to intersection 35 | // points. 36 | // * @param[out] fmap A mapping from face pointer to intersection 37 | // points. 38 | // * @param[out] fmap_rev A mapping from intersection points to face 39 | // pointers. 40 | // map from intersected vertex to intersection point. 41 | VVMap vmap; 42 | 43 | // map from intersected edge to intersection points. 44 | EIntMap emap; 45 | 46 | // map from intersected face to intersection points. 47 | FVSMap fmap; 48 | 49 | // map from intersection point to intersected faces. 50 | VFSMap fmap_rev; 51 | 52 | // created by divideEdges(). 53 | // holds, for each edge, an ordered vector of inserted vertices. 54 | EVVMap divided_edges; 55 | 56 | // created by faceSplitEdges. 57 | FV2SMap face_split_edges; 58 | 59 | // mapping from vertex to edge for potentially intersected 60 | // faces. Saves building the vertex to edge map for all faces of 61 | // both meshes. 62 | VEVecMap vert_to_edges; 63 | }; 64 | -------------------------------------------------------------------------------- /lib/edge.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(HAVE_CONFIG_H) 26 | #include 27 | #endif 28 | 29 | #include 30 | -------------------------------------------------------------------------------- /lib/intersect_classify_common.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #pragma once 26 | 27 | #include "intersect_common.hpp" 28 | 29 | template 30 | static int is_same(const std::vector& a, const std::vector& b) { 31 | if (a.size() != b.size()) { 32 | return false; 33 | } 34 | 35 | const size_t S = a.size(); 36 | size_t i, j, p; 37 | 38 | for (p = 0; p < S; ++p) { 39 | if (a[0] == b[p]) { 40 | break; 41 | } 42 | } 43 | if (p == S) { 44 | return 0; 45 | } 46 | 47 | for (i = 1, j = p + 1; j < S; ++i, ++j) { 48 | if (a[i] != b[j]) { 49 | goto not_fwd; 50 | } 51 | } 52 | for (j = 0; i < S; ++i, ++j) { 53 | if (a[i] != b[j]) { 54 | goto not_fwd; 55 | } 56 | } 57 | return +1; 58 | 59 | not_fwd: 60 | for (i = 1, j = p - 1; j != (size_t)-1; ++i, --j) { 61 | if (a[i] != b[j]) { 62 | goto not_rev; 63 | } 64 | } 65 | for (j = S - 1; i < S; ++i, --j) { 66 | if (a[i] != b[j]) { 67 | goto not_rev; 68 | } 69 | } 70 | return -1; 71 | 72 | not_rev: 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /lib/intersect_debug.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(HAVE_CONFIG_H) 26 | #include 27 | #endif 28 | 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | #include "intersect_debug.hpp" 38 | 39 | namespace carve { 40 | namespace csg { 41 | 42 | #if defined(CARVE_DEBUG) 43 | 44 | #define DEBUG_DRAW_FACE_EDGES 45 | #define DEBUG_DRAW_INTERSECTIONS 46 | // #define DEBUG_DRAW_OCTREE 47 | #define DEBUG_DRAW_INTERSECTION_LINE 48 | // #define DEBUG_DRAW_GROUPS 49 | // #define DEBUG_PRINT_RESULT_FACES 50 | 51 | IntersectDebugHooks* g_debug = NULL; 52 | 53 | IntersectDebugHooks* intersect_installDebugHooks(IntersectDebugHooks* hooks) { 54 | IntersectDebugHooks* h = g_debug; 55 | g_debug = hooks; 56 | return h; 57 | } 58 | 59 | bool intersect_debugEnabled() { 60 | return true; 61 | } 62 | 63 | #else 64 | 65 | IntersectDebugHooks* intersect_installDebugHooks( 66 | IntersectDebugHooks* /* hooks */) { 67 | return nullptr; 68 | } 69 | 70 | bool intersect_debugEnabled() { 71 | return false; 72 | } 73 | 74 | #endif 75 | } // namespace csg 76 | } // namespace carve 77 | -------------------------------------------------------------------------------- /lib/intersect_debug.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #include 26 | 27 | #if defined(CARVE_DEBUG) 28 | 29 | #define DEBUG_DRAW_FACE_EDGES 30 | #define DEBUG_DRAW_INTERSECTIONS 31 | // #define DEBUG_DRAW_OCTREE 32 | #define DEBUG_DRAW_INTERSECTION_LINE 33 | // #define DEBUG_DRAW_GROUPS 34 | // #define DEBUG_PRINT_RESULT_FACES 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /lib/pointset.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(HAVE_CONFIG_H) 26 | #include 27 | #endif 28 | 29 | #include 30 | #include 31 | 32 | namespace carve { 33 | namespace point { 34 | 35 | PointSet::PointSet(const std::vector& points) { 36 | vertices.resize(points.size()); 37 | for (size_t i = 0; i < points.size(); ++i) { 38 | vertices[i].v = points[i]; 39 | } 40 | aabb.fit(points.begin(), points.end()); 41 | } 42 | 43 | void PointSet::sortVertices(const carve::geom3d::Vector& axis) { 44 | std::vector > temp; 45 | temp.reserve(vertices.size()); 46 | for (size_t i = 0; i < vertices.size(); ++i) { 47 | temp.push_back(std::make_pair(dot(axis, vertices[i].v), i)); 48 | } 49 | std::sort(temp.begin(), temp.end()); 50 | 51 | std::vector vnew; 52 | vnew.reserve(vertices.size()); 53 | 54 | // std::vector revmap; 55 | // revmap.resize(vertices.size()); 56 | 57 | for (size_t i = 0; i < vertices.size(); ++i) { 58 | vnew.push_back(vertices[temp[i].second]); 59 | // revmap[temp[i].second] = i; 60 | } 61 | 62 | vertices.swap(vnew); 63 | } 64 | } // namespace point 65 | } // namespace carve 66 | -------------------------------------------------------------------------------- /lib/polyline.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(HAVE_CONFIG_H) 26 | #include 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | namespace carve { 34 | namespace line { 35 | carve::geom3d::AABB Polyline::aabb() const { 36 | return carve::geom3d::AABB(vbegin(), vend(), vec_adapt_vertex_ptr()); 37 | } 38 | 39 | PolylineSet::PolylineSet(const std::vector& points) { 40 | vertices.resize(points.size()); 41 | for (size_t i = 0; i < points.size(); ++i) { 42 | vertices[i].v = points[i]; 43 | } 44 | aabb.fit(points.begin(), points.end(), carve::geom3d::vec_adapt_ident()); 45 | } 46 | 47 | void PolylineSet::sortVertices(const carve::geom3d::Vector& axis) { 48 | std::vector > temp; 49 | temp.reserve(vertices.size()); 50 | for (size_t i = 0; i < vertices.size(); ++i) { 51 | temp.push_back(std::make_pair(dot(axis, vertices[i].v), i)); 52 | } 53 | std::sort(temp.begin(), temp.end()); 54 | std::vector vnew; 55 | std::vector revmap; 56 | vnew.reserve(vertices.size()); 57 | revmap.resize(vertices.size()); 58 | 59 | for (size_t i = 0; i < vertices.size(); ++i) { 60 | vnew.push_back(vertices[temp[i].second]); 61 | revmap[temp[i].second] = i; 62 | } 63 | 64 | for (line_iter i = lines.begin(); i != lines.end(); ++i) { 65 | Polyline& l = *(*i); 66 | for (size_t j = 0; j < l.edges.size(); ++j) { 67 | PolylineEdge& e = *l.edges[j]; 68 | if (e.v1) { 69 | e.v1 = &vnew[revmap[vertexToIndex_fast(e.v1)]]; 70 | } 71 | if (e.v2) { 72 | e.v2 = &vnew[revmap[vertexToIndex_fast(e.v2)]]; 73 | } 74 | } 75 | } 76 | vertices.swap(vnew); 77 | } 78 | } // namespace line 79 | } // namespace carve 80 | -------------------------------------------------------------------------------- /lib/tag.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(HAVE_CONFIG_H) 26 | #include 27 | #endif 28 | 29 | #include 30 | 31 | int carve::tagable::s_count = 0; 32 | -------------------------------------------------------------------------------- /regression/compare_runs.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import sre 4 | 5 | from sets import Set 6 | 7 | output = sre.compile(r"test_(.*).out") 8 | 9 | RUN_1_DIR = sys.argv[1] 10 | RUN_2_DIR = sys.argv[2] 11 | 12 | run_1_files = os.listdir(RUN_1_DIR) 13 | run_2_files = os.listdir(RUN_2_DIR) 14 | 15 | tests_1 = [] 16 | tests_2 = [] 17 | 18 | for _ in run_1_files: 19 | m = output.match(_) 20 | if m is None: continue 21 | tests_1.append(m.group(1)) 22 | 23 | for _ in run_2_files: 24 | m = output.match(_) 25 | if m is None: continue 26 | tests_2.append(m.group(1)) 27 | 28 | tests = Set(tests_1) & Set(tests_2) 29 | 30 | print len(tests), 'common tests' 31 | 32 | def parseLog(log): 33 | try: 34 | timings_idx = log.index('Timings: ') 35 | totals_idx = log.index('Totals: ') 36 | except ValueError: 37 | return {}, None 38 | timings = log[timings_idx+1:totals_idx-1] 39 | totals = log[totals_idx+1:-2] 40 | tot = {} 41 | # mem = timings[1].split() 42 | # mem = (float(mem[-5].replace(',','')), float(mem[-2].replace(',',''))) 43 | mem = None 44 | for line in totals: 45 | line = line.strip() 46 | ident, t = line.rsplit(' - ', 1) 47 | ident = ident.strip() 48 | t = float(t[:-1]) 49 | tot[ident] = t 50 | return tot, mem 51 | 52 | def PCT(b, a, k): 53 | if k not in a or k not in b: return '********' 54 | return '%+6.2f%%' % ((float(b[k]) - float(a[k])) * 100.0 / float(a[k]),) 55 | 56 | def compareStats(a, b): 57 | print ' Exec time: %s' % (PCT(b, a, 'Application')), 58 | print ' Parse time: %s' % (PCT(b, a, 'Parse')), 59 | print ' Eval time: %s' % (PCT(b, a, 'Eval')), 60 | 61 | def compareMem(a, b): 62 | if a is not None and b is not None: 63 | print ' Mem usage: %+6.2f%%' % (PCT(b[0], a[0]),), 64 | print ' Mem delta: %+6.2f%%' % (PCT(b[1], a[1]),), 65 | 66 | def compare(test, a, b): 67 | print 'test: %-30s' % (test,), 68 | if a[0] == b[0]: 69 | print ' OK', 70 | else: 71 | print 'DIFFER', 72 | 73 | a_log = a[1].split('\n') 74 | a_stats = parseLog(a_log) 75 | 76 | b_log = b[1].split('\n') 77 | b_stats = parseLog(b_log) 78 | 79 | compareStats(a_stats[0], b_stats[0]) 80 | compareMem(a_stats[1], b_stats[1]) 81 | print 82 | 83 | for test in tests: 84 | a_out = os.path.join(RUN_1_DIR, 'test_%s.out' % (test,)) 85 | a_err = os.path.join(RUN_1_DIR, 'test_%s.err' % (test,)) 86 | 87 | b_out = os.path.join(RUN_2_DIR, 'test_%s.out' % (test,)) 88 | b_err = os.path.join(RUN_2_DIR, 'test_%s.err' % (test,)) 89 | 90 | compare(test, (open(a_out).read(), open(a_err).read()), (open(b_out).read(), open(b_err).read())) 91 | -------------------------------------------------------------------------------- /regression/test-spheres-1: -------------------------------------------------------------------------------- 1 | ( 2 | ../data/ico.ply UNION 3 | TRANS(+1.8,+1.8,+1.8,../data/ico.ply) UNION 4 | TRANS(+1.8,+1.8,-1.8,../data/ico.ply) UNION 5 | TRANS(+1.8,-1.8,+1.8,../data/ico.ply) UNION 6 | TRANS(+1.8,-1.8,-1.8,../data/ico.ply) UNION 7 | TRANS(-1.8,+1.8,+1.8,../data/ico.ply) UNION 8 | TRANS(-1.8,+1.8,-1.8,../data/ico.ply) UNION 9 | TRANS(-1.8,-1.8,+1.8,../data/ico.ply) UNION 10 | TRANS(-1.8,-1.8,-1.8,../data/ico.ply) 11 | ) A_MINUS_B 12 | ROT(1,1,1,1,( 13 | TRANS(+1.2,+1.2,+1.2,../data/ico.ply) UNION 14 | TRANS(+1.2,+1.2,-1.2,../data/ico.ply) UNION 15 | TRANS(+1.2,-1.2,+1.2,../data/ico.ply) UNION 16 | TRANS(+1.2,-1.2,-1.2,../data/ico.ply) UNION 17 | TRANS(-1.2,+1.2,+1.2,../data/ico.ply) UNION 18 | TRANS(-1.2,+1.2,-1.2,../data/ico.ply) UNION 19 | TRANS(-1.2,-1.2,+1.2,../data/ico.ply) UNION 20 | TRANS(-1.2,-1.2,-1.2,../data/ico.ply)) 21 | ) 22 | -------------------------------------------------------------------------------- /regression/test-spheres-2: -------------------------------------------------------------------------------- 1 | ( 2 | ../data/ico5.ply UNION 3 | TRANS(+1.8,+1.8,+1.8,../data/ico5.ply) UNION 4 | TRANS(+1.8,+1.8,-1.8,../data/ico5.ply) UNION 5 | TRANS(+1.8,-1.8,+1.8,../data/ico5.ply) UNION 6 | TRANS(+1.8,-1.8,-1.8,../data/ico5.ply) UNION 7 | TRANS(-1.8,+1.8,+1.8,../data/ico5.ply) UNION 8 | TRANS(-1.8,+1.8,-1.8,../data/ico5.ply) UNION 9 | TRANS(-1.8,-1.8,+1.8,../data/ico5.ply) UNION 10 | TRANS(-1.8,-1.8,-1.8,../data/ico5.ply) 11 | ) A_MINUS_B 12 | ROT(1,1,1,1,( 13 | TRANS(+1.2,+1.2,+1.2,../data/ico5.ply) UNION 14 | TRANS(+1.2,+1.2,-1.2,../data/ico5.ply) UNION 15 | TRANS(+1.2,-1.2,+1.2,../data/ico5.ply) UNION 16 | TRANS(+1.2,-1.2,-1.2,../data/ico5.ply) UNION 17 | TRANS(-1.2,+1.2,+1.2,../data/ico5.ply) UNION 18 | TRANS(-1.2,+1.2,-1.2,../data/ico5.ply) UNION 19 | TRANS(-1.2,-1.2,+1.2,../data/ico5.ply) UNION 20 | TRANS(-1.2,-1.2,-1.2,../data/ico5.ply)) 21 | ) 22 | -------------------------------------------------------------------------------- /regression/test-spheres-3: -------------------------------------------------------------------------------- 1 | ( 2 | ../data/ico5.ply UNION 3 | TRANS(+1.4,+1.4,+1.4,../data/ico5.ply) UNION 4 | TRANS(+1.4,+1.4,-1.4,../data/ico5.ply) UNION 5 | TRANS(+1.4,-1.4,+1.4,../data/ico5.ply) UNION 6 | TRANS(+1.4,-1.4,-1.4,../data/ico5.ply) UNION 7 | TRANS(-1.4,+1.4,+1.4,../data/ico5.ply) UNION 8 | TRANS(-1.4,+1.4,-1.4,../data/ico5.ply) UNION 9 | TRANS(-1.4,-1.4,+1.4,../data/ico5.ply) UNION 10 | TRANS(-1.4,-1.4,-1.4,../data/ico5.ply) 11 | ) A_MINUS_B 12 | ROT(1,1,1,1,( 13 | TRANS(+0.8,+0.8,+0.8,../data/ico5.ply) UNION 14 | TRANS(+0.8,+0.8,-0.8,../data/ico5.ply) UNION 15 | TRANS(+0.8,-0.8,+0.8,../data/ico5.ply) UNION 16 | TRANS(+0.8,-0.8,-0.8,../data/ico5.ply) UNION 17 | TRANS(-0.8,+0.8,+0.8,../data/ico5.ply) UNION 18 | TRANS(-0.8,+0.8,-0.8,../data/ico5.ply) UNION 19 | TRANS(-0.8,-0.8,+0.8,../data/ico5.ply) UNION 20 | TRANS(-0.8,-0.8,-0.8,../data/ico5.ply)) 21 | ) 22 | -------------------------------------------------------------------------------- /regression/test-spheres-4: -------------------------------------------------------------------------------- 1 | ( 2 | (../data/ico5.ply A_MINUS_B SCALE(0.95,0.95,0.95, ../data/ico5.ply)) UNION 3 | (SCALE(0.90,0.90,0.90, ../data/ico5.ply) A_MINUS_B SCALE(0.85,0.85,0.85, ../data/ico5.ply)) UNION 4 | (SCALE(0.80,0.80,0.80, ../data/ico5.ply) A_MINUS_B SCALE(0.75,0.75,0.75, ../data/ico5.ply)) UNION 5 | (SCALE(0.70,0.70,0.70, ../data/ico5.ply) A_MINUS_B SCALE(0.65,0.65,0.65, ../data/ico5.ply)) UNION 6 | (SCALE(0.60,0.60,0.60, ../data/ico5.ply) A_MINUS_B SCALE(0.55,0.55,0.55, ../data/ico5.ply)) UNION 7 | (SCALE(0.50,0.50,0.50, ../data/ico5.ply) A_MINUS_B SCALE(0.45,0.45,0.45, ../data/ico5.ply)) UNION 8 | (SCALE(0.40,0.40,0.40, ../data/ico5.ply) A_MINUS_B SCALE(0.35,0.35,0.35, ../data/ico5.ply)) UNION 9 | (SCALE(0.30,0.30,0.30, ../data/ico5.ply) A_MINUS_B SCALE(0.25,0.25,0.25, ../data/ico5.ply)) UNION 10 | (SCALE(0.20,0.20,0.20, ../data/ico5.ply) A_MINUS_B SCALE(0.15,0.15,0.15, ../data/ico5.ply)) UNION 11 | (SCALE(0.10,0.10,0.10, ../data/ico5.ply) A_MINUS_B SCALE(0.05,0.05,0.05, ../data/ico5.ply)) 12 | ) INTERSECTION ( 13 | (CYLINDER(256,1.0,2) A_MINUS_B CYLINDER(256,0.9,2)) UNION 14 | (CYLINDER(256,0.8,2) A_MINUS_B CYLINDER(256,0.7,2)) UNION 15 | (CYLINDER(256,0.6,2) A_MINUS_B CYLINDER(256,0.5,2)) UNION 16 | (CYLINDER(256,0.4,2) A_MINUS_B CYLINDER(256,0.3,2)) UNION 17 | (CYLINDER(256,0.2,2) A_MINUS_B CYLINDER(256,0.1,2)) 18 | ) 19 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories("${carve_SOURCE_DIR}/include") 2 | include_directories("${carve_SOURCE_DIR}/external/GLOOP/include") 3 | include_directories("${carve_SOURCE_DIR}/external/GLUI/include") 4 | 5 | if(GLEW_FOUND) 6 | include_directories("${GLEW_INCLUDE_DIR}") 7 | else(GLEW_FOUND) 8 | include_directories("${carve_SOURCE_DIR}/external/GLEW/include") 9 | endif(GLEW_FOUND) 10 | 11 | include_directories(${OPENGL_INCLUDE_DIR}) 12 | 13 | include_directories("${carve_SOURCE_DIR}/common") 14 | 15 | link_directories("${gloop_BINARY_DIR}") 16 | link_directories("${carve_BINARY_DIR}/common") 17 | 18 | if(CARVE_INTERSECT_GLU_TRIANGULATOR AND CARVE_WITH_GUI) 19 | add_executable (intersect glu_triangulator.cpp intersect.cpp) 20 | target_link_libraries(intersect carve_fileformats carve_misc carve gloop_model ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES}) 21 | add_executable (slice glu_triangulator.cpp slice.cpp) 22 | target_link_libraries(slice carve_fileformats carve_misc carve gloop_model ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES}) 23 | else(CARVE_INTERSECT_GLU_TRIANGULATOR AND CARVE_WITH_GUI) 24 | add_definitions(-DDISABLE_GLU_TRIANGULATOR) 25 | add_executable (intersect intersect.cpp) 26 | target_link_libraries(intersect carve_fileformats carve_misc carve gloop_model) 27 | add_executable (slice slice.cpp) 28 | target_link_libraries(slice carve_fileformats carve_misc carve gloop_model) 29 | endif(CARVE_INTERSECT_GLU_TRIANGULATOR AND CARVE_WITH_GUI) 30 | 31 | if(CARVE_WITH_GUI) 32 | add_executable (view view.cpp) 33 | target_link_libraries(view carve_fileformats carve_misc carve_ui carve gloop_model glui ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES}) 34 | install(TARGETS view RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") 35 | endif(CARVE_WITH_GUI) 36 | 37 | add_executable (face_merge face_merge.cpp) 38 | target_link_libraries(face_merge carve_fileformats carve gloop_model) 39 | 40 | add_executable (mesh_simplify mesh_simplify.cpp) 41 | target_link_libraries(mesh_simplify carve_fileformats carve gloop_model) 42 | 43 | add_executable (triangulate triangulate.cpp) 44 | target_link_libraries(triangulate carve_fileformats carve gloop_model) 45 | 46 | add_executable (cutgraph cut.cpp) 47 | target_link_libraries(cutgraph carve_fileformats carve gloop_model) 48 | 49 | add_executable (extrude extrude.cpp) 50 | target_link_libraries(extrude carve_fileformats carve gloop_model) 51 | 52 | add_executable (convert convert.cpp) 53 | target_link_libraries(convert carve_fileformats carve gloop_model) 54 | 55 | add_executable (close_manifold close_manifold.cpp) 56 | target_link_libraries(close_manifold carve_fileformats carve gloop_model) 57 | 58 | add_executable (selfintersect selfintersect.cpp) 59 | target_link_libraries(selfintersect carve_fileformats carve gloop_model) 60 | 61 | foreach(tgt slice intersect triangulate convert) 62 | install(TARGETS ${tgt} 63 | RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") 64 | endforeach(tgt) 65 | -------------------------------------------------------------------------------- /src/face_merge.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(HAVE_CONFIG_H) 26 | #include 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include "read_ply.hpp" 40 | #include "write_ply.hpp" 41 | 42 | #include "opts.hpp" 43 | 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | #include 51 | #include 52 | 53 | typedef carve::mesh::MeshSet<3> meshset_t; 54 | typedef carve::mesh::Mesh<3> mesh_t; 55 | typedef mesh_t::vertex_t vertex_t; 56 | typedef mesh_t::edge_t edge_t; 57 | typedef mesh_t::face_t face_t; 58 | 59 | int main(int argc, char** argv) { 60 | try { 61 | carve::input::Input inputs; 62 | readPLY(std::string(argv[1]), inputs); 63 | carve::mesh::MeshSet<3>* p; 64 | p = carve::input::Input::create >( 65 | *inputs.input.begin()); 66 | 67 | carve::mesh::MeshSimplifier simplifier; 68 | 69 | simplifier.mergeCoplanarFaces(p, 1e-2); 70 | // simplifier.snap(p, -5, 0, 0); 71 | 72 | writePLY(std::cout, p, true); 73 | return 0; 74 | } catch (carve::exception e) { 75 | std::cerr << "exception: " << e.str() << std::endl; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/glu_triangulator.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(__APPLE__) 26 | #include 27 | #include 28 | #else 29 | 30 | #ifdef WIN32 31 | #include 32 | #undef rad1 33 | #undef rad2 34 | #endif 35 | 36 | #include 37 | #include 38 | 39 | #endif 40 | 41 | #include 42 | 43 | class GLUTriangulator : public carve::csg::CSG::Hook { 44 | GLUtesselator* tess; 45 | GLenum curr_type; 46 | 47 | std::vector*> vertices; 48 | std::vector*> new_faces; 49 | const carve::poly::Face<3>* orig_face; 50 | 51 | public: 52 | GLUTriangulator(); 53 | ~GLUTriangulator() override; 54 | virtual void processOutputFace(std::vector*>& faces, 55 | const carve::poly::Face<3>* orig, 56 | bool flipped); 57 | 58 | void faceBegin(GLenum type); 59 | void faceVertex(const carve::poly::Vertex<3>* vertex); 60 | void faceEnd(); 61 | }; 62 | -------------------------------------------------------------------------------- /src/intersection.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/folded/carve/622ccac8871bf23a2803e15bf0018f404f705818/src/intersection.ply -------------------------------------------------------------------------------- /src/mesh_simplify.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(HAVE_CONFIG_H) 26 | #include 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | typedef carve::mesh::MeshSet<3> meshset_t; 46 | typedef carve::mesh::Mesh<3> mesh_t; 47 | typedef mesh_t::vertex_t vertex_t; 48 | typedef mesh_t::edge_t edge_t; 49 | typedef mesh_t::face_t face_t; 50 | 51 | #include "read_ply.hpp" 52 | #include "write_ply.hpp" 53 | 54 | #include "opts.hpp" 55 | 56 | int main(int argc, char** argv) { 57 | try { 58 | carve::input::Input inputs; 59 | readPLY(std::string(argv[1]), inputs); 60 | carve::mesh::MeshSet<3>* p; 61 | p = carve::input::Input::create >( 62 | *inputs.input.begin()); 63 | 64 | carve::mesh::MeshSimplifier simplifier; 65 | 66 | simplifier.removeFins(p); 67 | simplifier.removeLowVolumeManifolds(p, 1.0); 68 | 69 | // p->transform(carve::geom::quantize<10,3>()); 70 | simplifier.simplify(p, 1e-2, 1.0, M_PI / 180.0, 2e-3); 71 | // std::cerr << "n_flips: " << simplifier.improveMesh_conservative(p) << 72 | // std::endl; 73 | 74 | simplifier.removeFins(p); 75 | simplifier.removeLowVolumeManifolds(p, 1.0); 76 | 77 | writePLY(std::cout, p, true); 78 | return 0; 79 | } catch (carve::exception e) { 80 | std::cerr << "exception: " << e.str() << std::endl; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /tests/test.txt: -------------------------------------------------------------------------------- 1 | BEGIN 2 | 1 1 3 | -1 1 4 | -1 -1 5 | 1 -1 6 | BEGIN 7 | .5 .5 8 | .5 -.5 9 | -.5 -.5 10 | -.5 .5 11 | -------------------------------------------------------------------------------- /tests/test_aabb.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(HAVE_CONFIG_H) 26 | #include 27 | #endif 28 | 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | int main(int argc, char** argv) { 38 | carve::geom3d::AABB aabb(carve::geom::VECTOR(0, 0, 0), 39 | carve::geom::VECTOR(1, 1, 1)); 40 | 41 | std::ifstream in("aabb.test"); 42 | while (in.good()) { 43 | double x1, y1, z1; 44 | double x2, y2, z2; 45 | char ray_intersects[10]; 46 | char lineseg_intersects[10]; 47 | bool ri; 48 | bool li; 49 | std::string line; 50 | 51 | std::getline(in, line); 52 | sscanf(line.c_str(), "<%lf,%lf,%lf>\t<%lf,%lf,%lf>\t%s\t%s", &x1, &y1, &z1, 53 | &x2, &y2, &z2, ray_intersects, lineseg_intersects); 54 | 55 | carve::geom3d::Vector v1 = carve::geom::VECTOR(x1, y1, z1); 56 | carve::geom3d::Vector v2 = carve::geom::VECTOR(x2, y2, z2); 57 | 58 | carve::geom3d::Ray r(v2 - v1, v1); 59 | carve::geom3d::LineSegment l(v1, v2); 60 | 61 | ri = !std::strcmp(ray_intersects, "True"); 62 | li = !std::strcmp(lineseg_intersects, "True"); 63 | 64 | bool ri_t = aabb.intersects(r); 65 | bool li_t = aabb.intersectsLineSegment(l.v1, l.v2); 66 | 67 | if (li != li_t || ri != ri_t) { 68 | std::cout << line << std::endl; 69 | } 70 | 71 | if (ri != ri_t) { 72 | std::cout << "RAY: " << ri << " " << ri_t << std::endl; 73 | } 74 | if (li != li_t) { 75 | std::cout << "LINE: " << li << " " << li_t << std::endl; 76 | std::cout << "LINE MIDPOINT = " << l.midpoint.asStr() << std::endl; 77 | aabb.intersectsLineSegment(l.v1, l.v2); 78 | } 79 | if (li != li_t || ri != ri_t) { 80 | std::cout << std::endl; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /tests/test_eigen.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(HAVE_CONFIG_H) 26 | #include 27 | #endif 28 | 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | #define D(x) strtod(x, NULL) 35 | 36 | int main(int argc, char** argv) { 37 | carve::math::Matrix3 m; 38 | m._11 = D(argv[1]); 39 | m._12 = D(argv[2]); 40 | m._13 = D(argv[3]); 41 | m._21 = D(argv[2]); 42 | m._22 = D(argv[4]); 43 | m._23 = D(argv[5]); 44 | m._31 = D(argv[3]); 45 | m._32 = D(argv[5]); 46 | m._33 = D(argv[6]); 47 | 48 | double l1, l2, l3; 49 | carve::geom::vector<3> e1, e2, e3; 50 | 51 | carve::math::eigSolveSymmetric(m, l1, e1, l2, e2, l3, e3); 52 | std::cout << l1 << " " << e1 << std::endl; 53 | std::cout << l2 << " " << e2 << std::endl; 54 | std::cout << l3 << " " << e3 << std::endl; 55 | 56 | std::cout << m * e1 - l1 * e1 << " " << (m * e1 - l1 * e1).isZero() 57 | << std::endl; 58 | std::cout << m * e2 - l2 * e2 << " " << (m * e2 - l2 * e2).isZero() 59 | << std::endl; 60 | std::cout << m * e3 - l3 * e3 << " " << (m * e3 - l3 * e3).isZero() 61 | << std::endl; 62 | 63 | eigSolve(m, l1, l2, l3); 64 | 65 | std::cout << l1 << " " << e1 << std::endl; 66 | std::cout << l2 << " " << e2 << std::endl; 67 | std::cout << l3 << " " << e3 << std::endl; 68 | } 69 | -------------------------------------------------------------------------------- /tests/test_geom.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #include 26 | 27 | int main(int argc, char** argv) { 28 | carve::geom::vector<4> v; 29 | v.x = 1.0; 30 | } 31 | -------------------------------------------------------------------------------- /tests/test_rescale.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(HAVE_CONFIG_H) 26 | #include 27 | #endif 28 | 29 | #include 30 | 31 | #include "mersenne_twister.h" 32 | 33 | int main(int argc, char** argv) { 34 | MTRand rand; 35 | double sx, sy, sz; 36 | double minx, maxx, miny, maxy, minz, maxz; 37 | 38 | sx = rand.rand(1e5) + 1; 39 | sy = rand.rand(1e5) + 1; 40 | sz = rand.rand(1e5) + 1; 41 | 42 | minx = rand.rand(1e10) - sx / 2; 43 | maxx = minx + sx; 44 | miny = rand.rand(1e10) - sy / 2; 45 | maxy = miny + sy; 46 | minz = rand.rand(1e10) - sz / 2; 47 | maxz = minz + sz; 48 | 49 | if (minx > maxx) { 50 | std::swap(minx, maxx); 51 | } 52 | if (miny > maxy) { 53 | std::swap(miny, maxy); 54 | } 55 | if (minz > maxz) { 56 | std::swap(minz, maxz); 57 | } 58 | 59 | carve::rescale::rescale r(minx, miny, minz, maxx, maxy, maxz); 60 | carve::rescale::fwd fwd(r); 61 | carve::rescale::rev rev(r); 62 | 63 | std::cout << "x: [" << minx << "," << maxx << "]" << std::endl; 64 | std::cout << "y: [" << miny << "," << maxy << "]" << std::endl; 65 | std::cout << "z: [" << minz << "," << maxz << "]" << std::endl; 66 | std::cout << std::endl; 67 | std::cout << "r.dx=" << r.dx << " r.dy=" << r.dy << " r.dz=" << r.dz 68 | << " r.scale=" << r.scale << std::endl; 69 | std::cout << std::endl; 70 | 71 | for (int i = 0; i < 10000; i++) { 72 | carve::geom3d::Vector in, temp, out; 73 | in.x = rand.rand(maxx - minx) + minx; 74 | in.y = rand.rand(maxy - miny) + miny; 75 | in.z = rand.rand(maxz - minz) + minz; 76 | temp = fwd(in); 77 | out = rev(temp); 78 | std::cout << in << " -> " << temp << " -> " << out << std::endl; 79 | CARVE_ASSERT(fabs(temp.x) < 1.0 && fabs(temp.y) < 1.0 && 80 | fabs(temp.z) < 1.0); 81 | CARVE_ASSERT(out.x == in.x && out.y == in.y && out.z == in.z); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /tests/test_spacetree.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(HAVE_CONFIG_H) 26 | #include 27 | #endif 28 | 29 | #include 30 | 31 | int main(int argc, char** argv) { 32 | carve::space::SpatialSubdivTree<3, carve::space::nodedata_FaceEdge> octree( 33 | carve::geom::VECTOR(0, 0, 0), carve::geom::VECTOR(1, 1, 1)); 34 | } 35 | -------------------------------------------------------------------------------- /tests/tetrahedron.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #if defined(HAVE_CONFIG_H) 26 | #include 27 | #endif 28 | 29 | #include 30 | #include 31 | 32 | double triangularPrismVolume(const carve::geom3d::Vector& a, 33 | const carve::geom3d::Vector& b, 34 | const carve::geom3d::Vector& c, double z) { 35 | double v1 = carve::geom3d::tetrahedronVolume( 36 | carve::geom::VECTOR(a.x, a.y, z), carve::geom::VECTOR(c.x, c.y, z), 37 | carve::geom::VECTOR(b.x, b.y, z), a); 38 | double v2 = carve::geom3d::tetrahedronVolume( 39 | carve::geom::VECTOR(a.x, a.y, z), carve::geom::VECTOR(c.x, c.y, z), b, a); 40 | double v3 = carve::geom3d::tetrahedronVolume(carve::geom::VECTOR(c.x, c.y, z), 41 | c, b, a); 42 | 43 | std::cerr << "[components:" << v1 << "," << v2 << "," << v3 << "]" 44 | << std::endl; 45 | return v1 + v2 + v3; 46 | } 47 | 48 | int main(int argc, char** argv) { 49 | std::cerr << "result: " << triangularPrismVolume(carve::geom::VECTOR(1, 0, 1), 50 | carve::geom::VECTOR(0, 1, 1), 51 | carve::geom::VECTOR(0, 0, 3), 52 | 0) 53 | << std::endl; 54 | std::cerr << "result: " 55 | << triangularPrismVolume(carve::geom::VECTOR(11, 10, 1), 56 | carve::geom::VECTOR(10, 11, 1), 57 | carve::geom::VECTOR(10, 10, 3), 0) 58 | << std::endl; 59 | } 60 | -------------------------------------------------------------------------------- /tests/tri_point_distance_unittest.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #include 26 | 27 | #if defined(HAVE_CONFIG_H) 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | TEST(TriPtDistTest, TriPtDistTest1) {} 35 | -------------------------------------------------------------------------------- /tests/triangle_intersection_unittest.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #include 26 | 27 | #if defined(HAVE_CONFIG_H) 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | typedef carve::geom::vector<2> vec2; 37 | typedef carve::geom::vector<2> vec3; 38 | 39 | std::istream& operator>>(std::istream& in, vec2& vec) { 40 | char c = 0; 41 | in >> vec.x; 42 | if (in >> c && c != ',') { 43 | in.setstate(std::ios_base::failbit); 44 | } 45 | in >> vec.y; 46 | return in; 47 | } 48 | 49 | std::ostream& operator<<(std::ostream& out, const vec2& vec) { 50 | out << vec.x << "," << vec.y; 51 | return out; 52 | } 53 | 54 | TEST(TriangleIntersectionTest, Test3D) { 55 | vec3 tri_a[3], tri_b[3]; 56 | tri_a[0] = carve::geom::VECTOR(0, 1, 0); 57 | tri_a[1] = carve::geom::VECTOR(1, 0.5, 0); 58 | tri_a[2] = carve::geom::VECTOR(0.5, 0.75, 1); 59 | 60 | tri_b[0] = carve::geom::VECTOR(2, 1, 1); 61 | tri_b[1] = carve::geom::VECTOR(1, 0.5, 1); 62 | tri_b[2] = carve::geom::VECTOR(1.5, 0.75, 0); 63 | } 64 | 65 | TEST(TriangleIntersectionTest, Test2D) { 66 | std::ifstream in("intersection_2d.txt"); 67 | 68 | while (in.good()) { 69 | char c; 70 | vec2 t1[3], t2[3]; 71 | 72 | in >> c >> t1[0] >> t1[1] >> t1[2] >> t2[0] >> t2[1] >> t2[2]; 73 | if (!in.eof()) { 74 | ASSERT_EQ( 75 | carve::geom::triangle_intersection(t1, t2), 76 | (c == 't') ? carve::geom::TR_INT_INT : carve::geom::TR_INT_NONE); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /tests/triangulate_unittest.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2015 Tobias Sargeant (tobias.sargeant@gmail.com). 2 | // 3 | // This file is part of the Carve CSG Library (http://carve-csg.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person 6 | // obtaining a copy of this software and associated documentation 7 | // files (the "Software"), to deal in the Software without 8 | // restriction, including without limitation the rights to use, copy, 9 | // modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | #include 26 | 27 | #if defined(HAVE_CONFIG_H) 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | TEST(Triangulate, Test2) { 36 | std::vector > poly; 37 | std::vector result; 38 | 39 | poly.push_back(carve::geom::VECTOR(0.0614821249999999985824672, 40 | 0.0192046249999999994739763)); 41 | poly.push_back(carve::geom::VECTOR(0.0480376250000000004636291, 42 | 0.0355867500000000003268497)); 43 | poly.push_back(carve::geom::VECTOR(0.0316555000000000030802028, 44 | 0.0490312499999999984456878)); 45 | poly.push_back(carve::geom::VECTOR(0.0480376250000000004636291, 46 | 0.0355867500000000003268497)); 47 | 48 | carve::triangulate::triangulate(poly, result); 49 | } 50 | 51 | TEST(Triangulate, Test1) { 52 | std::vector > poly; 53 | std::vector result; 54 | 55 | poly.push_back(carve::geom::VECTOR(-0.0197657499999999985984545, 56 | -0.00112325000000000618793905)); 57 | poly.push_back(carve::geom::VECTOR(-0.0197657499999999985984545, 58 | -0.0562291249999999978581577)); 59 | poly.push_back(carve::geom::VECTOR(0.000514374999999999966797393, 60 | -0.0562291249999999978581577)); 61 | poly.push_back(carve::geom::VECTOR(0.000514374999999999966797393, 62 | -0.00112324999999999924904515)); 63 | 64 | carve::triangulate::triangulate(poly, result); 65 | } 66 | --------------------------------------------------------------------------------