Эх сурвалжийг харах

Used the correct header guard for igl/copyleft/cgal/fast_winding_number.h

Former-commit-id: dd2112ee8fd353a4abb9f3bfd11258a67e54fd33
GavinBarill 7 жил өмнө
parent
commit
c31f738e66

+ 0 - 142
include/igl/build_octree.cpp

@@ -1,142 +0,0 @@
-#include "build_octree.h"
-#include <vector>
-#include <queue>
-
-
-namespace igl {
-  template <typename DerivedP, typename IndexType, typename CentersType,
-    typename WidthsType>
-  IGL_INLINE void build_octree(const Eigen::MatrixBase<DerivedP>& P,
-    std::vector<std::vector<IndexType> > & point_indices,
-    std::vector<Eigen::Matrix<IndexType,8,1>,
-      Eigen::aligned_allocator<Eigen::Matrix<IndexType,8,1> > > & children,
-    std::vector<Eigen::Matrix<CentersType,1,3>,
-      Eigen::aligned_allocator<Eigen::Matrix<CentersType,1,3> > > & centers,
-    std::vector<WidthsType> & widths)
-  {
-    const int MAX_DEPTH = 30000;
-
-    typedef Eigen::Matrix<IndexType,8,1> Vector8i;
-    typedef Eigen::Matrix<typename DerivedP::Scalar, 1, 3> RowVector3PType;
-    typedef Eigen::Matrix<CentersType, 1, 3> RowVector3CentersType;
-    
-    auto get_octant = [](RowVector3PType location,
-                         RowVector3CentersType center){
-      // We use a binary numbering of children. Treating the parent cell's
-      // center as the origin, we number the octants in the following manner:
-      // The first bit is 1 iff the octant's x coordinate is positive
-      // The second bit is 1 iff the octant's y coordinate is positive
-      // The third bit is 1 iff the octant's z coordinate is positive
-      //
-      // For example, the octant with negative x, positive y, positive z is:
-      // 110 binary = 6 decimal
-      IndexType index = 0;
-      if( location(0) >= center(0)){
-        index = index + 1;
-      }
-      if( location(1) >= center(1)){
-        index = index + 2;
-      }
-      if( location(2) >= center(2)){
-        index = index + 4;
-      }
-      return index;
-    };
-
-    
-    auto translate_center = [](const RowVector3CentersType & parent_center,
-                               const CentersType h,
-                               const IndexType child_index){
-      RowVector3CentersType change_vector;
-      change_vector << -h,-h,-h;
-      //positive x chilren are 1,3,4,7
-      if(child_index % 2){
-        change_vector(0) = h;
-      }
-      //positive y children are 2,3,6,7
-      if(child_index == 2 || child_index == 3 ||
-        child_index == 6 || child_index == 7){
-        change_vector(1) = h;
-      }
-      //positive z children are 4,5,6,7
-      if(child_index > 3){
-        change_vector(2) = h;
-      }
-      return parent_center + change_vector;
-    };
-  
-    // How many cells do we have so far?
-    IndexType m = 0;
-  
-    // Useful list of number 0..7
-    const Vector8i zero_to_seven = (Vector8i()<<0,1,2,3,4,5,6,7).finished();
-    const Vector8i neg_ones = (Vector8i()<<-1,-1,-1,-1,-1,-1,-1,-1).finished();
-  
-    std::function< void(const int, const int) > helper;
-    helper = [&helper,&translate_center,&get_octant,&m,
-              &zero_to_seven,&neg_ones,&P,
-              &point_indices,&children,&centers,&widths]
-    (const IndexType index, const int depth)-> void
-    {
-      if(point_indices.at(index).size() > 1 && depth < MAX_DEPTH){
-        //give the parent access to the children
-        children.at(index) = zero_to_seven.array() + m;
-        //make the children's data in our arrays
-      
-        //Add the children to the lists, as default children
-        WidthsType h = widths.at(index)/2;
-        RowVector3CentersType curr_center = centers.at(index);
-        for(int i = 0; i < 8; i++){
-          children.emplace_back(neg_ones);
-          point_indices.emplace_back(std::vector<IndexType>());
-          centers.emplace_back(translate_center(curr_center,h,i));
-          widths.emplace_back(h);
-        }
-      
-        //Split up the points into the corresponding children
-        for(int j = 0; j < point_indices.at(index).size(); j++){
-          IndexType curr_point_index = point_indices.at(index).at(j);
-          IndexType cell_of_curr_point =
-            get_octant(P.row(curr_point_index),curr_center)+m;
-          point_indices.at(cell_of_curr_point).emplace_back(curr_point_index);
-        }
-      
-        //Now increase m
-        m += 8;
-      
-        // Look ma, I'm calling myself.
-        for(int i = 0; i < 8; i++){
-          helper(children.at(index)(i),depth+1);
-        }
-      }
-    };
-  
-    {
-      std::vector<IndexType> all(P.rows());
-      for(IndexType i = 0;i<all.size();i++) all[i]=i;
-      point_indices.emplace_back(all);
-    }
-    children.emplace_back(neg_ones);
-  
-    //Get the minimum AABB for the points
-    RowVector3PType backleftbottom(P.col(0).minCoeff(),
-                                   P.col(1).minCoeff(),
-                                   P.col(2).minCoeff());
-    RowVector3PType frontrighttop(P.col(0).maxCoeff(),
-                                  P.col(1).maxCoeff(),
-                                  P.col(2).maxCoeff());
-    RowVector3CentersType aabb_center = (backleftbottom+frontrighttop)/2.0;
-    WidthsType aabb_width = std::max(std::max(
-                                          frontrighttop(0) - backleftbottom(0),
-                                          frontrighttop(1) - backleftbottom(1)),
-                                          frontrighttop(2) - backleftbottom(2));
-    centers.emplace_back( aabb_center );
-  
-    //Widths are the side length of the cube, (not half the side length):
-    widths.emplace_back( aabb_width );
-    m++;
-    // then you have to actually call the function
-    helper(0,0);
-  }
-}
-

