/* $XConsortium: primxf1.pi,v 5.4 94/04/17 20:47:23 hersh 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. ******************************************************************/ ## primxf1.pi - ## Test transformation with different primitives ## modelling : rotation ## view orientation : translation ## view mapping : perspective ## workstation : scaling source macro.pi macro im_xf_test(@msg) im_confirm_point3(xdisplay,xwindow,1,1,rtestpt,1,5,1,@msg); i_pause(); pdel_elem(); endmacro tbegintest("primxf1","Test transformation with different primitives"); # setup: open phigs, open workstation, open structure i_open_phigs(NULL,0) i_open_x_ws(1,&xdisplay,&xwindow,0,0,200,200); popen_struct(1) ppost_struct(1,1,1.0) pset_anno_char_ht(0.03); pset_char_ht(0.03); #initialize matrices for rotation and translation vector = I_Pvec3(0.2, 0.0, 0.0); ptranslate3(&vector, &err, xlate_mtx); im_ifneq(err,0,"ERROR: %d in ptranslate3\n",err); protate_z(0.35, &err, rotate_mtx); im_ifneq(err,0,"ERROR: %d in protote\n",err); # calculate rotated test point testpt = I_Ppoint3(0.5,0.5,0.0); ptran_point3(&testpt,rotate_mtx,&err,&rtestpt); im_ifneq(err,0,"ERROR: %d in ptran_point3\n",err); # initialize view representation win = I_Plimit(0.0,1.0,0.0,1.0); view = I_Plimit3(0.0,1.0,0.0,1.0,0.0,1.0); cliplimit = I_Plimit3(0.0,1.0,0.0,1.0,0.0,1.0); prp = I_Ppoint3(0.0,0.0,4.0); viewmap = I_Pview_map3(win,view,PTYPE_PERSPECT,prp,0.0,0.0,1.0); peval_view_map_matrix3(&viewmap,&err,mapmtx); im_ifneq(err,0,"ERROR: %d in pevalviewmappingtrix3\n",err); viewrep = I_Pview_rep3(xlate_mtx,mapmtx,cliplimit,PIND_CLIP,PIND_CLIP,PIND_CLIP); # initliaize ws viewport wsview = I_Plimit3(0.0,100.0,0.0,100.0,0.0,1.0); # set up ws viewport pset_ws_vp3(1,&wsview); # set up view index and view rep pset_view_rep3(1,1,&viewrep); pset_view_ind(1); # set up local xform pset_local_tran3(rotate_mtx,PTYPE_REPLACE); # draw different primitives # 1. annotation text atxpos1 = I_Ppoint3(0.5,0.5,0.0); atxoffset1 = I_Ppoint3( 0.0,0.0,0.0); panno_text_rel3(&atxpos1,&atxoffset1,"PEX-SI"); im_xf_test("annotation text"); # 2. cell array cols2 = IA_Pcoval(4, PINDIRECT, 0,1,1,0); pt21 = I_Ppoint3(0.5,0.5,0.0); pt22 = I_Ppoint3(0.5,0.4,0.0); pt23 = I_Ppoint3(0.6,0.5,0.0); paral2 = I_Pparal(pt21,pt22,pt23); dim2 = I_Pint_size(2,2); pcell_array3_plus(¶l2,&dim2,PINDIRECT,cols2); im_xf_test("cell array"); # 3. fill area fapts3 = IA_Ppoint3(4, 0.5,0.5,0.0, 0.6,0.5,0.0, 0.6,0.4,0.0, 0.5,0.4,0.0) fa3 = I_Ppoint_list3(4,fapts3); pfill_area3(&fa3); im_xf_test("fill area"); # 4. fill area set pts4 = IA_Ppoint3(4, 0.5,0.5,0.0, 0.6,0.5,1.0, 0.6,0.4,1.0, 0.5,0.4,0.0) fas4 = I_Ppoint_list3(4,pts4); fas4_l = I_Ppoint_list_list3(1,&fas4); pfill_area_set3(&fas4_l); im_xf_test("fill area set"); # 5. fill area set with data ptarr5 = IA_Ppoint3(4, 0.5,0.5,0.0, 0.6,0.5,1.0, 0.6,0.4,1.0, 0.5,0.4,0.0) varr5 = I_Pfacet_vdata_arr3(PVERT_COORD,ptarr5); vlst5 = I_Pfacet_vdata_list3(4,varr5); vdata5 = IA_Pfacet_vdata_list3(1,vlst5); pfill_area_set3_data(PFACET_NONE,PEDGE_NONE,PVERT_COORD,PMODEL_RGB,NULL,1,NULL,vdata5); im_xf_test("fill area set with data"); # 6. nurb curve floatarr6 = IA_Pfloat(7, 0.0,0.0,0.0,0.1,0.2,0.2,0.2); knots6 = I_Pfloat_list(7, floatarr6); cpts6 = IA_Ppoint3(4, 0.5,0.5,0.0, 0.6,0.6,1.0, 0.7,0.6,1.0, 0.8,0.5,0.0); ctlpts6 = I_Ppoint_list34(4,"3D",cpts6); pnuni_bsp_curv(3,&knots6,PNON_RATIONAL,&ctlpts6,0.0,0.2); im_xf_test("nurb curve"); # 7. nurb surface floatarr7 = IA_Pfloat(6, 0.0,0.0,0.0,0.1,0.1,0.1); knots7 = I_Pfloat_list(6, floatarr7); cpts7 = IA_Ppoint3(9, 0.5,0.3,1.0, 0.6,0.35,1.0, 0.7,0.3,1.0, 0.5,0.4,0.5, 0.6,0.45,0.5, 0.7,0.4,0.5, 0.5,0.5,0.0, 0.6,0.55,0.0, 0.7,0.5,0.0); grid7 = I_Ppoint_grid34(3,3,"3D",cpts7); pnuni_bsp_surf(3,3,&knots7,&knots7,PNON_RATIONAL,&grid7,0,NULL) im_xf_test("nurb surface"); # 8. polyline plpts8 = IA_Ppoint3(2, 0.5,0.5,0.0, 0.7,0.7,1.0); pl8 = I_Ppoint_list3(2,plpts8); ppolyline3(&pl8); im_xf_test("polyline"); # 9. polymarker pmpts9 = IA_Ppoint3(2, 0.5,0.5,0.0, 0.7,0.7,0.0); pm9 = I_Ppoint_list3(2,pmpts9); ppolymarker3(&pm9); im_xf_test("polymarker"); # 10. polyline set with data ptarr10 = IA_Ppoint3(2,0.5,0.5,0.0, 0.7,0.7,1.0); lva10 = I_Pline_vdata_arr3(PVERT_COORD,ptarr10); lv10 = I_Pline_vdata_list3(2,lva10); vdata10 = IA_Pline_vdata_list3(1,lv10); ppolyline_set3_data(PVERT_COORD,PMODEL_RGB,1,vdata10); im_xf_test("polyline set with data"); # 11. quad mesh with data dim11 = I_Pint_size(2,2); ptarr11 = IA_Ppoint3(4,0.5,0.5,0.0, 0.6,0.5,0.0, 0.5,0.4,0.0, 0.6,0.4,0.0); vdata11 = I_Pfacet_vdata_arr3(PVERT_COORD, ptarr11); pquad_mesh3_data(PFACET_NONE,PVERT_COORD,PMODEL_RGB,&dim11,NULL,&vdata11); im_xf_test("quad mesh with data"); # 12. triangle strip with data ptarr12 = IA_Ppoint3(3,0.5,0.5,0.0, 0.6,0.6,0.0, 0.7,0.5,1.0); vdata12 = I_Pfacet_vdata_arr3(PVERT_COORD, ptarr12); ptri_strip3_data(PFACET_NONE,PVERT_COORD,PMODEL_RGB,3,NULL,&vdata12); im_xf_test("triangle strip with data"); # 13. set of fill area set with data ia13 = IA_Pint(3,0,1,2); il13 = I_Pint_list(3,ia13); ill13 = I_Pint_list_list(1,&il13); vlist13 = IA_Pint_list_list(1,ill13); ptarr13 = IA_Ppoint3(3, 0.5,0.5,0.0, 0.6,0.6,0.0, 0.7,0.5,1.0); varr13 = I_Pfacet_vdata_arr3(PVERT_COORD, ptarr13); vdata13 = I_Pfacet_vdata_list3(3,varr13); pset_of_fill_area_set3_data(PFACET_NONE,PEDGE_NONE,PVERT_COORD,PMODEL_RGB,1,NULL,NULL,vlist13,&vdata13); im_xf_test("set of fill area set with data"); # 14. text txpos14 = I_Ppoint3( 0.5,0.5,0.0); dir14 = IA_Pvec3(2, 1.0,0.0,0.0, 0.0,1.0,0.0); ptext3(&txpos14,dir14,"PEX-SI"); im_xf_test("text"); tendtest();