template<class T,class T2> void OPENGL_SCALAR_FIELD_2D<T,T2>:: Update() { VECTOR<int,2> start_index(values.domain.min_corner.x,values.domain.min_corner.y),end_index(values.domain.max_corner.x,values.domain.max_corner.y); if(!draw_ghost_values){start_index=clamp_min(start_index,VECTOR<int,2>(1,1));end_index=clamp_max(end_index,grid.counts);} if (draw_mode==DRAW_TEXTURE) Update_Texture(start_index,end_index); else if (draw_mode==DRAW_POINTS) Update_Points(start_index,end_index); else Update_Contour_Curves(); }
/** * Find the overlap of the inputWS with the given polygon * @param oldAxis1 :: Axis 1 bin boundaries from the input grid * @param oldAxis2 :: Axis 2 bin boundaries from the input grid * @param newPoly :: The new polygon to test * @returns A list of intersection locations with weights of the overlap */ std::vector<SofQW2::BinWithWeight> SofQW2::findIntersections(API::MatrixWorkspace_const_sptr inputWS, const Geometry::ConvexPolygon & newPoly) const { const MantidVec & oldAxis1 = inputWS->readX(0); // Find the X boundaries const double xn_lo(newPoly[0].X()), xn_hi(newPoly[2].X()); MantidVec::const_iterator start_it = std::upper_bound(oldAxis1.begin(), oldAxis1.end(), xn_lo); MantidVec::const_iterator end_it = std::upper_bound(oldAxis1.begin(), oldAxis1.end(), xn_hi); size_t start_index(0), end_index(oldAxis1.size() - 1); if( start_it != oldAxis1.begin() ) { start_index = (start_it - oldAxis1.begin() - 1); } if( end_it != oldAxis1.end() ) { end_index = end_it - oldAxis1.begin(); } const double yn_lo(newPoly[0].Y()), yn_hi(newPoly[1].Y()); std::vector<BinWithWeight> overlaps; overlaps.reserve(5); // Have a guess at a possible limit std::list<QRangeCache>::const_iterator iend = m_qcached.end(); for(std::list<QRangeCache>::const_iterator itr = m_qcached.begin(); itr != iend; ++itr) { for(size_t j = start_index; j < end_index; ++j) { const double xo_lo(oldAxis1[j]), xo_hi(oldAxis1[j+1]); const QValues & qold = itr->qValues[j]; if( qold.upperLeft < yn_lo || qold.upperRight < yn_lo || qold.lowerLeft > yn_hi || qold.lowerRight > yn_hi ) continue; Quadrilateral oldPoly(V2D(xo_lo, qold.lowerLeft), V2D(xo_hi, qold.lowerRight), V2D(xo_hi, qold.upperRight), V2D(xo_lo, qold.upperLeft)); try { ConvexPolygon overlap = intersectionByLaszlo(newPoly, oldPoly); // std::cerr << "Areas " << newPoly << " " << oldPoly << "\n"; // std::cerr << "Areas " << overlap.area() << " " << oldPoly.area() << "\n"; overlaps.push_back(BinWithWeight(itr->wsIndex,j,itr->weight*overlap.area()/oldPoly.area())); } catch(Geometry::NoIntersectionException &) {} } } return overlaps; }
Indices indices_at_offset ( LengthStrideIter first_ls , LengthStrideIter last_ls , GetLengthStride get_length_stride //provides length and stride funcitons to access lengths //and strides of elements in LengthStrideIter. , Offset offset0 ) /**@brief * Returns the indices corresponding to offset0 * in array with length and strides given by * first_ls...last_ls. * * This corresponds to equation (5.7) in @reference * for each axis. * **@reference: * _An APL Compiler_ * Timothy Budd * Springer-Verlag, 1988 */ { std::size_t const size=last_ls-first_ls ; Indices indices(size) ; typedef index_at_offset < typename Indices::value_type , typename LengthStrideIter::value_type , GetLengthStride , Offset > iao_t ; typedef transform_iterator < iao_t , LengthStrideIter > xiter_t ; iao_t iao_v(offset0,get_length_stride) ; xiter_t beg_index( first_ls, iao_v) ; xiter_t end_index( last_ls, iao_v) ; typename Indices::iterator beg_is=indices.begin() ; std::copy ( beg_index , end_index , beg_is ); return indices; }