Beispiel #1
0
    void generateRandomParticles(
        ParticleStore& particles,
        Bounds const& bounds,
        Generator& gen
    ) {
        typedef typename ParticleStore::value_type Particle;
        typedef typename ParticleStore::iterator PvIter;

        for(PvIter p(particles.begin()); p!=particles.end(); ++p) {
            generateRandomPosition(bounds.begin(), bounds.end(), p->beginPosition(), gen);
        }
    }
Beispiel #2
0
        static bool checkBoundsOK(
            PositionIter posIter,
            Bounds const& bounds
        ) {
            typedef typename Bounds::const_iterator BvIter;

            BvIter
                b(bounds.begin()),
                e(bounds.end());

            for(; b!=e; ++b, ++posIter) if(*posIter < b->first || *posIter > b->second) return false;

            return true;
        }
Beispiel #3
0
        static void moveParticleInbounds(
            PositionIter posIter,
            Bounds const& bounds,
            NT jitter,
            Generator& gen
        ) {
            typedef typename Bounds::const_iterator BvIter;

            BvIter
                bb(bounds.begin());

            for(; bb!=bounds.end(); ++bb, ++posIter) {
                if(*posIter < bb->first) *posIter = bb->first + gen() * (bb->second - bb->first) * jitter;
                else if(*posIter > bb->second) *posIter = bb->second - gen() * (bb->second - bb->first) * jitter;
            }
        }
std::vector< Projection::MappedPoint >
ScaledProjection::cut_region_of_interest_( const ROISpecification& r ) const
{
    std::vector< MappedPoint > rv;
    Bounds bb = get_region_of_interest_( r );

    if ( r.guaranteed_row_width ) {
        quantity< camera::length, int > 
            one =1 * camera::pixel, width = bb.width(Direction_X),
            lower = bb.get_lower_edge( Direction_X ), upper = bb.get_upper_edge( Direction_X );
        if ( width < *r.guaranteed_row_width ) { 
            lower -= one; width += one; 
            if ( width < *r.guaranteed_row_width ) 
                { upper += one; width += one; }
        } else if ( width > *r.guaranteed_row_width ) {
            upper -= one; width -= one;
        }
        assert( width == *r.guaranteed_row_width );
        while ( upper >= size.x() )
            { upper -= one; lower -= one; }
        while ( lower < 0 * camera::pixel )
            { lower += one; upper += one; }
        if ( upper >= size.x() )
            throw std::runtime_error("Image is too small for desired ROI");

        bb.set_range( lower, upper, Direction_X );
    }

    ImagePosition pos;
    typedef ImagePosition::Scalar Pixel;
    rv.reserve( bb.volume().value() );
    SamplePosition sample;
    for ( Bounds::const_iterator i = bb.begin(); i != bb.end(); ++i ) {
        rv.push_back( MappedPoint( *i, pixel_in_sample_space(*i) ) );
    }
    return rv;
}