File: demo_cellule.sci

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (142 lines) | stat: -rw-r--r-- 3,990 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//  PROGRAMME DA4-11 : Structure dynamique A : division sur place de quasi-carrs sans effet d'chelle
//  PROGRAM   DA4-11 : Dynamical stucture A :  division on place of quasi-squares without scale effects
//  Version 4.3 du 3 novembre 2005
//  Copyright Jacques-Deric Rouault
//  Designed for Scilab 3.1.1 & 4.0 under Windows XP & Linux
// Modified by Jean-Baptiste Silvy for the 17/11/2005 demo.

function demo_cellule()
demo_help demo_cellule

clear;
mprintf ("\nPROGRAMME DA4-11 : Structure dynamique A sur quasi-carrs sans adresse\n");
mprintf ("PROGRAM DA4-11 : Dynamical stucture A on quasi-squares without adresses\n");
racine_prog = "DA4-11";
ndivi=13; // Nombre de divisions
long =5000; // Longueur du rectangle initial
haut =3700; // Largeur du rectangle initial
ncoulmax = 32;

// ETAPE/STEP 01 : REPERTOIRE DE TRAVAIL / WORKING DIRECTORY
//[fsci,erreur] = mopen (racine_prog + ".sci","r");
//repertoire_prog = getcwd ();
//if erreur<>0 then
//  repertoire_prog=tk_getdir(title="REPERTOIRE DE L''APPLICATION\nAPPLICATION DIRECTORY");
//  chdir (repertoire_prog);
//  [fsci,erreur] = mopen (racine_prog + ".sci","r");
//  if erreur<>0 then 
//    mprintf ("\nLE REPERTOIRE COURANT NE CONTIENT PAS LE FICHIER " + racine_prog + ".sci\n");
//    mprintf ("THE CURRENT DIRECTORY DOES NOT CONTAIN THE FILE " + racine_prog + ".sci\n\n");
//    abort; 
//  end;  
//end;
//mclose (fsci);

long2 = long ;
haut2 = haut ;

nrects = 1 ;
rectd = [] ; // Niveau de divisions
rectc = [] ; // Coordonnes
rectp = [] ; // Pattern = couleur

rectd (1)   = 0 ;     //  Niveau de division
rectc (1,1) = 0 ;     // x coin suprieur gauche
rectc (2,1) = haut ;  // y coin suprieur gauche
rectc (3,1) = long ;  //  longueur
rectc (4,1) = haut ;  //  hauteur
rectp (1)   = 2 ;     //  Couleur

//  representation
nd = 0;
hf = scf (0);
nomfenetre = sprintf ("DA4-11 : Division numro %d/%d",nd,ndivi);
hf.figure_name = nomfenetre;

ha = hf.children;
ha.axes_visible = "off";
ha.isoview = "on";
ha.margins=[0.01, 0.01, 0.01, 0.01];
ha.data_bounds = [0,0; long,haut];

//xsetech (frect=[0,0,long,haut]) ;
xrects (rectc,rectp);

for nd=1:ndivi do
  drawlater();
  //  division
  xpause (1000000);
  couleur = 1;
  if rectc(3,1)>rectc(4,1) then  // division en longueur est-ouest
    long2=long2/2;
  else
    haut2=haut2/2;
  end;  
  for nr=1:nrects do
    nrects=nrects+1;
    if rectc(3,nr)>rectc(4,nr) then  // division en longueur est-ouest
      // Ouest = nouveau rectangle nrects
      rectc (1:4,nrects)=rectc(1:4,nr);
      rectp (nrects)=rectp(nr);
      rectd (nrects)=nd;
      rectc (3,nrects)=long2;
      couleur=couleur+1;
      if couleur==ncoulmax then couleur=1; end;
      rectp (nrects)=couleur;

      // Est = ancien rectangle nr
      rectd (nr)=nd;
      rectc (1,nr)=rectc (1,nr)+long2;
      rectc (3,nr)=long2;
      couleur=couleur+1;
      if couleur==ncoulmax then couleur=1; end;
      rectp (nr)=couleur;
      // nord = inchang
      // est = inchang
      // sud = inchang

    else  // division en hauteur nord-sud
      // nord = nouveau rectangle
      rectc (1:4,nrects)=rectc(1:4,nr);
      rectp (nrects)=rectp(nr);
      rectd (nrects)=nd;
      rectc (4,nrects)=haut2;
      couleur=couleur+1;
      if couleur==ncoulmax then couleur=1; end;
      rectp (nrects)=couleur;

      // sud = ancien rectangle
      rectd (nr)=nd;
      rectc (2,nr)=rectc (2,nr)-haut2;
      rectc (4,nr)=haut2;
      couleur=couleur+1;
      if couleur==ncoulmax then couleur=1; end;
      rectp(nr)=couleur;

    end; 
  end ;

  //  representation
  clf();
  SetPosition();
  hf = scf (0);
  nomfenetre = sprintf ("DA4-11 : Division numro %d/%d",nd,ndivi);
  hf.figure_name = nomfenetre;

  ha = hf.children;
  ha.axes_visible = "off";
  ha.isoview = "on";
  ha.margins=[0.0, 0.0, 0.0, 0.0];
  ha.data_bounds = [0,0; long,haut];
 // xsetech (frect=[0,0,long,haut]) ;
  xrects (rectc,rectp);
  drawnow();
end ;

realtimeinit(i)
for i=1:10
  realtime(i);
end ;

endfunction