Kaynağa Gözat

namespaces and missing includes in curvature related code

Former-commit-id: c92f0204bf169b7af70d64906427ee0a81834876
Alec Jacobson (jalec 11 yıl önce
ebeveyn
işleme
32a3ea765e

+ 38 - 0
include/igl/ReAntTweakBar.cpp

@@ -33,6 +33,44 @@ IGL_INLINE TwType igl::ReTwDefineEnum(
   return type;
 }
 
+IGL_INLINE TwType igl::ReTwDefineEnum(
+  const char * _Name,
+  const char * _EnumString)
+{
+  // Taken directly from TwMgr.cpp, just replace TwDefineEnum with
+  // ReTwDefineEnum
+  using namespace std;
+  {
+    if (_EnumString == NULL) 
+        return ReTwDefineEnum(_Name, NULL, 0);
+
+    // split enumString
+    stringstream EnumStream(_EnumString);
+    string Label;
+    vector<string> Labels;
+    while( getline(EnumStream, Label, ',') ) {
+        // trim Label
+        size_t Start = Label.find_first_not_of(" \n\r\t");
+        size_t End = Label.find_last_not_of(" \n\r\t");
+        if( Start==string::npos || End==string::npos )
+            Label = "";
+        else
+            Label = Label.substr(Start, (End-Start)+1);
+        // store Label
+        Labels.push_back(Label);
+    }
+    // create TwEnumVal array
+    vector<TwEnumVal> Vals(Labels.size());
+    for( int i=0; i<(int)Labels.size(); i++ )
+    {
+        Vals[i].Value = i;
+        Vals[i].Label = Labels[i].c_str();
+    }
+
+    return ReTwDefineEnum(_Name, Vals.empty() ? NULL : &(Vals[0]), (unsigned int)Vals.size());
+  }
+}
+
 namespace
 {
   struct ReTwTypeString

+ 1 - 0
include/igl/ReAntTweakBar.h

@@ -57,6 +57,7 @@ namespace igl
     const char *name, 
     const TwEnumVal *enumValues, 
     unsigned int nbValues);
+  TwType ReTwDefineEnum(const char * name,const char * enumString);
   
   struct ReTwRWItem
   {

+ 1 - 0
include/igl/Viewport.h

@@ -23,6 +23,7 @@ namespace igl
       camera(camera)
     {
     };
+    virtual ~Viewport(){}
     void reshape(
       const int x, 
       const int y, 

+ 1 - 0
include/igl/active_set.cpp

@@ -275,6 +275,7 @@ IGL_INLINE igl::SolverStatus igl::active_set(
       ret = SOLVER_STATUS_ERROR;
       break;
     }
+    //cout<<matlab_format(Z,"Z")<<endl;
 #ifdef ACTIVE_SET_CPP_DEBUG
     cout<<"  post"<<endl;
 #endif

+ 1 - 0
include/igl/add_barycenter.cpp

@@ -11,6 +11,7 @@ IGL_INLINE void igl::add_barycenter(
     Eigen::PlainObjectBase<Scalar> & VD, 
     Eigen::PlainObjectBase<Index> & FD)
 {
+  using namespace Eigen;
 	// Compute face barycenter
 	Eigen::MatrixXd BC;
 	igl::barycenter(V,F,BC);

+ 12 - 12
include/igl/principal_curvature.cpp

@@ -2,6 +2,7 @@
 #include <iostream>
 #include <fstream>
 #include <iomanip>
+#include <iostream>
 #include <queue>
 #include <list>
 #include <cmath>
@@ -16,11 +17,6 @@
 #include <igl/avg_edge_length.h>
 #include <igl/vf.h>
 
-using std::setfill;
-using std::setw;
-using std::cout;
-using std::endl;
-
 typedef enum
 {
   SPHERE_SEARCH,
@@ -102,8 +98,9 @@ public:
     }
     
     
-    IGL_INLINE static Quadric fit(vector<Eigen::Vector3d> &VV, bool zeroDetCheck, bool svd)
+    IGL_INLINE static Quadric fit(std::vector<Eigen::Vector3d> &VV, bool zeroDetCheck, bool svd)
     {
+      using namespace std;
       assert(VV.size() >= 5);
       if (VV.size() < 5)
       {
@@ -205,7 +202,7 @@ public:
   IGL_INLINE CurvatureCalculator();
   IGL_INLINE void init(const Eigen::MatrixXd& V, const Eigen::MatrixXi& F);
   
-  IGL_INLINE void finalEigenStuff (int, vector<Eigen::Vector3d>, Quadric );
+  IGL_INLINE void finalEigenStuff (int, std::vector<Eigen::Vector3d>, Quadric );
   IGL_INLINE void fitQuadric (Eigen::Vector3d, std::vector<Eigen::Vector3d> ref, const  std::vector<int>& , Quadric *);
   IGL_INLINE void applyProjOnPlane(Eigen::Vector3d, std::vector<int>, std::vector<int>&);
   IGL_INLINE void getSphere(const int, const double, std::vector<int>&, int min);
@@ -369,7 +366,7 @@ IGL_INLINE void CurvatureCalculator::init(const Eigen::MatrixXd& V, const Eigen:
 
 IGL_INLINE void CurvatureCalculator::fitQuadric (Eigen::Vector3d v, std::vector<Eigen::Vector3d> ref, const std::vector<int>& vv, Quadric *q)
 {
-  vector<Eigen::Vector3d> points;
+  std::vector<Eigen::Vector3d> points;
   points.reserve (vv.size());
   
   for (unsigned int i = 0; i < vv.size(); ++i) {
@@ -387,7 +384,7 @@ IGL_INLINE void CurvatureCalculator::fitQuadric (Eigen::Vector3d v, std::vector<
   *q = Quadric::fit (points, zeroDetCheck, svd);
 }
 
-IGL_INLINE void CurvatureCalculator::finalEigenStuff (int i, vector<Eigen::Vector3d> ref, Quadric q)
+IGL_INLINE void CurvatureCalculator::finalEigenStuff (int i, std::vector<Eigen::Vector3d> ref, Quadric q)
 {
   double a = q.a();
   double b = q.b();
@@ -501,7 +498,7 @@ IGL_INLINE void CurvatureCalculator::getSphere(const int start, const double r,
   queue->push_back(start);
   visited[start]=true;
   Eigen::Vector3d me=vertices.row(start);
-  std::priority_queue<std::pair<int, double>, vector<std::pair<int, double> >, comparer >* extra_candidates= new  std::priority_queue<std::pair<int, double>, vector<std::pair<int, double> >, comparer >();
+  std::priority_queue<std::pair<int, double>, std::vector<std::pair<int, double> >, comparer >* extra_candidates= new  std::priority_queue<std::pair<int, double>, std::vector<std::pair<int, double> >, comparer >();
   while (!queue->empty())
   {
     int toVisit=queue->front();
@@ -544,7 +541,7 @@ IGL_INLINE void CurvatureCalculator::getSphere(const int start, const double r,
   free(visited);
 }
 
-IGL_INLINE inline Eigen::Vector3d CurvatureCalculator::project(Eigen::Vector3d v, Eigen::Vector3d  vp, Eigen::Vector3d ppn)
+IGL_INLINE Eigen::Vector3d CurvatureCalculator::project(Eigen::Vector3d v, Eigen::Vector3d  vp, Eigen::Vector3d ppn)
 {
   return (vp - (ppn * ((vp - v).dot(ppn))));
 }
@@ -644,7 +641,7 @@ IGL_INLINE double CurvatureCalculator::getAverageEdge()
 
 IGL_INLINE void CurvatureCalculator::applyProjOnPlane(Eigen::Vector3d ppn, std::vector<int> vin, std::vector<int> &vout)
 {
-  for (vector<int>::iterator vpi = vin.begin(); vpi != vin.end(); ++vpi)
+  for (std::vector<int>::iterator vpi = vin.begin(); vpi != vin.end(); ++vpi)
     if (vertex_normals.row(*vpi) * ppn > 0.0f)
       vout.push_back (*vpi);
 }
@@ -670,6 +667,7 @@ IGL_INLINE void CurvatureCalculator::applyMontecarlo(std::vector<int>& vin, std:
 
 IGL_INLINE void CurvatureCalculator::computeCurvature()
 {
+  using namespace std;
   
   //CHECK che esista la mesh
   size_t vertices_count=vertices.rows() ;
@@ -765,6 +763,7 @@ IGL_INLINE void CurvatureCalculator::computeCurvature()
 
 IGL_INLINE void CurvatureCalculator::printCurvature(std::string outpath)
 {
+  using namespace std;
   if (!curvatureComputed)
     return;
   
@@ -798,6 +797,7 @@ IGL_INLINE void igl::principal_curvature(
                                          unsigned radius
                                          )
 {
+  using namespace std;
   
   // Preallocate memory
   PD1.resize(V.rows(),3);

+ 2 - 4
include/igl/principal_curvature.h

@@ -1,5 +1,5 @@
-#ifndef PRINCIPAL_CURVATURE_H
-#define PRINCIPAL_CURVATURE_H
+#ifndef IGL_PRINCIPAL_CURVATURE_H
+#define IGL_PRINCIPAL_CURVATURE_H
 
 
 #include <Eigen/Geometry>
@@ -8,13 +8,11 @@
 #include <stdio.h>
 #include <map>
 
-#define IGL_HEADER_ONLY
 #include <igl/igl_inline.h>
 #include <igl/cotmatrix.h>
 #include <igl/writeOFF.h>
 
 
-using std::vector;
 
 namespace igl
 {

+ 2 - 6
include/igl/read_eigen_from_CSV.cpp

@@ -3,14 +3,12 @@
 #include <sstream>
 #include <string>
 #include <fstream>
+#include <iostream>
 
 #include <vector>
 
-namespace igl
-{
-
 template <typename Scalar>
-IGL_INLINE bool read_eigen_from_CSV(const std::string str, Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>& M)
+IGL_INLINE bool igl::read_eigen_from_CSV(const std::string str, Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>& M)
 {
   using namespace std;
   using namespace igl;
@@ -56,8 +54,6 @@ IGL_INLINE bool read_eigen_from_CSV(const std::string str, Eigen::Matrix<Scalar,
   return false;
 }
 
-}
-
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
 // generated by autoexplicit.sh

+ 4 - 12
include/igl/read_eigen_from_CSV.h

@@ -1,13 +1,5 @@
-//
-//  IGL Lib - Simple C++ mesh library 
-//
-//  Copyright 2011, Daniele Panozzo. All rights reserved.
-
-// History:
-
-
-#ifndef IGL_READEIGENFROMCSV_H
-#define IGL_READEIGENFROMCSV_H
+#ifndef IGL_READ_EIGEN_FROM_CSV_H
+#define IGL_READ_EIGEN_FROM_CSV_H
 
 #include "igl/igl_inline.h"
 #include <Eigen/Core>
@@ -27,8 +19,8 @@ namespace igl
   IGL_INLINE bool read_eigen_from_CSV(const std::string str, Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>& M);
 }
 
-//#ifdef IGL_HEADER_ONLY
+#ifdef IGL_HEADER_ONLY
 #  include "read_eigen_from_CSV.cpp"
-//#endif
+#endif
 
 #endif