⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wiremesh.c

📁 Intro/: Directory containing introductory examples. HelloWorld.c A simple program that draws a bo
💻 C
字号:
#include <phigs.h>			/* get HP-PHIGS definitions for C */#include <stdio.h>			/* get standard I/O definitions */#include <math.h>			/* link with library "-lm" */#define	 deg	*3.14159265358979/180	/* convert degrees to radians */main()					/* file "WireMesh.c" */{    Pint	WorkstnID = 1;		/* workstation identifier */    Pint	ConnID;			/* connection identifier */    Pint	WorkstnType = POIDDX;	/* out/in, direct, dbl bfr, Xwindow */    Pint	TheMesh = 1;		/* structure ID (chosen by user) */    Pvec3	Vector;			/* for various translations, etc. */    static Pfloat UknotVals[6] = {0.0, 0.0, 0.0, 1.0, 1.0, 1.0};    static Pfloat VknotVals[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0};    static Ppoint3	CtrlPts[12] = {	{0.0, 0.0, 0.0}, {0.5, 0.3, 0.0}, {1.0, 0.2, 0.0},	{0.0, 0.1, 0.3}, {0.5, 0.5, 0.3}, {1.0, 0.4, 0.3},	{0.0, 0.3, 0.6}, {0.5, 0.4, 0.6}, {1.0, 0.1, 0.6},	{0.0, 0.0, 0.9}, {0.5, 0.2, 0.9}, {1.0, 0.3, 0.9}};    static Psurf_geom_spline Surface = {	3, 4,	{6, UknotVals}, {8, VknotVals},	{PB_SPLINE_NON_RATIONAL, 3, 4, CtrlPts}};    static Pfloat Approximations[4] = {0.1, 0.1, 0.1, 0.1};    Psurf_approx_crit Approximation;    Pparam_surf_chars SurfaceChars;    Pint	Error;			/* error-return variable */    Pmatrix3	xform;			/* transformation matrix */    Pint	MeshLabel = 1;		/* structure label */    Pint	u, v, I, Iu, Iv;	/* loop control variables */    Pfloat	ThetaMin = 0.0,		/* loop control variables */		ThetaMax = 410,		dTheta = 0.4;    Pfloat	Theta;			/* loop control variable */    Approximation.type = PSURF_APPROX_STEP;    Approximation.data.step_size.sample_size[0] = Approximations[0];    Approximation.data.step_size.sample_size[1] = Approximations[1];    Approximation.data.step_size.sample_size[2] = Approximations[2];    Approximation.data.step_size.sample_size[3] = Approximations[3];    popen_phigs((char *) stderr, 0);	/* errors go to "stderr" */    pescape_u4("/dev/screen/phigs_window", &ConnID);    popen_ws(WorkstnID, (void *) ConnID, WorkstnType);    popen_struct(TheMesh);    /*--- set up transformations -------------------------------------------*/    Vector.delta_x = -0.5, Vector.delta_y = 0.0, Vector.delta_z = -0.5;    ptranslate3(&Vector, &Error, xform);	/* 3D translate to origin */    pset_local_tran3(xform, PTYPE_REPLACE);    Vector.delta_x = 0.7, Vector.delta_y = 0.7, Vector.delta_z = 0.7;    pscale3(&Vector, &Error, xform);		/* 3d scale to 70% */    pset_local_tran3(xform, PTYPE_POSTCONCAT);    protate_x(30 deg, &Error, xform);    pset_local_tran3(xform, PTYPE_POSTCONCAT);    protate_y(0 deg, &Error, xform);    plabel(MeshLabel);    pset_local_tran3(xform, PTYPE_POSTCONCAT);    Vector.delta_x = 0.5, Vector.delta_y = 0.3, Vector.delta_z = 0.5;    ptranslate3(&Vector, &Error, xform);	/* 3D translate to position */    pset_local_tran3(xform, PTYPE_POSTCONCAT);    /*--- draw the b-spline surface ----------------------------------------*/    SurfaceChars.type = PPARAM_SURF_CHARS_INT_EDGE;    pset_param_surf_chars(&SurfaceChars);    pset_surf_approx_crit(&Approximation);    pnon_uniform_b_spline_surf3(&Surface, NULL);    /*--- draw control-point grid ------------------------------------------*/    pset_linetype(PLINE_DOT);    for (u = 0; u < 4; u++) {	for (v = 0; v < 3; v++) {	    I  = u * 3 + v;			/* index of X(u, v)   */	    Iu = (u + 1) * 3 + v;		/* index of X(u+1, v) */	    Iv = u * 3 + v + 1;			/* index of X(u, v+1) */	    if (u < 3)				/* unless on right edge... */		Line(CtrlPts[I].x, CtrlPts[I].y, CtrlPts[I].z,		  CtrlPts[Iu].x, CtrlPts[Iu].y, CtrlPts[Iu].z);	    if (v < 2)				/* unless on bottom edge... */		Line(CtrlPts[I].x, CtrlPts[I].y, CtrlPts[I].z,		  CtrlPts[Iv].x, CtrlPts[Iv].y, CtrlPts[Iv].z);	}    }    pclose_struct();    /*=== rotate the spline surface ========================================*/    ppost_struct(WorkstnID, TheMesh, 1.0);    Theta = ThetaMin;				/* set loop control var. */    while (Theta < ThetaMax) {			/* for each angle... */	popen_struct(TheMesh);	protate_y(Theta deg, &Error, xform);	pset_elem_ptr(1);	pset_elem_ptr_label(MeshLabel);	poffset_elem_ptr(1);	pset_edit_mode(PEDIT_REPLACE);	pset_local_tran3(xform, PTYPE_POSTCONCAT);	pclose_struct();	pupd_ws(WorkstnID, PFLAG_PERFORM);	Theta += dTheta;    }    pclose_ws(WorkstnID);    pclose_phigs();}/****************************************************************************/Line(X1, Y1, Z1, X2, Y2, Z2)float	X1, Y1, Z1, X2, Y2, Z2;		/* "from" point, "to" point */{    Ppoint3		Pts[2];		/* for 3D polyline */    Ppoint_list3	Line;        Pts[0].x = X1;			/* \				*/    Pts[0].y = Y1;			/*  \				*/    Pts[0].z = Z1;			/*   \ put the individual	*/    Pts[1].x = X2;			/*   / values into the arrays	*/    Pts[1].y = Y2;			/*  /				*/    Pts[1].z = Z2;			/* /				*/    Line.num_points = 2;    Line.points = Pts;    ppolyline3(&Line);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -