void EditView::OnFramesRemoved(int first, int last) { if(Frame()>=first) { int newframe = Frame()-(last-first); if(newframe<0) newframe=0; if(newframe>Proj().GetAnim().NumFrames()-1) newframe = Proj().GetAnim().NumFrames()-1; SetFrame(newframe); } }
void EditView::SetZoom( int zoom ) { if(zoom<1) zoom=1; if(zoom>128) zoom=128; if(zoom == m_Zoom) return; m_Zoom = zoom; m_XZoom = Proj().Settings().PixW*zoom; m_YZoom = Proj().Settings().PixH*zoom; ConfineView(); DrawView(m_ViewBox); Redraw(m_ViewBox); }
void Proj2::realize() { if (sproj == "") return; _proj = Proj(sproj); _llproj = _proj.latlong_from_proj(); }
void EditView::CenterView() { Box const& p = Proj().ImgConst(Frame()).Bounds(); Box v = ViewToProj( m_ViewBox ); m_Offset.x = -(v.w - p.w) / 2; m_Offset.y = -(v.h - p.h) / 2; }
typename util::detail::algorithm_result<ExPolicy, InIter>::type for_each_n(ExPolicy && policy, InIter first, Size count, F && f, Proj && proj = Proj()) { typedef typename std::iterator_traits<InIter>::iterator_category iterator_category; static_assert( (boost::is_base_of<std::input_iterator_tag, iterator_category>::value), "Requires at least input iterator."); // if count is representing a negative value, we do nothing if (detail::is_negative<Size>::call(count)) { return util::detail::algorithm_result<ExPolicy, InIter>::get( std::move(first)); } typedef typename boost::mpl::or_< is_sequential_execution_policy<ExPolicy>, boost::is_same<std::input_iterator_tag, iterator_category> >::type is_seq; return detail::for_each_n<InIter>().call( std::forward<ExPolicy>(policy), is_seq(), first, std::size_t(count), std::forward<F>(f), std::forward<Proj>(proj)); }
void EditView::Resize( int w, int h ) { if(m_Canvas) { delete m_Canvas; m_Canvas = 0; } m_ViewBox.w = w; m_ViewBox.h = h; m_Canvas = new Img( FMT_RGBX8, w,h ); ConfineView(); // if view is wider/taller than image, center it Box const& p = Proj().ImgConst(Frame()).Bounds(); Box v = ViewToProj( m_ViewBox ); if( v.w>p.w) m_Offset.x = -(v.w - p.w) / 2; if( v.h>p.h) m_Offset.y = -(v.h - p.h) / 2; DrawView(m_ViewBox); Redraw(m_ViewBox); }
void EditView::OnPaletteReplaced() { // redraw the whole project Box area(ProjToView(Proj().GetAnim().GetFrame(Frame()).Bounds())); Box affected; DrawView(area,&affected); Redraw(affected); }
cElHJaDroite::cElHJaDroite ( const ElSeg3D & aDr, cElHJaPlan3D & aP1, cElHJaPlan3D & aP2, INT aNbPl ) : mDr (aDr), mSegPl (Proj(mDr.P0()),Proj(mDr.P1())), mP1 (&aP1), mP2 (&aP2) { aP1.AddInter(*this,aP2); aP2.AddInter(*this,aP1); for(INT aK=0; aK<aNbPl ; aK++) mInters.push_back(0); }
double DistSP(Segment s,Point p) { int ccw=CCW(s.pos,s.pos+s.dir,Proj(s,p)); if(ccw==-2) return abs(p-s.pos); if(ccw==2) return abs(p-(s.pos+s.dir)); return DistLP(s,p); }
typename util::detail::algorithm_result< ExPolicy, typename traits::range_iterator<Rng>::type >::type for_each(ExPolicy && policy, Rng && rng, F && f, Proj && proj = Proj()) { return for_each(std::forward<ExPolicy>(policy), boost::begin(rng), boost::end(rng), std::forward<F>(f), std::forward<Proj>(proj)); }
void EditView::SetFrame( int frame ) { assert( frame>=0); assert( frame<Proj().GetAnim().NumFrames()); m_Frame = frame; ConfineView(); DrawView(m_ViewBox); Redraw(m_ViewBox); }
typename util::detail::algorithm_result< ExPolicy, typename traits::range_traits<Rng>::iterator_type >::type max_element(ExPolicy && policy, Rng && rng, F && f = F(), Proj && proj = Proj()) { return max_element(std::forward<ExPolicy>(policy), boost::begin(rng), boost::end(rng), std::forward<F>(f), std::forward<Proj>(proj)); }
typename util::detail::algorithm_result< ExPolicy, typename traits::range_traits<Rng>::iterator_type >::type replace(ExPolicy && policy, Rng && rng, T1 const& old_value, T2 const& new_value, Proj && proj = Proj()) { return replace(std::forward<ExPolicy>(policy), boost::begin(rng), boost::end(rng), old_value, new_value, std::forward<Proj>(proj)); }
typename util::detail::algorithm_result< ExPolicy, typename traits::range_iterator<Rng>::type >::type sort(ExPolicy && policy, Rng && rng, Compare && comp = Compare(), Proj && proj = Proj()) { return sort(std::forward<ExPolicy>(policy), boost::begin(rng), boost::end(rng), std::forward<Compare>(comp), std::forward<Proj>(proj)); }
// confine the view to keep as much of the image onscreen as possible. void EditView::ConfineView() { Box const& p = Proj().ImgConst(Frame()).Bounds(); Box v = ViewToProj( m_ViewBox ); #if 0 if( p.W() < v.W() ) m_Offset.x = -(v.W()-p.W())/2; // center else if( v.XMin() < 0 ) m_Offset.x = 0; else if( v.XMax() > p.XMax() ) m_Offset.x = (p.x + p.W()) - v.W(); if( p.H() < v.H() ) m_Offset.y = -(v.H()-p.H())/2; // center else if( v.YMin() < 0 ) m_Offset.y = 0; else if( v.YMax() > p.YMax() ) m_Offset.y = (p.y+p.H()) - v.H(); #endif if( p.W() < v.W() ) { // view is wider than proj if( v.XMin() > p.XMin() ) m_Offset.x = p.XMin(); if( v.XMax() < p.XMax() ) m_Offset.x = (p.x + p.W())-v.W(); } else { // proj is wider than view if( v.XMin() < 0 ) m_Offset.x = 0; else if( v.XMax() > p.XMax() ) m_Offset.x = (p.x + p.W()) - v.W(); } if( p.H() < v.H() ) { // view is taller than proj if( v.YMin() > p.YMin() ) m_Offset.y = p.YMin(); if( v.YMax() < p.YMax() ) m_Offset.y = (p.y + p.H())-v.H(); } else { // proj is taller than view if( v.YMin() < 0 ) m_Offset.y = 0; else if( v.YMax() > p.YMax() ) m_Offset.y = (p.y+p.H()) - v.H(); } }
int main(){ Options o; o.put("lon0",39.0); o.put("E0",500000.0); convs::pt2pt cnv(Datum("wgs84"), Proj("lonlat"), Options(), Datum("pulkovo"), Proj("tmerc"), o); dPoint p( 39 + ((double)rand()/RAND_MAX - 0.5) * 6, // 36..42 ((double)rand()/RAND_MAX - 0.5) * 180); // -90..+90 printf("%.12f %.12f\n",p.x,p.y); int i; for (i=0; i<1000000; i++){ cnv.frw(p); cnv.bck(p); } printf("%.12f %.12f\n",p.x,p.y); }
typename util::detail::algorithm_result< ExPolicy, hpx::util::tagged_pair< tag::in(typename traits::range_traits<Rng>::iterator_type), tag::out(OutIter) > >::type copy_if(ExPolicy && policy, Rng && rng, OutIter dest, F && f, Proj && proj = Proj()) { return copy_if(std::forward<ExPolicy>(policy), boost::begin(rng), boost::end(rng), dest, std::forward<F>(f), std::forward<Proj>(proj)); }
typename util::detail::algorithm_result< ExPolicy, hpx::util::tagged_pair< tag::in(typename traits::range_traits<Rng>::iterator_type), tag::out(OutIter) > >::type replace_copy(ExPolicy && policy, Rng && rng, OutIter dest, T1 const& old_value, T2 const& new_value, Proj && proj = Proj()) { return replace_copy(std::forward<ExPolicy>(policy), boost::begin(rng), boost::end(rng), dest, old_value, new_value, std::forward<Proj>(proj)); }
typename util::detail::algorithm_result<ExPolicy, InIter>::type for_each(ExPolicy && policy, InIter first, InIter last, F && f, Proj && proj = Proj()) { typedef typename std::iterator_traits<InIter>::iterator_category iterator_category; static_assert( (boost::is_base_of<std::input_iterator_tag, iterator_category>::value), "Requires at least input iterator."); typedef hpx::traits::segmented_iterator_traits<InIter> iterator_traits; typedef typename iterator_traits::is_segmented_iterator is_segmented; return detail::for_each_( std::forward<ExPolicy>(policy), first, last, std::forward<F>(f), std::forward<Proj>(proj), is_segmented()); }
EditView::EditView( Editor& editor, int w, int h ) : m_Editor(editor), m_PrevPos(-1,-1), m_Canvas( new Img(FMT_RGBX8,w,h ) ), m_ViewBox(0,0,w,h), m_Frame(0), m_Zoom(4), m_Offset(0,0), m_Panning(false), m_PanAnchor(0,0) { m_XZoom = m_Zoom*editor.Proj().Settings().PixW; m_YZoom = m_Zoom*editor.Proj().Settings().PixH; CenterView(); DrawView(m_ViewBox); Proj().AddListener( this ); editor.AddView( this ); }
LagrangeMatrix(PointIter first, PointIter last, Proj proj = Proj()) { p.resize(std::distance(first,last)); q.resize(p.size()); auto pit = p.begin(); auto qit = q.begin(); for ( ; first != last; ++first, ++pit, ++qit) { auto&& point = proj(*first); // Copy the point to p[i] std::array<T,D>& pi = *pit; std::copy(point.begin(), point.end(), pi.begin()); // Compute the pre-factors q[i] std::array<T,D>& qi = *qit; qi.fill(T(1)); for (std::size_t k = 0; k != Q; ++k) { for (std::size_t d = 0; d != D; ++d) { qi[d] *= (pi[d] - Chebyshev<T,Q>::x[k]); } } } }
XMMATRIX Camera::ViewProj()const { return XMMatrixMultiply(View(), Proj()); }
void cElHJaArrangt::ConstruireAll() { mStats.push_back ( cStatistique ( 0.0, 0.0, mSurfEmpr * mNbPl ) ); bool toShoTime = false; ElTimer aChrono; ELISE_ASSERT(mNbPl>=0,"No Init int cElHJaArrangt"); // Construction de la geometrie 3D for (tItPl itPl = mPlans.begin() ; itPl!=mPlans.end() ; itPl++) { (*itPl)->SetNbPlansInter(mNbPl); } for (tItPl itPl1 = mPlans.begin() ; itPl1!=mPlans.end() ; itPl1++) { for (tItPl itPl2 = NextIter(itPl1) ; itPl2!=mPlans.end() ; itPl2++) { bool Ok; ElSeg3D aD3d = (*itPl1)->Plan().Inter((*itPl2)->Plan(),Ok); if (Ok) { mDroites.push_back(new cElHJaDroite(aD3d,**itPl1,**itPl2,mNbPl)); for (tItPl itPl3=NextIter(itPl2) ; itPl3!=mPlans.end() ; itPl3++) { Pt3dr aP = (*itPl1)->Plan().Inter((*itPl2)->Plan(),(*itPl3)->Plan(),Ok); if (Ok && PointInPoly(mEmprVPt2d,Proj(aP))) mPoints.push_back(new cElHJaPoint(aP,**itPl1,**itPl2,**itPl3)); } } } } for (tItPoint itPt = mPoints.begin() ; itPt!=mPoints.end() ; itPt++) (*itPt)->MakeDroites(); if (toShoTime) cout << "Time Geom3D : " << aChrono.ValAndInit() << "\n"; // Construction des Intersection Droites/emprise for (tItDr itD = mDroites.begin(); itD!=mDroites.end(); itD++) (*itD)->MakeIntersectionEmprise(mEmprPl); if (toShoTime) cout << "Time Inter Emprise : " << aChrono.ValAndInit() << "\n"; // Construction des facettes dans chaque plan for (tItPl itPl = mPlans.begin() ; itPl!=mPlans.end() ; itPl++) (*itPl)->AddArcEmpriseInGraphe(); for (tItDr itD = mDroites.begin(); itD!=mDroites.end(); itD++) (*itD)->AddArcsInterieurInGraphe(mEmprVPt2d); for (tItPl itPl = mPlans.begin() ; itPl!=mPlans.end() ; itPl++) (*itPl)->MakeFacettes(*this); if (toShoTime) cout << "Time Facette : " << aChrono.ValAndInit() << "\n"; // Construction des relations entre facettes for (tItFac itF = mFacettes.begin() ; itF!=mFacettes.end() ; itF++) (*itF)->MakeAdjacences(); for (tItFac itF1 = mFacettes.begin() ; itF1!=mFacettes.end() ; itF1++) for (tItFac itF2 = NextIter(itF1) ; itF2!=mFacettes.end() ; itF2++) (*itF1)->MakeRecouvrt(*itF2); TriTopologiqueFacette(); if (toShoTime) cout << "Time Relation F : " << aChrono.ValAndInit() << "\n"; }
XMMATRIX Camera::ViewProj()const { XMMATRIX m = XMMatrixMultiply(View(),Proj()); return m; }
double DistLP(Line l,Point p) { return abs(Proj(l,p)-p); }
EditView::~EditView() { Proj().RemoveListener( this ); Ed().RemoveView( this ); delete m_Canvas; }
void EditView::DrawView( Box const& viewbox, Box* affectedview ) { // note: viewbox can be outside the project boundary // Colour checkerboard[2] = { Colour(192,192,192), Colour(224,224,224) }; Box vb(viewbox); vb.ClipAgainst(m_ViewBox); Img const& img = Proj().GetAnim().GetFrame(Frame()); // get project bounds in view coords (unclipped) Box pbox(ProjToView(img.Bounds())); // step x,y through view coords of the area to draw int y; // int xmin = std::min(pbox.XMin(), vb.XMax()+1); int xbegin = std::min(pbox.x, vb.x + vb.w); int xend = std::min(pbox.x + pbox.w, vb.x + vb.w); for(y=vb.YMin(); y<=vb.YMax(); ++y) { RGBX8* dest = m_Canvas->Ptr_RGBX8(vb.x,y); int x=vb.XMin(); // scanline intersects canvas? if(y<pbox.YMin() || y>pbox.YMax()) { // line is above or below the project while(x<=vb.XMax()) { *dest++ = checker2(x,y); ++x; } continue; } // left of project canvas while(x<xbegin) { *dest++ = checker2(x,y); ++x; } if(x<xend) { // on the project canvas Point p( ViewToProj(Point(x,y)) ); switch( img.Fmt() ) { case FMT_I8: { /* if( p.x<0) { printf("POOP:\n"); printf("pbox: %d %d %d %d\n", pbox.x, pbox.y, pbox.w, pbox.h); printf("vb : %d %d %d %d\n", vb.x, vb.y, vb.w, vb.h); printf("x,y : %d %d\n", x,y); printf("p.x,p.y : %d %d\n", p.x,p.y); printf("xbegin,xend : %d %d\n", xbegin,xend); } assert( p.x >=0); assert( p.x < img.W()); assert( p.y < img.H()); assert( p.y >=0); */ //printf("%d\n",y); I8 const* src = img.PtrConst_I8( p.x,p.y ); while(x<xend) { int cx = x + (m_Offset.x*m_XZoom); int pixstop = x + (m_XZoom-(cx%m_XZoom)); if(pixstop>xend) pixstop=xend; RGBA8 c = Proj().PaletteConst().GetColour(*src++); while(x<pixstop) { //*dest++ = c; *dest++ = Blend(c,checker(x,y)); ++x; } } } break; case FMT_RGBX8: { RGBX8 const* src = img.PtrConst_RGBX8( p.x,p.y ); while(x<xend) { int cx = x + (m_Offset.x*m_XZoom); int pixstop = x + (m_XZoom-(cx%m_XZoom)); if(pixstop>xend) pixstop=xend; RGBX8 c = *src++; while(x<pixstop) { *dest++ = c; ++x; } } } break; case FMT_RGBA8: { RGBA8 const* src = img.PtrConst_RGBA8( p.x,p.y ); while(x<xend) { int cx = x + (m_Offset.x*m_XZoom); int pixstop = x + (m_XZoom-(cx%m_XZoom)); if(pixstop>xend) pixstop=xend; RGBA8 c = *src++; while(x<pixstop) { *dest++ = Blend(c,checker(x,y)); ++x; } } } break; default: assert(false); break; } } // right of canvas while(x < vb.x+vb.w) { *dest++ = checker2(x,y); ++x; } } if(affectedview) *affectedview = vb; }
Tvec Perp(Tvec u, Tvec v) { return u-Proj(u, v); }
void EditView::OnAnimReplaced() { assert(Proj().GetAnim().NumFrames() > 0); SetFrame(0); }
/** Returns a new coordinate system definition which is the geographic coordinate (lat/long) system underlying pj_in. This is essential in creating TWO Proj objects to be used in the transform() subroutines below. */ Proj latlong_from_proj() const { return Proj(pj_latlong_from_proj(pj)); }