source: XIOS/trunk/src/filter/axis_zoom.cpp @ 622

Last change on this file since 622 was 622, checked in by mhnguyen, 9 years ago

Final testing transfomation algorithm: inverse axis (local commit)

+) Make some minor change to make sure one element (axis or domain) be able to have several similar transformation

Test
+) On Curie
+) test_new_feature: test passed with correct data written

File size: 1.7 KB
Line 
1#include "axis_zoom.hpp"
2
3namespace xios {
4
5CAxisZoom::CAxisZoom(CAxis* axisDestination, CAxis* axisSource, CZoomAxis* zoomAxis)
6: CAxisAlgorithmTransformation(axisDestination, axisSource), axisDest_(axisDestination), axisSrc_(axisSource)
7{
8  zoomAxis->checkValid(axisSource);
9  zoomBegin_ = zoomAxis->zoom_begin.getValue();
10  zoomEnd_   = zoomAxis->zoom_end.getValue();
11  zoomSize_  = zoomAxis->zoom_size.getValue();
12
13  if (zoomSize_ > axisSource->size.getValue())
14  {
15    ERROR("CAxisZoom::CAxisZoom(CAxis* axisDestination, CAxis* axisSource, CZoomAxis* zoomAxis)",
16           << "Zoom size is greater than size of axis source"
17           << "Size of axis source " <<axisSource->getId() << " is " << axisSource->size.getValue()  << std::endl
18           << "Zoom size is " << zoomSize_ );
19  }
20
21  // Axis destination now must have new size equal to zoom size
22  axisDestination->size.setValue(zoomSize_);
23  computeIndexSourceMapping();
24}
25
26void CAxisZoom::computeIndexSourceMapping()
27{
28  StdSize niSource = axisSrc_->ni.getValue();
29  StdSize ibeginSource = axisSrc_->ibegin.getValue();
30  StdSize iendSource = ibeginSource + niSource - 1;
31
32  StdSize ibegin = std::max(ibeginSource, zoomBegin_);
33  StdSize iend = std::min(iendSource, zoomEnd_);
34  StdSize ni = iend + 1 - ibegin;
35  if (ibeginSource > zoomEnd_)
36  {
37    axisDest_->ibegin.setValue(0);
38    axisDest_->ni.setValue(0);
39  }
40  else
41  {
42    axisDest_->ibegin.setValue(ibegin - zoomBegin_);
43    axisDest_->ni.setValue(ni);
44  }
45
46  std::map<int, std::vector<int> >& transMap = this->transformationMapping_;
47  StdSize axisDestIBegin = axisDest_->ibegin.getValue();
48  for (StdSize idx = 0; idx < ni; ++idx)
49  {
50    transMap[axisDestIBegin+idx].push_back(ibegin+idx);
51  }
52}
53
54}
Note: See TracBrowser for help on using the repository browser.