C INTERNATIONAL AVS CENTER C (This disclaimer must remain at the top of all files) C C WARRANTY DISCLAIMER C C This module and the files associated with it are distributed free of charge. C It is placed in the public domain and permission is granted for anyone to use, C duplicate, modify, and redistribute it unless otherwise noted. Some modules C may be copyrighted. You agree to abide by the conditions also included in C the AVS Licensing Agreement, version 1.0, located in the main module C directory located at the International AVS Center ftp site and to include C the AVS Licensing Agreement when you distribute any files downloaded from C that site. C C The International AVS Center, MCNC, the AVS Consortium and the individual C submitting the module and files associated with said module provide absolutely C NO WARRANTY OF ANY KIND with respect to this software. The entire risk as to C the quality and performance of this software is with the user. IN NO EVENT C WILL The International AVS Center, MCNC, the AVS Consortium and the individual C submitting the module and files associated with said module BE LIABLE TO C ANYONE FOR ANY DAMAGES ARISING FROM THE USE OF THIS SOFTWARE, INCLUDING, C WITHOUT LIMITATION, DAMAGES RESULTING FROM LOST DATA OR LOST PROFITS, OR ANY C SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES. C C This AVS module and associated files are public domain software unless C otherwise noted. Permission is hereby granted to do whatever you like with C it, subject to the conditions that may exist in copyrighted materials. Should C you wish to make a contribution toward the improvement, modification, or C general performance of this module, please send us your comments: why you C liked or disliked it, how you use it, and most important, how it helps your C work. We will receive your comments at avs@ncsc.org. C C Please send AVS module bug reports to avs@ncsc.org. C C mod_gen Version 1 C Module Name: "if" (Input) (Subroutine) C Author: Dr. John Tee, Consultant, AVS Inc, UK C Date Created: Tue May 26 08:57:56 1992 C C This file is automatically generated by the Module Generator (mod_gen) C Please do not modify or move the contents of this comment block as C mod_gen needs it in order to read module sources back in. C C input 0 "In" field REQUIRED C output 0 "Outif0" field C output 1 "Outif1" field C param 0 "Flag" toggle 0 0 1 C End of Module Description Comments C **************************************** C Module Specification C **************************************** integer function if_spec() implicit none C IAC CODE CHANGE : include 'avs/avs.inc' INCLUDE '/usr/avs/include/avs.inc' integer in_port, out_port, param external if_compute integer if_compute call AVSset_module_name('if', 'data') call AVSset_module_flags(single_arg_data) C Input Port Specifications in_port = AVScreate_input_port('In', 'field', REQUIRED) C Output Port Specifications out_port = AVScreate_output_port('Outif0', 'field') out_port = AVScreate_output_port('Outif1', 'field') C Parameter Specifications param = AVSadd_parameter('Flag', 'boolean', 0, 0, 1) call AVSconnect_widget(param, 'toggle') call AVSset_compute_proc(if_compute) C ----> START OF USER-SUPPLIED CODE SECTION #2 (ADDITIONAL SPECIFICATION INFO) C <---- END OF USER-SUPPLIED CODE SECTION #2 if_spec = 1 return end C **************************************** C Module Compute Routine C **************************************** integer function if_compute( In, Outif1, Outif0, Flag) implicit none C IAC CODE CHANGE : include 'avs/avs.inc' INCLUDE '/usr/avs/include/avs.inc' integer In integer Outif1 integer Outif0 integer Flag C THIS IS A 'HINTS' AREA - YOU MAY CUT AND PASTE AT WILL FROM IT C integer dimsi, dims0, dims1 dimension dimsi(10), dims0(10), dims1(10) C Output template (copy basic information from input to alloc output) integer template integer comdimi, dsize integer pixptr, iptr, optr0, optr1, optr integer ixs, iys, i, j, k, iargb, iresult C Processing routine integer JTfield_copy_image C C Free old field data if (Outif0 .ne. 0) call AVSfield_free(Outif0) if (Outif1 .ne. 0) call AVSfield_free(Outif1) C C Get select information from the input field C Dimensions of resulting field are the same as input field comdimi = AVSfield_get_int(In, avs_field_ndim) iresult = AVSfield_get_dimensions(In, dimsi) C Build a template from the input field and modify it to help allocate C the output field. Set to 0 to force creation of a template field C structure. template = 0 iresult = AVSfield_make_template(In, template) C Allocate the output field using the template field C This automatically allocates the data array (and points if needed) C copies the provided dimensions into the fields dimensions array C and sets the field description information - uniform, etc. C Free the template when completed. Outif0 = AVSfield_alloc(template, dimsi) Outif1 = AVSfield_alloc(template, dimsi) call AVSfield_free(template) C THIS IS THE END OF THE 'HINTS' AREA. ADD YOUR OWN CODE BETWEEN THE C FOLLOWING COMMENTS. THE CODE YOU SUPPLY WILL NOT BE OVERWRITTEN. C ----> START OF USER-SUPPLIED CODE SECTION #3 (COMPUTE ROUTINE BODY) C This doesn't seem to work (perhaps because it is for coordinates only) C - there must be a similar routine i(AVSfield_copy_data?) which does! C if(flag .eq. 0)iresult = AVSfield_copy_points(In, Outif0) C if(flag .eq. 1)iresult = AVSfield_copy_points(In, Outif1) C In the mean-time, try copying bytes, at the expense of speed and generality ixs = dimsi(1) iys = dimsi(2) iptr = AVSfield_data_ptr(In) if(flag.eq.0)optr = AVSfield_data_ptr(Outif0) write(*,*)'optr=',optr,'flag=',flag if(flag.eq.1)optr = AVSfield_data_ptr(Outif1) write(*,*)'optr=',optr,'flag=',flag C iresult = JTfield_copy_image(iptr, optr, ixs, iys) write(*,*) 'copy_image: optr,ixs,iys',optr,ixs,iys do j=1, iys pixptr = (j-1) * ixs * 4 do i=1,ixs do iargb=0, 3 k = AVSload_byte(iptr,pixptr) call AVSstore_byte (optr, pixptr, k) pixptr = pixptr + 1 if(ixs.eq.100)write(*,*)k enddo enddo enddo C <---- END OF USER-SUPPLIED CODE SECTION #3 if_compute = 1 return end C ********************************************************************** C Initialization for modules contained in this file. C ********************************************************************** subroutine AVSinit_modules C IAC CODE CHANGE : include 'avs/avs.inc' INCLUDE '/usr/avs/include/avs.inc' external if_spec integer if_spec call AVSmodule_from_desc(if_spec) end C ----> START OF USER-SUPPLIED CODE SECTION #4 (SUBROUTINES, FUNCTIONS, UTILITY ROUTINES) integer function JTfield_copy_image(iptr, optr, ixs, iys) integer ixs, iys, iargb, i, j, k, pixptr integer iptr, optr write(*,*) 'copy_image: optr,ixs,iys',optr,ixs,iys do j=1, iys pixptr = (j-1) * ixs * 4 do i=1,ixs do iargb=0, 3 k = AVSload_byte(iptr,pixptr) call AVSstore_byte (optr, pixptr, k) pixptr = pixptr + 1 enddo enddo enddo return end C <---- END OF USER-SUPPLIED CODE SECTION #4