diff --git a/include/igl/average_onto_vertices.cpp b/include/igl/average_onto_vertices.cpp index a43d51383..c19461b02 100644 --- a/include/igl/average_onto_vertices.cpp +++ b/include/igl/average_onto_vertices.cpp @@ -7,15 +7,15 @@ // obtain one at http://mozilla.org/MPL/2.0/. #include "average_onto_vertices.h" -template -IGL_INLINE void igl::average_onto_vertices(const Eigen::Matrix &V, - const Eigen::Matrix &F, - const Eigen::Matrix &S, - Eigen::Matrix &SV) +template +IGL_INLINE void igl::average_onto_vertices(const Eigen::MatrixBase &V, + const Eigen::MatrixBase &F, + const Eigen::MatrixBase &S, + Eigen::MatrixBase &SV) { - - SV = Eigen::Matrix::Zero(V.rows(),S.cols()); - Eigen::Matrix COUNT = Eigen::Matrix::Zero(V.rows()); + SV = DerivedS::Zero(V.rows(),S.cols()); + Eigen::Matrix COUNT(V.rows()); + COUNT.setZero(); for (int i = 0; i (Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix&); #endif diff --git a/include/igl/average_onto_vertices.h b/include/igl/average_onto_vertices.h index 256b35643..e7fca6238 100644 --- a/include/igl/average_onto_vertices.h +++ b/include/igl/average_onto_vertices.h @@ -21,12 +21,11 @@ namespace igl // // Output: // SV: scalar field defined on vertices - template - IGL_INLINE void average_onto_vertices( - const Eigen::Matrix &V, - const Eigen::Matrix &F, - const Eigen::Matrix &S, - Eigen::Matrix &SV); + template + IGL_INLINE void average_onto_vertices(const Eigen::MatrixBase &V, + const Eigen::MatrixBase &F, + const Eigen::MatrixBase &S, + Eigen::MatrixBase &SV); } #ifndef IGL_STATIC_LIBRARY diff --git a/include/igl/boundary_loop.cpp b/include/igl/boundary_loop.cpp index 586362e47..1187fc9b6 100755 --- a/include/igl/boundary_loop.cpp +++ b/include/igl/boundary_loop.cpp @@ -23,8 +23,8 @@ IGL_INLINE void igl::boundary_loop( if(F.rows() == 0) return; - MatrixXd Vdummy(F.maxCoeff()+1,1); - MatrixXi TT,TTi; + VectorXd Vdummy(F.maxCoeff()+1,1); + DerivedF TT,TTi; vector > VF, VFi; triangle_triangle_adjacency(F,TT,TTi); vertex_triangle_adjacency(Vdummy,F,VF,VFi); diff --git a/include/igl/embree/EmbreeIntersector.h b/include/igl/embree/EmbreeIntersector.h index bc7591e78..7d72b11bf 100644 --- a/include/igl/embree/EmbreeIntersector.h +++ b/include/igl/embree/EmbreeIntersector.h @@ -57,11 +57,13 @@ namespace igl // Inputs: // V #V by 3 list of vertex positions // F #F by 3 list of Oriented triangles + // isStatic scene is optimized for static geometry // Side effects: // The first time this is ever called the embree engine is initialized. inline void init( const PointMatrixType& V, - const FaceMatrixType& F); + const FaceMatrixType& F, + bool isStatic = false); // Initialize with a given mesh. // @@ -69,12 +71,14 @@ namespace igl // V vector of #V by 3 list of vertex positions for each geometry // F vector of #F by 3 list of Oriented triangles for each geometry // masks a 32 bit mask to identify active geometries. + // isStatic scene is optimized for static geometry // Side effects: // The first time this is ever called the embree engine is initialized. inline void init( const std::vector& V, const std::vector& F, - const std::vector& masks); + const std::vector& masks, + bool isStatic = false); // Deinitialize embree datasctructures for current mesh. Also called on // destruction: no need to call if you just want to init() once and @@ -252,7 +256,8 @@ inline igl::embree::EmbreeIntersector & igl::embree::EmbreeIntersector::operator inline void igl::embree::EmbreeIntersector::init( const PointMatrixType& V, - const FaceMatrixType& F) + const FaceMatrixType& F, + bool isStatic) { std::vector Vtemp; std::vector Ftemp; @@ -260,13 +265,14 @@ inline void igl::embree::EmbreeIntersector::init( Vtemp.push_back(&V); Ftemp.push_back(&F); masks.push_back(0xFFFFFFFF); - init(Vtemp,Ftemp,masks); + init(Vtemp,Ftemp,masks,isStatic); } inline void igl::embree::EmbreeIntersector::init( const std::vector& V, const std::vector& F, - const std::vector& masks) + const std::vector& masks, + bool isStatic) { if(initialized) @@ -282,7 +288,10 @@ inline void igl::embree::EmbreeIntersector::init( } // create a scene - scene = rtcNewScene(RTC_SCENE_ROBUST | RTC_SCENE_HIGH_QUALITY,RTC_INTERSECT1); + RTCSceneFlags flags = RTC_SCENE_ROBUST | RTC_SCENE_HIGH_QUALITY; + if(isStatic) + flags = flags | RTC_SCENE_STATIC; + scene = rtcNewScene(flags,RTC_INTERSECT1); for(int g=0;g<(int)V.size();g++) { diff --git a/include/igl/is_border_vertex.cpp b/include/igl/is_border_vertex.cpp index 36ca5dfce..df8c1ade8 100644 --- a/include/igl/is_border_vertex.cpp +++ b/include/igl/is_border_vertex.cpp @@ -12,7 +12,7 @@ template IGL_INLINE std::vector igl::is_border_vertex( - const Eigen::PlainObjectBase &V, + const Eigen::PlainObjectBase &V, const Eigen::PlainObjectBase &F) { DerivedF FF; @@ -35,4 +35,5 @@ IGL_INLINE std::vector igl::is_border_vertex( // Explicit template specialization template std::vector > igl::is_border_vertex, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); template std::vector > igl::is_border_vertex, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); +template std::vector > igl::is_border_vertex, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); #endif diff --git a/include/igl/lim/lim.cpp b/include/igl/lim/lim.cpp index dcd7b298e..599579ed4 100644 --- a/include/igl/lim/lim.cpp +++ b/include/igl/lim/lim.cpp @@ -8,37 +8,39 @@ #include "lim.h" #include -IGL_INLINE int igl::lim::lim( +using namespace igl::lim; + +IGL_INLINE State lim( Eigen::Matrix& vertices, const Eigen::Matrix& initialVertices, const Eigen::Matrix& elements, const Eigen::SparseMatrix& constraintMatrix, const Eigen::Matrix& constraintTargets, - int energyType, + Energy energyType, double tolerance, int maxIteration, bool findLocalMinima) { - return ComputeLIM( + return (State)ComputeLIM( vertices, initialVertices, elements, constraintMatrix, constraintTargets, - energyType, + (EnergyType)energyType, tolerance, maxIteration, findLocalMinima ); } -IGL_INLINE int igl::lim( +IGL_INLINE State igl::lim::lim( Eigen::Matrix& vertices, const Eigen::Matrix& initialVertices, const Eigen::Matrix& elements, const Eigen::SparseMatrix& constraintMatrix, const Eigen::Matrix& constraintTargets, - int energyType, + Energy energyType, double tolerance, int maxIteration, bool findLocalMinima, @@ -48,13 +50,13 @@ IGL_INLINE int igl::lim( double beta, double eps) { - return ComputeLIM( + return (State)ComputeLIM( vertices, initialVertices, elements, constraintMatrix, constraintTargets, - energyType, + (EnergyType)energyType, tolerance, maxIteration, findLocalMinima, @@ -66,7 +68,7 @@ IGL_INLINE int igl::lim( ); } -IGL_INLINE int igl::lim( +IGL_INLINE State igl::lim::lim( Eigen::Matrix& vertices, const Eigen::Matrix& initialVertices, const Eigen::Matrix& elements, @@ -74,12 +76,12 @@ IGL_INLINE int igl::lim( const Eigen::Matrix& gradients, const Eigen::SparseMatrix& constraintMatrix, const Eigen::Matrix& constraintTargets, - int energyType, + Energy energyType, double tolerance, int maxIteration, bool findLocalMinima) { - return ComputeLIM( + return (State)ComputeLIM( vertices, initialVertices, elements, @@ -87,14 +89,14 @@ IGL_INLINE int igl::lim( gradients, constraintMatrix, constraintTargets, - energyType, + (EnergyType)energyType, tolerance, maxIteration, findLocalMinima ); } -IGL_INLINE int igl::lim( +IGL_INLINE State igl::lim::lim( Eigen::Matrix& vertices, const Eigen::Matrix& initialVertices, const Eigen::Matrix& elements, @@ -102,7 +104,7 @@ IGL_INLINE int igl::lim( const Eigen::Matrix& gradients, const Eigen::SparseMatrix& constraintMatrix, const Eigen::Matrix& constraintTargets, - int energyType, + Energy energyType, double tolerance, int maxIteration, bool findLocalMinima, @@ -112,7 +114,7 @@ IGL_INLINE int igl::lim( double beta, double eps) { - return ComputeLIM( + return (State)ComputeLIM( vertices, initialVertices, elements, @@ -120,7 +122,7 @@ IGL_INLINE int igl::lim( gradients, constraintMatrix, constraintTargets, - energyType, + (EnergyType)energyType, tolerance, maxIteration, findLocalMinima, diff --git a/include/igl/lim/lim.h b/include/igl/lim/lim.h index 3236a4b4a..ab4999d80 100644 --- a/include/igl/lim/lim.h +++ b/include/igl/lim/lim.h @@ -15,9 +15,6 @@ namespace igl { namespace lim { - // Known issues: energy type should be a readable enum rather than magic - // ints. - // // Computes a locally injective mapping of a triangle or tet-mesh based on // a deformation energy subject to some provided linear positional // constraints Cv-d. @@ -39,7 +36,7 @@ namespace igl // y_2, ..., x_v,y_v]) // constraintTargets d: c vector target positions // energyType type of used energy: - // 0=Dirichlet,1=Laplacian,2=Green,3=ARAP,4=LSCM + // Dirichlet, Laplacian, Green, ARAP, LSCM, Poisson (only 2D), UniformLaplacian, Identity // tolerance max squared positional constraints error // maxIteration max number of iterations // findLocalMinima iterating until a local minima is found. If not @@ -61,30 +58,32 @@ namespace igl // mesh //-------------------------------------------------------------------------- // Return values: - // 1 : Optimization deemed successful because either (a) it stagnated - // (very step size) or (b) positional constraints were satisfied. (re: - // https://github.com/libigl/libigl/issues/79 ) - // -1 : Max iteration reached before tolerance was fulfilled - // -2 : not feasible -> has inverted elements (may want to decrease eps?) + // Succeeded : Successful optimization with fulfilled tolerance + // LocalMinima : Convergenged to a local minima / tolerance not fullfilled + // IterationLimit : Max iteration reached before tolerance was fulfilled + // Infeasible : not feasible -> has inverted elements (decrease eps?) - int lim( + enum Energy { Dirichlet = 0, Laplacian=1, Green=2, ARAP=3, LSCM=4, Poisson=5, UniformLaplacian=6, Identity=7 }; + enum State { Uninitialized = -4, Infeasible = -3, IterationLimit = -2, LocalMinima = -1, Running = 0, Succeeded = 1 }; + + State lim( Eigen::Matrix& vertices, const Eigen::Matrix& initialVertices, const Eigen::Matrix& elements, const Eigen::SparseMatrix& constraintMatrix, const Eigen::Matrix& constraintTargets, - int energyType, + Energy energyType, double tolerance, int maxIteration, bool findLocalMinima); - int lim( + State lim( Eigen::Matrix& vertices, const Eigen::Matrix& initialVertices, const Eigen::Matrix& elements, const Eigen::SparseMatrix& constraintMatrix, const Eigen::Matrix& constraintTargets, - int energyType, + Energy energyType, double tolerance, int maxIteration, bool findLocalMinima, @@ -94,7 +93,7 @@ namespace igl double beta, double eps); - int lim( + State lim( Eigen::Matrix& vertices, const Eigen::Matrix& initialVertices, const Eigen::Matrix& elements, @@ -102,12 +101,12 @@ namespace igl const Eigen::Matrix& gradients, const Eigen::SparseMatrix& constraintMatrix, const Eigen::Matrix& constraintTargets, - int energyType, + Energy energyType, double tolerance, int maxIteration, bool findLocalMinima); - int lim( + State lim( Eigen::Matrix& vertices, const Eigen::Matrix& initialVertices, const Eigen::Matrix& elements, @@ -115,7 +114,7 @@ namespace igl const Eigen::Matrix& gradients, const Eigen::SparseMatrix& constraintMatrix, const Eigen::Matrix& constraintTargets, - int energyType, + Energy energyType, double tolerance, int maxIteration, bool findLocalMinima, diff --git a/include/igl/list_to_matrix.cpp b/include/igl/list_to_matrix.cpp index f808b7b8f..6869dc064 100644 --- a/include/igl/list_to_matrix.cpp +++ b/include/igl/list_to_matrix.cpp @@ -15,8 +15,8 @@ #include "max_size.h" #include "min_size.h" -template -IGL_INLINE bool igl::list_to_matrix(const std::vector > & V,Mat & M) +template +IGL_INLINE bool igl::list_to_matrix(const std::vector > & V,Eigen::PlainObjectBase& M) { // number of rows int m = V.size(); @@ -48,12 +48,12 @@ IGL_INLINE bool igl::list_to_matrix(const std::vector > & V,Mat return true; } -template +template IGL_INLINE bool igl::list_to_matrix( const std::vector > & V, const int n, const T & padding, - Mat & M) + Eigen::PlainObjectBase& M) { const int m = V.size(); M.resize(m,n); @@ -77,8 +77,8 @@ IGL_INLINE bool igl::list_to_matrix( return true; } -template -IGL_INLINE bool igl::list_to_matrix(const std::vector & V,Mat & M) +template +IGL_INLINE bool igl::list_to_matrix(const std::vector & V,Eigen::PlainObjectBase& M) { // number of rows int m = V.size(); @@ -86,10 +86,10 @@ IGL_INLINE bool igl::list_to_matrix(const std::vector & V,Mat & M) { //fprintf(stderr,"Error: list_to_matrix() list is empty()\n"); //return false; - if(Mat::ColsAtCompileTime == 1) + if(Eigen::PlainObjectBase::ColsAtCompileTime == 1) { M.resize(0,1); - }else if(Mat::RowsAtCompileTime == 1) + }else if(Eigen::PlainObjectBase::RowsAtCompileTime == 1) { M.resize(1,0); }else @@ -99,7 +99,7 @@ IGL_INLINE bool igl::list_to_matrix(const std::vector & V,Mat & M) return true; } // Resize output - if(Mat::RowsAtCompileTime == 1) + if(Eigen::PlainObjectBase::RowsAtCompileTime == 1) { M.resize(1,m); }else @@ -118,50 +118,20 @@ IGL_INLINE bool igl::list_to_matrix(const std::vector & V,Mat & M) #ifdef IGL_STATIC_LIBRARY // Explicit template specialization -// generated by autoexplicit.sh -template bool igl::list_to_matrix > >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template bool igl::list_to_matrix > >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template bool igl::list_to_matrix > >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template bool igl::list_to_matrix >(std::vector > const&, Eigen::Matrix&); -// generated by autoexplicit.sh -template bool igl::list_to_matrix > >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template bool igl::list_to_matrix > >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template bool igl::list_to_matrix > >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::Matrix&); -// generated by autoexplicit.sh -template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::Matrix&); -// generated by autoexplicit.sh -template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::Matrix&); -template bool igl::list_to_matrix > >(std::vector > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix > >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix > >(std::vector > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::Matrix&); -template bool igl::list_to_matrix >(std::vector > const&, Eigen::Matrix&); -template bool igl::list_to_matrix > >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix > >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix > >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix >(std::vector > const&, Eigen::Matrix&); -template bool igl::list_to_matrix > >(std::vector > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix > >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix > >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix >(std::vector > const&, Eigen::Matrix&); -template bool igl::list_to_matrix > >(std::vector > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix >(std::vector > const&, Eigen::Matrix&); -template bool igl::list_to_matrix > >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::Matrix&); -template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::Matrix&); -template bool igl::list_to_matrix > >(std::vector > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix > >(std::vector > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix > >(std::vector > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix > >(std::vector > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::Matrix&); -template bool igl::list_to_matrix > >(std::vector > const &,Eigen::PlainObjectBase > &); -template bool igl::list_to_matrix > >(std::vector > const&, Eigen::PlainObjectBase >&); -template bool igl::list_to_matrix > >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector > const&, Eigen::PlainObjectBase >&); +template bool igl::list_to_matrix >(std::vector >, std::allocator > > > const&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/list_to_matrix.h b/include/igl/list_to_matrix.h index 0146be49d..1a5881dc1 100644 --- a/include/igl/list_to_matrix.h +++ b/include/igl/list_to_matrix.h @@ -1,18 +1,20 @@ // This file is part of libigl, a simple c++ geometry processing library. -// +// // Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can +// +// This Source Code Form is subject to the terms of the Mozilla Public License +// v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #ifndef IGL_LIST_TO_MATRIX_H #define IGL_LIST_TO_MATRIX_H #include "igl_inline.h" #include +#include + namespace igl { // Convert a list (std::vector) of row vectors of the same length to a matrix - // Template: + // Template: // T type that can be safely cast to type in Mat via '=' // Mat Matrix type, must implement: // .resize(m,n) @@ -22,10 +24,10 @@ namespace igl // Outputs: // M an m by n matrix // Returns true on success, false on errors - template + template IGL_INLINE bool list_to_matrix( const std::vector > & V, - Mat & M); + Eigen::PlainObjectBase& M); // Convert a list of row vectors of `n` or less to a matrix and pad on // the right with `padding`: // @@ -35,15 +37,15 @@ namespace igl // padding value to fill in from right for short rows // Outputs: // M an m by n matrix - template + template IGL_INLINE bool list_to_matrix( const std::vector > & V, const int n, const T & padding, - Mat & M); + Eigen::PlainObjectBase& M); // Vector wrapper - template - IGL_INLINE bool list_to_matrix(const std::vector & V,Mat & M); + template + IGL_INLINE bool list_to_matrix(const std::vector & V,Eigen::PlainObjectBase& M); } #ifndef IGL_STATIC_LIBRARY diff --git a/include/igl/vertex_triangle_adjacency.cpp b/include/igl/vertex_triangle_adjacency.cpp index d0fed98a3..f8206090e 100644 --- a/include/igl/vertex_triangle_adjacency.cpp +++ b/include/igl/vertex_triangle_adjacency.cpp @@ -51,4 +51,5 @@ template void igl::vertex_triangle_adjacency, long, long>(Eigen::Matrix::Scalar, Eigen::PlainObjectBase > const&, std::vector >, std::allocator > > >&, std::vector >, std::allocator > > >&); template void igl::vertex_triangle_adjacency, long, long>(Eigen::Matrix::Scalar, Eigen::PlainObjectBase > const&, std::vector >, std::allocator > > >&, std::vector >, std::allocator > > >&); template void igl::vertex_triangle_adjacency, unsigned long, unsigned long>(Eigen::Matrix::Scalar, Eigen::PlainObjectBase > const&, std::vector >, std::allocator > > >&, std::vector >, std::allocator > > >&); +template void igl::vertex_triangle_adjacency, Eigen::Matrix, int>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector >, std::allocator > > >&, std::vector >, std::allocator > > >&); #endif diff --git a/tutorial/106_ViewerMenu/main.cpp b/tutorial/106_ViewerMenu/main.cpp index 3b2d1aec3..56219caef 100755 --- a/tutorial/106_ViewerMenu/main.cpp +++ b/tutorial/106_ViewerMenu/main.cpp @@ -3,7 +3,7 @@ int main() { std::cerr<< - "Error: recompile with IGL_VIEWER_WITH_NANOGUI defined."< #include "tutorial_shared_path.h" -Eigen::MatrixXd V; -Eigen::MatrixXi F; - -bool boolVariable = true; -float floatVariable = 0.1f; - int main(int argc, char *argv[]) { + Eigen::MatrixXd V; + Eigen::MatrixXi F; + + bool boolVariable = true; + float floatVariable = 0.1f; + enum Orientation { Up=0,Down,Left,Right } dir = Up; + // Load a mesh in OFF format igl::readOFF(TUTORIAL_SHARED_PATH "/bunny.off", V, F); @@ -45,10 +46,13 @@ int main(int argc, char *argv[]) return boolVariable; // get }); + // Expose an enumaration type + viewer.ngui->addVariable("Direction",dir)->setItems({"Up","Down","Left","Right"}); + // Add a button viewer.ngui->addButton("Print Hello",[](){ std::cout << "Hello\n"; }); - // Add an additional bar + // Add an additional menu window viewer.ngui->addWindow(Eigen::Vector2i(220,10),"New Window"); // Expose the same variable directly ... diff --git a/tutorial/608_LIM/main.cpp b/tutorial/608_LIM/main.cpp index f032e53e9..6b4b4bb69 100644 --- a/tutorial/608_LIM/main.cpp +++ b/tutorial/608_LIM/main.cpp @@ -7,6 +7,8 @@ #include "tutorial_shared_path.h" +using namespace igl::lim; + // Mesh Eigen::MatrixX3d V0; Eigen::MatrixX3d V1; @@ -15,7 +17,7 @@ Eigen::MatrixXi F; Eigen::SparseMatrix C; Eigen::VectorXd b; -int energyType; +Energy energyType; bool barriersEnabled; // This function is called every time a keyboard button is pressed @@ -28,7 +30,7 @@ bool key_down(igl::viewer::Viewer& viewer,unsigned char key,int modifier) if(key >= '0' && key <= '5' || key == 'B') { // compute locally injective map - int energy = key - '1'; + Energy energy = Energy(key - '1'); V1 = V0; @@ -44,8 +46,7 @@ bool key_down(igl::viewer::Viewer& viewer,unsigned char key,int modifier) if(key != '0') { - igl::lim::lim( - V1,V0,F,C,b,energyType,1e-8,100,true,true,barriersEnabled,true,-1,-1); + lim(V1,V0,F,C,b,energyType,1e-8,100,true,true,barriersEnabled,true,-1,-1); } // set mesh @@ -62,7 +63,7 @@ int main(int argc, char *argv[]) using namespace std; using namespace Eigen; - energyType = 0; + energyType = Dirichlet; barriersEnabled = true; // load a mesh in OFF format @@ -102,8 +103,7 @@ int main(int argc, char *argv[]) b(2*fixedVertices.size()+1) = 0.2; // compute locally injective map - igl::lim::lim( - V1,V0,F,C,b,energyType,1e-8,100,true,true,barriersEnabled,true,-1,-1); + lim(V1,V0,F,C,b,energyType,1e-8,100,true,true,barriersEnabled,true,-1,-1); // Show mesh igl::viewer::Viewer viewer; diff --git a/tutorial/CMakeLists.txt b/tutorial/CMakeLists.txt index 6c11373a2..1834c3589 100644 --- a/tutorial/CMakeLists.txt +++ b/tutorial/CMakeLists.txt @@ -34,6 +34,7 @@ find_package(MOSEK QUIET) find_package(TETGEN QUIET) find_package(TINYXML2 QUIET) find_package(TRIANGLE QUIET) +find_package(LIM QUIET) message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") include("CMakeLists.shared") diff --git a/tutorial/cmake/FindLIM.cmake b/tutorial/cmake/FindLIM.cmake index 1a3027a3d..537c6e84a 100644 --- a/tutorial/cmake/FindLIM.cmake +++ b/tutorial/cmake/FindLIM.cmake @@ -9,6 +9,7 @@ FIND_PATH(LIM_INCLUDE_DIR LIMSolverInterface.h /usr/include /usr/local/include ${PROJECT_SOURCE_DIR}/../libigl/external/lim/ + ${PROJECT_SOURCE_DIR}/../external/lim/ ${PROJECT_SOURCE_DIR}/../../external/lim/ NO_DEFAULT_PATH ) @@ -33,6 +34,8 @@ set( ${LIM_INCLUDE_DIR}/GreenStrain_LIMSolver3D.cpp ${LIM_INCLUDE_DIR}/LSConformal_LIMSolver2D.cpp ${LIM_INCLUDE_DIR}/Poisson_LIMSolver2D.cpp + ${LIM_INCLUDE_DIR}/Identity_LIMSolver2D.cpp + ${LIM_INCLUDE_DIR}/Identity_LIMSolver3D.cpp ) SET(LIM_FOUND "NO") diff --git a/tutorial/tutorial.md.REMOVED.git-id b/tutorial/tutorial.md.REMOVED.git-id index c7cabb3dc..7b5dd1d11 100644 --- a/tutorial/tutorial.md.REMOVED.git-id +++ b/tutorial/tutorial.md.REMOVED.git-id @@ -1 +1 @@ -e2e0d9675881ddf6a0d438a24c4ef1bb8f4b4791 \ No newline at end of file +c1fd59bc7313c701b8e5c88150b65216c1ea30a5 \ No newline at end of file