/[escript]/trunk/escript/src/DataTagged.cpp
ViewVC logotype

Diff of /trunk/escript/src/DataTagged.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 102 by jgs, Wed Dec 15 07:08:39 2004 UTC revision 108 by jgs, Thu Jan 27 06:21:59 2005 UTC
# Line 15  Line 15 
15    
16  #include "escript/Data/DataTagged.h"  #include "escript/Data/DataTagged.h"
17  #include "escript/Data/DataConstant.h"  #include "escript/Data/DataConstant.h"
18    #include "escript/Data/DataExpanded.h"
19    #include "escript/Data/DataException.h"
20    
21  #include <sstream>  #include <sstream>
22    
# Line 74  DataTagged::DataTagged(const DataTagged& Line 76  DataTagged::DataTagged(const DataTagged&
76    //    //
77    // get the shape of the slice to copy from other    // get the shape of the slice to copy from other
78    DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));    DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));
79    //    DataArrayView::RegionLoopRangeType region_loop_range=getSliceRegionLoopRange(region);
80    // allocate enough space for all values    // allocate enough space for all values
81    m_data.resize(DataArrayView::noValues(shape)*(other.m_offsetLookup.size()+1));    m_data.resize(DataArrayView::noValues(shape)*(other.m_offsetLookup.size()+1));
82    DataArrayView temp(m_data,shape);    DataArrayView temp(m_data,shape);
83    setPointDataView(temp);    setPointDataView(temp);
84    getDefaultValue().copySlice(other.getDefaultValue(),region);    getDefaultValue().copySlice(other.getDefaultValue(),region_loop_range);
85    //    //
86    // Loop through the tag values    // Loop through the tag values
87    DataMapType::const_iterator pos;    DataMapType::const_iterator pos;
88    DataArrayView::ValueType::size_type tagOffset=getPointDataView().noValues();    DataArrayView::ValueType::size_type tagOffset=getPointDataView().noValues();
89    for (pos=other.m_offsetLookup.begin();pos!=other.m_offsetLookup.end();++pos){    for (pos=other.m_offsetLookup.begin();pos!=other.m_offsetLookup.end();++pos){
90      getPointDataView().copySlice(tagOffset,other.getPointDataView(), pos->second,region);      getPointDataView().copySlice(tagOffset,other.getPointDataView(), pos->second,region_loop_range);
91      m_offsetLookup.insert(DataMapType::value_type(pos->first,tagOffset));      m_offsetLookup.insert(DataMapType::value_type(pos->first,tagOffset));
92      tagOffset+=getPointDataView().noValues();      tagOffset+=getPointDataView().noValues();
93    }    }
# Line 136  DataTagged::setSlice(const DataAbstract* Line 138  DataTagged::setSlice(const DataAbstract*
138    if (tempDataTag==0) {    if (tempDataTag==0) {
139      throw DataException("Programming error - casting to DataTagged.");      throw DataException("Programming error - casting to DataTagged.");
140    }    }
141      //
142      DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));
143      DataArrayView::RegionLoopRangeType region_loop_range=getSliceRegionLoopRange(region);
144      //
145    if (getPointDataView().getRank()!=region.size()) {    if (getPointDataView().getRank()!=region.size()) {
146      throw DataException("Error - Invalid slice region.");      throw DataException("Error - Invalid slice region.");
147    }    }
148    //    if (tempDataTag->getPointDataView().getRank()>0 && !value->getPointDataView().checkShape(shape)) {
   // get the shape of the slice  
   DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));  
   if (!value->getPointDataView().checkShape(shape)) {  
149      throw DataException (value->getPointDataView().createShapeErrorMessage(      throw DataException (value->getPointDataView().createShapeErrorMessage(
150                  "Error - Couldn't copy slice due to shape mismatch.",shape));                  "Error - Couldn't copy slice due to shape mismatch.",shape));
151    }    }
152    //    //
153    getDefaultValue().copySliceFrom(tempDataTag->getDefaultValue(),region);    getDefaultValue().copySliceFrom(tempDataTag->getDefaultValue(),region_loop_range);
154    //    //
155    // Loop through the tag values    // Loop through the tag values
156    DataMapType::const_iterator pos;    DataMapType::const_iterator pos;
157    for (pos=m_offsetLookup.begin();pos!=m_offsetLookup.end();++pos){    for (pos=m_offsetLookup.begin();pos!=m_offsetLookup.end();++pos){
158      getDataPointByTag(pos->first).copySliceFrom(tempDataTag->getDataPointByTag(pos->first),region);      getDataPointByTag(pos->first).copySliceFrom(tempDataTag->getDataPointByTag(pos->first),region_loop_range);
159    }    }
160  }  }
161    

Legend:
Removed from v.102  
changed lines
  Added in v.108

  ViewVC Help
Powered by ViewVC 1.1.26