Skip to content

Commit

Permalink
Improved error metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
iveevi committed Aug 31, 2023
1 parent 78f5324 commit f9420cf
Show file tree
Hide file tree
Showing 7 changed files with 564 additions and 66 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ add_executable(decimate decimate.cpp)
add_executable(opt opt.cu casdf/casdf.cu)

add_executable(reshape reshape.cu casdf/casdf.cu)
add_executable(measure measure.cu casdf/casdf.cu)

target_link_libraries(nsc
glfw
Expand Down Expand Up @@ -68,6 +69,12 @@ target_link_libraries(reshape
glslang::glslang-default-resource-limits
)


target_link_libraries(measure
assimp
OpenMP::OpenMP_CXX
)

include_directories(.
glm
imgui
Expand Down
13 changes: 3 additions & 10 deletions casdf/casdf.cu
Original file line number Diff line number Diff line change
Expand Up @@ -505,21 +505,14 @@ void brute_closest_point(const cumesh &cu_mesh, const closest_point_kinfo &kinfo
cas_grid::cas_grid(const geometry &ref_, uint32_t resolution_)
: ref(ref_), resolution(resolution_)
{
printf("Constructing cas grid\n");
uint32_t size = resolution * resolution * resolution;
overlapping_triangles.resize(size);
query_triangles.resize(size);

// Put triangles into bins
std::tie(max, min) = bound(ref);
glm::vec3 extent = { max.x - min.x, max.y - min.y, max.z - min.z };
printf("extent: %f %f %f\n", extent.x, extent.y, extent.z);
bin_size = extent / (float) resolution;
printf("min: %f %f %f\n", min.x, min.y, min.z);
printf("max: %f %f %f\n", max.x, max.y, max.z);
printf("extent: %f %f %f\n", extent.x, extent.y, extent.z);
printf("resolution: %d\n", resolution);
printf("expected extent: %f %f %f\n", (max.x - min.x) / resolution, (max.y - min.y) / resolution, (max.z - min.z) / resolution);

for (size_t i = 0; i < ref.triangles.size(); i++) {
const glm::uvec3 &triangle = ref.triangles[i];
Expand Down Expand Up @@ -716,7 +709,7 @@ std::tuple <glm::vec3, glm::vec3, float, uint32_t> cas_grid::query(const glm::ve
assert(bin.size() > 0);

glm::vec3 closest = p;
glm::vec3 bary;
glm::vec3 barycentric;
float distance = FLT_MAX;
uint32_t triangle_index = 0;

Expand All @@ -733,13 +726,13 @@ std::tuple <glm::vec3, glm::vec3, float, uint32_t> cas_grid::query(const glm::ve

if (dist < distance) {
closest = point;
bary = bary;
barycentric = bary;
distance = dist;
triangle_index = index;
}
}

return std::make_tuple(closest, bary, distance, triangle_index);
return std::make_tuple(closest, barycentric, distance, triangle_index);
}

// Host-side query
Expand Down
Loading

0 comments on commit f9420cf

Please sign in to comment.