?? gm_cpoly.m
字號:
function b = gm_cpoly(verts, codes)% GM_CPOLY: Construct a 2D brep given boundary paths.% Matlab: newbrep = gm_cpoly(vtxlist, codelist)% This routine creates a 2D polygon. The argument vtxlist is a matrix% of vertices. Each row has two entries that are vertex coordinates.% These are the vertices of the polygon in order. The codelist is a% list of codes; there is one code per vertex. The codes are as% follows:% 0 = vertex is start of a new loop% 1 = vertex is start of a new toplogical edge; part of existing loop% 2 = vertex is start of bezier curve; part of existing topological edge% 3 = vertex is an intermediate bezier control point.% The first entry in codes must be 0. An interactive graphical% front-end to this routine is provided by gmmouse.global gm_brep_type_code[numv,n] = size(verts);if n ~= 2 error('verts argument wrong size');endif numv < 3 error('Need at least three vertices for gm_cpoly.')end[numv2,n2] = size(codes);if n2 ~= 1 error('Second argument to gm_cpoly must be a column vector')endif numv2 ~= numv error('Two arguments to gm_cpoly must have the same number of entries')endif codes(1) ~= 0 error "first entry of nodetypelist must be 0"endif any(codes < 0) | any(codes > 3) error('each entry of codes must be an integer in 0..3')end %A code to close the final loop.verts = [verts; [-1e308 -1e308]];codes = [codes; -1];cplist = [];tvert = [];tedge = {};rbdry = {};thisedgecurves = {};thiscurve = [];vert_to_seq = zeros(numv + 1, 1);seq_to_vert = zba(zeros(numv + 1, 1));edge_to_seq = zeros(numv + 1, 1);seq_to_edge = zba(zeros(numv + 1, 1));vcount = 0;ecount = 0;loopstart = 1;for cpind = 1 : numv + 1 vert = verts(cpind, :); code = codes(cpind); if code < 2 & code > -1 tvert{1,vcount+1} = sprintf('v%d', cpind); tvert{2,vcount+1} = {}; tvert{3,vcount+1} = {}; tvert{4,vcount+1} = {}; tvert{5,vcount+1} = {'vertex'; []; [cpind - 1]}; seq_to_vert(vcount) = cpind; vert_to_seq(cpind) = vcount; vcount = vcount + 1; end if code < 3 & cpind > 1 if code <= 0 fvertex = loopstart; else fvertex = cpind; end thiscurve = [thiscurve; fvertex-1]; degree = length(thiscurve) - 1; bez1 = {'bezier_curve'; [degree]; thiscurve'}; [scrap,sz1] = size(thisedgecurves); thisedgecurves{1,sz1+1} = 'bezier_curve'; thisedgecurves{2,sz1+1} = [degree]; thisedgecurves{3,sz1+1} = thiscurve'; thiscurve = []; if code < 2 [scrap,nume] = size(tedge); tedge{1,ecount+1} = sprintf('e%d', cpind); tedge{2,ecount+1} = {}; tedge{3,ecount+1} = ... {sprintf('v%d', edgestart), sprintf('v%d', fvertex)}; tedge{4,ecount+1} = {}; tedge{5,ecount+1} = thisedgecurves; seq_to_edge(ecount) = cpind; edge_to_seq(cpind) = ecount; rbdry{ecount+1} = sprintf('e%d', cpind); ecount = ecount + 1; thisedgecurves = {}; end end if code == -1 break; end cplist = [cplist,vert']; thiscurve = [thiscurve;cpind-1]; if code < 2 edgestart = cpind; if code < 1 loopstart = cpind; end endendglobal GM_BREP_TYPE_CODEtregion = {'mregion'; {}; rbdry; {}; {}};b = zba({GM_BREP_TYPE_CODE; 2; 2; {}; cplist; tvert; tedge; tregion});% ------------------------------------------------------------------% 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% ------------------------------------------------------------------
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -