Changeset 873 for XIOS/trunk/src/filter
- Timestamp:
- 06/14/16 16:28:07 (8 years ago)
- Location:
- XIOS/trunk/src/filter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/filter/spatial_transform_filter.cpp
r842 r873 6 6 namespace xios 7 7 { 8 CSpatialTransformFilter::CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, size_t inputSlotsCount)9 : CFilter(gc, inputSlotsCount, engine) 8 CSpatialTransformFilter::CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, double outputValue, size_t inputSlotsCount) 9 : CFilter(gc, inputSlotsCount, engine), outputDefaultValue(outputValue) 10 10 { /* Nothing to do */ } 11 11 12 12 std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> > 13 CSpatialTransformFilter::buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid )13 CSpatialTransformFilter::buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, double defaultValue) 14 14 { 15 15 if (!srcGrid || !destGrid) … … 26 26 const std::vector<StdString>& auxInputs = gridTransformation->getAuxInputs(); 27 27 size_t inputCount = 1 + (auxInputs.empty() ? 0 : auxInputs.size()); 28 boost::shared_ptr<CSpatialTransformFilter> filter(new CSpatialTransformFilter(gc, engine, inputCount));28 boost::shared_ptr<CSpatialTransformFilter> filter(new CSpatialTransformFilter(gc, engine, defaultValue, inputCount)); 29 29 30 30 if (!lastFilter) … … 48 48 } 49 49 50 void CSpatialTransformFilter::onInputReady(std::vector<CDataPacketPtr> data) 51 { 52 CSpatialTransformFilterEngine* spaceFilter = static_cast<CSpatialTransformFilterEngine*>(engine); 53 CDataPacketPtr outputPacket = spaceFilter->applyFilter(data, outputDefaultValue); 54 if (outputPacket) 55 deliverOuput(outputPacket); 56 } 57 50 58 CSpatialTransformFilterEngine::CSpatialTransformFilterEngine(CGridTransformation* gridTransformation) 51 59 : gridTransformation(gridTransformation) … … 75 83 76 84 CDataPacketPtr CSpatialTransformFilterEngine::apply(std::vector<CDataPacketPtr> data) 85 { 86 /* Nothing to do */ 87 } 88 89 CDataPacketPtr CSpatialTransformFilterEngine::applyFilter(std::vector<CDataPacketPtr> data, double defaultValue) 77 90 { 78 91 CDataPacketPtr packet(new CDataPacket); … … 90 103 } 91 104 packet->data.resize(gridTransformation->getGridDestination()->storeIndex_client.numElements()); 105 packet->data = defaultValue; 92 106 apply(data[0]->data, packet->data); 93 107 } … … 99 113 { 100 114 CContextClient* client = CContext::getCurrent()->client; 115 116 // Get default value for output data 117 double defaultValue = 0.0; 118 if (0 != dataDest.numElements()) defaultValue = dataDest(0); 101 119 102 120 const std::list<CGridTransformation::SendingIndexGridSourceMap>& listLocalIndexSend = gridTransformation->getLocalIndexToSendFromGridSource(); 103 121 const std::list<CGridTransformation::RecvIndexGridDestinationMap>& listLocalIndexToReceive = gridTransformation->getLocalIndexToReceiveOnGridDest(); 104 122 const std::list<size_t>& listNbLocalIndexToReceive = gridTransformation->getNbLocalIndexToReceiveOnGridDest(); 123 const std::list<std::vector<bool> >& listLocalIndexMaskOnDest = gridTransformation->getLocalMaskIndexOnGridDest(); 105 124 106 125 CArray<double,1> dataCurrentDest(dataSrc.copy()); … … 110 129 std::list<CGridTransformation::RecvIndexGridDestinationMap>::const_iterator itListRecv = listLocalIndexToReceive.begin(); 111 130 std::list<size_t>::const_iterator itNbListRecv = listNbLocalIndexToReceive.begin(); 112 113 for (; itListSend != iteListSend; ++itListSend, ++itListRecv, ++itNbListRecv) 131 std::list<std::vector<bool> >::const_iterator itLocalMaskIndexOnDest = listLocalIndexMaskOnDest.begin(); 132 133 for (; itListSend != iteListSend; ++itListSend, ++itListRecv, ++itNbListRecv, ++itLocalMaskIndexOnDest) 114 134 { 115 135 CArray<double,1> dataCurrentSrc(dataCurrentDest); … … 164 184 165 185 dataCurrentDest.resize(*itNbListRecv); 166 dataCurrentDest = 0.0; 186 const std::vector<bool>& localMaskDest = *itLocalMaskIndexOnDest; 187 for (int i = 0; i < localMaskDest.size(); ++i) 188 if (localMaskDest[i]) dataCurrentDest(i) = 0.0; 189 else dataCurrentDest(i) = defaultValue; 190 167 191 currentBuff = 0; 168 192 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) -
XIOS/trunk/src/filter/spatial_transform_filter.hpp
r827 r873 21 21 * \param gc the associated garbage collector 22 22 * \param engine the engine defining the spatial transformation 23 * \param outputValue default value of output pin 23 24 * \param [in] inputSlotsCount number of input, by default there is only one for field src 24 25 */ 25 CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, size_t inputSlotsCount = 1);26 CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, double outputValue, size_t inputSlotsCount = 1); 26 27 27 28 /*! … … 34 35 */ 35 36 static std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> > 36 buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid); 37 buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, double defaultValue); 38 39 protected: 40 /*! 41 Overriding this function to process transformations with auxillary inputs 42 */ 43 void virtual onInputReady(std::vector<CDataPacketPtr> data); 44 45 protected: 46 //! Default value of output pin 47 double outputDefaultValue; 37 48 }; // class CSpatialTransformFilter 38 49 … … 56 67 * 57 68 * \param data a vector of packets corresponding to each slot (one in this case) 69 * \param [in] defaultValue default value of output data 70 * \return the result of the grid transformation 71 */ 72 CDataPacketPtr applyFilter(std::vector<CDataPacketPtr> data, double defaultValue = 0); 73 74 /*! 75 * Applies the grid transformation to the input data and returns the result. 76 * 77 * \param data a vector of packets corresponding to each slot (one in this case) 58 78 * \return the result of the grid transformation 59 79 */ 60 80 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 81 82 61 83 62 84 protected:
Note: See TracChangeset
for help on using the changeset viewer.