Просмотр исходного кода

read -> read_triangle_mesh

Former-commit-id: 68886f87a5389835abc939d91c1354f523919277
Daniele Panozzo 11 лет назад
Родитель
Сommit
bafcdc9311

+ 2 - 2
examples/ambient-occlusion-mex/mexFunction.cpp

@@ -11,7 +11,7 @@
 #include <iostream>
 #include <string>
 
-void mexFunction(int nlhs, mxArray *plhs[], 
+void mexFunction(int nlhs, mxArray *plhs[],
     int nrhs, const mxArray *prhs[])
 {
   // This is useful for debugging whether Matlab is caching the mex binary
@@ -31,7 +31,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
   // Prepare left-hand side
   nlhs = 1;
 
-  //read("../shared/cheburashka.off",V,F);
+  //read_triangle_mesh("../shared/cheburashka.off",V,F);
   //P = V;
   //per_vertex_normals(V,F,N);
   ambient_occlusion(V,F,P,N,num_samples,S);

+ 8 - 9
examples/basic_topology/example1.cpp

@@ -1,10 +1,10 @@
 //
-//  IGL Lib - Simple C++ mesh library 
+//  IGL Lib - Simple C++ mesh library
 //
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 
 // IMPORTANT DO NOT REMOVE OR MOVE
-#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET 
+#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
 
 #include <iostream>
 #include <string>
@@ -19,7 +19,7 @@ int main (int argc, const char * argv[])
 {
     Eigen::MatrixXd V;
     Eigen::MatrixXi F;
-    igl::read("../shared/TinyTorus.obj",V,F);
+    igl::read_triangle_mesh("../shared/TinyTorus.obj",V,F);
 
     std::cout << "Mesh loaded!\n";
     cout << "Vertex Array:" << endl;
@@ -28,9 +28,9 @@ int main (int argc, const char * argv[])
     cout << "Face Array:" << endl;
     cout << F << endl;
     cout << "-------------" << endl;
-    
+
     igl::write("bunny_out.off",V,F);
-    
+
     // Face Topology
     cout << "TT Topology:" << endl;
     Eigen::MatrixXi TT;
@@ -43,12 +43,11 @@ int main (int argc, const char * argv[])
     Eigen::MatrixXi EV;
     Eigen::MatrixXi FE;
     Eigen::MatrixXi EF;
-    
+
     igl::edgetopology(V,F,EV,FE, EF);
     cout << EV << endl << FE << endl << EF << endl;
     cout << "-------------" << endl;
-    
-    
+
+
     return 0;
 }
-

+ 7 - 7
examples/embree/example.cpp

@@ -220,9 +220,9 @@ void display()
     const double w0 = (1.0-hit->u-hit->v);
     const double w1 = hit->u;
     const double w2 = hit->v;
-    VectorXd hitP = 
-      w0 * V.row(F(hit->id,0)) + 
-      w1 * V.row(F(hit->id,1)) + 
+    VectorXd hitP =
+      w0 * V.row(F(hit->id,0)) +
+      w1 * V.row(F(hit->id,1)) +
       w2 * V.row(F(hit->id,2));
     glVertex3dv(hitP.data());
   }
@@ -278,7 +278,7 @@ void display()
     glDisable(GL_COLOR_MATERIAL);
     glDisable(GL_DEPTH_TEST);
     glEnable(GL_BLEND);
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
+    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glColor4f(1.0,0.3,0.3,0.6);
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
@@ -428,7 +428,7 @@ void key(unsigned char key, int mouse_x, int mouse_y)
     default:
       cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
   }
-  
+
 }
 
 int main(int argc, char * argv[])
@@ -448,7 +448,7 @@ int main(int argc, char * argv[])
     // Read and prepare mesh
     filename = argv[1];
   }
-  if(!read(filename,V,F))
+  if(!read_triangle_mesh(filename,V,F))
   {
     return 1;
   }
@@ -458,7 +458,7 @@ int main(int argc, char * argv[])
   mean = V.colwise().mean();
   C.resize(F.rows(),3);
   init_C();
-  bbd = 
+  bbd =
     (V.colwise().maxCoeff() -
     V.colwise().minCoeff()).maxCoeff();
 

