diff --git a/tutorial/706_FacetOrientation/CMakeLists.txt b/tutorial/706_FacetOrientation/CMakeLists.txt new file mode 100644 index 000000000..b61c5ba4c --- /dev/null +++ b/tutorial/706_FacetOrientation/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 2.8.12) +project(706_FacetOrientation) + +add_executable(${PROJECT_NAME}_bin + main.cpp) +target_include_directories(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_INCLUDE_DIRS}) +target_compile_definitions(${PROJECT_NAME}_bin PRIVATE ${LIBIGL_DEFINITIONS}) +target_link_libraries(${PROJECT_NAME}_bin ${LIBIGL_LIBRARIES} ${LIBIGL_EXTRA_LIBRARIES}) diff --git a/tutorial/706_FacetOrientation/main.cpp b/tutorial/706_FacetOrientation/main.cpp new file mode 100755 index 000000000..5a815d1f0 --- /dev/null +++ b/tutorial/706_FacetOrientation/main.cpp @@ -0,0 +1,108 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +igl::viewer::Viewer viewer; +Eigen::MatrixXd V; +std::vector C(2); +std::vector RGB(2); +Eigen::MatrixXi F; +std::vector FF(2); +bool is_showing_reoriented = false; +bool facetwise = false; + +int main(int argc, char * argv[]) +{ + using namespace std; + cout<()/(double)C[pass].maxCoeff(); + HSV.rightCols(2).setConstant(1.0); + igl::hsv_to_rgb(HSV,RGB[pass]); + } + viewer.data.set_colors(RGB[facetwise]); + }; + + viewer.callback_key_pressed = + [&scramble_colors] + (igl::viewer::Viewer& /*viewer*/, unsigned int key, int mod)->bool + { + switch(key) + { + default: + return false; + case 'F': + case 'f': + { + facetwise = !facetwise; + break; + } + case 'S': + case 's': + { + scramble_colors(); + return true; + } + case ' ': + { + is_showing_reoriented = !is_showing_reoriented; + break; + } + } + viewer.data.clear(); + viewer.data.set_mesh(V,is_showing_reoriented?FF[facetwise]:F); + viewer.data.set_colors(RGB[facetwise]); + return true; + }; + + + // Compute patches + for(int pass = 0;pass<2;pass++) + { + Eigen::VectorXi I; + igl::embree::reorient_facets_raycast( + V,F,F.rows()*100,10,pass==1,false,false,I,C[pass]); + // apply reorientation + FF[pass].conservativeResize(F.rows(),F.cols()); + for(int i = 0;i