/* $XConsortium: nurbsc1.pi,v 5.2 94/04/17 20:48:53 rws Exp $ */ /***************************************************************** Copyright (c) 1989, 1990, 1991,1990 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. Copyright (c) 1989, 1990, 1991,1990 by Sun Microsystems, Inc. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Sun Microsystems, and the X Consortium, not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ ## nurbsc1.pi ## test nurbs curve geometry and line attributes ## . order 3 ## . order 4 ## . multiple knots ## . multiple control points ## . rational/nonrational curves ## . line width ## . line type ## . line colour index ## . line colour source macro.pi tbegintest("nurbsc1","nurb curve geometry and line attributes"); # initialize: nurbs curve data structures and colour data yellow = I_Pgcolr(PMODEL_RGB,1.0,1.0,0.0); # order 3, 3 ctlr pts, rational, w=1 for all points fa3 = IA_Pfloat(6, 0.0,0.0, 0.0,0.1, 0.1,0.1); knots3 = I_Pfloat_list(6, fa3); pts31 = IA_Ppoint3(3, 0.1,0.1,0.0, 0.2,0.2,0.0, 0.3,0.1,0.0); cpts31 = I_Ppoint_list34(3,"3D",pts31); # order 3, 3 ctlr pts, rational varying w's pts32 = IA_Ppoint4(3, 0.1,0.2,0.0,1.0, 0.2,0.3,0.0,0.7, 0.3,0.2,0.0,1.2); cpts32 = I_Ppoint_list34(3,"4D",pts32); # order 4, 6 ctlr pts fa41 = IA_Pfloat(10, 0.0,0.0,0.0, 0.0,0.1,0.2,0.3, 0.3,0.3,0.3); knots41 = I_Pfloat_list(10, fa41); pts41 = IA_Ppoint3(6, 0.4,0.2,0.0, 0.5,0.3,0.0, 0.6,0.2,0.0, 0.7,0.1,0.0, 0.8,0.2,0.0, 0.9,0.3,0.0); cpts41 = I_Ppoint_list34(6,"3D",pts41); # order 4, 6 ctlr pts, multiple knots 2 fa42 = IA_Pfloat(10, 0.0,0.0,0.0, 0.0,0.1,0.1,0.2, 0.2,0.2,0.2); knots42 = I_Pfloat_list(10, fa42); pts42 = IA_Ppoint3(6, 0.4,0.3,0.0, 0.5,0.4,0.0, 0.6,0.3,0.0, 0.7,0.2,0.0, 0.8,0.3,0.0, 0.9,0.4,0.0); cpts42 = I_Ppoint_list34(6,"3D",pts42); # order 4, 8 ctlr pts, multiple knots 1 fa41 = IA_Pfloat(12, -0.3,-0.2,-0.1, 0.0,0.1,0.2,0.3,0.4,0.5, 0.6,0.7,0.8); knots41 = I_Pfloat_list(12, fa41); pts41 = IA_Ppoint3(8, 0.4,0.1,0.0, 0.4,0.2,0.0, 0.5,0.2,0.0, 0.5,0.1,0.0, 0.6,0.1,0.0, 0.7,0.2,0.0, 0.8,0.2,0.0, 0.8,0.1,0.0); cpts41 = I_Ppoint_list34(8,"3D",pts41); # order 4, 8 ctlr pts, multiple knots 2 fa42 = IA_Pfloat(12, -0.3,-0.2,-0.1, 0.0,0.1,0.1,0.1,0.2,0.3, 0.4,0.5,0.6); knots42 = I_Pfloat_list(12, fa42); pts42 = IA_Ppoint3(8, 0.4,0.2,0.0, 0.4,0.3,0.0, 0.5,0.3,0.0, 0.5,0.2,0.0, 0.6,0.2,0.0, 0.7,0.3,0.0, 0.8,0.3,0.0, 0.8,0.2,0.0); cpts42 = I_Ppoint_list34(8,"3D",pts42); # order 4, 8 ctlr pts, multiple knots 3 fa43 = IA_Pfloat(12, -0.3,-0.2,-0.1, 0.0,0.1,0.1,0.1,0.1,0.2, 0.3,0.4,0.5); knots43 = I_Pfloat_list(12, fa43); pts43 = IA_Ppoint3(8, 0.4,0.3,0.0, 0.4,0.4,0.0, 0.5,0.4,0.0, 0.5,0.3,0.0, 0.6,0.3,0.0, 0.7,0.4,0.0, 0.8,0.4,0.0, 0.8,0.3,0.0); cpts43 = I_Ppoint_list34(8,"3D",pts43); # order 4, 5 ctlr pts, multiple control points 1 fa44 = IA_Pfloat(9, 0.0,0.1,0.2, 0.3,0.4,0.5, 0.6,0.7,0.8); knots44 = I_Pfloat_list(9, fa44); pts44 = IA_Ppoint3(5, 0.4,0.6,0.0, 0.5,0.4,0.0, 0.6,0.6,0.0, 0.7,0.4,0.0, 0.8,0.6,0.0); cpts44 = I_Ppoint_list34(5,"3D",pts44); # order 4, 5 ctlr pts, multiple control points 2 fa45 = IA_Pfloat(9, 0.0,0.1,0.2, 0.3,0.4,0.5, 0.6,0.7,0.8); knots45 = I_Pfloat_list(9, fa45); pts45 = IA_Ppoint3(5, 0.4,0.8,0.0, 0.5,0.6,0.0, 0.5,0.6,0.0, 0.6,0.8,0.0, 0.7,0.6,0.0); cpts45 = I_Ppoint_list34(5,"3D",pts45); # order 4, 5 ctlr pts, multiple control points 3 fa46 = IA_Pfloat(9, 0.0,0.1,0.2, 0.3,0.4,0.5, 0.6,0.7,0.8); knots46 = I_Pfloat_list(9, fa46); pts46 = IA_Ppoint3(5, 0.4,1.0,0.0, 0.5,0.8,0.0, 0.5,0.8,0.0, 0.5,0.8,0.0, 0.6,1.0,0.0); cpts46 = I_Ppoint_list34(5,"3D",pts46); # setup: open phigs, workstation, open and post a structure i_open_phigs(NULL,0); i_open_x_ws(1,&xdisplay,&xwindow,0,0,200,200); popen_struct(1); #order 3 pset_curve_approx(PCURV_CONSTANT_PARAMETRIC_BETWEEN_KNOTS,5.0); #non-rational pnuni_bsp_curv(3,&knots3,PNON_RATIONAL,&cpts31,0.0,0.1) #rational pnuni_bsp_curv(3,&knots3,PRATIONAL,&cpts32,0.0,0.1) #order 4 #mutilple knots test: 1,2,3 pset_line_colr(&yellow); pnuni_bsp_curv(4,&knots41,PNON_RATIONAL,&cpts41,0.0,0.5) pset_line_colr_ind(4); pnuni_bsp_curv(4,&knots42,PNON_RATIONAL,&cpts42,0.0,0.3) pnuni_bsp_curv(4,&knots43,PNON_RATIONAL,&cpts43,0.0,0.2) #mutilple control points test: 1,2,3 pnuni_bsp_curv(4,&knots46,PNON_RATIONAL,&cpts46,0.3,0.5) pset_linewidth(5.0); pnuni_bsp_curv(4,&knots45,PNON_RATIONAL,&cpts45,0.3,0.5) pset_linetype(PLINE_DOT); pnuni_bsp_curv(4,&knots44,PNON_RATIONAL,&cpts44,0.3,0.5) ppost_struct(1,1,1.0); # verify image i_check_image("nurbsc1",xdisplay,xwindow,0,0,199,199, "nurbs curve geometry and line attributes"); im_def_grid(); i_pause(); tendtest();