+ 6 - 6
examples/intersections/example.cpp

@@ -97,7 +97,7 @@ void TW_CALL set_rotation_type(const void * value, void * clientData)
   using namespace igl;
   const RotationType old_rotation_type = rotation_type;
   rotation_type = *(const RotationType *)(value);
-  if(rotation_type == ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP && 
+  if(rotation_type == ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP &&
     old_rotation_type != ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP)
   {
     push_undo();
@@ -446,7 +446,7 @@ void mouse_drag(int mouse_x, int mouse_y)
       }
       case ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP:
       {
-        // Rotate according to two axis valuator with fixed up vector 
+        // Rotate according to two axis valuator with fixed up vector
         two_axis_valuator_fixed_up(
           width, height,
           2.0,
@@ -536,7 +536,7 @@ void key(unsigned char key, int mouse_x, int mouse_y)
         cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
       }
   }
-  
+
   glutPostRedisplay();
 }
 
@@ -622,13 +622,13 @@ int main(int argc, char * argv[])
     return true;
   };
 
-  if(!read(filename,V,F,N))
+  if(!read_triangle_mesh(filename,V,F,N))
   {
     return 1;
   }
   if(has_other)
   {
-    if(!read(argv[2],U,G,W))
+    if(!read_triangle_mesh(argv[2],U,G,W))
     {
       return 1;
     }
@@ -656,7 +656,7 @@ int main(int argc, char * argv[])
   }
   // Create a tweak bar
   rebar.TwNewBar("TweakBar");
-  rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D, 
+  rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
   s.camera.push_away(3);
   s.camera.dolly_zoom(25-s.camera.m_angle);

+ 6 - 6
examples/multi-viewport/example.cpp

@@ -338,9 +338,9 @@ int in_viewport(const int x, const int y)
   for(int vp = 0;vp<NUM_VIEWPORTS;vp++)
   {
     if(
-      x >= viewports[vp].x && 
-      y >= viewports[vp].y && 
-      x <  viewports[vp].x+viewports[vp].width && 
+      x >= viewports[vp].x &&
+      y >= viewports[vp].y &&
+      x <  viewports[vp].x+viewports[vp].width &&
       y <  viewports[vp].y+viewports[vp].height)
     {
       down_vp = vp;
@@ -503,7 +503,7 @@ void key(unsigned char key, int mouse_x, int mouse_y)
     default:
       cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
   }
-  
+
 }
 
 int main(int argc, char * argv[])
@@ -519,7 +519,7 @@ int main(int argc, char * argv[])
     filename = argv[1];
   }
 
-  if(!read(filename,V,F))
+  if(!read_triangle_mesh(filename,V,F))
   {
     return 1;
   }
@@ -529,7 +529,7 @@ int main(int argc, char * argv[])
   mean = V.colwise().mean();
   C.resize(F.rows(),3);
   init_C();
-  bbd = 
+  bbd =
     (V.colwise().maxCoeff() -
     V.colwise().minCoeff()).maxCoeff();
 

+ 2 - 2
examples/principal_curvature/curvature.cpp

@@ -68,7 +68,7 @@ void app_init(int argc, char* argv[], CurvatureCalculator& c, Eigen::MatrixXd& V
                 break;
             case 'i':
                 meshName=*++argv;
-                igl::read(meshName,V,F);
+                igl::read_triangle_mesh(meshName,V,F);
                 argc--;
                 break;
             case 'k':
@@ -152,7 +152,7 @@ int main(int argc, char *argv[])
     string filename;
 
     app_init(argc,argv,c,V,F);
-    
+
     c.init(V,F);
 
     c.computeCurvature();

+ 1 - 1
examples/transparency/example.cpp

@@ -303,7 +303,7 @@ int main(int argc, char * argv[])
   {
     filename = argv[1];
   }
-  if(!read(filename,V,F))
+  if(!read_triangle_mesh(filename,V,F))
   {
     return 1;
   }

+ 16 - 16
include/igl/read.cpp → include/igl/read_triangle_mesh.cpp

@@ -1,22 +1,22 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// 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/.
-#include "read.h"
+#include "read_triangle_mesh.h"
 
-#include "readOBJ.h"
-#include "readOFF.h"
-#include "pathinfo.h"
+#include <igl/readOBJ.h>
+#include <igl/readOFF.h>
+#include <igl/pathinfo.h>
 
 #include <cstdio>
 #include <iostream>
 
 
 template <typename Scalar, typename Index>
-IGL_INLINE bool igl::read(
+IGL_INLINE bool igl::read_triangle_mesh(
   const std::string str,
   std::vector<std::vector<Scalar> > & V,
   std::vector<std::vector<Index> > & F)
@@ -45,7 +45,7 @@ IGL_INLINE bool igl::read(
 
 #ifndef IGL_NO_EIGN
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE bool igl::read(
+IGL_INLINE bool igl::read_triangle_mesh(
   const std::string str,
   Eigen::PlainObjectBase<DerivedV>& V,
   Eigen::PlainObjectBase<DerivedF>& F)
@@ -55,7 +55,7 @@ IGL_INLINE bool igl::read(
         ;
     while (*p != '.')
         p--;
-    
+
     if (!strcmp(p, ".obj") || !strcmp(p, ".OBJ"))
     {
         return igl::readOBJ(str,V,F);
@@ -63,9 +63,9 @@ IGL_INLINE bool igl::read(
     {
         return igl::readOFF(str,V,F);
     }
-    else 
+    else
     {
-      fprintf(stderr,"read() does not recognize extension: %s\n",p);
+      fprintf(stderr,"read_triangle_mesh() does not recognize extension: %s\n",p);
       return false;
     }
 }
@@ -74,7 +74,7 @@ IGL_INLINE bool igl::read(
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
 // generated by autoexplicit.sh
-template bool igl::read<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-template bool igl::read<double, int>(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&);
-template bool igl::read<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(std::string, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
+template bool igl::read_triangle_mesh<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template bool igl::read_triangle_mesh<double, int>(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&);
+template bool igl::read_triangle_mesh<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(std::string, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
 #endif

+ 11 - 10
include/igl/read.h → include/igl/read_triangle_mesh.h

@@ -1,12 +1,12 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// 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_READ_H
-#define IGL_READ_H
+#ifndef IGL_READ_TRIANGLE_MESH_H
+#define IGL_READ_TRIANGLE_MESH_H
 #include "igl_inline.h"
 
 #ifndef IGL_NO_EIGEN
@@ -15,9 +15,10 @@
 #include <string>
 #include <vector>
 // History:
+//  renamed read -> read_triangle_mesh     Daniele 24 June 2014
 //  return type changed from void to bool  Alec 18 Sept 2011
 
-namespace igl 
+namespace igl
 {
   // read mesh from an ascii file with automatic detection of file format. supported: obj, off)
   // Templates:
@@ -31,13 +32,13 @@ namespace igl
   //   V  eigen double matrix #V by 3
   //   F  eigen int matrix #F by 3
   template <typename Scalar, typename Index>
-  IGL_INLINE bool read(
+  IGL_INLINE bool read_triangle_mesh(
     const std::string str,
     std::vector<std::vector<Scalar> > & V,
     std::vector<std::vector<Index> > & F);
 #ifndef IGL_NO_EIGEN
   template <typename DerivedV, typename DerivedF>
-  IGL_INLINE bool read(
+  IGL_INLINE bool read_triangle_mesh(
     const std::string str,
     Eigen::PlainObjectBase<DerivedV>& V,
     Eigen::PlainObjectBase<DerivedF>& F);
@@ -45,7 +46,7 @@ namespace igl
 }
 
 #ifdef IGL_HEADER_ONLY
-#  include "read.cpp"
+#  include "read_triangle_mesh.cpp"
 #endif
 
 #endif

+ 6 - 7
include/igl/triangulate.h

@@ -1,9 +1,9 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// 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_TRIANGULATE_H
 #define IGL_TRIANGULATE_H
@@ -14,7 +14,7 @@
 #endif
 #include <vector>
 
-namespace igl 
+namespace igl
 {
   // Triangulate a general polygonal mesh into a triangle mesh.
   //
@@ -26,7 +26,7 @@ namespace igl
   // Example:
   //   vector<vector<double > > vV;
   //   vector<vector<int > > vF;
-  //   read("poly.obj",vV,vF);
+  //   read_triangle_mesh("poly.obj",vV,vF);
   //   MatrixXd V;
   //   MatrixXi F;
   //   list_to_matrix(vV,V);
@@ -42,4 +42,3 @@ namespace igl
 #endif
 
 #endif
-

+ 12 - 12
tutorial.html

@@ -13,13 +13,13 @@
             <li><a href=#header_benefits_drawbacks>Benefits and drawbacks</a></li>
           </ul>
         </li>
-        <li> 
+        <li>
           <a href=#static_library>Statically linked library (libigl.a)</a>
           <ul>
             <li><a href=#static_benefits_drawbacks>Benefits and drawbacks</a></li>
           </ul>
         </li>
-        <li> 
+        <li>
           <a href=#compress>Compressed igl.h/igl.cpp pair</a>
           <ul>
             <li><a href=#compress_benefits_drawbacks>Benefits and drawbacks</a></li>
@@ -30,7 +30,7 @@
         </li>
         <li><a href=#matlab>Conversion from matlab</a>
       <ul>
-    </div> 
+    </div>
     <div id=container>
     <div class=article_outer>
     <div class=article_inner>
@@ -97,7 +97,7 @@
 
       <div class=note>This practice is not recommended outside of debugging
       purposes.</div>
-      
+
 
       <h3 id=header_benefits_drawbacks>Benefits of headers-only library</h3>
       <ul>
@@ -214,7 +214,7 @@ cd /to/your/project
 make 2&gt;$LIBIGL/make.err
 cd $LIBIGL
 cat make.err | ./autoexplicit.sh
-make clean 
+make clean
 make
         </code></pre>
 
@@ -241,11 +241,11 @@ make
       <p>Calling the script:</p>
       <pre><code>scripts/compress.sh igl.h igl.cpp</code></pre>
       <p>will create a single header
-      <code>igl.h</code> and a single cpp file <code>igl.cpp</code>. 
+      <code>igl.h</code> and a single cpp file <code>igl.cpp</code>.
 
       <p>Alternatively, you can also compress everything into a single header file (analagous to IGL_HEADER_ONLY):</p>
       <pre><code>scripts/compress.sh igl.h</code></pre>
-      
+
       <h3 id=compress_benefits_drawbacks>Benefits of compressed .h/.cpp pair</h3>
       <ul>
         <li><strong>Easy incorporation:</strong> This can be easily incorporated
@@ -278,7 +278,7 @@ int main(int argc, char * argv[])
 {
   Eigen::MatrixXd V;
   Eigen::MatrixXi F;
-  return (argc&gt;=2 &amp;&amp; igl::read(argv[1],V,F)?0:1);
+  return (argc&gt;=2 &amp;&amp; igl::read_triangle_mesh(argv[1],V,F)?0:1);
 }
       </code></pre>
       <p>Then compile <code>igl.cpp</code> with:
@@ -314,10 +314,10 @@ grep OpenGL `grep -L IGL_NO_OPENGL include/igl/*`
         optional. All OpenGL-dependent functions may be disabled by defining
         the <code>IGL_NO_OPENGL</code> preprocessor macro.</p>
         </p>
-        <p> Likewise, 
+        <p> Likewise,
           <a href="http://www.antisphere.com/Wiki/tools:anttweakbar">AntTweakBar</a>
-          is an 
-        <i>assumed</i> dependency, similarly diabled by defining 
+          is an
+        <i>assumed</i> dependency, similarly diabled by defining
         the <code>IGL_NO_ANTTWEAKBAR</code> preprocessor macro.</p>
 
         <p><span class=todo>Each IGL_NO_XXX should just be replaced by a libiglXXX.a extra</span></p>
@@ -350,7 +350,7 @@ grep OpenGL `grep -L IGL_NO_OPENGL include/igl/*`
         translation table</a>). We have implemented a few additional
         matlab-esque functions to make the translation even easier. <a
         href="matlab-to-eigen.html">Our own translation table</a> shows a list
-        of common matlab functions and their igl-eigen equivalents.  
+        of common matlab functions and their igl-eigen equivalents.
       </p>
 
       <h3>Including OpenGL</h3>