source: XMLIO_V2/dev/common/src/xmlio/node/domain.cpp @ 274

Last change on this file since 274 was 274, checked in by hozdoba, 13 years ago

nouvelle interface fortran et corrections

File size: 26.5 KB
Line 
1#include "domain.hpp"
2
3#include "attribute_template_impl.hpp"
4#include "object_template_impl.hpp"
5#include "group_template_impl.hpp"
6
7#include "mpi_manager.hpp"
8
9#include "tree_manager.hpp"
10
11#include <algorithm>
12
13namespace xmlioserver {
14namespace tree {
15   
16   /// ////////////////////// Définitions ////////////////////// ///
17
18   CDomain::CDomain(void)
19      : CObjectTemplate<CDomain>(), CDomainAttributes()
20      , isChecked(false), local_mask(new CArray<int, 2>(boost::extents[0][0])), relFiles()
21      , ibegin_sub(), iend_sub(), jbegin_sub(), jend_sub()
22      , ibegin_zoom_sub(), jbegin_zoom_sub()
23      , lonvalue_sub(), latvalue_sub()
24   { /* Ne rien faire de plus */ }
25
26   CDomain::CDomain(const StdString & id)
27      : CObjectTemplate<CDomain>(id), CDomainAttributes()
28      , isChecked(false), local_mask(new CArray<int, 2>(boost::extents[0][0])), relFiles()
29      , ibegin_sub(), iend_sub(), jbegin_sub(), jend_sub()
30      , ibegin_zoom_sub(), jbegin_zoom_sub()
31      , lonvalue_sub(), latvalue_sub()
32   { /* Ne rien faire de plus */ }
33
34   CDomain::~CDomain(void)
35   { 
36      this->local_mask.reset();
37      for (StdSize i = 0; i < this->lonvalue_sub.size(); i++)
38      {
39         this->lonvalue_sub[i].reset();
40         this->latvalue_sub[i].reset();
41      }     
42   }
43
44   ///---------------------------------------------------------------
45
46   const std::set<StdString> & CDomain::getRelFiles(void) const
47   {
48      return (this->relFiles);
49   }
50
51   //----------------------------------------------------------------
52   
53   bool CDomain::hasZoom(void) const
54   {
55      return ((this->zoom_ni.getValue() != this->ni_glo.getValue()) && 
56              (this->zoom_nj.getValue() != this->nj_glo.getValue()));
57   }
58   
59   //----------------------------------------------------------------
60   
61   bool CDomain::isEmpty(void) const
62   {
63      return ((this->zoom_ni_loc.getValue() == 0) || 
64              (this->zoom_nj_loc.getValue() == 0));
65   }
66
67   //----------------------------------------------------------------
68
69   bool CDomain::IsWritten(const StdString & filename) const
70   {
71      return (this->relFiles.find(filename) != this->relFiles.end());
72   }
73
74   //----------------------------------------------------------------
75
76   void CDomain::addRelFile(const StdString & filename)
77   {
78      this->relFiles.insert(filename);
79   }
80
81   //----------------------------------------------------------------
82
83   void CDomain::fromBinary(StdIStream & is)
84   {
85      SuperClass::fromBinary(is);
86     
87      if ( !this->ibegin.isEmpty()   &&
88           !this->jbegin.isEmpty()   &&
89           !this->iend.isEmpty()     &&
90           !this->jend.isEmpty()     &&
91           !this->latvalue.isEmpty() &&
92           !this->lonvalue.isEmpty())
93      {
94     
95         this->ibegin_sub.push_back(this->ibegin.getValue());
96         this->jbegin_sub.push_back(this->jbegin.getValue());
97         this->iend_sub.push_back(this->iend.getValue());
98         this->jend_sub.push_back(this->jend.getValue()); 
99         
100         this->ibegin_zoom_sub.push_back(this->zoom_ibegin_loc.getValue());
101         this->jbegin_zoom_sub.push_back(this->zoom_jbegin_loc.getValue());
102     
103         this->latvalue_sub.push_back(this->latvalue.getValue());
104         this->lonvalue_sub.push_back(this->lonvalue.getValue());
105      }
106     
107#define CLEAR_ATT(name_)\
108      SuperClassAttribute::operator[](#name_)->clear()
109
110         CLEAR_ATT(mask);
111         CLEAR_ATT(data_n_index);
112         CLEAR_ATT(data_i_index);
113         CLEAR_ATT(data_j_index);
114         
115         CLEAR_ATT(data_ni);
116         CLEAR_ATT(data_nj);
117         CLEAR_ATT(data_ibegin);
118         CLEAR_ATT(data_jbegin);
119         
120         CLEAR_ATT(ni);
121         CLEAR_ATT(nj);
122         
123#undef CLEAR_ATT
124
125      if ( !this->ibegin.isEmpty()   &&
126           !this->jbegin.isEmpty()   &&
127           !this->iend.isEmpty()     &&
128           !this->jend.isEmpty()     &&
129           !this->latvalue.isEmpty() &&
130           !this->lonvalue.isEmpty())
131      {
132
133         this->ibegin.setValue(*std::min_element(this->ibegin_sub.begin(),this->ibegin_sub.end()));
134         this->jbegin.setValue(*std::min_element(this->jbegin_sub.begin(),this->jbegin_sub.end()));
135         this->iend.setValue(*std::max_element(this->iend_sub.begin(),this->iend_sub.end()));
136         this->jend.setValue(*std::max_element(this->jend_sub.begin(),this->jend_sub.end()));
137      }
138   }
139
140   //----------------------------------------------------------------
141
142   StdString CDomain::GetName(void)   { return (StdString("domain")); }
143   StdString CDomain::GetDefName(void){ return (CDomain::GetName()); }
144   ENodeType CDomain::GetType(void)   { return (eDomain); }
145
146   //----------------------------------------------------------------
147
148   void CDomain::checkGlobalDomain(void)
149   {
150      if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) ||
151          (nj_glo.isEmpty() || nj_glo.getValue() <= 0 ))
152      {
153         abort();
154         ERROR("CDomain::checkAttributes(void)",
155               << "[ Id = " << this->getId() << " ] "
156               << "Le domaine global est mal défini,"
157               << " vérifiez les valeurs de \'ni_glo\' et \'nj_glo\' !") 
158      }
159   }
160
161   //----------------------------------------------------------------
162
163   void CDomain::checkLocalIDomain(void)
164   {
165      if (!ni.isEmpty() && !ibegin.isEmpty() && iend.isEmpty())
166         iend.setValue(ibegin.getValue() + ni.getValue() - 1) ;
167
168      else if (!ni.isEmpty() && !iend.isEmpty()   && ibegin.isEmpty())
169         ibegin.setValue( - ni.getValue() + iend.getValue() + 1) ;
170
171      else if (!ibegin.isEmpty() && !iend.isEmpty() && ni.isEmpty())
172         ni.setValue(iend.getValue() - ibegin.getValue() + 1) ;
173
174      else if (!ibegin.isEmpty() && !iend.isEmpty() &&
175               !ni.isEmpty() && (iend.getValue() != ibegin.getValue() + ni.getValue() - 1))
176      {
177         ERROR("CDomain::checkAttributes(void)",
178               << "Le domaine est mal défini,"
179               << " iend est différent de (ibegin + ni - 1) !") ;
180      }
181      else
182      {
183         ERROR("CDomain::checkAttributes(void)",
184               << "Le domaine est mal défini,"
185               << " deux valeurs au moins parmis iend, ibegin, ni doivent être définies !") ;
186      }
187
188
189      if (ni.getValue() < 0 || ibegin.getValue() > iend.getValue() ||
190          ibegin.getValue() < 1 || iend.getValue() > ni_glo.getValue())
191         ERROR("CDomain::checkAttributes(void)",
192               << "[ Id = " << this->getId() << " ] "
193               << "Domaine local mal défini,"
194               << " vérifiez les valeurs ni, ni_glo, ibegin, iend") ;
195
196   }
197
198   //----------------------------------------------------------------
199
200   void CDomain::checkLocalJDomain(void)
201   {
202      if (!nj.isEmpty() && !jbegin.isEmpty() && jend.isEmpty())
203         jend.setValue(jbegin.getValue() + nj.getValue() - 1) ;
204
205      else if (!nj.isEmpty() && !jend.isEmpty() && jbegin.isEmpty())
206         jbegin.setValue( - nj.getValue() + jend.getValue() + 1) ;
207
208      else if (!jbegin.isEmpty() && !jend.isEmpty() && nj.isEmpty())
209         nj.setValue(jend.getValue() - jbegin.getValue() + 1) ;
210
211      else if (!jbegin.isEmpty() && !jend.isEmpty() && !nj.isEmpty() &&
212               (jend.getValue() != jbegin.getValue() + nj.getValue() - 1))
213      {
214         ERROR("CDomain::checkAttributes(void)",
215               << "Le domaine est mal défini,"
216               << " iend est différent de (jbegin + nj - 1) !") ;
217      }
218      else
219      {
220         ERROR("CDomain::checkAttributes(void)",
221               << "Le domaine est mal défini,"
222               << " deux valeurs au moins parmis jend, jbegin, nj doivent être définies !") ;
223      }
224
225      if (nj.getValue() < 0 || jbegin.getValue() > jend.getValue() ||
226          jbegin.getValue() < 1 || jend.getValue() > nj_glo.getValue())
227         ERROR("CDomain::checkAttributes(void)",
228               << "Domaine local mal défini,"
229               << " vérifiez les valeurs nj, nj_glo, jbegin, jend") ;
230   }
231
232   //----------------------------------------------------------------
233
234   void CDomain::checkMask(void)
235   {
236      using namespace std;
237     
238      int ibegin_mask = 0,
239          jbegin_mask = 0,
240          iend_mask = iend.getValue() - ibegin.getValue(),
241          jend_mask = jend.getValue() - jbegin.getValue();
242     
243      if (!zoom_ibegin.isEmpty())
244      {
245         int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1;
246         int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1;
247         
248         ibegin_mask = max (ibegin.getValue(), zoom_ibegin.getValue());
249         jbegin_mask = max (jbegin.getValue(), zoom_jbegin.getValue());
250         iend_mask   = min (iend.getValue(), zoom_iend);
251         jend_mask   = min (jend.getValue(), zoom_jend);
252                 
253         ibegin_mask -= ibegin.getValue();
254         jbegin_mask -= jbegin.getValue();
255         iend_mask   -= ibegin.getValue();
256         jend_mask   -= jbegin.getValue();
257      }
258     
259      //~ std::cout << "-------------------" << std::endl
260                //~ << "zoom : " << std::boolalpha << this->hasZoom() << std::endl
261                //~ << "size : " << ni.getValue()  << " X " << nj.getValue()   << std::endl
262                //~ << "it : " << ibegin.getValue() << ", " << iend.getValue() << std::endl
263                //~ << "jt : " << jbegin.getValue() << ", " << jend.getValue() << std::endl
264                //~ << "im : " << ibegin_mask << ", " << iend_mask << std::endl
265                //~ << "jm : " << jbegin_mask << ", " << jend_mask << std::endl
266                //~ << "-------------------" << std::endl;
267
268      if (!mask.isEmpty())
269      {
270         ARRAY(bool, 2) mask_ = mask.getValue();
271         unsigned int niu = ni.getValue(), nju = nj.getValue();
272         if ((mask_->shape()[0] != niu) ||
273             (mask_->shape()[1] != nju))
274            ERROR("CDomain::checkAttributes(void)",
275                  <<"Le masque n'a pas la même taille que le domaine local") ;
276                 
277         for (int i = 0; i < ni.getValue(); i++)
278         {
279            for (int j = 0; j < nj.getValue(); j++)
280            {
281               if (i < ibegin_mask && i > iend_mask &&
282                   j < jbegin_mask && j > jend_mask )
283                     (*mask_)[i][j] = false;
284            }
285         }
286      }
287      else // (!mask.hasValue())
288      { // Si aucun masque n'est défini,
289        // on en crée un nouveau qui valide l'intégralité du domaine.
290         ARRAY_CREATE(__arr, bool, 2, [ni.getValue()][nj.getValue()]);
291         for (int i = 0; i < ni.getValue(); i++)
292         {
293            for (int j = 0; j < nj.getValue(); j++)
294            {
295               if (i >= ibegin_mask && i <= iend_mask &&
296                   j >= jbegin_mask && j <= jend_mask )
297                     (*__arr)[i][j] = true;
298               else  (*__arr)[i][j] = false;
299            }
300         }
301               
302         mask.setValue(__arr);
303         __arr.reset();
304      }
305   }
306
307
308   //----------------------------------------------------------------
309
310   void CDomain::checkDomainData(void)
311   {     
312      if (!data_dim.isEmpty() &&
313         !(data_dim.getValue() == 1 || data_dim.getValue() == 2))
314      {
315         ERROR("CDomain::checkAttributes(void)",
316               << "Dimension des données non comptatible (doit être 1 ou 2) !") ;
317      }
318      else if (data_dim.isEmpty())
319      {
320         ERROR("CDomain::checkAttributes(void)",
321               << "Dimension des données non définie !") ;
322      }
323
324      if (data_ibegin.isEmpty())
325         data_ibegin.setValue(0) ;
326      if (data_jbegin.isEmpty() && (data_dim.getValue() == 2))
327         data_jbegin.setValue(0) ;
328
329      if (!data_ni.isEmpty() && (data_ni.getValue() <= 0))
330      {
331         ERROR("CDomain::checkAttributes(void)",
332               << "Dimension des données négative (data_ni).") ;
333      }
334      else if (data_ni.isEmpty())
335      {
336         data_ni.setValue((data_dim.getValue() == 1)
337                           ? (ni.getValue() * nj.getValue())
338                           : ni.getValue());
339      }
340
341      if (data_dim.getValue() == 2)
342      {
343         if (!data_nj.isEmpty() && (data_nj.getValue() <= 0) )
344         {
345            ERROR("CDomain::checkAttributes(void)",
346                  << "Dimension des données négative (data_nj).") ;
347         }
348         else if (data_nj.isEmpty())
349            data_nj.setValue(nj.getValue()) ;
350      }
351
352   }
353
354   //----------------------------------------------------------------
355
356   void CDomain::checkCompression(void)
357   {
358      if (!data_i_index.isEmpty())
359      {
360         int ssize = data_i_index.getValue()->size();
361         if (!data_n_index.isEmpty() &&
362            (data_n_index.getValue() != ssize))
363         {
364            ERROR("CDomain::checkAttributes(void)",
365                  <<"Dimension data_i_index incompatible avec data_n_index.") ;
366         }
367         else if (data_n_index.isEmpty())
368            data_n_index.setValue(ssize) ;
369
370         if (data_dim.getValue() == 2)
371         {
372            if (!data_j_index.isEmpty() &&
373               (data_j_index.getValue()->size() != data_i_index.getValue()->size()))
374            {
375               ERROR("CDomain::checkAttributes(void)",
376                     <<"Dimension data_j_index incompatible avec data_i_index.") ;
377            }
378            else if (data_j_index.isEmpty())
379            {
380               ERROR("CDomain::checkAttributes(void)",
381                     <<"La donnée data_j_index doit être renseignée !") ;
382            }
383         }
384      }
385      else
386      {
387         if (!data_n_index.isEmpty() ||
388            ((data_dim.getValue() == 2) && (!data_j_index.isEmpty())))
389            ERROR("CDomain::checkAttributes(void)", << "data_i_index non défini") ;
390      }
391
392      if (data_n_index.isEmpty())
393      { // -> bloc re-vérifié OK
394         if (data_dim.getValue() == 1)
395         {
396            const int dni = data_ni.getValue();
397            ARRAY_CREATE(__arri, int, 1, [dni]);
398            data_n_index.setValue(dni);
399            for (int i = 0; i < dni; i++)
400               (*__arri)[i] = i+1 ;
401            data_i_index.setValue(__arri) ;
402         }
403         else   // (data_dim == 2)
404         {
405            const int dni = data_ni.getValue() * data_nj.getValue();
406           
407            ARRAY_CREATE(__arri, int, 1, [dni]);
408            ARRAY_CREATE(__arrj, int, 1, [dni]);               
409            data_n_index.setValue(dni);
410           
411            //for(int count = 0, i = 0; i  < data_ni.getValue(); i++)
412            //for(int j = 0; j < data_nj.getValue(); j++, count++)
413           
414            for(int count = 0, j = 0; j  < data_nj.getValue(); j++)
415            {
416               for(int i = 0; i < data_ni.getValue(); i++, count++)
417               {
418                  (*__arri)[count] = i+1 ;
419                  (*__arrj)[count] = j+1 ;
420               }
421            }
422            data_i_index.setValue(__arri) ;
423            data_j_index.setValue(__arrj) ;           
424            __arri.reset();
425            __arrj.reset();
426         }
427      }
428   }
429
430   //----------------------------------------------------------------
431   
432   void CDomain::completeLonLatClient(void)
433   {
434      ARRAY_CREATE(lonvalue_temp, double, 1, [0]);
435      ARRAY_CREATE(latvalue_temp, double, 1, [0]);
436     
437      const int zoom_ibegin_client  = zoom_ibegin_loc.getValue(),
438                zoom_jbegin_client  = zoom_jbegin_loc.getValue(),
439                zoom_ni_client      = zoom_ni_loc.getValue(),
440                zoom_nj_client      = zoom_nj_loc.getValue();
441               
442      ARRAY(double, 1) lonvalue_ = this->lonvalue.getValue(),
443                       latvalue_ = this->latvalue.getValue();
444               
445      if (this->data_dim.getValue() == 2)
446      {
447         StdSize dm = zoom_ni_client * zoom_nj_client;
448
449         lonvalue_temp->resize(boost::extents[dm]);
450         latvalue_temp->resize(boost::extents[dm]);
451         
452         for (int i = 0; i < zoom_ni_client; i++)
453         {
454            for (int j = 0; j < zoom_nj_client; j++)
455            {
456               (*lonvalue_temp)[i + j * zoom_ni_client] = (*lonvalue_)[(i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue()];             
457               (*latvalue_temp)[i + j * zoom_ni_client] = (*latvalue_)[(i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue()];
458            }
459         }
460         this->lonvalue.setValue(lonvalue_temp);
461         this->latvalue.setValue(latvalue_temp);
462      }
463      else
464      {
465         lonvalue_temp->resize(boost::extents[zoom_ni_client]);
466         latvalue_temp->resize(boost::extents[zoom_nj_client]);
467         
468         for (int i = zoom_ibegin_client - 1; i < (zoom_ni_client - zoom_ibegin_client + 1); i++)
469         {
470            (*lonvalue_temp)[i] = (*lonvalue_)[i]; 
471         }
472         
473         for (int j = zoom_ibegin_client - 1; j < (zoom_nj_client - zoom_jbegin_client + 1); j++)
474         {
475            (*latvalue_temp)[j] = (*latvalue_)[j];
476         }
477         
478         this->lonvalue.setValue(lonvalue_temp);
479         this->latvalue.setValue(latvalue_temp);
480      } 
481   }
482 
483   //----------------------------------------------------------------
484     
485   void CDomain::completeLonLatServer(void)
486   {
487      ARRAY_CREATE(lonvalue_temp, double, 1, [0]);
488      ARRAY_CREATE(latvalue_temp, double, 1, [0]);
489     
490      const int ibegin_serv  = ibegin.getValue(),
491                jbegin_serv  = jbegin.getValue(),
492                zoom_ni_serv = zoom_ni_loc.getValue(),
493                zoom_nj_serv = zoom_nj_loc.getValue();
494                     
495      /*std::cout << "Rang du serveur :" << comm::CMPIManager::GetCommRank()   << std::endl
496                << "Begin serv : "     << ibegin_serv << ", " << jbegin_serv <<  std::endl
497                << "End serv : "       << iend_serv   << ", " << jend_serv   <<  std::endl
498                << "Zoom_loc begin : " << zoom_ibegin_loc << ", " << zoom_jbegin_loc <<  std::endl
499                << "Zoom_loc size : "  << zoom_ni_loc << ", " << zoom_nj_loc <<  std::endl;*/
500     
501     
502      ARRAY(double, 1) lonvalue_ = this->lonvalue.getValue(),
503                       latvalue_ = this->latvalue.getValue();
504                       
505      if (this->data_dim.getValue() == 2)
506      {
507         StdSize dm = zoom_ni_serv * zoom_nj_serv;
508         StdSize dn = this->ni.getValue() * this->nj.getValue();
509         
510         lonvalue_->resize(boost::extents[dn]);
511         latvalue_->resize(boost::extents[dn]);
512         lonvalue_temp->resize(boost::extents[dm]);
513         latvalue_temp->resize(boost::extents[dm]);
514         
515         for (StdSize k = 0; k < lonvalue_sub.size(); k++)
516         {
517            int l = 0;
518            ARRAY(double, 1) lonvalue_loc = this->lonvalue_sub[k],
519                             latvalue_loc = this->latvalue_sub[k];
520            const int ibegin_loc = ibegin_sub[k], iend_loc = iend_sub[k],
521                      jbegin_loc = jbegin_sub[k], jend_loc = jend_sub[k];
522                     
523            for (int i = ibegin_loc - ibegin_serv; i < (iend_loc - ibegin_serv + 1); i++)
524            {
525               for (int j = jbegin_loc - jbegin_serv; j < (jend_loc - jbegin_serv + 1); j++)
526               {
527                  (*lonvalue_)[i + j * this->ni.getValue()] = (*lonvalue_loc)[l];      // erreur       
528                  (*latvalue_)[i + j * this->ni.getValue()] = (*latvalue_loc)[l++];    // erreur
529               }
530            }
531         }
532         this->lonvalue.setValue(lonvalue_temp);
533         this->latvalue.setValue(latvalue_temp);
534      }
535      else
536      {
537         lonvalue_->resize(boost::extents[this->ni.getValue()]);
538         latvalue_->resize(boost::extents[this->nj.getValue()]);
539         lonvalue_temp->resize(boost::extents[zoom_ni_serv]);
540         latvalue_temp->resize(boost::extents[zoom_nj_serv]);
541         
542         for (StdSize k = 0; k < lonvalue_sub.size(); k++)
543         {
544            int l = 0;
545            ARRAY(double, 1) lonvalue_loc = this->lonvalue_sub[k],
546                             latvalue_loc = this->latvalue_sub[k];
547            const int ibegin_loc = ibegin_sub[k], iend_loc = iend_sub[k],
548                      jbegin_loc = jbegin_sub[k], jend_loc = jend_sub[k];
549                     
550            for (int i = ibegin_loc - ibegin_serv; i < (iend_loc - ibegin_loc + 1); i++)
551               (*lonvalue_)[i] = (*lonvalue_loc)[l++];
552               
553            for (int j = jbegin_loc - jbegin_serv; j < (jend_loc - jbegin_loc + 1); j++)
554               (*latvalue_)[j] = (*latvalue_loc)[l++];
555         }       
556         this->lonvalue.setValue(lonvalue_temp);
557         this->latvalue.setValue(latvalue_temp);
558      }
559   }
560
561   //----------------------------------------------------------------
562
563   void CDomain::checkZoom(void)
564   {
565      // Résolution et vérification des données globales de zoom.
566      if (!this->zoom_ni.isEmpty() || !this->zoom_nj.isEmpty() ||
567          !this->zoom_ibegin.isEmpty() || !this->zoom_jbegin.isEmpty())
568      {
569         if (this->zoom_ni.isEmpty()     && this->zoom_nj.isEmpty() &&
570             this->zoom_ibegin.isEmpty() && this->zoom_jbegin.isEmpty())
571         {
572            ERROR("CDomain::checkZoom(void)",
573                  <<"Les attributs définissant un zoom doivent tous être définis") ;
574         }
575         else
576         {
577            int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1;
578            int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1;
579               
580            if (zoom_ibegin.getValue() < 1  || zoom_jbegin.getValue() < 1 ||
581                zoom_iend > ni_glo.getValue() || zoom_jend > nj_glo.getValue())
582               ERROR("CDomain::checkZoom(void)",
583                     << "Zoom mal défini,"
584                     << " vérifiez les valeurs zoom_ni, zoom_nj, zoom_ibegin, zoom_ibegin") ;
585         }
586      }
587      else
588      {
589         this->zoom_ni.setValue(this->ni_glo.getValue()); 
590         this->zoom_nj.setValue(this->nj_glo.getValue());
591         this->zoom_ibegin.setValue(1);
592         this->zoom_jbegin.setValue(1);
593      }
594      // Résolution des données locales de zoom.
595      {
596         int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1;
597         int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1;
598         
599         if ((zoom_ibegin.getValue() > iend.getValue()) || 
600             (zoom_iend < ibegin.getValue()))
601         {
602            zoom_ni_loc.setValue(0);
603            zoom_ibegin_loc.setValue(-1);
604         }
605         else
606         {
607            int zoom_ibegin_loc_ = (zoom_ibegin.getValue() > ibegin.getValue()) 
608                                 ? zoom_ibegin.getValue()
609                                 : ibegin.getValue();
610            int zoom_iend_loc_  = (zoom_iend < iend.getValue()) 
611                                 ? zoom_iend
612                                 : iend.getValue();
613            int zoom_ni_loc_ = zoom_iend_loc_ - zoom_ibegin_loc_ + 1;
614           
615            zoom_ni_loc.setValue(zoom_ni_loc_);
616            zoom_ibegin_loc.setValue(zoom_ibegin_loc_-ibegin.getValue()+1);
617         }
618         
619         if ((zoom_jbegin.getValue() > jend.getValue()) || 
620             (zoom_jend < jbegin.getValue()))
621         {
622            zoom_nj_loc.setValue(0);
623            zoom_jbegin_loc.setValue(-1);
624         }
625         else
626         {
627            int zoom_jbegin_loc_ = (zoom_jbegin.getValue() > jbegin.getValue()) 
628                                 ? zoom_jbegin.getValue()
629                                 : jbegin.getValue();
630            int zoom_jend_loc_  = (zoom_jend < jend.getValue()) 
631                                 ? zoom_jend
632                                 : jend.getValue();
633            int zoom_nj_loc_ = zoom_jend_loc_ - zoom_jbegin_loc_ + 1;
634           
635            zoom_nj_loc.setValue(zoom_nj_loc_);
636            zoom_jbegin_loc.setValue(zoom_jbegin_loc_-jbegin.getValue()+1);
637         }
638      }
639   }
640
641   //----------------------------------------------------------------
642
643   void CDomain::checkAttributes(void)
644   {
645      if (this->isChecked) return;
646
647      this->checkGlobalDomain();
648      this->checkLocalIDomain();
649      this->checkLocalJDomain();
650     
651      this->checkZoom();
652
653      if (this->latvalue_sub.size() == 0)
654      { // CÃŽté client uniquement
655         this->checkMask();
656         this->checkDomainData();
657         this->checkCompression();
658         
659         this->ibegin_sub.push_back(this->ibegin.getValue());
660         this->jbegin_sub.push_back(this->jbegin.getValue());
661         this->iend_sub.push_back(this->iend.getValue());
662         this->jend_sub.push_back(this->jend.getValue()); 
663     
664         this->latvalue_sub.push_back(this->latvalue.getValue());
665         this->lonvalue_sub.push_back(this->lonvalue.getValue()); 
666         
667         if (!this->isEmpty())
668         {
669            this->completeLonLatClient();
670         }
671      }
672      else
673      { // CÃŽté serveur uniquement
674         if (!this->isEmpty())
675            this->completeLonLatServer();
676      }
677      this->completeMask();
678
679      this->isChecked = true;
680   }
681   
682   //----------------------------------------------------------------
683   
684   void CDomain::completeMask(void)
685   {
686      this->local_mask->resize(boost::extents[zoom_ni_loc.getValue()][zoom_nj_loc.getValue()]);
687   }
688
689   //----------------------------------------------------------------
690
691   ARRAY(int, 2) CDomain::getLocalMask(void) const
692   {
693      return (this->local_mask);
694   }
695   
696   //----------------------------------------------------------------
697   
698   const std::vector<int> & CDomain::getIBeginSub(void) const
699   {
700      return (this->ibegin_sub);
701   }
702   
703   //----------------------------------------------------------------
704   
705   const std::vector<int> & CDomain::getIBeginZoomSub(void) const
706   {
707      return (this->ibegin_zoom_sub);
708   }
709               
710   //----------------------------------------------------------------
711                     
712   const std::vector<int> & CDomain::getIEndSub(void) const
713   {
714      return (this->iend_sub);
715   }
716   
717   //----------------------------------------------------------------
718   
719   const std::vector<int> & CDomain::getJBeginSub(void) const
720   {
721      return (this->jbegin_sub);
722   }
723   
724   //----------------------------------------------------------------
725     
726   const std::vector<int> & CDomain::getJBeginZoomSub(void) const
727   {
728      return (this->jbegin_zoom_sub);
729   }
730                 
731   
732   //----------------------------------------------------------------
733   
734   const std::vector<int> & CDomain::getJEndSub(void) const
735   {
736      return (this->iend_sub);
737   }
738   
739   //----------------------------------------------------------------
740   
741   const std::vector<ARRAY(double, 1)> & CDomain::getLonValueSub(void) const
742   {
743      return (this->lonvalue_sub);
744   }
745   
746   //----------------------------------------------------------------
747   
748   const std::vector<ARRAY(double, 1)> & CDomain::getLatValueSub(void) const
749   {
750      return (this->latvalue_sub);
751   }   
752   
753   ///---------------------------------------------------------------
754
755} // namespace tree
756} // namespace xmlioserver
Note: See TracBrowser for help on using the repository browser.