Changeset 1000 for XIOS/trunk/src/node/field.cpp
- Timestamp:
- 11/22/16 16:31:11 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/field.cpp
r998 r1000 768 768 { 769 769 if (!areAllReferenceSolved) solveAllReferenceEnabledField(false); 770 770 771 // Start by building a filter which can provide the field's instant data 771 772 if (!instantDataFilter) 772 773 { 773 boost::shared_ptr<COutputPin> arithmDataFilter;774 775 774 // Check if we have an expression to parse 776 if (hasExpression() || !field_ref.isEmpty()) 777 { 778 if (hasExpression()) 775 if (hasExpression()) 776 { 777 boost::scoped_ptr<IFilterExprNode> expr(parseExpr(getExpression() + '\0')); 778 boost::shared_ptr<COutputPin> filter = expr->reduce(gc, *this); 779 780 // Check if a spatial transformation is needed 781 if (!field_ref.isEmpty()) 779 782 { 780 boost::scoped_ptr<IFilterExprNode> expr(parseExpr(getExpression() + '\0')); 781 arithmDataFilter = expr->reduce(gc, *this); 783 CGrid* gridRef = CField::get(field_ref)->grid; 784 785 if (grid && grid != gridRef && grid->hasTransform()) 786 { 787 double defaultValue = !default_value.isEmpty() ? default_value : 0.0; 788 std::pair<boost::shared_ptr<CFilter>, boost::shared_ptr<CFilter> > filters = CSpatialTransformFilter::buildFilterGraph(gc, gridRef, grid, defaultValue); 789 790 filter->connectOutput(filters.first, 0); 791 filter = filters.second; 792 } 782 793 } 783 // Check if we have a reference on another field 784 if (!field_ref.isEmpty()) instantDataFilter = getFieldReference(gc,arithmDataFilter); 785 } 794 795 instantDataFilter = filter; 796 } 797 // Check if we have a reference on another field 798 else if (!field_ref.isEmpty()) 799 instantDataFilter = getFieldReference(gc); 786 800 // Check if the data is to be read from a file 787 801 else if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read) … … 816 830 * \return the output pin corresponding to the field reference 817 831 */ 818 boost::shared_ptr<COutputPin> CField::getFieldReference(CGarbageCollector& gc , boost::shared_ptr<COutputPin> OutputPin)832 boost::shared_ptr<COutputPin> CField::getFieldReference(CGarbageCollector& gc) 819 833 { 820 834 if (instantDataFilter || field_ref.isEmpty()) … … 823 837 824 838 CField* fieldRef = CField::get(field_ref); 825 if (!OutputPin)fieldRef->buildFilterGraph(gc, false);839 fieldRef->buildFilterGraph(gc, false); 826 840 827 841 std::pair<boost::shared_ptr<CFilter>, boost::shared_ptr<CFilter> > filters; … … 829 843 if (grid && grid != fieldRef->grid && grid->hasTransform()) 830 844 { 831 double defaultValue = 0.0; 832 if (!default_value.isEmpty()) defaultValue = this->default_value; 845 double defaultValue = !default_value.isEmpty() ? default_value : 0.0; 833 846 filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid, defaultValue); 834 847 } 835 836 848 else 837 849 filters.first = filters.second = boost::shared_ptr<CFilter>(new CPassThroughFilter(gc)); 838 850 839 if (!OutputPin) fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0); 840 else OutputPin->connectOutput(filters.first, 0); 851 fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0); 841 852 842 853 return filters.second; … … 854 865 boost::shared_ptr<COutputPin> CField::getSelfReference(CGarbageCollector& gc) 855 866 { 856 if (instantDataFilter || ! 867 if (instantDataFilter || !hasExpression()) 857 868 ERROR("COutputPin* CField::getSelfReference(CGarbageCollector& gc)", 858 869 "Impossible to add a self reference to a field which has already been parsed or which does not have an expression."); … … 926 937 /*! 927 938 * Returns the temporal filter corresponding to the field's temporal operation 928 * for the specified operation frequency. The filter is created if it does not 929 * exist, otherwise it is reused. 939 * for the specified operation frequency. 930 940 * 931 941 * \param gc the garbage collector to use … … 936 946 boost::shared_ptr<COutputPin> CField::getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq) 937 947 { 938 939 948 if (instantDataFilter || !hasExpression()) 940 949 ERROR("COutputPin* CField::getSelfTemporalDataFilter(CGarbageCollector& gc)", … … 968 977 } 969 978 } 970 971 972 /*973 boost::shared_ptr<COutputPin> CField::getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq)974 {975 976 if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read)977 {978 if (!serverSourceFilter)979 serverSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid,980 freq_offset.isEmpty() ? NoneDu : freq_offset));981 982 selfReferenceFilter = serverSourceFilter;983 }984 else if (!field_ref.isEmpty())985 {986 CField* fieldRef = CField::get(field_ref);987 fieldRef->buildFilterGraph(gc, false);988 return fieldRef->getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq) ;989 }990 991 }992 993 */994 979 995 980 //---------------------------------------------------------------- … … 1425 1410 * \return if content is defined return content string, otherwise, if "expr" attribute is defined, return expr string. 1426 1411 */ 1427 string CField::getExpression(void) 1428 { 1429 if (! expr.isEmpty() && content.empty()) 1430 { 1431 content=expr ; 1432 expr.reset() ; 1433 } 1412 const string& CField::getExpression(void) 1413 { 1414 if (!expr.isEmpty() && content.empty()) 1415 { 1416 content = expr; 1417 expr.reset(); 1418 } 1419 1434 1420 return content; 1435 1421 } 1436 1437 bool CField::hasExpression(void) 1438 { 1439 if (! expr.isEmpty()) return true ; 1440 if (!content.empty()) return true ; 1441 return false; 1442 } 1422 1423 bool CField::hasExpression(void) const 1424 { 1425 return (!expr.isEmpty() || !content.empty()); 1426 } 1427 1443 1428 DEFINE_REF_FUNC(Field,field) 1444 1429 } // namespace xios
Note: See TracChangeset
for help on using the changeset viewer.