[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dennou-ruby:000145] Re: reading binary files



�¸��Ǥ���

 > ���ʤߤ�, ���Υѥå������Ǥ���Ǿ�饤�֥��Τɤ����դ�ޤǻȤ����Ǥ���
 > ����?  grph1 ����?

���Υѥå������Ǥ� grph1 �����Ǥ���
dcl �Υ������ˤ� mksrc.rb �򤫤���С�
grph2 �ʤɤ�Ȥ���Ȼפ��ޤ���

% mksrc.rb $DCLDIR/src/grph2/*/*.f > grph2.c

�ʤɡ���

���������ޤ� ***get �����ޤ����äƤ��ʤ��褦�Ǥ���

***get ��
   lclip=nil   # �������ν������ɬ��
   Dcl.sglget('lclip', lclip)     
�Ȥ����ꡤ
   lclip = Dcl.sglget('lclip')
�Ȥ����ۤ��������Ǥ��礦�͡�

Ʊ�ͤˡ����Ȥ��� sgqwnd �ϡ�
  uxmin, uxmax, uymin, uymax = Dcl.sgqwnd()
�Ǥ��礦����


�Ȥ����ǡ�ź�դ���Ǥϴ�ñ�����ơ�FloatArray �Υ��󥿥ե�������
�狼��ʤ��Ȼפ��ޤ���sgpk03 �����Ĥ��ޤ���

      x = FloatArray.new(N) 
�ˤ����ܤ�������������ǡ�
      Dcl.sgplu(N, x, y)                  
�ʤɤȻȤ��ޤ�����ruby �����̾�� Array �Τ褦�˥��������Ǥ��ޤ���

------------------------------------------------
#!/usr/local/bin/ruby 

require "mcarray"
require "mcdcl"

#     program sgpk03

      N=41
      x = FloatArray.new(N)
      y = FloatArray.new(N)

      dt = 4.0* 3.14159 / (N-1)
      for i in 0...N
        y[i] = Math.sin(dt*i)*0.15
        x[i] = 1.0*i/(N-1)
      end

      Dcl.sgopn(1)

#----------------------------- page 1 ---------------------------------
      Dcl.sgfrm

      Dcl.sgswnd( 0.0,  1.0, -0.8, 0.2)
      Dcl.sgsvpt( 0.15, 0.85, 0.1, 0.9)
      Dcl.sgstrn(1)
      Dcl.sgstrf
      Dcl.slpvpr(1)
      Dcl.sgplu(N, x, y)                   # <-- 1����

      Dcl.sgswnd( 0.0,  1.0, -0.7, 0.3)
      Dcl.sgstrf
      Dcl.sgspli(2)                        # <-- line index ����
      Dcl.sgplu(N, x, y)                   # <-- 2����

      Dcl.sgswnd( 0.0,  1.0, -0.6, 0.4)
      Dcl.sgstrf
      Dcl.sgspli(3)                        # <-- line index ����
      Dcl.sgplu(N, x, y)                   # <-- 3����

      Dcl.sgswnd( 0.0,  1.0, -0.4, 0.6)
      Dcl.sgstrf
      Dcl.sgsplt(2)                        # <-- line type ���� (����)
      Dcl.sgplu(N, x, y)                   # <-- 4����

      Dcl.sgswnd( 0.0,  1.0, -0.3, 0.7)
      Dcl.sgstrf
      Dcl.sgsplt(3)                        # <-- line type ���� (����)
      Dcl.sgplu(N, x, y)                   # <-- 5����

      Dcl.sgswnd( 0.0,  1.0, -0.2, 0.8)
      Dcl.sgstrf
      Dcl.sgsplt(4)                        # <-- line type ���� (��������)
      Dcl.sgplu(N, x, y)                   # <-- 6����

#----------------------------- page 2 ---------------------------------

      Dcl.sgfrm

      Dcl.sgswnd( 0.0,  1.0, -0.8, 0.2)
      Dcl.sgsvpt( 0.15, 0.85, 0.1, 0.9)
      Dcl.sgstrn(1)
      Dcl.sgstrf
      Dcl.slpvpr(1)

      Dcl.sgrset('bitlen', 0.006)          # <-- ��������Ĺ���ѹ�
      Dcl.sgsplt(4)
      Dcl.sgplu(N, x, y)                   # <-- 1����

      Dcl.sgswnd( 0.0,  1.0, -0.6, 0.4)
      Dcl.sgstrf
      Dcl.sgspli(2)

      itype, = ['1111111100100100'].pack("B*").unpack("s")
      Dcl.sgsplt(itype)                    # <-- �ѥ���������
      Dcl.sgplu(N, x, y)                   # <-- 2����

      Dcl.sgswnd( 0.0,  1.0, -0.4, 0.6)
      Dcl.sgstrf
      Dcl.sgiset('nbits', 32)
      itype, = ['10010010011111000111110001111100'].pack("B*").unpack("i")
      Dcl.sgsplt(itype)
      Dcl.sgplu(N, x, y)

      Dcl.sgswnd( 0.0,  1.0, -0.2, 0.8)
      Dcl.sgstrf
      Dcl.sgspli(1)
      Dcl.sgsplt(1)

      n1=N/4-1
      y[n1-1] = 999.0                        # <-- ��»��
      y[n1  ] = 999.0
      y[n1+1] = 999.0

      n2=(n1+1)*3-1
      y[n2-1] = 999.0
      y[n2+1] = 999.0

###   Dcl.gllset('lmiss',true)             # not implimented yet, sorry!!
      Dcl.sgplu(N, x, y)                   # <-- 4����

      Dcl.sgcls