gm_mcompo.cpp
来自「算断裂的」· C++ 代码 · 共 76 行
CPP
76 行
// ------------------------------------------------------------------// gm_mcompo.cpp//// This file contains a routine to find connected components// of a mesh.// ------------------------------------------------------------------// 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.// ------------------------------------------------------------------#include "qbrep.h"#include "qsimpcomp.h"#include "qfrontend.h"#include "qunionfind.h"#define GM_ROUTINE_NAME gm_mcompo#define GM_ROUTINE_NAME_Q "gm_mcompo"namespace { static void worker(const QMG::FrontEnd::ArgValType& argvalhandle, QMG::FrontEnd::ReturnValType& returnvalhandle, QMG::FrontEnd::Interpreter& interp) { using namespace QMG; using namespace QMG::FrontEnd; argvalhandle.verify_nargin(1, 1, GM_ROUTINE_NAME_Q); returnvalhandle.verify_nargout(1, 1, GM_ROUTINE_NAME_Q); SimpComplex_From_FrontEnd sc = argvalhandle.get_simpcomp(0); int nn = sc.num_nodes(); UnionFind uf; uf.initialize(nn); int gdim = sc.gdim(); int levsize = sc.brep_levelsize(gdim); for (int faceind = 0; faceind < levsize; ++faceind) { Brep::Face_Spec fspec(gdim, faceind); int nmf = sc.num_meshface_on_face(fspec); for (int seqno = 0; seqno < nmf; ++seqno) { SimpComplex::VertexGlobalIndex vk = sc.node_of_meshface_on_face(fspec, seqno, 0); SimpComplex::VertexOrdinalIndex vko = sc.global_to_ordinal(vk); for (int i = 1; i < gdim + 1; ++i) { SimpComplex::VertexGlobalIndex vi = sc.node_of_meshface_on_face(fspec, seqno, i); SimpComplex::VertexOrdinalIndex vio = sc.global_to_ordinal(vi); uf.merge(vko,vio); } } } uf.pack_labels(); vector<int> labels(nn); for (SimpComplex::VertexOrdinalIndex vnumo = 0; vnumo < nn; ++vnumo) { labels[vnumo] = uf.get_label(vnumo); } returnvalhandle.put_intvector(0, labels); }}#include "gm_entrypoint.cpp"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?