function hidden_surface_mesh () % Copyright 2000, J.E. Akin. All rights reserved. % ------------------------------------------------------ % 3-D hidden plot of a membrane or shell mesh geometry % ------------------------------------------------------ %? global az el ? these are not changing with new view % c_x = x coordinates of nod_per_el line polygon % c_y = y coordinates of nod_per_el line polygon % msh_typ_nodes = connectivity list for elements, nt x nod_per_el % loop = corners for nod_per_el line polygon % nod_per_el = Nodes per element % np = Number of Points % nt = Number of elements % pre_e = Element items before connectivity list pre_e = 1 post_e = 0 % pre_p = Nodal items before coordinates pre_p = 1 post_p = 1 % msh_bc_xyz = Nodal coordinates (with preceeding data) % t_x = x coordinates of nod_per_el corners % t_y = y coordinates of nod_per_el corners %b if ( nargin == 0 ) %b end % if no arguments % Read coordinate file and connectivity file % integer bc code, real xy pairs for np points (pre_p = 1) load msh_bc_xyz.tmp ; % Set control data: number of points np = size (msh_bc_xyz,1) ; % number of nodal points fprintf ('Read %g mesh coordinate triplets \n', np) ns = size (msh_bc_xyz,2) - pre_p ; % space dimension ns = ns - post_p if ( ns < 3 ) error ('This is not a 3D mesh, use mesh_plot') end % if not 3D data disp(msh_bc_xyz(1:2,pre_p+1:pre_p+3)) % Set control data: number elements load msh_typ_nodes.tmp ; % nod_per_el nodes per element nt = size (msh_typ_nodes,1) ; % number of elements in mesh nod_per_el = size (msh_typ_nodes,2) - pre_e ; %b-1 ; % nodes per elem %b nod_per_el = nod_per_el - post_e ; fprintf ('Read %g elements connections \n', nt) fprintf ('each with %g nodes \n', nod_per_el) disp(msh_typ_nodes(nt, pre_e+1:pre_e+nod_per_el)) x (np) = 0. ; % pre-allocate array x y (np) = 0. ; % pre-allocate array y z (np) = 0. ; % pre-allocate array z t_nodes (nod_per_el) = 0 ; % Optional pre-allocation t_x (nod_per_el) = 0 ; % Optional pre-allocation t_y (nod_per_el) = 0 ; % Optional pre-allocation c_x (nod_per_el + 1) = 0 ; % Optional pre-allocation c_y (nod_per_el + 1) = 0 ; % Optional pre-allocation loop (nod_per_el + 1) = 0 ; % Optional pre-allocation % set constants [loop] = get_El_Loop (nod_per_el) ; % msh_bc_xyz has: pre_p items then: x, y x = msh_bc_xyz (1:np, (pre_p+1)) ; % extract x column y = msh_bc_xyz (1:np, (pre_p+2)) ; % extract y column z = msh_bc_xyz (1:np, (pre_p+3)) ; % extract y column % Initialize plots xmax = max (x) ; xmin = min (x) ; ymax = max (y) ; ymin = min (y) ; zmax = max (z) ; zmin = min (z) ; clf % clear graphics axis ([xmin, xmax, ymin, ymax, zmin, zmax]) % set axes axis('equal') % view([52.5,30]) hold on % hold image for plots xlabel ('X') % add label ylabel ('Y') % add label zlabel ('Z') % add label title (['FEA Surface Mesh Geometry : ', ... int2str(nt),' Elements, ', int2str(np), ... ' Nodes, (', int2str(nod_per_el), ' per Element)']) % Loop over all elements for it = 1:nt ; % Extract corner connectivity %b t_nodes = msh_typ_nodes (it, (pre_e+2):(nod_per_el+pre_e+1)); t_nodes = msh_typ_nodes (it, (pre_e+1):(pre_e+nod_per_el)); if ( all ( t_nodes > 0 ) ) %B % Extract corner coordinates t_x = x (t_nodes) ; % x at those nodes, only t_y = y (t_nodes) ; % y at those nodes, only t_z = z (t_nodes) ; % z at those nodes, only % Plot this polygon c_x = t_x (loop) ; % x for nod_per_el line polygon c_y = t_y (loop) ; % y for nod_per_el line polygon c_z = t_z (loop) ; fill3 (c_x, c_y, c_z, 'w' ) % plot nod_per_el lines end % if all end % for over all elements grid % end % if show labels % -depsc -tiff % for an eps version % print ('-dpsc', ['hidden_surface_mesh']) hold off % v_text = ['Created hidden_surface_mesh.ps']) ; % fprintf (1,'%s', v_text) ; fprintf (1, ' \n' ) % end of hidden_surface_mesh