[630] | 1 | #include "interpolate_axis.hpp" |
---|
| 2 | #include "type.hpp" |
---|
[827] | 3 | #include "field.hpp" |
---|
[630] | 4 | |
---|
| 5 | namespace xios { |
---|
| 6 | |
---|
| 7 | /// ////////////////////// Définitions ////////////////////// /// |
---|
| 8 | |
---|
| 9 | CInterpolateAxis::CInterpolateAxis(void) |
---|
| 10 | : CObjectTemplate<CInterpolateAxis>(), CInterpolateAxisAttributes(), CTransformation<CAxis>() |
---|
| 11 | { /* Ne rien faire de plus */ } |
---|
| 12 | |
---|
| 13 | CInterpolateAxis::CInterpolateAxis(const StdString & id) |
---|
| 14 | : CObjectTemplate<CInterpolateAxis>(id), CInterpolateAxisAttributes(), CTransformation<CAxis>() |
---|
| 15 | { /* Ne rien faire de plus */ } |
---|
| 16 | |
---|
| 17 | CInterpolateAxis::~CInterpolateAxis(void) |
---|
| 18 | {} |
---|
| 19 | |
---|
[836] | 20 | CTransformation<CAxis>* CInterpolateAxis::create(const StdString& id, xml::CXMLNode* node) |
---|
| 21 | { |
---|
| 22 | CInterpolateAxis* interpAxis = CInterpolateAxisGroup::get("interpolate_axis_definition")->createChild(id); |
---|
| 23 | if (node) interpAxis->parse(*node); |
---|
| 24 | return static_cast<CTransformation<CAxis>*>(interpAxis); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | bool CInterpolateAxis::registerTrans() |
---|
| 28 | { |
---|
| 29 | return registerTransformation(TRANS_INTERPOLATE_AXIS, CInterpolateAxis::create); |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | bool CInterpolateAxis::_dummyRegistered = CInterpolateAxis::registerTrans(); |
---|
| 33 | |
---|
[630] | 34 | //---------------------------------------------------------------- |
---|
| 35 | |
---|
| 36 | StdString CInterpolateAxis::GetName(void) { return StdString("interpolate_axis"); } |
---|
| 37 | StdString CInterpolateAxis::GetDefName(void) { return StdString("interpolate_axis"); } |
---|
| 38 | ENodeType CInterpolateAxis::GetType(void) { return eInterpolateAxis; } |
---|
| 39 | |
---|
[827] | 40 | void CInterpolateAxis::checkValid(CAxis* axisSrc) |
---|
[630] | 41 | { |
---|
[937] | 42 | if (this->order.isEmpty()) this->order.setValue(1); |
---|
[1980] | 43 | if (this->coordinate.isEmpty() && !this->coordinate_src.isEmpty()) this->coordinate.setValue(this->coordinate_src.getValue()); |
---|
| 44 | if (this->coordinate_src.isEmpty() && !this->coordinate.isEmpty()) this->coordinate_src.setValue(this->coordinate.getValue()); |
---|
[827] | 45 | int order = this->order.getValue(); |
---|
| 46 | if (order >= axisSrc->n_glo.getValue()) |
---|
| 47 | { |
---|
| 48 | ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", |
---|
| 49 | << "Order of interpolation is greater than global size of axis source" |
---|
| 50 | << "Size of axis source " <<axisSrc->getId() << " is " << axisSrc->n_glo.getValue() << std::endl |
---|
| 51 | << "Order of interpolation is " << order ); |
---|
| 52 | } |
---|
| 53 | |
---|
[937] | 54 | if (order < 1) |
---|
| 55 | { |
---|
| 56 | ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", |
---|
| 57 | << "Order of interpolation is smaller than 1" |
---|
| 58 | << "Size of axis source " <<axisSrc->getId() << " is " << axisSrc->n_glo.getValue() << std::endl |
---|
| 59 | << "Order of interpolation is " << order ); |
---|
| 60 | } |
---|
[827] | 61 | |
---|
[937] | 62 | |
---|
[827] | 63 | if (!this->coordinate.isEmpty()) |
---|
| 64 | { |
---|
| 65 | StdString coordinate = this->coordinate.getValue(); |
---|
| 66 | if (!CField::has(coordinate)) |
---|
| 67 | ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", |
---|
| 68 | << "Coordinate field whose id " << coordinate << "does not exist " |
---|
| 69 | << "Please define one"); |
---|
| 70 | } |
---|
[1980] | 71 | |
---|
| 72 | if (!this->coordinate_dst.isEmpty()) |
---|
| 73 | { |
---|
| 74 | StdString coordinate = this->coordinate_dst.getValue(); |
---|
| 75 | if (!CField::has(coordinate)) |
---|
| 76 | ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", |
---|
| 77 | << "Coordinate field whose id " << coordinate << "does not exist " |
---|
| 78 | << "Please define one"); |
---|
| 79 | } |
---|
| 80 | |
---|
[630] | 81 | } |
---|
| 82 | |
---|
[827] | 83 | std::vector<StdString> CInterpolateAxis::checkAuxInputs_() |
---|
| 84 | { |
---|
| 85 | std::vector<StdString> auxInputs; |
---|
[1980] | 86 | if (!this->coordinate.isEmpty() && this->coordinate_src.isEmpty()) |
---|
[827] | 87 | { |
---|
| 88 | StdString coordinate = this->coordinate.getValue(); |
---|
[1980] | 89 | this->coordinate_src.setValue(coordinate); |
---|
[827] | 90 | if (!CField::has(coordinate)) |
---|
| 91 | ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", |
---|
| 92 | << "Coordinate field whose id " << coordinate << "does not exist " |
---|
| 93 | << "Please define one"); |
---|
| 94 | auxInputs.push_back(coordinate); |
---|
| 95 | } |
---|
[1980] | 96 | if (!this->coordinate_src.isEmpty() || !this->coordinate.isEmpty()) |
---|
| 97 | { |
---|
| 98 | StdString coordinate = !this->coordinate.isEmpty()? this->coordinate.getValue():this->coordinate_src.getValue(); |
---|
| 99 | this->coordinate.setValue(coordinate); |
---|
| 100 | if (!CField::has(coordinate)) |
---|
| 101 | ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", |
---|
| 102 | << "Coordinate field whose id " << coordinate << "does not exist " |
---|
| 103 | << "Please define one"); |
---|
| 104 | auxInputs.push_back(coordinate); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | if (!this->coordinate_dst.isEmpty()) |
---|
| 108 | { |
---|
| 109 | StdString coordinate = this->coordinate_dst.getValue(); |
---|
| 110 | if (!CField::has(coordinate)) |
---|
| 111 | ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", |
---|
| 112 | << "Coordinate field whose id " << coordinate << "does not exist " |
---|
| 113 | << "Please define one"); |
---|
| 114 | auxInputs.push_back(coordinate); |
---|
| 115 | } |
---|
[827] | 116 | |
---|
| 117 | return auxInputs; |
---|
| 118 | } |
---|
[630] | 119 | } |
---|