📄 display.m
字号:
function obj_display ( input_file_name )%% STLA_DISPLAY displays the faces of a shape defined by an ASCII STL file.%% Usage:%% obj_display ( 'file.obj' )%% Licensing:%% This code is distributed under the GNU LGPL license.%% Modified:%% 27 September 2008%% Author:%% John Burkardt% timestamp ( ); fprintf ( 1, '\n' ); fprintf ( 1, 'OBJ_DISPLAY\n' ); fprintf ( 1, ' MATLAB version\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' Reads an object in an ASCII OBJ file.\n' ); fprintf ( 1, ' Display it as a MATLAB shape.\n' );%% If at least one command line argument, it's the input file name.% if ( nargin < 1 ) fprintf ( 1, '\n' ); fprintf ( 1, 'OBJ_DISPLAY:\n' ); input_file_name = input ( 'Enter the name of the input file:' ); end%% Get sizes.% [ node_num, face_num, normal_num, order_max ] = obj_size ( input_file_name );%% Print the sizes.% obj_size_print ( input_file_name, node_num, face_num, normal_num, order_max );%% Get the data.% [ node_xyz, face_order, face_node, normal_vector, vertex_normal ] = ... obj_read ( input_file_name, node_num, face_num, normal_num, order_max );%% FACE_NODE may contain polygons of different orders.% To make the call to PATCH, we will assume all the polygons are the same order.% To do so, we'll simply "stutter" the first node in each face list.% for face = 1 : face_num face_node(face_order(face)+1:order_max,face) = face_node(1,face); end%% If any node index is still less than 1, set the whole face to 1's.% We're giving up on this presumably meaningless face, but we need to% do it in a way that keeps MATLAB happy!% for face = 1 : face_num for i = 1 : order_max face_node(i,face) = max ( face_node(i,face), 1 ); end end%% Display the shape.% handle = patch ( 'Vertices', node_xyz', 'Faces', face_node' ); set ( handle, 'FaceColor', [0.5, 0.6, 0.8], 'EdgeColor', 'Black' ); axis equal; grid on; xlabel ( '--X axis--' ) ylabel ( '--Y axis--' ) zlabel ( '--Z axis--' )%% The TITLE function will interpret underscores in the title.% We need to unescape such escape sequences!% title_string = s_escape_tex ( input_file_name ); title ( title_string ) fprintf ( 1, '\n' ); fprintf ( 1, 'OBJ_DISPLAY:\n' ); fprintf ( 1, ' Normal end of execution.\n' ); fprintf ( 1, '\n' ); timestamp ( ); returnend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -