Dynamic updates to AABB tree; intersection-blocking mesh decimation (#2301)

* working insertion and rotation b-b-b-but pointers aren't stuck to m_primitive

* insert now maintains primitive's pointers;+rotate is now getting heights in right ballpark

* sibling rotations working (and helping); dry run test working (and helping)

* working insertion, deletion (detach), and refit with padding.

* working; inexact

* working; inexact

* working; inexact

* note about poor assumptions

* working well after bug fixes. before refactor into functions

* simple self-intersection test function

* moved all functions to files

* docs

* blocking directly in qslim. better docs. aabb templates/tests;

* dont use size_t and fix namespace

* brute-force too fast on linux

* rm overloads in qslim/decimate; cgal template

* fix coplanar bug; factor out raytri.c

* fix and cgal debug

* refactor fast_find; fix bugs in fast_find; fix bugs in shared_vertex

* tutorials running again

* cleaned up aabb tutorials; templates

* format docs

* docs. arg names

* template name

* improve docs

* debugging test

* debugging test

* debugging test

* debugging test

* debugging test

* debugging test

* debugging test

* debugging test

* ebuggin test

* ebuggin test

* add epsilon to ray_triangle ifs

* erroneous includes

* rm leftover includes

* fix cmake bug

* uh actually fix cmake bug

* missing delete

* simple insert test

* don't pad all leaves F.rows() times

* fix pad bug

---------

Co-authored-by: Alec Jacobson <alecjacobson@adobe.com>
This commit is contained in:
Alec Jacobson
2023-10-14 07:32:50 -04:00
committed by GitHub
co-authored by Alec Jacobson
parent 7c9387c92b
commit 112c1b8e48
56 changed files with 4336 additions and 815 deletions
+18 -20
View File
@@ -1,8 +1,8 @@
#include <igl/readOFF.h>
#include <igl/combine.h>
#include <igl/read_triangle_mesh.h>
#include <igl/AABB.h>
#include <igl/unique.h>
#include <igl/opengl/glfw/Viewer.h>
#include <igl/opengl/glfw/imgui/ImGuiMenu.h>
#include <igl/fast_find_intersections.h>
@@ -17,26 +17,24 @@ double slice_z;
void update_visualization(igl::opengl::glfw::Viewer & viewer)
{
Eigen::MatrixXi I;
Eigen::MatrixXd edges;
//shifted intersection object
Eigen::MatrixXd V2_(V2.rows(),V2.cols());
V2_<< V2.col(0), V2.col(1), V2.col(2).array()+slice_z;
igl::fast_find_intersections(tree, V1,F1, V2_,F2, I,edges);
Eigen::MatrixXi edges_link=Eigen::MatrixXi::NullaryExpr(edges.rows()/2,2, [](int i,int j) { return i*2+j;});
Eigen::MatrixXi IF,EE;
Eigen::MatrixXd EV;
Eigen::VectorXi EI;
igl::fast_find_intersections(tree, V1,F1, V2_,F2,false,false,IF,EV,EE,EI);
// Plot the edges of the intersects
viewer.data().set_edges ( edges, edges_link, Eigen::RowVector3d(1,0,0));
viewer.data().set_edges( EV,EE, Eigen::RowVector3d(1,0,0));
// show faces which are intersected
Eigen::VectorXd face_data=Eigen::VectorXd::Zero(F1.rows());
for(int i=0; i<I.rows(); ++i)
face_data(I(i,0)) = 1.0;
viewer.data().set_data(face_data);
Eigen::VectorXi I;
igl::unique(IF,I);
Eigen::VectorXd D = Eigen::MatrixXd::Zero(F1.rows(),1);
D(I).setConstant(1.0);
viewer.data().set_data(D,0,1,igl::COLOR_MAP_TYPE_PARULA);
}
@@ -61,8 +59,10 @@ bool key_down(igl::opengl::glfw::Viewer& viewer, unsigned char key, int mod)
int main(int argc, char *argv[])
{
// Load two meshes
igl::readOFF(TUTORIAL_SHARED_PATH "/cow.off", V1, F1);
igl::readOFF(TUTORIAL_SHARED_PATH "/planexy.off", V2, F2);
igl::read_triangle_mesh(
argc<=1?TUTORIAL_SHARED_PATH "/cow.off" :argv[1],V1,F1);
igl::read_triangle_mesh(
argc<=2?TUTORIAL_SHARED_PATH "/planexy.off":argv[2],V2,F2);
// initialize AABB tree with first mesh (it doesn't move)
tree.init(V1,F1);
@@ -81,13 +81,11 @@ int main(int argc, char *argv[])
// Plot the mesh
igl::opengl::glfw::Viewer viewer;
viewer.data().set_mesh(V1, F1);
viewer.data().set_face_based(true);
update_visualization(viewer);
igl::opengl::glfw::imgui::ImGuiMenu menu;
//plugin.widgets.push_back(&menu);
menu.callback_draw_viewer_window = [](){};
viewer.callback_key_down = &key_down;
// show the cow closer