?? gmrndcolor.m
字號:
function a = gmrndcolor(b, dimtocolor);% gmrndcolor: assign random colors to faces of a brep% a = gmrndcolor(b {, dimtocolor})% This function assigns a random sequence of colors chosen from% a pallette of about 20 colors to brep b, and returns the colored brep as% a. Faces already colored are not recolored. The second optional% argument tells which dimension of faces should be colored.% The default for the second argument is 1 less than the embedded dimension% of the brep, or its gdim, whichever is smaller.if ~isa(b,'zba') error('Object passed to gmrndcolor not a zba');endif length(b) < 1 error('Object passed to gmrndcolor not a brep');endglobal GM_BREP_TYPE_CODEif ~strcmpi(double(b{0}), GM_BREP_TYPE_CODE) error('Object passed to gmrndcolor not a brep');endgdim = double(b{1});di = double(b{2});if nargin < 2 dimtocolor = min(di - 1, gdim);endif (dimtocolor < 0 | dimtocolor > gdim) error('2nd argument must be between 0 and intrinsic dim')end[scrap,numface] = size(b{5 + dimtocolor});color = [0, 0, 00, 0, 0.40, 0, .90, 0.4, 00, 0.4, 0.40, 0.4, 0.90, 0.9, 00, 0.9, 0.40, .9, .90.4, 0, 00.4, 0, 0.40.4, 0, 0.90.4, 0.4, 00.4, 0.4, 0.40.4, 0.4, 0.90.4, 0.9, 00.4, 0.9, 0.40.4, 0.9, 0.90.9, 0, 00.9, 0, 0.40.9, 0, 0.90.9, 0.4, 00.9, 0.4, 0.40.9, 0.4, 0.90.9, 0.9, 00.9, 0.9, 0.4];[numcolors,scrap] = size(color);[scrap,permut]=sort(rand(numcolors,1));color = color(permut,:);cnum = 1;a = b;for face = 0 : numface - 1; [scrap,numpv] = size(b{5+dimtocolor}{1,face}); colorfound = 0; for pvind = 0 : numpv - 1 if strcmpi(double(b{5+dimtocolor}{1,face}{0,pvind}), 'color') colorfound = 1; break; end end if ~colorfound a{5 + dimtocolor}{1,face}{0,numpv} = 'color'; a{5 + dimtocolor}{1,face}{1,numpv} = ... sprintf('(%f %f %f 1)', color(cnum,1), color(cnum,2), color(cnum,3)); end cnum = cnum + 1; if cnum > numcolors cnum = 1; endend% ------------------------------------------------------------------% 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 + -