Previous Next Up Title Contents Index Functions Index Top Library

1.7.9. DRAWING A PARALLELEPIPED WITH A PARALLEL VIEW

/* include file containing the "define" and types specific to PHIGURE */
#include <phigure.h>

main () {

	Pfloat zoom=0.8, xmin,xmax,xmid, ymin,ymax,ymid, zmin,zmax,zmid,
	x_size,y_size,z_size,size;
	Pint ws_id = 1, view_ind = 1, scene_id = 10, cube_id = 11, system_id=12;

	static Plimit3 viewport = {0.,1., 0., 1., 0.,1.}, domain;
	static Ppoint3 first_corner={10.,10.,5.},second_corner={20.,30.,35.},
	domain_center={15.,20.,20.}, view_center={0.5,0.5,0.5};

	static Pint struct_ids[2];
	static Pint_list struct_id_list = {2, struct_ids};

/* open PHIGURE and an X-Window type workstation (8887) */
	topen_phigure (PDEF_ERR_FILE);
	topen_ws (ws_id, PDEF_ERR_FILE, 8887);

/* define cubic domain centered around data */
	xmin = first_corner.x; xmax = second_corner.x; xmid = (xmin+xmax)/2.; x_size= xmax-xmin;
	ymin = first_corner.y; ymax = second_corner.y; ymid = (ymin+ymax)/2.; y_size= ymax-ymin;
	zmin = first_corner.z; zmax = second_corner.z; zmid = (zmin+zmax)/2.; z_size= zmax-zmin;
	size = (x_size > y_size) ? x_size : y_size;
	size = (size > z_size) ? size/2.0 : z_size/2.0;
	domain.x_min = xmid - size; domain.x_max = xmid + size;
	domain.y_min = ymid - size; domain.y_max = ymid + size;
	domain.z_min = zmid - size; domain.z_max = zmid + size;
	tdomain3 (&domain);

/* build parallelepiped */
	tcube (cube_id, &first_corner, &second_corner);

/* build system with a type of dotted line */
	tcoordinate_system_axis (system_id, &domain_center, &second_corner, "X","Y","Z", .1,.1);
	tset_linetype (system_id, -1, PLINE_DASH);

/* define scene */
	struct_ids[0] = cube_id;
	struct_ids[1] = system_id;
	tscene (scene_id, &struct_id_list, view_ind);

/* define 3D view in parallel*/
	tview3_paral_z_vert (ws_id, view_ind, &view_center, 55., 25., zoom, &viewport);

/* display scene on workstation */
	ppost_struct (ws_id, scene_id, 1.0);
	predraw_all_structs (ws_id, PFLAG_ALWAYS);

/* close workstation and PHIGURE */
	tclose_ws (ws_id);
	tclose_phigure ();

}

This program is identical to n°8, except that the structures are displayed in parallel projection by replacing tview3_perspect_z_vert with tview3_paral_z_vert.


Previous Next Up Title Contents Index Functions Index Top Library