+ 0 - 64
include/igl/build_octree.h

@@ -1,64 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2018 Gavin Barill <gavinpcb@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
-// obtain one at http://mozilla.org/MPL/2.0/
-
-#ifndef IGL_BUILD_OCTREE
-#define IGL_BUILD_OCTREE
-#include "igl_inline.h"
-#include <Eigen/Core>
-#include <vector>
-
-
-
-
-namespace igl
-{
-  // Given a set of 3D points P, generate data structures for a pointerless
-  // octree. Each cell stores its points, children, center location and width.
-  // Our octree is not dense. We use the following rule: if the current cell
-  // has any number of points, it will have all 8 children. A leaf cell will
-  // have -1's as its list of child indices.
-  //
-  // We use a binary numbering of children. Treating the parent cell's center
-  // as the origin, we number the octants in the following manner:
-  // The first bit is 1 iff the octant's x coordinate is positive
-  // The second bit is 1 iff the octant's y coordinate is positive
-  // The third bit is 1 iff the octant's z coordinate is positive
-  //
-  // For example, the octant with negative x, positive y, positive z is:
-  // 110 binary = 6 decimal
-  //
-  // Inputs:
-  //   P  #P by 3 list of point locations
-  //
-  // Outputs:
-  //   point_indices  a vector of vectors, where the ith entry is a vector of
-  //                  the indices into P that are the ith octree cell's points
-  //   children       a vector of vectors, where the ith entry is a vector of
-  //                  the ith octree cell's of octree children
-  //   centers        a vector where the ith entry is a 3d row vector
-  //                  representing the position of the ith cell's center
-  //   widths          a vector where the ith entry is the width of the ith
-  //                  octree cell
-  //
-  template <typename DerivedP, typename IndexType, typename CentersType,
-    typename WidthsType>
-  IGL_INLINE void build_octree(const Eigen::MatrixBase<DerivedP>& P,
-    std::vector<std::vector<IndexType> > & point_indices,
-    std::vector<Eigen::Matrix<IndexType,8,1>,
-      Eigen::aligned_allocator<Eigen::Matrix<IndexType,8,1> > > & children,
-    std::vector<Eigen::Matrix<CentersType,1,3>,
-      Eigen::aligned_allocator<Eigen::Matrix<CentersType,1,3> > > & centers,
-    std::vector<WidthsType> & widths);
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "build_octree.cpp"
-#endif
-
-#endif
-

+ 2 - 2
include/igl/copyleft/cgal/fast_winding_number.h

@@ -1,5 +1,5 @@
-#ifndef IGL_FAST_WINDING_NUMBER_CGAL
-#define IGL_FAST_WINDING_NUMBER_CGAL
+#ifndef IGL_COPYLEFT_CGAL_FAST_WINDING_NUMBER
+#define IGL_COPYLEFT_CGAL_FAST_WINDING_NUMBER
 #include "../../igl_inline.h"
 #include <Eigen/Core>
 #include <vector>

+ 0 - 105
include/igl/knn_octree.cpp

@@ -1,105 +0,0 @@
-#include "knn_octree.h"
-#include "parallel_for.h"
-
-#include <cmath>
-#include <queue>
-
-namespace igl {
-  template <typename DerivedP, typename KType, typename IndexType,
-    typename CentersType, typename WidthsType, typename DerivedI>
-  IGL_INLINE void knn_octree(
-    const Eigen::MatrixBase<DerivedP>& P,
-    const KType & k,
-    const std::vector<std::vector<IndexType> > & point_indices,
-    const std::vector<Eigen::Matrix<IndexType,8,1>,
-        Eigen::aligned_allocator<Eigen::Matrix<IndexType,8,1> > > & children,
-    const std::vector<Eigen::Matrix<CentersType,1,3>,
-        Eigen::aligned_allocator<Eigen::Matrix<CentersType,1,3> > > & centers,
-    const std::vector<WidthsType> & widths,
-    Eigen::PlainObjectBase<DerivedI> & I)
-  {
-    
-    typedef Eigen::Matrix<typename DerivedP::Scalar, 1, 3> RowVector3PType;
-    
-    int n = P.rows();
-    const KType real_k = std::min(n,k);
-    
-    auto distance_to_width_one_cube = [](RowVector3PType point){
-      return std::sqrt(std::pow(std::max(std::abs(point(0))-1,0.0),2)
-                       + std::pow(std::max(std::abs(point(1))-1,0.0),2)
-                       + std::pow(std::max(std::abs(point(2))-1,0.0),2));
-    };
-    
-    auto distance_to_cube = [&distance_to_width_one_cube]
-              (RowVector3PType point,
-               Eigen::Matrix<CentersType,1,3> cube_center,
-               WidthsType cube_width){
-      RowVector3PType transformed_point = (point-cube_center)/cube_width;
-      return cube_width*distance_to_width_one_cube(transformed_point);
-    };
-    
-    I.resize(n,real_k);
-    
-    igl::parallel_for(n,[&](int i)
-    {
-      int points_found = 0;
-      RowVector3PType point_of_interest = P.row(i);
-      
-      //To make my priority queue take both points and octree cells,
-      //I use the indices 0 to n-1 for the n points,
-      // and the indices n to n+m-1 for the m octree cells
-      
-      // Using lambda to compare elements.
-      auto cmp = [&point_of_interest, &P, &centers, &widths,
-                  &n, &distance_to_cube](int left, int right) {
-        double leftdistance, rightdistance;
-        if(left < n){ //left is a point index
-          leftdistance = (P.row(left) - point_of_interest).norm();
-        } else { //left is an octree cell
-          leftdistance = distance_to_cube(point_of_interest,
-                                            centers.at(left-n),
-                                            widths.at(left-n));
-        }
-      
-        if(right < n){ //left is a point index
-          rightdistance = (P.row(right) - point_of_interest).norm();
-        } else { //left is an octree cell
-          rightdistance = distance_to_cube(point_of_interest,
-                                             centers.at(right-n),
-                                             widths.at(right-n));
-        }
-        return leftdistance >= rightdistance;
-      };
-      
-      std::priority_queue<IndexType, std::vector<IndexType>,
-        decltype(cmp)> queue(cmp);
-      
-      queue.push(n); //This is the 0th octree cell (ie the root)
-      while(points_found < real_k){
-        IndexType curr_cell_or_point = queue.top();
-        queue.pop();
-        if(curr_cell_or_point < n){ //current index is for is a point
-          I(i,points_found) = curr_cell_or_point;
-          points_found++;
-        } else {
-          IndexType curr_cell = curr_cell_or_point - n;
-          if(children.at(curr_cell)(0) == -1){ //In the case of a leaf
-            if(point_indices.at(curr_cell).size() > 0){
-              //Assumption: Leaves either have one point, or none
-              queue.push(point_indices.at(curr_cell).at(0));
-            }
-          } else { //Not a leaf
-            for(int j = 0; j < 8; j++){
-              //+n to adjust for the octree cells
-              queue.push(children.at(curr_cell)(j)+n);
-            }
-          }
-        }
-      }
-    },1000);
-  }
-}
-
-
-
-

+ 0 - 51
include/igl/knn_octree.h

@@ -1,51 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2018 Gavin Barill <gavinpcb@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
-// obtain one at http://mozilla.org/MPL/2.0/
-
-#ifndef IGL_KNN_OCTREE
-#define IGL_KNN_OCTREE
-#include "igl_inline.h"
-#include <Eigen/Core>
-#include <vector>
-
-namespace igl
-{
-  // Given a 3D set of points P, an whole number k, and an octree
-  // find the indicies of the k nearest neighbors for each point in P.
-  // Note that each point is its own neighbor.
-  //
-  // The octree data structures used in this function are intended to be the
-  // same ones output from igl::build_octree
-  //
-  // Inputs:
-  //   P  #P by 3 list of point locations
-  //   k  number of neighbors to find
-  //   point_indices  a vector of vectors, where the ith entry is a vector of
-  //                  the indices into P that are the ith octree cell's points
-  //   children       a vector of vectors, where the ith entry is a vector of
-  //                  the ith octree cell's of octree children
-  //   centers        a vector where the ith entry is a 3d row vector
-  //                  representing the position of the ith cell's center
-  //   widths         a vector where the ith entry is the width of the ith
-  //                  octree cell
-  // Outputs:
-  //   I  #P by k list of k-nearest-neighbor indices into P
-  template <typename DerivedP, typename KType, typename IndexType,
-    typename CentersType, typename WidthsType, typename DerivedI>
-  IGL_INLINE void knn_octree(const Eigen::MatrixBase<DerivedP>& P,
-    const KType & k,
-    const std::vector<std::vector<IndexType> > & point_indices,
-    const std::vector<Eigen::Matrix<IndexType,8,1>, Eigen::aligned_allocator<Eigen::Matrix<IndexType,8,1> > > & children,
-    const std::vector<Eigen::Matrix<CentersType,1,3>, Eigen::aligned_allocator<Eigen::Matrix<CentersType,1,3> > > & centers,
-    const std::vector<WidthsType> & widths,
-    Eigen::PlainObjectBase<DerivedI> & I);
-}
-#ifndef IGL_STATIC_LIBRARY
-#  include "knn_octree.cpp"
-#endif
-#endif
-