mirror of https://github.com/wpkong/Octree.git
7 changed files with 679 additions and 89 deletions
@ -0,0 +1 @@ |
|||||
|
test-path.h |
@ -0,0 +1,8 @@ |
|||||
|
set(LOCAL_TEST_DATA_BASE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/data) |
||||
|
|
||||
|
configure_file( |
||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/test-path.h.in" |
||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/test-path.h" |
||||
|
) |
||||
|
add_executable(2d_broken_test main.cpp) |
||||
|
target_link_libraries(2d_broken_test Octree pMesh) |
@ -0,0 +1,548 @@ |
|||||
|
# vtk DataFile Version 3.0 |
||||
|
Volume Mesh |
||||
|
ASCII |
||||
|
DATASET UNSTRUCTURED_GRID |
||||
|
POINTS 181 float |
||||
|
0 2 0 |
||||
|
0.0349048 1.9997 0 |
||||
|
0.069799 1.99878 0 |
||||
|
0.104672 1.99726 0 |
||||
|
0.139513 1.99513 0 |
||||
|
0.174311 1.99239 0 |
||||
|
0.209057 1.98904 0 |
||||
|
0.243739 1.98509 0 |
||||
|
0.278346 1.98054 0 |
||||
|
0.312869 1.97538 0 |
||||
|
0.347296 1.96962 0 |
||||
|
0.381618 1.96325 0 |
||||
|
0.415823 1.9563 0 |
||||
|
0.449902 1.94874 0 |
||||
|
0.483844 1.94059 0 |
||||
|
0.517638 1.93185 0 |
||||
|
0.551275 1.92252 0 |
||||
|
0.584743 1.91261 0 |
||||
|
0.618034 1.90211 0 |
||||
|
0.651136 1.89104 0 |
||||
|
0.68404 1.87939 0 |
||||
|
0.716736 1.86716 0 |
||||
|
0.749213 1.85437 0 |
||||
|
0.781462 1.84101 0 |
||||
|
0.813473 1.82709 0 |
||||
|
0.845237 1.81262 0 |
||||
|
0.876742 1.79759 0 |
||||
|
0.907981 1.78201 0 |
||||
|
0.938943 1.7659 0 |
||||
|
0.969619 1.74924 0 |
||||
|
1 1.73205 0 |
||||
|
1.03008 1.71433 0 |
||||
|
1.05984 1.6961 0 |
||||
|
1.08928 1.67734 0 |
||||
|
1.11839 1.65808 0 |
||||
|
1.14715 1.6383 0 |
||||
|
1.17557 1.61803 0 |
||||
|
1.20363 1.59727 0 |
||||
|
1.23132 1.57602 0 |
||||
|
1.25864 1.55429 0 |
||||
|
1.28558 1.53209 0 |
||||
|
1.31212 1.50942 0 |
||||
|
1.33826 1.48629 0 |
||||
|
1.364 1.46271 0 |
||||
|
1.38932 1.43868 0 |
||||
|
1.41421 1.41421 0 |
||||
|
1.43868 1.38932 0 |
||||
|
1.46271 1.364 0 |
||||
|
1.48629 1.33826 0 |
||||
|
1.50942 1.31212 0 |
||||
|
1.53209 1.28558 0 |
||||
|
1.55429 1.25864 0 |
||||
|
1.57602 1.23132 0 |
||||
|
1.59727 1.20363 0 |
||||
|
1.61803 1.17557 0 |
||||
|
1.6383 1.14715 0 |
||||
|
1.65808 1.11839 0 |
||||
|
1.67734 1.08928 0 |
||||
|
1.6961 1.05984 0 |
||||
|
1.71433 1.03008 0 |
||||
|
1.73205 1 0 |
||||
|
1.74924 0.969619 0 |
||||
|
1.7659 0.938943 0 |
||||
|
1.78201 0.907981 0 |
||||
|
1.79759 0.876742 0 |
||||
|
1.81262 0.845237 0 |
||||
|
1.82709 0.813473 0 |
||||
|
1.84101 0.781462 0 |
||||
|
1.85437 0.749213 0 |
||||
|
1.86716 0.716736 0 |
||||
|
1.87939 0.68404 0 |
||||
|
1.89104 0.651136 0 |
||||
|
1.90211 0.618034 0 |
||||
|
1.91261 0.584743 0 |
||||
|
1.92252 0.551275 0 |
||||
|
1.93185 0.517638 0 |
||||
|
1.94059 0.483844 0 |
||||
|
1.94874 0.449902 0 |
||||
|
1.9563 0.415823 0 |
||||
|
1.96325 0.381618 0 |
||||
|
1.96962 0.347296 0 |
||||
|
1.97538 0.312869 0 |
||||
|
1.98054 0.278346 0 |
||||
|
1.98509 0.243739 0 |
||||
|
1.98904 0.209057 0 |
||||
|
1.99239 0.174311 0 |
||||
|
1.99513 0.139513 0 |
||||
|
1.99726 0.104672 0 |
||||
|
1.99878 0.069799 0 |
||||
|
1.9997 0.0349048 0 |
||||
|
2 0 0 |
||||
|
1.9997 -0.0349048 0 |
||||
|
1.99878 -0.069799 0 |
||||
|
1.99726 -0.104672 0 |
||||
|
1.99513 -0.139513 0 |
||||
|
1.99239 -0.174311 0 |
||||
|
1.98904 -0.209057 0 |
||||
|
1.98509 -0.243739 0 |
||||
|
1.98054 -0.278346 0 |
||||
|
1.97538 -0.312869 0 |
||||
|
1.96962 -0.347296 0 |
||||
|
1.96325 -0.381618 0 |
||||
|
1.9563 -0.415823 0 |
||||
|
1.94874 -0.449902 0 |
||||
|
1.94059 -0.483844 0 |
||||
|
1.93185 -0.517638 0 |
||||
|
1.92252 -0.551275 0 |
||||
|
1.91261 -0.584743 0 |
||||
|
1.90211 -0.618034 0 |
||||
|
1.89104 -0.651136 0 |
||||
|
1.87939 -0.68404 0 |
||||
|
1.86716 -0.716736 0 |
||||
|
1.85437 -0.749213 0 |
||||
|
1.84101 -0.781462 0 |
||||
|
1.82709 -0.813473 0 |
||||
|
1.81262 -0.845237 0 |
||||
|
1.79759 -0.876742 0 |
||||
|
1.78201 -0.907981 0 |
||||
|
1.7659 -0.938943 0 |
||||
|
1.74924 -0.969619 0 |
||||
|
1.73205 -1 0 |
||||
|
1.71433 -1.03008 0 |
||||
|
1.6961 -1.05984 0 |
||||
|
1.67734 -1.08928 0 |
||||
|
1.65808 -1.11839 0 |
||||
|
1.6383 -1.14715 0 |
||||
|
1.61803 -1.17557 0 |
||||
|
1.59727 -1.20363 0 |
||||
|
1.57602 -1.23132 0 |
||||
|
1.55429 -1.25864 0 |
||||
|
1.53209 -1.28558 0 |
||||
|
1.50942 -1.31212 0 |
||||
|
1.48629 -1.33826 0 |
||||
|
1.46271 -1.364 0 |
||||
|
1.43868 -1.38932 0 |
||||
|
1.41421 -1.41421 0 |
||||
|
1.38932 -1.43868 0 |
||||
|
1.364 -1.46271 0 |
||||
|
1.33826 -1.48629 0 |
||||
|
1.31212 -1.50942 0 |
||||
|
1.28558 -1.53209 0 |
||||
|
1.25864 -1.55429 0 |
||||
|
1.23132 -1.57602 0 |
||||
|
1.20363 -1.59727 0 |
||||
|
1.17557 -1.61803 0 |
||||
|
1.14715 -1.6383 0 |
||||
|
1.11839 -1.65808 0 |
||||
|
1.08928 -1.67734 0 |
||||
|
1.05984 -1.6961 0 |
||||
|
1.03008 -1.71433 0 |
||||
|
1 -1.73205 0 |
||||
|
0.969619 -1.74924 0 |
||||
|
0.938943 -1.7659 0 |
||||
|
0.907981 -1.78201 0 |
||||
|
0.876742 -1.79759 0 |
||||
|
0.845237 -1.81262 0 |
||||
|
0.813473 -1.82709 0 |
||||
|
0.781462 -1.84101 0 |
||||
|
0.749213 -1.85437 0 |
||||
|
0.716736 -1.86716 0 |
||||
|
0.68404 -1.87939 0 |
||||
|
0.651136 -1.89104 0 |
||||
|
0.618034 -1.90211 0 |
||||
|
0.584743 -1.91261 0 |
||||
|
0.551275 -1.92252 0 |
||||
|
0.517638 -1.93185 0 |
||||
|
0.483844 -1.94059 0 |
||||
|
0.449902 -1.94874 0 |
||||
|
0.415823 -1.9563 0 |
||||
|
0.381618 -1.96325 0 |
||||
|
0.347296 -1.96962 0 |
||||
|
0.312869 -1.97538 0 |
||||
|
0.278346 -1.98054 0 |
||||
|
0.243739 -1.98509 0 |
||||
|
0.209057 -1.98904 0 |
||||
|
0.174311 -1.99239 0 |
||||
|
0.139513 -1.99513 0 |
||||
|
0.104672 -1.99726 0 |
||||
|
0.069799 -1.99878 0 |
||||
|
0.0349048 -1.9997 0 |
||||
|
0 -2 0 |
||||
|
CELLS 180 540 |
||||
|
2 0 1 |
||||
|
2 1 2 |
||||
|
2 2 3 |
||||
|
2 3 4 |
||||
|
2 4 5 |
||||
|
2 5 6 |
||||
|
2 6 7 |
||||
|
2 7 8 |
||||
|
2 8 9 |
||||
|
2 9 10 |
||||
|
2 10 11 |
||||
|
2 11 12 |
||||
|
2 12 13 |
||||
|
2 13 14 |
||||
|
2 14 15 |
||||
|
2 15 16 |
||||
|
2 16 17 |
||||
|
2 17 18 |
||||
|
2 18 19 |
||||
|
2 19 20 |
||||
|
2 20 21 |
||||
|
2 21 22 |
||||
|
2 22 23 |
||||
|
2 23 24 |
||||
|
2 24 25 |
||||
|
2 25 26 |
||||
|
2 26 27 |
||||
|
2 27 28 |
||||
|
2 28 29 |
||||
|
2 29 30 |
||||
|
2 30 31 |
||||
|
2 31 32 |
||||
|
2 32 33 |
||||
|
2 33 34 |
||||
|
2 34 35 |
||||
|
2 35 36 |
||||
|
2 36 37 |
||||
|
2 37 38 |
||||
|
2 38 39 |
||||
|
2 39 40 |
||||
|
2 40 41 |
||||
|
2 41 42 |
||||
|
2 42 43 |
||||
|
2 43 44 |
||||
|
2 44 45 |
||||
|
2 45 46 |
||||
|
2 46 47 |
||||
|
2 47 48 |
||||
|
2 48 49 |
||||
|
2 49 50 |
||||
|
2 50 51 |
||||
|
2 51 52 |
||||
|
2 52 53 |
||||
|
2 53 54 |
||||
|
2 54 55 |
||||
|
2 55 56 |
||||
|
2 56 57 |
||||
|
2 57 58 |
||||
|
2 58 59 |
||||
|
2 59 60 |
||||
|
2 60 61 |
||||
|
2 61 62 |
||||
|
2 62 63 |
||||
|
2 63 64 |
||||
|
2 64 65 |
||||
|
2 65 66 |
||||
|
2 66 67 |
||||
|
2 67 68 |
||||
|
2 68 69 |
||||
|
2 69 70 |
||||
|
2 70 71 |
||||
|
2 71 72 |
||||
|
2 72 73 |
||||
|
2 73 74 |
||||
|
2 74 75 |
||||
|
2 75 76 |
||||
|
2 76 77 |
||||
|
2 77 78 |
||||
|
2 78 79 |
||||
|
2 79 80 |
||||
|
2 80 81 |
||||
|
2 81 82 |
||||
|
2 82 83 |
||||
|
2 83 84 |
||||
|
2 84 85 |
||||
|
2 85 86 |
||||
|
2 86 87 |
||||
|
2 87 88 |
||||
|
2 88 89 |
||||
|
2 89 90 |
||||
|
2 90 91 |
||||
|
2 91 92 |
||||
|
2 92 93 |
||||
|
2 93 94 |
||||
|
2 94 95 |
||||
|
2 95 96 |
||||
|
2 96 97 |
||||
|
2 97 98 |
||||
|
2 98 99 |
||||
|
2 99 100 |
||||
|
2 100 101 |
||||
|
2 101 102 |
||||
|
2 102 103 |
||||
|
2 103 104 |
||||
|
2 104 105 |
||||
|
2 105 106 |
||||
|
2 106 107 |
||||
|
2 107 108 |
||||
|
2 108 109 |
||||
|
2 109 110 |
||||
|
2 110 111 |
||||
|
2 111 112 |
||||
|
2 112 113 |
||||
|
2 113 114 |
||||
|
2 114 115 |
||||
|
2 115 116 |
||||
|
2 116 117 |
||||
|
2 117 118 |
||||
|
2 118 119 |
||||
|
2 119 120 |
||||
|
2 120 121 |
||||
|
2 121 122 |
||||
|
2 122 123 |
||||
|
2 123 124 |
||||
|
2 124 125 |
||||
|
2 125 126 |
||||
|
2 126 127 |
||||
|
2 127 128 |
||||
|
2 128 129 |
||||
|
2 129 130 |
||||
|
2 130 131 |
||||
|
2 131 132 |
||||
|
2 132 133 |
||||
|
2 133 134 |
||||
|
2 134 135 |
||||
|
2 135 136 |
||||
|
2 136 137 |
||||
|
2 137 138 |
||||
|
2 138 139 |
||||
|
2 139 140 |
||||
|
2 140 141 |
||||
|
2 141 142 |
||||
|
2 142 143 |
||||
|
2 143 144 |
||||
|
2 144 145 |
||||
|
2 145 146 |
||||
|
2 146 147 |
||||
|
2 147 148 |
||||
|
2 148 149 |
||||
|
2 149 150 |
||||
|
2 150 151 |
||||
|
2 151 152 |
||||
|
2 152 153 |
||||
|
2 153 154 |
||||
|
2 154 155 |
||||
|
2 155 156 |
||||
|
2 156 157 |
||||
|
2 157 158 |
||||
|
2 158 159 |
||||
|
2 159 160 |
||||
|
2 160 161 |
||||
|
2 161 162 |
||||
|
2 162 163 |
||||
|
2 163 164 |
||||
|
2 164 165 |
||||
|
2 165 166 |
||||
|
2 166 167 |
||||
|
2 167 168 |
||||
|
2 168 169 |
||||
|
2 169 170 |
||||
|
2 170 171 |
||||
|
2 171 172 |
||||
|
2 172 173 |
||||
|
2 173 174 |
||||
|
2 174 175 |
||||
|
2 175 176 |
||||
|
2 176 177 |
||||
|
2 177 178 |
||||
|
2 178 179 |
||||
|
2 179 180 |
||||
|
CELL_TYPES 180 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
||||
|
3 |
@ -0,0 +1,101 @@ |
|||||
|
/**
|
||||
|
* ------------------------------------ |
||||
|
* @author: Weipeng Kong |
||||
|
* @date: 2021/11/17 |
||||
|
* @email: yjxkwp@foxmail.com |
||||
|
* @site: https://donot.fit
|
||||
|
* @description: |
||||
|
* ------------------------------------ |
||||
|
**/ |
||||
|
|
||||
|
#include <iostream> |
||||
|
#include "Octree/sdf/SDFOctree.h" |
||||
|
#include "Octree/OctreeBuilder.h" |
||||
|
#include "Octree/OctreeTraverser.h" |
||||
|
#include "Octree/sdf/SDFTraversalSampler.h" |
||||
|
#include <igl/marching_cubes.h> |
||||
|
#include <igl/voxel_grid.h> |
||||
|
#include <igl/writeOBJ.h> |
||||
|
#include <igl/signed_distance.h> |
||||
|
#include <pMesh/mesh/TriangleMesh.h> |
||||
|
#include <pMesh/mesh/HexahedronMesh.h> |
||||
|
#include <pMesh/io/reader/OBJReader.h> |
||||
|
#include <pMesh/io/reader/VTKReader.h> |
||||
|
#include <pMesh/io/writer/VTKWriter.h> |
||||
|
#include <pMesh/io/adapter/DefaultReadAdapter.h> |
||||
|
#include <pMesh/io/adapter/DefaultWriteAdapter.h> |
||||
|
#include <boost/timer.hpp> |
||||
|
#include <boost/log/trivial.hpp> |
||||
|
#include <pMesh/io/reader/BaseReader.h> |
||||
|
#include <pMesh/io/adapter/DefaultReadAdapter.h> |
||||
|
#include "test-path.h" |
||||
|
|
||||
|
int main(){ |
||||
|
auto out_sphere_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "broken.vtk"; |
||||
|
auto inside_out_point_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "inside_output_point.vtk"; |
||||
|
auto outside_out_point_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "outside_output_point.vtk"; |
||||
|
|
||||
|
double radius = 2; |
||||
|
|
||||
|
Eigen::MatrixXd V; |
||||
|
Eigen::MatrixXi F; |
||||
|
|
||||
|
std::vector<Eigen::Vector2i> mesh; |
||||
|
pMesh::SurfaceMesh half_sphere; |
||||
|
|
||||
|
pMesh::SurfaceMesh debug_point_cloud; |
||||
|
|
||||
|
for (int i = 0; i <= 180; ++i) { |
||||
|
double rad = i * M_PI / 180; |
||||
|
double x = radius * std::sin(rad); |
||||
|
double y = radius * std::cos(rad); |
||||
|
half_sphere.push_vertex(Eigen::Vector3d{x, y, 0}); |
||||
|
if(i != 0) |
||||
|
half_sphere.push_face({i - 1, i}); |
||||
|
} |
||||
|
pMesh::io::VTKWriter(3, out_sphere_path) << pMesh::io::DefaultSurfaceWriteAdapter(half_sphere)(); |
||||
|
|
||||
|
V.resize(half_sphere.v_size(), 3); |
||||
|
F.resize(half_sphere.f_size(), 2); |
||||
|
|
||||
|
for (int i = 0; i < half_sphere.v_size(); ++i) { |
||||
|
V.row(i) = half_sphere.vertices[i].attr.coordinate; |
||||
|
} |
||||
|
for (int i = 0; i < half_sphere.f_size(); ++i) { |
||||
|
F.row(i) << half_sphere.faces[i].attr.vertices[0].id(), half_sphere.faces[i].attr.vertices[1].id(); |
||||
|
} |
||||
|
|
||||
|
Eigen::MatrixXd GV; |
||||
|
Eigen::RowVector3i res; |
||||
|
const int s = 10; |
||||
|
igl::voxel_grid(V, 0, s, 0, GV, res); |
||||
|
|
||||
|
Eigen::MatrixXd S; |
||||
|
Eigen::MatrixXi I; |
||||
|
Eigen::MatrixXd C; |
||||
|
Eigen::MatrixXd N; |
||||
|
|
||||
|
igl::signed_distance(GV, V, F, igl::SIGNED_DISTANCE_TYPE_PSEUDONORMAL, S, I, C, N); |
||||
|
|
||||
|
// pMesh::SurfaceMesh inside_mesh;
|
||||
|
// pMesh::SurfaceMesh outside_mesh;
|
||||
|
//
|
||||
|
// for (int i = 0; i < GV.rows(); ++i) {
|
||||
|
// auto p = GV.row(i);
|
||||
|
// if (S(i) < 0) {
|
||||
|
//// std::cout << hier3.winding_number(p) << std::endl;
|
||||
|
// auto v = pMesh::Surface::Vertex(inside_mesh.v_size(), GV.row(i));
|
||||
|
// auto f = pMesh::Surface::Face({.vertices={pMesh::Surface::VertexHandle(inside_mesh.v_size())}});
|
||||
|
// inside_mesh.vertices.emplace_back(v);
|
||||
|
// inside_mesh.faces.emplace_back(f);
|
||||
|
//
|
||||
|
// } else {
|
||||
|
// auto v = pMesh::Surface::Vertex(outside_mesh.v_size(), GV.row(i));
|
||||
|
// auto f = pMesh::Surface::Face({.vertices={pMesh::Surface::VertexHandle(outside_mesh.v_size())}});
|
||||
|
// outside_mesh.vertices.emplace_back(v);
|
||||
|
// outside_mesh.faces.emplace_back(f);
|
||||
|
// }
|
||||
|
// }
|
||||
|
// pMesh::io::VTKWriter(1, inside_out_point_path.string()) << pMesh::io::DefaultSurfaceWriteAdapter(inside_mesh)();
|
||||
|
// pMesh::io::VTKWriter(1, outside_out_point_path.string()) << pMesh::io::DefaultSurfaceWriteAdapter(outside_mesh)();
|
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
/**
|
||||
|
* ------------------------------------ |
||||
|
* @author: Weipeng Kong |
||||
|
* @date: 2021/12/1 |
||||
|
* @email: yjxkwp@foxmail.com |
||||
|
* @site: https://donot.fit
|
||||
|
* @description: |
||||
|
* ------------------------------------ |
||||
|
**/ |
||||
|
|
||||
|
#ifndef OCTREE_SDF_TEST_PATH_H |
||||
|
#define OCTREE_SDF_TEST_PATH_H |
||||
|
|
||||
|
#define TEST_DATA_BASE_PATH "@TEST_DATA_BASE_PATH@" |
||||
|
|
||||
|
#define LOCAL_TEST_DATA_BASE_PATH "@LOCAL_TEST_DATA_BASE_PATH@" |
||||
|
|
||||
|
#endif //OCTREE_SDF_TEST_PATH_H
|
@ -1,89 +1 @@ |
|||||
/**
|
/**
* ------------------------------------
* @author: Weipeng Kong
* @date: 2021/11/17
* @email: yjxkwp@foxmail.com
* @site: https://donot.fit
* @description:
* ------------------------------------
**/
#include <igl/WindingNumberTree.h>
#include <igl/WindingNumberAABB.h>
#include <iostream>
#include <igl/marching_cubes.h>
#include <igl/voxel_grid.h>
#include <igl/writeOBJ.h>
#include <igl/readOBJ.h>
#include <igl/read_triangle_mesh.h>
#include <igl/in_element.h>
#include <igl/signed_distance.h>
#include <boost/log/trivial.hpp>
#include <boost/filesystem.hpp>
#include <Eigen/Core>
#include <pMesh/io/writer/VTKWriter.h>
#include <pMesh/mesh/TriangleMesh.h>
#include <pMesh/io/adapter/DefaultWriteAdapter.h>
#include "test-path.h"
int main() {
auto mesh_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "dup_quarter_sphere.obj";
auto inside_out_point_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "inside_output_point.vtk";
auto outside_out_point_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "outside_output_point.vtk";
auto mc_out_point_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "dup_quarter_sphere_mc.obj";
Eigen::MatrixXd V;
Eigen::MatrixXi F;
igl::read_triangle_mesh(mesh_path.string(), V, F);
// typedef Eigen::Matrix<double, 1, 3> RowVector3S;
// igl::WindingNumberAABB<RowVector3S, Eigen::MatrixXd, Eigen::MatrixXi> hier3;
// hier3.set_mesh(V, F);
// hier3.grow();
// igl::AABB<Eigen::MatrixXd, 3> aabb;
// igl::signed_distance_pseudonormal(aabb,)
Eigen::MatrixXd GV;
Eigen::RowVector3i res;
const int s = 30;
igl::voxel_grid(V, 0, s, 0, GV, res);
Eigen::MatrixXd S;
Eigen::MatrixXi I;
Eigen::MatrixXd C;
Eigen::MatrixXd N;
igl::signed_distance(GV, V, F, igl::SIGNED_DISTANCE_TYPE_PSEUDONORMAL, S, I, C, N);
pMesh::SurfaceMesh inside_mesh;
pMesh::SurfaceMesh outside_mesh;
for (int i = 0; i < GV.rows(); ++i) {
auto p = GV.row(i);
if (S(i) < 0) {
// std::cout << hier3.winding_number(p) << std::endl;
auto v = pMesh::Surface::Vertex(inside_mesh.v_size(), GV.row(i));
auto f = pMesh::Surface::Face({.vertices={pMesh::Surface::VertexHandle(inside_mesh.v_size())}});
inside_mesh.vertices.emplace_back(v);
inside_mesh.faces.emplace_back(f);
} else {
auto v = pMesh::Surface::Vertex(outside_mesh.v_size(), GV.row(i));
auto f = pMesh::Surface::Face({.vertices={pMesh::Surface::VertexHandle(outside_mesh.v_size())}});
outside_mesh.vertices.emplace_back(v);
outside_mesh.faces.emplace_back(f);
}
}
pMesh::io::VTKWriter(1, inside_out_point_path.string()) << pMesh::io::DefaultSurfaceWriteAdapter(inside_mesh)();
pMesh::io::VTKWriter(1, outside_out_point_path.string()) << pMesh::io::DefaultSurfaceWriteAdapter(outside_mesh)();
Eigen::MatrixXd SV, BV;
Eigen::MatrixXi SF, BF;
igl::marching_cubes(S, GV, res(0), res(1), res(2), 0, SV, SF);
igl::writeOBJ(mc_out_point_path.string(), SV, SF);
return 0;
} |
||||
* ------------------------------------ |
|
||||
* @author: Weipeng Kong |
|
||||
* @date: 2021/11/17 |
|
||||
* @email: yjxkwp@foxmail.com |
|
||||
* @site: https://donot.fit
|
|
||||
* @description: |
|
||||
* ------------------------------------ |
|
||||
**/ |
|
||||
|
|
||||
#include <igl/WindingNumberTree.h> |
|
||||
#include <igl/WindingNumberAABB.h> |
|
||||
#include <iostream> |
|
||||
#include <igl/marching_cubes.h> |
|
||||
#include <igl/voxel_grid.h> |
|
||||
#include <igl/writeOBJ.h> |
|
||||
#include <igl/readOBJ.h> |
|
||||
#include <igl/read_triangle_mesh.h> |
|
||||
#include <igl/in_element.h> |
|
||||
#include <igl/signed_distance.h> |
|
||||
#include <boost/log/trivial.hpp> |
|
||||
#include <boost/filesystem.hpp> |
|
||||
#include <Eigen/Core> |
|
||||
#include <pMesh/io/writer/VTKWriter.h> |
|
||||
#include <pMesh/mesh/TriangleMesh.h> |
|
||||
#include <pMesh/io/adapter/DefaultWriteAdapter.h> |
|
||||
#include "test-path.h" |
|
||||
|
|
||||
int main() { |
|
||||
auto mesh_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "hole_quarter_sphere.obj"; |
|
||||
auto inside_out_point_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "inside_output_point.vtk"; |
|
||||
auto outside_out_point_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "outside_output_point.vtk"; |
|
||||
auto mc_out_point_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "hole_quarter_sphere_mc.obj"; |
|
||||
Eigen::MatrixXd V; |
|
||||
Eigen::MatrixXi F; |
|
||||
igl::read_triangle_mesh(mesh_path.string(), V, F); |
|
||||
|
|
||||
// typedef Eigen::Matrix<double, 1, 3> RowVector3S;
|
|
||||
// igl::WindingNumberAABB<RowVector3S, Eigen::MatrixXd, Eigen::MatrixXi> hier3;
|
|
||||
// hier3.set_mesh(V, F);
|
|
||||
// hier3.grow();
|
|
||||
// igl::AABB<Eigen::MatrixXd, 3> aabb;
|
|
||||
// igl::signed_distance_pseudonormal(aabb,)
|
|
||||
|
|
||||
|
|
||||
Eigen::MatrixXd GV; |
|
||||
Eigen::RowVector3i res; |
|
||||
const int s = 10; |
|
||||
igl::voxel_grid(V, 0, s, 1, GV, res); |
|
||||
|
|
||||
Eigen::MatrixXd S; |
|
||||
Eigen::MatrixXi I; |
|
||||
Eigen::MatrixXd C; |
|
||||
Eigen::MatrixXd N; |
|
||||
|
|
||||
igl::signed_distance(GV, V, F, igl::SIGNED_DISTANCE_TYPE_PSEUDONORMAL, S, I, C, N); |
|
||||
|
|
||||
pMesh::SurfaceMesh inside_mesh; |
|
||||
pMesh::SurfaceMesh outside_mesh; |
|
||||
|
|
||||
for (int i = 0; i < GV.rows(); ++i) { |
|
||||
auto p = GV.row(i); |
|
||||
if (S(i) < 0) { |
|
||||
// std::cout << hier3.winding_number(p) << std::endl;
|
|
||||
auto v = pMesh::Surface::Vertex(inside_mesh.v_size(), GV.row(i)); |
|
||||
auto f = pMesh::Surface::Face({.vertices={pMesh::Surface::VertexHandle(inside_mesh.v_size())}}); |
|
||||
inside_mesh.vertices.emplace_back(v); |
|
||||
inside_mesh.faces.emplace_back(f); |
|
||||
|
|
||||
} else { |
|
||||
auto v = pMesh::Surface::Vertex(outside_mesh.v_size(), GV.row(i)); |
|
||||
auto f = pMesh::Surface::Face({.vertices={pMesh::Surface::VertexHandle(outside_mesh.v_size())}}); |
|
||||
outside_mesh.vertices.emplace_back(v); |
|
||||
outside_mesh.faces.emplace_back(f); |
|
||||
} |
|
||||
} |
|
||||
pMesh::io::VTKWriter(1, inside_out_point_path.string()) << pMesh::io::DefaultSurfaceWriteAdapter(inside_mesh)(); |
|
||||
pMesh::io::VTKWriter(1, outside_out_point_path.string()) << pMesh::io::DefaultSurfaceWriteAdapter(outside_mesh)(); |
|
||||
|
|
||||
Eigen::MatrixXd SV, BV; |
|
||||
Eigen::MatrixXi SF, BF; |
|
||||
|
|
||||
igl::marching_cubes(S, GV, res(0), res(1), res(2), 0, SV, SF); |
|
||||
|
|
||||
igl::writeOBJ(mc_out_point_path.string(), SV, SF); |
|
||||
|
|
||||
return 0; |
|
||||
} |
|
||||
|
|
Loading…
Reference in new issue