source: XIOS/dev/dev_trunk_graph/src/filter/transform_filter.cpp @ 2023

Last change on this file since 2023 was 2023, checked in by yushan, 8 months ago

Graph intermediate commit to a tmp branch.

  • Property svn:executable set to *
File size: 2.5 KB
Line 
1#include "transform_filter.hpp"
2#include "grid_algorithm.hpp"
3#include "workflow_graph.hpp"
4namespace xios
5{
6 
7  CTransformFilter::CTransformFilter( CGarbageCollector& gc, int slots, CGridAlgorithm* algo, bool detectMissingValues, double defaultValue) 
8                                    : CFilter(gc, slots, this), algorithm_(algo), 
9                                      detectMissingValues_(detectMissingValues), defaultValue_(defaultValue)
10  {
11
12  }
13
14  CDataPacketPtr CTransformFilter::apply(std::vector<CDataPacketPtr> data)
15  {
16    // for now, no auxilliairy field
17    CDataPacketPtr packet(new CDataPacket);
18    packet->date = data[0]->date;
19    packet->timestamp = data[0]->timestamp;
20    packet->status = data[0]->status;
21   
22    if (packet->status == CDataPacket::NO_ERROR) 
23    {
24      cout<<"transformeFilter = "<<this<<" and graphEnabled = "<<this->graphEnabled<<std::endl;
25      buildWorkflowGraph(data, packet, algorithm_);
26     
27      if (data.size()>1)
28      {
29        vector<CArray<double,1>> auxData(data.size()-1); 
30        for(int i=0;i<data.size()-1 ;i++) auxData[i].reference(data[i+1]->data) ;
31        algorithm_->apply(data[0]->data, auxData, packet->data);
32      }
33      else algorithm_->apply(data[0]->data, packet->data);
34    }
35    return packet;
36  }
37
38  void CTransformFilter::buildWorkflowGraph(std::vector<CDataPacketPtr> data, CDataPacketPtr packet, CGridAlgorithm* algorithm)
39  {
40    if(this->graphEnabled)
41    {
42      this->graphPackage->filterId = CWorkflowGraph::getNodeSize();
43   
44      packet->graphPackage = new CGraphDataPackage;
45      if(data[0]->graphPackage)
46      {
47        packet->graphPackage->fromFilter = data[0]->graphPackage->fromFilter;
48      }
49      packet->graphPackage->toFilter = data[0]->graphPackage->toFilter;
50      packet->graphPackage->current_filter_name = data[0]->graphPackage->current_filter_name;
51      packet->graphPackage->contextId = data[0]->graphPackage->contextId;         
52      packet->graphPackage->currentField = data[0]->graphPackage->currentField;//this->graphPackage->inFields[0];
53   
54      CWorkflowGraph::addNode("Spatial transform filter "+algorithm->getAlgoName(), 4, false, 1, packet);
55      CWorkflowGraph::addEdge(packet->graphPackage->fromFilter, this->graphPackage->filterId, packet);
56     
57     
58     
59      packet->graphPackage->fromFilter = this->graphPackage->filterId;
60      packet->graphPackage->currentField = this->graphPackage->inFields[0];
61      std::rotate(this->graphPackage->inFields.begin(), this->graphPackage->inFields.begin() + 1, this->graphPackage->inFields.end());
62    }
63  }
64
65}
Note: See TracBrowser for help on using the repository browser.