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

Last change on this file since 2026 was 2026, checked in by yushan, 9 months ago

Graph intermediate commit to a tmp branch.

  • Property svn:executable set to *
File size: 2.9 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      buildWorkflowGraph(data, packet, algorithm_);
25     
26      if (data.size()>1)
27      {
28        vector<CArray<double,1>> auxData(data.size()-1); 
29        for(int i=0;i<data.size()-1 ;i++) auxData[i].reference(data[i+1]->data) ;
30        algorithm_->apply(data[0]->data, auxData, packet->data);
31      }
32      else algorithm_->apply(data[0]->data, packet->data);
33    }
34    return packet;
35  }
36
37  void CTransformFilter::buildWorkflowGraph(std::vector<CDataPacketPtr> data, CDataPacketPtr packet, CGridAlgorithm* algorithm)
38  {
39    if(this->graphEnabled)
40    {
41      this->graphPackage->filterId = CWorkflowGraph::getNodeSize();
42   
43      packet->graphPackage = new CGraphDataPackage;
44      if(data[0]->graphPackage)
45      {
46        packet->graphPackage->fromFilter = data[0]->graphPackage->fromFilter;
47      }
48      packet->graphPackage->toFilter = data[0]->graphPackage->toFilter;
49      packet->graphPackage->current_filter_name = data[0]->graphPackage->current_filter_name;
50      packet->graphPackage->contextId = data[0]->graphPackage->contextId;         
51   
52      int tmp_from = packet->graphPackage->fromFilter;
53      if(this->graphPackage->show)
54      {
55        packet->graphPackage->currentField = data[0]->graphPackage->currentField->getDirectFieldReference();//this->graphPackage->inFields[0];
56        CWorkflowGraph::addNode("Spatial transform filter "+algorithm->getAlgoName(), 4, false, 1, packet);
57        CWorkflowGraph::addEdge(packet->graphPackage->fromFilter, this->graphPackage->filterId, packet);
58        packet->graphPackage->fromFilter = this->graphPackage->filterId;
59        packet->graphPackage->currentField = this->graphPackage->inFields[0];
60        std::rotate(this->graphPackage->inFields.begin(), this->graphPackage->inFields.begin() + 1, this->graphPackage->inFields.end());
61      }
62      else
63      {
64        packet->graphPackage->currentField = this->graphPackage->inFields[0];
65        if(CXios::isClient) CWorkflowGraph::vectorOfNodes_->at(tmp_from).filter_name += algorithm->getAlgoName();
66        else                CWorkflowGraph::vectorOfNodes_srv_->at(tmp_from).filter_name += algorithm->getAlgoName();
67       
68      }     
69    }
70  }
71
72}
Note: See TracBrowser for help on using the repository browser.