diff --git a/include/igl/boolean/CSGTree.h b/include/igl/boolean/CSGTree.h deleted file mode 100644 index 5f1371326..000000000 --- a/include/igl/boolean/CSGTree.h +++ /dev/null @@ -1,182 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_BOOLEAN_CSG_TREE_H -#define IGL_BOOLEAN_CSG_TREE_H - -#include -#include -#include -#include -#include - -namespace igl -{ - namespace boolean - { - // Class for defining and computing a constructive solid geometry result - // out of a tree of boolean operations on "solid" triangle meshes. - // - //template - class CSGTree - { - private: - typedef CGAL::Epeck::FT ExactScalar; - typedef Eigen::Matrix MatrixX3E; - //typedef Eigen::PlainObjectBase POBF; - typedef Eigen::MatrixXi POBF; - typedef POBF::Index FIndex; - typedef Eigen::Matrix VectorJ; - // Resulting mesh - MatrixX3E m_V; - POBF m_F; - VectorJ m_J; - // Number of birth faces in A + those in B. I.e. sum of original "leaf" - // faces involved in result. - size_t m_number_of_birth_faces; - public: - CSGTree() - { - } - //typedef Eigen::MatrixXd MatrixX3E; - //typedef Eigen::MatrixXi POBF; - // http://stackoverflow.com/a/3279550/148668 - CSGTree(const CSGTree & other) - : - // copy things - m_V(other.m_V), - // This is an issue if m_F is templated - // https://forum.kde.org/viewtopic.php?f=74&t=128414 - m_F(other.m_F), - m_J(other.m_J), - m_number_of_birth_faces(other.m_number_of_birth_faces) - { - } - // copy-swap idiom - friend void swap(CSGTree& first, CSGTree& second) - { - using std::swap; - // swap things - swap(first.m_V,second.m_V); - // This is an issue if m_F is templated, similar to - // https://forum.kde.org/viewtopic.php?f=74&t=128414 - swap(first.m_F,second.m_F); - swap(first.m_J,second.m_J); - swap(first.m_number_of_birth_faces,second.m_number_of_birth_faces); - } - // Pass-by-value (aka copy) - CSGTree& operator=(CSGTree other) - { - swap(*this,other); - return *this; - } - CSGTree(CSGTree&& other): - // initialize via default constructor - CSGTree() - { - swap(*this,other); - } - // Construct and compute a boolean operation on existing CSGTree nodes. - // - // Inputs: - // A Solid result of previous CSG operation (or identity, see below) - // B Solid result of previous CSG operation (or identity, see below) - // type type of mesh boolean to compute - CSGTree( - const CSGTree & A, - const CSGTree & B, - const MeshBooleanType & type) - { - // conduct boolean operation - mesh_boolean(A.V(),A.F(),B.V(),B.F(),type,m_V,m_F,m_J); - // reindex m_J - std::for_each(m_J.data(),m_J.data()+m_J.size(), - [&](typename VectorJ::Scalar & j) - { - if(j < A.F().rows()) - { - j = A.J()(j); - }else - { - assert(j<(A.F().rows()+B.F().rows())); - j = A.number_of_birth_faces()+(B.J()(j-A.F().rows())); - } - }); - m_number_of_birth_faces = - A.number_of_birth_faces() + B.number_of_birth_faces(); - } - // Overload using string for type - CSGTree( - const CSGTree & A, - const CSGTree & B, - const std::string & s): - CSGTree(A,B,string_to_mesh_boolean_type(s)) - { - // do nothing (all done in constructor). - } - // "Leaf" node with identity operation on assumed "solid" mesh (V,F) - // - // Inputs: - // V #V by 3 list of mesh vertices (in any precision, will be - // converted to exact) - // F #F by 3 list of mesh face indices into V - template - CSGTree(const Eigen::PlainObjectBase & V, const POBF & F)//: - // Possible Eigen bug: - // https://forum.kde.org/viewtopic.php?f=74&t=128414 - //m_V(V.template cast()),m_F(F) - { - m_V = V.template cast(); - m_F = F; - // number of faces - m_number_of_birth_faces = m_F.rows(); - // identity birth index - m_J = VectorJ::LinSpaced( - m_number_of_birth_faces,0,m_number_of_birth_faces-1); - } - // Returns reference to resulting mesh vertices m_V in exact scalar - // representation - const MatrixX3E & V() const - { - return m_V; - } - // Returns mesh vertices in the desired output type, casting when - // appropriate to floating precision. - template - Eigen::PlainObjectBase cast_V() const - { - Eigen::PlainObjectBase dV; - dV.resize(m_V.rows(),m_V.cols()); - for(int i = 0;i -// -// 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_BOOLEAN_MESH_BOOLEAN_TYPE_H -#define IGL_BOOLEAN_MESH_BOOLEAN_TYPE_H -namespace igl -{ - namespace boolean - { - enum MeshBooleanType - { - MESH_BOOLEAN_TYPE_UNION = 0, - MESH_BOOLEAN_TYPE_INTERSECT = 1, - MESH_BOOLEAN_TYPE_MINUS = 2, - MESH_BOOLEAN_TYPE_XOR = 3, - MESH_BOOLEAN_TYPE_RESOLVE = 4, - NUM_MESH_BOOLEAN_TYPES = 5 - }; - } -}; - -#endif diff --git a/include/igl/boolean/from_cork_mesh.h b/include/igl/boolean/from_cork_mesh.h deleted file mode 100644 index c31f54e96..000000000 --- a/include/igl/boolean/from_cork_mesh.h +++ /dev/null @@ -1,38 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_BOOLEAN_FROM_CORK_MESH_H -#define IGL_BOOLEAN_FROM_CORK_MESH_H -#ifndef IGL_NO_CORK -#include -#include -#include -namespace igl -{ - namespace boolean - { - // Convert cork's triangle mesh representation to a (V,F) mesh. - // - // Inputs: - // mesh cork representation of mesh - // Outputs: - // V #V by 3 list of vertex positions - // F #F by 3 list of triangle indices into V - template < - typename DerivedV, - typename DerivedF> - IGL_INLINE void from_cork_mesh( - const CorkTriMesh & mesh, - Eigen::PlainObjectBase & V, - Eigen::PlainObjectBase & F); - } -} -#ifndef IGL_STATIC_LIBRARY -# include "from_cork_mesh.cpp" -#endif -#endif -#endif diff --git a/include/igl/boolean/mesh_boolean_cork.h b/include/igl/boolean/mesh_boolean_cork.h deleted file mode 100644 index 1951b9630..000000000 --- a/include/igl/boolean/mesh_boolean_cork.h +++ /dev/null @@ -1,54 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_BOOLEAN_MESH_BOOLEAN_CORK_H -#define IGL_BOOLEAN_MESH_BOOLEAN_CORK_H -#ifndef IGL_NO_CORK -#include "MeshBooleanType.h" -#include -#include -#include // for consistent uint - -namespace igl -{ - namespace boolean - { - // Compute a boolean operation on two input meshes using the cork library. - // - // Inputs: - // VA #VA by 3 list of vertex positions of first mesh - // FA #FA by 3 list of triangle indices into VA - // VB #VB by 3 list of vertex positions of second mesh - // FB #FB by 3 list of triangle indices into VB - // type of boolean operation see MeshBooleanType.h - // Outputs: - // VC #VC by 3 list of vertex positions of output mesh - // FC #FC by 3 list of triangle indices into VC - template < - typename DerivedVA, - typename DerivedFA, - typename DerivedVB, - typename DerivedFB, - typename DerivedVC, - typename DerivedFC> - IGL_INLINE void mesh_boolean_cork( - const Eigen::PlainObjectBase & VA, - const Eigen::PlainObjectBase & FA, - const Eigen::PlainObjectBase & VB, - const Eigen::PlainObjectBase & FB, - const MeshBooleanType & type, - Eigen::PlainObjectBase & VC, - Eigen::PlainObjectBase & FC); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "mesh_boolean_cork.cpp" -#endif -#endif - -#endif diff --git a/include/igl/boolean/string_to_mesh_boolean_type.h b/include/igl/boolean/string_to_mesh_boolean_type.h deleted file mode 100644 index f0fb79697..000000000 --- a/include/igl/boolean/string_to_mesh_boolean_type.h +++ /dev/null @@ -1,41 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_BOOLEAN_STRING_TO_MESH_BOOLEAN_H -#define IGL_BOOLEAN_STRING_TO_MESH_BOOLEAN_H - -#include -#include "MeshBooleanType.h" -#include - -namespace igl -{ - namespace boolean - { - // Convert string to boolean type - // - // Inputs: - // s string identifying type, one of the following: - // "union","intersect","minus","xor","resolve" - // Outputs: - // type type of boolean operation - // Returns true only on success - // - IGL_INLINE bool string_to_mesh_boolean_type( - const std::string & s, - MeshBooleanType & type); - // Returns type without error handling - IGL_INLINE MeshBooleanType string_to_mesh_boolean_type( - const std::string & s); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "string_to_mesh_boolean_type.cpp" -#endif - -#endif diff --git a/include/igl/boolean/to_cork_mesh.h b/include/igl/boolean/to_cork_mesh.h deleted file mode 100644 index 3ad479685..000000000 --- a/include/igl/boolean/to_cork_mesh.h +++ /dev/null @@ -1,38 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_BOOLEAN_TO_CORK_MESH_H -#define IGL_BOOLEAN_TO_CORK_MESH_H -#ifndef IGL_NO_CORK -#include -#include -#include -namespace igl -{ - namespace boolean - { - // Convert a (V,F) mesh to a cork's triangle mesh representation. - // - // Inputs: - // V #V by 3 list of vertex positions - // F #F by 3 list of triangle indices into V - // Outputs: - // mesh cork representation of mesh - template < - typename DerivedV, - typename DerivedF> - IGL_INLINE void to_cork_mesh( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - CorkTriMesh & mesh); - } -} -#ifndef IGL_STATIC_LIBRARY -# include "to_cork_mesh.cpp" -#endif -#endif -#endif diff --git a/include/igl/cgal/RemeshSelfIntersectionsParam.h b/include/igl/cgal/RemeshSelfIntersectionsParam.h deleted file mode 100644 index e2c1a5523..000000000 --- a/include/igl/cgal/RemeshSelfIntersectionsParam.h +++ /dev/null @@ -1,28 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_CGAL_REMESH_SELF_INTERSECTIONS_PARAM_H -#define IGL_CGAL_REMESH_SELF_INTERSECTIONS_PARAM_H - -namespace igl -{ - namespace cgal - { - // Optional Parameters - // DetectOnly Only compute IF, leave VV and FF alone - struct RemeshSelfIntersectionsParam - { - bool detect_only; - bool first_only; - RemeshSelfIntersectionsParam():detect_only(false),first_only(false){}; - RemeshSelfIntersectionsParam(bool _detect_only, bool _first_only): - detect_only(_detect_only),first_only(_first_only){}; - }; - } -} - -#endif diff --git a/include/igl/cgal/assign_scalar.h b/include/igl/cgal/assign_scalar.h deleted file mode 100644 index 8f95eb1c5..000000000 --- a/include/igl/cgal/assign_scalar.h +++ /dev/null @@ -1,34 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_CGAL_ASSIGN_SCALAR_H -#define IGL_CGAL_ASSIGN_SCALAR_H -#include "../igl_inline.h" -#include "CGAL_includes.hpp" -namespace igl -{ - namespace cgal - { - // Inputs: - // cgal cgal scalar - // Outputs: - // d output scalar - IGL_INLINE void assign_scalar( - const typename CGAL::Epeck::FT & cgal, - CGAL::Epeck::FT & d); - IGL_INLINE void assign_scalar( - const typename CGAL::Epeck::FT & cgal, - double & d); - IGL_INLINE void assign_scalar( - const double & c, - double & d); - } -} -#ifndef IGL_STATIC_LIBRARY -# include "assign_scalar.cpp" -#endif -#endif diff --git a/include/igl/cgal/closest_facet.h b/include/igl/cgal/closest_facet.h deleted file mode 100644 index 9a1e005a2..000000000 --- a/include/igl/cgal/closest_facet.h +++ /dev/null @@ -1,63 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 Qingnan Zhou -// -// 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 CLOSEST_FACET_H -#define CLOSEST_FACET_H - -#include "../igl_inline.h" -#include - -namespace igl { - namespace cgal { - - // Determine the closest facet for each of the input points. - // - // Inputs: - // V #V by 3 array of vertices. - // F #F by 3 array of faces. - // I #I list of triangle indices to consider. - // P #P by 3 array of query points. - // - // Outputs: - // R #P list of closest facet indices. - // S #P list of bools indicating on which side of the closest facet - // each query point lies. - template< - typename DerivedV, - typename DerivedF, - typename DerivedI, - typename DerivedP, - typename DerivedR, - typename DerivedS > - IGL_INLINE void closest_facet( - const Eigen::PlainObjectBase& V, - const Eigen::PlainObjectBase& F, - const Eigen::PlainObjectBase& I, - const Eigen::PlainObjectBase& P, - Eigen::PlainObjectBase& R, - Eigen::PlainObjectBase& S); - - template< - typename DerivedV, - typename DerivedF, - typename DerivedP, - typename DerivedR, - typename DerivedS > - IGL_INLINE void closest_facet( - const Eigen::PlainObjectBase& V, - const Eigen::PlainObjectBase& F, - const Eigen::PlainObjectBase& P, - Eigen::PlainObjectBase& R, - Eigen::PlainObjectBase& S); - } -} - -#ifndef IGL_STATIC_LIBRARY -#include "closest_facet.cpp" -#endif -#endif diff --git a/include/igl/cgal/complex_to_mesh.h b/include/igl/cgal/complex_to_mesh.h deleted file mode 100644 index e1ba3995f..000000000 --- a/include/igl/cgal/complex_to_mesh.h +++ /dev/null @@ -1,44 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2014 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_CGAL_COMPLEX_TO_MESH_H -#define IGL_CGAL_COMPLEX_TO_MESH_H -#include "../igl_inline.h" - -#include -#include - -namespace igl -{ - namespace cgal - { - // Templates: - // Tr CGAL triangulation type, e.g. - // CGAL::Surface_mesh_default_triangulation_3 - // Inputs - // c2t3 2-complex (surface) living in a 3d triangulation (e.g. result of - // CGAL::make_surface_mesh) - // Outputs: - // V #V by 3 list of vertex positions - // F #F by 3 list of triangle indices - // Returns true iff conversion was successful, failure can ok if CGAL code - // can't figure out ordering. - // - template - IGL_INLINE bool complex_to_mesh( - const CGAL::Complex_2_in_triangulation_3 & c2t3, - Eigen::PlainObjectBase & V, - Eigen::PlainObjectBase & F); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "complex_to_mesh.cpp" -#endif - -#endif - diff --git a/include/igl/cgal/intersect_other.cpp b/include/igl/cgal/intersect_other.cpp deleted file mode 100644 index 9abce2a5f..000000000 --- a/include/igl/cgal/intersect_other.cpp +++ /dev/null @@ -1,270 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2014 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#include "intersect_other.h" -#include "CGAL_includes.hpp" -#include "mesh_to_cgal_triangle_list.h" -#include "remesh_intersections.h" - -#ifndef IGL_FIRST_HIT_EXCEPTION -#define IGL_FIRST_HIT_EXCEPTION 10 -#endif - -// Un-exposed helper functions -namespace igl -{ - namespace cgal - { - template - static IGL_INLINE void push_result( - const Eigen::PlainObjectBase & F, - const int f, - const CGAL::Object & result, - std::map< - typename DerivedF::Index, - std::pair > > & offending, - std::map< - std::pair, - std::vector > & edge2faces) - { - typedef typename DerivedF::Index Index; - typedef std::pair EMK; - if(offending.count(f) == 0) - { - // first time marking, initialize with new id and empty list - Index id = offending.size(); - offending[f] = {id,{}}; - for(Index e = 0; e<3;e++) - { - // append face to edge's list - Index i = F(f,(e+1)%3) < F(f,(e+2)%3) ? F(f,(e+1)%3) : F(f,(e+2)%3); - Index j = F(f,(e+1)%3) < F(f,(e+2)%3) ? F(f,(e+2)%3) : F(f,(e+1)%3); - edge2faces[EMK(i,j)].push_back(f); - } - } - offending[f].second.push_back(result); - } - template < - typename Kernel, - typename DerivedVA, - typename DerivedFA, - typename DerivedVB, - typename DerivedFB, - typename DerivedIF, - typename DerivedVVA, - typename DerivedFFA, - typename DerivedJA, - typename DerivedIMA, - typename DerivedVVB, - typename DerivedFFB, - typename DerivedJB, - typename DerivedIMB> - static IGL_INLINE bool intersect_other_helper( - const Eigen::PlainObjectBase & VA, - const Eigen::PlainObjectBase & FA, - const Eigen::PlainObjectBase & VB, - const Eigen::PlainObjectBase & FB, - const RemeshSelfIntersectionsParam & params, - Eigen::PlainObjectBase & IF, - Eigen::PlainObjectBase & VVA, - Eigen::PlainObjectBase & FFA, - Eigen::PlainObjectBase & JA, - Eigen::PlainObjectBase & IMA, - Eigen::PlainObjectBase & VVB, - Eigen::PlainObjectBase & FFB, - Eigen::PlainObjectBase & JB, - Eigen::PlainObjectBase & IMB) - { - - using namespace std; - using namespace Eigen; - - typedef typename DerivedFA::Index Index; - // 3D Primitives - typedef CGAL::Point_3 Point_3; - typedef CGAL::Segment_3 Segment_3; - typedef CGAL::Triangle_3 Triangle_3; - typedef CGAL::Plane_3 Plane_3; - typedef CGAL::Tetrahedron_3 Tetrahedron_3; - // 2D Primitives - typedef CGAL::Point_2 Point_2; - typedef CGAL::Segment_2 Segment_2; - typedef CGAL::Triangle_2 Triangle_2; - // 2D Constrained Delaunay Triangulation types - typedef CGAL::Triangulation_vertex_base_2 TVB_2; - typedef CGAL::Constrained_triangulation_face_base_2 CTAB_2; - typedef CGAL::Triangulation_data_structure_2 TDS_2; - typedef CGAL::Exact_intersections_tag Itag; - typedef CGAL::Constrained_Delaunay_triangulation_2 - CDT_2; - typedef CGAL::Constrained_triangulation_plus_2 CDT_plus_2; - // Axis-align boxes for all-pairs self-intersection detection - typedef std::vector Triangles; - typedef typename Triangles::iterator TrianglesIterator; - typedef typename Triangles::const_iterator TrianglesConstIterator; - typedef - CGAL::Box_intersection_d::Box_with_handle_d - Box; - typedef - std::map > > - OffendingMap; - typedef std::map,std::vector > EdgeMap; - typedef std::pair EMK; - - Triangles TA,TB; - // Compute and process self intersections - mesh_to_cgal_triangle_list(VA,FA,TA); - mesh_to_cgal_triangle_list(VB,FB,TB); - // http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Box_intersection_d/Chapter_main.html#Section_63.5 - // Create the corresponding vector of bounding boxes - std::vector A_boxes,B_boxes; - const auto box_up = [](Triangles & T, std::vector & boxes) - { - boxes.reserve(T.size()); - for ( - TrianglesIterator tit = T.begin(); - tit != T.end(); - ++tit) - { - boxes.push_back(Box(tit->bbox(), tit)); - } - }; - box_up(TA,A_boxes); - box_up(TB,B_boxes); - OffendingMap offendingA,offendingB; - EdgeMap edge2facesA,edge2facesB; - - std::list lIF; - const auto cb = [&](const Box &a, const Box &b) - { - using namespace std; - // index in F and T - int fa = a.handle()-TA.begin(); - int fb = b.handle()-TB.begin(); - const Triangle_3 & A = *a.handle(); - const Triangle_3 & B = *b.handle(); - if(CGAL::do_intersect(A,B)) - { - // There was an intersection - lIF.push_back(fa); - lIF.push_back(fb); - if(params.first_only) - { - throw IGL_FIRST_HIT_EXCEPTION; - } - if(!params.detect_only) - { - CGAL::Object result = CGAL::intersection(A,B); - - push_result(FA,fa,result,offendingA,edge2facesA); - push_result(FB,fb,result,offendingB,edge2facesB); - } - } - }; - try{ - CGAL::box_intersection_d( - A_boxes.begin(), A_boxes.end(), - B_boxes.begin(), B_boxes.end(), - cb); - }catch(int e) - { - // Rethrow if not FIRST_HIT_EXCEPTION - if(e != IGL_FIRST_HIT_EXCEPTION) - { - throw e; - } - // Otherwise just fall through - } - - // Convert lIF to Eigen matrix - assert(lIF.size()%2 == 0); - IF.resize(lIF.size()/2,2); - { - int i=0; - for( - list::const_iterator ifit = lIF.begin(); - ifit!=lIF.end(); - ) - { - IF(i,0) = (*ifit); - ifit++; - IF(i,1) = (*ifit); - ifit++; - i++; - } - } - if(!params.detect_only) - { - remesh_intersections(VA,FA,TA,offendingA,edge2facesA,VVA,FFA,JA,IMA); - remesh_intersections(VB,FB,TB,offendingB,edge2facesB,VVB,FFB,JB,IMB); - } - - return IF.rows() > 0; - } - } -} - -template < - typename DerivedVA, - typename DerivedFA, - typename DerivedVB, - typename DerivedFB, - typename DerivedIF, - typename DerivedVVA, - typename DerivedFFA, - typename DerivedJA, - typename DerivedIMA, - typename DerivedVVB, - typename DerivedFFB, - typename DerivedJB, - typename DerivedIMB> -IGL_INLINE bool igl::cgal::intersect_other( - const Eigen::PlainObjectBase & VA, - const Eigen::PlainObjectBase & FA, - const Eigen::PlainObjectBase & VB, - const Eigen::PlainObjectBase & FB, - const RemeshSelfIntersectionsParam & params, - Eigen::PlainObjectBase & IF, - Eigen::PlainObjectBase & VVA, - Eigen::PlainObjectBase & FFA, - Eigen::PlainObjectBase & JA, - Eigen::PlainObjectBase & IMA, - Eigen::PlainObjectBase & VVB, - Eigen::PlainObjectBase & FFB, - Eigen::PlainObjectBase & JB, - Eigen::PlainObjectBase & IMB) -{ - if(params.detect_only) - { - return intersect_other_helper - (VA,FA,VB,FB,params,IF,VVA,FFA,JA,IMA,VVB,FFB,JB,IMB); - }else - { - return intersect_other_helper - (VA,FA,VB,FB,params,IF,VVA,FFA,JA,IMA,VVB,FFB,JB,IMB); - } -} - -IGL_INLINE bool igl::cgal::intersect_other( - const Eigen::MatrixXd & VA, - const Eigen::MatrixXi & FA, - const Eigen::MatrixXd & VB, - const Eigen::MatrixXi & FB, - const bool first_only, - Eigen::MatrixXi & IF) -{ - Eigen::MatrixXd VVA,VVB; - Eigen::MatrixXi FFA,FFB; - Eigen::VectorXi JA,JB,IMA,IMB; - return intersect_other( - VA,FA,VB,FB,{true,first_only},IF,VVA,FFA,JA,IMA,VVB,FFB,JB,IMB); -} - -#ifdef IGL_STATIC_LIBRARY -// Explicit template specialization -#endif diff --git a/include/igl/cgal/intersect_other.h b/include/igl/cgal/intersect_other.h deleted file mode 100644 index c4935587c..000000000 --- a/include/igl/cgal/intersect_other.h +++ /dev/null @@ -1,106 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_CGAL_INTERSECT_OTHER_H -#define IGL_CGAL_INTERSECT_OTHER_H -#include "../igl_inline.h" -#include "RemeshSelfIntersectionsParam.h" - -#include - -#ifdef MEX -# include -# include -# undef assert -# define assert( isOK ) ( (isOK) ? (void)0 : (void) mexErrMsgTxt(C_STR(__FILE__<<":"<<__LINE__<<": failed assertion `"<<#isOK<<"'"< - IGL_INLINE bool intersect_other( - const Eigen::PlainObjectBase & VA, - const Eigen::PlainObjectBase & FA, - const Eigen::PlainObjectBase & VB, - const Eigen::PlainObjectBase & FB, - const RemeshSelfIntersectionsParam & params, - Eigen::PlainObjectBase & IF, - Eigen::PlainObjectBase & VVA, - Eigen::PlainObjectBase & FFA, - Eigen::PlainObjectBase & JA, - Eigen::PlainObjectBase & IMA, - Eigen::PlainObjectBase & VVB, - Eigen::PlainObjectBase & FFB, - Eigen::PlainObjectBase & JB, - Eigen::PlainObjectBase & IMB); - // Legacy wrapper for detect only using common types. - // - // Inputs: - // VA #V by 3 list of vertex positions - // FA #F by 3 list of triangle indices into VA - // VB #V by 3 list of vertex positions - // FB #F by 3 list of triangle indices into VB - // first_only whether to only detect the first intersection. - // Outputs: - // IF #intersecting face pairs by 2 list of intersecting face pairs, - // indexing FA and FB - // Returns true if any intersections were found - // - // See also: remesh_self_intersections - IGL_INLINE bool intersect_other( - const Eigen::MatrixXd & VA, - const Eigen::MatrixXi & FA, - const Eigen::MatrixXd & VB, - const Eigen::MatrixXi & FB, - const bool first_only, - Eigen::MatrixXi & IF); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "intersect_other.cpp" -#endif - -#endif - diff --git a/include/igl/cgal/mesh_to_cgal_triangle_list.cpp b/include/igl/cgal/mesh_to_cgal_triangle_list.cpp deleted file mode 100644 index 886ca3285..000000000 --- a/include/igl/cgal/mesh_to_cgal_triangle_list.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2014 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#include "mesh_to_cgal_triangle_list.h" -#include "assign_scalar.h" - -#include - -template < - typename DerivedV, - typename DerivedF, - typename Kernel> -IGL_INLINE void igl::cgal::mesh_to_cgal_triangle_list( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - std::vector > & T) -{ - typedef CGAL::Point_3 Point_3; - typedef CGAL::Triangle_3 Triangle_3; - // Must be 3D - assert(V.cols() == 3); - // **Copy** to convert to output type (this is especially/only needed if the - // input type DerivedV::Scalar is CGAL::Epeck - Eigen::Matrix< - typename Kernel::FT, - DerivedV::RowsAtCompileTime, - DerivedV::ColsAtCompileTime> - KV(V.rows(),V.cols()); - // Just use f'ing for loops. What if V and KV don't use same ordering? - for(int i = 0;i, Eigen::Matrix, CGAL::Epeck>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector, std::allocator > >&); -template void igl::cgal::mesh_to_cgal_triangle_list, Eigen::Matrix, CGAL::Epick>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector, std::allocator > >&); -template void igl::cgal::mesh_to_cgal_triangle_list, Eigen::Matrix, CGAL::Epeck>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector, std::allocator > >&); -template void igl::cgal::mesh_to_cgal_triangle_list, Eigen::Matrix, CGAL::Epick>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector, std::allocator > >&); -template void igl::cgal::mesh_to_cgal_triangle_list, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epeck>(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::vector, std::allocator > >&); -template void igl::cgal::mesh_to_cgal_triangle_list, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epick>(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::vector, std::allocator > >&); -template void igl::cgal::mesh_to_cgal_triangle_list, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epick>(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > >&); -template void igl::cgal::mesh_to_cgal_triangle_list, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epeck>(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > >&); -#endif diff --git a/include/igl/cgal/mesh_to_cgal_triangle_list.h b/include/igl/cgal/mesh_to_cgal_triangle_list.h deleted file mode 100644 index b66dc46e3..000000000 --- a/include/igl/cgal/mesh_to_cgal_triangle_list.h +++ /dev/null @@ -1,41 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2014 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_CGAL_MESH_TO_CGAL_TRIANGLE_LIST_H -#define IGL_CGAL_MESH_TO_CGAL_TRIANGLE_LIST_H -#include -#include -#include "CGAL_includes.hpp" -namespace igl -{ - namespace cgal - { - // Convert a mesh (V,F) to a list of CGAL triangles - // - // Templates: - // Kernal CGAL computation and construction kernel (e.g. - // CGAL::Exact_predicates_exact_constructions_kernel) - // Inputs: - // V #V by 3 list of vertex positions - // F #F by 3 list of triangle indices - // Outputs: - // T #F list of CGAL triangles - template < - typename DerivedV, - typename DerivedF, - typename Kernel> - IGL_INLINE void mesh_to_cgal_triangle_list( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - std::vector > & T); - } -} -#ifndef IGL_STATIC_LIBRARY -# include "mesh_to_cgal_triangle_list.cpp" -#endif - -#endif diff --git a/include/igl/cgal/mesh_to_polyhedron.h b/include/igl/cgal/mesh_to_polyhedron.h deleted file mode 100644 index 806cd5c6c..000000000 --- a/include/igl/cgal/mesh_to_polyhedron.h +++ /dev/null @@ -1,39 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_CGAL_MESH_TO_POLYHEDRON_H -#define IGL_CGAL_MESH_TO_POLYHEDRON_H -#include -#include - -namespace igl -{ - namespace cgal - { - // Convert a mesh (V,F) to a CGAL Polyhedron - // - // Templates: - // Polyhedron CGAL Polyhedron type (e.g. Polyhedron_3) - // Inputs: - // V #V by 3 list of vertex positions - // F #F by 3 list of triangle indices - // Outputs: - // poly cgal polyhedron - // Returns true only if (V,F) can be converted to a valid polyhedron (i.e. if - // (V,F) is vertex and edge manifold). - template - IGL_INLINE bool mesh_to_polyhedron( - const Eigen::MatrixXd & V, - const Eigen::MatrixXi & F, - Polyhedron & poly); - } -} -#ifndef IGL_STATIC_LIBRARY -# include "mesh_to_polyhedron.cpp" -#endif - -#endif diff --git a/include/igl/cgal/order_facets_around_edges.h b/include/igl/cgal/order_facets_around_edges.h deleted file mode 100644 index e44d9aa30..000000000 --- a/include/igl/cgal/order_facets_around_edges.h +++ /dev/null @@ -1,104 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_CGAL_ORDER_FACETS_AROUND_EDGES_H -#define IGL_CGAL_ORDER_FACETS_AROUND_EDGES_H -#include "../igl_inline.h" -#include -#include -#include - -namespace igl -{ - namespace cgal - { - // For each undirected edge, sort its adjacent faces. Assuming the - // undirected edge is (s, d). Sort the adjacent faces clockwise around the - // axis (d - s), i.e. left-hand rule. An adjacent face is consistently - // oriented if it contains (d, s) as a directed edge. - // - // For overlapping faces, break the tie using signed face index, smaller - // signed index comes before the larger signed index. Signed index is - // computed as (consistent? 1:-1) * index. - // - // Inputs: - // V #V by 3 list of vertices. - // F #F by 3 list of faces - // N #F by 3 list of face normals. - // uE #uE by 2 list of vertex_indices, represents undirected edges. - // uE2E #uE list of lists that maps uE to E. (a one-to-many map) - // - // Outputs: - // uE2oE #uE list of lists that maps uE to an ordered list of E. (a - // one-to-many map) - // uE2C #uE list of lists of bools indicates whether each face in - // uE2oE[i] is consistently orientated as the ordering. - // - template< - typename DerivedV, - typename DerivedF, - typename DerivedN, - typename DeriveduE, - typename uE2EType, - typename uE2oEType, - typename uE2CType > - IGL_INLINE - typename std::enable_if::value, void>::type - order_facets_around_edges( - const Eigen::PlainObjectBase& V, - const Eigen::PlainObjectBase& F, - const Eigen::PlainObjectBase& N, - const Eigen::PlainObjectBase& uE, - const std::vector >& uE2E, - std::vector >& uE2oE, - std::vector >& uE2C ); - - template< - typename DerivedV, - typename DerivedF, - typename DerivedN, - typename DeriveduE, - typename uE2EType, - typename uE2oEType, - typename uE2CType > - IGL_INLINE - typename std::enable_if::value, void>::type - order_facets_around_edges( - const Eigen::PlainObjectBase& V, - const Eigen::PlainObjectBase& F, - const Eigen::PlainObjectBase& N, - const Eigen::PlainObjectBase& uE, - const std::vector >& uE2E, - std::vector >& uE2oE, - std::vector >& uE2C ); - - // Order faces around each edge. Only exact predicate is used in the algorithm. - // Normal is not needed. - template< - typename DerivedV, - typename DerivedF, - typename DeriveduE, - typename uE2EType, - typename uE2oEType, - typename uE2CType > - IGL_INLINE void order_facets_around_edges( - const Eigen::PlainObjectBase& V, - const Eigen::PlainObjectBase& F, - const Eigen::PlainObjectBase& uE, - const std::vector >& uE2E, - std::vector >& uE2oE, - std::vector >& uE2C ); - } -} - -#ifndef IGL_STATIC_LIBRARY -#include "order_facets_around_edges.cpp" -#endif - -#endif diff --git a/include/igl/cgal/outer_element.h b/include/igl/cgal/outer_element.h deleted file mode 100644 index 6107cf482..000000000 --- a/include/igl/cgal/outer_element.h +++ /dev/null @@ -1,112 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 Qingan Zhou -// -// 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_CGAL_OUTER_ELEMENT_H -#define IGL_CGAL_OUTER_ELEMENT_H -#include "../igl_inline.h" -#include -namespace igl -{ - namespace cgal - { - // Find a vertex that is reachable from infinite without crossing any faces. - // Such vertex is called "outer vertex." - // - // Precondition: The input mesh must have all self-intersection resolved and - // no duplicated vertices. See cgal::remesh_self_intersections.h for how to - // obtain such input. - // - // Inputs: - // V #V by 3 list of vertex positions - // F #F by 3 list of triangle indices into V - // I #I list of facets to consider - // Outputs: - // v_index index of outer vertex - // A #A list of facets incident to the outer vertex - template < - typename DerivedV, - typename DerivedF, - typename DerivedI, - typename IndexType, - typename DerivedA - > - IGL_INLINE void outer_vertex( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - const Eigen::PlainObjectBase & I, - IndexType & v_index, - Eigen::PlainObjectBase & A); - // Find an edge that is reachable from infinity without crossing any faces. - // Such edge is called "outer edge." - // - // Precondition: The input mesh must have all self-intersection resolved - // and no duplicated vertices. The correctness of the output depends on - // the fact that there is no edge overlap. See - // cgal::remesh_self_intersections.h for how to obtain such input. - // - // Inputs: - // V #V by 3 list of vertex positions - // F #F by 3 list of triangle indices into V - // I #I list of facets to consider - // Outputs: - // v1 index of the first end point of outer edge - // v2 index of the second end point of outer edge - // A #A list of facets incident to the outer edge - template< - typename DerivedV, - typename DerivedF, - typename DerivedI, - typename IndexType, - typename DerivedA - > - IGL_INLINE void outer_edge( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - const Eigen::PlainObjectBase & I, - IndexType & v1, - IndexType & v2, - Eigen::PlainObjectBase & A); - - - // Find a facet that is reachable from infinity without crossing any faces. - // Such facet is called "outer facet." - // - // Precondition: The input mesh must have all self-intersection resolved. - // I.e there is no duplicated vertices, no overlapping edge and no - // intersecting faces (the only exception is there could be topologically - // duplicated faces). See cgal::remesh_self_intersections.h for how to - // obtain such input. - // - // Inputs: - // V #V by 3 list of vertex positions - // F #F by 3 list of triangle indices into V - // N #N by 3 list of face normals - // I #I list of facets to consider - // Outputs: - // f Index of the outer facet. - // flipped true iff the normal of f points inwards. - template< - typename DerivedV, - typename DerivedF, - typename DerivedN, - typename DerivedI, - typename IndexType - > - IGL_INLINE void outer_facet( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - const Eigen::PlainObjectBase & N, - const Eigen::PlainObjectBase & I, - IndexType & f, - bool & flipped); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "outer_element.cpp" -#endif -#endif diff --git a/include/igl/cgal/outer_hull.h b/include/igl/cgal/outer_hull.h deleted file mode 100644 index c6b1edd6d..000000000 --- a/include/igl/cgal/outer_hull.h +++ /dev/null @@ -1,51 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_CGAL_OUTER_HULL_H -#define IGL_CGAL_OUTER_HULL_H -#include "../igl_inline.h" -#include -namespace igl -{ - namespace cgal - { - // Compute the "outer hull" of a potentially non-manifold mesh (V,F) whose - // intersections have been "resolved" (e.g. using `cork` or - // `igl::cgal::selfintersect`). The outer hull is defined to be all facets - // (regardless of orientation) for which there exists some path from infinity - // to the face without intersecting any other facets. For solids, this is the - // surface of the solid. In general this includes any thin "wings" or - // "flaps". This implementation largely follows Section 3.6 of "Direct - // repair of self-intersecting meshes" [Attene 2014]. - // - // Inputs: - // V #V by 3 list of vertex positions - // F #F by 3 list of triangle indices into V - // Outputs: - // G #G by 3 list of output triangle indices into V - // J #G list of indices into F - // flip #F list of whether facet was added to G **and** flipped orientation - // (false for faces not added to G) - template < - typename DerivedV, - typename DerivedF, - typename DerivedG, - typename DerivedJ, - typename Derivedflip> - IGL_INLINE void outer_hull( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - Eigen::PlainObjectBase & G, - Eigen::PlainObjectBase & J, - Eigen::PlainObjectBase & flip); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "outer_hull.cpp" -#endif -#endif diff --git a/include/igl/cgal/peel_outer_hull_layers.h b/include/igl/cgal/peel_outer_hull_layers.h deleted file mode 100644 index 246989d7f..000000000 --- a/include/igl/cgal/peel_outer_hull_layers.h +++ /dev/null @@ -1,44 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_CGAL_PEEL_OUTER_HULL_LAYERS_H -#define IGL_CGAL_PEEL_OUTER_HULL_LAYERS_H -#include "../igl_inline.h" -#include -namespace igl -{ - namespace cgal - { - // Computes necessary generic information for boolean operations by - // successively "peeling" off the "outer hull" of a mesh (V,F) resulting from - // "resolving" all (self-)intersections. - // - // Inputs: - // V #V by 3 list of vertex positions - // F #F by 3 list of triangle indices into V - // Outputs: - // I #F list of which peel Iation a facet belongs - // flip #F list of whether a facet's orientation was flipped when facet - // "peeled" into its associated outer hull layer. - // Returns number of peels - template < - typename DerivedV, - typename DerivedF, - typename DerivedI, - typename Derivedflip> - IGL_INLINE size_t peel_outer_hull_layers( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - Eigen::PlainObjectBase & I, - Eigen::PlainObjectBase & flip); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "peel_outer_hull_layers.cpp" -#endif -#endif diff --git a/include/igl/cgal/point_mesh_squared_distance.h b/include/igl/cgal/point_mesh_squared_distance.h deleted file mode 100644 index ef646d1eb..000000000 --- a/include/igl/cgal/point_mesh_squared_distance.h +++ /dev/null @@ -1,85 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2014 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_CGAL_POINT_MESH_SQUARED_DISTANCE_H -#define IGL_CGAL_POINT_MESH_SQUARED_DISTANCE_H -#include -#include -#include -#include "CGAL_includes.hpp" -namespace igl -{ - namespace cgal - { - // Compute distances from a set of points P to a triangle mesh (V,F) - // - // Templates: - // Kernal CGAL computation and construction kernel (e.g. - // CGAL::Simple_cartesian) - // Inputs: - // P #P by 3 list of query point positions - // V #V by 3 list of vertex positions - // F #F by 3 list of triangle indices - // Outputs: - // sqrD #P list of smallest squared distances - // I #P list of facet indices corresponding to smallest distances - // C #P by 3 list of closest points - // - // Known bugs: This only computes distances to triangles. So unreferenced - // vertices and degenerate triangles (segments) are ignored. - template - IGL_INLINE void point_mesh_squared_distance( - const Eigen::MatrixXd & P, - const Eigen::MatrixXd & V, - const Eigen::MatrixXi & F, - Eigen::VectorXd & sqrD, - Eigen::VectorXi & I, - Eigen::MatrixXd & C); - // Probably can do this in a way that we don't pass around `tree` and `T` - // - // Outputs: - // tree CGAL's AABB tree - // T list of CGAL triangles in order of F (for determining which was found - // in computation) - template - IGL_INLINE void point_mesh_squared_distance_precompute( - const Eigen::MatrixXd & V, - const Eigen::MatrixXi & F, - CGAL::AABB_tree< - CGAL::AABB_traits >::iterator - > - > - > & tree, - std::vector > & T); - // Inputs: - // see above - // Outputs: - // see above - template - IGL_INLINE void point_mesh_squared_distance( - const Eigen::MatrixXd & P, - const CGAL::AABB_tree< - CGAL::AABB_traits >::iterator - > - > - > & tree, - const std::vector > & T, - Eigen::VectorXd & sqrD, - Eigen::VectorXi & I, - Eigen::MatrixXd & C); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "point_mesh_squared_distance.cpp" -#endif - -#endif diff --git a/include/igl/cgal/polyhedron_to_mesh.h b/include/igl/cgal/polyhedron_to_mesh.h deleted file mode 100644 index 605906bc2..000000000 --- a/include/igl/cgal/polyhedron_to_mesh.h +++ /dev/null @@ -1,37 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_CGAL_POLYHEDRON_TO_MESH_H -#define IGL_CGAL_POLYHEDRON_TO_MESH_H -#include -#include - -namespace igl -{ - namespace cgal - { - // Convert a CGAL Polyhedron to a mesh (V,F) - // - // Templates: - // Polyhedron CGAL Polyhedron type (e.g. Polyhedron_3) - // Inputs: - // poly cgal polyhedron - // Outputs: - // V #V by 3 list of vertex positions - // F #F by 3 list of triangle indices - template - IGL_INLINE void polyhedron_to_mesh( - const Polyhedron & poly, - Eigen::MatrixXd & V, - Eigen::MatrixXi & F); - } -} -#ifndef IGL_STATIC_LIBRARY -# include "polyhedron_to_mesh.cpp" -#endif - -#endif diff --git a/include/igl/cgal/projected_delaunay.h b/include/igl/cgal/projected_delaunay.h deleted file mode 100644 index d48a3510d..000000000 --- a/include/igl/cgal/projected_delaunay.h +++ /dev/null @@ -1,43 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_CGAL_PROJECTED_DELAUNAY_H -#define IGL_CGAL_PROJECTED_DELAUNAY_H -#include "../igl_inline.h" -#include "CGAL_includes.hpp" -namespace igl -{ - namespace cgal - { - // Compute 2D delaunay triangulation of a given 3d triangle and a list of - // intersection objects (points,segments,triangles). CGAL uses an affine - // projection rather than an isometric projection, so we're not guaranteed - // that the 2D delaunay triangulation here will be a delaunay triangulation - // in 3D. - // - // Inputs: - // A triangle in 3D - // A_objects_3 updated list of intersection objects for A - // Outputs: - // cdt Contrained delaunay triangulation in projected 2D plane - template - IGL_INLINE void projected_delaunay( - const CGAL::Triangle_3 & A, - const std::vector & A_objects_3, - CGAL::Constrained_triangulation_plus_2< - CGAL::Constrained_Delaunay_triangulation_2< - Kernel, - CGAL::Triangulation_data_structure_2< - CGAL::Triangulation_vertex_base_2, - CGAL::Constrained_triangulation_face_base_2 >, - CGAL::Exact_intersections_tag> > & cdt); - } -} -#ifndef IGL_STATIC_LIBRARY -# include "projected_delaunay.cpp" -#endif -#endif diff --git a/include/igl/cgal/remesh_intersections.cpp b/include/igl/cgal/remesh_intersections.cpp deleted file mode 100644 index 5aa223336..000000000 --- a/include/igl/cgal/remesh_intersections.cpp +++ /dev/null @@ -1,362 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 Qingnan Zhou -// -// 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 "remesh_intersections.h" -#include "assign_scalar.h" - -#include -#include -#include -#include - -template < -typename DerivedV, -typename DerivedF, -typename Kernel, -typename DerivedVV, -typename DerivedFF, -typename DerivedJ, -typename DerivedIM> -IGL_INLINE void igl::cgal::remesh_intersections( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - const std::vector > & T, - const std::map< - typename DerivedF::Index, - std::pair > > & offending, - const std::map< - std::pair, - std::vector > & edge2faces, - Eigen::PlainObjectBase & VV, - Eigen::PlainObjectBase & FF, - Eigen::PlainObjectBase & J, - Eigen::PlainObjectBase & IM) { - - typedef CGAL::Point_3 Point_3; - typedef CGAL::Segment_3 Segment_3; - typedef CGAL::Triangle_3 Triangle_3; - typedef CGAL::Plane_3 Plane_3; - typedef CGAL::Point_2 Point_2; - typedef CGAL::Segment_2 Segment_2; - typedef CGAL::Triangle_2 Triangle_2; - typedef CGAL::Triangulation_vertex_base_2 TVB_2; - typedef CGAL::Constrained_triangulation_face_base_2 CTFB_2; - typedef CGAL::Triangulation_data_structure_2 TDS_2; - typedef CGAL::Exact_intersections_tag Itag; - typedef CGAL::Constrained_Delaunay_triangulation_2 - CDT_2; - typedef CGAL::Constrained_triangulation_plus_2 CDT_plus_2; - - typedef typename DerivedF::Index Index; - typedef std::pair Edge; - struct EdgeHash { - size_t operator()(const Edge& e) const { - return (e.first * 805306457) ^ (e.second * 201326611); - } - }; - typedef std::unordered_map, EdgeHash > EdgeMap; - - auto normalize_plane_coeff = [](const Plane_3& P) { - std::vector coeffs = { - P.a(), P.b(), P.c(), P.d() - }; - const auto max_itr = std::max_element(coeffs.begin(), coeffs.end()); - const auto min_itr = std::min_element(coeffs.begin(), coeffs.end()); - typename Kernel::FT max_coeff; - if (*max_itr < -1 * *min_itr) { - max_coeff = *min_itr; - } else { - max_coeff = *max_itr; - } - std::transform(coeffs.begin(), coeffs.end(), coeffs.begin(), - [&](const typename Kernel::FT& val) - {return val / max_coeff; } ); - return coeffs; - }; - - auto plane_comp = [&](const Plane_3& p1, const Plane_3& p2) { - const auto p1_coeffs = normalize_plane_coeff(p1); - const auto p2_coeffs = normalize_plane_coeff(p2); - if (p1_coeffs[0] != p2_coeffs[0]) - return p1_coeffs[0] < p2_coeffs[0]; - if (p1_coeffs[1] != p2_coeffs[1]) - return p1_coeffs[1] < p2_coeffs[1]; - if (p1_coeffs[2] != p2_coeffs[2]) - return p1_coeffs[2] < p2_coeffs[2]; - if (p1_coeffs[3] != p2_coeffs[3]) - return p1_coeffs[3] < p2_coeffs[3]; - return false; - }; - std::map, decltype(plane_comp)> - unique_planes(plane_comp); - - const size_t num_faces = F.rows(); - const size_t num_base_vertices = V.rows(); - assert(num_faces == T.size()); - std::vector is_offending(num_faces, false); - for (const auto itr : offending) { - const auto& fid = itr.first; - is_offending[fid] = true; - - Plane_3 key = T[fid].supporting_plane(); - assert(!key.is_degenerate()); - const auto jtr = unique_planes.find(key); - if (jtr == unique_planes.end()) { - unique_planes.insert({key, {fid}}); - } else { - jtr->second.push_back(fid); - } - } - - const size_t INVALID = std::numeric_limits::max(); - std::vector > resolved_faces; - std::vector source_faces; - std::vector new_vertices; - EdgeMap edge_vertices; - - /** - * Run constraint Delaunay triangulation on the plane. - */ - auto run_delaunay_triangulation = [&](const Plane_3& P, - const std::vector& involved_faces, - std::vector& vertices, - std::vector >& faces) { - CDT_plus_2 cdt; - for (const auto& fid : involved_faces) { - const auto itr = offending.find(fid); - const auto& triangle = T[fid]; - cdt.insert_constraint(P.to_2d(triangle[0]), P.to_2d(triangle[1])); - cdt.insert_constraint(P.to_2d(triangle[1]), P.to_2d(triangle[2])); - cdt.insert_constraint(P.to_2d(triangle[2]), P.to_2d(triangle[0])); - - if (itr == offending.end()) continue; - for (const auto& obj : itr->second.second) { - if(const Segment_3 *iseg = CGAL::object_cast(&obj)) { - // Add segment constraint - cdt.insert_constraint( - P.to_2d(iseg->vertex(0)),P.to_2d(iseg->vertex(1))); - }else if(const Point_3 *ipoint = CGAL::object_cast(&obj)) { - // Add point - cdt.insert(P.to_2d(*ipoint)); - } else if(const Triangle_3 *itri = CGAL::object_cast(&obj)) { - // Add 3 segment constraints - cdt.insert_constraint( - P.to_2d(itri->vertex(0)),P.to_2d(itri->vertex(1))); - cdt.insert_constraint( - P.to_2d(itri->vertex(1)),P.to_2d(itri->vertex(2))); - cdt.insert_constraint( - P.to_2d(itri->vertex(2)),P.to_2d(itri->vertex(0))); - } else if(const std::vector *polyp = - CGAL::object_cast< std::vector >(&obj)) { - //cerr< & poly = *polyp; - const Index m = poly.size(); - assert(m>=2); - for(Index p = 0;p v2i; - size_t count=0; - for (auto itr = cdt.finite_vertices_begin(); - itr != cdt.finite_vertices_end(); itr++) { - vertices.push_back(P.to_3d(itr->point())); - v2i[itr] = count; - count++; - } - for (auto itr = cdt.finite_faces_begin(); - itr != cdt.finite_faces_end(); itr++) { - faces.push_back( { - v2i[itr->vertex(0)], - v2i[itr->vertex(1)], - v2i[itr->vertex(2)] }); - } - }; - - /** - * Given p on triangle indexed by ori_f, determine the index of p. - */ - auto determine_point_index = [&]( - const Point_3& p, const size_t ori_f) -> Index { - const auto& triangle = T[ori_f]; - const auto& f = F.row(ori_f).eval(); - - // Check if p is one of the triangle corners. - for (size_t i=0; i<3; i++) { - if (p == triangle[i]) return f[i]; - } - - // Check if p is on one of the edges. - for (size_t i=0; i<3; i++) { - const Point_3 curr_corner = triangle[i]; - const Point_3 next_corner = triangle[(i+1)%3]; - const Segment_3 edge(curr_corner, next_corner); - if (edge.has_on(p)) { - const Index curr = f[i]; - const Index next = f[(i+1)%3]; - Edge key; - key.first = currsecond) { - if (p == new_vertices[vid - num_base_vertices]) { - return vid; - } - } - const size_t index = num_base_vertices + new_vertices.size(); - new_vertices.push_back(p); - itr->second.push_back(index); - return index; - } - } - } - - // p must be in the middle of the triangle. - const size_t index = num_base_vertices + new_vertices.size(); - new_vertices.push_back(p); - return index; - }; - - /** - * Determine the vertex indices for each corner of each output triangle. - */ - auto post_triangulation_process = [&]( - const std::vector& vertices, - const std::vector >& faces, - const std::vector& involved_faces) { - for (const auto& f : faces) { - const Point_3& v0 = vertices[f[0]]; - const Point_3& v1 = vertices[f[1]]; - const Point_3& v2 = vertices[f[2]]; - Point_3 center( - (v0[0] + v1[0] + v2[0]) / 3.0, - (v0[1] + v1[1] + v2[1]) / 3.0, - (v0[2] + v1[2] + v2[2]) / 3.0); - for (const auto& ori_f : involved_faces) { - const auto& triangle = T[ori_f]; - const Plane_3 P = triangle.supporting_plane(); - if (triangle.has_on(center)) { - std::vector corners(3); - corners[0] = determine_point_index(v0, ori_f); - corners[1] = determine_point_index(v1, ori_f); - corners[2] = determine_point_index(v2, ori_f); - if (CGAL::orientation( - P.to_2d(v0), P.to_2d(v1), P.to_2d(v2)) - == CGAL::RIGHT_TURN) { - std::swap(corners[0], corners[1]); - } - resolved_faces.emplace_back(corners); - source_faces.push_back(ori_f); - } - } - } - }; - - // Process un-touched faces. - for (size_t i=0; i vertices; - std::vector > faces; - run_delaunay_triangulation(P, involved_faces, vertices, faces); - post_triangulation_process(vertices, faces, involved_faces); - } - - // Output resolved mesh. - const size_t num_out_vertices = new_vertices.size() + num_base_vertices; - VV.resize(num_out_vertices, 3); - for (size_t i=0; i vv2i; - // Safe to check for duplicates using double for original vertices: if - // incoming reps are different then the points are unique. - for(Index v = 0;v, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -#endif - diff --git a/include/igl/cgal/remesh_intersections.h b/include/igl/cgal/remesh_intersections.h deleted file mode 100644 index 07c77f861..000000000 --- a/include/igl/cgal/remesh_intersections.h +++ /dev/null @@ -1,70 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 Qingnan Zhou -// -// 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_CGAL_REMESH_INTERSECTIONS_H -#define IGL_CGAL_REMESH_INTERSECTIONS_H - -#include -#include -#include "CGAL_includes.hpp" - -namespace igl -{ - namespace cgal - { - // Remesh faces according to results of intersection detection and - // construction (e.g. from `igl::cgal::intersect_other` or - // `igl::cgal::SelfIntersectMesh`) - // - // Inputs: - // V #V by 3 list of vertex positions - // F #F by 3 list of triangle indices into V - // T #F list of cgal triangles - // offending #offending map taking face indices into F to pairs of order - // of first finding and list of intersection objects from all - // intersections - // edge2faces #edges <= #offending*3 to incident offending faces - // Outputs: - // VV #VV by 3 list of vertex positions - // FF #FF by 3 list of triangle indices into V - // IF #intersecting face pairs by 2 list of intersecting face pairs, - // indexing F - // J #FF list of indices into F denoting birth triangle - // IM #VV list of indices into VV of unique vertices. - // - template < - typename DerivedV, - typename DerivedF, - typename Kernel, - typename DerivedVV, - typename DerivedFF, - typename DerivedJ, - typename DerivedIM> - IGL_INLINE void remesh_intersections( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - const std::vector > & T, - const std::map< - typename DerivedF::Index, - std::pair > > & offending, - const std::map< - std::pair, - std::vector > & edge2faces, - Eigen::PlainObjectBase & VV, - Eigen::PlainObjectBase & FF, - Eigen::PlainObjectBase & J, - Eigen::PlainObjectBase & IM); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "remesh_intersections.cpp" -#endif - -#endif diff --git a/include/igl/cgal/remesh_self_intersections.cpp b/include/igl/cgal/remesh_self_intersections.cpp deleted file mode 100644 index fe37225b7..000000000 --- a/include/igl/cgal/remesh_self_intersections.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2014 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#include "remesh_self_intersections.h" -#include "SelfIntersectMesh.h" -#include -#include -#include - -template < - typename DerivedV, - typename DerivedF, - typename DerivedVV, - typename DerivedFF, - typename DerivedIF, - typename DerivedJ, - typename DerivedIM> -IGL_INLINE void igl::cgal::remesh_self_intersections( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - const RemeshSelfIntersectionsParam & params, - Eigen::PlainObjectBase & VV, - Eigen::PlainObjectBase & FF, - Eigen::PlainObjectBase & IF, - Eigen::PlainObjectBase & J, - Eigen::PlainObjectBase & IM) -{ - using namespace std; - if(params.detect_only) - { - //// This is probably a terrible idea, but CGAL is throwing floating point - //// exceptions. - -//#ifdef __APPLE__ -//#define IGL_THROW_FPE 11 -// const auto & throw_fpe = [](int e) -// { -// throw "IGL_THROW_FPE"; -// }; -// signal(SIGFPE,throw_fpe); -//#endif - - typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; - typedef - SelfIntersectMesh< - Kernel, - DerivedV, - DerivedF, - DerivedVV, - DerivedFF, - DerivedIF, - DerivedJ, - DerivedIM> - SelfIntersectMeshK; - SelfIntersectMeshK SIM = SelfIntersectMeshK(V,F,params,VV,FF,IF,J,IM); - -//#ifdef __APPLE__ -// signal(SIGFPE,SIG_DFL); -//#endif - - }else - { - typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; - typedef - SelfIntersectMesh< - Kernel, - DerivedV, - DerivedF, - DerivedVV, - DerivedFF, - DerivedIF, - DerivedJ, - DerivedIM> - SelfIntersectMeshK; - SelfIntersectMeshK SIM = SelfIntersectMeshK(V,F,params,VV,FF,IF,J,IM); - } -} - -#ifdef IGL_STATIC_LIBRARY -// Explicit template specialization -template void igl::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_self_intersections, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, igl::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_self_intersections, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, igl::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -#endif diff --git a/include/igl/cgal/remesh_self_intersections.h b/include/igl/cgal/remesh_self_intersections.h deleted file mode 100644 index 2b7872c7a..000000000 --- a/include/igl/cgal/remesh_self_intersections.h +++ /dev/null @@ -1,85 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2014 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_CGAL_REMESH_SELF_INTERSECTIONS_H -#define IGL_CGAL_REMESH_SELF_INTERSECTIONS_H -#include -#include "RemeshSelfIntersectionsParam.h" - -#include - -#ifdef MEX -# include -# include -# undef assert -# define assert( isOK ) ( (isOK) ? (void)0 : (void) mexErrMsgTxt(C_STR(__FILE__<<":"<<__LINE__<<": failed assertion `"<<#isOK<<"'"< - IGL_INLINE void remesh_self_intersections( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - const RemeshSelfIntersectionsParam & params, - Eigen::PlainObjectBase & VV, - Eigen::PlainObjectBase & FF, - Eigen::PlainObjectBase & IF, - Eigen::PlainObjectBase & J, - Eigen::PlainObjectBase & IM); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "remesh_self_intersections.cpp" -#endif - -#endif diff --git a/include/igl/cgal/signed_distance_isosurface.h b/include/igl/cgal/signed_distance_isosurface.h deleted file mode 100644 index c8c76f1ce..000000000 --- a/include/igl/cgal/signed_distance_isosurface.h +++ /dev/null @@ -1,51 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2014 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 -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_CGAL_SIGNED_DISTANCE_ISOSURFACE_H -#define IGL_CGAL_SIGNED_DISTANCE_ISOSURFACE_H -#include "../igl_inline.h" -#include "../signed_distance.h" -#include -namespace igl -{ - namespace cgal - { - // SIGNED_DISTANCE_ISOSURFACE Compute the contour of an iso-level of the - // signed distance field to a given mesh. - // - // Inputs: - // IV #IV by 3 list of input mesh vertex positions - // IF #IF by 3 list of input triangle indices - // level iso-level to contour in world coords, negative is inside. - // angle_bound lower bound on triangle angles (mesh quality) (e.g. 28) - // radius_bound upper bound on triangle size (mesh density?) (e.g. 0.02) - // distance_bound cgal mysterious parameter (mesh density?) (e.g. 0.01) - // sign_type method for computing distance _sign_ (see - // ../signed_distance.h) - // Outputs: - // V #V by 3 list of input mesh vertex positions - // F #F by 3 list of input triangle indices - // - IGL_INLINE bool signed_distance_isosurface( - const Eigen::MatrixXd & IV, - const Eigen::MatrixXi & IF, - const double level, - const double angle_bound, - const double radius_bound, - const double distance_bound, - const SignedDistanceType sign_type, - Eigen::MatrixXd & V, - Eigen::MatrixXi & F); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "signed_distance_isosurface.cpp" -#endif - -#endif - diff --git a/include/igl/boolean/BinaryWindingNumberOperations.h b/include/igl/copyleft/boolean/BinaryWindingNumberOperations.h similarity index 85% rename from include/igl/boolean/BinaryWindingNumberOperations.h rename to include/igl/copyleft/boolean/BinaryWindingNumberOperations.h index 233f5ad7e..a1c3353d9 100644 --- a/include/igl/boolean/BinaryWindingNumberOperations.h +++ b/include/igl/copyleft/boolean/BinaryWindingNumberOperations.h @@ -6,19 +6,21 @@ // 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_BINARY_WINDING_NUMBER_OPERATIONS -#define IGL_BINARY_WINDING_NUMBER_OPERATIONS +#ifndef IGL_COPYLEFT_BOOLEAN_BINARY_WINDING_NUMBER_OPERATIONS_H +#define IGL_COPYLEFT_BOOLEAN_BINARY_WINDING_NUMBER_OPERATIONS_H #include -#include +#include "../../igl_inline.h" #include "MeshBooleanType.h" #include namespace igl { + namespace copyleft + { namespace boolean { - template + template class BinaryWindingNumberOperations { public: template @@ -29,7 +31,7 @@ namespace igl }; template <> - class BinaryWindingNumberOperations { + class BinaryWindingNumberOperations { public: template typename DerivedW::Scalar operator()( @@ -39,7 +41,7 @@ namespace igl }; template <> - class BinaryWindingNumberOperations { + class BinaryWindingNumberOperations { public: template typename DerivedW::Scalar operator()( @@ -49,7 +51,7 @@ namespace igl }; template <> - class BinaryWindingNumberOperations { + class BinaryWindingNumberOperations { public: template typename DerivedW::Scalar operator()( @@ -59,7 +61,7 @@ namespace igl }; template <> - class BinaryWindingNumberOperations { + class BinaryWindingNumberOperations { public: template typename DerivedW::Scalar operator()( @@ -70,7 +72,7 @@ namespace igl }; template <> - class BinaryWindingNumberOperations { + class BinaryWindingNumberOperations { public: template typename DerivedW::Scalar operator()( @@ -123,6 +125,7 @@ namespace igl typedef WindingNumberFilter KeepInside; typedef WindingNumberFilter KeepAll; } + } } #endif diff --git a/include/igl/copyleft/boolean/CSGTree.h b/include/igl/copyleft/boolean/CSGTree.h new file mode 100644 index 000000000..8160c20a9 --- /dev/null +++ b/include/igl/copyleft/boolean/CSGTree.h @@ -0,0 +1,185 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_BOOLEAN_CSG_TREE_H +#define IGL_COPYLEFT_BOOLEAN_CSG_TREE_H + +#include "string_to_mesh_boolean_type.h" +#include "MeshBooleanType.h" +#include "mesh_boolean.h" +#include +#include + +namespace igl +{ + namespace copyleft + { + namespace boolean + { + // Class for defining and computing a constructive solid geometry result + // out of a tree of boolean operations on "solid" triangle meshes. + // + //template + class CSGTree + { + private: + typedef CGAL::Epeck::FT ExactScalar; + typedef Eigen::Matrix MatrixX3E; + //typedef Eigen::PlainObjectBase POBF; + typedef Eigen::MatrixXi POBF; + typedef POBF::Index FIndex; + typedef Eigen::Matrix VectorJ; + // Resulting mesh + MatrixX3E m_V; + POBF m_F; + VectorJ m_J; + // Number of birth faces in A + those in B. I.e. sum of original "leaf" + // faces involved in result. + size_t m_number_of_birth_faces; + public: + CSGTree() + { + } + //typedef Eigen::MatrixXd MatrixX3E; + //typedef Eigen::MatrixXi POBF; + // http://stackoverflow.com/a/3279550/148668 + CSGTree(const CSGTree & other) + : + // copy things + m_V(other.m_V), + // This is an issue if m_F is templated + // https://forum.kde.org/viewtopic.php?f=74&t=128414 + m_F(other.m_F), + m_J(other.m_J), + m_number_of_birth_faces(other.m_number_of_birth_faces) + { + } + // copy-swap idiom + friend void swap(CSGTree& first, CSGTree& second) + { + using std::swap; + // swap things + swap(first.m_V,second.m_V); + // This is an issue if m_F is templated, similar to + // https://forum.kde.org/viewtopic.php?f=74&t=128414 + swap(first.m_F,second.m_F); + swap(first.m_J,second.m_J); + swap(first.m_number_of_birth_faces,second.m_number_of_birth_faces); + } + // Pass-by-value (aka copy) + CSGTree& operator=(CSGTree other) + { + swap(*this,other); + return *this; + } + CSGTree(CSGTree&& other): + // initialize via default constructor + CSGTree() + { + swap(*this,other); + } + // Construct and compute a boolean operation on existing CSGTree nodes. + // + // Inputs: + // A Solid result of previous CSG operation (or identity, see below) + // B Solid result of previous CSG operation (or identity, see below) + // type type of mesh boolean to compute + CSGTree( + const CSGTree & A, + const CSGTree & B, + const MeshBooleanType & type) + { + // conduct boolean operation + mesh_boolean(A.V(),A.F(),B.V(),B.F(),type,m_V,m_F,m_J); + // reindex m_J + std::for_each(m_J.data(),m_J.data()+m_J.size(), + [&](typename VectorJ::Scalar & j) + { + if(j < A.F().rows()) + { + j = A.J()(j); + }else + { + assert(j<(A.F().rows()+B.F().rows())); + j = A.number_of_birth_faces()+(B.J()(j-A.F().rows())); + } + }); + m_number_of_birth_faces = + A.number_of_birth_faces() + B.number_of_birth_faces(); + } + // Overload using string for type + CSGTree( + const CSGTree & A, + const CSGTree & B, + const std::string & s): + CSGTree(A,B,string_to_mesh_boolean_type(s)) + { + // do nothing (all done in constructor). + } + // "Leaf" node with identity operation on assumed "solid" mesh (V,F) + // + // Inputs: + // V #V by 3 list of mesh vertices (in any precision, will be + // converted to exact) + // F #F by 3 list of mesh face indices into V + template + CSGTree(const Eigen::PlainObjectBase & V, const POBF & F)//: + // Possible Eigen bug: + // https://forum.kde.org/viewtopic.php?f=74&t=128414 + //m_V(V.template cast()),m_F(F) + { + m_V = V.template cast(); + m_F = F; + // number of faces + m_number_of_birth_faces = m_F.rows(); + // identity birth index + m_J = VectorJ::LinSpaced( + m_number_of_birth_faces,0,m_number_of_birth_faces-1); + } + // Returns reference to resulting mesh vertices m_V in exact scalar + // representation + const MatrixX3E & V() const + { + return m_V; + } + // Returns mesh vertices in the desired output type, casting when + // appropriate to floating precision. + template + Eigen::PlainObjectBase cast_V() const + { + Eigen::PlainObjectBase dV; + dV.resize(m_V.rows(),m_V.cols()); + for(int i = 0;i +// +// 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_COPYLEFT_BOOLEAN_MESH_BOOLEAN_TYPE_H +#define IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_TYPE_H +namespace igl +{ + namespace copyleft + { + namespace boolean + { + enum MeshBooleanType + { + MESH_BOOLEAN_TYPE_UNION = 0, + MESH_BOOLEAN_TYPE_INTERSECT = 1, + MESH_BOOLEAN_TYPE_MINUS = 2, + MESH_BOOLEAN_TYPE_XOR = 3, + MESH_BOOLEAN_TYPE_RESOLVE = 4, + NUM_MESH_BOOLEAN_TYPES = 5 + }; + } + } +}; + +#endif diff --git a/include/igl/boolean/from_cork_mesh.cpp b/include/igl/copyleft/boolean/from_cork_mesh.cpp similarity index 61% rename from include/igl/boolean/from_cork_mesh.cpp rename to include/igl/copyleft/boolean/from_cork_mesh.cpp index a6c71aaf2..c3a392607 100644 --- a/include/igl/boolean/from_cork_mesh.cpp +++ b/include/igl/copyleft/boolean/from_cork_mesh.cpp @@ -11,7 +11,7 @@ template < typename DerivedV, typename DerivedF> -IGL_INLINE void igl::boolean::from_cork_mesh( +IGL_INLINE void igl::copyleft::boolean::from_cork_mesh( const CorkTriMesh & mesh, Eigen::PlainObjectBase & V, Eigen::PlainObjectBase & F) @@ -37,8 +37,8 @@ IGL_INLINE void igl::boolean::from_cork_mesh( #ifdef IGL_STATIC_LIBRARY // Explicit template specialization -template void igl::boolean::from_cork_mesh, Eigen::Matrix >(CorkTriMesh const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::boolean::from_cork_mesh, Eigen::Matrix >(CorkTriMesh const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::boolean::from_cork_mesh, Eigen::Matrix >(CorkTriMesh const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::boolean::from_cork_mesh, Eigen::Matrix >(CorkTriMesh const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif #endif diff --git a/include/igl/copyleft/boolean/from_cork_mesh.h b/include/igl/copyleft/boolean/from_cork_mesh.h new file mode 100644 index 000000000..6bb632b32 --- /dev/null +++ b/include/igl/copyleft/boolean/from_cork_mesh.h @@ -0,0 +1,41 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_BOOLEAN_FROM_CORK_MESH_H +#define IGL_COPYLEFT_BOOLEAN_FROM_CORK_MESH_H +#ifndef IGL_NO_CORK +#include "../../igl_inline.h" +#include +#include +namespace igl +{ + namespace copyleft + { + namespace boolean + { + // Convert cork's triangle mesh representation to a (V,F) mesh. + // + // Inputs: + // mesh cork representation of mesh + // Outputs: + // V #V by 3 list of vertex positions + // F #F by 3 list of triangle indices into V + template < + typename DerivedV, + typename DerivedF> + IGL_INLINE void from_cork_mesh( + const CorkTriMesh & mesh, + Eigen::PlainObjectBase & V, + Eigen::PlainObjectBase & F); + } + } +} +#ifndef IGL_STATIC_LIBRARY +# include "from_cork_mesh.cpp" +#endif +#endif +#endif diff --git a/include/igl/boolean/mesh_boolean.cpp b/include/igl/copyleft/boolean/mesh_boolean.cpp similarity index 74% rename from include/igl/boolean/mesh_boolean.cpp rename to include/igl/copyleft/boolean/mesh_boolean.cpp index 9e079745e..39ee01cf4 100644 --- a/include/igl/boolean/mesh_boolean.cpp +++ b/include/igl/copyleft/boolean/mesh_boolean.cpp @@ -12,15 +12,16 @@ #include "../cgal/assign_scalar.h" #include "../cgal/propagate_winding_numbers.h" #include "../cgal/remesh_self_intersections.h" -#include "../remove_unreferenced.h" -#include "../unique_simplices.h" -#include "../slice.h" +#include "../../remove_unreferenced.h" +#include "../../unique_simplices.h" +#include "../../slice.h" #include #include namespace igl { + namespace copyleft { namespace boolean { namespace mesh_boolean_helper { typedef CGAL::Epeck Kernel; @@ -39,12 +40,12 @@ namespace igl { Eigen::PlainObjectBase& Fo, Eigen::PlainObjectBase& J) { Eigen::VectorXi I; - igl::cgal::RemeshSelfIntersectionsParam params; + igl::copyleft::cgal::RemeshSelfIntersectionsParam params; DerivedVo Vr; DerivedFo Fr; Eigen::MatrixXi IF; - igl::cgal::remesh_self_intersections(V, F, params, Vr, Fr, IF, J, I); + igl::copyleft::cgal::remesh_self_intersections(V, F, params, Vr, Fr, IF, J, I); assert(I.size() == Vr.rows()); // Merge coinciding vertices into non-manifold vertices. @@ -164,6 +165,7 @@ namespace igl { } } } + } } template < @@ -177,7 +179,7 @@ typename ResolveFunc, typename DerivedVC, typename DerivedFC, typename DerivedJ> -IGL_INLINE void igl::boolean::per_face_winding_number_binary_operation( +IGL_INLINE void igl::copyleft::boolean::per_face_winding_number_binary_operation( const Eigen::PlainObjectBase & VA, const Eigen::PlainObjectBase & FA, const Eigen::PlainObjectBase & VB, @@ -188,7 +190,7 @@ IGL_INLINE void igl::boolean::per_face_winding_number_binary_operation( Eigen::PlainObjectBase & VC, Eigen::PlainObjectBase & FC, Eigen::PlainObjectBase & J) { - using namespace igl::boolean::mesh_boolean_helper; + using namespace igl::copyleft::boolean::mesh_boolean_helper; typedef typename DerivedVC::Scalar Scalar; typedef typename DerivedFC::Scalar Index; @@ -213,7 +215,7 @@ IGL_INLINE void igl::boolean::per_face_winding_number_binary_operation( Eigen::VectorXi labels(num_faces); std::transform(CJ.data(), CJ.data()+CJ.size(), labels.data(), [&](int i) { return i -IGL_INLINE void igl::boolean::mesh_boolean( +IGL_INLINE void igl::copyleft::boolean::mesh_boolean( const Eigen::PlainObjectBase & VA, const Eigen::PlainObjectBase & FA, const Eigen::PlainObjectBase & VB, @@ -300,7 +302,7 @@ IGL_INLINE void igl::boolean::mesh_boolean( Eigen::PlainObjectBase & VC, Eigen::PlainObjectBase & FC, Eigen::PlainObjectBase & J) { - using namespace igl::boolean::mesh_boolean_helper; + using namespace igl::copyleft::boolean::mesh_boolean_helper; typedef Eigen::Matrix< ExactScalar, Eigen::Dynamic, @@ -316,30 +318,30 @@ IGL_INLINE void igl::boolean::mesh_boolean( switch (type) { case MESH_BOOLEAN_TYPE_UNION: - igl::boolean::per_face_winding_number_binary_operation( - VA, FA, VB, FB, igl::boolean::BinaryUnion(), - igl::boolean::KeepInside(), resolve_func, VC, FC, J); + igl::copyleft::boolean::per_face_winding_number_binary_operation( + VA, FA, VB, FB, igl::copyleft::boolean::BinaryUnion(), + igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J); break; case MESH_BOOLEAN_TYPE_INTERSECT: - igl::boolean::per_face_winding_number_binary_operation( - VA, FA, VB, FB, igl::boolean::BinaryIntersect(), - igl::boolean::KeepInside(), resolve_func, VC, FC, J); + igl::copyleft::boolean::per_face_winding_number_binary_operation( + VA, FA, VB, FB, igl::copyleft::boolean::BinaryIntersect(), + igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J); break; case MESH_BOOLEAN_TYPE_MINUS: - igl::boolean::per_face_winding_number_binary_operation( - VA, FA, VB, FB, igl::boolean::BinaryMinus(), - igl::boolean::KeepInside(), resolve_func, VC, FC, J); + igl::copyleft::boolean::per_face_winding_number_binary_operation( + VA, FA, VB, FB, igl::copyleft::boolean::BinaryMinus(), + igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J); break; case MESH_BOOLEAN_TYPE_XOR: - igl::boolean::per_face_winding_number_binary_operation( - VA, FA, VB, FB, igl::boolean::BinaryXor(), - igl::boolean::KeepInside(), resolve_func, VC, FC, J); + igl::copyleft::boolean::per_face_winding_number_binary_operation( + VA, FA, VB, FB, igl::copyleft::boolean::BinaryXor(), + igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J); break; case MESH_BOOLEAN_TYPE_RESOLVE: //op = binary_resolve(); - igl::boolean::per_face_winding_number_binary_operation( - VA, FA, VB, FB, igl::boolean::BinaryResolve(), - igl::boolean::KeepAll(), resolve_func, VC, FC, J); + igl::copyleft::boolean::per_face_winding_number_binary_operation( + VA, FA, VB, FB, igl::copyleft::boolean::BinaryResolve(), + igl::copyleft::boolean::KeepAll(), resolve_func, VC, FC, J); break; default: throw std::runtime_error("Unsupported boolean type."); @@ -353,7 +355,7 @@ typename DerivedVB, typename DerivedFB, typename DerivedVC, typename DerivedFC> -IGL_INLINE void igl::boolean::mesh_boolean( +IGL_INLINE void igl::copyleft::boolean::mesh_boolean( const Eigen::PlainObjectBase & VA, const Eigen::PlainObjectBase & FA, const Eigen::PlainObjectBase & VB, @@ -362,17 +364,17 @@ IGL_INLINE void igl::boolean::mesh_boolean( Eigen::PlainObjectBase & VC, Eigen::PlainObjectBase & FC) { Eigen::Matrix J; - return igl::boolean::mesh_boolean(VA,FA,VB,FB,type,VC,FC,J); + return igl::copyleft::boolean::mesh_boolean(VA,FA,VB,FB,type,VC,FC,J); } #ifdef IGL_STATIC_LIBRARY // Explicit template specialization -template void igl::boolean::mesh_boolean, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::boolean::MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::boolean::mesh_boolean, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, igl::boolean::MeshBooleanType const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::boolean::mesh_boolean, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::boolean::MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::boolean::mesh_boolean, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::copyleft::boolean::MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::boolean::mesh_boolean, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, igl::copyleft::boolean::MeshBooleanType const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::boolean::mesh_boolean, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::copyleft::boolean::MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #undef IGL_STATIC_LIBRARY -#include "../remove_unreferenced.cpp" +#include "../../remove_unreferenced.cpp" template void igl::remove_unreferenced, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -#include "../slice.cpp" +#include "../../slice.cpp" template void igl::slice, -1, 3, 0, -1, 3> >, Eigen::Matrix, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, int, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&); #endif diff --git a/include/igl/boolean/mesh_boolean.h b/include/igl/copyleft/boolean/mesh_boolean.h similarity index 93% rename from include/igl/boolean/mesh_boolean.h rename to include/igl/copyleft/boolean/mesh_boolean.h index e43b88ca3..716b65cf9 100644 --- a/include/igl/boolean/mesh_boolean.h +++ b/include/igl/copyleft/boolean/mesh_boolean.h @@ -7,18 +7,20 @@ // 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_BOOLEAN_MESH_BOOLEAN_H -#define IGL_BOOLEAN_MESH_BOOLEAN_H +#ifndef IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_H +#define IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_H -#include +#include "../../igl_inline.h" #include "MeshBooleanType.h" #include #include namespace igl { - namespace boolean + namespace copyleft { + namespace boolean + { template < typename DerivedVA, typename DerivedFA, @@ -75,7 +77,7 @@ namespace igl const MeshBooleanType & type, Eigen::PlainObjectBase & VC, Eigen::PlainObjectBase & FC); - + } } } diff --git a/include/igl/boolean/mesh_boolean_cork.cpp b/include/igl/copyleft/boolean/mesh_boolean_cork.cpp similarity index 60% rename from include/igl/boolean/mesh_boolean_cork.cpp rename to include/igl/copyleft/boolean/mesh_boolean_cork.cpp index 624f0c344..c6d5c3381 100644 --- a/include/igl/boolean/mesh_boolean_cork.cpp +++ b/include/igl/copyleft/boolean/mesh_boolean_cork.cpp @@ -17,7 +17,7 @@ template < typename DerivedFB, typename DerivedVC, typename DerivedFC> -IGL_INLINE void igl::boolean::mesh_boolean_cork( +IGL_INLINE void igl::copyleft::boolean::mesh_boolean_cork( const Eigen::PlainObjectBase & VA, const Eigen::PlainObjectBase & FA, const Eigen::PlainObjectBase & VB, @@ -94,8 +94,8 @@ IGL_INLINE void igl::boolean::mesh_boolean_cork( } #ifdef IGL_STATIC_LIBRARY // Explicit template specialization -template void igl::boolean::mesh_boolean_cork, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::boolean::mesh_boolean_cork, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::boolean::MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::boolean::mesh_boolean_cork, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::boolean::mesh_boolean_cork, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::copyleft::boolean::MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif #endif diff --git a/include/igl/copyleft/boolean/mesh_boolean_cork.h b/include/igl/copyleft/boolean/mesh_boolean_cork.h new file mode 100644 index 000000000..5e16f9666 --- /dev/null +++ b/include/igl/copyleft/boolean/mesh_boolean_cork.h @@ -0,0 +1,57 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_CORK_H +#define IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_CORK_H +#ifndef IGL_NO_CORK +#include "MeshBooleanType.h" +#include "../../igl_inline.h" +#include +#include // for consistent uint + +namespace igl +{ + namespace copyleft + { + namespace boolean + { + // Compute a boolean operation on two input meshes using the cork library. + // + // Inputs: + // VA #VA by 3 list of vertex positions of first mesh + // FA #FA by 3 list of triangle indices into VA + // VB #VB by 3 list of vertex positions of second mesh + // FB #FB by 3 list of triangle indices into VB + // type of boolean operation see MeshBooleanType.h + // Outputs: + // VC #VC by 3 list of vertex positions of output mesh + // FC #FC by 3 list of triangle indices into VC + template < + typename DerivedVA, + typename DerivedFA, + typename DerivedVB, + typename DerivedFB, + typename DerivedVC, + typename DerivedFC> + IGL_INLINE void mesh_boolean_cork( + const Eigen::PlainObjectBase & VA, + const Eigen::PlainObjectBase & FA, + const Eigen::PlainObjectBase & VB, + const Eigen::PlainObjectBase & FB, + const MeshBooleanType & type, + Eigen::PlainObjectBase & VC, + Eigen::PlainObjectBase & FC); + } + } +} + +#ifndef IGL_STATIC_LIBRARY +# include "mesh_boolean_cork.cpp" +#endif +#endif + +#endif diff --git a/include/igl/boolean/string_to_mesh_boolean_type.cpp b/include/igl/copyleft/boolean/string_to_mesh_boolean_type.cpp similarity index 87% rename from include/igl/boolean/string_to_mesh_boolean_type.cpp rename to include/igl/copyleft/boolean/string_to_mesh_boolean_type.cpp index ba77186a7..1dbec9fa5 100644 --- a/include/igl/boolean/string_to_mesh_boolean_type.cpp +++ b/include/igl/copyleft/boolean/string_to_mesh_boolean_type.cpp @@ -3,7 +3,7 @@ #include #include -IGL_INLINE bool igl::boolean::string_to_mesh_boolean_type( +IGL_INLINE bool igl::copyleft::boolean::string_to_mesh_boolean_type( const std::string & s, MeshBooleanType & type) { @@ -38,7 +38,7 @@ IGL_INLINE bool igl::boolean::string_to_mesh_boolean_type( return true; } -IGL_INLINE igl::boolean::MeshBooleanType igl::boolean::string_to_mesh_boolean_type( +IGL_INLINE igl::copyleft::boolean::MeshBooleanType igl::copyleft::boolean::string_to_mesh_boolean_type( const std::string & s) { MeshBooleanType type; diff --git a/include/igl/copyleft/boolean/string_to_mesh_boolean_type.h b/include/igl/copyleft/boolean/string_to_mesh_boolean_type.h new file mode 100644 index 000000000..64ac324d3 --- /dev/null +++ b/include/igl/copyleft/boolean/string_to_mesh_boolean_type.h @@ -0,0 +1,44 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_BOOLEAN_STRING_TO_MESH_BOOLEAN_H +#define IGL_COPYLEFT_BOOLEAN_STRING_TO_MESH_BOOLEAN_H + +#include "../../igl_inline.h" +#include "MeshBooleanType.h" +#include + +namespace igl +{ + namespace copyleft + { + namespace boolean + { + // Convert string to boolean type + // + // Inputs: + // s string identifying type, one of the following: + // "union","intersect","minus","xor","resolve" + // Outputs: + // type type of boolean operation + // Returns true only on success + // + IGL_INLINE bool string_to_mesh_boolean_type( + const std::string & s, + MeshBooleanType & type); + // Returns type without error handling + IGL_INLINE MeshBooleanType string_to_mesh_boolean_type( + const std::string & s); + } + } +} + +#ifndef IGL_STATIC_LIBRARY +# include "string_to_mesh_boolean_type.cpp" +#endif + +#endif diff --git a/include/igl/boolean/to_cork_mesh.cpp b/include/igl/copyleft/boolean/to_cork_mesh.cpp similarity index 66% rename from include/igl/boolean/to_cork_mesh.cpp rename to include/igl/copyleft/boolean/to_cork_mesh.cpp index adba15199..a332d8092 100644 --- a/include/igl/boolean/to_cork_mesh.cpp +++ b/include/igl/copyleft/boolean/to_cork_mesh.cpp @@ -10,7 +10,7 @@ template < typename DerivedV, typename DerivedF> -IGL_INLINE void igl::boolean::to_cork_mesh( +IGL_INLINE void igl::copyleft::boolean::to_cork_mesh( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & F, CorkTriMesh & mesh) @@ -39,7 +39,7 @@ IGL_INLINE void igl::boolean::to_cork_mesh( } #ifdef IGL_STATIC_LIBRARY // Explicit template specialization -template void igl::boolean::to_cork_mesh, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, CorkTriMesh&); -template void igl::boolean::to_cork_mesh, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, CorkTriMesh&); +template void igl::copyleft::boolean::to_cork_mesh, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, CorkTriMesh&); +template void igl::copyleft::boolean::to_cork_mesh, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, CorkTriMesh&); #endif #endif diff --git a/include/igl/copyleft/boolean/to_cork_mesh.h b/include/igl/copyleft/boolean/to_cork_mesh.h new file mode 100644 index 000000000..60ae184b5 --- /dev/null +++ b/include/igl/copyleft/boolean/to_cork_mesh.h @@ -0,0 +1,41 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_BOOLEAN_TO_CORK_MESH_H +#define IGL_COPYLEFT_BOOLEAN_TO_CORK_MESH_H +#ifndef IGL_NO_CORK +#include "../../igl_inline.h" +#include +#include +namespace igl +{ + namespace copyleft + { + namespace boolean + { + // Convert a (V,F) mesh to a cork's triangle mesh representation. + // + // Inputs: + // V #V by 3 list of vertex positions + // F #F by 3 list of triangle indices into V + // Outputs: + // mesh cork representation of mesh + template < + typename DerivedV, + typename DerivedF> + IGL_INLINE void to_cork_mesh( + const Eigen::PlainObjectBase & V, + const Eigen::PlainObjectBase & F, + CorkTriMesh & mesh); + } + } +} +#ifndef IGL_STATIC_LIBRARY +# include "to_cork_mesh.cpp" +#endif +#endif +#endif diff --git a/include/igl/cgal/CGAL_includes.hpp b/include/igl/copyleft/cgal/CGAL_includes.hpp similarity index 100% rename from include/igl/cgal/CGAL_includes.hpp rename to include/igl/copyleft/cgal/CGAL_includes.hpp diff --git a/include/igl/copyleft/cgal/RemeshSelfIntersectionsParam.h b/include/igl/copyleft/cgal/RemeshSelfIntersectionsParam.h new file mode 100644 index 000000000..26e53d04e --- /dev/null +++ b/include/igl/copyleft/cgal/RemeshSelfIntersectionsParam.h @@ -0,0 +1,31 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_CGAL_REMESH_SELF_INTERSECTIONS_PARAM_H +#define IGL_COPYLEFT_CGAL_REMESH_SELF_INTERSECTIONS_PARAM_H + +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // Optional Parameters + // DetectOnly Only compute IF, leave VV and FF alone + struct RemeshSelfIntersectionsParam + { + bool detect_only; + bool first_only; + RemeshSelfIntersectionsParam():detect_only(false),first_only(false){}; + RemeshSelfIntersectionsParam(bool _detect_only, bool _first_only): + detect_only(_detect_only),first_only(_first_only){}; + }; + } + } +} + +#endif diff --git a/include/igl/cgal/SelfIntersectMesh.h b/include/igl/copyleft/cgal/SelfIntersectMesh.h similarity index 67% rename from include/igl/cgal/SelfIntersectMesh.h rename to include/igl/copyleft/cgal/SelfIntersectMesh.h index 8cbb90182..cc313a3ea 100644 --- a/include/igl/cgal/SelfIntersectMesh.h +++ b/include/igl/copyleft/cgal/SelfIntersectMesh.h @@ -5,8 +5,8 @@ // 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_CGAL_SELFINTERSECTMESH_H -#define IGL_CGAL_SELFINTERSECTMESH_H +#ifndef IGL_COPYLEFT_CGAL_SELFINTERSECTMESH_H +#define IGL_COPYLEFT_CGAL_SELFINTERSECTMESH_H #include "CGAL_includes.hpp" #include "RemeshSelfIntersectionsParam.h" @@ -25,199 +25,202 @@ namespace igl { - namespace cgal + namespace copyleft { - // Kernel is a CGAL kernel like: - // CGAL::Exact_predicates_inexact_constructions_kernel - // or - // CGAL::Exact_predicates_exact_constructions_kernel - - template < - typename Kernel, - typename DerivedV, - typename DerivedF, - typename DerivedVV, - typename DerivedFF, - typename DerivedIF, - typename DerivedJ, - typename DerivedIM> - class SelfIntersectMesh + namespace cgal { - typedef - SelfIntersectMesh< - Kernel, - DerivedV, - DerivedF, - DerivedVV, - DerivedFF, - DerivedIF, - DerivedJ, - DerivedIM> Self; - public: - // 3D Primitives - typedef CGAL::Point_3 Point_3; - typedef CGAL::Segment_3 Segment_3; - typedef CGAL::Triangle_3 Triangle_3; - typedef CGAL::Plane_3 Plane_3; - typedef CGAL::Tetrahedron_3 Tetrahedron_3; - //typedef CGAL::Polyhedron_3 Polyhedron_3; - //typedef CGAL::Nef_polyhedron_3 Nef_polyhedron_3; - // 2D Primitives - typedef CGAL::Point_2 Point_2; - typedef CGAL::Segment_2 Segment_2; - typedef CGAL::Triangle_2 Triangle_2; - // 2D Constrained Delaunay Triangulation types - typedef CGAL::Triangulation_vertex_base_2 TVB_2; - typedef CGAL::Constrained_triangulation_face_base_2 CTFB_2; - typedef CGAL::Triangulation_data_structure_2 TDS_2; - typedef CGAL::Exact_intersections_tag Itag; - typedef CGAL::Constrained_Delaunay_triangulation_2 - CDT_2; - typedef CGAL::Constrained_triangulation_plus_2 CDT_plus_2; - // Axis-align boxes for all-pairs self-intersection detection - typedef std::vector Triangles; - typedef typename Triangles::iterator TrianglesIterator; - typedef typename Triangles::const_iterator TrianglesConstIterator; + // Kernel is a CGAL kernel like: + // CGAL::Exact_predicates_inexact_constructions_kernel + // or + // CGAL::Exact_predicates_exact_constructions_kernel + + template < + typename Kernel, + typename DerivedV, + typename DerivedF, + typename DerivedVV, + typename DerivedFF, + typename DerivedIF, + typename DerivedJ, + typename DerivedIM> + class SelfIntersectMesh + { typedef - CGAL::Box_intersection_d::Box_with_handle_d - Box; - - // Input mesh - const Eigen::PlainObjectBase & V; - const Eigen::PlainObjectBase & F; - // Number of self-intersecting triangle pairs - typedef typename DerivedF::Index Index; - Index count; - typedef std::vector ObjectList; - // Using a vector here makes this **not** output sensitive - Triangles T; - typedef std::vector IndexList; - IndexList lIF; - // #F-long list of faces with intersections mapping to the order in - // which they were first found - std::map > offending; - // Make a short name for the edge map's key - typedef std::pair EMK; - // Make a short name for the type stored at each edge, the edge map's - // value - typedef std::vector EMV; - // Make a short name for the edge map - typedef std::map EdgeMap; - // Maps edges of offending faces to all incident offending faces - EdgeMap edge2faces; - public: - RemeshSelfIntersectionsParam params; - public: - // Constructs (VV,FF) a new mesh with self-intersections of (V,F) - // subdivided - // - // See also: remesh_self_intersections.h - inline SelfIntersectMesh( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - const RemeshSelfIntersectionsParam & params, - Eigen::PlainObjectBase & VV, - Eigen::PlainObjectBase & FF, - Eigen::PlainObjectBase & IF, - Eigen::PlainObjectBase & J, - Eigen::PlainObjectBase & IM); - private: - // Helper function to mark a face as offensive - // - // Inputs: - // f index of face in F - inline void mark_offensive(const Index f); - // Helper function to count intersections between faces - // - // Input: - // fa index of face A in F - // fb index of face B in F - inline void count_intersection( const Index fa, const Index fb); - // Helper function for box_intersect. Intersect two triangles A and B, - // append the intersection object (point,segment,triangle) to a running - // list for A and B - // - // Inputs: - // A triangle in 3D - // B triangle in 3D - // fa index of A in F (and key into offending) - // fb index of A in F (and key into offending) - // Returns true only if A intersects B - // - inline bool intersect( - const Triangle_3 & A, - const Triangle_3 & B, - const Index fa, - const Index fb); - // Helper function for box_intersect. In the case where A and B have - // already been identified to share a vertex, then we only want to add - // possible segment intersections. Assumes truly duplicate triangles are - // not given as input - // - // Inputs: - // A triangle in 3D - // B triangle in 3D - // fa index of A in F (and key into offending) - // fb index of B in F (and key into offending) - // va index of shared vertex in A (and key into offending) - // vb index of shared vertex in B (and key into offending) - //// Returns object of intersection (should be Segment or point) - // Returns true if intersection (besides shared point) - // - inline bool single_shared_vertex( - const Triangle_3 & A, - const Triangle_3 & B, - const Index fa, - const Index fb, - const Index va, - const Index vb); - // Helper handling one direction - inline bool single_shared_vertex( - const Triangle_3 & A, - const Triangle_3 & B, - const Index fa, - const Index fb, - const Index va); - // Helper function for box_intersect. In the case where A and B have - // already been identified to share two vertices, then we only want to add - // a possible coplanar (Triangle) intersection. Assumes truly degenerate - // facets are not givin as input. - inline bool double_shared_vertex( - const Triangle_3 & A, - const Triangle_3 & B, - const Index fa, - const Index fb, - const std::vector > shared); - - public: - // Callback function called during box self intersections test. Means - // boxes a and b intersect. This method then checks if the triangles in - // each box intersect and if so, then processes the intersections - // - // Inputs: - // a box containing a triangle - // b box containing a triangle - inline void box_intersect(const Box& a, const Box& b); - private: - // Compute 2D delaunay triangulation of a given 3d triangle and a list of - // intersection objects (points,segments,triangles). CGAL uses an affine - // projection rather than an isometric projection, so we're not - // guaranteed that the 2D delaunay triangulation here will be a delaunay - // triangulation in 3D. - // - // Inputs: - // A triangle in 3D - // A_objects_3 updated list of intersection objects for A - // Outputs: - // cdt Contrained delaunay triangulation in projected 2D plane - public: - // Getters: - //const IndexList& get_lIF() const{ return lIF;} - static inline void box_intersect_static( - SelfIntersectMesh * SIM, - const Box &a, - const Box &b); - }; + SelfIntersectMesh< + Kernel, + DerivedV, + DerivedF, + DerivedVV, + DerivedFF, + DerivedIF, + DerivedJ, + DerivedIM> Self; + public: + // 3D Primitives + typedef CGAL::Point_3 Point_3; + typedef CGAL::Segment_3 Segment_3; + typedef CGAL::Triangle_3 Triangle_3; + typedef CGAL::Plane_3 Plane_3; + typedef CGAL::Tetrahedron_3 Tetrahedron_3; + //typedef CGAL::Polyhedron_3 Polyhedron_3; + //typedef CGAL::Nef_polyhedron_3 Nef_polyhedron_3; + // 2D Primitives + typedef CGAL::Point_2 Point_2; + typedef CGAL::Segment_2 Segment_2; + typedef CGAL::Triangle_2 Triangle_2; + // 2D Constrained Delaunay Triangulation types + typedef CGAL::Triangulation_vertex_base_2 TVB_2; + typedef CGAL::Constrained_triangulation_face_base_2 CTFB_2; + typedef CGAL::Triangulation_data_structure_2 TDS_2; + typedef CGAL::Exact_intersections_tag Itag; + typedef CGAL::Constrained_Delaunay_triangulation_2 + CDT_2; + typedef CGAL::Constrained_triangulation_plus_2 CDT_plus_2; + // Axis-align boxes for all-pairs self-intersection detection + typedef std::vector Triangles; + typedef typename Triangles::iterator TrianglesIterator; + typedef typename Triangles::const_iterator TrianglesConstIterator; + typedef + CGAL::Box_intersection_d::Box_with_handle_d + Box; + + // Input mesh + const Eigen::PlainObjectBase & V; + const Eigen::PlainObjectBase & F; + // Number of self-intersecting triangle pairs + typedef typename DerivedF::Index Index; + Index count; + typedef std::vector ObjectList; + // Using a vector here makes this **not** output sensitive + Triangles T; + typedef std::vector IndexList; + IndexList lIF; + // #F-long list of faces with intersections mapping to the order in + // which they were first found + std::map > offending; + // Make a short name for the edge map's key + typedef std::pair EMK; + // Make a short name for the type stored at each edge, the edge map's + // value + typedef std::vector EMV; + // Make a short name for the edge map + typedef std::map EdgeMap; + // Maps edges of offending faces to all incident offending faces + EdgeMap edge2faces; + public: + RemeshSelfIntersectionsParam params; + public: + // Constructs (VV,FF) a new mesh with self-intersections of (V,F) + // subdivided + // + // See also: remesh_self_intersections.h + inline SelfIntersectMesh( + const Eigen::PlainObjectBase & V, + const Eigen::PlainObjectBase & F, + const RemeshSelfIntersectionsParam & params, + Eigen::PlainObjectBase & VV, + Eigen::PlainObjectBase & FF, + Eigen::PlainObjectBase & IF, + Eigen::PlainObjectBase & J, + Eigen::PlainObjectBase & IM); + private: + // Helper function to mark a face as offensive + // + // Inputs: + // f index of face in F + inline void mark_offensive(const Index f); + // Helper function to count intersections between faces + // + // Input: + // fa index of face A in F + // fb index of face B in F + inline void count_intersection( const Index fa, const Index fb); + // Helper function for box_intersect. Intersect two triangles A and B, + // append the intersection object (point,segment,triangle) to a running + // list for A and B + // + // Inputs: + // A triangle in 3D + // B triangle in 3D + // fa index of A in F (and key into offending) + // fb index of A in F (and key into offending) + // Returns true only if A intersects B + // + inline bool intersect( + const Triangle_3 & A, + const Triangle_3 & B, + const Index fa, + const Index fb); + // Helper function for box_intersect. In the case where A and B have + // already been identified to share a vertex, then we only want to add + // possible segment intersections. Assumes truly duplicate triangles are + // not given as input + // + // Inputs: + // A triangle in 3D + // B triangle in 3D + // fa index of A in F (and key into offending) + // fb index of B in F (and key into offending) + // va index of shared vertex in A (and key into offending) + // vb index of shared vertex in B (and key into offending) + //// Returns object of intersection (should be Segment or point) + // Returns true if intersection (besides shared point) + // + inline bool single_shared_vertex( + const Triangle_3 & A, + const Triangle_3 & B, + const Index fa, + const Index fb, + const Index va, + const Index vb); + // Helper handling one direction + inline bool single_shared_vertex( + const Triangle_3 & A, + const Triangle_3 & B, + const Index fa, + const Index fb, + const Index va); + // Helper function for box_intersect. In the case where A and B have + // already been identified to share two vertices, then we only want to add + // a possible coplanar (Triangle) intersection. Assumes truly degenerate + // facets are not givin as input. + inline bool double_shared_vertex( + const Triangle_3 & A, + const Triangle_3 & B, + const Index fa, + const Index fb, + const std::vector > shared); + + public: + // Callback function called during box self intersections test. Means + // boxes a and b intersect. This method then checks if the triangles in + // each box intersect and if so, then processes the intersections + // + // Inputs: + // a box containing a triangle + // b box containing a triangle + inline void box_intersect(const Box& a, const Box& b); + private: + // Compute 2D delaunay triangulation of a given 3d triangle and a list of + // intersection objects (points,segments,triangles). CGAL uses an affine + // projection rather than an isometric projection, so we're not + // guaranteed that the 2D delaunay triangulation here will be a delaunay + // triangulation in 3D. + // + // Inputs: + // A triangle in 3D + // A_objects_3 updated list of intersection objects for A + // Outputs: + // cdt Contrained delaunay triangulation in projected 2D plane + public: + // Getters: + //const IndexList& get_lIF() const{ return lIF;} + static inline void box_intersect_static( + SelfIntersectMesh * SIM, + const Box &a, + const Box &b); + }; + } } } @@ -227,9 +230,9 @@ namespace igl #include "remesh_intersections.h" #include "remesh_intersections.h" -#include -#include -#include +#include "../../REDRUM.h" +#include "../../get_seconds.h" +#include "../../C_STR.h" #include @@ -272,7 +275,7 @@ template < typename DerivedIF, typename DerivedJ, typename DerivedIM> -inline void igl::cgal::SelfIntersectMesh< +inline void igl::copyleft::cgal::SelfIntersectMesh< Kernel, DerivedV, DerivedF, @@ -297,7 +300,7 @@ template < typename DerivedIF, typename DerivedJ, typename DerivedIM> -inline igl::cgal::SelfIntersectMesh< +inline igl::copyleft::cgal::SelfIntersectMesh< Kernel, DerivedV, DerivedF, @@ -430,7 +433,7 @@ template < typename DerivedIF, typename DerivedJ, typename DerivedIM> -inline void igl::cgal::SelfIntersectMesh< +inline void igl::copyleft::cgal::SelfIntersectMesh< Kernel, DerivedV, DerivedF, @@ -466,7 +469,7 @@ template < typename DerivedIF, typename DerivedJ, typename DerivedIM> -inline void igl::cgal::SelfIntersectMesh< +inline void igl::copyleft::cgal::SelfIntersectMesh< Kernel, DerivedV, DerivedF, @@ -497,7 +500,7 @@ template < typename DerivedIF, typename DerivedJ, typename DerivedIM> -inline bool igl::cgal::SelfIntersectMesh< +inline bool igl::copyleft::cgal::SelfIntersectMesh< Kernel, DerivedV, DerivedF, @@ -536,7 +539,7 @@ template < typename DerivedIF, typename DerivedJ, typename DerivedIM> -inline bool igl::cgal::SelfIntersectMesh< +inline bool igl::copyleft::cgal::SelfIntersectMesh< Kernel, DerivedV, DerivedF, @@ -582,7 +585,7 @@ template < typename DerivedIF, typename DerivedJ, typename DerivedIM> -inline bool igl::cgal::SelfIntersectMesh< +inline bool igl::copyleft::cgal::SelfIntersectMesh< Kernel, DerivedV, DerivedF, @@ -661,7 +664,7 @@ template < typename DerivedIF, typename DerivedJ, typename DerivedIM> -inline bool igl::cgal::SelfIntersectMesh< +inline bool igl::copyleft::cgal::SelfIntersectMesh< Kernel, DerivedV, DerivedF, @@ -803,7 +806,7 @@ template < typename DerivedIF, typename DerivedJ, typename DerivedIM> -inline void igl::cgal::SelfIntersectMesh< +inline void igl::copyleft::cgal::SelfIntersectMesh< Kernel, DerivedV, DerivedF, diff --git a/include/igl/cgal/assign_scalar.cpp b/include/igl/copyleft/cgal/assign_scalar.cpp similarity index 79% rename from include/igl/cgal/assign_scalar.cpp rename to include/igl/copyleft/cgal/assign_scalar.cpp index 854aea293..f288f5d2d 100644 --- a/include/igl/cgal/assign_scalar.cpp +++ b/include/igl/copyleft/cgal/assign_scalar.cpp @@ -7,21 +7,21 @@ // obtain one at http://mozilla.org/MPL/2.0/. #include "assign_scalar.h" -IGL_INLINE void igl::cgal::assign_scalar( +IGL_INLINE void igl::copyleft::cgal::assign_scalar( const typename CGAL::Epeck::FT & cgal, CGAL::Epeck::FT & d) { d = cgal; } -IGL_INLINE void igl::cgal::assign_scalar( +IGL_INLINE void igl::copyleft::cgal::assign_scalar( const typename CGAL::Epeck::FT & cgal, double & d) { d = CGAL::to_double(cgal); } -IGL_INLINE void igl::cgal::assign_scalar( +IGL_INLINE void igl::copyleft::cgal::assign_scalar( const double & c, double & d) { diff --git a/include/igl/copyleft/cgal/assign_scalar.h b/include/igl/copyleft/cgal/assign_scalar.h new file mode 100644 index 000000000..d53fabb47 --- /dev/null +++ b/include/igl/copyleft/cgal/assign_scalar.h @@ -0,0 +1,37 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_CGAL_ASSIGN_SCALAR_H +#define IGL_COPYLEFT_CGAL_ASSIGN_SCALAR_H +#include "../../igl_inline.h" +#include "CGAL_includes.hpp" +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // Inputs: + // cgal cgal scalar + // Outputs: + // d output scalar + IGL_INLINE void assign_scalar( + const typename CGAL::Epeck::FT & cgal, + CGAL::Epeck::FT & d); + IGL_INLINE void assign_scalar( + const typename CGAL::Epeck::FT & cgal, + double & d); + IGL_INLINE void assign_scalar( + const double & c, + double & d); + } + } +} +#ifndef IGL_STATIC_LIBRARY +# include "assign_scalar.cpp" +#endif +#endif diff --git a/include/igl/cgal/closest_facet.cpp b/include/igl/copyleft/cgal/closest_facet.cpp similarity index 93% rename from include/igl/cgal/closest_facet.cpp rename to include/igl/copyleft/cgal/closest_facet.cpp index 01fb91413..1f883c0a9 100644 --- a/include/igl/cgal/closest_facet.cpp +++ b/include/igl/copyleft/cgal/closest_facet.cpp @@ -26,7 +26,7 @@ template< typename DerivedP, typename DerivedR, typename DerivedS > -IGL_INLINE void igl::cgal::closest_facet( +IGL_INLINE void igl::copyleft::cgal::closest_facet( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, const Eigen::PlainObjectBase& I, @@ -172,7 +172,7 @@ IGL_INLINE void igl::cgal::closest_facet( Eigen::VectorXi order; DerivedP pivot = P.row(query_idx).eval(); - igl::cgal::order_facets_around_edge(V, F, s, d, + igl::copyleft::cgal::order_facets_around_edge(V, F, s, d, intersected_face_signed_indices, pivot, order); @@ -343,7 +343,7 @@ template< typename DerivedP, typename DerivedR, typename DerivedS > -IGL_INLINE void igl::cgal::closest_facet( +IGL_INLINE void igl::copyleft::cgal::closest_facet( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, const Eigen::PlainObjectBase& P, @@ -352,9 +352,9 @@ IGL_INLINE void igl::cgal::closest_facet( const size_t num_faces = F.rows(); Eigen::VectorXi I(num_faces); I.setLinSpaced(num_faces, 0, num_faces-1); - igl::cgal::closest_facet(V, F, I, P, R, S); + igl::copyleft::cgal::closest_facet(V, F, I, P, R, S); } #ifdef IGL_STATIC_LIBRARY -template void igl::cgal::closest_facet, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::closest_facet, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/copyleft/cgal/closest_facet.h b/include/igl/copyleft/cgal/closest_facet.h new file mode 100644 index 000000000..5c83320e7 --- /dev/null +++ b/include/igl/copyleft/cgal/closest_facet.h @@ -0,0 +1,67 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 Qingnan Zhou +// +// 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_COPYLET_CGAL_CLOSEST_FACET_H +#define IGL_COPYLET_CGAL_CLOSEST_FACET_H + +#include "../../igl_inline.h" +#include + +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // Determine the closest facet for each of the input points. + // + // Inputs: + // V #V by 3 array of vertices. + // F #F by 3 array of faces. + // I #I list of triangle indices to consider. + // P #P by 3 array of query points. + // + // Outputs: + // R #P list of closest facet indices. + // S #P list of bools indicating on which side of the closest facet + // each query point lies. + template< + typename DerivedV, + typename DerivedF, + typename DerivedI, + typename DerivedP, + typename DerivedR, + typename DerivedS > + IGL_INLINE void closest_facet( + const Eigen::PlainObjectBase& V, + const Eigen::PlainObjectBase& F, + const Eigen::PlainObjectBase& I, + const Eigen::PlainObjectBase& P, + Eigen::PlainObjectBase& R, + Eigen::PlainObjectBase& S); + + template< + typename DerivedV, + typename DerivedF, + typename DerivedP, + typename DerivedR, + typename DerivedS > + IGL_INLINE void closest_facet( + const Eigen::PlainObjectBase& V, + const Eigen::PlainObjectBase& F, + const Eigen::PlainObjectBase& P, + Eigen::PlainObjectBase& R, + Eigen::PlainObjectBase& S); + } + } +} + +#ifndef IGL_STATIC_LIBRARY +#include "closest_facet.cpp" +#endif +#endif diff --git a/include/igl/cgal/complex_to_mesh.cpp b/include/igl/copyleft/cgal/complex_to_mesh.cpp similarity index 71% rename from include/igl/cgal/complex_to_mesh.cpp rename to include/igl/copyleft/cgal/complex_to_mesh.cpp index eace8f1db..2462bcd7b 100644 --- a/include/igl/cgal/complex_to_mesh.cpp +++ b/include/igl/copyleft/cgal/complex_to_mesh.cpp @@ -7,8 +7,8 @@ // obtain one at http://mozilla.org/MPL/2.0/. #include "complex_to_mesh.h" -#include -#include +#include "../../centroid.h" +#include "../../remove_unreferenced.h" #include #include @@ -16,7 +16,7 @@ #include template -IGL_INLINE bool igl::cgal::complex_to_mesh( +IGL_INLINE bool igl::copyleft::cgal::complex_to_mesh( const CGAL::Complex_2_in_triangulation_3 & c2t3, Eigen::PlainObjectBase & V, Eigen::PlainObjectBase & F) @@ -149,5 +149,5 @@ IGL_INLINE bool igl::cgal::complex_to_mesh( } #ifdef IGL_STATIC_LIBRARY -template bool igl::cgal::complex_to_mesh, CGAL::Triangulation_data_structure_3, CGAL::Triangulation_vertex_base_3, CGAL::Triangulation_ds_vertex_base_3 > >, CGAL::Delaunay_triangulation_cell_base_with_circumcenter_3, CGAL::Surface_mesh_cell_base_3, CGAL::Triangulation_cell_base_3, CGAL::Triangulation_ds_cell_base_3 > > >, CGAL::Sequential_tag>, CGAL::Default, CGAL::Default>, Eigen::Matrix, Eigen::Matrix >(CGAL::Complex_2_in_triangulation_3, CGAL::Triangulation_data_structure_3, CGAL::Triangulation_vertex_base_3, CGAL::Triangulation_ds_vertex_base_3 > >, CGAL::Delaunay_triangulation_cell_base_with_circumcenter_3, CGAL::Surface_mesh_cell_base_3, CGAL::Triangulation_cell_base_3, CGAL::Triangulation_ds_cell_base_3 > > >, CGAL::Sequential_tag>, CGAL::Default, CGAL::Default>, void> const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template bool igl::copyleft::cgal::complex_to_mesh, CGAL::Triangulation_data_structure_3, CGAL::Triangulation_vertex_base_3, CGAL::Triangulation_ds_vertex_base_3 > >, CGAL::Delaunay_triangulation_cell_base_with_circumcenter_3, CGAL::Surface_mesh_cell_base_3, CGAL::Triangulation_cell_base_3, CGAL::Triangulation_ds_cell_base_3 > > >, CGAL::Sequential_tag>, CGAL::Default, CGAL::Default>, Eigen::Matrix, Eigen::Matrix >(CGAL::Complex_2_in_triangulation_3, CGAL::Triangulation_data_structure_3, CGAL::Triangulation_vertex_base_3, CGAL::Triangulation_ds_vertex_base_3 > >, CGAL::Delaunay_triangulation_cell_base_with_circumcenter_3, CGAL::Surface_mesh_cell_base_3, CGAL::Triangulation_cell_base_3, CGAL::Triangulation_ds_cell_base_3 > > >, CGAL::Sequential_tag>, CGAL::Default, CGAL::Default>, void> const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/copyleft/cgal/complex_to_mesh.h b/include/igl/copyleft/cgal/complex_to_mesh.h new file mode 100644 index 000000000..ed66064b7 --- /dev/null +++ b/include/igl/copyleft/cgal/complex_to_mesh.h @@ -0,0 +1,47 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2014 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_CGAL_COMPLEX_TO_MESH_H +#define IGL_COPYLEFT_CGAL_COMPLEX_TO_MESH_H +#include "../../igl_inline.h" + +#include +#include + +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // Templates: + // Tr CGAL triangulation type, e.g. + // CGAL::Surface_mesh_default_triangulation_3 + // Inputs + // c2t3 2-complex (surface) living in a 3d triangulation (e.g. result of + // CGAL::make_surface_mesh) + // Outputs: + // V #V by 3 list of vertex positions + // F #F by 3 list of triangle indices + // Returns true iff conversion was successful, failure can ok if CGAL code + // can't figure out ordering. + // + template + IGL_INLINE bool complex_to_mesh( + const CGAL::Complex_2_in_triangulation_3 & c2t3, + Eigen::PlainObjectBase & V, + Eigen::PlainObjectBase & F); + } + } +} + +#ifndef IGL_STATIC_LIBRARY +# include "complex_to_mesh.cpp" +#endif + +#endif + diff --git a/include/igl/cgal/component_inside_component.cpp b/include/igl/copyleft/cgal/component_inside_component.cpp similarity index 88% rename from include/igl/cgal/component_inside_component.cpp rename to include/igl/copyleft/cgal/component_inside_component.cpp index 8951691e5..f9cc38b04 100644 --- a/include/igl/cgal/component_inside_component.cpp +++ b/include/igl/copyleft/cgal/component_inside_component.cpp @@ -22,7 +22,7 @@ #include "points_inside_component.h" template -IGL_INLINE bool igl::cgal::component_inside_component( +IGL_INLINE bool igl::copyleft::cgal::component_inside_component( const Eigen::PlainObjectBase& V1, const Eigen::PlainObjectBase& F1, const Eigen::PlainObjectBase& I1, @@ -39,13 +39,13 @@ IGL_INLINE bool igl::cgal::component_inside_component( (V1(f[0],1) + V1(f[1],1) + V1(f[2],1))/3.0, (V1(f[0],2) + V1(f[1],2) + V1(f[2],2))/3.0); Eigen::VectorXi inside; - igl::cgal::points_inside_component(V2, F2, I2, query, inside); + igl::copyleft::cgal::points_inside_component(V2, F2, I2, query, inside); assert(inside.size() == 1); return inside[0]; } template -IGL_INLINE bool igl::cgal::component_inside_component( +IGL_INLINE bool igl::copyleft::cgal::component_inside_component( const Eigen::PlainObjectBase& V1, const Eigen::PlainObjectBase& F1, const Eigen::PlainObjectBase& V2, @@ -56,13 +56,13 @@ IGL_INLINE bool igl::cgal::component_inside_component( Eigen::VectorXi I1(F1.rows()), I2(F2.rows()); I1.setLinSpaced(F1.rows(), 0, F1.rows()-1); I2.setLinSpaced(F2.rows(), 0, F2.rows()-1); - return igl::cgal::component_inside_component(V1, F1, I1, V2, F2, I2); + return igl::copyleft::cgal::component_inside_component(V1, F1, I1, V2, F2, I2); } #ifdef IGL_STATIC_LIBRARY // Explicit template specialization -template bool igl::cgal::component_inside_component< +template bool igl::copyleft::cgal::component_inside_component< Eigen::Matrix, Eigen::Matrix< int, -1, -1, 0, -1, -1>, Eigen::Matrix< int, -1, -1, 0, -1, -1> > ( @@ -73,7 +73,7 @@ Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); -template bool igl::cgal::component_inside_component< +template bool igl::copyleft::cgal::component_inside_component< Eigen::Matrix, Eigen::Matrix< int, -1, -1, 0, -1, -1> > ( Eigen::PlainObjectBase > const&, diff --git a/include/igl/cgal/component_inside_component.h b/include/igl/copyleft/cgal/component_inside_component.h similarity index 94% rename from include/igl/cgal/component_inside_component.h rename to include/igl/copyleft/cgal/component_inside_component.h index 83d309604..17fdd6255 100644 --- a/include/igl/cgal/component_inside_component.h +++ b/include/igl/copyleft/cgal/component_inside_component.h @@ -5,14 +5,16 @@ // 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 COMONENT_INSIDE_COMPONENT -#define COMONENT_INSIDE_COMPONENT +#ifndef IGL_COPYLEFT_CGAL_COMONENT_INSIDE_COMPONENT +#define IGL_COPYLEFT_CGAL_COMONENT_INSIDE_COMPONENT -#include "../igl_inline.h" +#include "../../igl_inline.h" #include #include namespace igl { + namespace copyleft + { namespace cgal { // Determine if connected facet component (V1, F1, I1) is inside of @@ -64,6 +66,7 @@ namespace igl { const Eigen::PlainObjectBase& V2, const Eigen::PlainObjectBase& F2); } + } } #ifndef IGL_STATIC_LIBRARY diff --git a/include/igl/cgal/extract_cells.cpp b/include/igl/copyleft/cgal/extract_cells.cpp similarity index 87% rename from include/igl/cgal/extract_cells.cpp rename to include/igl/copyleft/cgal/extract_cells.cpp index 0b7caec77..588acaada 100644 --- a/include/igl/cgal/extract_cells.cpp +++ b/include/igl/copyleft/cgal/extract_cells.cpp @@ -7,10 +7,10 @@ // obtain one at http://mozilla.org/MPL/2.0/. // #include "extract_cells.h" -#include "../extract_manifold_patches.h" -#include "../facet_components.h" -#include "../triangle_triangle_adjacency.h" -#include "../unique_edge_map.h" +#include "../../extract_manifold_patches.h" +#include "../../facet_components.h" +#include "../../triangle_triangle_adjacency.h" +#include "../../unique_edge_map.h" #include "closest_facet.h" #include "order_facets_around_edge.h" #include "outer_facet.h" @@ -26,7 +26,7 @@ typename DeriveduE, typename uE2EType, typename DerivedEMAP, typename DerivedC > -IGL_INLINE size_t igl::cgal::extract_cells_single_component( +IGL_INLINE size_t igl::copyleft::cgal::extract_cells_single_component( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, const Eigen::PlainObjectBase& P, @@ -69,7 +69,7 @@ IGL_INLINE size_t igl::cgal::extract_cells_single_component( signed_adj_faces.push_back((fid+1)*(cons ? 1:-1)); } auto& order = orders[i]; - igl::cgal::order_facets_around_edge( + igl::copyleft::cgal::order_facets_around_edge( V, F, s, d, signed_adj_faces, order); auto& orientation = orientations[i]; orientation.resize(order.size()); @@ -162,7 +162,7 @@ template< typename uE2EType, typename DerivedEMAP, typename DerivedC > -IGL_INLINE size_t igl::cgal::extract_cells( +IGL_INLINE size_t igl::copyleft::cgal::extract_cells( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, const Eigen::PlainObjectBase& P, @@ -177,7 +177,7 @@ IGL_INLINE size_t igl::cgal::extract_cells( DerivedC raw_cells; const size_t num_raw_cells = - igl::cgal::extract_cells_single_component( + igl::copyleft::cgal::extract_cells_single_component( V, F, P, uE, uE2E, EMAP, raw_cells); std::vector > > TT,_1; @@ -203,7 +203,7 @@ IGL_INLINE size_t igl::cgal::extract_cells( Eigen::VectorXi outer_cells(num_components); for (size_t i=0; i -IGL_INLINE size_t igl::cgal::extract_cells( +IGL_INLINE size_t igl::copyleft::cgal::extract_cells( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, Eigen::PlainObjectBase& cells) { @@ -330,7 +330,7 @@ IGL_INLINE size_t igl::cgal::extract_cells( DerivedC per_patch_cells; const size_t num_cells = - igl::cgal::extract_cells(V, F, P, E, uE, uE2E, EMAP, per_patch_cells); + igl::copyleft::cgal::extract_cells(V, F, P, E, uE, uE2E, EMAP, per_patch_cells); cells.resize(num_faces, 2); for (size_t i=0; i -template unsigned long igl::cgal::extract_cells, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, unsigned long, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector >, std::__1::allocator > > > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); +template unsigned long igl::copyleft::cgal::extract_cells, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, unsigned long, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector >, std::__1::allocator > > > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/cgal/extract_cells.h b/include/igl/copyleft/cgal/extract_cells.h similarity index 96% rename from include/igl/cgal/extract_cells.h rename to include/igl/copyleft/cgal/extract_cells.h index 39e33444e..3abf660ac 100644 --- a/include/igl/cgal/extract_cells.h +++ b/include/igl/copyleft/cgal/extract_cells.h @@ -6,14 +6,16 @@ // 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_CGAL_EXTRACT_CELLS -#define IGL_CGAL_EXTRACT_CELLS +#ifndef IGL_COPYLEFT_CGAL_EXTRACT_CELLS +#define IGL_COPYLEFT_CGAL_EXTRACT_CELLS -#include "../igl_inline.h" +#include "../../igl_inline.h" #include #include namespace igl { + namespace copyleft + { namespace cgal { // Extract connected 3D space partitioned by mesh (V, F). // @@ -103,6 +105,7 @@ namespace igl { Eigen::PlainObjectBase& cells); } + } } #ifndef IGL_STATIC_LIBRARY diff --git a/include/igl/copyleft/cgal/intersect_other.cpp b/include/igl/copyleft/cgal/intersect_other.cpp new file mode 100644 index 000000000..c522d98bf --- /dev/null +++ b/include/igl/copyleft/cgal/intersect_other.cpp @@ -0,0 +1,273 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2014 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#include "intersect_other.h" +#include "CGAL_includes.hpp" +#include "mesh_to_cgal_triangle_list.h" +#include "remesh_intersections.h" + +#ifndef IGL_FIRST_HIT_EXCEPTION +#define IGL_FIRST_HIT_EXCEPTION 10 +#endif + +// Un-exposed helper functions +namespace igl +{ + namespace copyleft + { + namespace cgal + { + template + static IGL_INLINE void push_result( + const Eigen::PlainObjectBase & F, + const int f, + const CGAL::Object & result, + std::map< + typename DerivedF::Index, + std::pair > > & offending, + std::map< + std::pair, + std::vector > & edge2faces) + { + typedef typename DerivedF::Index Index; + typedef std::pair EMK; + if(offending.count(f) == 0) + { + // first time marking, initialize with new id and empty list + Index id = offending.size(); + offending[f] = {id,{}}; + for(Index e = 0; e<3;e++) + { + // append face to edge's list + Index i = F(f,(e+1)%3) < F(f,(e+2)%3) ? F(f,(e+1)%3) : F(f,(e+2)%3); + Index j = F(f,(e+1)%3) < F(f,(e+2)%3) ? F(f,(e+2)%3) : F(f,(e+1)%3); + edge2faces[EMK(i,j)].push_back(f); + } + } + offending[f].second.push_back(result); + } + template < + typename Kernel, + typename DerivedVA, + typename DerivedFA, + typename DerivedVB, + typename DerivedFB, + typename DerivedIF, + typename DerivedVVA, + typename DerivedFFA, + typename DerivedJA, + typename DerivedIMA, + typename DerivedVVB, + typename DerivedFFB, + typename DerivedJB, + typename DerivedIMB> + static IGL_INLINE bool intersect_other_helper( + const Eigen::PlainObjectBase & VA, + const Eigen::PlainObjectBase & FA, + const Eigen::PlainObjectBase & VB, + const Eigen::PlainObjectBase & FB, + const RemeshSelfIntersectionsParam & params, + Eigen::PlainObjectBase & IF, + Eigen::PlainObjectBase & VVA, + Eigen::PlainObjectBase & FFA, + Eigen::PlainObjectBase & JA, + Eigen::PlainObjectBase & IMA, + Eigen::PlainObjectBase & VVB, + Eigen::PlainObjectBase & FFB, + Eigen::PlainObjectBase & JB, + Eigen::PlainObjectBase & IMB) + { + + using namespace std; + using namespace Eigen; + + typedef typename DerivedFA::Index Index; + // 3D Primitives + typedef CGAL::Point_3 Point_3; + typedef CGAL::Segment_3 Segment_3; + typedef CGAL::Triangle_3 Triangle_3; + typedef CGAL::Plane_3 Plane_3; + typedef CGAL::Tetrahedron_3 Tetrahedron_3; + // 2D Primitives + typedef CGAL::Point_2 Point_2; + typedef CGAL::Segment_2 Segment_2; + typedef CGAL::Triangle_2 Triangle_2; + // 2D Constrained Delaunay Triangulation types + typedef CGAL::Triangulation_vertex_base_2 TVB_2; + typedef CGAL::Constrained_triangulation_face_base_2 CTAB_2; + typedef CGAL::Triangulation_data_structure_2 TDS_2; + typedef CGAL::Exact_intersections_tag Itag; + typedef CGAL::Constrained_Delaunay_triangulation_2 + CDT_2; + typedef CGAL::Constrained_triangulation_plus_2 CDT_plus_2; + // Axis-align boxes for all-pairs self-intersection detection + typedef std::vector Triangles; + typedef typename Triangles::iterator TrianglesIterator; + typedef typename Triangles::const_iterator TrianglesConstIterator; + typedef + CGAL::Box_intersection_d::Box_with_handle_d + Box; + typedef + std::map > > + OffendingMap; + typedef std::map,std::vector > EdgeMap; + typedef std::pair EMK; + + Triangles TA,TB; + // Compute and process self intersections + mesh_to_cgal_triangle_list(VA,FA,TA); + mesh_to_cgal_triangle_list(VB,FB,TB); + // http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Box_intersection_d/Chapter_main.html#Section_63.5 + // Create the corresponding vector of bounding boxes + std::vector A_boxes,B_boxes; + const auto box_up = [](Triangles & T, std::vector & boxes) + { + boxes.reserve(T.size()); + for ( + TrianglesIterator tit = T.begin(); + tit != T.end(); + ++tit) + { + boxes.push_back(Box(tit->bbox(), tit)); + } + }; + box_up(TA,A_boxes); + box_up(TB,B_boxes); + OffendingMap offendingA,offendingB; + EdgeMap edge2facesA,edge2facesB; + + std::list lIF; + const auto cb = [&](const Box &a, const Box &b) + { + using namespace std; + // index in F and T + int fa = a.handle()-TA.begin(); + int fb = b.handle()-TB.begin(); + const Triangle_3 & A = *a.handle(); + const Triangle_3 & B = *b.handle(); + if(CGAL::do_intersect(A,B)) + { + // There was an intersection + lIF.push_back(fa); + lIF.push_back(fb); + if(params.first_only) + { + throw IGL_FIRST_HIT_EXCEPTION; + } + if(!params.detect_only) + { + CGAL::Object result = CGAL::intersection(A,B); + + push_result(FA,fa,result,offendingA,edge2facesA); + push_result(FB,fb,result,offendingB,edge2facesB); + } + } + }; + try{ + CGAL::box_intersection_d( + A_boxes.begin(), A_boxes.end(), + B_boxes.begin(), B_boxes.end(), + cb); + }catch(int e) + { + // Rethrow if not FIRST_HIT_EXCEPTION + if(e != IGL_FIRST_HIT_EXCEPTION) + { + throw e; + } + // Otherwise just fall through + } + + // Convert lIF to Eigen matrix + assert(lIF.size()%2 == 0); + IF.resize(lIF.size()/2,2); + { + int i=0; + for( + list::const_iterator ifit = lIF.begin(); + ifit!=lIF.end(); + ) + { + IF(i,0) = (*ifit); + ifit++; + IF(i,1) = (*ifit); + ifit++; + i++; + } + } + if(!params.detect_only) + { + remesh_intersections(VA,FA,TA,offendingA,edge2facesA,VVA,FFA,JA,IMA); + remesh_intersections(VB,FB,TB,offendingB,edge2facesB,VVB,FFB,JB,IMB); + } + + return IF.rows() > 0; + } + } + } +} + +template < + typename DerivedVA, + typename DerivedFA, + typename DerivedVB, + typename DerivedFB, + typename DerivedIF, + typename DerivedVVA, + typename DerivedFFA, + typename DerivedJA, + typename DerivedIMA, + typename DerivedVVB, + typename DerivedFFB, + typename DerivedJB, + typename DerivedIMB> +IGL_INLINE bool igl::copyleft::cgal::intersect_other( + const Eigen::PlainObjectBase & VA, + const Eigen::PlainObjectBase & FA, + const Eigen::PlainObjectBase & VB, + const Eigen::PlainObjectBase & FB, + const RemeshSelfIntersectionsParam & params, + Eigen::PlainObjectBase & IF, + Eigen::PlainObjectBase & VVA, + Eigen::PlainObjectBase & FFA, + Eigen::PlainObjectBase & JA, + Eigen::PlainObjectBase & IMA, + Eigen::PlainObjectBase & VVB, + Eigen::PlainObjectBase & FFB, + Eigen::PlainObjectBase & JB, + Eigen::PlainObjectBase & IMB) +{ + if(params.detect_only) + { + return intersect_other_helper + (VA,FA,VB,FB,params,IF,VVA,FFA,JA,IMA,VVB,FFB,JB,IMB); + }else + { + return intersect_other_helper + (VA,FA,VB,FB,params,IF,VVA,FFA,JA,IMA,VVB,FFB,JB,IMB); + } +} + +IGL_INLINE bool igl::copyleft::cgal::intersect_other( + const Eigen::MatrixXd & VA, + const Eigen::MatrixXi & FA, + const Eigen::MatrixXd & VB, + const Eigen::MatrixXi & FB, + const bool first_only, + Eigen::MatrixXi & IF) +{ + Eigen::MatrixXd VVA,VVB; + Eigen::MatrixXi FFA,FFB; + Eigen::VectorXi JA,JB,IMA,IMB; + return intersect_other( + VA,FA,VB,FB,{true,first_only},IF,VVA,FFA,JA,IMA,VVB,FFB,JB,IMB); +} + +#ifdef IGL_STATIC_LIBRARY +// Explicit template specialization +#endif diff --git a/include/igl/copyleft/cgal/intersect_other.h b/include/igl/copyleft/cgal/intersect_other.h new file mode 100644 index 000000000..87112cf82 --- /dev/null +++ b/include/igl/copyleft/cgal/intersect_other.h @@ -0,0 +1,109 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_CGAL_INTERSECT_OTHER_H +#define IGL_COPYLEFT_CGAL_INTERSECT_OTHER_H +#include "../../igl_inline.h" +#include "RemeshSelfIntersectionsParam.h" + +#include + +#ifdef MEX +# include +# include +# undef assert +# define assert( isOK ) ( (isOK) ? (void)0 : (void) mexErrMsgTxt(C_STR(__FILE__<<":"<<__LINE__<<": failed assertion `"<<#isOK<<"'"< + IGL_INLINE bool intersect_other( + const Eigen::PlainObjectBase & VA, + const Eigen::PlainObjectBase & FA, + const Eigen::PlainObjectBase & VB, + const Eigen::PlainObjectBase & FB, + const RemeshSelfIntersectionsParam & params, + Eigen::PlainObjectBase & IF, + Eigen::PlainObjectBase & VVA, + Eigen::PlainObjectBase & FFA, + Eigen::PlainObjectBase & JA, + Eigen::PlainObjectBase & IMA, + Eigen::PlainObjectBase & VVB, + Eigen::PlainObjectBase & FFB, + Eigen::PlainObjectBase & JB, + Eigen::PlainObjectBase & IMB); + // Legacy wrapper for detect only using common types. + // + // Inputs: + // VA #V by 3 list of vertex positions + // FA #F by 3 list of triangle indices into VA + // VB #V by 3 list of vertex positions + // FB #F by 3 list of triangle indices into VB + // first_only whether to only detect the first intersection. + // Outputs: + // IF #intersecting face pairs by 2 list of intersecting face pairs, + // indexing FA and FB + // Returns true if any intersections were found + // + // See also: remesh_self_intersections + IGL_INLINE bool intersect_other( + const Eigen::MatrixXd & VA, + const Eigen::MatrixXi & FA, + const Eigen::MatrixXd & VB, + const Eigen::MatrixXi & FB, + const bool first_only, + Eigen::MatrixXi & IF); + } + } +} + +#ifndef IGL_STATIC_LIBRARY +# include "intersect_other.cpp" +#endif + +#endif + diff --git a/include/igl/copyleft/cgal/mesh_to_cgal_triangle_list.cpp b/include/igl/copyleft/cgal/mesh_to_cgal_triangle_list.cpp new file mode 100644 index 000000000..031732643 --- /dev/null +++ b/include/igl/copyleft/cgal/mesh_to_cgal_triangle_list.cpp @@ -0,0 +1,65 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2014 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#include "mesh_to_cgal_triangle_list.h" +#include "assign_scalar.h" + +#include + +template < + typename DerivedV, + typename DerivedF, + typename Kernel> +IGL_INLINE void igl::copyleft::cgal::mesh_to_cgal_triangle_list( + const Eigen::PlainObjectBase & V, + const Eigen::PlainObjectBase & F, + std::vector > & T) +{ + typedef CGAL::Point_3 Point_3; + typedef CGAL::Triangle_3 Triangle_3; + // Must be 3D + assert(V.cols() == 3); + // **Copy** to convert to output type (this is especially/only needed if the + // input type DerivedV::Scalar is CGAL::Epeck + Eigen::Matrix< + typename Kernel::FT, + DerivedV::RowsAtCompileTime, + DerivedV::ColsAtCompileTime> + KV(V.rows(),V.cols()); + // Just use f'ing for loops. What if V and KV don't use same ordering? + for(int i = 0;i, Eigen::Matrix, CGAL::Epeck>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector, std::allocator > >&); +template void igl::copyleft::cgal::mesh_to_cgal_triangle_list, Eigen::Matrix, CGAL::Epick>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector, std::allocator > >&); +template void igl::copyleft::cgal::mesh_to_cgal_triangle_list, Eigen::Matrix, CGAL::Epeck>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector, std::allocator > >&); +template void igl::copyleft::cgal::mesh_to_cgal_triangle_list, Eigen::Matrix, CGAL::Epick>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector, std::allocator > >&); +template void igl::copyleft::cgal::mesh_to_cgal_triangle_list, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epeck>(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::vector, std::allocator > >&); +template void igl::copyleft::cgal::mesh_to_cgal_triangle_list, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epick>(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::vector, std::allocator > >&); +template void igl::copyleft::cgal::mesh_to_cgal_triangle_list, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epick>(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > >&); +template void igl::copyleft::cgal::mesh_to_cgal_triangle_list, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epeck>(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > >&); +#endif diff --git a/include/igl/copyleft/cgal/mesh_to_cgal_triangle_list.h b/include/igl/copyleft/cgal/mesh_to_cgal_triangle_list.h new file mode 100644 index 000000000..6efa82342 --- /dev/null +++ b/include/igl/copyleft/cgal/mesh_to_cgal_triangle_list.h @@ -0,0 +1,44 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2014 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_CGAL_MESH_TO_CGAL_TRIANGLE_LIST_H +#define IGL_COPYLEFT_CGAL_MESH_TO_CGAL_TRIANGLE_LIST_H +#include "../../igl_inline.h" +#include +#include "CGAL_includes.hpp" +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // Convert a mesh (V,F) to a list of CGAL triangles + // + // Templates: + // Kernal CGAL computation and construction kernel (e.g. + // CGAL::Exact_predicates_exact_constructions_kernel) + // Inputs: + // V #V by 3 list of vertex positions + // F #F by 3 list of triangle indices + // Outputs: + // T #F list of CGAL triangles + template < + typename DerivedV, + typename DerivedF, + typename Kernel> + IGL_INLINE void mesh_to_cgal_triangle_list( + const Eigen::PlainObjectBase & V, + const Eigen::PlainObjectBase & F, + std::vector > & T); + } + } +} +#ifndef IGL_STATIC_LIBRARY +# include "mesh_to_cgal_triangle_list.cpp" +#endif + +#endif diff --git a/include/igl/cgal/mesh_to_polyhedron.cpp b/include/igl/copyleft/cgal/mesh_to_polyhedron.cpp similarity index 75% rename from include/igl/cgal/mesh_to_polyhedron.cpp rename to include/igl/copyleft/cgal/mesh_to_polyhedron.cpp index 9e304400b..b562a534d 100644 --- a/include/igl/cgal/mesh_to_polyhedron.cpp +++ b/include/igl/copyleft/cgal/mesh_to_polyhedron.cpp @@ -11,7 +11,7 @@ template -IGL_INLINE bool igl::cgal::mesh_to_polyhedron( +IGL_INLINE bool igl::copyleft::cgal::mesh_to_polyhedron( const Eigen::MatrixXd & V, const Eigen::MatrixXi & F, Polyhedron & poly) @@ -50,5 +50,5 @@ IGL_INLINE bool igl::cgal::mesh_to_polyhedron( // Explicit template specialization #include #include -template bool igl::cgal::mesh_to_polyhedron, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator > >(Eigen::Matrix const&, Eigen::Matrix const&, CGAL::Polyhedron_3, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator >&); +template bool igl::copyleft::cgal::mesh_to_polyhedron, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator > >(Eigen::Matrix const&, Eigen::Matrix const&, CGAL::Polyhedron_3, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator >&); #endif diff --git a/include/igl/copyleft/cgal/mesh_to_polyhedron.h b/include/igl/copyleft/cgal/mesh_to_polyhedron.h new file mode 100644 index 000000000..de17d8aa2 --- /dev/null +++ b/include/igl/copyleft/cgal/mesh_to_polyhedron.h @@ -0,0 +1,42 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_CGAL_MESH_TO_POLYHEDRON_H +#define IGL_COPYLEFT_CGAL_MESH_TO_POLYHEDRON_H +#include "../../igl_inline.h" +#include + +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // Convert a mesh (V,F) to a CGAL Polyhedron + // + // Templates: + // Polyhedron CGAL Polyhedron type (e.g. Polyhedron_3) + // Inputs: + // V #V by 3 list of vertex positions + // F #F by 3 list of triangle indices + // Outputs: + // poly cgal polyhedron + // Returns true only if (V,F) can be converted to a valid polyhedron (i.e. if + // (V,F) is vertex and edge manifold). + template + IGL_INLINE bool mesh_to_polyhedron( + const Eigen::MatrixXd & V, + const Eigen::MatrixXi & F, + Polyhedron & poly); + } + } +} +#ifndef IGL_STATIC_LIBRARY +# include "mesh_to_polyhedron.cpp" +#endif + +#endif diff --git a/include/igl/cgal/order_facets_around_edge.cpp b/include/igl/copyleft/cgal/order_facets_around_edge.cpp similarity index 80% rename from include/igl/cgal/order_facets_around_edge.cpp rename to include/igl/copyleft/cgal/order_facets_around_edge.cpp index 04513c68b..f1345973c 100644 --- a/include/igl/cgal/order_facets_around_edge.cpp +++ b/include/igl/copyleft/cgal/order_facets_around_edge.cpp @@ -5,6 +5,8 @@ namespace igl { + namespace copyleft + { namespace cgal { namespace order_facets_around_edges_helper @@ -27,6 +29,7 @@ namespace igl } } } + } } // adj_faces contains signed index starting from +- 1. @@ -34,7 +37,7 @@ template< typename DerivedV, typename DerivedF, typename DerivedI > -void igl::cgal::order_facets_around_edge( +void igl::copyleft::cgal::order_facets_around_edge( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, size_t s, @@ -42,7 +45,7 @@ void igl::cgal::order_facets_around_edge( const std::vector& adj_faces, Eigen::PlainObjectBase& order, bool debug) { - using namespace igl::cgal::order_facets_around_edges_helper; + using namespace igl::copyleft::cgal::order_facets_around_edges_helper; // Although we only need exact predicates in the algorithm, // exact constructions are needed to avoid degeneracies due to @@ -297,7 +300,7 @@ template< typename DerivedF, typename DerivedI> IGL_INLINE -void igl::cgal::order_facets_around_edge( +void igl::copyleft::cgal::order_facets_around_edge( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, size_t s, @@ -390,7 +393,7 @@ void igl::cgal::order_facets_around_edge( } DerivedI order_with_pivot; - igl::cgal::order_facets_around_edge( + order_facets_around_edge( vertices, faces, N+1, N+2, adj_faces_with_pivot, order_with_pivot); @@ -416,11 +419,10 @@ void igl::cgal::order_facets_around_edge( #ifdef IGL_STATIC_LIBRARY // Explicit template specialization -template void -igl::cgal::order_facets_around_edge, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, unsigned long, unsigned long, std::vector > const&, Eigen::PlainObjectBase >&, bool); -template void igl::cgal::order_facets_around_edge, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, unsigned long, unsigned long, std::vector > const&, Eigen::PlainObjectBase >&, bool); -template void igl::cgal::order_facets_around_edge, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, unsigned long, unsigned long, std::vector > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase >&); -template void igl::cgal::order_facets_around_edge, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, unsigned long, unsigned long, std::vector > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); -template void igl::cgal::order_facets_around_edge, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, unsigned long, unsigned long, std::vector > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); -template void igl::cgal::order_facets_around_edge, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, unsigned long, unsigned long, std::__1::vector > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::order_facets_around_edge, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, unsigned long, unsigned long, std::vector > const&, Eigen::PlainObjectBase >&, bool); +template void igl::copyleft::cgal::order_facets_around_edge, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, unsigned long, unsigned long, std::vector > const&, Eigen::PlainObjectBase >&, bool); +template void igl::copyleft::cgal::order_facets_around_edge, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, unsigned long, unsigned long, std::vector > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::order_facets_around_edge, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, unsigned long, unsigned long, std::vector > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::order_facets_around_edge, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, unsigned long, unsigned long, std::vector > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::order_facets_around_edge, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, unsigned long, unsigned long, std::__1::vector > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/cgal/order_facets_around_edge.h b/include/igl/copyleft/cgal/order_facets_around_edge.h similarity index 94% rename from include/igl/cgal/order_facets_around_edge.h rename to include/igl/copyleft/cgal/order_facets_around_edge.h index 1623bbeb4..222e2e10d 100644 --- a/include/igl/cgal/order_facets_around_edge.h +++ b/include/igl/copyleft/cgal/order_facets_around_edge.h @@ -6,13 +6,15 @@ // 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 ORDER_FACETS_AROUND_EDGE_H -#define ORDER_FACETS_AROUND_EDGE_H -#include "../igl_inline.h" +#ifndef IGL_COPYLEFT_CGAL_ORDER_FACETS_AROUND_EDGE_H +#define IGL_COPYLEFT_CGAL_ORDER_FACETS_AROUND_EDGE_H +#include "../../igl_inline.h" #include #include namespace igl { + namespace copyleft + { namespace cgal { // Given a directed edge, sort its adjacent faces. Assuming the // directed edge is (s, d). Sort the adjacent faces clockwise around the @@ -63,6 +65,7 @@ namespace igl { const Eigen::PlainObjectBase& pivot_point, Eigen::PlainObjectBase& order); } + } } #ifndef IGL_STATIC_LIBRARY diff --git a/include/igl/cgal/order_facets_around_edges.cpp b/include/igl/copyleft/cgal/order_facets_around_edges.cpp similarity index 83% rename from include/igl/cgal/order_facets_around_edges.cpp rename to include/igl/copyleft/cgal/order_facets_around_edges.cpp index 61044ddb3..f823633d3 100644 --- a/include/igl/cgal/order_facets_around_edges.cpp +++ b/include/igl/copyleft/cgal/order_facets_around_edges.cpp @@ -7,7 +7,7 @@ // obtain one at http://mozilla.org/MPL/2.0/. #include "order_facets_around_edges.h" #include "order_facets_around_edge.h" -#include "../sort_angles.h" +#include "../../sort_angles.h" #include #include @@ -22,7 +22,7 @@ template< IGL_INLINE typename std::enable_if::value, void>::type -igl::cgal::order_facets_around_edges( +igl::copyleft::cgal::order_facets_around_edges( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, const Eigen::PlainObjectBase& N, @@ -162,7 +162,7 @@ template< IGL_INLINE typename std::enable_if::value, void>::type -igl::cgal::order_facets_around_edges( +igl::copyleft::cgal::order_facets_around_edges( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, const Eigen::PlainObjectBase& N, @@ -253,7 +253,7 @@ template< typename uE2EType, typename uE2oEType, typename uE2CType > -IGL_INLINE void igl::cgal::order_facets_around_edges( +IGL_INLINE void igl::copyleft::cgal::order_facets_around_edges( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, const Eigen::PlainObjectBase& uE, @@ -320,7 +320,7 @@ IGL_INLINE void igl::cgal::order_facets_around_edges( #ifdef IGL_STATIC_LIBRARY // Explicit template specialization -template void igl::cgal::order_facets_around_edges, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, long, long, bool>(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector >, std::allocator > > > const&, std::vector >, std::allocator > > >&, std::vector >, std::allocator > > >&); -template void igl::cgal::order_facets_around_edges, Eigen::Matrix, Eigen::Matrix, long, long, bool>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector >, std::allocator > > > const&, std::vector >, std::allocator > > >&, std::vector >, std::allocator > > >&); -template void igl::cgal::order_facets_around_edges, Eigen::Matrix, Eigen::Matrix, long, long, bool>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector >, std::allocator > > > const&, std::vector >, std::allocator > > >&, std::vector >, std::allocator > > >&); +template void igl::copyleft::cgal::order_facets_around_edges, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, long, long, bool>(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector >, std::allocator > > > const&, std::vector >, std::allocator > > >&, std::vector >, std::allocator > > >&); +template void igl::copyleft::cgal::order_facets_around_edges, Eigen::Matrix, Eigen::Matrix, long, long, bool>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector >, std::allocator > > > const&, std::vector >, std::allocator > > >&, std::vector >, std::allocator > > >&); +template void igl::copyleft::cgal::order_facets_around_edges, Eigen::Matrix, Eigen::Matrix, long, long, bool>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::vector >, std::allocator > > > const&, std::vector >, std::allocator > > >&, std::vector >, std::allocator > > >&); #endif diff --git a/include/igl/copyleft/cgal/order_facets_around_edges.h b/include/igl/copyleft/cgal/order_facets_around_edges.h new file mode 100644 index 000000000..fd918482f --- /dev/null +++ b/include/igl/copyleft/cgal/order_facets_around_edges.h @@ -0,0 +1,107 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_CGAL_ORDER_FACETS_AROUND_EDGES_H +#define IGL_COPYLEFT_CGAL_ORDER_FACETS_AROUND_EDGES_H +#include "../../igl_inline.h" +#include +#include +#include + +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // For each undirected edge, sort its adjacent faces. Assuming the + // undirected edge is (s, d). Sort the adjacent faces clockwise around the + // axis (d - s), i.e. left-hand rule. An adjacent face is consistently + // oriented if it contains (d, s) as a directed edge. + // + // For overlapping faces, break the tie using signed face index, smaller + // signed index comes before the larger signed index. Signed index is + // computed as (consistent? 1:-1) * index. + // + // Inputs: + // V #V by 3 list of vertices. + // F #F by 3 list of faces + // N #F by 3 list of face normals. + // uE #uE by 2 list of vertex_indices, represents undirected edges. + // uE2E #uE list of lists that maps uE to E. (a one-to-many map) + // + // Outputs: + // uE2oE #uE list of lists that maps uE to an ordered list of E. (a + // one-to-many map) + // uE2C #uE list of lists of bools indicates whether each face in + // uE2oE[i] is consistently orientated as the ordering. + // + template< + typename DerivedV, + typename DerivedF, + typename DerivedN, + typename DeriveduE, + typename uE2EType, + typename uE2oEType, + typename uE2CType > + IGL_INLINE + typename std::enable_if::value, void>::type + order_facets_around_edges( + const Eigen::PlainObjectBase& V, + const Eigen::PlainObjectBase& F, + const Eigen::PlainObjectBase& N, + const Eigen::PlainObjectBase& uE, + const std::vector >& uE2E, + std::vector >& uE2oE, + std::vector >& uE2C ); + + template< + typename DerivedV, + typename DerivedF, + typename DerivedN, + typename DeriveduE, + typename uE2EType, + typename uE2oEType, + typename uE2CType > + IGL_INLINE + typename std::enable_if::value, void>::type + order_facets_around_edges( + const Eigen::PlainObjectBase& V, + const Eigen::PlainObjectBase& F, + const Eigen::PlainObjectBase& N, + const Eigen::PlainObjectBase& uE, + const std::vector >& uE2E, + std::vector >& uE2oE, + std::vector >& uE2C ); + + // Order faces around each edge. Only exact predicate is used in the algorithm. + // Normal is not needed. + template< + typename DerivedV, + typename DerivedF, + typename DeriveduE, + typename uE2EType, + typename uE2oEType, + typename uE2CType > + IGL_INLINE void order_facets_around_edges( + const Eigen::PlainObjectBase& V, + const Eigen::PlainObjectBase& F, + const Eigen::PlainObjectBase& uE, + const std::vector >& uE2E, + std::vector >& uE2oE, + std::vector >& uE2C ); + } + } +} + +#ifndef IGL_STATIC_LIBRARY +#include "order_facets_around_edges.cpp" +#endif + +#endif diff --git a/include/igl/cgal/outer_element.cpp b/include/igl/copyleft/cgal/outer_element.cpp similarity index 74% rename from include/igl/cgal/outer_element.cpp rename to include/igl/copyleft/cgal/outer_element.cpp index f06df0156..d24695395 100644 --- a/include/igl/cgal/outer_element.cpp +++ b/include/igl/copyleft/cgal/outer_element.cpp @@ -16,7 +16,7 @@ template < typename IndexType, typename DerivedA > -IGL_INLINE void igl::cgal::outer_vertex( +IGL_INLINE void igl::copyleft::cgal::outer_vertex( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & F, const Eigen::PlainObjectBase & I, @@ -85,7 +85,7 @@ template< typename IndexType, typename DerivedA > -IGL_INLINE void igl::cgal::outer_edge( +IGL_INLINE void igl::copyleft::cgal::outer_edge( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & F, const Eigen::PlainObjectBase & I, @@ -211,7 +211,7 @@ template< typename DerivedI, typename IndexType > -IGL_INLINE void igl::cgal::outer_facet( +IGL_INLINE void igl::copyleft::cgal::outer_facet( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & F, const Eigen::PlainObjectBase & N, @@ -274,10 +274,10 @@ IGL_INLINE void igl::cgal::outer_facet( #ifdef IGL_STATIC_LIBRARY // Explicit template specialization #include -template void igl::cgal::outer_facet, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, int>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int&, bool&); -template void igl::cgal::outer_facet, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, unsigned long>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, unsigned long&, bool&); -template void igl::cgal::outer_facet, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, int>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int&, bool&); -template void igl::cgal::outer_facet, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, int>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int&, bool&); -template void igl::cgal::outer_edge, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, long, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, long&, long&, Eigen::PlainObjectBase >&); -template void igl::cgal::outer_edge, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, long, Eigen::Matrix >(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, long&, long&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::outer_facet, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, int>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int&, bool&); +template void igl::copyleft::cgal::outer_facet, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, unsigned long>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, unsigned long&, bool&); +template void igl::copyleft::cgal::outer_facet, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, int>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int&, bool&); +template void igl::copyleft::cgal::outer_facet, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, int>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int&, bool&); +template void igl::copyleft::cgal::outer_edge, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, long, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, long&, long&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::outer_edge, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, long, Eigen::Matrix >(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, long&, long&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/copyleft/cgal/outer_element.h b/include/igl/copyleft/cgal/outer_element.h new file mode 100644 index 000000000..5a256be40 --- /dev/null +++ b/include/igl/copyleft/cgal/outer_element.h @@ -0,0 +1,115 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 Qingan Zhou +// +// 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_COPYLEFT_CGAL_OUTER_ELEMENT_H +#define IGL_COPYLEFT_CGAL_OUTER_ELEMENT_H +#include "../../igl_inline.h" +#include +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // Find a vertex that is reachable from infinite without crossing any faces. + // Such vertex is called "outer vertex." + // + // Precondition: The input mesh must have all self-intersection resolved and + // no duplicated vertices. See cgal::remesh_self_intersections.h for how to + // obtain such input. + // + // Inputs: + // V #V by 3 list of vertex positions + // F #F by 3 list of triangle indices into V + // I #I list of facets to consider + // Outputs: + // v_index index of outer vertex + // A #A list of facets incident to the outer vertex + template < + typename DerivedV, + typename DerivedF, + typename DerivedI, + typename IndexType, + typename DerivedA + > + IGL_INLINE void outer_vertex( + const Eigen::PlainObjectBase & V, + const Eigen::PlainObjectBase & F, + const Eigen::PlainObjectBase & I, + IndexType & v_index, + Eigen::PlainObjectBase & A); + // Find an edge that is reachable from infinity without crossing any faces. + // Such edge is called "outer edge." + // + // Precondition: The input mesh must have all self-intersection resolved + // and no duplicated vertices. The correctness of the output depends on + // the fact that there is no edge overlap. See + // cgal::remesh_self_intersections.h for how to obtain such input. + // + // Inputs: + // V #V by 3 list of vertex positions + // F #F by 3 list of triangle indices into V + // I #I list of facets to consider + // Outputs: + // v1 index of the first end point of outer edge + // v2 index of the second end point of outer edge + // A #A list of facets incident to the outer edge + template< + typename DerivedV, + typename DerivedF, + typename DerivedI, + typename IndexType, + typename DerivedA + > + IGL_INLINE void outer_edge( + const Eigen::PlainObjectBase & V, + const Eigen::PlainObjectBase & F, + const Eigen::PlainObjectBase & I, + IndexType & v1, + IndexType & v2, + Eigen::PlainObjectBase & A); + + + // Find a facet that is reachable from infinity without crossing any faces. + // Such facet is called "outer facet." + // + // Precondition: The input mesh must have all self-intersection resolved. + // I.e there is no duplicated vertices, no overlapping edge and no + // intersecting faces (the only exception is there could be topologically + // duplicated faces). See cgal::remesh_self_intersections.h for how to + // obtain such input. + // + // Inputs: + // V #V by 3 list of vertex positions + // F #F by 3 list of triangle indices into V + // N #N by 3 list of face normals + // I #I list of facets to consider + // Outputs: + // f Index of the outer facet. + // flipped true iff the normal of f points inwards. + template< + typename DerivedV, + typename DerivedF, + typename DerivedN, + typename DerivedI, + typename IndexType + > + IGL_INLINE void outer_facet( + const Eigen::PlainObjectBase & V, + const Eigen::PlainObjectBase & F, + const Eigen::PlainObjectBase & N, + const Eigen::PlainObjectBase & I, + IndexType & f, + bool & flipped); + } + } +} + +#ifndef IGL_STATIC_LIBRARY +# include "outer_element.cpp" +#endif +#endif diff --git a/include/igl/cgal/outer_facet.cpp b/include/igl/copyleft/cgal/outer_facet.cpp similarity index 60% rename from include/igl/cgal/outer_facet.cpp rename to include/igl/copyleft/cgal/outer_facet.cpp index 9b17e2bfc..f47e8a26f 100644 --- a/include/igl/cgal/outer_facet.cpp +++ b/include/igl/copyleft/cgal/outer_facet.cpp @@ -18,7 +18,7 @@ template< typename DerivedI, typename IndexType > -IGL_INLINE void igl::cgal::outer_facet( +IGL_INLINE void igl::copyleft::cgal::outer_facet( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & F, const Eigen::PlainObjectBase & I, @@ -83,9 +83,9 @@ IGL_INLINE void igl::cgal::outer_facet( // Explicit template specialization #include #include -template void igl::cgal::outer_facet, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, int>(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int&, bool&); -template void igl::cgal::outer_facet, Eigen::Matrix, Eigen::Matrix, int>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int&, bool&); -template void igl::cgal::outer_facet, Eigen::Matrix, Eigen::Matrix, int>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int&, bool&); -template void igl::cgal::outer_facet, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, unsigned long>(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, unsigned long&, bool&); -template void igl::cgal::outer_facet, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, int>(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int&, bool&); +template void igl::copyleft::cgal::outer_facet, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, int>(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int&, bool&); +template void igl::copyleft::cgal::outer_facet, Eigen::Matrix, Eigen::Matrix, int>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int&, bool&); +template void igl::copyleft::cgal::outer_facet, Eigen::Matrix, Eigen::Matrix, int>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int&, bool&); +template void igl::copyleft::cgal::outer_facet, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, unsigned long>(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, unsigned long&, bool&); +template void igl::copyleft::cgal::outer_facet, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, int>(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int&, bool&); #endif diff --git a/include/igl/cgal/outer_facet.h b/include/igl/copyleft/cgal/outer_facet.h similarity index 93% rename from include/igl/cgal/outer_facet.h rename to include/igl/copyleft/cgal/outer_facet.h index 54fa47780..f50230486 100644 --- a/include/igl/cgal/outer_facet.h +++ b/include/igl/copyleft/cgal/outer_facet.h @@ -6,13 +6,15 @@ // 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_CGAL_OUTER_FACET_H -#define IGL_CGAL_OUTER_FACET_H -#include "../igl_inline.h" +#ifndef IGL_COPYLEFT_CGAL_OUTER_FACET_H +#define IGL_COPYLEFT_CGAL_OUTER_FACET_H +#include "../../igl_inline.h" #include namespace igl { + namespace copyleft + { namespace cgal { // Find a facet that is reachable from infinity without crossing any faces. @@ -47,6 +49,7 @@ namespace igl bool & flipped); } + } } #ifndef IGL_STATIC_LIBRARY diff --git a/include/igl/cgal/outer_hull.cpp b/include/igl/copyleft/cgal/outer_hull.cpp similarity index 88% rename from include/igl/cgal/outer_hull.cpp rename to include/igl/copyleft/cgal/outer_hull.cpp index b29d3aea3..b5bc9c36a 100644 --- a/include/igl/cgal/outer_hull.cpp +++ b/include/igl/copyleft/cgal/outer_hull.cpp @@ -9,16 +9,16 @@ #include "outer_hull.h" #include "order_facets_around_edges.h" #include "outer_facet.h" -#include "../sortrows.h" -#include "../facet_components.h" -#include "../winding_number.h" -#include "../triangle_triangle_adjacency.h" -#include "../unique_edge_map.h" -#include "../barycenter.h" -#include "../per_face_normals.h" -#include "../writePLY.h" -#include "../sort_angles.h" -#include "../writePLY.h" +#include "../../sortrows.h" +#include "../../facet_components.h" +#include "../../winding_number.h" +#include "../../triangle_triangle_adjacency.h" +#include "../../unique_edge_map.h" +#include "../../barycenter.h" +#include "../../per_face_normals.h" +#include "../../writePLY.h" +#include "../../sort_angles.h" +#include "../../writePLY.h" #include #include @@ -35,7 +35,7 @@ template < typename DerivedG, typename DerivedJ, typename Derivedflip> -IGL_INLINE void igl::cgal::outer_hull( +IGL_INLINE void igl::copyleft::cgal::outer_hull( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & F, Eigen::PlainObjectBase & G, @@ -159,7 +159,7 @@ IGL_INLINE void igl::cgal::outer_hull( #ifdef IGL_OUTER_HULL_DEBUG cout<<"outer facet..."<, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::cgal::outer_hull, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::outer_hull, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::outer_hull, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/copyleft/cgal/outer_hull.h b/include/igl/copyleft/cgal/outer_hull.h new file mode 100644 index 000000000..07e5feed4 --- /dev/null +++ b/include/igl/copyleft/cgal/outer_hull.h @@ -0,0 +1,54 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_CGAL_OUTER_HULL_H +#define IGL_COPYLEFT_CGAL_OUTER_HULL_H +#include "../../igl_inline.h" +#include +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // Compute the "outer hull" of a potentially non-manifold mesh (V,F) whose + // intersections have been "resolved" (e.g. using `cork` or + // `igl::copyleft::cgal::selfintersect`). The outer hull is defined to be all facets + // (regardless of orientation) for which there exists some path from infinity + // to the face without intersecting any other facets. For solids, this is the + // surface of the solid. In general this includes any thin "wings" or + // "flaps". This implementation largely follows Section 3.6 of "Direct + // repair of self-intersecting meshes" [Attene 2014]. + // + // Inputs: + // V #V by 3 list of vertex positions + // F #F by 3 list of triangle indices into V + // Outputs: + // G #G by 3 list of output triangle indices into V + // J #G list of indices into F + // flip #F list of whether facet was added to G **and** flipped orientation + // (false for faces not added to G) + template < + typename DerivedV, + typename DerivedF, + typename DerivedG, + typename DerivedJ, + typename Derivedflip> + IGL_INLINE void outer_hull( + const Eigen::PlainObjectBase & V, + const Eigen::PlainObjectBase & F, + Eigen::PlainObjectBase & G, + Eigen::PlainObjectBase & J, + Eigen::PlainObjectBase & flip); + } + } +} + +#ifndef IGL_STATIC_LIBRARY +# include "outer_hull.cpp" +#endif +#endif diff --git a/include/igl/cgal/peel_outer_hull_layers.cpp b/include/igl/copyleft/cgal/peel_outer_hull_layers.cpp similarity index 84% rename from include/igl/cgal/peel_outer_hull_layers.cpp rename to include/igl/copyleft/cgal/peel_outer_hull_layers.cpp index 9e4a04ad8..729cea347 100644 --- a/include/igl/cgal/peel_outer_hull_layers.cpp +++ b/include/igl/copyleft/cgal/peel_outer_hull_layers.cpp @@ -11,9 +11,9 @@ #include //#define IGL_PEEL_OUTER_HULL_LAYERS_DEBUG #ifdef IGL_PEEL_OUTER_HULL_LAYERS_DEBUG -#include "../writePLY.h" -#include "../writeDMAT.h" -#include "../STR.h" +#include "../../writePLY.h" +#include "../../writeDMAT.h" +#include "../../STR.h" #endif template < @@ -21,7 +21,7 @@ template < typename DerivedF, typename DerivedI, typename Derivedflip> -IGL_INLINE size_t igl::cgal::peel_outer_hull_layers( +IGL_INLINE size_t igl::copyleft::cgal::peel_outer_hull_layers( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & F, Eigen::PlainObjectBase & I, @@ -115,5 +115,5 @@ IGL_INLINE size_t igl::cgal::peel_outer_hull_layers( #ifdef IGL_STATIC_LIBRARY // Explicit template specialization -template size_t igl::cgal::peel_outer_hull_layers, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template size_t igl::copyleft::cgal::peel_outer_hull_layers, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/copyleft/cgal/peel_outer_hull_layers.h b/include/igl/copyleft/cgal/peel_outer_hull_layers.h new file mode 100644 index 000000000..ee2752b29 --- /dev/null +++ b/include/igl/copyleft/cgal/peel_outer_hull_layers.h @@ -0,0 +1,47 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_CGAL_PEEL_OUTER_HULL_LAYERS_H +#define IGL_COPYLEFT_CGAL_PEEL_OUTER_HULL_LAYERS_H +#include "../../igl_inline.h" +#include +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // Computes necessary generic information for boolean operations by + // successively "peeling" off the "outer hull" of a mesh (V,F) resulting from + // "resolving" all (self-)intersections. + // + // Inputs: + // V #V by 3 list of vertex positions + // F #F by 3 list of triangle indices into V + // Outputs: + // I #F list of which peel Iation a facet belongs + // flip #F list of whether a facet's orientation was flipped when facet + // "peeled" into its associated outer hull layer. + // Returns number of peels + template < + typename DerivedV, + typename DerivedF, + typename DerivedI, + typename Derivedflip> + IGL_INLINE size_t peel_outer_hull_layers( + const Eigen::PlainObjectBase & V, + const Eigen::PlainObjectBase & F, + Eigen::PlainObjectBase & I, + Eigen::PlainObjectBase & flip); + } + } +} + +#ifndef IGL_STATIC_LIBRARY +# include "peel_outer_hull_layers.cpp" +#endif +#endif diff --git a/include/igl/cgal/peel_winding_number_layers.cpp b/include/igl/copyleft/cgal/peel_winding_number_layers.cpp similarity index 84% rename from include/igl/cgal/peel_winding_number_layers.cpp rename to include/igl/copyleft/cgal/peel_winding_number_layers.cpp index 3cc8cd98f..2bb71a780 100644 --- a/include/igl/cgal/peel_winding_number_layers.cpp +++ b/include/igl/copyleft/cgal/peel_winding_number_layers.cpp @@ -8,7 +8,7 @@ template< typename DerivedV, typename DerivedF, typename DerivedW > -IGL_INLINE size_t igl::cgal::peel_winding_number_layers( +IGL_INLINE size_t igl::copyleft::cgal::peel_winding_number_layers( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & F, Eigen::PlainObjectBase& W) { @@ -17,7 +17,7 @@ IGL_INLINE size_t igl::cgal::peel_winding_number_layers( labels.setZero(); Eigen::MatrixXi winding_numbers; - igl::cgal::propagate_winding_numbers(V, F, labels, winding_numbers); + igl::copyleft::cgal::propagate_winding_numbers(V, F, labels, winding_numbers); assert(winding_numbers.rows() == num_faces); assert(winding_numbers.cols() == 2); diff --git a/include/igl/cgal/peel_winding_number_layers.h b/include/igl/copyleft/cgal/peel_winding_number_layers.h similarity index 74% rename from include/igl/cgal/peel_winding_number_layers.h rename to include/igl/copyleft/cgal/peel_winding_number_layers.h index 7ac53ce29..644c361e3 100644 --- a/include/igl/cgal/peel_winding_number_layers.h +++ b/include/igl/copyleft/cgal/peel_winding_number_layers.h @@ -1,9 +1,10 @@ -#ifndef IGL_CGAL_PEEL_WINDING_NUMBER_LAYERS_H -#define IGL_CGAL_PEEL_WINDING_NUMBER_LAYERS_H -#include "../igl_inline.h" +#ifndef IGL_COPYLEFT_CGAL_PEEL_WINDING_NUMBER_LAYERS_H +#define IGL_COPYLEFT_CGAL_PEEL_WINDING_NUMBER_LAYERS_H +#include "../../igl_inline.h" #include namespace igl { + namespace copyleft { namespace cgal { template< typename DerivedV, @@ -14,6 +15,7 @@ namespace igl { const Eigen::PlainObjectBase & F, Eigen::PlainObjectBase& W); } + } } #ifndef IGL_STATIC_LIBRARY diff --git a/include/igl/cgal/point_mesh_squared_distance.cpp b/include/igl/copyleft/cgal/point_mesh_squared_distance.cpp similarity index 71% rename from include/igl/cgal/point_mesh_squared_distance.cpp rename to include/igl/copyleft/cgal/point_mesh_squared_distance.cpp index 1b9d09e38..49d069be1 100644 --- a/include/igl/cgal/point_mesh_squared_distance.cpp +++ b/include/igl/copyleft/cgal/point_mesh_squared_distance.cpp @@ -9,7 +9,7 @@ #include "mesh_to_cgal_triangle_list.h" template -IGL_INLINE void igl::cgal::point_mesh_squared_distance( +IGL_INLINE void igl::copyleft::cgal::point_mesh_squared_distance( const Eigen::MatrixXd & P, const Eigen::MatrixXd & V, const Eigen::MatrixXi & F, @@ -30,7 +30,7 @@ IGL_INLINE void igl::cgal::point_mesh_squared_distance( } template -IGL_INLINE void igl::cgal::point_mesh_squared_distance_precompute( +IGL_INLINE void igl::copyleft::cgal::point_mesh_squared_distance_precompute( const Eigen::MatrixXd & V, const Eigen::MatrixXi & F, CGAL::AABB_tree< @@ -78,7 +78,7 @@ IGL_INLINE void igl::cgal::point_mesh_squared_distance_precompute( } template -IGL_INLINE void igl::cgal::point_mesh_squared_distance( +IGL_INLINE void igl::copyleft::cgal::point_mesh_squared_distance( const Eigen::MatrixXd & P, const CGAL::AABB_tree< CGAL::AABB_traits(Eigen::Matrix const&, Eigen::Matrix const&, CGAL::AABB_tree, std::allocator > >::iterator, CGAL::Boolean_tag > > >&, std::vector, std::allocator > >&); -template void igl::cgal::point_mesh_squared_distance( const Eigen::MatrixXd & P, const Eigen::MatrixXd & V, const Eigen::MatrixXi & F, Eigen::VectorXd & sqrD, Eigen::VectorXi & I, Eigen::MatrixXd & C); -template void igl::cgal::point_mesh_squared_distance(Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix&, Eigen::Matrix&, Eigen::Matrix&); -template void igl::cgal::point_mesh_squared_distance >(Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix&, Eigen::Matrix&, Eigen::Matrix&); +template void igl::copyleft::cgal::point_mesh_squared_distance_precompute(Eigen::Matrix const&, Eigen::Matrix const&, CGAL::AABB_tree, std::allocator > >::iterator, CGAL::Boolean_tag > > >&, std::vector, std::allocator > >&); +template void igl::copyleft::cgal::point_mesh_squared_distance( const Eigen::MatrixXd & P, const Eigen::MatrixXd & V, const Eigen::MatrixXi & F, Eigen::VectorXd & sqrD, Eigen::VectorXi & I, Eigen::MatrixXd & C); +template void igl::copyleft::cgal::point_mesh_squared_distance(Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix&, Eigen::Matrix&, Eigen::Matrix&); +template void igl::copyleft::cgal::point_mesh_squared_distance >(Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix&, Eigen::Matrix&, Eigen::Matrix&); #endif diff --git a/include/igl/copyleft/cgal/point_mesh_squared_distance.h b/include/igl/copyleft/cgal/point_mesh_squared_distance.h new file mode 100644 index 000000000..61107fd4e --- /dev/null +++ b/include/igl/copyleft/cgal/point_mesh_squared_distance.h @@ -0,0 +1,88 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2014 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_CGAL_POINT_MESH_SQUARED_DISTANCE_H +#define IGL_COPYLEFT_CGAL_POINT_MESH_SQUARED_DISTANCE_H +#include "../../igl_inline.h" +#include +#include +#include "CGAL_includes.hpp" +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // Compute distances from a set of points P to a triangle mesh (V,F) + // + // Templates: + // Kernal CGAL computation and construction kernel (e.g. + // CGAL::Simple_cartesian) + // Inputs: + // P #P by 3 list of query point positions + // V #V by 3 list of vertex positions + // F #F by 3 list of triangle indices + // Outputs: + // sqrD #P list of smallest squared distances + // I #P list of facet indices corresponding to smallest distances + // C #P by 3 list of closest points + // + // Known bugs: This only computes distances to triangles. So unreferenced + // vertices and degenerate triangles (segments) are ignored. + template + IGL_INLINE void point_mesh_squared_distance( + const Eigen::MatrixXd & P, + const Eigen::MatrixXd & V, + const Eigen::MatrixXi & F, + Eigen::VectorXd & sqrD, + Eigen::VectorXi & I, + Eigen::MatrixXd & C); + // Probably can do this in a way that we don't pass around `tree` and `T` + // + // Outputs: + // tree CGAL's AABB tree + // T list of CGAL triangles in order of F (for determining which was found + // in computation) + template + IGL_INLINE void point_mesh_squared_distance_precompute( + const Eigen::MatrixXd & V, + const Eigen::MatrixXi & F, + CGAL::AABB_tree< + CGAL::AABB_traits >::iterator + > + > + > & tree, + std::vector > & T); + // Inputs: + // see above + // Outputs: + // see above + template + IGL_INLINE void point_mesh_squared_distance( + const Eigen::MatrixXd & P, + const CGAL::AABB_tree< + CGAL::AABB_traits >::iterator + > + > + > & tree, + const std::vector > & T, + Eigen::VectorXd & sqrD, + Eigen::VectorXi & I, + Eigen::MatrixXd & C); + } + } +} + +#ifndef IGL_STATIC_LIBRARY +# include "point_mesh_squared_distance.cpp" +#endif + +#endif diff --git a/include/igl/cgal/points_inside_component.cpp b/include/igl/copyleft/cgal/points_inside_component.cpp similarity index 83% rename from include/igl/cgal/points_inside_component.cpp rename to include/igl/copyleft/cgal/points_inside_component.cpp index 77573d9d2..5349ef954 100644 --- a/include/igl/cgal/points_inside_component.cpp +++ b/include/igl/copyleft/cgal/points_inside_component.cpp @@ -21,6 +21,8 @@ #include "assign_scalar.h" namespace igl { + namespace copyleft + { namespace cgal { namespace points_inside_component_helper { typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; @@ -153,9 +155,9 @@ namespace igl { assert(num_adj_faces > 0); DerivedV pivot_point(1, 3); - igl::cgal::assign_scalar(query.x(), pivot_point(0, 0)); - igl::cgal::assign_scalar(query.y(), pivot_point(0, 1)); - igl::cgal::assign_scalar(query.z(), pivot_point(0, 2)); + igl::copyleft::cgal::assign_scalar(query.x(), pivot_point(0, 0)); + igl::copyleft::cgal::assign_scalar(query.y(), pivot_point(0, 1)); + igl::copyleft::cgal::assign_scalar(query.z(), pivot_point(0, 2)); Eigen::VectorXi order; order_facets_around_edge(V, F, s, d, adj_faces, pivot_point, order); @@ -263,17 +265,18 @@ namespace igl { } } } + } } template -IGL_INLINE void igl::cgal::points_inside_component( +IGL_INLINE void igl::copyleft::cgal::points_inside_component( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, const Eigen::PlainObjectBase& I, const Eigen::PlainObjectBase& P, Eigen::PlainObjectBase& inside) { - using namespace igl::cgal::points_inside_component_helper; + using namespace igl::copyleft::cgal::points_inside_component_helper; if (F.rows() <= 0 || I.rows() <= 0) { throw "Inside check cannot be done on empty facet component."; } @@ -330,21 +333,21 @@ IGL_INLINE void igl::cgal::points_inside_component( template -IGL_INLINE void igl::cgal::points_inside_component( +IGL_INLINE void igl::copyleft::cgal::points_inside_component( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, const Eigen::PlainObjectBase& P, Eigen::PlainObjectBase& inside) { Eigen::VectorXi I(F.rows()); I.setLinSpaced(F.rows(), 0, F.rows()-1); - igl::cgal::points_inside_component(V, F, I, P, inside); + igl::copyleft::cgal::points_inside_component(V, F, I, P, inside); } #ifdef IGL_STATIC_LIBRARY // Explicit template specialization -template void igl::cgal::points_inside_component< Eigen::Matrix, Eigen::Matrix< int, -1, -1, 0, -1, -1>, Eigen::Matrix< int, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix< int, -1, -1, 0, -1, -1> > ( Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); -template void igl::cgal::points_inside_component< Eigen::Matrix, Eigen::Matrix< int, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix< int, -1, -1, 0, -1, -1> > ( Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); -template void igl::cgal::points_inside_component, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase >&); -template void igl::cgal::points_inside_component, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); -template void igl::cgal::points_inside_component, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::points_inside_component< Eigen::Matrix, Eigen::Matrix< int, -1, -1, 0, -1, -1>, Eigen::Matrix< int, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix< int, -1, -1, 0, -1, -1> > ( Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::points_inside_component< Eigen::Matrix, Eigen::Matrix< int, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix< int, -1, -1, 0, -1, -1> > ( Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::points_inside_component, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::points_inside_component, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::points_inside_component, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/cgal/points_inside_component.h b/include/igl/copyleft/cgal/points_inside_component.h similarity index 93% rename from include/igl/cgal/points_inside_component.h rename to include/igl/copyleft/cgal/points_inside_component.h index f7f7622e3..3f57eb7cc 100644 --- a/include/igl/cgal/points_inside_component.h +++ b/include/igl/copyleft/cgal/points_inside_component.h @@ -5,14 +5,16 @@ // 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 POINTS_INSIDE_COMPONENTS -#define POINTS_INSIDE_COMPONENTS +#ifndef IGL_COPYLEFT_CGAL_POINTS_INSIDE_COMPONENTS +#define IGL_COPYLEFT_CGAL_POINTS_INSIDE_COMPONENTS -#include "../igl_inline.h" +#include "../../igl_inline.h" #include #include namespace igl { + namespace copyleft + { namespace cgal { // Determine if queries points P are inside of connected facet component @@ -51,6 +53,7 @@ namespace igl { const Eigen::PlainObjectBase& P, Eigen::PlainObjectBase& inside); } + } } #ifndef IGL_STATIC_LIBRARY diff --git a/include/igl/cgal/polyhedron_to_mesh.cpp b/include/igl/copyleft/cgal/polyhedron_to_mesh.cpp similarity index 79% rename from include/igl/cgal/polyhedron_to_mesh.cpp rename to include/igl/copyleft/cgal/polyhedron_to_mesh.cpp index 406c01112..218e09586 100644 --- a/include/igl/cgal/polyhedron_to_mesh.cpp +++ b/include/igl/copyleft/cgal/polyhedron_to_mesh.cpp @@ -9,7 +9,7 @@ #include template -IGL_INLINE void igl::cgal::polyhedron_to_mesh( +IGL_INLINE void igl::copyleft::cgal::polyhedron_to_mesh( const Polyhedron & poly, Eigen::MatrixXd & V, Eigen::MatrixXi & F) @@ -60,5 +60,5 @@ IGL_INLINE void igl::cgal::polyhedron_to_mesh( // Explicit template specialization #include #include -template void igl::cgal::polyhedron_to_mesh, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator > >(CGAL::Polyhedron_3, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator > const&, Eigen::Matrix&, Eigen::Matrix&); +template void igl::copyleft::cgal::polyhedron_to_mesh, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator > >(CGAL::Polyhedron_3, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator > const&, Eigen::Matrix&, Eigen::Matrix&); #endif diff --git a/include/igl/copyleft/cgal/polyhedron_to_mesh.h b/include/igl/copyleft/cgal/polyhedron_to_mesh.h new file mode 100644 index 000000000..91d6f26f6 --- /dev/null +++ b/include/igl/copyleft/cgal/polyhedron_to_mesh.h @@ -0,0 +1,40 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_CGAL_POLYHEDRON_TO_MESH_H +#define IGL_COPYLEFT_CGAL_POLYHEDRON_TO_MESH_H +#include "../../igl_inline.h" +#include + +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // Convert a CGAL Polyhedron to a mesh (V,F) + // + // Templates: + // Polyhedron CGAL Polyhedron type (e.g. Polyhedron_3) + // Inputs: + // poly cgal polyhedron + // Outputs: + // V #V by 3 list of vertex positions + // F #F by 3 list of triangle indices + template + IGL_INLINE void polyhedron_to_mesh( + const Polyhedron & poly, + Eigen::MatrixXd & V, + Eigen::MatrixXi & F); + } + } +} +#ifndef IGL_STATIC_LIBRARY +# include "polyhedron_to_mesh.cpp" +#endif + +#endif diff --git a/include/igl/cgal/projected_delaunay.cpp b/include/igl/copyleft/cgal/projected_delaunay.cpp similarity index 75% rename from include/igl/cgal/projected_delaunay.cpp rename to include/igl/copyleft/cgal/projected_delaunay.cpp index 9f2fcc7e8..af4343693 100644 --- a/include/igl/cgal/projected_delaunay.cpp +++ b/include/igl/copyleft/cgal/projected_delaunay.cpp @@ -6,7 +6,7 @@ // 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 "projected_delaunay.h" -#include "../REDRUM.h" +#include "../../REDRUM.h" #include #include @@ -15,7 +15,7 @@ #endif template -IGL_INLINE void igl::cgal::projected_delaunay( +IGL_INLINE void igl::copyleft::cgal::projected_delaunay( const CGAL::Triangle_3 & A, const std::vector & A_objects_3, CGAL::Constrained_triangulation_plus_2< @@ -101,6 +101,6 @@ IGL_INLINE void igl::cgal::projected_delaunay( #ifdef IGL_STATIC_LIBRARY // Explicit template specialization -template void igl::cgal::projected_delaunay(CGAL::Triangle_3 const&, std::vector > const&, CGAL::Constrained_triangulation_plus_2 >, CGAL::Constrained_triangulation_face_base_2 > > >, CGAL::Exact_intersections_tag> >&); -template void igl::cgal::projected_delaunay(CGAL::Triangle_3 const&, std::vector > const&, CGAL::Constrained_triangulation_plus_2 >, CGAL::Constrained_triangulation_face_base_2 > > >, CGAL::Exact_intersections_tag> >&); +template void igl::copyleft::cgal::projected_delaunay(CGAL::Triangle_3 const&, std::vector > const&, CGAL::Constrained_triangulation_plus_2 >, CGAL::Constrained_triangulation_face_base_2 > > >, CGAL::Exact_intersections_tag> >&); +template void igl::copyleft::cgal::projected_delaunay(CGAL::Triangle_3 const&, std::vector > const&, CGAL::Constrained_triangulation_plus_2 >, CGAL::Constrained_triangulation_face_base_2 > > >, CGAL::Exact_intersections_tag> >&); #endif diff --git a/include/igl/copyleft/cgal/projected_delaunay.h b/include/igl/copyleft/cgal/projected_delaunay.h new file mode 100644 index 000000000..ee72305cd --- /dev/null +++ b/include/igl/copyleft/cgal/projected_delaunay.h @@ -0,0 +1,46 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_CGAL_PROJECTED_DELAUNAY_H +#define IGL_COPYLEFT_CGAL_PROJECTED_DELAUNAY_H +#include "../../igl_inline.h" +#include "CGAL_includes.hpp" +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // Compute 2D delaunay triangulation of a given 3d triangle and a list of + // intersection objects (points,segments,triangles). CGAL uses an affine + // projection rather than an isometric projection, so we're not guaranteed + // that the 2D delaunay triangulation here will be a delaunay triangulation + // in 3D. + // + // Inputs: + // A triangle in 3D + // A_objects_3 updated list of intersection objects for A + // Outputs: + // cdt Contrained delaunay triangulation in projected 2D plane + template + IGL_INLINE void projected_delaunay( + const CGAL::Triangle_3 & A, + const std::vector & A_objects_3, + CGAL::Constrained_triangulation_plus_2< + CGAL::Constrained_Delaunay_triangulation_2< + Kernel, + CGAL::Triangulation_data_structure_2< + CGAL::Triangulation_vertex_base_2, + CGAL::Constrained_triangulation_face_base_2 >, + CGAL::Exact_intersections_tag> > & cdt); + } + } +} +#ifndef IGL_STATIC_LIBRARY +# include "projected_delaunay.cpp" +#endif +#endif diff --git a/include/igl/cgal/propagate_winding_numbers.cpp b/include/igl/copyleft/cgal/propagate_winding_numbers.cpp similarity index 90% rename from include/igl/cgal/propagate_winding_numbers.cpp rename to include/igl/copyleft/cgal/propagate_winding_numbers.cpp index c2b6118c8..8f8c9a984 100644 --- a/include/igl/cgal/propagate_winding_numbers.cpp +++ b/include/igl/copyleft/cgal/propagate_winding_numbers.cpp @@ -7,12 +7,12 @@ // obtain one at http://mozilla.org/MPL/2.0/. // #include "propagate_winding_numbers.h" -#include "../extract_manifold_patches.h" -#include "../extract_non_manifold_edge_curves.h" -#include "../facet_components.h" -#include "../unique_edge_map.h" -#include "../writeOBJ.h" -#include "../writePLY.h" +#include "../../extract_manifold_patches.h" +#include "../../extract_non_manifold_edge_curves.h" +#include "../../facet_components.h" +#include "../../unique_edge_map.h" +#include "../../writeOBJ.h" +#include "../../writePLY.h" #include "order_facets_around_edge.h" #include "outer_facet.h" #include "closest_facet.h" @@ -71,7 +71,7 @@ typename DerivedV, typename DerivedF, typename DerivedL, typename DerivedW> -IGL_INLINE void igl::cgal::propagate_winding_numbers( +IGL_INLINE void igl::copyleft::cgal::propagate_winding_numbers( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, const Eigen::PlainObjectBase& labels, @@ -90,7 +90,7 @@ IGL_INLINE void igl::cgal::propagate_winding_numbers( DerivedW per_patch_cells; const size_t num_cells = - igl::cgal::extract_cells(V, F, P, E, uE, uE2E, EMAP, per_patch_cells); + igl::copyleft::cgal::extract_cells(V, F, P, E, uE, uE2E, EMAP, per_patch_cells); typedef std::tuple CellConnection; std::vector > cell_adjacency(num_cells); @@ -183,7 +183,7 @@ IGL_INLINE void igl::cgal::propagate_winding_numbers( bool flipped; Eigen::VectorXi I; I.setLinSpaced(num_faces, 0, num_faces-1); - igl::cgal::outer_facet(V, F, I, outer_facet, flipped); + igl::copyleft::cgal::outer_facet(V, F, I, outer_facet, flipped); const size_t outer_patch = P[outer_facet]; const size_t infinity_cell = per_patch_cells(outer_patch, flipped?1:0); @@ -257,5 +257,5 @@ IGL_INLINE void igl::cgal::propagate_winding_numbers( #ifdef IGL_STATIC_LIBRARY -template void igl::cgal::propagate_winding_numbers, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::propagate_winding_numbers, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/cgal/propagate_winding_numbers.h b/include/igl/copyleft/cgal/propagate_winding_numbers.h similarity index 93% rename from include/igl/cgal/propagate_winding_numbers.h rename to include/igl/copyleft/cgal/propagate_winding_numbers.h index b57787519..3c595d301 100644 --- a/include/igl/cgal/propagate_winding_numbers.h +++ b/include/igl/copyleft/cgal/propagate_winding_numbers.h @@ -6,9 +6,9 @@ // 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_CGAL_PROPAGATE_WINDING_NUMBERS_H -#define IGL_CGAL_PROPAGATE_WINDING_NUMBERS_H -#include "../igl_inline.h" +#ifndef IGL_COPYLEFT_CGAL_PROPAGATE_WINDING_NUMBERS_H +#define IGL_COPYLEFT_CGAL_PROPAGATE_WINDING_NUMBERS_H +#include "../../igl_inline.h" #include #include @@ -20,6 +20,8 @@ // facets. namespace igl { + namespace copyleft + { namespace cgal { // Compute winding number on each side of the face. The input mesh @@ -49,6 +51,7 @@ namespace igl { const Eigen::PlainObjectBase& labels, Eigen::PlainObjectBase& W); } + } } #ifndef IGL_STATIC_LIBRARY diff --git a/include/igl/copyleft/cgal/remesh_intersections.cpp b/include/igl/copyleft/cgal/remesh_intersections.cpp new file mode 100644 index 000000000..4dc1e8dc6 --- /dev/null +++ b/include/igl/copyleft/cgal/remesh_intersections.cpp @@ -0,0 +1,362 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 Qingnan Zhou +// +// 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 "remesh_intersections.h" +#include "assign_scalar.h" + +#include +#include +#include +#include + +template < +typename DerivedV, +typename DerivedF, +typename Kernel, +typename DerivedVV, +typename DerivedFF, +typename DerivedJ, +typename DerivedIM> +IGL_INLINE void igl::copyleft::cgal::remesh_intersections( + const Eigen::PlainObjectBase & V, + const Eigen::PlainObjectBase & F, + const std::vector > & T, + const std::map< + typename DerivedF::Index, + std::pair > > & offending, + const std::map< + std::pair, + std::vector > & edge2faces, + Eigen::PlainObjectBase & VV, + Eigen::PlainObjectBase & FF, + Eigen::PlainObjectBase & J, + Eigen::PlainObjectBase & IM) { + + typedef CGAL::Point_3 Point_3; + typedef CGAL::Segment_3 Segment_3; + typedef CGAL::Triangle_3 Triangle_3; + typedef CGAL::Plane_3 Plane_3; + typedef CGAL::Point_2 Point_2; + typedef CGAL::Segment_2 Segment_2; + typedef CGAL::Triangle_2 Triangle_2; + typedef CGAL::Triangulation_vertex_base_2 TVB_2; + typedef CGAL::Constrained_triangulation_face_base_2 CTFB_2; + typedef CGAL::Triangulation_data_structure_2 TDS_2; + typedef CGAL::Exact_intersections_tag Itag; + typedef CGAL::Constrained_Delaunay_triangulation_2 + CDT_2; + typedef CGAL::Constrained_triangulation_plus_2 CDT_plus_2; + + typedef typename DerivedF::Index Index; + typedef std::pair Edge; + struct EdgeHash { + size_t operator()(const Edge& e) const { + return (e.first * 805306457) ^ (e.second * 201326611); + } + }; + typedef std::unordered_map, EdgeHash > EdgeMap; + + auto normalize_plane_coeff = [](const Plane_3& P) { + std::vector coeffs = { + P.a(), P.b(), P.c(), P.d() + }; + const auto max_itr = std::max_element(coeffs.begin(), coeffs.end()); + const auto min_itr = std::min_element(coeffs.begin(), coeffs.end()); + typename Kernel::FT max_coeff; + if (*max_itr < -1 * *min_itr) { + max_coeff = *min_itr; + } else { + max_coeff = *max_itr; + } + std::transform(coeffs.begin(), coeffs.end(), coeffs.begin(), + [&](const typename Kernel::FT& val) + {return val / max_coeff; } ); + return coeffs; + }; + + auto plane_comp = [&](const Plane_3& p1, const Plane_3& p2) { + const auto p1_coeffs = normalize_plane_coeff(p1); + const auto p2_coeffs = normalize_plane_coeff(p2); + if (p1_coeffs[0] != p2_coeffs[0]) + return p1_coeffs[0] < p2_coeffs[0]; + if (p1_coeffs[1] != p2_coeffs[1]) + return p1_coeffs[1] < p2_coeffs[1]; + if (p1_coeffs[2] != p2_coeffs[2]) + return p1_coeffs[2] < p2_coeffs[2]; + if (p1_coeffs[3] != p2_coeffs[3]) + return p1_coeffs[3] < p2_coeffs[3]; + return false; + }; + std::map, decltype(plane_comp)> + unique_planes(plane_comp); + + const size_t num_faces = F.rows(); + const size_t num_base_vertices = V.rows(); + assert(num_faces == T.size()); + std::vector is_offending(num_faces, false); + for (const auto itr : offending) { + const auto& fid = itr.first; + is_offending[fid] = true; + + Plane_3 key = T[fid].supporting_plane(); + assert(!key.is_degenerate()); + const auto jtr = unique_planes.find(key); + if (jtr == unique_planes.end()) { + unique_planes.insert({key, {fid}}); + } else { + jtr->second.push_back(fid); + } + } + + const size_t INVALID = std::numeric_limits::max(); + std::vector > resolved_faces; + std::vector source_faces; + std::vector new_vertices; + EdgeMap edge_vertices; + + /** + * Run constraint Delaunay triangulation on the plane. + */ + auto run_delaunay_triangulation = [&](const Plane_3& P, + const std::vector& involved_faces, + std::vector& vertices, + std::vector >& faces) { + CDT_plus_2 cdt; + for (const auto& fid : involved_faces) { + const auto itr = offending.find(fid); + const auto& triangle = T[fid]; + cdt.insert_constraint(P.to_2d(triangle[0]), P.to_2d(triangle[1])); + cdt.insert_constraint(P.to_2d(triangle[1]), P.to_2d(triangle[2])); + cdt.insert_constraint(P.to_2d(triangle[2]), P.to_2d(triangle[0])); + + if (itr == offending.end()) continue; + for (const auto& obj : itr->second.second) { + if(const Segment_3 *iseg = CGAL::object_cast(&obj)) { + // Add segment constraint + cdt.insert_constraint( + P.to_2d(iseg->vertex(0)),P.to_2d(iseg->vertex(1))); + }else if(const Point_3 *ipoint = CGAL::object_cast(&obj)) { + // Add point + cdt.insert(P.to_2d(*ipoint)); + } else if(const Triangle_3 *itri = CGAL::object_cast(&obj)) { + // Add 3 segment constraints + cdt.insert_constraint( + P.to_2d(itri->vertex(0)),P.to_2d(itri->vertex(1))); + cdt.insert_constraint( + P.to_2d(itri->vertex(1)),P.to_2d(itri->vertex(2))); + cdt.insert_constraint( + P.to_2d(itri->vertex(2)),P.to_2d(itri->vertex(0))); + } else if(const std::vector *polyp = + CGAL::object_cast< std::vector >(&obj)) { + //cerr< & poly = *polyp; + const Index m = poly.size(); + assert(m>=2); + for(Index p = 0;p v2i; + size_t count=0; + for (auto itr = cdt.finite_vertices_begin(); + itr != cdt.finite_vertices_end(); itr++) { + vertices.push_back(P.to_3d(itr->point())); + v2i[itr] = count; + count++; + } + for (auto itr = cdt.finite_faces_begin(); + itr != cdt.finite_faces_end(); itr++) { + faces.push_back( { + v2i[itr->vertex(0)], + v2i[itr->vertex(1)], + v2i[itr->vertex(2)] }); + } + }; + + /** + * Given p on triangle indexed by ori_f, determine the index of p. + */ + auto determine_point_index = [&]( + const Point_3& p, const size_t ori_f) -> Index { + const auto& triangle = T[ori_f]; + const auto& f = F.row(ori_f).eval(); + + // Check if p is one of the triangle corners. + for (size_t i=0; i<3; i++) { + if (p == triangle[i]) return f[i]; + } + + // Check if p is on one of the edges. + for (size_t i=0; i<3; i++) { + const Point_3 curr_corner = triangle[i]; + const Point_3 next_corner = triangle[(i+1)%3]; + const Segment_3 edge(curr_corner, next_corner); + if (edge.has_on(p)) { + const Index curr = f[i]; + const Index next = f[(i+1)%3]; + Edge key; + key.first = currsecond) { + if (p == new_vertices[vid - num_base_vertices]) { + return vid; + } + } + const size_t index = num_base_vertices + new_vertices.size(); + new_vertices.push_back(p); + itr->second.push_back(index); + return index; + } + } + } + + // p must be in the middle of the triangle. + const size_t index = num_base_vertices + new_vertices.size(); + new_vertices.push_back(p); + return index; + }; + + /** + * Determine the vertex indices for each corner of each output triangle. + */ + auto post_triangulation_process = [&]( + const std::vector& vertices, + const std::vector >& faces, + const std::vector& involved_faces) { + for (const auto& f : faces) { + const Point_3& v0 = vertices[f[0]]; + const Point_3& v1 = vertices[f[1]]; + const Point_3& v2 = vertices[f[2]]; + Point_3 center( + (v0[0] + v1[0] + v2[0]) / 3.0, + (v0[1] + v1[1] + v2[1]) / 3.0, + (v0[2] + v1[2] + v2[2]) / 3.0); + for (const auto& ori_f : involved_faces) { + const auto& triangle = T[ori_f]; + const Plane_3 P = triangle.supporting_plane(); + if (triangle.has_on(center)) { + std::vector corners(3); + corners[0] = determine_point_index(v0, ori_f); + corners[1] = determine_point_index(v1, ori_f); + corners[2] = determine_point_index(v2, ori_f); + if (CGAL::orientation( + P.to_2d(v0), P.to_2d(v1), P.to_2d(v2)) + == CGAL::RIGHT_TURN) { + std::swap(corners[0], corners[1]); + } + resolved_faces.emplace_back(corners); + source_faces.push_back(ori_f); + } + } + } + }; + + // Process un-touched faces. + for (size_t i=0; i vertices; + std::vector > faces; + run_delaunay_triangulation(P, involved_faces, vertices, faces); + post_triangulation_process(vertices, faces, involved_faces); + } + + // Output resolved mesh. + const size_t num_out_vertices = new_vertices.size() + num_base_vertices; + VV.resize(num_out_vertices, 3); + for (size_t i=0; i vv2i; + // Safe to check for duplicates using double for original vertices: if + // incoming reps are different then the points are unique. + for(Index v = 0;v, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, -1, 3, 0, -1, 3>, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epick, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_intersections, Eigen::Matrix, CGAL::Epeck, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, std::__1::vector, std::__1::allocator > > const&, std::__1::map::Index, std::__1::pair::Index, std::__1::vector > >, std::__1::less::Index>, std::__1::allocator::Index const, std::__1::pair::Index, std::__1::vector > > > > > const&, std::__1::map::Index, Eigen::Matrix::Index>, std::__1::vector::Index, std::__1::allocator::Index> >, std::__1::less::Index, Eigen::Matrix::Index> >, std::__1::allocator::Index, Eigen::Matrix::Index> const, std::__1::vector::Index, std::__1::allocator::Index> > > > > const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +#endif + diff --git a/include/igl/copyleft/cgal/remesh_intersections.h b/include/igl/copyleft/cgal/remesh_intersections.h new file mode 100644 index 000000000..42eb83490 --- /dev/null +++ b/include/igl/copyleft/cgal/remesh_intersections.h @@ -0,0 +1,73 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 Qingnan Zhou +// +// 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_COPYLEFT_CGAL_REMESH_INTERSECTIONS_H +#define IGL_COPYLEFT_CGAL_REMESH_INTERSECTIONS_H + +#include "../../igl_inline.h" +#include +#include "CGAL_includes.hpp" + +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // Remesh faces according to results of intersection detection and + // construction (e.g. from `igl::copyleft::cgal::intersect_other` or + // `igl::copyleft::cgal::SelfIntersectMesh`) + // + // Inputs: + // V #V by 3 list of vertex positions + // F #F by 3 list of triangle indices into V + // T #F list of cgal triangles + // offending #offending map taking face indices into F to pairs of order + // of first finding and list of intersection objects from all + // intersections + // edge2faces #edges <= #offending*3 to incident offending faces + // Outputs: + // VV #VV by 3 list of vertex positions + // FF #FF by 3 list of triangle indices into V + // IF #intersecting face pairs by 2 list of intersecting face pairs, + // indexing F + // J #FF list of indices into F denoting birth triangle + // IM #VV list of indices into VV of unique vertices. + // + template < + typename DerivedV, + typename DerivedF, + typename Kernel, + typename DerivedVV, + typename DerivedFF, + typename DerivedJ, + typename DerivedIM> + IGL_INLINE void remesh_intersections( + const Eigen::PlainObjectBase & V, + const Eigen::PlainObjectBase & F, + const std::vector > & T, + const std::map< + typename DerivedF::Index, + std::pair > > & offending, + const std::map< + std::pair, + std::vector > & edge2faces, + Eigen::PlainObjectBase & VV, + Eigen::PlainObjectBase & FF, + Eigen::PlainObjectBase & J, + Eigen::PlainObjectBase & IM); + } + } +} + +#ifndef IGL_STATIC_LIBRARY +# include "remesh_intersections.cpp" +#endif + +#endif diff --git a/include/igl/copyleft/cgal/remesh_self_intersections.cpp b/include/igl/copyleft/cgal/remesh_self_intersections.cpp new file mode 100644 index 000000000..32a024f40 --- /dev/null +++ b/include/igl/copyleft/cgal/remesh_self_intersections.cpp @@ -0,0 +1,95 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2014 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#include "remesh_self_intersections.h" +#include "SelfIntersectMesh.h" +#include "../../C_STR.h" +#include +#include + +template < + typename DerivedV, + typename DerivedF, + typename DerivedVV, + typename DerivedFF, + typename DerivedIF, + typename DerivedJ, + typename DerivedIM> +IGL_INLINE void igl::copyleft::cgal::remesh_self_intersections( + const Eigen::PlainObjectBase & V, + const Eigen::PlainObjectBase & F, + const RemeshSelfIntersectionsParam & params, + Eigen::PlainObjectBase & VV, + Eigen::PlainObjectBase & FF, + Eigen::PlainObjectBase & IF, + Eigen::PlainObjectBase & J, + Eigen::PlainObjectBase & IM) +{ + using namespace std; + if(params.detect_only) + { + //// This is probably a terrible idea, but CGAL is throwing floating point + //// exceptions. + +//#ifdef __APPLE__ +//#define IGL_THROW_FPE 11 +// const auto & throw_fpe = [](int e) +// { +// throw "IGL_THROW_FPE"; +// }; +// signal(SIGFPE,throw_fpe); +//#endif + + typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; + typedef + SelfIntersectMesh< + Kernel, + DerivedV, + DerivedF, + DerivedVV, + DerivedFF, + DerivedIF, + DerivedJ, + DerivedIM> + SelfIntersectMeshK; + SelfIntersectMeshK SIM = SelfIntersectMeshK(V,F,params,VV,FF,IF,J,IM); + +//#ifdef __APPLE__ +// signal(SIGFPE,SIG_DFL); +//#endif + + }else + { + typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; + typedef + SelfIntersectMesh< + Kernel, + DerivedV, + DerivedF, + DerivedVV, + DerivedFF, + DerivedIF, + DerivedJ, + DerivedIM> + SelfIntersectMeshK; + SelfIntersectMeshK SIM = SelfIntersectMeshK(V,F,params,VV,FF,IF,J,IM); + } +} + +#ifdef IGL_STATIC_LIBRARY +// Explicit template specialization +template void igl::copyleft::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_self_intersections, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_self_intersections, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cgal::remesh_self_intersections, Eigen::Matrix, Eigen::Matrix, -1, -1, 0, -1, -1>, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +#endif diff --git a/include/igl/copyleft/cgal/remesh_self_intersections.h b/include/igl/copyleft/cgal/remesh_self_intersections.h new file mode 100644 index 000000000..06ba6007f --- /dev/null +++ b/include/igl/copyleft/cgal/remesh_self_intersections.h @@ -0,0 +1,88 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2014 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_CGAL_REMESH_SELF_INTERSECTIONS_H +#define IGL_COPYLEFT_CGAL_REMESH_SELF_INTERSECTIONS_H +#include "../../igl_inline.h" +#include "RemeshSelfIntersectionsParam.h" + +#include + +#ifdef MEX +# include +# include +# undef assert +# define assert( isOK ) ( (isOK) ? (void)0 : (void) mexErrMsgTxt(C_STR(__FILE__<<":"<<__LINE__<<": failed assertion `"<<#isOK<<"'"< + IGL_INLINE void remesh_self_intersections( + const Eigen::PlainObjectBase & V, + const Eigen::PlainObjectBase & F, + const RemeshSelfIntersectionsParam & params, + Eigen::PlainObjectBase & VV, + Eigen::PlainObjectBase & FF, + Eigen::PlainObjectBase & IF, + Eigen::PlainObjectBase & J, + Eigen::PlainObjectBase & IM); + } + } +} + +#ifndef IGL_STATIC_LIBRARY +# include "remesh_self_intersections.cpp" +#endif + +#endif diff --git a/include/igl/cgal/signed_distance_isosurface.cpp b/include/igl/copyleft/cgal/signed_distance_isosurface.cpp similarity index 92% rename from include/igl/cgal/signed_distance_isosurface.cpp rename to include/igl/copyleft/cgal/signed_distance_isosurface.cpp index ef7ee81d9..c3c3b25b5 100644 --- a/include/igl/cgal/signed_distance_isosurface.cpp +++ b/include/igl/copyleft/cgal/signed_distance_isosurface.cpp @@ -9,13 +9,13 @@ #include "point_mesh_squared_distance.h" #include "complex_to_mesh.h" -#include "../AABB.h" -#include "../per_face_normals.h" -#include "../per_edge_normals.h" -#include "../per_vertex_normals.h" -#include "../centroid.h" -#include "../WindingNumberAABB.h" -#include "../matlab_format.h" +#include "../../AABB.h" +#include "../../per_face_normals.h" +#include "../../per_edge_normals.h" +#include "../../per_vertex_normals.h" +#include "../../centroid.h" +#include "../../WindingNumberAABB.h" +#include "../../matlab_format.h" #include #include @@ -28,7 +28,7 @@ #include #include -IGL_INLINE bool igl::cgal::signed_distance_isosurface( +IGL_INLINE bool igl::copyleft::cgal::signed_distance_isosurface( const Eigen::MatrixXd & IV, const Eigen::MatrixXi & IF, const double level, @@ -135,5 +135,5 @@ IGL_INLINE bool igl::cgal::signed_distance_isosurface( // meshing surface CGAL::make_surface_mesh(c2t3, surface, criteria, CGAL::Manifold_tag()); // complex to (V,F) - return igl::cgal::complex_to_mesh(c2t3,V,F); + return igl::copyleft::cgal::complex_to_mesh(c2t3,V,F); } diff --git a/include/igl/copyleft/cgal/signed_distance_isosurface.h b/include/igl/copyleft/cgal/signed_distance_isosurface.h new file mode 100644 index 000000000..149ea5e3d --- /dev/null +++ b/include/igl/copyleft/cgal/signed_distance_isosurface.h @@ -0,0 +1,54 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2014 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 +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_COPYLEFT_CGAL_SIGNED_DISTANCE_ISOSURFACE_H +#define IGL_COPYLEFT_CGAL_SIGNED_DISTANCE_ISOSURFACE_H +#include "../../igl_inline.h" +#include "../../signed_distance.h" +#include +namespace igl +{ + namespace copyleft + { + namespace cgal + { + // SIGNED_DISTANCE_ISOSURFACE Compute the contour of an iso-level of the + // signed distance field to a given mesh. + // + // Inputs: + // IV #IV by 3 list of input mesh vertex positions + // IF #IF by 3 list of input triangle indices + // level iso-level to contour in world coords, negative is inside. + // angle_bound lower bound on triangle angles (mesh quality) (e.g. 28) + // radius_bound upper bound on triangle size (mesh density?) (e.g. 0.02) + // distance_bound cgal mysterious parameter (mesh density?) (e.g. 0.01) + // sign_type method for computing distance _sign_ (see + // ../signed_distance.h) + // Outputs: + // V #V by 3 list of input mesh vertex positions + // F #F by 3 list of input triangle indices + // + IGL_INLINE bool signed_distance_isosurface( + const Eigen::MatrixXd & IV, + const Eigen::MatrixXi & IF, + const double level, + const double angle_bound, + const double radius_bound, + const double distance_bound, + const SignedDistanceType sign_type, + Eigen::MatrixXd & V, + Eigen::MatrixXi & F); + } + } +} + +#ifndef IGL_STATIC_LIBRARY +# include "signed_distance_isosurface.cpp" +#endif + +#endif + diff --git a/optional/CMakeLists.txt b/optional/CMakeLists.txt index f9bbf544d..c3fc93252 100644 --- a/optional/CMakeLists.txt +++ b/optional/CMakeLists.txt @@ -170,6 +170,7 @@ include_directories( ${PROJECT_SOURCE_DIR}/../include/) file(GLOB SOURCES "${PROJECT_SOURCE_DIR}/../include/igl/*.cpp" + "${PROJECT_SOURCE_DIR}/../include/igl/copyleft/*.cpp" ) add_library(igl STATIC ${SOURCES}) @@ -198,13 +199,13 @@ if (NOT CORK_FOUND) add_definitions(-DIGL_NO_CORK) endif(NOT CORK_FOUND) file(GLOB SOURCES_BOOLEAN - "${PROJECT_SOURCE_DIR}/../include/igl/boolean/*.cpp" + "${PROJECT_SOURCE_DIR}/../include/igl/copyleft/boolean/*.cpp" ) add_library(iglboolean STATIC ${SOURCES_BOOLEAN}) set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES} "iglboolean") #### Compile the cgal part file(GLOB SOURCES_CGAL - "${PROJECT_SOURCE_DIR}/../include/igl/cgal/*.cpp" + "${PROJECT_SOURCE_DIR}/../include/igl/copyleft/cgal/*.cpp" ) add_library(iglcgal STATIC ${SOURCES_CGAL}) set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES} "iglcgal") diff --git a/tutorial/609_Boolean/main.cpp b/tutorial/609_Boolean/main.cpp index 73e88c95b..c2da17eec 100755 --- a/tutorial/609_Boolean/main.cpp +++ b/tutorial/609_Boolean/main.cpp @@ -1,7 +1,7 @@ #include #define IGL_NO_CORK //#undef IGL_STATIC_LIBRARY -#include +#include #include #include @@ -12,8 +12,8 @@ Eigen::MatrixXd VA,VB,VC; Eigen::VectorXi J,I; Eigen::MatrixXi FA,FB,FC; -igl::boolean::MeshBooleanType boolean_type( - igl::boolean::MESH_BOOLEAN_TYPE_UNION); +igl::copyleft::boolean::MeshBooleanType boolean_type( + igl::copyleft::boolean::MESH_BOOLEAN_TYPE_UNION); const char * MESH_BOOLEAN_TYPE_NAMES[] = { @@ -26,7 +26,7 @@ const char * MESH_BOOLEAN_TYPE_NAMES[] = void update(igl::viewer::Viewer &viewer) { - igl::boolean::mesh_boolean(VA,FA,VB,FB,boolean_type,VC,FC,J); + igl::copyleft::boolean::mesh_boolean(VA,FA,VB,FB,boolean_type,VC,FC,J); Eigen::MatrixXd C(FC.rows(),3); for(size_t f = 0;f( - (boolean_type+1)% igl::boolean::NUM_MESH_BOOLEAN_TYPES); + static_cast( + (boolean_type+1)% igl::copyleft::boolean::NUM_MESH_BOOLEAN_TYPES); break; case ',': boolean_type = - static_cast( - (boolean_type+igl::boolean::NUM_MESH_BOOLEAN_TYPES-1)% - igl::boolean::NUM_MESH_BOOLEAN_TYPES); + static_cast( + (boolean_type+igl::copyleft::boolean::NUM_MESH_BOOLEAN_TYPES-1)% + igl::copyleft::boolean::NUM_MESH_BOOLEAN_TYPES); break; case '[': viewer.core.camera_dnear -= 0.1; @@ -68,7 +68,7 @@ bool key_down(igl::viewer::Viewer &viewer, unsigned char key, int mods) return true; } std::cout<<"A "< -#include +#include #include #include #include @@ -9,7 +9,7 @@ int main(int argc, char * argv[]) { using namespace Eigen; - using namespace igl::boolean; + using namespace igl::copyleft::boolean; using namespace std; using namespace igl; MatrixXi FA,FB,FC,FD,FE;