From 761cb5e91e705be65cbfcace629b7bb334fcf50d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Dumas?= Date: Mon, 9 Jul 2018 16:31:06 -0400 Subject: [PATCH] Fix template instantiations. --- include/igl/AABB.cpp | 1 + .../igl/copyleft/tetgen/tetrahedralize.cpp | 51 +- include/igl/exact_geodesic.cpp | 451 +++++++++--------- include/igl/matrix_to_list.cpp | 1 + include/igl/ray_mesh_intersect.cpp | 21 +- python/CMakeLists.txt | 2 +- 6 files changed, 266 insertions(+), 261 deletions(-) diff --git a/include/igl/AABB.cpp b/include/igl/AABB.cpp index aa9e9231b..095373354 100644 --- a/include/igl/AABB.cpp +++ b/include/igl/AABB.cpp @@ -1071,4 +1071,5 @@ template void igl::AABB, 3>::init, 2>::init >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&); template double igl::AABB, 3>::squared_distance >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::Matrix const&, double, int&, Eigen::PlainObjectBase >&) const; +template bool igl::AABB, 3>::intersect_ray >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::Matrix const&, Eigen::Matrix const&, igl::Hit&) const; #endif diff --git a/include/igl/copyleft/tetgen/tetrahedralize.cpp b/include/igl/copyleft/tetgen/tetrahedralize.cpp index 8ef851b66..aba998b7e 100644 --- a/include/igl/copyleft/tetgen/tetrahedralize.cpp +++ b/include/igl/copyleft/tetgen/tetrahedralize.cpp @@ -1,15 +1,15 @@ // This file is part of libigl, a simple c++ geometry processing library. -// +// // Copyright (C) 2013 Alec Jacobson -// -// 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 "tetrahedralize.h" #include "mesh_to_tetgenio.h" #include "tetgenio_to_tetmesh.h" -// IGL includes +// IGL includes #include "../../matrix_to_list.h" #include "../../list_to_matrix.h" #include "../../boundary_facets.h" @@ -19,11 +19,11 @@ #include IGL_INLINE int igl::copyleft::tetgen::tetrahedralize( - const std::vector > & V, - const std::vector > & F, + const std::vector > & V, + const std::vector > & F, const std::string switches, - std::vector > & TV, - std::vector > & TT, + std::vector > & TV, + std::vector > & TT, std::vector > & TF) { using namespace std; @@ -60,10 +60,10 @@ IGL_INLINE int igl::copyleft::tetgen::tetrahedralize( } template < - typename DerivedV, - typename DerivedF, - typename DerivedTV, - typename DerivedTT, + typename DerivedV, + typename DerivedF, + typename DerivedTV, + typename DerivedTT, typename DerivedTF> IGL_INLINE int igl::copyleft::tetgen::tetrahedralize( const Eigen::PlainObjectBase& V, @@ -101,12 +101,12 @@ IGL_INLINE int igl::copyleft::tetgen::tetrahedralize( } template < - typename DerivedV, - typename DerivedF, - typename DerivedVM, - typename DerivedFM, - typename DerivedTV, - typename DerivedTT, + typename DerivedV, + typename DerivedF, + typename DerivedVM, + typename DerivedFM, + typename DerivedTV, + typename DerivedTT, typename DerivedTF, typename DerivedTM> IGL_INLINE int igl::copyleft::tetgen::tetrahedralize( @@ -124,7 +124,7 @@ IGL_INLINE int igl::copyleft::tetgen::tetrahedralize( vector > vV,vTV; vector > vF,vTT,vTF; vector vTM; - + matrix_to_list(V,vV); matrix_to_list(F,vF); vector vVM = matrix_to_list(VM); @@ -156,13 +156,13 @@ IGL_INLINE int igl::copyleft::tetgen::tetrahedralize( return e; } IGL_INLINE int igl::copyleft::tetgen::tetrahedralize( - const std::vector > & V, - const std::vector > & F, - const std::vector & VM, + const std::vector > & V, + const std::vector > & F, + const std::vector & VM, const std::vector & FM, const std::string switches, - std::vector > & TV, - std::vector > & TT, + std::vector > & TV, + std::vector > & TT, std::vector > & TF, std::vector & TM) { @@ -216,4 +216,5 @@ IGL_INLINE int igl::copyleft::tetgen::tetrahedralize( // Explicit template instantiation template int igl::copyleft::tetgen::tetrahedralize, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::basic_string, std::allocator >, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template int igl::copyleft::tetgen::tetrahedralize,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(const Eigen::PlainObjectBase > &,const Eigen::PlainObjectBase > &,const Eigen::PlainObjectBase > &,const Eigen::PlainObjectBase > &,const std::basic_string, std::allocator >,Eigen::PlainObjectBase > &,Eigen::PlainObjectBase > &,Eigen::PlainObjectBase > &, Eigen::PlainObjectBase > &); +template int igl::copyleft::tetgen::tetrahedralize, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__cxx11::basic_string, std::allocator >, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/exact_geodesic.cpp b/include/igl/exact_geodesic.cpp index 0ffa8b039..a0c5a93d2 100644 --- a/include/igl/exact_geodesic.cpp +++ b/include/igl/exact_geodesic.cpp @@ -33,7 +33,7 @@ double const GEODESIC_INF = 1e100; //in order to avoid numerical problems with "infinitely small" intervals, //we drop all the intervals smaller than SMALLEST_INTERVAL_RATIO*edge_length -double const SMALLEST_INTERVAL_RATIO = 1e-6; +double const SMALLEST_INTERVAL_RATIO = 1e-6; //double const SMALL_EPSILON = 1e-10; @@ -65,7 +65,7 @@ inline bool read_mesh_from_file(char* filename, std::ifstream file(filename); assert(file.is_open()); if(!file.is_open()) return false; - + unsigned num_points; file >> num_points; assert(num_points>=3); @@ -96,16 +96,16 @@ class SimlpeMemoryAllocator public: typedef T* pointer; - SimlpeMemoryAllocator(unsigned block_size = 0, + SimlpeMemoryAllocator(unsigned block_size = 0, unsigned max_number_of_blocks = 0) { - reset(block_size, + reset(block_size, max_number_of_blocks); }; ~SimlpeMemoryAllocator(){}; - void reset(unsigned block_size, + void reset(unsigned block_size, unsigned max_number_of_blocks) { m_block_size = block_size; @@ -135,7 +135,7 @@ public: return result; }; private: - std::vector > m_storage; + std::vector > m_storage; unsigned m_block_size; //size of a single block unsigned m_max_number_of_blocks; //maximum allowed number of blocks unsigned m_current_position; //first unused element inside the current block @@ -148,10 +148,10 @@ class MemoryAllocator public: typedef T* pointer; - MemoryAllocator(unsigned block_size = 1024, + MemoryAllocator(unsigned block_size = 1024, unsigned max_number_of_blocks = 1024) { - reset(block_size, + reset(block_size, max_number_of_blocks); }; @@ -159,11 +159,11 @@ public: void clear() { - reset(m_block_size, + reset(m_block_size, m_max_number_of_blocks); } - void reset(unsigned block_size, + void reset(unsigned block_size, unsigned max_number_of_blocks) { m_block_size = block_size; @@ -271,10 +271,10 @@ private: -class Vertex; -class Edge; -class Face; -class Mesh; +class Vertex; +class Edge; +class Face; +class Mesh; class MeshElementBase; typedef Vertex* vertex_pointer; @@ -283,7 +283,7 @@ typedef Face* face_pointer; typedef Mesh* mesh_pointer; typedef MeshElementBase* base_pointer; -template //simple vector that stores info about mesh references +template //simple vector that stores info about mesh references class SimpleVector //for efficiency, it uses an outside memory allocator { public: @@ -334,9 +334,9 @@ enum PointType class MeshElementBase //prototype of vertices, edges and faces { public: - typedef SimpleVector vertex_pointer_vector; - typedef SimpleVector edge_pointer_vector; - typedef SimpleVector face_pointer_vector; + typedef SimpleVector vertex_pointer_vector; + typedef SimpleVector edge_pointer_vector; + typedef SimpleVector face_pointer_vector; MeshElementBase(): m_id(0), @@ -347,7 +347,7 @@ public: edge_pointer_vector& adjacent_edges(){return m_adjacent_edges;}; face_pointer_vector& adjacent_faces(){return m_adjacent_faces;}; - unsigned& id(){return m_id;}; + unsigned& id(){return m_id;}; PointType type(){return m_type;}; protected: @@ -432,7 +432,7 @@ public: ~Vertex(){}; bool& saddle_or_boundary(){return m_saddle_or_boundary;}; -private: +private: //this flag speeds up exact geodesic algorithm bool m_saddle_or_boundary; //it is true if total adjacent angle is larger than 2*PI or this vertex belongs to the mesh boundary }; @@ -491,10 +491,10 @@ public: return NULL; } - assert(adjacent_faces()[0]->id() == f->id() || + assert(adjacent_faces()[0]->id() == f->id() || adjacent_faces()[1]->id() == f->id()); - return adjacent_faces()[0]->id() == f->id() ? + return adjacent_faces()[0]->id() == f->id() ? adjacent_faces()[1] : adjacent_faces()[0]; }; @@ -508,7 +508,7 @@ public: bool belongs(vertex_pointer v) { - return adjacent_vertices()[0]->id() == v->id() || + return adjacent_vertices()[0]->id() == v->id() || adjacent_vertices()[1]->id() == v->id(); } @@ -517,8 +517,8 @@ public: vertex_pointer v0(){return adjacent_vertices()[0];}; vertex_pointer v1(){return adjacent_vertices()[1];}; - void local_coordinates(Point3D* point, - double& x, + void local_coordinates(Point3D* point, + double& x, double& y) { double d0 = point->distance(v0()); @@ -569,7 +569,7 @@ public: }; SurfacePoint(edge_pointer e, //set the surface point in the middle of the edge - double a = 0.5): + double a = 0.5): m_p(e) { double b = 1 - a; @@ -582,7 +582,7 @@ public: z() = b*v0->z() + a*v1->z(); }; - SurfacePoint(base_pointer g, + SurfacePoint(base_pointer g, double x, double y, double z, @@ -694,7 +694,7 @@ public: template void initialize_mesh_data(unsigned num_vertices, - Points& p, + Points& p, unsigned num_faces, Faces& tri); //build mesh from regular point-triangle representation @@ -705,7 +705,7 @@ public: std::vector& edges(){return m_edges;}; std::vector& faces(){return m_faces;}; - unsigned closest_vertices(SurfacePoint* p, + unsigned closest_vertices(SurfacePoint* p, std::vector* storage = NULL); //list vertices closest to the point private: @@ -714,9 +714,9 @@ private: bool verify(); //verifies connectivity of the mesh and prints some debug info typedef void* void_pointer; - void_pointer allocate_pointers(unsigned n) + void_pointer allocate_pointers(unsigned n) { - return m_pointer_allocator.allocate(n); + return m_pointer_allocator.allocate(n); } std::vector m_vertices; @@ -726,7 +726,7 @@ private: SimlpeMemoryAllocator m_pointer_allocator; //fast memory allocating for Face/Vertex/Edge cross-references }; -inline unsigned Mesh::closest_vertices(SurfacePoint* p, +inline unsigned Mesh::closest_vertices(SurfacePoint* p, std::vector* storage) { assert(p->type() != UNDEFINED_POINT); @@ -778,20 +778,20 @@ void Mesh::initialize_mesh_data(Points& p, Faces& tri) //build mesh from regula assert(p.size() % 3 == 0); unsigned const num_vertices = p.size() / 3; assert(tri.size() % 3 == 0); - unsigned const num_faces = tri.size() / 3; + unsigned const num_faces = tri.size() / 3; initialize_mesh_data(num_vertices, p, num_faces, tri); } template void Mesh::initialize_mesh_data(unsigned num_vertices, - Points& p, + Points& p, unsigned num_faces, Faces& tri) { unsigned const approximate_number_of_internal_pointers = (num_vertices + num_faces)*4; - unsigned const max_number_of_pointer_blocks = 100; - m_pointer_allocator.reset(approximate_number_of_internal_pointers, + unsigned const max_number_of_pointer_blocks = 100; + m_pointer_allocator.reset(approximate_number_of_internal_pointers, max_number_of_pointer_blocks); m_vertices.resize(num_vertices); @@ -846,7 +846,7 @@ inline void Mesh::build_adjacencies() unsigned num_adjacent_faces = count[i]; v.adjacent_faces().set_allocation(allocate_pointers(num_adjacent_faces), //allocate three units of memory - num_adjacent_faces); + num_adjacent_faces); } std::fill(count.begin(), count.end(), 0); @@ -875,7 +875,7 @@ inline void Mesh::build_adjacencies() half_edges[k].vertex_0 = std::min(vertex_id_1, vertex_id_2); half_edges[k].vertex_1 = std::max(vertex_id_1, vertex_id_2); - k++; + k++; } } std::sort(half_edges.begin(), half_edges.end()); @@ -910,7 +910,7 @@ inline void Mesh::build_adjacencies() e.adjacent_vertices()[1] = &m_vertices[half_edges[i].vertex_1]; e.length() = e.adjacent_vertices()[0]->distance(e.adjacent_vertices()[1]); - assert(e.length() > 1e-100); //algorithm works well with non-degenerate meshes only + assert(e.length() > 1e-100); //algorithm works well with non-degenerate meshes only if(i != half_edges.size()-1 && half_edges[i] == half_edges[i+1]) //double edge { @@ -939,7 +939,7 @@ inline void Mesh::build_adjacencies() for(unsigned i=0; iadjacent_edges()[count[v->id()]++] = &e; } - } + } // Faces->adjacent Edges for(unsigned i=0; iid()]<3); f->adjacent_edges()[count[f->id()]++] = &e; } - } + } //compute angles for the faces for(unsigned i=0; i1e-5); //algorithm works well with non-degenerate meshes only + assert(angle>1e-5); //algorithm works well with non-degenerate meshes only f.corner_angles()[j] = angle; sum += angle; } - assert(std::abs(sum - igl::PI) < 1e-5); //algorithm works well with non-degenerate meshes only + assert(std::abs(sum - igl::PI) < 1e-5); //algorithm works well with non-degenerate meshes only } //define m_turn_around_flag for vertices @@ -1009,7 +1009,7 @@ inline void Mesh::build_adjacencies() for(unsigned i=0; i 2.0*igl::PI - 1e-5); + v.saddle_or_boundary() = (total_vertex_angle[v.id()] > 2.0*igl::PI - 1e-5); } for(unsigned i=0; i map(m_vertices.size(), false); for(unsigned i=0; i* stop_points, + void set_stop_conditions(std::vector* stop_points, double stop_distance); double stop_distance() { @@ -1676,7 +1676,7 @@ protected: geodesic::Mesh* m_mesh; double m_time_consumed; //how much time does the propagation step takes - double m_propagation_distance_stopped; //at what distance (if any) the propagation algorithm stopped + double m_propagation_distance_stopped; //at what distance (if any) the propagation algorithm stopped }; inline double length(std::vector& path) @@ -1695,7 +1695,7 @@ inline double length(std::vector& path) inline void print_info_about_path(std::vector& path) { std::cout << "number of the points in the path = " << path.size() - << ", length of the path = " << length(path) + << ", length of the path = " << length(path) << std::endl; } @@ -1723,7 +1723,7 @@ inline void GeodesicAlgorithmBase::geodesic(SurfacePoint& source, std::vector stop_points(1, destination); double const max_propagation_distance = GEODESIC_INF; - propagate(sources, + propagate(sources, max_propagation_distance, &stop_points); @@ -1736,7 +1736,7 @@ inline void GeodesicAlgorithmBase::geodesic(std::vector& sources, { double const max_propagation_distance = GEODESIC_INF; - propagate(sources, + propagate(sources, max_propagation_distance, &destinations); //we use desinations as stop points @@ -1748,7 +1748,7 @@ inline void GeodesicAlgorithmBase::geodesic(std::vector& sources, } } -inline void GeodesicAlgorithmBase::set_stop_conditions(std::vector* stop_points, +inline void GeodesicAlgorithmBase::set_stop_conditions(std::vector* stop_points, double stop_distance) { m_max_propagation_distance = stop_distance; @@ -1768,7 +1768,7 @@ inline void GeodesicAlgorithmBase::set_stop_conditions(std::vector possible_vertices.clear(); m_mesh->closest_vertices(point, &possible_vertices); - + vertex_pointer closest_vertex = NULL; double min_distance = 1e100; for(unsigned j = 0; j < possible_vertices.size(); ++j) @@ -1803,7 +1803,7 @@ public: { m_edge_interval_lists[i].initialize(&mesh->edges()[i]); } - }; + }; ~GeodesicAlgorithmExact(){}; @@ -1815,7 +1815,7 @@ public: std::vector& path); unsigned best_source(SurfacePoint& point, //quickly find what source this point belongs to and what is the distance to this source - double& best_source_distance); + double& best_source_distance); void print_statistics(); @@ -1826,10 +1826,10 @@ private: IntervalWithStop* candidates, //up to two candidates unsigned num_candidates); - unsigned compute_propagated_parameters(double pseudo_x, - double pseudo_y, + unsigned compute_propagated_parameters(double pseudo_x, + double pseudo_y, double d, //parameters of the interval - double start, + double start, double end, //start/end of the interval double alpha, //corner angle double L, //length of the new edge @@ -1839,8 +1839,8 @@ private: bool turn_right, IntervalWithStop* candidates); //if it is the last interval on the edge - void construct_propagated_intervals(bool invert, - edge_pointer edge, + void construct_propagated_intervals(bool invert, + edge_pointer edge, face_pointer face, //constructs iNew from the rest of the data IntervalWithStop* candidates, unsigned& num_candidates, @@ -1852,11 +1852,11 @@ private: double sin_alpha, double cos_alpha); //used in construct_propagated_intervals - unsigned intersect_intervals(interval_pointer zero, + unsigned intersect_intervals(interval_pointer zero, IntervalWithStop* one); //intersecting two intervals with up to three intervals in the end - interval_pointer best_first_interval(SurfacePoint& point, - double& best_total_distance, + interval_pointer best_first_interval(SurfacePoint& point, + double& best_total_distance, double& best_interval_position, unsigned& best_source_index); @@ -1883,31 +1883,31 @@ private: m_sources.initialize(sources); } - void initialize_propagation_data(); + void initialize_propagation_data(); void list_edges_visible_from_source(MeshElementBase* p, std::vector& storage); //used in initialization long visible_from_source(SurfacePoint& point); //used in backtracing - void best_point_on_the_edge_set(SurfacePoint& point, + void best_point_on_the_edge_set(SurfacePoint& point, std::vector const& storage, interval_pointer& best_interval, double& best_total_distance, double& best_interval_position); - void possible_traceback_edges(SurfacePoint& point, + void possible_traceback_edges(SurfacePoint& point, std::vector& storage); bool erase_from_queue(interval_pointer p); IntervalQueue m_queue; //interval queue - MemoryAllocator m_memory_allocator; //quickly allocate and deallocate intervals - std::vector m_edge_interval_lists; //every edge has its interval data + MemoryAllocator m_memory_allocator; //quickly allocate and deallocate intervals + std::vector m_edge_interval_lists; //every edge has its interval data enum MapType {OLD, NEW}; //used for interval intersection - MapType map[5]; + MapType map[5]; double start[6]; interval_pointer i_new[5]; @@ -1917,7 +1917,7 @@ private: SortedSources m_sources; }; -inline void GeodesicAlgorithmExact::best_point_on_the_edge_set(SurfacePoint& point, +inline void GeodesicAlgorithmExact::best_point_on_the_edge_set(SurfacePoint& point, std::vector const& storage, interval_pointer& best_interval, double& best_total_distance, @@ -1933,9 +1933,9 @@ inline void GeodesicAlgorithmExact::best_point_on_the_edge_set(SurfacePoint& poi double distance; interval_pointer interval; - list->find_closest_point(&point, - offset, - distance, + list->find_closest_point(&point, + offset, + distance, interval); if(distance < best_total_distance) @@ -1947,7 +1947,7 @@ inline void GeodesicAlgorithmExact::best_point_on_the_edge_set(SurfacePoint& poi } } -inline void GeodesicAlgorithmExact::possible_traceback_edges(SurfacePoint& point, +inline void GeodesicAlgorithmExact::possible_traceback_edges(SurfacePoint& point, std::vector& storage) { storage.clear(); @@ -1986,7 +1986,7 @@ inline long GeodesicAlgorithmExact::visible_from_source(SurfacePoint& point) //n { assert(point.type() != UNDEFINED_POINT); - if(point.type() == EDGE) + if(point.type() == EDGE) { edge_pointer e = static_cast(point.base_element()); list_pointer list = interval_list(e); @@ -2002,11 +2002,11 @@ inline long GeodesicAlgorithmExact::visible_from_source(SurfacePoint& point) //n return -1; } } - else if(point.type() == FACE) + else if(point.type() == FACE) { return -1; } - else if(point.type() == VERTEX) + else if(point.type() == VERTEX) { vertex_pointer v = static_cast(point.base_element()); for(unsigned i=0; iadjacent_edges().size(); ++i) @@ -2105,14 +2105,14 @@ inline bool GeodesicAlgorithmExact::erase_from_queue(interval_pointer p) return false; } -inline unsigned GeodesicAlgorithmExact::intersect_intervals(interval_pointer zero, +inline unsigned GeodesicAlgorithmExact::intersect_intervals(interval_pointer zero, IntervalWithStop* one) //intersecting two intervals with up to three intervals in the end { assert(zero->edge()->id() == one->edge()->id()); assert(zero->stop() > one->start() && zero->start() < one->stop()); assert(one->min() < GEODESIC_INF/10.0); - double const local_epsilon = SMALLEST_INTERVAL_RATIO*one->edge()->length(); + double const local_epsilon = SMALLEST_INTERVAL_RATIO*one->edge()->length(); unsigned N=0; if(zero->min() > GEODESIC_INF/10.0) @@ -2141,7 +2141,7 @@ inline unsigned GeodesicAlgorithmExact::intersect_intervals(interval_pointer zer return N; } - double const local_small_epsilon = 1e-8*one->edge()->length(); + double const local_small_epsilon = 1e-8*one->edge()->length(); double D = zero->d() - one->d(); double x0 = zero->pseudo_x(); @@ -2195,7 +2195,7 @@ inline unsigned GeodesicAlgorithmExact::intersect_intervals(interval_pointer zer inter[0] = (-B + det)/A; inter[1] = (-B - det)/A; } - + if(inter[1] - inter[0] > local_small_epsilon) { Ninter = 2; @@ -2218,7 +2218,7 @@ inline unsigned GeodesicAlgorithmExact::intersect_intervals(interval_pointer zer double good_start[4]; //points of intersection within the (left, right) limits +"left" + "right" good_start[0] = left; - char Ngood_start=1; //number of the points of the intersection + char Ngood_start=1; //number of the points of the intersection for(char i=0; istart(); // just to make sure that epsilons do not damage anything //start[N] = zero->stop(); - return N; + return N; } inline void GeodesicAlgorithmExact::initialize_propagation_data() @@ -2283,14 +2283,14 @@ inline void GeodesicAlgorithmExact::initialize_propagation_data() IntervalWithStop candidate; std::vector edges_visible_from_source; - for(unsigned i=0; ibase_element(), + list_edges_visible_from_source(source->base_element(), edges_visible_from_source); - + for(unsigned j=0; j& sources face_pointer face = edge->adjacent_faces()[i]; //if we come from 1, go to 2 edge_pointer next_edge = face->next_edge(edge,edge->v0()); - unsigned num_propagated = compute_propagated_parameters(min_interval->pseudo_x(), - min_interval->pseudo_y(), + unsigned num_propagated = compute_propagated_parameters(min_interval->pseudo_x(), + min_interval->pseudo_y(), min_interval->d(), //parameters of the interval - min_interval->start(), + min_interval->start(), min_interval->stop(), //start/end of the interval face->vertex_angle(edge->v0()), //corner angle next_edge->length(), //length of the new edge @@ -2378,22 +2378,22 @@ inline void GeodesicAlgorithmExact::propagate(std::vector& sources if(num_propagated) { - if(candidates[num_propagated-1].stop() != next_edge->length()) + if(candidates[num_propagated-1].stop() != next_edge->length()) { propagate_to_right = false; } - + bool const invert = next_edge->v0()->id() != edge->v0()->id(); //if the origins coinside, do not invert intervals - construct_propagated_intervals(invert, //do not inverse - next_edge, + construct_propagated_intervals(invert, //do not inverse + next_edge, face, candidates, num_propagated, min_interval); - - update_list_and_queue(interval_list(next_edge), - candidates, + + update_list_and_queue(interval_list(next_edge), + candidates, num_propagated); } @@ -2403,10 +2403,10 @@ inline void GeodesicAlgorithmExact::propagate(std::vector& sources double length = edge->length(); next_edge = face->next_edge(edge,edge->v1()); - num_propagated = compute_propagated_parameters(length - min_interval->pseudo_x(), - min_interval->pseudo_y(), + num_propagated = compute_propagated_parameters(length - min_interval->pseudo_x(), + min_interval->pseudo_y(), min_interval->d(), //parameters of the interval - length - min_interval->stop(), + length - min_interval->stop(), length - min_interval->start(), //start/end of the interval face->vertex_angle(edge->v1()), //corner angle next_edge->length(), //length of the new edge @@ -2420,20 +2420,20 @@ inline void GeodesicAlgorithmExact::propagate(std::vector& sources { bool const invert = next_edge->v0()->id() != edge->v1()->id(); //if the origins coinside, do not invert intervals - construct_propagated_intervals(invert, //do not inverse - next_edge, + construct_propagated_intervals(invert, //do not inverse + next_edge, face, candidates, num_propagated, min_interval); - update_list_and_queue(interval_list(next_edge), - candidates, + update_list_and_queue(interval_list(next_edge), + candidates, num_propagated); } } - } - } + } + } m_propagation_distance_stopped = m_queue.empty() ? GEODESIC_INF : (*m_queue.begin())->min(); clock_t stop = clock(); @@ -2467,7 +2467,7 @@ inline bool GeodesicAlgorithmExact::check_stop_conditions(unsigned& index) vertex_pointer v = m_stop_vertices[index].first; edge_pointer edge = v->adjacent_edges()[0]; //take any edge - double distance = edge->v0()->id() == v->id() ? + double distance = edge->v0()->id() == v->id() ? interval_list(edge)->signal(0.0) : interval_list(edge)->signal(edge->length()); @@ -2489,13 +2489,13 @@ inline void GeodesicAlgorithmExact::update_list_and_queue(list_pointer list, assert(num_candidates <= 2); //assert(list->first() != NULL); edge_pointer edge = list->edge(); - double const local_epsilon = SMALLEST_INTERVAL_RATIO * edge->length(); + double const local_epsilon = SMALLEST_INTERVAL_RATIO * edge->length(); - if(list->first() == NULL) + if(list->first() == NULL) { interval_pointer* p = &list->first(); IntervalWithStop* first; - IntervalWithStop* second; + IntervalWithStop* second; if(num_candidates == 1) { @@ -2503,14 +2503,14 @@ inline void GeodesicAlgorithmExact::update_list_and_queue(list_pointer list, second = candidates; first->compute_min_distance(first->stop()); } - else - { + else + { if(candidates->start() <= (candidates+1)->start()) { first = candidates; second = candidates+1; } - else + else { first = candidates+1; second = candidates; @@ -2559,7 +2559,7 @@ inline void GeodesicAlgorithmExact::update_list_and_queue(list_pointer list, for(unsigned i=0; ifirst(); @@ -2567,14 +2567,14 @@ inline void GeodesicAlgorithmExact::update_list_and_queue(list_pointer list, while(p != NULL && p->stop() - local_epsilon < q->start()) { - p = p->next(); + p = p->next(); } while(p != NULL && p->start() < q->stop() - local_epsilon) //go through all old intervals { unsigned const N = intersect_intervals(p, q); //interset two intervals - if(N == 1) + if(N == 1) { if(map[0]==OLD) //if "p" is always better, we do not need to update anything) { @@ -2586,12 +2586,12 @@ inline void GeodesicAlgorithmExact::update_list_and_queue(list_pointer list, previous = NULL; } - p = p->next(); - + p = p->next(); + } else if(previous) //extend previous interval to cover everything; remove p { - previous->next() = p->next(); + previous->next() = p->next(); erase_from_queue(p); m_memory_allocator.deallocate(p); @@ -2608,7 +2608,7 @@ inline void GeodesicAlgorithmExact::update_list_and_queue(list_pointer list, previous->start() = start[0]; previous->next() = next; - p = next; + p = next; } continue; } @@ -2639,7 +2639,7 @@ inline void GeodesicAlgorithmExact::update_list_and_queue(list_pointer list, else if(previous) //extend previous interval to cover everything; remove p { i_new[0] = previous; - previous->next() = i_new[1]; + previous->next() = i_new[1]; m_memory_allocator.deallocate(p); previous = NULL; } @@ -2654,11 +2654,11 @@ inline void GeodesicAlgorithmExact::update_list_and_queue(list_pointer list, assert(!previous); - for(unsigned j=1; jnext() = swap.next(); } - else + else { current_interval->next() = i_new[j+1]; } @@ -2710,10 +2710,10 @@ inline void GeodesicAlgorithmExact::update_list_and_queue(list_pointer list, } } -inline unsigned GeodesicAlgorithmExact::compute_propagated_parameters(double pseudo_x, - double pseudo_y, +inline unsigned GeodesicAlgorithmExact::compute_propagated_parameters(double pseudo_x, + double pseudo_y, double d, //parameters of the interval - double begin, + double begin, double end, //start/end of the interval double alpha, //corner angle double L, //length of the new edge @@ -2722,7 +2722,7 @@ inline unsigned GeodesicAlgorithmExact::compute_propagated_parameters(double pse bool turn_left, bool turn_right, IntervalWithStop* candidates) //if it is the last interval on the edge -{ +{ assert(pseudo_y<=0.0); assert(d= L) @@ -2793,10 +2793,10 @@ inline unsigned GeodesicAlgorithmExact::compute_propagated_parameters(double pse } } - double L2 = compute_positive_intersection(end, - pseudo_x, - pseudo_y, - sin_alpha, + double L2 = compute_positive_intersection(end, + pseudo_x, + pseudo_y, + sin_alpha, cos_alpha); if(L2 < 0 || L2 >= L) @@ -2836,8 +2836,8 @@ inline unsigned GeodesicAlgorithmExact::compute_propagated_parameters(double pse } } -inline void GeodesicAlgorithmExact::construct_propagated_intervals(bool invert, - edge_pointer edge, +inline void GeodesicAlgorithmExact::construct_propagated_intervals(bool invert, + edge_pointer edge, face_pointer face, //constructs iNew from the rest of the data IntervalWithStop* candidates, unsigned& num_candidates, @@ -2845,9 +2845,9 @@ inline void GeodesicAlgorithmExact::construct_propagated_intervals(bool invert, { double edge_length = edge->length(); double local_epsilon = SMALLEST_INTERVAL_RATIO * edge_length; - + //kill very small intervals in order to avoid precision problems - if(num_candidates == 2) + if(num_candidates == 2) { double start = std::min(candidates->start(), (candidates+1)->start()); double stop = std::max(candidates->stop(), (candidates+1)->stop()); @@ -2866,8 +2866,8 @@ inline void GeodesicAlgorithmExact::construct_propagated_intervals(bool invert, } } - IntervalWithStop* first; - IntervalWithStop* second; + IntervalWithStop* first; + IntervalWithStop* second; if(num_candidates == 1) { first = candidates; @@ -2880,7 +2880,7 @@ inline void GeodesicAlgorithmExact::construct_propagated_intervals(bool invert, first = candidates; second = candidates+1; } - else + else { first = candidates+1; second = candidates; @@ -2898,8 +2898,8 @@ inline void GeodesicAlgorithmExact::construct_propagated_intervals(bool invert, } //invert intervals if necessary; fill missing data and set pointers correctly - Interval::DirectionType direction = edge->adjacent_faces()[0]->id() == face->id() ? - Interval::FROM_FACE_0 : + Interval::DirectionType direction = edge->adjacent_faces()[0]->id() == face->id() ? + Interval::FROM_FACE_0 : Interval::FROM_FACE_1; if(!invert) //in this case everything is straighforward, we do not have to invert the intervals @@ -2918,7 +2918,7 @@ inline void GeodesicAlgorithmExact::construct_propagated_intervals(bool invert, assert(p->start() < p->stop()); } } - else //now we have to invert the intervals + else //now we have to invert the intervals { for(unsigned i=0; i(point.base_element()); list_pointer list = interval_list(e); @@ -2984,7 +2984,7 @@ inline interval_pointer GeodesicAlgorithmExact::best_first_interval(SurfacePoint best_source_index = best_interval->source_index(); } } - else if(point.type() == FACE) + else if(point.type() == FACE) { face_pointer f = static_cast(point.base_element()); for(unsigned i=0; i<3; ++i) @@ -2996,9 +2996,9 @@ inline interval_pointer GeodesicAlgorithmExact::best_first_interval(SurfacePoint double distance; interval_pointer interval; - list->find_closest_point(&point, - offset, - distance, + list->find_closest_point(&point, + offset, + distance, interval); if(interval && distance < best_total_distance) @@ -3025,14 +3025,14 @@ inline interval_pointer GeodesicAlgorithmExact::best_first_interval(SurfacePoint } } } - else if(point.type() == VERTEX) + else if(point.type() == VERTEX) { vertex_pointer v = static_cast(point.base_element()); for(unsigned i=0; iadjacent_edges().size(); ++i) { edge_pointer e = v->adjacent_edges()[i]; list_pointer list = interval_list(e); - + double position = e->v0()->id() == v->id() ? 0.0 : e->length(); interval_pointer interval = list->covering_interval(position); if(interval) @@ -3063,14 +3063,14 @@ inline interval_pointer GeodesicAlgorithmExact::best_first_interval(SurfacePoint inline void GeodesicAlgorithmExact::trace_back(SurfacePoint& destination, //trace back piecewise-linear path std::vector& path) -{ +{ path.clear(); - double best_total_distance; + double best_total_distance; double best_interval_position; unsigned source_index = std::numeric_limits::max(); - interval_pointer best_interval = best_first_interval(destination, - best_total_distance, - best_interval_position, + interval_pointer best_interval = best_first_interval(destination, + best_total_distance, + best_interval_position, source_index); if(best_total_distance >= GEODESIC_INF/2.0) //unable to find the right path @@ -3080,11 +3080,11 @@ inline void GeodesicAlgorithmExact::trace_back(SurfacePoint& destination, //tra path.push_back(destination); - if(best_interval) //if we did not hit the face source immediately + if(best_interval) //if we did not hit the face source immediately { std::vector possible_edges; possible_edges.reserve(10); - + while(visible_from_source(path.back()) < 0) //while this point is not in the direct visibility of some source (if we are inside the FACE, we obviously hit the source) { SurfacePoint& q = path.back(); @@ -3095,7 +3095,7 @@ inline void GeodesicAlgorithmExact::trace_back(SurfacePoint& destination, //tra double total_distance; double position; - best_point_on_the_edge_set(q, + best_point_on_the_edge_set(q, possible_edges, interval, total_distance, @@ -3141,11 +3141,11 @@ inline void GeodesicAlgorithmExact::print_statistics() } double intervals_per_edge = (double)interval_counter/(double)m_edge_interval_lists.size(); - double memory = m_edge_interval_lists.size()*sizeof(IntervalList) + + double memory = m_edge_interval_lists.size()*sizeof(IntervalList) + interval_counter*sizeof(Interval); std::cout << "uses about " << memory/1e6 << "Mb of memory" <, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(Eigen::MatrixBase> const &, Eigen::MatrixBase> const &, Eigen::MatrixBase> const &, Eigen::MatrixBase> const &, Eigen::MatrixBase> const &, Eigen::MatrixBase> const &, Eigen::PlainObjectBase> &); +template void igl::exact_geodesic, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/matrix_to_list.cpp b/include/igl/matrix_to_list.cpp index c3a74144d..1c30dff91 100644 --- a/include/igl/matrix_to_list.cpp +++ b/include/igl/matrix_to_list.cpp @@ -75,4 +75,5 @@ template void igl::matrix_to_list >(Eigen::D template void igl::matrix_to_list >(Eigen::DenseBase > const&, std::vector::Scalar, std::allocator::Scalar> >, std::allocator::Scalar, std::allocator::Scalar> > > >&); template void igl::matrix_to_list >(Eigen::DenseBase > const&, std::vector::Scalar, std::allocator::Scalar> >&); template void igl::matrix_to_list >(Eigen::DenseBase > const&, std::vector::Scalar, std::allocator::Scalar> >&); +template std::vector::Scalar, std::allocator::Scalar> > igl::matrix_to_list >(Eigen::DenseBase > const&); #endif diff --git a/include/igl/ray_mesh_intersect.cpp b/include/igl/ray_mesh_intersect.cpp index f2b917774..f1dad5584 100644 --- a/include/igl/ray_mesh_intersect.cpp +++ b/include/igl/ray_mesh_intersect.cpp @@ -1,9 +1,9 @@ // This file is part of libigl, a simple c++ geometry processing library. -// +// // Copyright (C) 2016 Alec Jacobson -// -// 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 "ray_mesh_intersect.h" @@ -15,8 +15,8 @@ extern "C" template < typename Derivedsource, typename Deriveddir, - typename DerivedV, - typename DerivedF> + typename DerivedV, + typename DerivedF> IGL_INLINE bool igl::ray_mesh_intersect( const Eigen::MatrixBase & s, const Eigen::MatrixBase & dir, @@ -26,14 +26,14 @@ IGL_INLINE bool igl::ray_mesh_intersect( { using namespace Eigen; using namespace std; - // Should be but can't be const + // Should be but can't be const Vector3d s_d = s.template cast(); Vector3d dir_d = dir.template cast(); hits.clear(); // loop over all triangles for(int f = 0;f(); RowVector3d v1 = V.row(F(f,1)).template cast(); RowVector3d v2 = V.row(F(f,2)).template cast(); @@ -57,8 +57,8 @@ IGL_INLINE bool igl::ray_mesh_intersect( template < typename Derivedsource, typename Deriveddir, - typename DerivedV, - typename DerivedF> + typename DerivedV, + typename DerivedF> IGL_INLINE bool igl::ray_mesh_intersect( const Eigen::MatrixBase & source, const Eigen::MatrixBase & dir, @@ -81,4 +81,5 @@ IGL_INLINE bool igl::ray_mesh_intersect( #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation template bool igl::ray_mesh_intersect, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, std::vector >&); +template bool igl::ray_mesh_intersect, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::Hit&); #endif diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 31ef6058a..901d5837f 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -144,7 +144,7 @@ elseif(UNIX) # .SO file extension on Linux/Mac OS set_target_properties(pyigl PROPERTIES SUFFIX ".so") - #Enable flag if undefined symbols appear on pyigl module import to get notified about the missing symbols at link time + # Enable flag if undefined symbols appear on pyigl module import to get notified about the missing symbols at link time option(CHECK_UNDEFINED "Check for undefined symbols" OFF) # Strip unnecessary sections of the binary on Linux/Mac OS