description of the 3D entities properties
The Surface entity is a leaf of the graphics entities hierarchy. Two classes appears under this type of entity : Plot3d and Fac3d according to the plotting function or the way data is entered. Fac3d and Plo3d entities are similar but Fac3d is more complete and accept more options than Plot3d. To always have Fac3d entities, simply use genfac3d to pre-build matrices before using plot3d or use the surf command.
Here are the properties contained in a surface entity:
parent: | This property contains the handle of the parent. The parent of the surface entity should be of type “Axes” or “Compound”. |
---|
: :color_flag: This field is used to specify the algorithm used to set facets’ colors. Not that the rules on color_mode, foreground and hiddencolor are still applied to this case.
color_flag == 0
- All facets are painted using the color index and method defined by color_mode (see above).
color_flag == 1
- All facets are painted using one color index per facet proportional to z. The minimum z value is painted using the index 1 color while the maximum z value is painted using highest color index. The edges of the facets can be additionnaly drawn depending on the value of color_mode (see above).
The 3 remaining cases ( color_flag == 2,3 or 4 )are only available only with Fac3d entity. Then, the data.color value is used to set colors for facets (indices in the current colormap) if it exists. If not, the current color_mode is used to paint the facets.
color_flag == 2 (‘flat’ shading)
- All facets are painted using the color index given in the data.color property (one color per facet is needed). Two cases are then possible :
- data.color contains a color vector : if color(i) is positive it gives the color of facet i and the boundary of the facet is drawn with current line style and color. If color(i) is negative, color id -color(i) is used and the boundary of the facet is not drawn. data.color contains a color matrix of size (nf,n) where n stands for the number of facets and nf for the number of points defining the polygonal facet. For the nf vertices defining each facet, the algorithm computes an average value of the color index (from the matrix color index) : the nf vertices of the same facet will have the same color index value.
color_flag == 3 (‘interpolated’ shading)
- Facets painting results of interpolation of vertices colors. The indices of vertices color are given in the data.color property (one color per vertex is needed). Two cases are possible :
- data.color contains a colors vector : then, there are too few data to complete the interpolated shading mode. Indeed, a color matrix of size (nf,n) (where n stands for the number of facets and nf for the number of points defining the polygonal facet) is needed to perform this operation. For each facet, the algorithm copies the single color index value of the facet into the nf color indexes vertices defining the facet’s boundary. data.color contains a color matrix of size (nf,n) (see upper for nf and n definitions), the interpolated shading mode can be completed normally using those color indexes.
color_flag == 4 (Matlab-like ‘flat’ shading)
- Same as color_flag==2 with a slight difference when data.color is a matrix. All facets are painted using the color index given in the data.color property (one color per facet is needed). Two cases are then possible :
- data.color contains a color vector : if color(i) is positive it gives the color of facet i and the boundary of the facet is drawn with current line style and color. If color(i) is negative, color id -color(i) is used and the boundary of the facet is not drawn. data.color contains a color matrix of size (nf,n) where n stands for the number of facets and nf for the number of points defining the polygonal facet. For the nf vertices defining each facet, the algorithm takes the color of the first vertex defining the patch (facet).
: :clip_state: This field contains the clip_state property value for the surface. It should be :
- “off” this means that the surface is not clipped.
- “clipgrf” this means that the surface is clipped outside the Axes box.
- “on” this means that the surface is clipped outside the rectangle given by property clip_box.
:
//create a figure
t=[0:0.3:2*%pi]'; z=`sin`_(t)*`cos`_(t');
[xx,yy,zz]=`genfac3d`_(t,t,z);
`plot3d`_([xx xx],[yy yy],`list`_([zz zz+4],[4*`ones`_(1,400) 5*`ones`_(1,400)]))
h=`get`_("hdl") //get handle on current entity (here the surface)
a=`gca`_(); //get current axes
a.rotation_angles=[40,70];
a.grid=[1 1 1];
//make grids
a.data_bounds=[-6,0,-1;6,6,5];
a.axes_visible="off";
//axes are hidden a.axes_bounds=[.2 0 1 1];
f=`get`_("current_figure");
//get the handle of the parent figure
f.color_map=`hotcolormap`_(64);
//change the figure colormap
h.color_flag=1;
//color according to z
h.color_mode=-2;
//remove the facets boundary
h.color_flag=2;
//color according to given colors
h.data.color=[1+`modulo`_(1:400,64),1+`modulo`_(1:400,64)];
//shaded
h.color_flag=3;
`scf`_(2); // creates second window and use surf command
`subplot`_(211)
`surf`_(z,'cdata_mapping','direct','facecol','interp')
`subplot`_(212)
`surf`_(t,t,z,'edgeco','b','marker','d','markersiz',9,'markeredg','red','markerfac','k')
e=`gce`_();
e.color_flag=1 // color index proportional to altitude (z coord.)
e.color_flag=2; // back to default mode
e.color_flag= 3; // interpolated shading mode (based on blue default color because field data.color is not filled)