diff --git a/include/igl/sharp_edges.cpp b/include/igl/sharp_edges.cpp new file mode 100644 index 000000000..33e90699c --- /dev/null +++ b/include/igl/sharp_edges.cpp @@ -0,0 +1,108 @@ +#include "sharp_edges.h" +#include +#include +#include +#include + +template < + typename DerivedV, + typename DerivedF, + typename DerivedSE, + typename DerivedE, + typename DeriveduE, + typename DerivedEMAP, + typename uE2Etype, + typename sharptype> +IGL_INLINE void igl::sharp_edges( + const Eigen::MatrixBase & V, + const Eigen::MatrixBase & F, + const typename DerivedV::Scalar angle, + Eigen::PlainObjectBase & SE, + Eigen::PlainObjectBase & E, + Eigen::PlainObjectBase & uE, + Eigen::PlainObjectBase & EMAP, + std::vector > & uE2E, + std::vector< sharptype > & sharp) +{ + typedef typename DerivedSE::Scalar Index; + typedef typename DerivedV::Scalar Scalar; + typedef Eigen::Matrix MatrixX2I; + typedef Eigen::Matrix MatrixX3S; + typedef Eigen::Matrix RowVector3S; + typedef Eigen::Matrix VectorXI; + + unique_edge_map(F,E,uE,EMAP,uE2E); + MatrixX3S N; + per_face_normals(V,F,N); + // number of faces + const Index m = F.rows(); + // Dihedral angles + //std::vector > DIJV; + sharp.clear(); + // Loop over each unique edge + for(int u = 0;u angle) + { + u_is_sharp = true; + } + } + if(u_is_sharp) + { + sharp.push_back(u); + } + } + SE.resize(sharp.size(),2); + for(int i = 0;i +IGL_INLINE void igl::sharp_edges( + const Eigen::MatrixBase & V, + const Eigen::MatrixBase & F, + const typename DerivedV::Scalar angle, + Eigen::PlainObjectBase & SE + ) +{ + typedef typename DerivedSE::Scalar Index; + typedef typename DerivedV::Scalar Scalar; + typedef Eigen::Matrix MatrixX2I; + typedef Eigen::Matrix MatrixX3S; + typedef Eigen::Matrix RowVector3S; + typedef Eigen::Matrix VectorXI; + MatrixX2I E,uE; + VectorXI EMAP; + std::vector > uE2E; + std::vector sharp; + return sharp_edges(V,F,angle,SE,E,uE,EMAP,uE2E,sharp); +} + +#ifdef IGL_STATIC_LIBRARY +// Explicit template instantiation +template void igl::sharp_edges, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::Matrix::Scalar, Eigen::PlainObjectBase >&); +template void igl::sharp_edges, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, int, int>(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::Matrix::Scalar, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, std::vector >, std::allocator > > >&, std::vector >&); +#endif diff --git a/include/igl/sharp_edges.h b/include/igl/sharp_edges.h new file mode 100644 index 000000000..7b417ee58 --- /dev/null +++ b/include/igl/sharp_edges.h @@ -0,0 +1,53 @@ +#ifndef IGL_SHARP_EDGES_H +#define IGL_SHARP_EDGES_H + +#include +#include + +namespace igl +{ + // SHARP_EDGES Given a mesh, compute sharp edges. + // + // Inputs: + // V #V by 3 list of vertex positions + // F #F by 3 list of triangle mesh indices into V + // angle dihedral angle considered to sharp (e.g., igl::PI * 0.11) + // Outputs: + // SE #SE by 2 list of edge indices into V + // + template < + typename DerivedV, + typename DerivedF, + typename DerivedSE, + typename DerivedE, + typename DeriveduE, + typename DerivedEMAP, + typename uE2Etype, + typename sharptype> + IGL_INLINE void sharp_edges( + const Eigen::MatrixBase & V, + const Eigen::MatrixBase & F, + const typename DerivedV::Scalar angle, + Eigen::PlainObjectBase & SE, + Eigen::PlainObjectBase & E, + Eigen::PlainObjectBase & uE, + Eigen::PlainObjectBase & EMAP, + std::vector > & uE2E, + std::vector< sharptype > & sharp); + template < + typename DerivedV, + typename DerivedF, + typename DerivedSE> + IGL_INLINE void sharp_edges( + const Eigen::MatrixBase & V, + const Eigen::MatrixBase & F, + const typename DerivedV::Scalar angle, + Eigen::PlainObjectBase & SE + ); +} + +#ifndef IGL_STATIC_LIBRARY +# include "sharp_edges.cpp" +#endif + +#endif