Home > matGeom > graphs > drawSquareMesh.m

drawSquareMesh

PURPOSE ^

DRAWSQUAREMESH Draw a 3D square mesh given as a graph.

SYNOPSIS ^

function varargout = drawSquareMesh(nodes, edges, faces, varargin) %#ok

DESCRIPTION ^

DRAWSQUAREMESH Draw a 3D square mesh given as a graph.

   drawSquareMesh(NODES, EDGES, FACES)
   Draw the mesh defined by NODES, EDGES and FACES. FACES must be a N-by-4
   array of vertex indices.

   See also
   boundaryGraph, drawGraph

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = drawSquareMesh(nodes, edges, faces, varargin) %#ok<INUSL>
0002 %DRAWSQUAREMESH Draw a 3D square mesh given as a graph.
0003 %
0004 %   drawSquareMesh(NODES, EDGES, FACES)
0005 %   Draw the mesh defined by NODES, EDGES and FACES. FACES must be a N-by-4
0006 %   array of vertex indices.
0007 %
0008 %   See also
0009 %   boundaryGraph, drawGraph
0010 
0011 % ------
0012 % Author: David Legland
0013 % E-mail: david.legland@inrae.fr
0014 % Created: 2004-06-28
0015 % Copyright 2004-2024 INRA - TPV URPOI - BIA IMASTE
0016 
0017 % input size check up
0018 if size(faces, 2) ~= 4
0019     error('Requires a face array with 4 columns');
0020 end
0021 
0022 % number of faces
0023 Nf = size(faces, 1);
0024 
0025 % allocate memory for vertex coordinates
0026 px = zeros(4, Nf);
0027 py = zeros(4, Nf);
0028 pz = zeros(4, Nf);
0029 
0030 % initialize vertex coordinates of each face
0031 for f = 1:Nf
0032     face = faces(f, 1:4);
0033     px(1:4, f) = nodes(face, 1);
0034     py(1:4, f) = nodes(face, 2);
0035     pz(1:4, f) = nodes(face, 3);
0036 end
0037 
0038 p = patch(px, py, pz, 'r');
0039 
0040 if nargout > 0
0041     varargout = {p};
0042 end

Generated on Thu 21-Nov-2024 11:30:22 by m2html © 2003-2022