
/* $XConsortium: modelxf4.pi,v 5.2 94/04/17 20:47:21 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.

******************************************************************/


## modelxf4.pi -  
## Test requirements:
##   Test that the modelling clipping indicator is used to determine
##   whether subsequent output primitives will be clipped against the
##   modelling clipping volume during structure traversal.
##   Also verify that the default modelling clip indicator is PIND_NO_CLIP
#  Setup:
#    Open phigs and a workstation, open and post a structure,
#    set up certain clipping volume that should result in partial clipping
#    of the output fill area.
#  Operations:
#    Render a solid fill area using default clipping indicator - PIND_NO_CLIP.
#    Render a solid fill area using clipping indicator - PIND_CLIP.
#    Render a solid fill area using clipping indicator - PIND_NO_CLIP.
#    The first and third fill areas should appear intact, 
#    the second fill area should be partially clipped. 
#  Verifications:
#    verify the existence of pixels at two sample test points 

source macro.pi

tbegintest("modelxf4","modelling clipping indicator attribute inheritance");

# initialize data for a fillarea and a halfspace, and test point
farea1 = IA_Ppoint(4, 0.25,0.25,  0.25,0.75, 0.75,0.75, 0.75,0.25);
fa1 = I_Ppoint_list(4, farea1);
pt = I_Ppoint(0.5,0.5);
norm = I_Pvec(1.0,0.0);
hs = I_Phalf_space(pt,norm);
hslst = I_Phalf_space_list(1,hs);
testpt1 = I_Ppoint3 (0.3,0.3,0.0);
testpt2 = I_Ppoint3 (0.6,0.6,0.0);

# set up phigs, a workstation , post and open a structure , and certain 
# clipping volume
i_open_phigs(NULL,PDEF_MEM_SIZE);
i_open_x_ws(1,&xdisplay,&xwindow,0,0,200,200);
popen_struct(1);
ppost_struct(1,1,1.0);
pset_model_clip_vol(PMC_REPLACE,&hslst);


# test default indicator == PIND_NO_CLIP
pset_int_style(PSTYLE_SOLID);
pfill_area(&fa1);
im_confirm_point3(xdisplay,xwindow,1,0,testpt1,1,5,1,"default clip ind PIND_NO_CLIP");
im_confirm_point3(xdisplay,xwindow,1,0,testpt2,1,5,1,"default clip ind PIND_NO_CLIP");
i_pause();

# test indicator == PIND_CLIP
pdel_elem();
pset_model_clip_ind(PIND_CLIP);
pfill_area(&fa1);
im_confirm_point3(xdisplay,xwindow,1,0,testpt1,0,5,1,"clip ind PIND_CLIP");
im_confirm_point3(xdisplay,xwindow,1,0,testpt2,1,5,1,"clip ind PIND_CLIP");
i_pause();

# test indicator == PIND_NO_CLIP
pdel_elem();
pdel_elem();
pset_model_clip_ind(PIND_NO_CLIP);
pfill_area(&fa1);
im_confirm_point3(xdisplay,xwindow,1,0,testpt1,1,5,1,"clip ind PIND_NO_CLIP");
im_confirm_point3(xdisplay,xwindow,1,0,testpt2,1,5,1,"clip ind PIND_NO_CLIP");
i_pause();

tendtest();
