Sfoglia il codice sorgente

stl file format

Former-commit-id: d837718398c3730d7d20ca8cedfba7d151c8c8a7
Alec Jacobson (jalec 11 anni fa
parent
commit
151e0e6ed2

+ 48 - 0
include/igl/local_basis.cpp

@@ -0,0 +1,48 @@
+#include "local_basis.h"
+
+#include <sstream>
+#include <string>
+#include <fstream>
+
+#include <vector>
+#include <Eigen/Geometry>
+
+using namespace Eigen;
+using namespace std;
+
+namespace igl
+{
+
+  template <typename DerivedV, typename DerivedF>
+  IGL_INLINE void local_basis(
+    const Eigen::PlainObjectBase<DerivedV>& V,
+    const Eigen::PlainObjectBase<DerivedF>& F,
+    Eigen::PlainObjectBase<DerivedV>& B1,
+    Eigen::PlainObjectBase<DerivedV>& B2,
+    Eigen::PlainObjectBase<DerivedV>& B3
+    )
+  {
+    B1.resize(F.rows(),3);
+    B2.resize(F.rows(),3);
+    B3.resize(F.rows(),3);
+
+    for (unsigned i=0;i<F.rows();++i)
+    {
+      RowVector3d v1 = (V.row(F(i,1)) - V.row(F(i,0))).normalized();
+      RowVector3d t = V.row(F(i,2)) - V.row(F(i,0));
+      RowVector3d v3 = v1.cross(t).normalized();
+      RowVector3d v2 = v1.cross(v3).normalized();
+
+      B1.row(i) = v1;
+      B2.row(i) = v2;
+      B3.row(i) = v3;
+    }
+
+  }
+
+}
+
+#ifndef IGL_HEADER_ONLY
+// Explicit template specialization
+// generated by autoexplicit.sh
+#endif

+ 39 - 0
include/igl/local_basis.h

@@ -0,0 +1,39 @@
+#ifndef IGL_LOCALBASIS_H
+#define IGL_LOCALBASIS_H
+
+#include "igl/igl_inline.h"
+#include <Eigen/Core>
+#include <string>
+#include <vector>
+
+namespace igl 
+{
+  // Compute a local orthogonal reference system for each triangle in the given mesh
+  // Templates:
+  //   DerivedV derived from vertex positions matrix type: i.e. MatrixXd
+  //   DerivedF derived from face indices matrix type: i.e. MatrixXi
+  // Inputs:
+  //   V  eigen matrix #V by 3
+  //   F  #F by 3 list of mesh faces (must be triangles)
+  // Outputs:
+  //   B1 eigen matrix #F by 3, each vector is tangent to the triangle
+  //   B2 eigen matrix #F by 3, each vector is tangent to the triangle and perpendicular to B1
+  //   B3 eigen matrix #F by 3, normal of the triangle
+  //
+  // See also: adjacency_matrix
+  template <typename DerivedV, typename DerivedF>
+  IGL_INLINE void local_basis(
+    const Eigen::PlainObjectBase<DerivedV>& V,
+    const Eigen::PlainObjectBase<DerivedF>& F,
+    Eigen::PlainObjectBase<DerivedV>& B1,
+    Eigen::PlainObjectBase<DerivedV>& B2,
+    Eigen::PlainObjectBase<DerivedV>& B3
+    );
+
+}
+
+#ifdef IGL_HEADER_ONLY
+#  include "local_basis.cpp"
+#endif
+
+#endif

+ 8 - 1
include/igl/principal_curvature.cpp

@@ -782,7 +782,8 @@ IGL_INLINE void igl::principal_curvature(
                                          const Eigen::PlainObjectBase<DerivedF>& F,
                                          Eigen::PlainObjectBase<DerivedV>& PD1,
                                          Eigen::PlainObjectBase<DerivedV>& PD2,
-                                         unsigned radius
+                                         unsigned radius,
+                                         bool useKring
                                          )
 {
   using namespace std;
@@ -796,6 +797,12 @@ IGL_INLINE void igl::principal_curvature(
   cc.init(V.template cast<double>(),F.template cast<int>());
   cc.sphereRadius = radius;
   
+  if (useKring)
+  {
+    cc.kRing = radius;
+    cc.st = K_RING_SEARCH;
+  }
+  
   // Compute
   cc.computeCurvature();
   

+ 2 - 1
include/igl/principal_curvature.h

@@ -51,7 +51,8 @@ IGL_INLINE void principal_curvature(
                                      const Eigen::PlainObjectBase<DerivedF>& F,
                                      Eigen::PlainObjectBase<DerivedV>& PD1,
                                      Eigen::PlainObjectBase<DerivedV>& PD2,
-                                     unsigned radius = 5
+                                     unsigned radius = 5,
+                                     bool useKring = true
                                      );
 }
 

+ 2 - 2
include/igl/tt.cpp

@@ -76,7 +76,7 @@ IGL_INLINE void igl::tt(const Eigen::PlainObjectBase<Scalar>& V,
                         const Eigen::PlainObjectBase<Index>& F,
                         Eigen::PlainObjectBase<Index>& TT)
 {
-  assert(igl::is_manifold(V,F));
+  //assert(igl::is_manifold(V,F));
   std::vector<std::vector<int> > TTT;
   
   tt_preprocess(V,F,TTT);
@@ -90,7 +90,7 @@ IGL_INLINE void igl::tt(const Eigen::PlainObjectBase<Scalar>& V,
                         Eigen::PlainObjectBase<Index>& TT,
                         Eigen::PlainObjectBase<Index>& TTi)
 {
-  assert(igl::is_manifold(V,F));
+  //assert(igl::is_manifold(V,F));
   std::vector<std::vector<int> > TTT;
   
   tt_preprocess(V,F,TTT);