?? test9.m
字號:
% QMG test 9: an object like a hex nut with a triangular crack.% Make the brep 'from scratch'.% get a 6-segment circle approximation.global GM_BREP_TYPE_CODEhexobj = zba({GM_BREP_TYPE_CODE; 3; 3; {}; zeros(3,75); ... cell(5,15); cell(5,23); cell(5,10); cell(5,1)});[nodes1, scrap] = gm_circ_approx(0, 2*pi, 6);% make a list of control points for the object.% Control pts 0-17 are 18 control points for the inner circle% of the bottom surfacenheight = .3;hexobj{4}(:,0:17) = [nodes1(1:18,:)'; -nheight*ones(1,18)];% Control pts 18-35 are 18 control points for the inner circle% of the top surfacehexobj{4}(:,18:35) = [nodes1(1:18,:)'; nheight*ones(1,18)];% Control pts 36-53 are 18 control points for the outer hexagon% of the bottom surfaceow = 1.7;cos1 = ow * cos((0:5) * 2 * pi / 6);sin1 = ow * sin((0:5) * 2 * pi / 6);cos2 = ow * cos((1:6) * 2 * pi / 6);sin2 = ow * sin((1:6) * 2 * pi / 6);hexobj{4}(:,36:3:53) = [cos1; sin1; -nheight*ones(1,6)];hexobj{4}(:,37:3:53) = ... [2*cos1/3 + cos2/3; 2*sin1/3 + sin2/3; -nheight*ones(1,6)];hexobj{4}(:,38:3:53) = ... [cos1/3 + 2*cos2/3; sin1/3 + 2*sin2/3; -nheight*ones(1,6)];% Control pts 54-71 are 18 control points for the outer hexagon% of the top surfacehexobj{4}(:,54:71) = ... [double(hexobj{4}(0:1,36:53)); nheight*ones(1,18)];% Control pts 72-74 are the control points bounding the crack.hexobj{4}(:,72:74) = [ -1.3, 0, 0 -1.1, 0.05, 0 -1.23, .17, .05]';% Create the list of topological vertices -- 6 on top and 6 on the bottom% to bound the two hexagons.for i = 0 : 11 if i < 6 hexobj{5}{0,i} = sprintf('vbottom%d',i); else hexobj{5}{0,i} = sprintf('vtop%d', i - 6); end hexobj{5}{1,i} = {}; hexobj{5}{2,i} = {}; hexobj{5}{3,i} = {}; hexobj{5}{4,i} = cell(3,1); hexobj{5}{4,i}{0} = 'vertex'; hexobj{5}{4,i}{1} = []; hexobj{5}{4,i}{2} = 36 + 3 * i;end% Topological vertices bounding the crackfor i = 12 : 14 hexobj{5}{0,i} = sprintf('vcrk%d', i - 12); hexobj{5}{1,i} = {}; hexobj{5}{2,i} = {}; hexobj{5}{3,i} = {}; hexobj{5}{4,i} = cell(3,1); hexobj{5}{4,i}{0} = 'vertex'; hexobj{5}{4,i}{1} = []; hexobj{5}{4,i}{2} = i + 60;end % Create the list of topological edges -- 6 on top, 6 on the bottom,% and 6 on the side to bound the two hexagons and side faces,% plus two circular curves and three edges bounding the crack.% edges for bottom and top hexesfor i = 0 : 11 if i < 6 hexobj{6}{0,i} = sprintf('ebottom%d',i); else hexobj{6}{0,i} = sprintf('etop%d', i - 6); end nexti = i + 1; if rem(nexti,6) == 0 nexti = nexti - 6; end hexobj{6}{1,i} = {}; if (i < 6) hexobj{6}{2,i} = {sprintf('vbottom%d', i), sprintf('vbottom%d',nexti)}; else hexobj{6}{2,i} = {sprintf('vtop%d', i - 6), sprintf('vtop%d',nexti - 6)}; end hexobj{6}{3,i} = {}; hexobj{6}{4,i} = cell(3,1); hexobj{6}{4,i}{0} = 'bezier_curve'; hexobj{6}{4,i}{1} = 1; hexobj{6}{4,i}{2} = [36 + i*3, 36 + nexti*3];end% edges connecting top and bottom hexfor i = 12 : 17 hexobj{6}{0,i} = sprintf('eside%d', i - 12); hexobj{6}{1,i} = {}; hexobj{6}{2,i} = {sprintf('vbottom%d', i - 12), sprintf('vtop%d', i - 12)}; hexobj{6}{3,i} = {}; hexobj{6}{4,i} = cell(3,1); hexobj{6}{4,i}{0} = 'bezier_curve'; hexobj{6}{4,i}{1} = 1; hexobj{6}{4,i}{2} = [i*3,i*3+18];end% two circular edgesfor i = 18 : 19 if i == 18 hexobj{6}{0,i} = 'ebottomcirc'; b1 = 0; else hexobj{6}{0,i} = 'etopcirc'; b1 = 18; end hexobj{6}{1,i} = {}; hexobj{6}{2,i} = {}; hexobj{6}{3,i} = {}; hexobj{6}{4,i} = cell(3,6); for j = 0 : 5 nextj = rem(j + 1,6); hexobj{6}{4,i}{0,j} = 'bezier_curve'; hexobj{6}{4,i}{1,j} = 3; hexobj{6}{4,i}{2,j} = [3*j+b1,3*j+b1+1,3*j+b1+2,3*nextj+b1]; endend % crackfor i = 20 : 22 hexobj{6}{0,i} = sprintf('ecrk%d', i - 20); hexobj{6}{1,i} = {}; hexobj{6}{2,i} = {sprintf('vcrk%d', i - 20), ... sprintf('vcrk%d', rem(i - 19,3))}; hexobj{6}{3,i} = {}; hexobj{6}{4,i} = cell(3,1); hexobj{6}{4,i}{0} = 'bezier_curve'; hexobj{6}{4,i}{1} = 1; hexobj{6}{4,i}{2} = [i + 52, rem(i - 19,3) + 72];end% Make the topological surfaces. There is one on bottom, one on top,% one for the inside, six for the outside, and one for the crack.% bottom and top surfacesfor i = 0 : 1 if i == 0 word1 = 'bottom'; b1 = 0; else ,... word1 = 'top'; b1 = 18; end ,... hexobj{7}{0,i} = sprintf('s_%s', word1); hexobj{7}{1,i} = {}; hexobj{7}{2,i} = cell(1,7); hexobj{7}{2,i}{0} = sprintf('e%scirc', word1); for j = 1 : 6 hexobj{7}{2,i}{j} = sprintf('e%s%d', word1, j - 1); end hexobj{7}{3,i} = {}; hexobj{7}{4,i} = cell(3,6); for j = 0 : 5 nextj = rem(j + 1, 6); hexobj{7}{4,i}{0,j} = 'bezier_quad'; hexobj{7}{4,i}{1,j} = [3,1]; hexobj{7}{4,i}{2,j} = [... b1 + 36 + 3*j, b1 + 37 + 3*j, b1 + 38 + 3*j, b1 + 36 + 3*nextj, ... b1 + 3*j, b1 + 1 + 3*j, b1 + 2 + 3*j, b1 + 3*nextj]; endend% inner surfacehexobj{7}{0,2} = 's_inner';hexobj{7}{1,2} = {};hexobj{7}{2,2} = {'ebottomcirc', 'etopcirc'};hexobj{7}{3,2} = {};hexobj{7}{4,2} = cell(3,6);for j = 0 : 5 nextj = rem(j+1,6); hexobj{7}{4,2}{0,j} = 'bezier_quad'; hexobj{7}{4,2}{1,j} = [3,1]; hexobj{7}{4,2}{2,j} = [... 3*j, 3*j+1, 3*j+2, 3*nextj, ... 3*j+18,3*j+19,3*j+20,3*nextj+18];end% six outer surfacesfor i = 3 : 8 i0 = i - 3; i1 = rem(i - 2,6); hexobj{7}{0,i} = sprintf('s_outer%d', i0); hexobj{7}{1,i} = {}; hexobj{7}{2,i} = {sprintf('ebottom%d', i0), sprintf('etop%d', i0), ... sprintf('eside%d', i0), sprintf('eside%d', i1)}; hexobj{7}{3,i} = {}; hexobj{7}{4,i} = cell(3,1); hexobj{7}{4,i}{0} = 'bezier_quad'; hexobj{7}{4,i}{1} = [1,1]; hexobj{7}{4,i}{2} = [3*i0+36,3*i1+36,3*i0+54,3*i1+54];end% crack surfacehexobj{7}(:,9) = { 'crack' {} {'ecrk0', 'ecrk1', 'ecrk2'} {} {'bezier_triangle'; 1; [72,73,74]}};% chamberhexobj{8}(:,0) = { 'hexnutcrack' {} {'s_bottom', 's_top', 's_inner', 's_outer0', 's_outer1', ... 's_outer2', 's_outer3', 's_outer4', 's_outer5', 'crack', 'crack'} {} {}};hexobj = gmrndcolor(hexobj);show = 0;global interactiveif length(interactive) > 0 show = 1;endmesh = gmmeshgen(hexobj, 'show', show, 'tol', 1e-12);[hexobj2, mesh2] = gmdouble(hexobj, {'*'}, mesh);asp = gmchecktri(hexobj2, mesh2);[scrap, numvtx] = size(mesh2{4});global aspprodglobal meshsizesumif length(aspprod) > 0, ... aspprod = aspprod * asp;, ... meshsizesum = meshsizesum + numvtx;, ...end% ------------------------------------------------------------------% 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 + -