├── .gitattributes ├── .gitignore ├── BinaryMeshFitting.sln ├── BinaryMeshFitting ├── BinaryMeshFitting.vcxproj ├── BinaryMeshFitting.vcxproj.filters ├── CMakeDeps.cmake ├── CMakeLists.txt ├── ChunkBlocks.hpp ├── ChunkGenerator.cpp ├── ChunkGenerator.hpp ├── ColorMapper.cpp ├── ColorMapper.hpp ├── Core.cpp ├── Core.hpp ├── DMCChunk.cpp ├── DMCChunk.hpp ├── Debug.h ├── DebugScene.cpp ├── DebugScene.hpp ├── DefaultOptions.h ├── DynamicGLChunk.cpp ├── DynamicGLChunk.hpp ├── Entry.cpp ├── FPSCamera.cpp ├── FPSCamera.hpp ├── Frustum.cpp ├── Frustum.hpp ├── GLChunk.cpp ├── GLChunk.hpp ├── GUI │ ├── IMGUILICENSE │ ├── WorldOptions.h │ ├── imconfig.h │ ├── imgui.cpp │ ├── imgui.h │ ├── imgui_demo.cpp │ ├── imgui_draw.cpp │ ├── imgui_impl_glfw_gl3.cpp │ ├── imgui_impl_glfw_gl3.h │ ├── imgui_internal.h │ ├── stb_rect_pack.h │ ├── stb_textedit.h │ └── stb_truetype.h ├── HashMap.hpp ├── HeightMapSampler.hpp ├── ImplicitSampler.cpp ├── ImplicitSampler.hpp ├── LinkedList.hpp ├── LinkedNode.hpp ├── MCTable.h ├── MemoryPool.h ├── MemoryPool.tcc ├── MeshProcessor.cpp ├── MeshProcessor.hpp ├── MeshRecursion.hpp ├── NoiseSampler.cpp ├── NoiseSampler.hpp ├── PCH.cpp ├── PCH.h ├── ResourceAllocator.hpp ├── Sampler.hpp ├── SmartContainer.hpp ├── Tables.hpp ├── Texture.cpp ├── Texture.hpp ├── ThreadDebug.hpp ├── Vertices.hpp ├── WorldOctree.cpp ├── WorldOctree.hpp ├── WorldOctreeNode.cpp ├── WorldOctreeNode.hpp ├── WorldStitcher.cpp ├── WorldStitcher.hpp ├── WorldWatcher.cpp ├── WorldWatcher.hpp ├── avx │ ├── README │ ├── casts.h │ ├── const.h │ ├── const_data.h │ ├── debug.h │ ├── deinterleave.tcc │ ├── detail.h │ ├── helperimpl.h │ ├── intrinsics.h │ ├── limits.h │ ├── macros.h │ ├── mask.h │ ├── mask.tcc │ ├── math.h │ ├── shuffle.h │ ├── simd_cast.h │ ├── simd_cast_caller.tcc │ ├── types.h │ ├── vector.h │ ├── vector.tcc │ └── vectorhelper.h ├── common │ ├── algorithms.h │ ├── aliasingentryhelper.h │ ├── alignedbase.h │ ├── bitscanintrinsics.h │ ├── const.h │ ├── data.h │ ├── deinterleave.h │ ├── elementreference.h │ ├── exponential.h │ ├── fix_clang_emmintrin.h │ ├── gatherimplementation.h │ ├── gatherinterface.h │ ├── generalinterface.h │ ├── iif.h │ ├── indexsequence.h │ ├── interleave.h │ ├── interleavedmemory.h │ ├── iterators.h │ ├── loadinterface.h │ ├── loadstoreflags.h │ ├── logarithm.h │ ├── macros.h │ ├── makeContainer.h │ ├── make_unique.h │ ├── malloc.h │ ├── mask.h │ ├── maskbool.h │ ├── math.h │ ├── memory.h │ ├── memorybase.h │ ├── memoryfwd.h │ ├── operators.h │ ├── permutation.h │ ├── scatterimplementation.h │ ├── scatterinterface.h │ ├── set.h │ ├── simd_cast.h │ ├── simd_cast_caller.tcc │ ├── simdarray.h │ ├── simdarrayfwd.h │ ├── simdarrayhelper.h │ ├── simdize.h │ ├── simdmaskarray.h │ ├── storage.h │ ├── storeinterface.h │ ├── subscript.h │ ├── support.h │ ├── transpose.h │ ├── trigonometric.h │ ├── types.h │ ├── utility.h │ ├── vector.h │ ├── vector │ │ └── casts.h │ ├── vectorabi.h │ ├── vectortraits.h │ ├── vectortuple.h │ ├── where.h │ ├── writemaskedvector.h │ └── x86_prefetches.h ├── imgui.ini ├── mic │ ├── casts.h │ ├── const_data.h │ ├── debug.h │ ├── deinterleave.tcc │ ├── detail.h │ ├── helperimpl.h │ ├── interleaveimpl.h │ ├── intrinsics.h │ ├── limits.h │ ├── macros.h │ ├── mask.h │ ├── mask.tcc │ ├── math.h │ ├── prefetches.tcc │ ├── simd_cast.h │ ├── simd_cast_caller.tcc │ ├── sorthelper.h │ ├── storemixin.h │ ├── type_traits.h │ ├── types.h │ ├── vector.h │ ├── vector.tcc │ └── writemaskedvector.h ├── qef_simd.h ├── scalar │ ├── detail.h │ ├── helperimpl.h │ ├── limits.h │ ├── macros.h │ ├── mask.h │ ├── math.h │ ├── operators.h │ ├── simd_cast.h │ ├── simd_cast_caller.tcc │ ├── type_traits.h │ ├── types.h │ ├── vector.h │ └── vector.tcc ├── shaders │ ├── main_fs.glsl │ ├── main_vs.glsl │ ├── outline_fs.glsl │ └── outline_vs.glsl ├── sparsepp │ ├── spp.h │ ├── spp_config.h │ ├── spp_dlalloc.h │ ├── spp_memory.h │ ├── spp_smartptr.h │ ├── spp_stdint.h │ ├── spp_timer.h │ ├── spp_traits.h │ └── spp_utils.h ├── sse │ ├── casts.h │ ├── const.h │ ├── const_data.h │ ├── debug.h │ ├── deinterleave.tcc │ ├── detail.h │ ├── helperimpl.h │ ├── intrinsics.h │ ├── limits.h │ ├── macros.h │ ├── mask.h │ ├── mask.tcc │ ├── math.h │ ├── prefetches.tcc │ ├── shuffle.h │ ├── simd_cast.h │ ├── simd_cast_caller.tcc │ ├── type_traits.h │ ├── types.h │ ├── vector.h │ ├── vector.tcc │ ├── vectorhelper.h │ └── vectorhelper.tcc ├── stb_image.h └── traits │ ├── decay.h │ ├── entry_type_of.h │ ├── has_addition_operator.h │ ├── has_contiguous_storage.h │ ├── has_equality_operator.h │ ├── has_multiply_operator.h │ ├── has_no_allocated_data.h │ ├── has_subscript_operator.h │ ├── is_functor_argument_immutable.h │ ├── is_gather_signature.h │ ├── is_implicit_cast_allowed.h │ ├── is_index_sequence.h │ ├── is_initializer_list.h │ ├── is_load_arguments.h │ ├── is_output_iterator.h │ └── type_traits.h ├── CMakeLists.txt ├── LICENSE ├── README.md └── cmake └── Modules ├── CustomUtil.cmake ├── FindFastNoiseSIMD.cmake ├── FindGLFW.cmake ├── FindGLM.cmake ├── FindVc.cmake └── PrecompiledHeader.cmake /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /BinaryMeshFitting/CMakeDeps.cmake: -------------------------------------------------------------------------------- 1 | # File generated by CMake process 2 | set(sources ChunkGenerator.cpp;ColorMapper.cpp;Core.cpp;DMCChunk.cpp;DebugScene.cpp;DynamicGLChunk.cpp;Entry.cpp;FPSCamera.cpp;Frustum.cpp;GLChunk.cpp;ImplicitSampler.cpp;MeshProcessor.cpp;NoiseSampler.cpp;PCH.cpp;Texture.cpp;WorldOctree.cpp;WorldOctreeNode.cpp;WorldStitcher.cpp;WorldWatcher.cpp) 3 | -------------------------------------------------------------------------------- /BinaryMeshFitting/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(name "BinaryMeshFitting") 2 | 3 | file(GLOB sources LIST_DIRECTORIES false *.cpp) 4 | file(GLOB sources_gui LIST_DIRECTORIES false GUI/*.cpp) 5 | normalize_file_list(sources "${sources}") 6 | normalize_file_list(sources_gui "${sources_gui}") 7 | add_executable(${name} ${sources} ${sources_gui}) 8 | add_precompiled_header(${name} PCH.h FORCEINCLUDE 9 | SOURCE_CXX PCH.cpp 10 | SOURCES ${sources} # i.e. not the GUI sources 11 | ) 12 | update_deps_file("${sources}" "${sources_gui}") 13 | 14 | set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${name}) 15 | 16 | find_package(OpenGL REQUIRED) 17 | find_package(GLEW REQUIRED) 18 | find_package(GLFW REQUIRED) 19 | find_package(GLM REQUIRED) 20 | find_package(Vc REQUIRED) 21 | find_package(FastNoiseSIMD REQUIRED) 22 | 23 | set_target_properties(${name} PROPERTIES 24 | VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} 25 | ) 26 | 27 | target_include_directories(${name} PRIVATE 28 | ${GLEW_INCLUDE_DIRS} 29 | ${GLFW_INCLUDE_DIRS} 30 | ${GLM_INCLUDE_DIRS} 31 | ${Vc_INCLUDE_DIR} 32 | ${FastNoiseSIMD_INCLUDE_DIRS} 33 | ) 34 | 35 | target_link_libraries(${name} PRIVATE 36 | ${OPENGL_gl_LIBRARY} 37 | ${GLEW_LIBRARIES} 38 | ${GLFW_LIBRARIES} 39 | ${Vc_LIBRARIES} 40 | ${FastNoiseSIMD_LIBRARIES} 41 | ) 42 | -------------------------------------------------------------------------------- /BinaryMeshFitting/ChunkGenerator.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "ThreadDebug.hpp" 10 | #include "SmartContainer.hpp" 11 | #include "ResourceAllocator.hpp" 12 | #include "ChunkBlocks.hpp" 13 | #include "WorldStitcher.hpp" 14 | 15 | class ChunkGenerator : public ThreadDebug 16 | { 17 | public: 18 | ChunkGenerator(); 19 | ~ChunkGenerator(); 20 | 21 | void init(class WorldOctree* _world); 22 | 23 | void process_queue(SmartContainer& batch); 24 | 25 | std::mutex _mutex; 26 | std::condition_variable _cv; 27 | 28 | ResourceAllocator gl_allocator; 29 | ResourceAllocator density_allocator; 30 | ResourceAllocator binary_allocator; 31 | ResourceAllocator masks_allocator; 32 | ResourceAllocator vi_allocator; 33 | ResourceAllocator cell_allocator; 34 | ResourceAllocator inds_allocator; 35 | ResourceAllocator isovertex_allocator; 36 | ResourceAllocator noise_allocator; 37 | 38 | WorldStitcher stitcher; 39 | 40 | private: 41 | class WorldOctree* world; 42 | 43 | std::vector queue; 44 | 45 | bool update_still_needed(class WorldOctreeNode* n); 46 | void generate_chunk(class WorldOctreeNode* n); 47 | 48 | void extract_chunk(SmartContainer& batch); 49 | void extract_samples(SmartContainer& batch); 50 | void extract_filter(SmartContainer& batch); 51 | void extract_dual_vertices(SmartContainer& batch); 52 | void extract_octrees(SmartContainer& batch); 53 | void extract_base_meshes(SmartContainer& batch); 54 | void extract_copy_vis(SmartContainer& batch); 55 | void extract_stitches(SmartContainer& batch); 56 | void extract_format_meshes(SmartContainer& batch); 57 | }; 58 | -------------------------------------------------------------------------------- /BinaryMeshFitting/ColorMapper.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" 2 | #include "ColorMapper.hpp" 3 | 4 | using namespace glm; 5 | 6 | ColorMapper::ColorMapper() 7 | { 8 | noise_context = FastNoiseSIMD::NewFastNoiseSIMD(); 9 | } 10 | 11 | ColorMapper::~ColorMapper() 12 | { 13 | } 14 | 15 | void ColorMapper::generate_colors(SmartContainer& verts) 16 | { 17 | if (!verts.count) 18 | return; 19 | 20 | float* noise = 0; 21 | get_noise(verts, &noise); 22 | map_noise(verts, noise); 23 | 24 | FastNoiseSIMD::FreeNoiseSet(noise); 25 | } 26 | 27 | void ColorMapper::get_noise(SmartContainer& verts, float** out) 28 | { 29 | int count = (int)verts.count; 30 | 31 | FastNoiseVectorSet vectors; 32 | vectors.SetSize(count); 33 | 34 | const float scale = 1.0f; 35 | 36 | for (int i = 0; i < count; i++) 37 | { 38 | vectors.xSet[i] = verts[i].p.x * scale; 39 | vectors.ySet[i] = verts[i].p.y * scale; 40 | vectors.zSet[i] = verts[i].p.z * scale; 41 | } 42 | 43 | *out = FastNoiseSIMD::GetEmptySet(count, 1, 1); 44 | 45 | noise_context->SetNoiseType(FastNoiseSIMD::NoiseType::SimplexFractal); 46 | noise_context->SetFractalOctaves(4); 47 | noise_context->SetFractalType(FastNoiseSIMD::FractalType::FBM); 48 | noise_context->FillNoiseSet(*out, &vectors); 49 | } 50 | 51 | void ColorMapper::map_noise(SmartContainer& verts, float* noise) 52 | { 53 | int count = (int)verts.count; 54 | 55 | for (int i = 0; i < count; i++) 56 | { 57 | float n = noise[i] * 4.0f; 58 | verts[i].color = hsl_to_rgb((n + 1.0f) * 0.5f * 360.0f, 0.72f, 1.0f); 59 | } 60 | } 61 | 62 | glm::vec3 ColorMapper::hsl_to_rgb(float h, float s, float v) 63 | { 64 | float hh, p, q, t, ff; 65 | int i; 66 | float r = 0, g = 0, b = 0; 67 | 68 | if (s <= 0.0f) { // < is bogus, just shuts up warnings 69 | r = v; 70 | g = v; 71 | b = v; 72 | return vec3(r, g, b); 73 | } 74 | hh = h; 75 | //if (hh < 0.0f) hh += 360.0f; 76 | hh = fmodf(fabsf(hh), 360.0f); 77 | hh /= 60.0f; 78 | i = (int)hh; 79 | ff = hh - i; 80 | p = v * (1.0f - s); 81 | q = v * (1.0f - (s * ff)); 82 | t = v * (1.0f - (s * (1.0f - ff))); 83 | 84 | switch (i) { 85 | case 0: 86 | r = v; 87 | g = t; 88 | b = p; 89 | break; 90 | case 1: 91 | r = q; 92 | g = v; 93 | b = p; 94 | break; 95 | case 2: 96 | r = p; 97 | g = v; 98 | b = t; 99 | break; 100 | 101 | case 3: 102 | r = p; 103 | g = q; 104 | b = v; 105 | break; 106 | case 4: 107 | r = t; 108 | g = p; 109 | b = v; 110 | break; 111 | case 5: 112 | default: 113 | r = v; 114 | g = p; 115 | b = q; 116 | break; 117 | } 118 | 119 | return vec3(r, g, b); 120 | } 121 | -------------------------------------------------------------------------------- /BinaryMeshFitting/ColorMapper.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "SmartContainer.hpp" 5 | #include "Vertices.hpp" 6 | 7 | class ColorMapper 8 | { 9 | public: 10 | FastNoiseSIMD* noise_context; 11 | 12 | ColorMapper(); 13 | ~ColorMapper(); 14 | 15 | void generate_colors(SmartContainer& verts); 16 | 17 | private: 18 | void get_noise(SmartContainer& verts, float** out); 19 | void map_noise(SmartContainer& verts, float* noise); 20 | 21 | __forceinline glm::vec3 hsl_to_rgb(float h, float s, float l); 22 | }; 23 | -------------------------------------------------------------------------------- /BinaryMeshFitting/Core.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" 2 | #include 3 | #include "Core.hpp" 4 | #include "DebugScene.hpp" 5 | 6 | #define MAX_FRAMESKIP 1 7 | #define UPDATES_PER_SECOND 60.0 8 | #define SKIP_TICKS 1.0 / UPDATES_PER_SECOND 9 | 10 | static DebugScene* global_scene; 11 | 12 | void Core_error_callback(int e, const char* s) 13 | { 14 | printf("GL Error %d: %s\n", e, s); 15 | } 16 | 17 | int Core_init(struct RenderInput* out) 18 | { 19 | if (!glfwInit()) 20 | return -1; 21 | 22 | glfwSetErrorCallback(Core_error_callback); 23 | glfwWindowHint(GLFW_SAMPLES, 4); 24 | out->window = glfwCreateWindow(DEFAULT_RENDER_WIDTH, DEFAULT_RENDER_HEIGHT, "GLIsosurface", NULL, NULL); 25 | glfwSetWindowPos(out->window, 150, 100); 26 | if (!out->window) 27 | { 28 | glfwTerminate(); 29 | return -1; 30 | } 31 | out->width = DEFAULT_RENDER_WIDTH; 32 | out->height = DEFAULT_RENDER_HEIGHT; 33 | 34 | glfwMakeContextCurrent(out->window); 35 | glfwSwapInterval(1); 36 | //glfwSetInputMode(out->window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); 37 | 38 | glewExperimental = GL_TRUE; 39 | glewInit(); 40 | 41 | const GLubyte* renderer = glGetString(GL_RENDERER); 42 | const GLubyte* version = glGetString(GL_VERSION); 43 | printf("Renderer: %s\n", renderer); 44 | printf("OpenGL version supported %s\n\n", version); 45 | 46 | glEnable(GL_DEPTH_TEST); 47 | glDepthFunc(GL_LESS); 48 | 49 | return 0; 50 | } 51 | 52 | int Core_run(struct RenderInput* render) 53 | { 54 | DebugScene scene(render); 55 | global_scene = &scene; 56 | glfwSetKeyCallback(render->window, key_callback); 57 | 58 | double last_time = glfwGetTime(); 59 | double timer = last_time; 60 | double current_time = 0; 61 | double next_tick = last_time; 62 | int frame_counter = 0; 63 | int last_fps = 0; 64 | int update_counter = 0; 65 | int tupdate_counter = 0; 66 | 67 | while (!glfwWindowShouldClose(render->window)) 68 | { 69 | current_time = glfwGetTime(); 70 | render->delta = (float)(current_time - last_time); 71 | last_time = current_time; 72 | update_counter = 0; 73 | 74 | while (glfwGetTime() > next_tick && update_counter < MAX_FRAMESKIP) 75 | { 76 | scene.update(render); 77 | update_counter++; 78 | next_tick += SKIP_TICKS; 79 | tupdate_counter++; 80 | } 81 | 82 | scene.render(render); 83 | 84 | frame_counter++; 85 | 86 | if (glfwGetTime() - timer > 1.0) 87 | { 88 | timer++; 89 | last_fps = frame_counter; 90 | //printf("FPS: %i\t\tUpdates: %i\n", last_fps, tupdate_counter); 91 | frame_counter = 0; 92 | tupdate_counter = 0; 93 | } 94 | } 95 | 96 | return 0; 97 | } 98 | 99 | void Core_cleanup() 100 | { 101 | glfwTerminate(); 102 | } 103 | 104 | void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 105 | { 106 | global_scene->key_callback(key, scancode, action, mods); 107 | } 108 | -------------------------------------------------------------------------------- /BinaryMeshFitting/Core.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #define GLFW_DLL 5 | #include 6 | #include 7 | #include 8 | 9 | #define DEFAULT_RENDER_WIDTH 1600 10 | #define DEFAULT_RENDER_HEIGHT 900 11 | 12 | struct RenderInput 13 | { 14 | GLFWwindow* window; 15 | uint32_t width; 16 | uint32_t height; 17 | float delta; 18 | }; 19 | 20 | int Core_init(struct RenderInput* out); 21 | int Core_run(struct RenderInput* render); 22 | void Core_cleanup(); 23 | 24 | void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods); -------------------------------------------------------------------------------- /BinaryMeshFitting/DMCChunk.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #define GLFW_DLL 5 | #include 6 | #define GLM_FORCE_NO_CTOR_INIT 7 | #define GLM_FORCE_INLINE 8 | #include 9 | #include 10 | 11 | #include "Vertices.hpp" 12 | #include "SmartContainer.hpp" 13 | #include "Sampler.hpp" 14 | #include "ResourceAllocator.hpp" 15 | #include "ChunkBlocks.hpp" 16 | #include "WorldOctreeNode.hpp" 17 | #include "MemoryPool.h" 18 | #include "HashMap.hpp" 19 | #include "NoiseSampler.hpp" 20 | 21 | class DMCChunk 22 | { 23 | public: 24 | bool pem; 25 | int id; 26 | int level; 27 | uint32_t dim; 28 | float size; 29 | glm::vec3 pos; 30 | float snap_threshold; 31 | 32 | bool contains_mesh; 33 | uint32_t mesh_offset; 34 | uint64_t parent_code; 35 | 36 | Sampler sampler; 37 | 38 | VerticesIndicesBlock* vi; 39 | 40 | DensityBlock* density_block; 41 | BinaryBlock* binary_block; 42 | DMC_CellsBlock* cell_block; 43 | IndexesBlock* indexes_block; 44 | 45 | DMCNode octree; 46 | union children_pool 47 | { 48 | MemoryPool node_pool; 49 | DMCNode children[8]; 50 | 51 | children_pool() : node_pool() {} 52 | ~children_pool() {} 53 | }; 54 | children_pool octree_children; 55 | SmartContainer nodes; 56 | 57 | glm::vec3 overlap_pos; 58 | glm::vec3 bound_start; 59 | float bound_size; 60 | float scale; 61 | 62 | DMCChunk(); 63 | DMCChunk(glm::vec3 pos, float size, int level, Sampler& sampler, uint64_t parent_code); 64 | ~DMCChunk(); 65 | 66 | // Main pipeline 67 | void init(glm::vec3 pos, float size, int level, Sampler& sampler, uint64_t parent_code); 68 | void label_grid(ResourceAllocator* binary_allocator, ResourceAllocator* density_allocator, ResourceAllocator* noise_allocator, float overlap, NoiseSamplers::NoiseSamplerProperties properties); 69 | void label_edges(ResourceAllocator* vi_allocator, ResourceAllocator* cell_allocator, ResourceAllocator* inds_allocator, ResourceAllocator* density_allocator, ResourceAllocator* masks_allocator); 70 | void snap_verts(); 71 | void polygonize(); 72 | void polygonize_cell(DMC_Cell& _c, int x, int y, int z, int dim, SmartContainer& verts, SmartContainer& inds); 73 | void copy_verts_and_inds(SmartContainer& v_out, SmartContainer& i_out); 74 | 75 | // Sub procedures 76 | void calculate_cell(int x, int y, int z, uint32_t next_v_index, uint8_t mask, DMC_Cell& dest, int dim); 77 | void calculate_isovertex(int x0, int y0, int z0, int x1, int y1, int z1, int index, int dim, DMC_Isovertex& out); 78 | DualVertex calculate_dual_vertex(DMC_Isovertex& in); 79 | 80 | void generate_octree(); 81 | 82 | int get_internal_node_at(glm::vec3 p); 83 | 84 | double extract(SmartContainer& v_out, SmartContainer& i_out, bool silent); 85 | }; 86 | 87 | -------------------------------------------------------------------------------- /BinaryMeshFitting/Debug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef _DEBUG 4 | #define DEBUG_TEXT (_NORMAL_BLOCK, __FILE, __LINE) 5 | #else 6 | #define DEBUG_TEXT 7 | #endif -------------------------------------------------------------------------------- /BinaryMeshFitting/DebugScene.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #define GLFW_DLL 5 | #include 6 | #include "FPSCamera.hpp" 7 | #include "GLChunk.hpp" 8 | #include "WorldOctree.hpp" 9 | #include "Frustum.hpp" 10 | #include "Texture.hpp" 11 | 12 | #include 13 | #include 14 | 15 | class DebugScene 16 | { 17 | int last_space : 1; 18 | bool outline_visible; 19 | int fillmode; 20 | bool cull; 21 | bool quads; 22 | bool smooth_shading; 23 | bool flat_quads; 24 | bool gui_visible; 25 | bool world_visible; 26 | bool update_focus; 27 | float line_width; 28 | float line_color[4]; 29 | float fill_color[4]; 30 | float clear_color[4]; 31 | float specular_power; 32 | GLuint points_vbo; 33 | GLuint colors_vbo; 34 | GLuint vao; 35 | GLuint ibo; 36 | 37 | GLuint vertex_shader; 38 | GLuint fragment_shader; 39 | GLuint shader_program; 40 | 41 | GLuint outline_vs; 42 | GLuint outline_fs; 43 | GLuint outline_sp; 44 | 45 | GLint shader_projection; 46 | GLint shader_view; 47 | GLint shader_mul_clr; 48 | GLint shader_eye_pos; 49 | GLint shader_smooth_shading; 50 | GLint shader_specular_power; 51 | GLint shader_camera_pos; 52 | GLint shader_chunk_pos; 53 | GLint shader_chunk_depth; 54 | 55 | GLint shader_rock_texture; 56 | GLint shader_rock2_texture; 57 | GLint shader_grass_texture; 58 | GLint shader_noise_texture; 59 | 60 | GLint outline_shader_projection; 61 | GLint outline_shader_view; 62 | GLint outline_shader_mul_clr; 63 | GLint outline_shader_camera_pos; 64 | GLint outline_shader_chunk_pos; 65 | 66 | class FPSCamera camera; 67 | Frustum frustum; 68 | GLChunk gl_chunk; 69 | WorldOctree world; 70 | 71 | class DMCChunk* dmc_chunk; 72 | 73 | std::mutex gl_mutex; 74 | clock_t last_extraction; 75 | 76 | Texture rock_texture; 77 | Texture rock2_texture; 78 | Texture grass_texture; 79 | Texture noise_texture; 80 | 81 | public: 82 | DebugScene(struct RenderInput* input); 83 | ~DebugScene(); 84 | 85 | bool create_texture(std::string filename, Texture& out); 86 | bool create_shader(std::string data, GLuint* out, GLenum type, const char* name); 87 | bool create_shader_from_file(std::string filename, GLuint* out, GLenum type, const char* name); 88 | 89 | void load_main_shader(); 90 | 91 | void init_dmc_chunk(); 92 | void init_world(); 93 | int update(struct RenderInput* input); 94 | int render(struct RenderInput* input); 95 | 96 | void render_dmc_chunk(); 97 | void render_world(); 98 | 99 | void key_callback(int key, int scancode, int action, int mods); 100 | void render_gui(); 101 | void reload_shaders(); 102 | }; -------------------------------------------------------------------------------- /BinaryMeshFitting/DefaultOptions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define FILL_MODE_FILL 0 4 | #define FILL_MODE_BOTH 1 5 | #define FILL_MODE_WIRE 2 6 | 7 | #define QUADS 0 8 | #define SMOOTH_NORMALS 0 9 | #define DEFAULT_FILL_MODE FILL_MODE_BOTH 10 | #define FLAT_QUADS 0 11 | 12 | #define SPECULAR_POWER 0.0f 13 | 14 | #define FAST_GROUPING 0 15 | -------------------------------------------------------------------------------- /BinaryMeshFitting/DynamicGLChunk.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #define GLFW_DLL 5 | #include 6 | #include 7 | #include "SmartContainer.hpp" 8 | #include "Vertices.hpp" 9 | #include "LinkedList.hpp" 10 | #include "MemoryPool.h" 11 | 12 | struct VertexRegion : public LinkedNode 13 | { 14 | uint32_t start; 15 | uint32_t count; 16 | bool marked_dirty; 17 | 18 | inline VertexRegion() 19 | { 20 | start = 0; 21 | count = 0; 22 | marked_dirty = false; 23 | } 24 | 25 | inline VertexRegion(uint32_t _start, uint32_t _count) : start(_start), count(_count), marked_dirty(false) 26 | { 27 | } 28 | }; 29 | 30 | class DynamicGLChunk 31 | { 32 | public: 33 | bool initialized; 34 | bool normals; 35 | bool colors; 36 | 37 | // Important -- Do not change structure! 38 | GLuint vao; 39 | GLuint v_vbo; 40 | GLuint n_vbo; 41 | GLuint c_vbo; 42 | 43 | uint32_t v_count; 44 | uint32_t p_count; 45 | uint32_t vbo_size; 46 | 47 | SmartContainer p_data; 48 | SmartContainer n_data; 49 | SmartContainer c_data; 50 | 51 | DynamicGLChunk(); 52 | ~DynamicGLChunk(); 53 | void init(bool _normals, bool _colors); 54 | void destroy(); 55 | 56 | VertexRegion* allocate(uint32_t count); 57 | void free(VertexRegion* r); 58 | void reset(VertexRegion* r, uint32_t offset = 0); 59 | 60 | void upload(VertexRegion* r); 61 | void upload_dirty_regions(); 62 | 63 | MemoryPool region_pool; 64 | LinkedList used_regions; 65 | LinkedList free_regions; 66 | 67 | SmartContainer dirty_regions; 68 | }; 69 | -------------------------------------------------------------------------------- /BinaryMeshFitting/Entry.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" 2 | 3 | #include 4 | #define GLFW_DLL 5 | #include 6 | #include 7 | 8 | #include "Core.hpp" 9 | 10 | #include 11 | 12 | #if defined(_DEBUG) && defined(_WIN32) 13 | #define DWIN32 14 | #define _CRTDBG_MAP_ALLOC 15 | #include 16 | #include 17 | #endif 18 | 19 | int main(void) 20 | { 21 | RenderInput render_input; 22 | 23 | if (Core_init(&render_input)) 24 | { 25 | glfwTerminate(); 26 | return -1; 27 | } 28 | 29 | Core_run(&render_input); 30 | Core_cleanup(); 31 | 32 | #ifdef DWIN32 33 | //Print out any memory leaks 34 | _CrtDumpMemoryLeaks(); 35 | #endif 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /BinaryMeshFitting/FPSCamera.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #define GLFW_DLL 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class FPSCamera 10 | { 11 | public: 12 | int last_1 : 1; 13 | int last_2 : 1; 14 | int last_c : 1; 15 | int last_mb : 1; 16 | int lock_cursor : 1; 17 | float speed; 18 | float smoothness; 19 | float rot_sensitivity; 20 | double last_x; 21 | double last_y; 22 | int last_modifiers[3]; 23 | 24 | glm::vec3 v_position; 25 | glm::vec3 v_rot; 26 | glm::vec3 v_velocity; 27 | glm::vec3 v_turn_velocity; 28 | 29 | glm::mat4 mat_projection; 30 | glm::mat4 mat_view; 31 | glm::mat4 mat_view_frustum; 32 | glm::mat4 mat_rotation; 33 | glm::quat camera_quat; 34 | 35 | void init(uint32_t width, uint32_t height, struct RenderInput* render_input); 36 | void update(struct RenderInput* render_input); 37 | void set_shader(GLint shader_proj, GLint shader_view); 38 | }; 39 | -------------------------------------------------------------------------------- /BinaryMeshFitting/Frustum.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Frustum 4 | { 5 | public: 6 | // Call this every time the camera moves to update the frustum 7 | void CalculateFrustum(float* proj, float* modl); 8 | 9 | // This takes a 3D point and returns TRUE if it's inside of the frustum 10 | bool PointInFrustum(float x, float y, float z); 11 | 12 | // This takes a 3D point and a radius and returns TRUE if the sphere is inside of the frustum 13 | bool SphereInFrustum(float x, float y, float z, float radius); 14 | 15 | // This takes the center and half the length of the cube. 16 | bool CubeInFrustum(float x, float y, float z, float size); 17 | 18 | private: 19 | // This holds the A B C and D values for each side of our frustum. 20 | float m_Frustum[6][4]; 21 | }; -------------------------------------------------------------------------------- /BinaryMeshFitting/GLChunk.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #define GLFW_DLL 5 | #include 6 | #include 7 | #include "SmartContainer.hpp" 8 | #include "Vertices.hpp" 9 | #include "LinkedNode.hpp" 10 | 11 | class GLChunk : public LinkedNode 12 | { 13 | public: 14 | bool initialized; 15 | bool normals; 16 | bool colors; 17 | bool indexed; 18 | 19 | // Important -- Do not change structure! 20 | GLuint vao; 21 | GLuint v_vbo; 22 | GLuint n_vbo; 23 | GLuint c_vbo; 24 | GLuint ibo; 25 | 26 | uint32_t v_count; 27 | uint32_t p_count; 28 | uint32_t vbo_size; 29 | uint32_t ibo_size; 30 | 31 | SmartContainer p_data; 32 | SmartContainer n_data; 33 | SmartContainer c_data; 34 | 35 | GLChunk(); 36 | ~GLChunk(); 37 | void init(bool _normals, bool _colors, bool _indexed = true); 38 | void destroy(); 39 | bool set_data(bool unwind = true); 40 | bool set_data(SmartContainer* index_data, bool unwind_verts); 41 | bool set_data(SmartContainer& pos_data, SmartContainer& index_data); 42 | bool set_data(SmartContainer& pos_data, SmartContainer& color_data, SmartContainer* index_data); 43 | bool set_data(SmartContainer& pos_data, SmartContainer& norm_data, SmartContainer& color_data, SmartContainer* index_data, bool unwind_verts); 44 | bool format_data_tris(SmartContainer& vert_data); 45 | bool format_data(SmartContainer& vert_data, SmartContainer& index_data, bool unwind_verts, bool smooth_normals); 46 | bool format_data(SmartContainer& vert_data, bool smooth_normals); 47 | void reset_data(); 48 | }; -------------------------------------------------------------------------------- /BinaryMeshFitting/GUI/IMGUILICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2015 Omar Cornut and ImGui contributors 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 | -------------------------------------------------------------------------------- /BinaryMeshFitting/GUI/WorldOptions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define DEFAULT_RESOLUTION 32 -------------------------------------------------------------------------------- /BinaryMeshFitting/GUI/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // USER IMPLEMENTATION 3 | // This file contains compile-time options for ImGui. 4 | // Other options (memory allocation overrides, callbacks, etc.) can be set at runtime via the ImGuiIO structure - ImGui::GetIO(). 5 | //----------------------------------------------------------------------------- 6 | 7 | #pragma once 8 | 9 | //---- Define assertion handler. Defaults to calling assert(). 10 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 11 | 12 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows. 13 | //#define IMGUI_API __declspec( dllexport ) 14 | //#define IMGUI_API __declspec( dllimport ) 15 | 16 | //---- Include imgui_user.h at the end of imgui.h 17 | //#define IMGUI_INCLUDE_IMGUI_USER_H 18 | 19 | //---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions) 20 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS 21 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS 22 | 23 | //---- Don't implement help and test window functionality (ShowUserGuide()/ShowStyleEditor()/ShowTestWindow() methods will be empty) 24 | //#define IMGUI_DISABLE_TEST_WINDOWS 25 | 26 | //---- Don't define obsolete functions names 27 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 28 | 29 | //---- Pack colors to BGRA instead of RGBA (remove need to post process vertex buffer in back ends) 30 | //#define IMGUI_USE_BGRA_PACKED_COLOR 31 | 32 | //---- Implement STB libraries in a namespace to avoid conflicts 33 | //#define IMGUI_STB_NAMESPACE ImGuiStb 34 | 35 | //---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4. 36 | /* 37 | #define IM_VEC2_CLASS_EXTRA \ 38 | ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ 39 | operator MyVec2() const { return MyVec2(x,y); } 40 | 41 | #define IM_VEC4_CLASS_EXTRA \ 42 | ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ 43 | operator MyVec4() const { return MyVec4(x,y,z,w); } 44 | */ 45 | 46 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. 47 | //---- e.g. create variants of the ImGui::Value() helper for your low-level math types, or your own widgets/helpers. 48 | /* 49 | namespace ImGui 50 | { 51 | void Value(const char* prefix, const MyMatrix44& v, const char* float_format = NULL); 52 | } 53 | */ 54 | 55 | -------------------------------------------------------------------------------- /BinaryMeshFitting/GUI/imgui_impl_glfw_gl3.h: -------------------------------------------------------------------------------- 1 | // ImGui GLFW binding with OpenGL3 + shaders 2 | // In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp. 3 | // (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) 4 | // (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.) 5 | 6 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 7 | // If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). 8 | // If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. 9 | // https://github.com/ocornut/imgui 10 | 11 | struct GLFWwindow; 12 | 13 | IMGUI_API bool ImGui_ImplGlfwGL3_Init(GLFWwindow* window, bool install_callbacks); 14 | IMGUI_API void ImGui_ImplGlfwGL3_Shutdown(); 15 | IMGUI_API void ImGui_ImplGlfwGL3_NewFrame(); 16 | 17 | // Use if you want to reset your rendering device without losing ImGui state. 18 | IMGUI_API void ImGui_ImplGlfwGL3_InvalidateDeviceObjects(); 19 | IMGUI_API bool ImGui_ImplGlfwGL3_CreateDeviceObjects(); 20 | 21 | // GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization) 22 | // Provided here if you want to chain callbacks. 23 | // You can also handle inputs yourself and use those as a reference. 24 | IMGUI_API void ImGui_ImplGlfwGL3_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods); 25 | IMGUI_API void ImGui_ImplGlfwGL3_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset); 26 | IMGUI_API void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); 27 | IMGUI_API void ImGui_ImplGlfwGL3_CharCallback(GLFWwindow* window, unsigned int c); -------------------------------------------------------------------------------- /BinaryMeshFitting/HeightMapSampler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /BinaryMeshFitting/ImplicitSampler.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" 2 | #include "ImplicitSampler.hpp" 3 | 4 | #define BLOCK(f) \ 5 | if (!out) \ 6 | return; \ 7 | if (!(*out)) \ 8 | *out = (float*)_aligned_malloc(size.x * size.y * size.z * sizeof(float), 16); \ 9 | glm::vec3 dxyz; \ 10 | for (int x = 0; x < size.x; x++) \ 11 | { \ 12 | dxyz.x = p.x + (float)x * scale; \ 13 | for (int y = 0; y < size.y; y++) \ 14 | { \ 15 | dxyz.y = p.y + (float)y * scale; \ 16 | for (int z = 0; z < size.z; z++) \ 17 | { \ 18 | dxyz.z = p.z + (float)z * scale; \ 19 | char* f_out = ((char*)((*out))) + offset + (x * size.y * size.z + y * size.z + z) * stride; \ 20 | *((float*)f_out) = f(resolution, dxyz); \ 21 | } \ 22 | } \ 23 | } 24 | 25 | namespace ImplicitFunctions 26 | { 27 | const float torus_z(const float resolution, const glm::vec3& p) 28 | { 29 | const float r1 = resolution / 4.0f; 30 | const float r2 = resolution / 10.0f; 31 | float q_x = fabsf(sqrtf(p[0] * p[0] + p[1] * p[1])) - r1; 32 | float len = sqrtf(q_x * q_x + p[2] * p[2]); 33 | return -(len - r2); 34 | } 35 | 36 | const void torus_z_block(const float resolution, const glm::vec3& p, const glm::ivec3& size, const float scale, void** out, FastNoiseVectorSet* vectorset_out, float* dest_noise, int offset, int stride, SamplerProperties* properties) 37 | { 38 | BLOCK(torus_z); 39 | } 40 | 41 | const void cuboid_block(const float resolution, const glm::vec3& p, const glm::ivec3& size, const float scale, void** out, FastNoiseVectorSet* vectorset_out, float* dest_noise, int offset, int stride, SamplerProperties* properties) 42 | { 43 | BLOCK(cuboid); 44 | } 45 | 46 | const float sphere(const float resolution, const glm::vec3& p) 47 | { 48 | const float r = resolution * 0.25f; 49 | return -(glm::length(p) - r); 50 | } 51 | 52 | const float cuboid(const float resolution, const glm::vec3 & p) 53 | { 54 | using namespace glm; 55 | float r = resolution / 8.0f; 56 | vec3 local = p; 57 | vec3 d(fabsf(local.x) - r, fabsf(local.y) - r, fabsf(local.z) - r); 58 | float m = fmaxf(d.x, fmaxf(d.y, d.z)); 59 | return -fminf(m, length(d)); 60 | } 61 | 62 | const float plane_y(const float resolution, const glm::vec3 & p) 63 | { 64 | return -p.y; 65 | } 66 | 67 | glm::vec3 get_intersection(glm::vec3 v0, glm::vec3 v1, float s0, float s1) 68 | { 69 | return v0 - s0 * (v1 - v0) / (s1 - s0); 70 | } 71 | } -------------------------------------------------------------------------------- /BinaryMeshFitting/ImplicitSampler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Sampler.hpp" 4 | 5 | namespace ImplicitFunctions 6 | { 7 | const float torus_z(const float resolution, const glm::vec3& p); 8 | const void torus_z_block(const float resolution, const glm::vec3& p, const glm::ivec3& size, const float scale, void** out, FastNoiseVectorSet* vectorset_out, float* dest_noise, int offset, int stride, SamplerProperties* properties); 9 | const float sphere(const float resolution, const glm::vec3& p); 10 | const float cuboid(const float resolution, const glm::vec3& p); 11 | const void cuboid_block(const float resolution, const glm::vec3& p, const glm::ivec3& size, const float scale, void** out, FastNoiseVectorSet* vectorset_out, float* dest_noise, int offset, int stride, SamplerProperties* properties); 12 | const float plane_y(const float resolution, const glm::vec3& p); 13 | 14 | inline void implicit_block(const SamplerValueFunction& f, const float resolution, const glm::vec3& p, const glm::ivec3& size, const float scale, void** out, FastNoiseVectorSet* vectorset_out, float* dest_noise, int offset, int stride) 15 | { 16 | if (!out) 17 | return; 18 | if (!(*out)) 19 | *out = (float*)_aligned_malloc(size.x * size.y * size.z * sizeof(float), 16); 20 | 21 | glm::vec3 dxyz; 22 | for (int x = 0; x < size.x; x++) 23 | { 24 | dxyz.x = p.x + (float)x * scale; 25 | for (int y = 0; y < size.y; y++) 26 | { 27 | dxyz.y = p.y + (float)y * scale; 28 | for (int z = 0; z < size.z; z++) 29 | { 30 | dxyz.z = p.z + (float)z * scale; 31 | char* f_out = ((char*)((*out))) + offset + (x * size.y * size.z + y * size.z + z) * stride; 32 | *((float*)f_out) = f(resolution, dxyz); 33 | } 34 | } 35 | } 36 | } 37 | 38 | inline glm::vec3 implicit_gradient(SamplerValueFunction f, const float resolution, const glm::vec3& p, float h = 0.01f) 39 | { 40 | using namespace glm; 41 | float dxp = f(resolution, vec3(p.x + h, p.y, p.z)); 42 | float dxm = f(resolution, vec3(p.x - h, p.y, p.z)); 43 | float dyp = f(resolution, vec3(p.x, p.y + h, p.z)); 44 | float dym = f(resolution, vec3(p.x, p.y - h, p.z)); 45 | float dzp = f(resolution, vec3(p.x, p.y, p.z + h)); 46 | float dzm = f(resolution, vec3(p.x, p.y, p.z - h)); 47 | 48 | return vec3(dxp - dxm, dyp - dym, dzp - dzm); 49 | } 50 | 51 | inline Sampler create_sampler(const SamplerValueFunction& f) 52 | { 53 | using namespace std::placeholders; 54 | Sampler s; 55 | s.value = f; 56 | s.block = std::bind(implicit_block, f, _1, _2, _3, _4, _5, _6, _7, _8, _9); 57 | s.gradient = std::bind(implicit_gradient, f, _1, _2, _3); 58 | return s; 59 | } 60 | 61 | glm::vec3 get_intersection(glm::vec3 v0, glm::vec3 v1, float s0, float s1); 62 | } -------------------------------------------------------------------------------- /BinaryMeshFitting/LinkedList.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "LinkedNode.hpp" 4 | 5 | template 6 | class LinkedList 7 | { 8 | public: 9 | LinkedNode* head; 10 | LinkedNode* tail; 11 | size_t count; 12 | 13 | inline LinkedList() 14 | { 15 | head = 0; 16 | tail = 0; 17 | count = 0; 18 | } 19 | 20 | inline ~LinkedList() 21 | { 22 | head = 0; 23 | tail = 0; 24 | count = 0; 25 | } 26 | 27 | inline void set_first(LinkedNode* node) 28 | { 29 | head = node; 30 | tail = node; 31 | count = 1; 32 | } 33 | 34 | inline void push_back(LinkedNode* node) 35 | { 36 | if (!node || node->prev || node->next) 37 | return; 38 | if (!tail) 39 | { 40 | set_first(node); 41 | return; 42 | } 43 | 44 | tail->next = node; 45 | node->prev = tail; 46 | tail = node; 47 | count++; 48 | } 49 | 50 | inline LinkedNode* unlink(LinkedNode* node) 51 | { 52 | if (head == node) 53 | { 54 | head = node->next; 55 | } 56 | if (tail == node) 57 | { 58 | tail = node->prev; 59 | } 60 | node->unlink(); 61 | count--; 62 | return node; 63 | } 64 | }; 65 | -------------------------------------------------------------------------------- /BinaryMeshFitting/LinkedNode.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | class LinkedNode 5 | { 6 | public: 7 | LinkedNode* prev; 8 | LinkedNode* next; 9 | 10 | inline LinkedNode() 11 | { 12 | prev = 0; 13 | next = 0; 14 | } 15 | 16 | inline ~LinkedNode() 17 | { 18 | unlink(); 19 | } 20 | 21 | inline void unlink() 22 | { 23 | if (prev) 24 | { 25 | prev->next = next; 26 | } 27 | if (next) 28 | { 29 | next->prev = prev; 30 | } 31 | next = 0; 32 | prev = 0; 33 | } 34 | }; -------------------------------------------------------------------------------- /BinaryMeshFitting/MemoryPool.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2013 Cosku Acay, http://www.coskuacay.com 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MEMORY_POOL_H 24 | #define MEMORY_POOL_H 25 | 26 | #include 27 | #include 28 | 29 | template 30 | class MemoryPool 31 | { 32 | public: 33 | /* Member types */ 34 | typedef T value_type; 35 | typedef T* pointer; 36 | typedef T& reference; 37 | typedef const T* const_pointer; 38 | typedef const T& const_reference; 39 | typedef size_t size_type; 40 | typedef ptrdiff_t difference_type; 41 | typedef std::false_type propagate_on_container_copy_assignment; 42 | typedef std::true_type propagate_on_container_move_assignment; 43 | typedef std::true_type propagate_on_container_swap; 44 | 45 | template struct rebind { 46 | typedef MemoryPool other; 47 | }; 48 | 49 | /* Member functions */ 50 | MemoryPool() noexcept; 51 | MemoryPool(const MemoryPool& memoryPool) noexcept; 52 | MemoryPool(MemoryPool&& memoryPool) noexcept; 53 | template MemoryPool(const MemoryPool& memoryPool) noexcept; 54 | 55 | ~MemoryPool() noexcept; 56 | 57 | MemoryPool& operator=(const MemoryPool& memoryPool) = delete; 58 | MemoryPool& operator=(MemoryPool&& memoryPool) noexcept; 59 | 60 | pointer address(reference x) const noexcept; 61 | const_pointer address(const_reference x) const noexcept; 62 | 63 | // Can only allocate one object at a time. n and hint are ignored 64 | pointer allocate(size_type n = 1, const_pointer hint = 0); 65 | void deallocate(pointer p, size_type n = 1); 66 | 67 | size_type max_size() const noexcept; 68 | 69 | template void construct(U* p, Args&&... args); 70 | template void destroy(U* p); 71 | 72 | template pointer newElement(Args&&... args); 73 | void deleteElement(pointer p); 74 | 75 | private: 76 | union Slot_ { 77 | value_type element; 78 | Slot_* next; 79 | }; 80 | 81 | typedef char* data_pointer_; 82 | typedef Slot_ slot_type_; 83 | typedef Slot_* slot_pointer_; 84 | 85 | slot_pointer_ currentBlock_; 86 | slot_pointer_ currentSlot_; 87 | slot_pointer_ lastSlot_; 88 | slot_pointer_ freeSlots_; 89 | 90 | size_type padPointer(data_pointer_ p, size_type align) const noexcept; 91 | void allocateBlock(); 92 | 93 | static_assert(BlockSize >= 2 * sizeof(slot_type_), "BlockSize too small."); 94 | }; 95 | 96 | #include "MemoryPool.tcc" 97 | 98 | #endif // MEMORY_POOL_H -------------------------------------------------------------------------------- /BinaryMeshFitting/MeshProcessor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Sampler.hpp" 4 | #include "SmartContainer.hpp" 5 | #include "Vertices.hpp" 6 | #include 7 | 8 | namespace Processing 9 | { 10 | template 11 | struct Primitive 12 | { 13 | float s; 14 | uint32_t v[N]; 15 | //uint32_t neighbor_duals[3]; 16 | 17 | // Dual vertex 18 | glm::vec3 dual_p; 19 | glm::vec3 dual_n; 20 | glm::vec3 dual_c; 21 | float weight; 22 | bool destroyed; 23 | bool boundary; 24 | }; 25 | 26 | struct Edge 27 | { 28 | uint32_t v[2]; 29 | 30 | Edge() {} 31 | Edge(uint32_t v0, uint32_t v1) 32 | { 33 | v[0] = v0; 34 | v[1] = v1; 35 | } 36 | 37 | bool operator==(const Edge& other) const 38 | { 39 | return (v[0] == other.v[0] && v[1] == other.v[1]) || (v[0] == other.v[1] && v[1] == other.v[0]); 40 | } 41 | }; 42 | 43 | template 44 | struct PrimPair 45 | { 46 | Primitive* p[2]; 47 | 48 | PrimPair() {} 49 | PrimPair(Primitive* p0, Primitive* p1) { 50 | p[0] = p0; 51 | p[1] = p1; 52 | } 53 | }; 54 | 55 | template 56 | class MeshProcessor 57 | { 58 | uint32_t prim_count; 59 | Sampler sampler; 60 | SmartContainer vertices; 61 | SmartContainer adj_block; 62 | Primitive* prims; 63 | bool smooth_normals; 64 | 65 | public: 66 | MeshProcessor(bool simple_quality, bool smooth_normals); 67 | ~MeshProcessor(); 68 | bool init(SmartContainer& vertices, SmartContainer& inds, Sampler& sampler); 69 | void flush(SmartContainer& v_out, SmartContainer& inds); 70 | void flush_to_tris(SmartContainer& v_out, SmartContainer& inds); 71 | void flush(SmartContainer& v_pos, SmartContainer & v_norm, SmartContainer& inds); 72 | void init_primitives(SmartContainer& inds); 73 | void optimize_dual_grid(int iterations, bool process_boundary = true); 74 | void optimize_primal_grid(bool qef, bool set_colors, bool process_boundary = true); 75 | 76 | void optimize_dual_prims(int start, bool face_norm); 77 | 78 | void collapse_bad_quads(); 79 | void collapse_edges(); 80 | 81 | bool simple_quality; 82 | 83 | private: 84 | }; 85 | } 86 | 87 | namespace std 88 | { 89 | template <> 90 | struct hash 91 | { 92 | size_t operator()(const Processing::Edge& e) const 93 | { 94 | return e.v[0] ^ e.v[1] + e.v[0] + e.v[1]; 95 | } 96 | }; 97 | } 98 | -------------------------------------------------------------------------------- /BinaryMeshFitting/MeshRecursion.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Vertices.hpp" 5 | 6 | // Average vertex 7 | template 8 | struct recursive_unroll { 9 | __forceinline static void result(TOp& k) 10 | { 11 | k(); 12 | recursive_unroll::result(k); 13 | } 14 | }; 15 | 16 | template 17 | struct recursive_unroll { 18 | __forceinline static void result(TOp& k) {} 19 | }; 20 | 21 | struct average_vertex 22 | { 23 | glm::vec3 p; 24 | uint32_t* inds; 25 | DualVertex* verts; 26 | 27 | inline average_vertex(uint32_t* v_inds, DualVertex* vertices) : inds(v_inds), verts(vertices), p(0, 0, 0) {} 28 | 29 | __forceinline void operator()() 30 | { 31 | p += verts[*(inds++)].p; 32 | } 33 | }; 34 | 35 | struct average_normal 36 | { 37 | glm::vec3 n; 38 | uint32_t* inds; 39 | DualVertex* verts; 40 | 41 | inline average_normal(uint32_t* v_inds, DualVertex* vertices) : inds(v_inds), verts(vertices), n(0, 0, 0) {} 42 | 43 | __forceinline void operator()() 44 | { 45 | n += verts[*(inds++)].n; 46 | } 47 | }; 48 | 49 | struct average_color 50 | { 51 | glm::vec3 c; 52 | uint32_t* inds; 53 | DualVertex* verts; 54 | 55 | inline average_color(uint32_t* v_inds, DualVertex* vertices) : inds(v_inds), verts(vertices), c(0, 0, 0) {} 56 | 57 | __forceinline void operator()() 58 | { 59 | c += verts[*(inds++)].color; 60 | } 61 | }; 62 | 63 | struct fill_prim 64 | { 65 | uint32_t* inds; 66 | uint32_t* src_inds; 67 | 68 | inline fill_prim(uint32_t* dest_inds, uint32_t* source_inds) : inds(dest_inds), src_inds(source_inds) {} 69 | 70 | __forceinline void operator()() 71 | { 72 | *inds++ = *src_inds++; 73 | } 74 | }; 75 | 76 | struct set_adj 77 | { 78 | SmartContainer* adj; 79 | uint32_t* inds; 80 | DualVertex* verts; 81 | uint32_t p_index; 82 | bool* boundary; 83 | 84 | inline set_adj(SmartContainer* adj_block, uint32_t* p_inds, DualVertex* vertices, uint32_t prim_index, bool* _boundary) : adj(adj_block), inds(p_inds), verts(vertices), p_index(prim_index), boundary(_boundary) {} 85 | 86 | __forceinline void operator()() 87 | { 88 | (*adj)[verts[*inds].adj_offset + verts[*inds].adj_next++] = p_index; 89 | if (verts[*inds].boundary) 90 | *boundary = true; 91 | inds++; 92 | } 93 | }; 94 | 95 | struct flush_inds 96 | { 97 | SmartContainer* inds; 98 | uint32_t* src_inds; 99 | 100 | inline flush_inds(SmartContainer* dest_inds, uint32_t* p_inds) : inds(dest_inds), src_inds(p_inds) {} 101 | 102 | __forceinline void operator()() 103 | { 104 | inds->push_back(*src_inds); 105 | src_inds++; 106 | } 107 | }; 108 | 109 | template 110 | struct build_adjacency 111 | { 112 | std::unordered_map*[2]> map; 113 | 114 | }; 115 | -------------------------------------------------------------------------------- /BinaryMeshFitting/PCH.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" -------------------------------------------------------------------------------- /BinaryMeshFitting/PCH.h: -------------------------------------------------------------------------------- 1 | // Pre-compiled headers go here... 2 | 3 | #define QEF_INCLUDE_IMPL 4 | #include "qef_simd.h" 5 | 6 | #define GLM_FORCE_NO_CTOR_INIT 7 | #define GLM_FORCE_INLINE 8 | #include 9 | 10 | #define PI 3.1415926535897932384626433832795f 11 | 12 | #include "GUI/imgui.h" 13 | #include "GUI/imgui_impl_glfw_gl3.h" 14 | 15 | #include 16 | -------------------------------------------------------------------------------- /BinaryMeshFitting/ResourceAllocator.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "MemoryPool.h" 5 | #include "LinkedList.hpp" 6 | 7 | template 8 | class ResourceAllocator 9 | { 10 | public: 11 | inline ResourceAllocator() 12 | { 13 | } 14 | 15 | inline ~ResourceAllocator() 16 | { 17 | LinkedNode* n = used_chunks.head; 18 | while (n) 19 | { 20 | LinkedNode* next = n->next; 21 | pool.deleteElement((T*)n); 22 | n = next; 23 | } 24 | 25 | n = free_chunks.head; 26 | while (n) 27 | { 28 | LinkedNode* next = n->next; 29 | pool.deleteElement((T*)n); 30 | n = next; 31 | } 32 | } 33 | 34 | inline T* new_element(bool no_lock = false) 35 | { 36 | std::unique_lock _lock(_mutex, std::defer_lock); 37 | if (!no_lock) 38 | _lock.lock(); 39 | if (free_chunks.tail) 40 | { 41 | T* c = (T*)free_chunks.tail; 42 | free_chunks.unlink(c); 43 | used_chunks.push_back(c); 44 | return c; 45 | } 46 | 47 | T* c = pool.newElement(); 48 | used_chunks.push_back(c); 49 | return c; 50 | } 51 | 52 | inline void free_element(T* element, bool no_lock = false) 53 | { 54 | if (!element) 55 | return; 56 | std::unique_lock lock(_mutex, std::defer_lock); 57 | if (!no_lock) 58 | lock.lock(); 59 | free_chunks.push_back(used_chunks.unlink(element)); 60 | if (!no_lock) 61 | lock.unlock(); 62 | } 63 | 64 | std::mutex _mutex; 65 | 66 | private: 67 | MemoryPool pool; 68 | LinkedList used_chunks; 69 | LinkedList free_chunks; 70 | }; -------------------------------------------------------------------------------- /BinaryMeshFitting/Sampler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class SamplerProperties 9 | { 10 | public: 11 | int thread_id; 12 | 13 | inline SamplerProperties() : thread_id(0) {} 14 | inline SamplerProperties(int _thread_id) : thread_id(_thread_id) {} 15 | virtual ~SamplerProperties() {}; 16 | 17 | }; 18 | 19 | //typedef std::function SamplerValueFunction; 20 | typedef const float(*SamplerValueFunction)(const float world_size, const glm::vec3& p); 21 | typedef std::function SamplerBlockFunction; 22 | typedef std::function SamplerGradientFunction; 23 | 24 | struct Sampler 25 | { 26 | float world_size; 27 | SamplerValueFunction value; 28 | SamplerBlockFunction block; 29 | SamplerGradientFunction gradient; 30 | FastNoiseSIMD* noise_samplers[8]; 31 | 32 | inline Sampler() { for (int i = 0; i < 8; i++) noise_samplers[i] = 0; } 33 | inline virtual ~Sampler() {} 34 | }; 35 | 36 | inline std::string get_simd_text() 37 | { 38 | switch (FastNoiseSIMD::GetSIMDLevel()) 39 | { 40 | case 1: 41 | return "SSE2"; 42 | case 2: 43 | return "SSE4.1"; 44 | case 3: 45 | return "AVX2/FMA3"; 46 | case 4: 47 | return "AVX512"; 48 | case 5: 49 | return "ARM NEON"; 50 | default: 51 | return "None"; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /BinaryMeshFitting/SmartContainer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | template 8 | class SmartContainer 9 | { 10 | const size_t DEFAULT_SIZE = 32; 11 | const int DEFAULT_SCALE = 2; 12 | 13 | public: 14 | size_t size; 15 | size_t count; 16 | T* elements; 17 | int scale; 18 | 19 | inline SmartContainer() : size(0), count(0), elements(0), scale(DEFAULT_SCALE) {} 20 | inline SmartContainer(size_t num_elements) : count(0) 21 | { 22 | scale = DEFAULT_SCALE; 23 | elements = static_cast(malloc(sizeof(T) * num_elements)); 24 | if (!elements) 25 | size = 0; 26 | else 27 | size = num_elements; 28 | } 29 | 30 | inline ~SmartContainer() 31 | { 32 | reset(); 33 | } 34 | 35 | inline T& operator[] (int index) { return elements[index]; } 36 | 37 | inline bool prepare(size_t amount) 38 | { 39 | if (count + amount <= size) 40 | return true; 41 | size_t new_size = (size_t)(pow(2.0, ceil(log2((double)(size + amount))))); 42 | return resize(new_size); 43 | } 44 | 45 | inline bool prepare_exact(size_t amount) 46 | { 47 | if (count + amount <= size) 48 | return true; 49 | return resize(size + amount); 50 | } 51 | 52 | inline bool resize(size_t new_size) 53 | { 54 | if (!elements) 55 | { 56 | elements = static_cast(malloc(sizeof(T) * new_size)); 57 | if (!elements) 58 | return false; 59 | } 60 | else 61 | { 62 | T* new_p = static_cast(realloc((void*)elements, sizeof(T) * new_size)); 63 | if (!new_p) 64 | return false; 65 | elements = new_p; 66 | } 67 | size = new_size; 68 | return true; 69 | } 70 | 71 | inline bool shrink() 72 | { 73 | if (!elements) 74 | return true; 75 | 76 | assert(count < size); 77 | if (!count) 78 | { 79 | free(elements); 80 | elements = 0; 81 | size = 0; 82 | return true; 83 | } 84 | 85 | realloc((void*)elements, sizeof(T) * count); 86 | size = count; 87 | return true; 88 | } 89 | 90 | inline bool push_back(const T& other) 91 | { 92 | if (count >= size) 93 | { 94 | if (!resize((!size ? DEFAULT_SIZE : size * scale))) 95 | return false; 96 | } 97 | 98 | elements[count++] = other; 99 | return true; 100 | } 101 | 102 | inline bool push_back(const SmartContainer& other) 103 | { 104 | if (!other.count) 105 | return true; 106 | if (!prepare(other.count)) 107 | return false; 108 | memcpy(elements + count, other.elements, sizeof(T) * other.count); 109 | count += other.count; 110 | return true; 111 | } 112 | 113 | inline bool push_back(const T* other, size_t _count) 114 | { 115 | if (!_count) 116 | return true; 117 | if (!prepare(_count)) 118 | return false; 119 | memcpy(elements + count, other, sizeof(T) * _count); 120 | count += _count; 121 | return true; 122 | } 123 | 124 | inline void zero() 125 | { 126 | if (!elements || !size) 127 | return; 128 | 129 | memset(elements, 0, sizeof(T) * size); 130 | } 131 | 132 | inline void reset() 133 | { 134 | size = 0; 135 | count = 0; 136 | free(elements); 137 | elements = 0; 138 | } 139 | }; 140 | -------------------------------------------------------------------------------- /BinaryMeshFitting/Texture.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" 2 | #include "Texture.hpp" 3 | 4 | #define STB_IMAGE_IMPLEMENTATION 5 | #include "stb_image.h" 6 | 7 | Texture::Texture() 8 | { 9 | id = 0; 10 | initialized = false; 11 | } 12 | 13 | Texture::~Texture() 14 | { 15 | if (initialized) 16 | { 17 | glDeleteTextures(1, &id); 18 | initialized = false; 19 | } 20 | } 21 | 22 | bool Texture::load_from_file(std::string filename) 23 | { 24 | unsigned char* rgb = stbi_load(filename.c_str(), &width, &height, &bpp, 3); 25 | if (!rgb) 26 | return false; 27 | 28 | init(rgb); 29 | 30 | stbi_image_free(rgb); 31 | 32 | return true; 33 | } 34 | 35 | void Texture::init(unsigned char* src) 36 | { 37 | glGenTextures(1, &id); 38 | glBindTexture(GL_TEXTURE_2D, id); 39 | 40 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 41 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 42 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 43 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 44 | 45 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei)width, (GLsizei)height, 0, GL_RGB, GL_UNSIGNED_BYTE, src); 46 | 47 | glBindTexture(GL_TEXTURE_2D, 0); 48 | 49 | initialized = true; 50 | } 51 | 52 | void Texture::init(int width, int height, int length, unsigned char* src) 53 | { 54 | this->width = width; 55 | this->height = height; 56 | this->length = length; 57 | 58 | glGenTextures(1, &id); 59 | glBindTexture(GL_TEXTURE_3D, id); 60 | 61 | glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 62 | glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 63 | glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_MIRRORED_REPEAT); 64 | glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); 65 | glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); 66 | 67 | glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, (GLsizei)width, (GLsizei)height, (GLsizei)length, 0, GL_RGB, GL_UNSIGNED_BYTE, src); 68 | 69 | glBindTexture(GL_TEXTURE_3D, 0); 70 | 71 | initialized = true; 72 | } 73 | -------------------------------------------------------------------------------- /BinaryMeshFitting/Texture.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #define GLFW_DLL 4 | #include 5 | #include 6 | #include 7 | 8 | class Texture 9 | { 10 | public: 11 | GLuint id; 12 | 13 | bool initialized; 14 | int width; 15 | int height; 16 | int length; 17 | int bpp; 18 | 19 | Texture(); 20 | ~Texture(); 21 | 22 | bool load_from_file(std::string filename); 23 | void init(unsigned char* src); 24 | void init(int width, int height, int length, unsigned char* src); 25 | }; 26 | -------------------------------------------------------------------------------- /BinaryMeshFitting/ThreadDebug.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class ThreadDebug 9 | { 10 | public: 11 | ThreadDebug(const std::string& name) : _name(name) {} 12 | 13 | std::string _name; 14 | 15 | inline std::ostream& print() 16 | { 17 | time_t t = time(0); 18 | struct tm* now = localtime(&t); 19 | return std::cout << "[" << _name << " | " << std::setfill('0') << std::setw(2) << now->tm_hour << ":" << std::setw(2) << now->tm_min << ":" << std::setw(2) << now->tm_sec << "] "; 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /BinaryMeshFitting/Vertices.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PCH.h" 3 | #include 4 | 5 | struct DualVertex 6 | { 7 | bool boundary; 8 | uint8_t mask; 9 | uint32_t index; 10 | uint8_t valence; 11 | uint8_t init_valence; 12 | uint8_t adj_next; 13 | uint32_t adj_offset; 14 | uint16_t edge_mask; 15 | float s; 16 | glm::ivec3 xyz; 17 | glm::vec3 p; 18 | glm::vec3 n; 19 | glm::vec3 avg; 20 | glm::vec3 color; 21 | 22 | inline DualVertex() {} 23 | inline DualVertex(glm::vec3 pos, glm::vec3 norm) : p(pos), n(norm) {} 24 | }; 25 | 26 | struct DMC_Isovertex 27 | { 28 | uint32_t index; 29 | float value; 30 | bool boundary; 31 | glm::vec3 position; 32 | }; 33 | 34 | struct DMC_Edge 35 | { 36 | bool snapped; 37 | uint32_t grid_v0; 38 | uint32_t grid_v1; 39 | float length; 40 | DMC_Isovertex iso_vertex; 41 | }; 42 | 43 | struct DMC_Cell 44 | { 45 | uint16_t mask; 46 | DMC_Edge edges[3]; 47 | }; 48 | 49 | struct DMC_ImmediateCell 50 | { 51 | uint16_t mask; 52 | uint32_t iso_verts[20]; 53 | }; 54 | -------------------------------------------------------------------------------- /BinaryMeshFitting/WorldOctree.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Sampler.hpp" 4 | #include "WorldOctreeNode.hpp" 5 | #include "MemoryPool.h" 6 | #include "DMCChunk.hpp" 7 | #include "SmartContainer.hpp" 8 | #include "GLChunk.hpp" 9 | #include "ColorMapper.hpp" 10 | #include "WorldWatcher.hpp" 11 | #include "ResourceAllocator.hpp" 12 | #include "ChunkBlocks.hpp" 13 | #include "NoiseSampler.hpp" 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | struct WorldProperties 20 | { 21 | float split_multiplier; 22 | float group_multiplier; 23 | float size_modifier; 24 | int max_level; 25 | int min_level; 26 | int num_threads; 27 | int process_iters; 28 | int chunk_resolution; 29 | bool enable_stitching; 30 | float overlap; 31 | bool boundary_processing; 32 | 33 | __declspec(noinline) WorldProperties(); 34 | }; 35 | 36 | class WorldOctree 37 | { 38 | public: 39 | Sampler sampler; 40 | WorldProperties properties; 41 | WorldOctreeNode octree; 42 | MemoryPool node_pool; 43 | MemoryPool chunk_pool; 44 | std::list leaves; 45 | SmartContainer v_out; 46 | SmartContainer i_out; 47 | GLChunk outline_chunk; 48 | int next_chunk_id; 49 | NoiseSamplers::NoiseSamplerProperties noise_properties; 50 | 51 | uint32_t leaf_count; 52 | glm::vec3 focus_point; 53 | 54 | ColorMapper color_mapper; 55 | 56 | WorldWatcher watcher; 57 | 58 | std::atomic generator_shutdown; 59 | std::mutex chunk_mutex; 60 | 61 | WorldOctree(); 62 | ~WorldOctree(); 63 | 64 | void destroy_leaves(); 65 | void init(uint32_t size); 66 | void split_leaves(); 67 | bool split_node(WorldOctreeNode* n); 68 | bool group_node(WorldOctreeNode* n); 69 | bool node_needs_split(const glm::vec3& center, WorldOctreeNode* n); 70 | bool node_needs_group(const glm::vec3& center, WorldOctreeNode* n); 71 | void create_chunk(WorldOctreeNode* n); 72 | void upload_batch(SmartContainer& batch); 73 | void generate_outline(SmartContainer& batch); 74 | DMCChunk* get_chunk_id_at(glm::vec3 p); 75 | 76 | void init_updates(glm::vec3 focus_pos); 77 | void process_from_render_thread(); 78 | 79 | private: 80 | }; -------------------------------------------------------------------------------- /BinaryMeshFitting/WorldStitcher.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "ThreadDebug.hpp" 10 | #include "SmartContainer.hpp" 11 | #include "GLChunk.hpp" 12 | #include "HashMap.hpp" 13 | #include "WorldOctreeNode.hpp" 14 | #include "sparsepp/spp.h" 15 | #include 16 | #include "DynamicGLChunk.hpp" 17 | 18 | typedef enum STITCHING_STAGES 19 | { 20 | STITCHING_STAGES_READY = 0, 21 | STITCHING_STAGES_STITCHING = 1, 22 | STITCHING_STAGES_AWAITING_SYNC = 2, 23 | STITCHING_STAGES_NEEDS_ACKNOWLEDGEMENT = 3, 24 | STITCHING_STAGES_ACKNOWLEDGED = 4, 25 | STITCHING_STAGES_NEEDS_UPLOAD = 5, 26 | STITCHING_STAGES_UPLOADING = 6, 27 | STITCHING_STAGES_UPLOADED = 7 28 | }; 29 | 30 | class WorldStitcher 31 | { 32 | public: 33 | WorldStitcher(); 34 | ~WorldStitcher(); 35 | 36 | void init(); 37 | void stitch_all(class WorldOctreeNode* root); 38 | void stitch_all(emilib::HashMap& leaves, spp::sparse_hash_map& chunk_nodes); 39 | void stitch_all_linear(emilib::HashMap& chunks); 40 | 41 | void upload(); 42 | void format(); 43 | 44 | void gather_marked_cells(SmartContainer& in_out); 45 | void stitch_batch(SmartContainer& batch); 46 | 47 | std::mutex _mutex; 48 | std::atomic stage; 49 | 50 | GLChunk gl_chunk; 51 | DynamicGLChunk dynamic_chunk; 52 | 53 | private: 54 | SmartContainer vertices; 55 | SmartContainer v_containers[8]; 56 | 57 | void gather_all_cells(WorldOctreeNode* n, SmartContainer& out); 58 | 59 | void stitch_cell(class OctreeNode* n, SmartContainer& v_out, bool allow_children = true); 60 | 61 | void stitch_face_xy(class OctreeNode* n0, class OctreeNode* n1, SmartContainer& v_out); 62 | void stitch_face_zy(class OctreeNode* n0, class OctreeNode* n1, SmartContainer& v_out); 63 | void stitch_face_xz(class OctreeNode* n0, class OctreeNode* n1, SmartContainer& v_out); 64 | 65 | void stitch_edge_x(class OctreeNode* n0, class OctreeNode* n1, class OctreeNode* n2, class OctreeNode* n3, SmartContainer& v_out); 66 | void stitch_edge_y(class OctreeNode* n0, class OctreeNode* n1, class OctreeNode* n2, class OctreeNode* n3, SmartContainer& v_out); 67 | void stitch_edge_z(class OctreeNode* n0, class OctreeNode* n1, class OctreeNode* n2, class OctreeNode* n3, SmartContainer& v_out); 68 | 69 | void stitch_indexes(class OctreeNode* n[8], SmartContainer& v_out); 70 | 71 | void mark_chunks(WorldOctreeNode* n, emilib::HashMap& leaves, SmartContainer& dest); 72 | bool stitch_dual_chunk(WorldOctreeNode* n, SmartContainer& v_out, emilib::HashMap& chunk_nodes); 73 | void stitch_primal(MortonCode& morton_code, SmartContainer& v_out, emilib::HashMap& chunk_nodes); 74 | 75 | int key2level(uint64_t key); 76 | void leaf2vert(uint64_t k, uint64_t* v_out, int* lv); 77 | void vert2leaf(uint64_t v, int lv, uint64_t* n_out); 78 | void stitch_mc(DMCNode* nodes[8], SmartContainer& v_out); 79 | }; 80 | -------------------------------------------------------------------------------- /BinaryMeshFitting/WorldWatcher.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "ThreadDebug.hpp" 10 | #include "SmartContainer.hpp" 11 | #include "ChunkGenerator.hpp" 12 | #include "WorldOctreeNode.hpp" 13 | #include "HashMap.hpp" 14 | #include "sparsepp/spp.h" 15 | #include 16 | 17 | class WorldWatcher : public ThreadDebug 18 | { 19 | public: 20 | WorldWatcher(); 21 | ~WorldWatcher(); 22 | 23 | void init(class WorldOctree* _world, glm::vec3 focus_pos); 24 | void update(); 25 | void stop(); 26 | 27 | glm::vec3 focus_pos; 28 | glm::vec3 last_focus_pos; 29 | 30 | std::mutex _mutex; 31 | std::mutex renderables_mutex; 32 | 33 | WorldOctreeNode* renderables_head; 34 | WorldOctreeNode* renderables_tail; 35 | SmartContainer destroy_watchlist; 36 | std::atomic renderables_count; 37 | ChunkGenerator generator; 38 | std::condition_variable upload_cv; 39 | 40 | emilib::HashMap leaf_nodes; 41 | //emilib::HashMap chunk_nodes; 42 | spp::sparse_hash_map chunk_nodes; 43 | //std::map chunk_nodes; 44 | 45 | private: 46 | class WorldOctree* world; 47 | std::thread _thread; 48 | std::atomic _stop; 49 | 50 | void check_leaves(SmartContainer& batch_out, const int max_gen); 51 | void handle_split_check(class WorldOctreeNode* n, SmartContainer& batch_out); 52 | void handle_group_check(class WorldOctreeNode* n, SmartContainer& batch_out); 53 | 54 | void process_batch(SmartContainer& batch_in, SmartContainer& batch_out, SmartContainer& stitch_batch); 55 | void post_process_batch(SmartContainer& batch_in); 56 | void split_node(class WorldOctreeNode* n, SmartContainer& generate_batch_out, SmartContainer& stitch_batch); 57 | void group_node_1(class WorldOctreeNode* n, SmartContainer& generate_batch_out); 58 | void process_stitching(SmartContainer& batch_in); 59 | 60 | void unlink_renderable(class WorldOctreeNode* n); 61 | void push_back_renderable(class WorldOctreeNode* n); 62 | 63 | void add_leaves(class WorldOctreeNode* n); 64 | }; 65 | -------------------------------------------------------------------------------- /BinaryMeshFitting/avx/README: -------------------------------------------------------------------------------- 1 | ########################################### 2 | ################# AVX ################# 3 | ########################################### 4 | 5 | 6 | 1. Floating Point 7 | =========================================== 8 | Uses full 256bit vectors for all operations. 128bit vectors are never used. 9 | 10 | 11 | 2. Integer 12 | =========================================== 13 | Integer support in AVX is minimal. 14 | The 256bit integer vectors are just intended as a supporting type of float operations. 15 | 16 | Any arithmetic, logical, or comparison operations must be implemented using 128bit operations. 17 | 18 | int_v/uint_v could be implemented either as 128 or 256 types. I.e. either int_v::Size == 4 or 8. 19 | 20 | 21 | 2.1. 256bit int vectors 22 | =========================================== 23 | 24 | 2.1.1. Implementation Details: 25 | This requires the SSE operations to not zero the high bits of the registers. Since the YMM registers 26 | are aliased on the XMM registers you need to use SSE ops that are not using the VEX prefix (IIUC). 27 | Or you have to use two XMM registers most of the time. 28 | Perfect would be the use of 29 | union M256I { 30 | __m256i ymm; 31 | __m128i xmm[2]; 32 | }; 33 | But as far as I know GCC, this will result in lots of unnecessary loads and stores. (It seems this is 34 | due to GCC expecting aliasing, thus making sure the modified values are always up-to-date in memory 35 | - like if it were declared volatile.) 36 | 37 | 2.1.2. Upsides: 38 | int_v::Size == float_v::Size 39 | 40 | 2.1.3. Downsides: 41 | Register pressure is increased. 42 | 43 | 2.2. 128bit int vectors 44 | =========================================== 45 | 46 | 2.2.1. Implementation Details: 47 | 48 | 2.2.2. Upsides: 49 | 50 | 2.2.3. Downsides: 51 | - Use of int_v for float_v operations involving __m256i arguments require an extra type. This will 52 | be hard to generalize 53 | 54 | 55 | 2.3. Mixed approach 56 | =========================================== 57 | int_v/uint_v are implemented as 256bit while short_v/ushort_v are implemented as 128bit. Thus 58 | int_v::Size == short_v::Size (which is the case on LRBni, too). 59 | -------------------------------------------------------------------------------- /BinaryMeshFitting/avx/macros.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "../common/macros.h" 29 | 30 | #ifndef VC_AVX_MACROS_H_ 31 | #define VC_AVX_MACROS_H_ 32 | 33 | #endif // VC_AVX_MACROS_H_ 34 | -------------------------------------------------------------------------------- /BinaryMeshFitting/avx/simd_cast_caller.tcc: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef Vc_AVX_SIMD_CAST_CALLER_TCC_ 29 | #define Vc_AVX_SIMD_CAST_CALLER_TCC_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | #if Vc_IS_VERSION_1 36 | template 37 | template 38 | Vc_INTRINSIC Vector::Vector(U &&x) 39 | : d(simd_cast(std::forward(x)).data()) 40 | { 41 | } 42 | 43 | template 44 | template 45 | Vc_INTRINSIC Mask::Mask(U &&rhs, 46 | Common::enable_if_mask_converts_explicitly) 47 | : Mask(simd_cast(std::forward(rhs))) 48 | { 49 | } 50 | #endif // Vc_IS_VERSION_1 51 | } 52 | 53 | #endif // Vc_AVX_SIMD_CAST_CALLER_TCC_ 54 | 55 | // vim: foldmethod=marker 56 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/bitscanintrinsics.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2011-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_BITSCANINTRINSICS_H_ 29 | #define VC_COMMON_BITSCANINTRINSICS_H_ 30 | 31 | #if defined(Vc_GCC) || defined(Vc_CLANG) || defined(Vc_APPLECLANG) 32 | # if Vc_GCC >= 0x40500 33 | // GCC 4.5.0 introduced _bit_scan_forward / _bit_scan_reverse 34 | # include 35 | # else 36 | // GCC <= 4.4 and clang have x86intrin.h, but not the required functions 37 | # define _bit_scan_forward(x) __builtin_ctz(x) 38 | #include "macros.h" 39 | static Vc_ALWAYS_INLINE Vc_CONST int _Vc_bit_scan_reverse_asm(unsigned int x) { 40 | int r; 41 | __asm__("bsr %1,%0" : "=r"(r) : "X"(x)); 42 | return r; 43 | } 44 | # define _bit_scan_reverse(x) _Vc_bit_scan_reverse_asm(x) 45 | # endif 46 | #elif defined(_WIN32) 47 | #include 48 | static inline __forceinline unsigned long _bit_scan_forward(unsigned long x) { 49 | unsigned long index; 50 | _BitScanForward(&index, x); 51 | return index; 52 | } 53 | static inline __forceinline unsigned long _bit_scan_reverse(unsigned long x) { 54 | unsigned long index; 55 | _BitScanReverse(&index, x); 56 | return index; 57 | } 58 | #elif defined(Vc_ICC) 59 | // for all I know ICC supports the _bit_scan_* intrinsics 60 | #else 61 | // just assume the compiler can do it 62 | #endif 63 | 64 | 65 | #endif // VC_COMMON_BITSCANINTRINSICS_H_ 66 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/data.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2013-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_CONST_DATA_H_ 29 | #define VC_COMMON_CONST_DATA_H_ 30 | 31 | #include "macros.h" 32 | namespace Vc_VERSIONED_NAMESPACE 33 | { 34 | namespace Common 35 | { 36 | 37 | alignas(64) extern unsigned int RandomState[]; 38 | alignas(32) extern const unsigned int AllBitsSet[8]; 39 | 40 | } // namespace Common 41 | } // namespace Vc 42 | 43 | #endif // VC_COMMON_CONST_DATA_H_ 44 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/fix_clang_emmintrin.h: -------------------------------------------------------------------------------- 1 | /*{{{ 2 | Copyright (C) 2013-2015 Matthias Kretz 3 | 4 | Permission to use, copy, modify, and distribute this software 5 | and its documentation for any purpose and without fee is hereby 6 | granted, provided that the above copyright notice appear in all 7 | copies and that both that the copyright notice and this 8 | permission notice and warranty disclaimer appear in supporting 9 | documentation, and that the name of the author not be used in 10 | advertising or publicity pertaining to distribution of the 11 | software without specific, written prior permission. 12 | 13 | The author disclaim all warranties with regard to this 14 | software, including all implied warranties of merchantability 15 | and fitness. In no event shall the author be liable for any 16 | special, indirect or consequential damages or any damages 17 | whatsoever resulting from loss of use, data or profits, whether 18 | in an action of contract, negligence or other tortious action, 19 | arising out of or in connection with the use or performance of 20 | this software. 21 | 22 | }}}*/ 23 | 24 | #ifndef VC_COMMON_FIX_CLANG_EMMINTRIN_H_ 25 | #define VC_COMMON_FIX_CLANG_EMMINTRIN_H_ 26 | 27 | #include 28 | 29 | #if (defined Vc_CLANG && Vc_CLANG < 0x30700) || (defined Vc_APPLECLANG && Vc_APPLECLANG < 0x70000) 30 | 31 | #ifdef _mm_slli_si128 32 | #undef _mm_slli_si128 33 | #define _mm_slli_si128(a, count) __extension__ ({ \ 34 | (__m128i)__builtin_ia32_pslldqi128((__m128i)(a), (count)*8); }) 35 | #endif 36 | 37 | #ifdef _mm_srli_si128 38 | #undef _mm_srli_si128 39 | #define _mm_srli_si128(a, count) __extension__ ({ \ 40 | (__m128i)__builtin_ia32_psrldqi128((__m128i)(a), (count)*8); }) 41 | #endif 42 | 43 | #ifdef _mm_shuffle_epi32 44 | #undef _mm_shuffle_epi32 45 | #define _mm_shuffle_epi32(a, imm) __extension__ ({ \ 46 | (__m128i)__builtin_shufflevector((__v4si)(__m128i)(a), (__v4si) _mm_set1_epi32(0), \ 47 | (imm) & 0x3, ((imm) & 0xc) >> 2, \ 48 | ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6); }) 49 | #endif 50 | 51 | #ifdef _mm_shufflelo_epi16 52 | #undef _mm_shufflelo_epi16 53 | #define _mm_shufflelo_epi16(a, imm) __extension__ ({ \ 54 | (__m128i)__builtin_shufflevector((__v8hi)(__m128i)(a), (__v8hi) _mm_set1_epi16(0), \ 55 | (imm) & 0x3, ((imm) & 0xc) >> 2, \ 56 | ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6, \ 57 | 4, 5, 6, 7); }) 58 | #endif 59 | 60 | #ifdef _mm_shufflehi_epi16 61 | #undef _mm_shufflehi_epi16 62 | #define _mm_shufflehi_epi16(a, imm) __extension__ ({ \ 63 | (__m128i)__builtin_shufflevector((__v8hi)(__m128i)(a), (__v8hi) _mm_set1_epi16(0), \ 64 | 0, 1, 2, 3, \ 65 | 4 + (((imm) & 0x03) >> 0), \ 66 | 4 + (((imm) & 0x0c) >> 2), \ 67 | 4 + (((imm) & 0x30) >> 4), \ 68 | 4 + (((imm) & 0xc0) >> 6)); }) 69 | #endif 70 | 71 | #ifdef _mm_shuffle_pd 72 | #undef _mm_shuffle_pd 73 | #define _mm_shuffle_pd(a, b, i) __extension__ ({ \ 74 | __builtin_shufflevector((__m128d)(a), (__m128d)(b), (i) & 1, (((i) & 2) >> 1) + 2); }) 75 | #endif 76 | 77 | #endif // Vc_CLANG || Vc_APPLECLANG 78 | 79 | #endif // VC_COMMON_FIX_CLANG_EMMINTRIN_H_ 80 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/generalinterface.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | public: 29 | /////////////////////////////////////////////////////////////////////////// 30 | // init to zero 31 | Vector() = default; 32 | 33 | /////////////////////////////////////////////////////////////////////////// 34 | // types 35 | 36 | /////////////////////////////////////////////////////////////////////////// 37 | // constants 38 | static constexpr std::size_t size() { return Size; } 39 | 40 | /////////////////////////////////////////////////////////////////////////// 41 | // constant Vectors 42 | explicit Vc_INTRINSIC_L Vector(VectorSpecialInitializerZero) Vc_INTRINSIC_R; 43 | explicit Vc_INTRINSIC_L Vector(VectorSpecialInitializerOne) Vc_INTRINSIC_R; 44 | explicit Vc_INTRINSIC_L Vector(VectorSpecialInitializerIndexesFromZero) Vc_INTRINSIC_R; 45 | static Vc_INTRINSIC Vc_CONST Vector Zero() { return Vector(Vc::Zero); } 46 | static Vc_INTRINSIC Vc_CONST Vector One() { return Vector(Vc::One); } 47 | static Vc_INTRINSIC Vc_CONST Vector IndexesFromZero() 48 | { 49 | return Vector(Vc::IndexesFromZero); 50 | } 51 | 52 | // vim: foldmethod=marker 53 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/indexsequence.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_INDEXSEQUENCE_H_ 29 | #define VC_COMMON_INDEXSEQUENCE_H_ 30 | 31 | #include 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | /** \internal 36 | * Helper class for a sequence of size_t values from 0 to N. This type will be included in 37 | * C++14. 38 | */ 39 | template struct index_sequence 40 | { 41 | static constexpr std::size_t size() noexcept { return sizeof...(I); } 42 | }; 43 | 44 | /** \internal 45 | * This struct builds an index_sequence type from a given upper bound \p N. 46 | * It does so recursively via concatenation of to index sequences of length N/2. 47 | */ 48 | template struct make_index_sequence_impl { 49 | template 50 | static index_sequence join(std::false_type, 51 | index_sequence); 52 | template 53 | static index_sequence join( 54 | std::true_type, index_sequence); 55 | 56 | using is_odd = std::integral_constant; 57 | using half = typename make_index_sequence_impl::type; 58 | using type = decltype(join<(N + 1) / 2>(is_odd(), half())); 59 | }; 60 | template <> struct make_index_sequence_impl<0> { 61 | using type = index_sequence<>; 62 | }; 63 | template <> struct make_index_sequence_impl<1> { 64 | using type = index_sequence<0>; 65 | }; 66 | template <> struct make_index_sequence_impl<2> { 67 | using type = index_sequence<0, 1>; 68 | }; 69 | 70 | /** \internal 71 | * Creates an index_sequence type for the upper bound \p N. 72 | */ 73 | template 74 | using make_index_sequence = typename make_index_sequence_impl::type; 75 | } 76 | 77 | #endif // VC_COMMON_INDEXSEQUENCE_H_ 78 | 79 | // vim: foldmethod=marker 80 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/interleave.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_INTERLEAVE_H_ 29 | #define VC_COMMON_INTERLEAVE_H_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | /** \ingroup Utilities 36 | Interleaves the entries from \p a and \p b into two vectors of the same type. The order 37 | in the returned vector contains the elements `a[0], b[0], a[1], b[1], a[2], b[2], a[3], 38 | b[3], ...`. 39 | 40 | Example: 41 | \code 42 | Vc::SimdArray a = { 1, 2, 3, 4 }; 43 | Vc::SimdArray b = { 9, 8, 7, 6 }; 44 | std::tie(a, b) = Vc::interleave(a, b); 45 | std::cout << a << b; 46 | // prints: 47 | // <1 9 2 8><3 7 4 6> 48 | \endcode 49 | 50 | \param a input vector whose data will appear at even indexes in the output 51 | \param b input vector whose data will appear at odd indexes in the output 52 | \return two vectors with data from \p a and \p b interleaved 53 | */ 54 | template ::value>> 55 | std::pair interleave(const V &a, const V &b) 56 | { 57 | return {a.interleaveLow(b), a.interleaveHigh(b)}; 58 | } 59 | } // namespace Vc 60 | 61 | #endif // VC_COMMON_INTERLEAVE_H_ 62 | 63 | // vim: foldmethod=marker 64 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/make_unique.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2013-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_MAKE_UNIQUE_H_ 29 | #define VC_COMMON_MAKE_UNIQUE_H_ 30 | 31 | #include 32 | 33 | #include "macros.h" 34 | 35 | namespace Vc_VERSIONED_NAMESPACE 36 | { 37 | namespace Common 38 | { 39 | 40 | template struct Deleter 41 | { 42 | Vc_ALWAYS_INLINE void operator()(T *ptr) { 43 | ptr->~T(); 44 | Vc::free(ptr); 45 | } 46 | }; 47 | 48 | template 49 | inline std::unique_ptr> make_unique(Args&&... args) 50 | { 51 | return std::unique_ptr>(new(Vc::malloc(1)) T(std::forward(args)...)); 52 | } 53 | 54 | } // namespace Common 55 | } // namespace Vc 56 | 57 | #endif // VC_COMMON_MAKE_UNIQUE_H_ 58 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/memoryfwd.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2011-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_MEMORYFWD_H_ 29 | #define VC_COMMON_MEMORYFWD_H_ 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | namespace Common 34 | { 35 | template 37 | class Memory; 38 | 39 | template 40 | class MemoryBase; 41 | } // namespace Common 42 | 43 | using Common::Memory; 44 | } // namespace Vc 45 | 46 | #endif // VC_COMMON_MEMORYFWD_H_ 47 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/permutation.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_PERMUTATION_H_ 29 | #define VC_COMMON_PERMUTATION_H_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Permutation 36 | { 37 | struct ReversedTag {}; 38 | constexpr ReversedTag Reversed{}; 39 | } // namespace Permutation 40 | } 41 | 42 | #endif // VC_COMMON_PERMUTATION_H_ 43 | 44 | // vim: foldmethod=marker 45 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/simd_cast.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_SIMD_CAST_H_ 29 | #define VC_COMMON_SIMD_CAST_H_ 30 | 31 | #include 32 | #include "macros.h" 33 | 34 | // declare a bogus simd_cast function template in the global namespace to enable ADL for 35 | // simd_cast 36 | template void simd_cast(); 37 | 38 | namespace Vc_VERSIONED_NAMESPACE 39 | { 40 | /** 41 | * Casts the argument \p x from type \p From to type \p To. 42 | * 43 | * This function implements the trivial case where \p To and \p From are the same type. 44 | * 45 | * \param x The object of type \p From to be converted to type \p To. 46 | * \returns An object of type \p To with all vector components converted according to 47 | * standard conversion behavior as mandated by the C++ standard for the 48 | * underlying arithmetic types. 49 | */ 50 | template 51 | Vc_INTRINSIC Vc_CONST To 52 | simd_cast(From &&x, enable_if>::value> = nullarg) 53 | { 54 | return std::forward(x); 55 | } 56 | 57 | /** 58 | * A cast from nothing results in default-initialization of \p To. 59 | * 60 | * This function can be useful in generic code where a parameter pack expands to nothing. 61 | * 62 | * \returns A zero-initialized object of type \p To. 63 | */ 64 | template Vc_INTRINSIC Vc_CONST To simd_cast() { return To(); } 65 | 66 | } // namespace Vc 67 | 68 | #endif // VC_COMMON_SIMD_CAST_H_ 69 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/support.h: -------------------------------------------------------------------------------- 1 | #ifndef VC_DEPRECATED_COMMON_SUPPORT_H_ 2 | #define VC_DEPRECATED_COMMON_SUPPORT_H_ 3 | #ifdef __GNUC__ 4 | #warning "the header is deprecated. Use instead." 5 | #endif 6 | #include 7 | #endif // VC_DEPRECATED_COMMON_SUPPORT_H_ 8 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/transpose.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_TRANSPOSE_H_ 29 | #define VC_COMMON_TRANSPOSE_H_ 30 | 31 | #include "macros.h" 32 | #include 33 | 34 | namespace Vc_VERSIONED_NAMESPACE 35 | { 36 | namespace Common 37 | { 38 | template struct TransposeProxy 39 | { 40 | TransposeProxy(const Inputs &... inputs) : in{inputs...} {} 41 | 42 | std::tuple in; 43 | }; 44 | 45 | template struct TransposeTag { 46 | }; 47 | } // namespace Common 48 | 49 | template Common::TransposeProxy transpose(Vs... vs) 50 | { 51 | return {vs...}; 52 | } 53 | } // namespace Vc 54 | 55 | #endif // VC_COMMON_TRANSPOSE_H_ 56 | 57 | // vim: foldmethod=marker 58 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/vector/casts.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | public: 29 | /////////////////////////////////////////////////////////////////////////////////////////// 30 | // casts - implemented in simd_cast_caller.tcc 31 | 32 | // implict conversion from compatible Vector 33 | template 34 | Vc_INTRINSIC_L Vector( 35 | U &&x, 36 | enable_if>::value && 37 | !std::is_same>::value && 38 | Traits::is_implicit_cast_allowed, T>::value> = 39 | nullarg) Vc_INTRINSIC_R; 40 | 41 | // static_cast from other types 42 | template 43 | Vc_INTRINSIC_L explicit Vector(U &&x, 44 | enable_if::value && 45 | !std::is_same>::value>> 46 | = nullarg) Vc_INTRINSIC_R; 47 | 48 | /////////////////////////////////////////////////////////////////////////////////////////// 49 | // broadcast 50 | Vc_INTRINSIC Vector(EntryType a); 51 | template 52 | Vc_INTRINSIC Vector( 53 | U a, 54 | typename std::enable_if::value && !std::is_same::value, 55 | void *>::type = nullptr) 56 | : Vector(static_cast(a)) 57 | { 58 | } 59 | 60 | /////////////////////////////////////////////////////////////////////////////////////////// 61 | // explicitly forbid construction from initializer_list 62 | explicit Vector(std::initializer_list) 63 | { 64 | static_assert(std::is_same::value, 65 | "A SIMD vector object cannot be initialized from an initializer list " 66 | "because the number of entries in the vector is target-dependent."); 67 | } 68 | 69 | // vim: foldmethod=marker 70 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/vectorabi.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_VECTORABI_H_ 29 | #define VC_COMMON_VECTORABI_H_ 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | namespace VectorAbi 34 | { 35 | struct Scalar {}; 36 | struct Sse {}; 37 | struct Avx {}; 38 | struct Mic {}; 39 | template 40 | using Avx1Abi = typename std::conditional::value, VectorAbi::Sse, 41 | VectorAbi::Avx>::type; 42 | template 43 | using Best = typename std::conditional< 44 | CurrentImplementation::is(ScalarImpl), Scalar, 45 | typename std::conditional< 46 | CurrentImplementation::is_between(SSE2Impl, SSE42Impl), Sse, 47 | typename std::conditional< 48 | CurrentImplementation::is(AVXImpl), Avx1Abi, 49 | typename std::conditional< 50 | CurrentImplementation::is(AVX2Impl), Avx, 51 | typename std::conditional::type>::type>::type>::type>::type; 53 | #ifdef Vc_IMPL_AVX2 54 | static_assert(std::is_same, Avx>::value, ""); 55 | static_assert(std::is_same, Avx>::value, ""); 56 | #elif defined Vc_IMPL_AVX 57 | static_assert(std::is_same, Avx>::value, ""); 58 | static_assert(std::is_same, Sse>::value, ""); 59 | #elif defined Vc_IMPL_SSE 60 | static_assert(CurrentImplementation::is_between(SSE2Impl, SSE42Impl), ""); 61 | static_assert(std::is_same, Sse>::value, ""); 62 | static_assert(std::is_same, Sse>::value, ""); 63 | #elif defined Vc_IMPL_MIC 64 | static_assert(std::is_same, Mic>::value, ""); 65 | static_assert(std::is_same, Mic>::value, ""); 66 | #elif defined Vc_IMPL_Scalar 67 | static_assert(std::is_same, Scalar>::value, ""); 68 | static_assert(std::is_same, Scalar>::value, ""); 69 | #endif 70 | } // namespace VectorAbi 71 | } // namespace Vc 72 | 73 | #endif // VC_COMMON_VECTORABI_H_ 74 | 75 | // vim: foldmethod=marker 76 | -------------------------------------------------------------------------------- /BinaryMeshFitting/common/vectortraits.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_VECTORTRAITS_H_ 29 | #define VC_COMMON_VECTORTRAITS_H_ 30 | 31 | #include "vectorabi.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | template struct VectorTraits; 36 | } // namespace Vc 37 | 38 | #endif // VC_COMMON_VECTORTRAITS_H_ 39 | 40 | // vim: foldmethod=marker 41 | -------------------------------------------------------------------------------- /BinaryMeshFitting/imgui.ini: -------------------------------------------------------------------------------- 1 | [Window][Debug##Default] 2 | Pos=60,60 3 | Size=400,400 4 | Collapsed=0 5 | 6 | [Window][Another Window] 7 | Pos=60,60 8 | Size=232,262 9 | Collapsed=0 10 | 11 | [Window][Options] 12 | Pos=25,52 13 | Size=338,632 14 | Collapsed=0 15 | 16 | [Window][Noise] 17 | Pos=1397,60 18 | Size=172,216 19 | Collapsed=0 20 | 21 | -------------------------------------------------------------------------------- /BinaryMeshFitting/mic/const_data.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2013-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_MIC_CONST_DATA_H_ 29 | #define VC_MIC_CONST_DATA_H_ 30 | 31 | #include "../common/data.h" 32 | #include "macros.h" 33 | 34 | namespace Vc_VERSIONED_NAMESPACE 35 | { 36 | namespace MIC 37 | { 38 | 39 | alignas(16) extern const char _IndexesFromZero8[16]; 40 | 41 | struct alignas(64) c_general 42 | { 43 | static const float oneFloat; 44 | static const unsigned int absMaskFloat[2]; 45 | static const unsigned int signMaskFloat[2]; 46 | static const unsigned int highMaskFloat; 47 | static const unsigned short minShort[2]; 48 | static const unsigned short one16[2]; 49 | static const float _2power31; 50 | static const double oneDouble; 51 | static const unsigned long long frexpMask; 52 | static const unsigned long long highMaskDouble; 53 | static const unsigned char frexpAndMask[16]; 54 | }; 55 | 56 | } // namespace MIC 57 | } // namespace Vc 58 | 59 | #endif // VC_MIC_CONST_DATA_H_ 60 | -------------------------------------------------------------------------------- /BinaryMeshFitting/mic/debug.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2011-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_MIC_DEBUG_H_ 29 | #define VC_MIC_DEBUG_H_ 30 | 31 | #ifndef NDEBUG 32 | #include "vector.h" 33 | #include 34 | #include 35 | #endif 36 | 37 | namespace Vc_VERSIONED_NAMESPACE 38 | { 39 | namespace MIC 40 | { 41 | 42 | #ifdef NDEBUG 43 | class DebugStream 44 | { 45 | public: 46 | DebugStream(const char *, const char *, int) {} 47 | template inline DebugStream &operator<<(const T &) { return *this; } 48 | }; 49 | #else 50 | class DebugStream 51 | { 52 | private: 53 | template static void printVector(V _x) 54 | { 55 | enum { Size = sizeof(V) / sizeof(T) }; 56 | union { V v; T m[Size]; } x = { _x }; 57 | std::cerr << '[' << std::setprecision(24) << x.m[0]; 58 | for (int i = 1; i < Size; ++i) { 59 | std::cerr << ", " << std::setprecision(24) << x.m[i]; 60 | } 61 | std::cerr << ']'; 62 | } 63 | public: 64 | DebugStream(const char *func, const char *file, int line) 65 | { 66 | std::cerr << "\033[1;40;33mDEBUG: " << file << ':' << line << ' ' << func << ' '; 67 | } 68 | 69 | template DebugStream &operator<<(const T &x) { std::cerr << x; return *this; } 70 | 71 | DebugStream &operator<<(__m512 x) { 72 | printVector(x); 73 | return *this; 74 | } 75 | DebugStream &operator<<(__m512d x) { 76 | printVector(x); 77 | return *this; 78 | } 79 | DebugStream &operator<<(__m512i x) { 80 | printVector(x); 81 | return *this; 82 | } 83 | 84 | ~DebugStream() 85 | { 86 | std::cerr << "\033[0m" << std::endl; 87 | } 88 | }; 89 | #endif 90 | 91 | #define Vc_DEBUG Vc::MIC::DebugStream(__PRETTY_FUNCTION__, __FILE__, __LINE__) 92 | 93 | } // namespace MIC 94 | } // namespace Vc 95 | 96 | #endif // VC_MIC_DEBUG_H_ 97 | -------------------------------------------------------------------------------- /BinaryMeshFitting/mic/deinterleave.tcc: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2010-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | namespace Vc_VERSIONED_NAMESPACE 29 | { 30 | namespace Detail 31 | { 32 | template 33 | inline void deinterleave(V &a, V &b, const M *m, A) 34 | { 35 | const auto i = MIC::int_v::IndexesFromZero() << 1; 36 | a.data() = MicIntrinsics::gather(i.data(), m, MIC::UpDownConversion()); 37 | b.data() = MicIntrinsics::gather(i.data(), m + 1, MIC::UpDownConversion()); 38 | } 39 | } // namespace Detail 40 | } // namespace Vc 41 | -------------------------------------------------------------------------------- /BinaryMeshFitting/mic/helperimpl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2010-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_MIC_HELPERIMPL_H_ 29 | #define VC_MIC_HELPERIMPL_H_ 30 | 31 | #include "macros.h" 32 | #include "deinterleave.tcc" 33 | #include "prefetches.tcc" 34 | 35 | #endif // VC_MIC_HELPERIMPL_H_ 36 | -------------------------------------------------------------------------------- /BinaryMeshFitting/mic/limits.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2013-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_MIC_LIMITS_H_ 29 | #define VC_MIC_LIMITS_H_ 30 | #ifdef CAN_OFFLOAD 31 | #pragma offload_attribute(push, target(mic)) 32 | #endif 33 | 34 | namespace std 35 | { 36 | // no need for specializations as uses broadcasts and they work very efficently on MIC 37 | } // namespace std 38 | 39 | #ifdef CAN_OFFLOAD 40 | #pragma offload_attribute(pop) 41 | #endif 42 | #endif // VC_MIC_LIMITS_H_ 43 | -------------------------------------------------------------------------------- /BinaryMeshFitting/mic/macros.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2013-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "../common/macros.h" 29 | 30 | #ifndef VC_MIC_MACROS_H_ 31 | #define VC_MIC_MACROS_H_ 32 | 33 | #endif // VC_MIC_MACROS_H_ 34 | -------------------------------------------------------------------------------- /BinaryMeshFitting/mic/mask.tcc: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2013-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_MIC_MASK_TCC_ 29 | #define VC_MIC_MASK_TCC_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | template <> 36 | template 37 | inline void MIC::double_m::load(const bool *mem, Flags) 38 | { 39 | __m512i ones = _mm512_setzero_epi32(); 40 | ones = _mm512_mask_extloadunpacklo_epi32(ones, 0xff, mem, MIC::UpDownConversion().up(), _MM_HINT_NONE); 41 | ones = _mm512_mask_extloadunpackhi_epi32(ones, 0xff, mem + 64, MIC::UpDownConversion().up(), _MM_HINT_NONE); 42 | //const __m512i ones = _mm512_mask_extload_epi32(_mm512_setzero_epi32(), 0xff, mem, , _MM_BROADCAST32_NONE, _MM_HINT_NONE); 43 | k = _mm512_cmpneq_epi32_mask(ones, _mm512_setzero_epi32()); 44 | } 45 | 46 | template <> 47 | template 48 | inline void MIC::double_m::store(bool *mem, Flags) const 49 | { 50 | const __m512i zero = _mm512_setzero_epi32(); 51 | const __m512i one = _mm512_set1_epi32(1); 52 | const __m512i tmp = MIC::_and(zero, static_cast<__mmask16>(k), one, one); 53 | _mm512_mask_extpackstorelo_epi32(mem, 0xff, tmp, MIC::UpDownConversion().down(), _MM_HINT_NONE); 54 | _mm512_mask_extpackstorehi_epi32(mem + 64, 0xff, tmp, MIC::UpDownConversion().down(), _MM_HINT_NONE); 55 | } 56 | } // namespace Vc 57 | 58 | #endif // VC_MIC_MASK_TCC_ 59 | -------------------------------------------------------------------------------- /BinaryMeshFitting/mic/prefetches.tcc: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2010-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_MIC_PREFETCHES_TCC_ 29 | #define VC_MIC_PREFETCHES_TCC_ 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | namespace Detail 34 | { 35 | Vc_ALWAYS_INLINE void prefetchForOneRead(const void *addr, VectorAbi::Mic) 36 | { 37 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_NTA); 38 | } 39 | Vc_ALWAYS_INLINE void prefetchClose(const void *addr, VectorAbi::Mic) 40 | { 41 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_T0); 42 | } 43 | Vc_ALWAYS_INLINE void prefetchMid(const void *addr, VectorAbi::Mic) 44 | { 45 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_T1); 46 | } 47 | Vc_ALWAYS_INLINE void prefetchFar(const void *addr, VectorAbi::Mic) 48 | { 49 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_T2); 50 | } 51 | Vc_ALWAYS_INLINE void prefetchForModify(const void *addr, VectorAbi::Mic) 52 | { 53 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_ET0); 54 | } 55 | } // namespace Detail 56 | } // namespace Vc 57 | 58 | #endif // VC_MIC_PREFETCHES_TCC_ 59 | -------------------------------------------------------------------------------- /BinaryMeshFitting/mic/simd_cast_caller.tcc: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef Vc_MIC_SIMD_CAST_CALLER_TCC_ 29 | #define Vc_MIC_SIMD_CAST_CALLER_TCC_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | #if Vc_IS_VERSION_1 36 | template 37 | template 38 | Vc_INTRINSIC Mask::Mask( 39 | U &&rhs, Common::enable_if_mask_converts_explicitly) 40 | : Mask(simd_cast(std::forward(rhs))) 41 | { 42 | } 43 | #endif 44 | } // namespace Vc 45 | 46 | #endif // Vc_MIC_SIMD_CAST_CALLER_TCC_ 47 | 48 | // vim: foldmethod=marker 49 | -------------------------------------------------------------------------------- /BinaryMeshFitting/mic/sorthelper.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2013-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_MIC_SORTHELPER_H_ 29 | #define VC_MIC_SORTHELPER_H_ 30 | 31 | #include 32 | #include "types.h" 33 | #include "macros.h" 34 | 35 | namespace Vc_VERSIONED_NAMESPACE 36 | { 37 | namespace MIC 38 | { 39 | 40 | template struct SortHelper 41 | { 42 | typedef typename VectorTypeHelper::Type VectorType; 43 | static VectorType sort(VectorType); 44 | template static std::tuple sort(std::tuple); 45 | }; 46 | 47 | } // namespace MIC 48 | } // namespace Vc 49 | 50 | #endif // VC_MIC_SORTHELPER_H_ 51 | -------------------------------------------------------------------------------- /BinaryMeshFitting/mic/type_traits.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_MIC_TYPE_TRAITS_H_ 29 | #define VC_MIC_TYPE_TRAITS_H_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace MIC 36 | { 37 | namespace Traits 38 | { 39 | template struct is_vector : public std::false_type {}; 40 | template struct is_vector> : public std::true_type {}; 41 | 42 | template struct is_mask : public std::false_type {}; 43 | template struct is_mask> : public std::true_type {}; 44 | } // namespace Traits 45 | } // namespace MIC 46 | } // namespace Vc 47 | 48 | #endif // VC_MIC_TYPE_TRAITS_H_ 49 | 50 | // vim: foldmethod=marker 51 | -------------------------------------------------------------------------------- /BinaryMeshFitting/mic/types.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2010-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "../scalar/types.h" 29 | 30 | #ifndef VC_MIC_TYPES_H_ 31 | #define VC_MIC_TYPES_H_ 32 | 33 | #ifdef Vc_DEFAULT_IMPL_MIC 34 | #define Vc_DOUBLE_V_SIZE 8 35 | #define Vc_FLOAT_V_SIZE 16 36 | #define Vc_INT_V_SIZE 16 37 | #define Vc_UINT_V_SIZE 16 38 | #define Vc_SHORT_V_SIZE 16 39 | #define Vc_USHORT_V_SIZE 16 40 | #endif 41 | 42 | namespace Vc_VERSIONED_NAMESPACE 43 | { 44 | namespace MIC 45 | { 46 | template using Vector = Vc::Vector; 47 | typedef Vector double_v; 48 | typedef Vector float_v; 49 | typedef Vector int_v; 50 | typedef Vector uint_v; 51 | typedef Vector short_v; 52 | typedef Vector ushort_v; 53 | typedef Vector schar_v; 54 | typedef Vector uchar_v; 55 | 56 | template using Mask = Vc::Mask; 57 | typedef Mask double_m; 58 | typedef Mask float_m; 59 | typedef Mask int_m; 60 | typedef Mask uint_m; 61 | typedef Mask short_m; 62 | typedef Mask ushort_m; 63 | typedef Mask schar_m; 64 | typedef Mask uchar_m; 65 | 66 | template struct is_vector : public std::false_type {}; 67 | template struct is_vector> : public std::true_type {}; 68 | template struct is_mask : public std::false_type {}; 69 | template struct is_mask> : public std::true_type {}; 70 | } // namespace MIC 71 | 72 | namespace Traits 73 | { 74 | template struct is_simd_mask_internal> 75 | : public std::true_type {}; 76 | 77 | template struct 78 | is_simd_vector_internal> 79 | : public is_valid_vector_argument {}; 80 | } // namespace Traits 81 | } // namespace Vc 82 | 83 | #endif // VC_MIC_TYPES_H_ 84 | -------------------------------------------------------------------------------- /BinaryMeshFitting/scalar/helperimpl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2010-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_SCALAR_DEINTERLEAVE_H_ 29 | #define VC_SCALAR_DEINTERLEAVE_H_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Detail 36 | { 37 | template 38 | Vc_ALWAYS_INLINE void deinterleave(Scalar::Vector &a, Scalar::Vector &b, 39 | const M *mem, A) 40 | { 41 | a = mem[0]; 42 | b = mem[1]; 43 | } 44 | 45 | Vc_ALWAYS_INLINE void prefetchForOneRead(const void *, VectorAbi::Scalar) {} 46 | Vc_ALWAYS_INLINE void prefetchForModify(const void *, VectorAbi::Scalar) {} 47 | Vc_ALWAYS_INLINE void prefetchClose(const void *, VectorAbi::Scalar) {} 48 | Vc_ALWAYS_INLINE void prefetchMid(const void *, VectorAbi::Scalar) {} 49 | Vc_ALWAYS_INLINE void prefetchFar(const void *, VectorAbi::Scalar) {} 50 | } // namespace Detail 51 | } // namespace Vc 52 | 53 | #endif // VC_SCALAR_DEINTERLEAVE_H_ 54 | -------------------------------------------------------------------------------- /BinaryMeshFitting/scalar/limits.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_SCALAR_LIMITS_H_ 29 | #define VC_SCALAR_LIMITS_H_ 30 | 31 | 32 | #endif // VC_SCALAR_LIMITS_H_ 33 | -------------------------------------------------------------------------------- /BinaryMeshFitting/scalar/macros.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "../common/macros.h" 29 | 30 | #ifndef VC_SCALAR_MACROS_H_ 31 | #define VC_SCALAR_MACROS_H_ 32 | 33 | #endif // VC_SCALAR_MACROS_H_ 34 | -------------------------------------------------------------------------------- /BinaryMeshFitting/scalar/simd_cast_caller.tcc: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef Vc_SCALAR_SIMD_CAST_CALLER_TCC_ 29 | #define Vc_SCALAR_SIMD_CAST_CALLER_TCC_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | #if Vc_IS_VERSION_1 36 | template 37 | template 38 | Vc_INTRINSIC Mask::Mask( 39 | U &&rhs, Common::enable_if_mask_converts_explicitly) 40 | : Mask(simd_cast(std::forward(rhs))) 41 | { 42 | } 43 | #endif 44 | } // namespace Vc 45 | 46 | #endif // Vc_SCALAR_SIMD_CAST_CALLER_TCC_ 47 | 48 | // vim: foldmethod=marker 49 | -------------------------------------------------------------------------------- /BinaryMeshFitting/scalar/type_traits.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_SCALAR_TYPE_TRAITS_H_ 29 | #define VC_SCALAR_TYPE_TRAITS_H_ 30 | 31 | #include "types.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Scalar 36 | { 37 | namespace Traits 38 | { 39 | template struct is_vector : public std::false_type {}; 40 | template struct is_vector> : public std::true_type {}; 41 | 42 | template struct is_mask : public std::false_type {}; 43 | template struct is_mask> : public std::true_type {}; 44 | } // namespace Traits 45 | } 46 | } 47 | 48 | #endif // VC_SCALAR_TYPE_TRAITS_H_ 49 | 50 | // vim: foldmethod=marker 51 | -------------------------------------------------------------------------------- /BinaryMeshFitting/scalar/types.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "../common/types.h" 29 | 30 | #ifndef VC_SCALAR_TYPES_H_ 31 | #define VC_SCALAR_TYPES_H_ 32 | 33 | #ifdef Vc_DEFAULT_IMPL_Scalar 34 | #define Vc_DOUBLE_V_SIZE 1 35 | #define Vc_FLOAT_V_SIZE 1 36 | #define Vc_INT_V_SIZE 1 37 | #define Vc_UINT_V_SIZE 1 38 | #define Vc_SHORT_V_SIZE 1 39 | #define Vc_USHORT_V_SIZE 1 40 | #endif 41 | 42 | namespace Vc_VERSIONED_NAMESPACE 43 | { 44 | namespace Scalar 45 | { 46 | template using Vector = Vc::Vector; 47 | typedef Vector double_v; 48 | typedef Vector float_v; 49 | typedef Vector int_v; 50 | typedef Vector uint_v; 51 | typedef Vector short_v; 52 | typedef Vector ushort_v; 53 | 54 | template using Mask = Vc::Mask; 55 | typedef Mask double_m; 56 | typedef Mask float_m; 57 | typedef Mask int_m; 58 | typedef Mask uint_m; 59 | typedef Mask short_m; 60 | typedef Mask ushort_m; 61 | 62 | template struct is_vector : public std::false_type {}; 63 | template struct is_vector> : public std::true_type {}; 64 | template struct is_mask : public std::false_type {}; 65 | template struct is_mask> : public std::true_type {}; 66 | } // namespace Scalar 67 | 68 | namespace Traits 69 | { 70 | template struct is_simd_mask_internal> 71 | : public std::true_type {}; 72 | 73 | template struct 74 | is_simd_vector_internal> 75 | : public is_valid_vector_argument {}; 76 | } // namespace Traits 77 | } // namespace Vc 78 | 79 | #endif // VC_SCALAR_TYPES_H_ 80 | -------------------------------------------------------------------------------- /BinaryMeshFitting/shaders/main_vs.glsl: -------------------------------------------------------------------------------- 1 | #version 400 core 2 | 3 | attribute vec3 vertex_position; 4 | attribute vec3 vertex_normal; 5 | attribute vec3 vertex_color; 6 | uniform mat4 projection; 7 | uniform mat4 view; 8 | uniform vec3 mul_color; 9 | uniform float smooth_shading; 10 | uniform float specular_power; 11 | uniform vec3 camera_pos; 12 | uniform vec4 chunk_pos; 13 | uniform float chunk_depth; 14 | 15 | out vec3 f_normal; 16 | out vec3 f_color; 17 | out vec3 f_mul_color; 18 | out vec3 f_ec_pos; 19 | out float f_smooth_shading; 20 | out float f_specular_power; 21 | out float log_z; 22 | out vec4 f_world_pos; 23 | out float f_chunk_depth; 24 | 25 | void main() 26 | { 27 | f_normal = normalize(vertex_normal); 28 | f_color = vertex_normal; 29 | f_mul_color = mul_color; 30 | f_smooth_shading = smooth_shading; 31 | f_specular_power = specular_power; 32 | f_ec_pos = vertex_position; 33 | 34 | vec3 world_pos = vertex_position * chunk_pos.w + chunk_pos.xyz; 35 | 36 | gl_Position = projection * view * vec4(world_pos - camera_pos, 1); 37 | f_world_pos = vec4(world_pos, chunk_pos.w); 38 | f_chunk_depth = chunk_depth; 39 | 40 | const float far = 1000.0; 41 | const float C = 0.01; 42 | const float FC = 1.0f / log(far * C + 1.0); 43 | log_z = log(gl_Position.w * C + 1.0) * FC; 44 | gl_Position.z = (2.0 * log_z - 1.0) * gl_Position.w; 45 | } -------------------------------------------------------------------------------- /BinaryMeshFitting/shaders/outline_fs.glsl: -------------------------------------------------------------------------------- 1 | #version 400 core 2 | in vec3 f_mul_color; 3 | in float log_z; 4 | out vec4 frag_color; 5 | void main() 6 | { 7 | frag_color = vec4(f_mul_color, 1.0); 8 | gl_FragDepth = log_z - 0.00001; 9 | } -------------------------------------------------------------------------------- /BinaryMeshFitting/shaders/outline_vs.glsl: -------------------------------------------------------------------------------- 1 | #version 400 core 2 | attribute vec3 vertex_position; 3 | uniform mat4 projection; 4 | uniform mat4 view; 5 | uniform vec3 mul_color; 6 | uniform vec3 camera_pos; 7 | uniform vec4 chunk_pos; 8 | 9 | out vec3 f_mul_color; 10 | out float log_z; 11 | 12 | void main() 13 | { 14 | f_mul_color = mul_color; 15 | gl_Position = projection * view * vec4(vertex_position * chunk_pos.w + chunk_pos.xyz - camera_pos, 1); 16 | const float near = 0.000001; 17 | const float far = 1000.0; 18 | const float C = 0.001; 19 | const float FC = 1.0 / log(far * C + 1.0); 20 | log_z = log(gl_Position.w * C + 1.0) * FC; 21 | gl_Position.z = (2.0 * log_z - 1.0) * gl_Position.w; 22 | } -------------------------------------------------------------------------------- /BinaryMeshFitting/sparsepp/spp_smartptr.h: -------------------------------------------------------------------------------- 1 | #if !defined(spp_smartptr_h_guard) 2 | #define spp_smartptr_h_guard 3 | 4 | 5 | /* ----------------------------------------------------------------------------------------------- 6 | * quick version of intrusive_ptr 7 | * ----------------------------------------------------------------------------------------------- 8 | */ 9 | 10 | #include 11 | #include "spp_config.h" 12 | 13 | // ------------------------------------------------------------------------ 14 | class spp_rc 15 | { 16 | public: 17 | spp_rc() : _cnt(0) {} 18 | spp_rc(const spp_rc &) : _cnt(0) {} 19 | void increment() const { ++_cnt; } 20 | void decrement() const { assert(_cnt); if (--_cnt == 0) delete this; } 21 | unsigned count() const { return _cnt; } 22 | 23 | protected: 24 | virtual ~spp_rc() {} 25 | 26 | private: 27 | mutable unsigned _cnt; 28 | }; 29 | 30 | // ------------------------------------------------------------------------ 31 | template 32 | class spp_sptr 33 | { 34 | public: 35 | spp_sptr() : _p(0) {} 36 | spp_sptr(T *p) : _p(p) { if (_p) _p->increment(); } 37 | spp_sptr(const spp_sptr &o) : _p(o._p) { if (_p) _p->increment(); } 38 | #ifndef SPP_NO_CXX11_RVALUE_REFERENCES 39 | spp_sptr(spp_sptr &&o) : _p(o._p) { o._p = (T *)0; } 40 | spp_sptr& operator=(spp_sptr &&o) 41 | { 42 | if (_p) _p->decrement(); 43 | _p = o._p; 44 | o._p = (T *)0; 45 | } 46 | #endif 47 | ~spp_sptr() { if (_p) _p->decrement(); } 48 | spp_sptr& operator=(const spp_sptr &o) { reset(o._p); return *this; } 49 | T* get() const { return _p; } 50 | void swap(spp_sptr &o) { T *tmp = _p; _p = o._p; o._p = tmp; } 51 | void reset(const T *p = 0) 52 | { 53 | if (p == _p) 54 | return; 55 | if (_p) _p->decrement(); 56 | _p = (T *)p; 57 | if (_p) _p->increment(); 58 | } 59 | T* operator->() const { return const_cast(_p); } 60 | bool operator!() const { return _p == 0; } 61 | 62 | private: 63 | T *_p; 64 | }; 65 | 66 | // ------------------------------------------------------------------------ 67 | namespace std 68 | { 69 | template 70 | inline void swap(spp_sptr &a, spp_sptr &b) 71 | { 72 | a.swap(b); 73 | } 74 | } 75 | 76 | #endif // spp_smartptr_h_guard 77 | -------------------------------------------------------------------------------- /BinaryMeshFitting/sparsepp/spp_stdint.h: -------------------------------------------------------------------------------- 1 | #if !defined(spp_stdint_h_guard) 2 | #define spp_stdint_h_guard 3 | 4 | #include "spp_config.h" 5 | 6 | #if defined(SPP_HAS_CSTDINT) && (__cplusplus >= 201103) 7 | #include 8 | #else 9 | #if defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX) 10 | #include 11 | #else 12 | #include 13 | #endif 14 | #endif 15 | 16 | #endif // spp_stdint_h_guard 17 | -------------------------------------------------------------------------------- /BinaryMeshFitting/sparsepp/spp_timer.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2016 Mariano Gonzalez 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | */ 22 | 23 | #ifndef spp_timer_h_guard 24 | #define spp_timer_h_guard 25 | 26 | #include 27 | 28 | namespace spp 29 | { 30 | template 31 | class Timer 32 | { 33 | public: 34 | Timer() { reset(); } 35 | void reset() { _start = _snap = clock::now(); } 36 | void snap() { _snap = clock::now(); } 37 | 38 | float get_total() const { return get_diff(_start, clock::now()); } 39 | float get_delta() const { return get_diff(_snap, clock::now()); } 40 | 41 | private: 42 | using clock = std::chrono::high_resolution_clock; 43 | using point = std::chrono::time_point; 44 | 45 | template 46 | static T get_diff(const point& start, const point& end) 47 | { 48 | using duration_t = std::chrono::duration; 49 | 50 | return std::chrono::duration_cast(end - start).count(); 51 | } 52 | 53 | point _start; 54 | point _snap; 55 | }; 56 | } 57 | 58 | #endif // spp_timer_h_guard 59 | -------------------------------------------------------------------------------- /BinaryMeshFitting/sse/helperimpl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2010-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_SSE_DEINTERLEAVE_H_ 29 | #define VC_SSE_DEINTERLEAVE_H_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Detail 36 | { 37 | template 38 | inline void deinterleave(SSE::float_v &, SSE::float_v &, const float *, A); 39 | template 40 | inline void deinterleave(SSE::float_v &, SSE::float_v &, const short *, A); 41 | template 42 | inline void deinterleave(SSE::float_v &, SSE::float_v &, const ushort *, A); 43 | template 44 | inline void deinterleave(SSE::double_v &, SSE::double_v &, const double *, A); 45 | template 46 | inline void deinterleave(SSE::int_v &, SSE::int_v &, const int *, A); 47 | template 48 | inline void deinterleave(SSE::int_v &, SSE::int_v &, const short *, A); 49 | template 50 | inline void deinterleave(SSE::uint_v &, SSE::uint_v &, const uint *, A); 51 | template 52 | inline void deinterleave(SSE::uint_v &, SSE::uint_v &, const ushort *, A); 53 | template 54 | inline void deinterleave(SSE::short_v &, SSE::short_v &, const short *, A); 55 | template 56 | inline void deinterleave(SSE::ushort_v &, SSE::ushort_v &, const ushort *, A); 57 | 58 | Vc_ALWAYS_INLINE_L void prefetchForOneRead(const void *addr, VectorAbi::Sse) Vc_ALWAYS_INLINE_R; 59 | Vc_ALWAYS_INLINE_L void prefetchForModify(const void *addr, VectorAbi::Sse) Vc_ALWAYS_INLINE_R; 60 | Vc_ALWAYS_INLINE_L void prefetchClose(const void *addr, VectorAbi::Sse) Vc_ALWAYS_INLINE_R; 61 | Vc_ALWAYS_INLINE_L void prefetchMid(const void *addr, VectorAbi::Sse) Vc_ALWAYS_INLINE_R; 62 | Vc_ALWAYS_INLINE_L void prefetchFar(const void *addr, VectorAbi::Sse) Vc_ALWAYS_INLINE_R; 63 | } // namespace Detail 64 | } // namespace Vc 65 | 66 | #include "deinterleave.tcc" 67 | #include "prefetches.tcc" 68 | 69 | #endif // VC_SSE_DEINTERLEAVE_H_ 70 | -------------------------------------------------------------------------------- /BinaryMeshFitting/sse/macros.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "../common/macros.h" 29 | 30 | #ifndef VC_SSE_MACROS_H_ 31 | #define VC_SSE_MACROS_H_ 32 | 33 | #ifndef _M128 34 | # define _M128 __m128 35 | #endif 36 | 37 | #ifndef _M128I 38 | # define _M128I __m128i 39 | #endif 40 | 41 | #ifndef _M128D 42 | # define _M128D __m128d 43 | #endif 44 | 45 | #if defined(Vc_IMPL_SSE4_1) && !defined(Vc_DISABLE_PTEST) 46 | #define Vc_USE_PTEST 47 | #endif 48 | 49 | #endif // VC_SSE_MACROS_H_ 50 | -------------------------------------------------------------------------------- /BinaryMeshFitting/sse/prefetches.tcc: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2010-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_SSE_PREFETCHES_TCC_ 29 | #define VC_SSE_PREFETCHES_TCC_ 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | namespace Detail 34 | { 35 | Vc_ALWAYS_INLINE void prefetchForOneRead(const void *addr, VectorAbi::Sse) 36 | { 37 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_NTA); 38 | } 39 | Vc_ALWAYS_INLINE void prefetchClose(const void *addr, VectorAbi::Sse) 40 | { 41 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_T0); 42 | } 43 | Vc_ALWAYS_INLINE void prefetchMid(const void *addr, VectorAbi::Sse) 44 | { 45 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_T1); 46 | } 47 | Vc_ALWAYS_INLINE void prefetchFar(const void *addr, VectorAbi::Sse) 48 | { 49 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_T2); 50 | } 51 | Vc_ALWAYS_INLINE void prefetchForModify(const void *addr, VectorAbi::Sse) 52 | { 53 | #ifdef __3dNOW__ 54 | _m_prefetchw(const_cast(addr)); 55 | #else 56 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_T0); 57 | #endif 58 | } 59 | } // namespace Detail 60 | } // namespace Vc 61 | 62 | #endif // VC_SSE_PREFETCHES_TCC_ 63 | -------------------------------------------------------------------------------- /BinaryMeshFitting/sse/simd_cast_caller.tcc: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef Vc_SSE_SIMD_CAST_CALLER_TCC_ 29 | #define Vc_SSE_SIMD_CAST_CALLER_TCC_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | #if Vc_IS_VERSION_1 36 | template 37 | template 38 | Vc_INTRINSIC Mask::Mask(U &&rhs, Common::enable_if_mask_converts_explicitly) 39 | : Mask(Vc::simd_cast(std::forward(rhs))) 40 | { 41 | } 42 | #endif 43 | } 44 | 45 | #endif // Vc_SSE_SIMD_CAST_CALLER_TCC_ 46 | 47 | // vim: foldmethod=marker 48 | -------------------------------------------------------------------------------- /BinaryMeshFitting/sse/type_traits.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_SSE_TYPE_TRAITS_H_ 29 | #define VC_SSE_TYPE_TRAITS_H_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace SSE 36 | { 37 | namespace Traits 38 | { 39 | template struct is_vector : public std::false_type {}; 40 | template struct is_vector> : public std::true_type {}; 41 | 42 | template struct is_mask : public std::false_type {}; 43 | template struct is_mask> : public std::true_type {}; 44 | } // namespace Traits 45 | } // namespace SSE 46 | } // namespace Vc 47 | 48 | #endif // VC_SSE_TYPE_TRAITS_H_ 49 | 50 | // vim: foldmethod=marker 51 | -------------------------------------------------------------------------------- /BinaryMeshFitting/sse/types.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "../scalar/types.h" 29 | 30 | #ifndef VC_SSE_TYPES_H_ 31 | #define VC_SSE_TYPES_H_ 32 | 33 | #ifdef Vc_DEFAULT_IMPL_SSE 34 | #define Vc_DOUBLE_V_SIZE 2 35 | #define Vc_FLOAT_V_SIZE 4 36 | #define Vc_INT_V_SIZE 4 37 | #define Vc_UINT_V_SIZE 4 38 | #define Vc_SHORT_V_SIZE 8 39 | #define Vc_USHORT_V_SIZE 8 40 | #endif 41 | 42 | namespace Vc_VERSIONED_NAMESPACE 43 | { 44 | namespace SSE 45 | { 46 | template using Vector = Vc::Vector; 47 | typedef Vector double_v; 48 | typedef Vector float_v; 49 | typedef Vector int_v; 50 | typedef Vector uint_v; 51 | typedef Vector short_v; 52 | typedef Vector ushort_v; 53 | 54 | template using Mask = Vc::Mask; 55 | typedef Mask double_m; 56 | typedef Mask float_m; 57 | typedef Mask int_m; 58 | typedef Mask uint_m; 59 | typedef Mask short_m; 60 | typedef Mask ushort_m; 61 | 62 | template struct Const; 63 | 64 | template struct is_vector : public std::false_type {}; 65 | template struct is_vector> : public std::true_type {}; 66 | template struct is_mask : public std::false_type {}; 67 | template struct is_mask> : public std::true_type {}; 68 | } // namespace SSE 69 | 70 | namespace Traits 71 | { 72 | template struct 73 | is_simd_vector_internal> 74 | : public is_valid_vector_argument {}; 75 | 76 | template struct is_simd_mask_internal> 77 | : public std::true_type {}; 78 | } // namespace Traits 79 | } // namespace Vc 80 | 81 | #endif // VC_SSE_TYPES_H_ 82 | -------------------------------------------------------------------------------- /BinaryMeshFitting/sse/vectorhelper.tcc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lin20/BinaryMeshFitting/d6f7c70aeea256ba51918728430f1b04e3dd792c/BinaryMeshFitting/sse/vectorhelper.tcc -------------------------------------------------------------------------------- /BinaryMeshFitting/traits/decay.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_DECAY_H_ 29 | #define VC_TRAITS_DECAY_H_ 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | namespace Traits 34 | { 35 | template using decay = typename std::decay::type; 36 | } // namespace Traits 37 | } // namespace Vc 38 | 39 | #endif // VC_TRAITS_DECAY_H_ 40 | 41 | // vim: foldmethod=marker 42 | -------------------------------------------------------------------------------- /BinaryMeshFitting/traits/entry_type_of.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_ENTRY_TYPE_OF_H_ 29 | #define VC_TRAITS_ENTRY_TYPE_OF_H_ 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | namespace Traits 34 | { 35 | namespace entry_type_of_internal 36 | { 37 | template ::value> struct entry_type; 38 | 39 | template struct entry_type 40 | { 41 | using type = typename decay::EntryType; 42 | }; 43 | 44 | template struct entry_type 45 | { 46 | using type = typename std::remove_cv::type>::type; 47 | }; 48 | } // namespace entry_type_of_internal 49 | 50 | /** 51 | * Resolves to T::EntryType if \p T is a SIMD type, otherwise it resolves to \p T itself. 52 | */ 53 | template using entry_type_of = typename entry_type_of_internal::entry_type::type; 54 | 55 | } // namespace Traits 56 | } // namespace Vc_VERSIONED_NAMESPACE 57 | 58 | #endif // VC_TRAITS_ENTRY_TYPE_OF_H_ 59 | 60 | // vim: foldmethod=marker 61 | -------------------------------------------------------------------------------- /BinaryMeshFitting/traits/has_addition_operator.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_HAS_ADDITION_OPERATOR_H_ 29 | #define VC_TRAITS_HAS_ADDITION_OPERATOR_H_ 30 | 31 | namespace has_addition_operator_impl 32 | { 33 | 34 | template () + std::declval())> std::true_type test(int); 35 | template std::false_type test(...); 36 | 37 | } // namespace has_addition_operator_impl 38 | 39 | template 40 | struct has_addition_operator : public decltype(has_addition_operator_impl::test(1)) 41 | { 42 | }; 43 | 44 | #endif // VC_TRAITS_HAS_ADDITION_OPERATOR_H_ 45 | -------------------------------------------------------------------------------- /BinaryMeshFitting/traits/has_equality_operator.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_HAS_EQUALITY_OPERATOR_H_ 29 | #define VC_TRAITS_HAS_EQUALITY_OPERATOR_H_ 30 | 31 | namespace has_equality_operator_impl 32 | { 33 | 34 | template () == std::declval())>::value>> 36 | std::true_type test(int); 37 | template std::false_type test(...); 38 | 39 | } // namespace has_equality_operator_impl 40 | 41 | template 42 | struct has_equality_operator : public decltype(has_equality_operator_impl::test(1)) 43 | { 44 | }; 45 | 46 | static_assert(has_equality_operator::value, "has_equality_operator fails"); 47 | namespace 48 | { 49 | class Foobar {}; 50 | static_assert(!has_equality_operator::value, "has_equality_operator fails"); 51 | } // unnamed namespace 52 | 53 | #endif // VC_TRAITS_HAS_EQUALITY_OPERATOR_H_ 54 | -------------------------------------------------------------------------------- /BinaryMeshFitting/traits/has_multiply_operator.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_HAS_MULTIPLY_OPERATOR_H_ 29 | #define VC_TRAITS_HAS_MULTIPLY_OPERATOR_H_ 30 | 31 | namespace has_multiply_operator_impl 32 | { 33 | 34 | template () * std::declval())> std::true_type test(int); 35 | template std::false_type test(...); 36 | 37 | } // namespace has_multiply_operator_impl 38 | 39 | template 40 | struct has_multiply_operator : public decltype(has_multiply_operator_impl::test(1)) 41 | { 42 | }; 43 | 44 | #endif // VC_TRAITS_HAS_MULTIPLY_OPERATOR_H_ 45 | -------------------------------------------------------------------------------- /BinaryMeshFitting/traits/has_subscript_operator.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_HAS_SUBSCRIPT_OPERATOR_H_ 29 | #define VC_TRAITS_HAS_SUBSCRIPT_OPERATOR_H_ 30 | 31 | namespace has_subscript_operator_impl 32 | { 33 | 34 | template ()[std::declval()])> std::true_type test(int); 35 | template std::false_type test(float); 36 | 37 | } // namespace has_subscript_operator_impl 38 | 39 | template 40 | struct has_subscript_operator : public decltype(has_subscript_operator_impl::test(1)) 41 | { 42 | }; 43 | 44 | static_assert(has_subscript_operator::value, ""); 45 | static_assert(has_subscript_operator::value, ""); 46 | static_assert(!has_subscript_operator::value, ""); 47 | 48 | #endif // VC_TRAITS_HAS_SUBSCRIPT_OPERATOR_H_ 49 | -------------------------------------------------------------------------------- /BinaryMeshFitting/traits/is_gather_signature.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | template struct is_gather_signature_impl; 29 | template 30 | struct is_gather_signature_impl 31 | : public std::integral_constant::value && 32 | !is_loadstoreflag_internal::value && 33 | has_subscript_operator::value> { 34 | }; 35 | template struct is_gather_signature_impl<0, Args...> : public std::false_type {}; 36 | template struct is_gather_signature_impl<1, Args...> : public std::false_type {}; 37 | 38 | template struct is_gather_signature : public is_gather_signature_impl...> {}; 39 | -------------------------------------------------------------------------------- /BinaryMeshFitting/traits/is_implicit_cast_allowed.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_IS_IMPLICIT_CAST_ALLOWED_H_ 29 | #define VC_TRAITS_IS_IMPLICIT_CAST_ALLOWED_H_ 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | namespace Traits 34 | { 35 | template ::value> 36 | struct is_implicit_cast_allowed 37 | : public std::integral_constant< 38 | bool, std::is_same::value || 39 | (std::is_integral::value && 40 | (std::is_same::type, To>::value || 41 | std::is_same::type, To>::value))> { 42 | }; 43 | 44 | template 45 | struct is_implicit_cast_allowed : public std::is_same::type { 46 | }; 47 | 48 | template 49 | struct is_implicit_cast_allowed_mask : public is_implicit_cast_allowed { 50 | }; 51 | 52 | static_assert(is_implicit_cast_allowed::value, ""); 53 | static_assert(!is_implicit_cast_allowed::value, ""); 54 | static_assert(is_implicit_cast_allowed< int64_t, uint64_t>::value, ""); 55 | static_assert(is_implicit_cast_allowed::value, ""); 56 | static_assert(is_implicit_cast_allowed< int32_t, uint32_t>::value, ""); 57 | static_assert(is_implicit_cast_allowed::value, ""); 58 | static_assert(is_implicit_cast_allowed< int16_t, uint16_t>::value, ""); 59 | static_assert(is_implicit_cast_allowed::value, ""); 60 | static_assert(is_implicit_cast_allowed< int8_t, uint8_t>::value, ""); 61 | static_assert(is_implicit_cast_allowed< uint8_t, int8_t>::value, ""); 62 | 63 | } // namespace Traits 64 | } // namespace Vc 65 | 66 | #endif // VC_TRAITS_IS_IMPLICIT_CAST_ALLOWED_H_ 67 | 68 | // vim: foldmethod=marker 69 | -------------------------------------------------------------------------------- /BinaryMeshFitting/traits/is_index_sequence.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_IS_INDEX_SEQUENCE_H_ 29 | #define VC_IS_INDEX_SEQUENCE_H_ 30 | 31 | #include "../common/indexsequence.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Traits 36 | { 37 | 38 | template struct is_index_sequence : public std::false_type {}; 39 | template 40 | struct is_index_sequence> : public std::true_type {}; 41 | 42 | static_assert(!is_index_sequence::value, ""); 43 | static_assert(is_index_sequence>::value, ""); 44 | 45 | } // namespace Traits 46 | } // namespace Vc 47 | 48 | #endif // VC_IS_INDEX_SEQUENCE_H_ 49 | 50 | // vim: foldmethod=marker 51 | -------------------------------------------------------------------------------- /BinaryMeshFitting/traits/is_initializer_list.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_IS_INITIALIZER_LIST_H_ 29 | #define VC_TRAITS_IS_INITIALIZER_LIST_H_ 30 | 31 | #include 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Traits 36 | { 37 | namespace is_initializer_list_impl 38 | { 39 | template struct test : public std::false_type {}; 40 | template struct test> : public std::true_type {}; 41 | } // namespace is_initializer_list_impl 42 | 43 | /** 44 | * \internal 45 | * 46 | * Trait that tests whether \p Args is a single type and of std::initializer_list. 47 | */ 48 | template 49 | struct is_initializer_list 50 | : public is_initializer_list_impl::test...> 51 | { 52 | }; 53 | } // namespace Traits 54 | } // namespace Vc 55 | 56 | #endif // VC_TRAITS_IS_INITIALIZER_LIST_H_ 57 | 58 | // vim: foldmethod=marker 59 | -------------------------------------------------------------------------------- /BinaryMeshFitting/traits/is_load_arguments.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_IS_LOAD_ARGUMENTS_H_ 29 | #define VC_TRAITS_IS_LOAD_ARGUMENTS_H_ 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | namespace Traits 34 | { 35 | template struct is_load_store_flag; 36 | 37 | template struct is_load_arguments : public std::false_type {}; 38 | template struct is_load_arguments : public std::is_pointer {}; 39 | template 40 | struct is_load_arguments : public std::integral_constant< 41 | bool, 42 | std::is_pointer::value&& is_load_store_flag::value> 43 | { 44 | }; 45 | } // namespace Traits 46 | } // namespace Vc 47 | 48 | #endif // VC_TRAITS_IS_LOAD_ARGUMENTS_H_ 49 | 50 | // vim: foldmethod=marker 51 | -------------------------------------------------------------------------------- /BinaryMeshFitting/traits/is_output_iterator.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_IS_OUTPUT_ITERATOR_H_ 29 | #define VC_TRAITS_IS_OUTPUT_ITERATOR_H_ 30 | 31 | #include 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Traits 36 | { 37 | namespace is_output_iterator_impl 38 | { 39 | template ::value_type, 40 | typename = decltype(*std::declval() = std::declval< 41 | ValueType>()) // tests that assignment to a 42 | // dereferenced iterator is possible, if 43 | // yes, T is an OutputIterator 44 | > 45 | std::true_type test(int); 46 | template std::false_type test(...); 47 | } // namespace is_output_iterator_impl 48 | 49 | template 50 | struct is_output_iterator 51 | : public std::conditional< 52 | std::is_void::value_type>::value, 53 | std::true_type, decltype(is_output_iterator_impl::test(int()))>::type 54 | { 55 | }; 56 | 57 | static_assert(!std::is_void::value_type>::value, ""); 58 | static_assert(is_output_iterator::value, ""); 59 | static_assert(!is_output_iterator::value, ""); 60 | 61 | } // namespace Traits 62 | } // namespace Vc 63 | 64 | #endif // VC_TRAITS_IS_OUTPUT_ITERATOR_H_ 65 | 66 | // vim: foldmethod=marker 67 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.11) # 3.11 is probably overkill 2 | project(BinaryMeshFitting LANGUAGES CXX) 3 | 4 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/) 5 | 6 | include(PrecompiledHeader) 7 | include(CustomUtil) 8 | 9 | set(CMAKE_CXX_STANDARD 17) 10 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 11 | set(CMAKE_CXX_EXTENSIONS OFF) 12 | 13 | find_package(OpenMP) 14 | if (OPENMP_FOUND) 15 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") 16 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 17 | set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") 18 | endif() 19 | 20 | add_subdirectory(BinaryMeshFitting) 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 John 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 | -------------------------------------------------------------------------------- /cmake/Modules/CustomUtil.cmake: -------------------------------------------------------------------------------- 1 | ### Utility/Convenience functionality: 2 | 3 | ## From https://stackoverflow.com/a/39971448 (modified): 4 | # Compare the new contents with the existing file, if it exists and is the 5 | # same we don't want to trigger a make by changing its timestamp. 6 | function(update_file path content) 7 | set(old_content "") 8 | if(EXISTS "${path}") 9 | file(READ "${path}" old_content) 10 | endif() 11 | if(NOT old_content STREQUAL content) 12 | file(WRITE "${path}" "${content}") 13 | endif() 14 | endfunction() 15 | 16 | # Normalize the list so it's the same on every machine 17 | function(normalize_file_list ret input_list) 18 | set(result "") 19 | list(REMOVE_DUPLICATES input_list) 20 | foreach(item IN LISTS input_list) 21 | if(IS_ABSOLUTE ${item}) 22 | file(RELATIVE_PATH item ${CMAKE_CURRENT_SOURCE_DIR} ${item}) 23 | endif() 24 | list(APPEND result ${item}) 25 | endforeach() 26 | list(SORT result) 27 | set(${ret} ${result} PARENT_SCOPE) 28 | endfunction() 29 | 30 | # Creates a file called CMakeDeps.cmake next to your CMakeLists.txt with 31 | # the list of dependencies in it - this file should be treated as part of 32 | # CMakeLists.txt (source controlled, etc.). 33 | function(update_deps_file deps) 34 | set(deps_file "CMakeDeps.cmake") 35 | normalize_file_list(rel_deps "${deps}") 36 | # Update the deps file 37 | set(content "# File generated by CMake process\nset(sources ${rel_deps})\n") 38 | update_file(${deps_file} "${content}") 39 | # Include the file so it's tracked as a generation dependency we don't 40 | # need the content. 41 | include(${deps_file}) 42 | endfunction() 43 | -------------------------------------------------------------------------------- /cmake/Modules/FindFastNoiseSIMD.cmake: -------------------------------------------------------------------------------- 1 | # Currently very minimal. 2 | 3 | include(FindPackageHandleStandardArgs) 4 | 5 | find_path(FastNoiseSIMD_INCLUDE_DIR FastNoiseSIMD.h) 6 | set(FastNoiseSIMD_INCLUDE_DIRS ${FastNoiseSIMD_INCLUDE_DIR}) 7 | 8 | find_library(FastNoiseSIMD_LIBRARY_RELEASE 9 | NAMES FastNoiseSIMD 10 | PATH_SUFFIXES lib/Release lib 11 | ) 12 | find_library(FastNoiseSIMD_LIBRARY_DEBUG 13 | NAMES FastNoiseSIMDd FastNoiseSIMD 14 | PATH_SUFFIXES lib/Debug lib 15 | ) 16 | set(FastNoiseSIMD_LIBRARIES 17 | optimized ${FastNoiseSIMD_LIBRARY_RELEASE} 18 | debug ${FastNoiseSIMD_LIBRARY_DEBUG} 19 | ) 20 | 21 | find_package_handle_standard_args(FastNoiseSIMD DEFAULT_MSG 22 | FastNoiseSIMD_LIBRARY_RELEASE 23 | FastNoiseSIMD_LIBRARY_DEBUG 24 | FastNoiseSIMD_INCLUDE_DIR 25 | ) 26 | -------------------------------------------------------------------------------- /cmake/Modules/FindGLFW.cmake: -------------------------------------------------------------------------------- 1 | # Currently very minimal. 2 | 3 | include(FindPackageHandleStandardArgs) 4 | 5 | find_path(GLFW_INCLUDE_DIR GLFW/glfw3.h) 6 | set(GLFW_INCLUDE_DIRS ${GLFW_INCLUDE_DIR}) 7 | 8 | find_library(GLFW_LIBRARY_RELEASE 9 | NAMES glfw3 10 | PATH_SUFFIXES lib/Release lib 11 | ) 12 | find_library(GLFW_LIBRARY_DEBUG 13 | NAMES glfw3d glfw3 14 | PATH_SUFFIXES lib/Debug lib 15 | ) 16 | set(GLFW_LIBRARIES 17 | optimized ${GLFW_LIBRARY_RELEASE} 18 | debug ${GLFW_LIBRARY_DEBUG} 19 | ) 20 | 21 | find_package_handle_standard_args(GLFW DEFAULT_MSG 22 | GLFW_LIBRARY_RELEASE 23 | GLFW_LIBRARY_DEBUG 24 | GLFW_INCLUDE_DIR 25 | ) 26 | -------------------------------------------------------------------------------- /cmake/Modules/FindGLM.cmake: -------------------------------------------------------------------------------- 1 | # Currently very minimal. 2 | 3 | include(FindPackageHandleStandardArgs) 4 | 5 | find_path(GLM_INCLUDE_DIR glm/glm.hpp) 6 | set(GLM_INCLUDE_DIRS ${GLM_INCLUDE_DIR}) 7 | 8 | find_package_handle_standard_args(GLM DEFAULT_MSG 9 | GLM_INCLUDE_DIRS 10 | ) 11 | -------------------------------------------------------------------------------- /cmake/Modules/FindVc.cmake: -------------------------------------------------------------------------------- 1 | # Locate the Vc template library. Vc can be found at https://github.com/VcDevel/Vc 2 | # 3 | # This file is meant to be copied into projects that want to use Vc. It will 4 | # search for VcConfig.cmake, which ships with Vc and will provide up-to-date 5 | # buildsystem changes. Thus there should not be any need to update FindVc.cmake 6 | # again after you integrated it into your project. 7 | # 8 | # This module defines the following variables: 9 | # Vc_FOUND 10 | # Vc_INCLUDE_DIR 11 | # Vc_LIBRARIES 12 | # Vc_DEFINITIONS 13 | # Vc_COMPILE_FLAGS 14 | # Vc_ARCHITECTURE_FLAGS 15 | # Vc_ALL_FLAGS (the union of the above three variables) 16 | # Vc_VERSION_MAJOR 17 | # Vc_VERSION_MINOR 18 | # Vc_VERSION_PATCH 19 | # Vc_VERSION 20 | # Vc_VERSION_STRING 21 | # Vc_INSTALL_DIR 22 | # Vc_LIB_DIR 23 | # Vc_CMAKE_MODULES_DIR 24 | # 25 | # The following two variables are set according to the compiler used. Feel free 26 | # to use them to skip whole compilation units. 27 | # Vc_SSE_INTRINSICS_BROKEN 28 | # Vc_AVX_INTRINSICS_BROKEN 29 | # 30 | #============================================================================= 31 | # Copyright 2009-2015 Matthias Kretz 32 | # 33 | # Redistribution and use in source and binary forms, with or without 34 | # modification, are permitted provided that the following conditions are 35 | # met: 36 | # 37 | # * Redistributions of source code must retain the above copyright notice, 38 | # this list of conditions and the following disclaimer. 39 | # * Redistributions in binary form must reproduce the above copyright notice, 40 | # this list of conditions and the following disclaimer in the documentation 41 | # and/or other materials provided with the distribution. 42 | # * Neither the names of contributing organizations nor the 43 | # names of its contributors may be used to endorse or promote products 44 | # derived from this software without specific prior written permission. 45 | # 46 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' 47 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 48 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 49 | # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR 50 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 51 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 52 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 53 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 54 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 55 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56 | #============================================================================= 57 | 58 | find_package(Vc ${Vc_FIND_VERSION} QUIET NO_MODULE PATHS $ENV{HOME} /opt/Vc) 59 | 60 | include(FindPackageHandleStandardArgs) 61 | find_package_handle_standard_args(Vc CONFIG_MODE) 62 | --------------------------------------------------------------------------------