gm_polytri.cpp
来自「算断裂的」· C++ 代码 · 共 77 行
CPP
77 行
// ------------------------------------------------------------------// gm_polytri.cpp//// This file contains the driver function polytri, a routine// for triangulating planar polygons (PSLG's).// ------------------------------------------------------------------// Author: Stephen A. Vavasis// Copyright (c) 1999 by Cornell University. All rights reserved.// // See the accompanying file 'Copyright' for authorship information,// the terms of the license governing this software, and disclaimers// concerning this software.// ------------------------------------------------------------------// This file is part of the QMG software. // Version 2.0 of QMG, release date September 3, 1999.// ------------------------------------------------------------------#ifdef _MSC_VER#if _MSC_VER == 1200#include "qmatvec.h"#endif#endif#include "qfrontend.h"#include "qpolytri.h"#include "qmatvec.h"namespace QMG { namespace PolyTri { extern Triangulation poly_cdt(const Matrix& vtxlist, const vector<Edge>& elist, double tol); }}#define GM_ROUTINE_NAME gm_polytri#define GM_ROUTINE_NAME_Q "gm_polytri"namespace { static void worker(const QMG::FrontEnd::ArgValType& argvalhandle, QMG::FrontEnd::ReturnValType& returnvalhandle, QMG::FrontEnd::Interpreter& interp) { using namespace QMG; using namespace QMG::FrontEnd; using namespace QMG::PolyTri; argvalhandle.verify_nargin(2, 3, GM_ROUTINE_NAME_Q); returnvalhandle.verify_nargout(1,1, GM_ROUTINE_NAME_Q); Matrix coord = argvalhandle.get_zbamatrix(0); IntMatrix edges = argvalhandle.get_intmatrix(1); double tol = (argvalhandle.nargin() < 3) ? default_tol(interp) : argvalhandle.get_double(2); if (edges.numrows() > 0 && edges.numcols() != 2) throw_error("Argument 1 (edges) must have two columns"); vector<Edge> edgelist; for (int j = 0; j < edges.numrows(); ++j) edgelist.push_back(Edge(edges(j,0), edges(j,1))); Triangulation tri = poly_cdt(coord, edgelist, tol); IntMatrix result(tri.numtri(), 3); for (int k = 0; k < tri.numtri(); ++k) { result(k,0) = tri.tri_vertex(k,0); result(k,1) = tri.tri_vertex(k,1); result(k,2) = tri.tri_vertex(k,2); } returnvalhandle.put_intmatrix(0, result); return; }}#include "gm_entrypoint.cpp"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?