source: XMLIO_V2/dev/dev_rv/src/xmlio/node/domain.cpp @ 277

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