Previous Next Up Title Contents General Index Functions Index Bookshelf

1.7.9. TRACÉ D'UN PARALLÉLÉPIPÈDE AVEC UNE VUE EN PARALLÈLE

/* inclusion du fichier contenant les "define" et les types propres à 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};

/* ouverture de PHIGURE et d'un poste de travail de type X-Window (8887) */
	topen_phigure (PDEF_ERR_FILE);
	topen_ws (ws_id, PDEF_ERR_FILE, 8887);

/* définition du domaine cubique centré autour des données */
	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);

/* construction d'un parallélépipède */
	tcube (cube_id, &first_corner, &second_corner);

/* construction du système avec un type de ligne pointillé */
	tcoordinate_system_axis (system_id, &domain_center, &second_corner, "X","Y","Z", .1,.1);
	tset_linetype (system_id, -1, PLINE_DASH);

/* définition de la scène */
	struct_ids[0] = cube_id;
	struct_ids[1] = system_id;
	tscene (scene_id, &struct_id_list, view_ind);

/* définition d'une vue 3D en parallèle*/
	tview3_paral_z_vert (ws_id, view_ind, &view_center, 55., 25., zoom, &viewport);

/* affichage de la scène sur le poste de travail */
	ppost_struct (ws_id, scene_id, 1.0);
	predraw_all_structs (ws_id, PFLAG_ALWAYS);

/* fermeture du poste de travail et de PHIGURE */
	tclose_ws (ws_id);
	tclose_phigure ();

}

Ce programme est identique au n°8, mais les structures sont visualisées avec une vue définie en projection parallèle en remplaçant tview3_perspect_z_vert par tview3_paral_z_vert.


Previous Next Up Title Contents General Index Functions Index Bookshelf