source: XIOS/trunk/src/filter/axis_algorithm_zoom.cpp @ 623

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

Implementing transformation algorithm: zoom axis (local commit)

+) Implement zoom axis: zoomed points are points not masked
+) Correct some minor bugs

Test
+) Ok with normal cases: zoom in the last of transformation list
+) There is still a bug in case of zoom then inverse

File size: 2.1 KB
Line 
1#include "axis_algorithm_zoom.hpp"
2
3namespace xios {
4
5CAxisAlgorithmZoom::CAxisAlgorithmZoom(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("CAxisAlgorithmZoom::CAxisAlgorithmZoom(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  computeIndexSourceMapping();
22}
23
24void CAxisAlgorithmZoom::computeIndexSourceMapping()
25{
26  StdSize niSource = axisSrc_->ni.getValue();
27  StdSize ibeginSource = axisSrc_->ibegin.getValue();
28  StdSize iendSource = ibeginSource + niSource - 1;
29
30  StdSize ibegin = std::max(ibeginSource, zoomBegin_);
31  StdSize iend = std::min(iendSource, zoomEnd_);
32  StdSize ni = iend + 1 - ibegin;
33  if (iend < ibegin) ni = 0;
34
35  std::map<int, std::vector<int> >& transMap = this->transformationMapping_;
36  for (StdSize idx = 0; idx < ni; ++idx)
37  {
38    transMap[ibegin+idx].push_back(ibegin+idx);
39  }
40
41  updateZoom();
42  updateAxisDestinationMask();
43}
44
45void CAxisAlgorithmZoom::updateZoom()
46{
47  axisDest_->global_zoom_begin = zoomBegin_;
48  axisDest_->global_zoom_size  = zoomSize_;
49}
50
51void CAxisAlgorithmZoom::updateAxisDestinationMask()
52{
53  StdSize niMask = axisDest_->mask.numElements();
54  StdSize iBeginMask = axisDest_->ibegin.getValue();
55  StdSize globalIndexMask = 0;
56  std::map<int, std::vector<int> >& transMap = this->transformationMapping_;
57  std::map<int, std::vector<int> >::const_iterator ite = (transMap).end();
58  for (StdSize idx = 0; idx < niMask; ++idx)
59  {
60    globalIndexMask = iBeginMask + idx;
61    if (transMap.find(globalIndexMask) == ite)
62      (axisDest_->mask)(idx) = false;
63  }
64}
65
66}
Note: See TracBrowser for help on using the repository browser.