// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2014 Daniele Panozzo // // 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 "triangulate.h" #ifdef ANSI_DECLARATORS # define IGL_PREVIOUSLY_DEFINED_ANSI_DECLARATORS ANSI_DECLARATORS #endif #ifdef REAL # define IGL_PREVIOUSLY_DEFINED_REAL REAL #endif #ifdef VOID # define IGL_PREVIOUSLY_DEFINED_VOID VOID #endif #define ANSI_DECLARATORS #define REAL double #define VOID int extern "C" { #include } #ifdef IGL_PREVIOUSLY_DEFINED_ANSI_DECLARATORS # define ANSI_DECLARATORS IGL_PREVIOUSLY_DEFINED_ANSI_DECLARATORS #else # undef ANSI_DECLARATORS #endif #ifdef IGL_PREVIOUSLY_DEFINED_REAL # define REAL IGL_PREVIOUSLY_DEFINED_REAL #else # undef REAL #endif #ifdef IGL_PREVIOUSLY_DEFINED_VOID # define VOID IGL_PREVIOUSLY_DEFINED_VOID #else # undef VOID #endif IGL_INLINE void igl::triangulate( const Eigen::MatrixXd& V, const Eigen::MatrixXi& E, const Eigen::MatrixXd& H, const std::string flags, Eigen::MatrixXd& V2, Eigen::MatrixXi& F2) { using namespace std; using namespace Eigen; // Prepare the flags string full_flags = flags + "pzBV"; // Prepare the input struct triangulateio in; assert(V.cols() == 2); in.numberofpoints = V.rows(); in.pointlist = (double*)calloc(V.rows()*2,sizeof(double)); for (unsigned i=0;i(full_flags.c_str()), &in, &out, 0); // Cleanup in free(in.pointlist); free(in.pointmarkerlist); free(in.segmentlist); free(in.segmentmarkerlist); free(in.holelist); // Cleanup out free(out.pointlist); free(out.trianglelist); free(out.segmentlist); // Return the mesh V2.resize(out.numberofpoints,2); for (unsigned i=0;i