当前位置: 首页>>代码示例>>C++>>正文


C++ ParticleList::size方法代码示例

本文整理汇总了C++中ParticleList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleList::size方法的具体用法?C++ ParticleList::size怎么用?C++ ParticleList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParticleList的用法示例。


在下文中一共展示了ParticleList::size方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawTouchTrail

void RenderingEngine::DrawTouchTrail(){
    long length = _touchTrails->size();
    if(length == 0) return;
    if(length > _touchTrailArraysLength){
        if(_touchTrailArrays != NULL){
            delete _touchTrailArrays;
        }
        length *= 2;
        _touchTrailArrays = CreateParticlePointArrays(length*2);
        _touchTrailArraysLength = length;
    }
    glUniform1f(_uniforms.PointSize, _factory->particleWidth);
    DrawParticles(_touchTrails, _touchTrails->size(), _touchTrailArrays);
}
开发者ID:YouVisio,项目名称:frog-fu-youvisio,代码行数:14,代码来源:RenderingEngine.cpp

示例2: drawParticles

void ParticleRender::drawParticles(const ParticleList &particles) {
	ci::gl::ScopedTextureBind	stb(mTexture);
	// Prevent writing to the depth buffer, which will block out
	// pixels that are supposed to be transparent.
	ci::gl::ScopedDepthWrite	sdw(false);
	ci::gl::ScopedBlendAlpha	sba;
	ci::gl::color(1.0f, 1.0f, 1.0f, 1.0f);

	size_t						k = 0, size = particles.size();
	while (size >= BUFFER_SIZE) {
		drawParticles(k, k + BUFFER_SIZE, particles);
		k += BUFFER_SIZE;
		size -= BUFFER_SIZE;
	}
	drawParticles(k, particles.size(), particles);
}
开发者ID:hackborn,项目名称:cellulite,代码行数:16,代码来源:particle_render.cpp

示例3: AdvanceTime

void AdvanceTime(ParticleList& list, float dt, float timeStep)
{
    Time += dt;

    for (size_t i = 0; i < list.size(); ++i) {
        Point3 p(list[i].Px, list[i].Py, list[i].Pz);
        Vector3 v = ComputeCurl(p);
        Point3 midx = p + 0.5f * timeStep * v;
        p += timeStep * ComputeCurl(midx);
        list[i].Px = p.getX();
        list[i].Py = p.getY();
        list[i].Pz = p.getZ();
        list[i].Vx = v.getX();
        list[i].Vy = v.getY();
        list[i].Vz = v.getZ();
    }

    for (ParticleList::iterator i = list.begin(); i != list.end();) {
        if (i->Py > PlumeCeiling) {
            i = list.erase(i);
        } else {
            ++i;
        }
    }

   noise.set_time(0.5f*NoiseGain[0]/NoiseLengthScale[0]*Time);

   if (!ShowStreamlines || Time < 0.1f)
        SeedParticles(list, dt);
}
开发者ID:evandrewry,项目名称:glut-turbulent-billboards,代码行数:30,代码来源:Particles.cpp

示例4: beforeResort

void beforeResort(ParticleList &pl, OutBuffer& out) {
  if (pl.size() == 1) {
    beforeResortCalled = true;
    int res = 42;
    out.write(res);
  }
}
开发者ID:Clemson-MSE,项目名称:espressopp,代码行数:7,代码来源:PTestDomainDecomposition.cpp

示例5: afterResort

void afterResort(ParticleList &pl, InBuffer& inbuf) {
  if (pl.size() == 1) {
    afterResortCalled = true;
    int res;
    inbuf.read(res);
    BOOST_CHECK_EQUAL(res, 42);
  }
}
开发者ID:Clemson-MSE,项目名称:espressopp,代码行数:8,代码来源:PTestDomainDecomposition.cpp

示例6: afterRecvParticles

  void FixedSingleList::afterRecvParticles(ParticleList &pl, InBuffer& buf) {
	longint size = pl.size();
    std::vector< longint > received(size);
    buf.read(received);
    for (std::vector< longint >::iterator it=received.begin(); it!=received.end(); it++) {
    	globalSingles.insert(*it);
    }
    LOG4ESPP_INFO(theLogger, "received fixed single list after receive particles");
  }
开发者ID:Clemson-MSE,项目名称:espressopp,代码行数:9,代码来源:FixedSingleList.cpp

示例7: beforeSendParticles

  void FixedSingleList::beforeSendParticles(ParticleList& pl, OutBuffer& buf) {
	std::vector< longint > toSend(pl.size());
    // loop over the particle list
    for (ParticleList::Iterator pit(pl); pit.isValid(); ++pit) {
      longint pid = pit->id();
      toSend.push_back(pid);
      globalSingles.erase(pid);
      LOG4ESPP_DEBUG(theLogger, "erase and send particle with pid from FixedSingleList" << pid);
    }
    // send the list
    buf.write(toSend);
    LOG4ESPP_INFO(theLogger, "prepared fixed single list before send particles");
  }
开发者ID:Clemson-MSE,项目名称:espressopp,代码行数:13,代码来源:FixedSingleList.cpp

示例8:

void  VarianceDiffusionStrategy<StateType>::diffuse(const ParticleList &_src, ParticleList &_dest)
{
	if(_src.size() == 0) return;
	if(_dest.size() != _src.size()) _dest = _src;

	const unsigned numDofs = _src[0].state.size();

	unsigned index = 0;
	StateType noise = _dest[0].state;

	if(mVariance.size() != noise.size())
	{
		TRACE("------------- variance has wrong size. (should not be possible) ---------- ABORTING");
		return;
	}

	if(mVarianceFactor.size() != noise.size())
	{
		TRACE("----------resizing variance factors. (should not happen) -------------- ");
		mVarianceFactor.resize(noise.size(), 1);
	}

	// iterate over all source particles
	for(ParticleListConstIterator it = _src.begin(); it != _src.end(); it++)
	{
		// for every dof
		for(unsigned i=0; i < numDofs; i++)
		{
			noise[i] = this->mNormDistGenerator() *  mVariance[i] * mVarianceFactor[i];
		}

		_dest[index].state = noise;
		_dest[index].state += _src[index].state;

		index++;
	}
}
开发者ID:benknopp,项目名称:wombat,代码行数:37,代码来源:VarianceDiffusionStrategy.hpp

示例9: SeedParticles

static void SeedParticles(ParticleList& list, float dt)
{
    static float time = 0;
    time += dt;
    unsigned int num_new = (unsigned int) (time * ParticlesPerSecond);
    if (num_new == 0)
        return;

    time = 0;
    list.reserve(list.size() + num_new);
    for (unsigned int i = 0; i < num_new; ++i) {
        float theta = randhashf(Seed++, 0, M_PI * 2);
        float r = randhashf(Seed++, 0, SeedRadius);
        float y = randhashf(Seed++, 0, InitialBand);
        Particle p;
        p.Px = r*std::cos(theta);
        p.Py = PlumeBase + y;
        p.Pz = r*std::sin(theta) + 0.125f; // Nudge the emitter towards the viewer
        p.ToB = Time;
        list.push_back(p);
    }
}
开发者ID:evandrewry,项目名称:glut-turbulent-billboards,代码行数:22,代码来源:Particles.cpp

示例10: main

int main( int argc, char **argv )
{    
    //
    //  process command line parameters
    //
    if( find_option( argc, argv, "-h" ) >= 0 )
    {
        printf( "Options:\n" );
        printf( "-h to see this help\n" );
        printf( "-n <int> to set the number of particles\n" );
        printf( "-o <filename> to specify the output file name\n" );
        return 0;
    }
    
    int n = read_int( argc, argv, "-n", 1000 );
    char *savename = read_string( argc, argv, "-o", NULL );
    
    //
    //  set up MPI
    //
    int n_proc, rank;
    set_size(n);
    int num_cells = get_num_cells();
    MPI_Init( &argc, &argv );
    MPI_Comm_size( MPI_COMM_WORLD, &n_proc );
    MPI_Comm_rank( MPI_COMM_WORLD, &rank );
    
    //
    //  allocate generic resources
    //

    // FILE *fsave = savename && rank == 0 ? fopen( savename, "w" ) : NULL;
    FILE *fsave = savename ? fopen( savename, "w" ) : NULL;
    particle_t *particles = (particle_t*) malloc( n * sizeof(particle_t) );
    
    MPI_Datatype PARTICLE;
    MPI_Type_contiguous( 6, MPI_DOUBLE, &PARTICLE );
    MPI_Type_commit( &PARTICLE );
    

    ParticleList reference_particles; // the particles needed to compute correct forces on my_particles.
    ParticleList my_particles;        // the particles that this process is responsible for updating.

    CellMatrix cells(num_cells);
   
    // dummy particle
    particle_t dummy;
    dummy.x = -1;
    dummy.y = -1;

    //
    //  set up the data partitioning across processors
    //
    int *partition_offsets = (int*) malloc( (n_proc+1) * sizeof(int) );
    int *partition_sizes = (int*) malloc( n_proc * sizeof(int) );
    

    //
    //  allocate storage for local partition
    //
    int rows_per_thread = (num_cells + n_proc - 1) / n_proc;
    int top_row     = min(  rank     * rows_per_thread, num_cells); // the top row that the process is responsible for.
    int bottom_row  = min( (rank+1)  * rows_per_thread, num_cells); // the bottow row that this process needs but is not responsible for
    
    int my_amount;
    
    //
    //  initialize and distribute the particles (that's fine to leave it unoptimized)
    //
    ParticleList all_particles;
    all_particles.clear();
    init_cell_matrix(cells);
    if( rank == 0 )
    {
        all_particles.clear();
        init_particles( n, particles );
        
        update_cells(particles, cells, n);
        for(int rankId = 0; rankId < n_proc; rankId++) 
        {
            partition_offsets[rankId] = all_particles.size();
            int first_row = min(  rankId     * rows_per_thread, num_cells);
            int last_row  = min( (rankId+1)  * rows_per_thread, num_cells);

            ParticleList tmp;
            tmp.clear();
            get_particles_from_rows(first_row, last_row, &tmp, cells);
            all_particles.insert(all_particles.end(), tmp.begin(), tmp.end());
            partition_sizes[rankId] = tmp.size();

        }
       partition_offsets[n_proc] = n;
    }
    // broadcast all offsets and sizes so we can scatter later.
    MPI_Bcast(partition_offsets, n_proc+1, MPI_INT, 0, MPI_COMM_WORLD);
    MPI_Bcast(partition_sizes, n_proc, MPI_INT, 0, MPI_COMM_WORLD);

    // get my_amount from the partition sizes array and rezise the my_particles vector.
    my_amount = partition_sizes[rank];
    my_particles.resize(my_amount);
//.........这里部分代码省略.........
开发者ID:erikhaq,项目名称:particles,代码行数:101,代码来源:mpi_orig.cpp

示例11: spawn

void ParticleEmitter::spawn(float delta, const AnimationTime& at, ParticleList& ps, const Matrix& m)
{
	if (!mVisibility.getFrame(at.current))
	{
		return;
	}
	//换算成秒
	float timeFactor = delta / 1000.0f;
	mCurrentEmission += mEmitRate.getFrame(at) * timeFactor;
	while(mCurrentEmission >= 1.0f)
	{
		if (ps.size() >= mLimitNumber /*|| !ps.empty()*/)
		{
			return;
		}
		Particle p;
		p.mEmitter = this;
		float		speed;
		float		width;
		float		length;
		float		height;
		float		latitude;
		float		variation;

		p.mVertices[0].texture_.x = 0;
		p.mVertices[0].texture_.y = 0;

		p.mVertices[1].texture_.x = 0;
		p.mVertices[1].texture_.y = 1;

		p.mVertices[2].texture_.x = 1;
		p.mVertices[2].texture_.y = 1;

		p.mVertices[3].texture_.x = 1;
		p.mVertices[3].texture_.y = 0;

		p.mStopMove = false;

		p.mColorStart = mColorStart;
		p.mColorMiddle = mColorMiddle;
		p.mColorEnd = mColorEnd;
		p.mAlpha = mAlpha;
		speed = mSpeedKFs.getFrame(at);
		width = mWidth.getFrame(at);
		length = mLength.getFrame(at);
		height = mHeigth.getFrame(at);
		latitude = mLatitude.getFrame(at);
		variation = mVariationKFs.getFrame(at);
		speed *= (1.0f + randomReal(0.0f, variation));

		p.mPosition = Vector3(randomReal(-width,width), randomReal(-height,height), randomReal(-length,length));
		p.mPosition = m.applyVector(p.mPosition);
		p.mOriginalPosition = p.mPosition;
		p.mNodeOriginalPosition = m.applyToOrigin();
		Matrix mtxX;
		{
			Quaternion q;
			q.fromAngleAxis(randomReal(0,latitude * TwoPI / 360.f), Vector3::AxisX);
			mtxX.make(Vector3::Zero, Vector3::One, q);
		}
		
		Matrix mtxY;
		{
			Quaternion q;
			q.fromAngleAxis(randomReal(0,TwoPI), Vector3::AxisY);
			mtxY.make(Vector3::Zero, Vector3::One, q);
		}
		Matrix rot;
		rot.multiply(mtxX, mtxY);
		p.mVelocity = rot.applyVector(Vector3(0,1,0));
		p.mVelocity.normalise();
		p.mVelocity = m.applyVectorNormal(p.mVelocity);

		p.mVelocity *= speed;

		p.mAge = 0.0f;
		if(mLifeSpan < mLifeVar)
			p.mLife = mLifeSpan;
		else
			p.mLife= randomReal(mLifeSpan - mLifeVar, mLifeSpan + mLifeVar);

		p.mGravity = mGravity.getFrame(at);
		p.mExplosiveForce = mExplosiveForce.getFrame(at);

		//每个粒子的缩放比例都可能不同
		p.mScale.x = randomReal(mScale.x - mScaleVar.x, mScale.x + mScaleVar.x);
		if(mFixedSize)
		{
			p.mScale.y = p.mScale.z = p.mScale.x;
		}
		else
		{
			p.mScale.y = randomReal(mScale.y - mScaleVar.y, mScale.y + mScaleVar.y);
			p.mScale.z = randomReal(mScale.z - mScaleVar.z, mScale.z + mScaleVar.z);
		}

		//粒子旋转的角度
		p.mAngle = randomReal(mInitAngleBegin, mInitAngleEnd);
		p.mRotateSpeed = randomReal(mRotateSpeed - mRotateSpeedVar, mRotateSpeed + mRotateSpeedVar) * timeFactor * 15.0f;

//.........这里部分代码省略.........
开发者ID:cpzhang,项目名称:zen,代码行数:101,代码来源:ParticleEmitter.cpp

示例12: image

    /* recieve and rebuild global tuple information */
    void FixedTupleListAdress::afterRecvParticles
                                    (ParticleList &pl, InBuffer& buf) {

        //std::cout << "afterRecvParticles\n";

        /*
        std::vector<longint> received, pids;
        int n;
        longint pidK;
        GlobalTuples::iterator it = globalTuples.begin();


        // receive the tuple list
        buf.read(received);
        int size = received.size();

        int i = 0;
        while (i < size) {
            // unpack the list
            pidK = received[i++];
            //std::cout << "receive pidK "<< pidK << "\n";

            n = received[i++];
            //std::cout << "receive n "<< n << "\n";

            for (; n > 0; --n) {
            	LOG4ESPP_DEBUG(theLogger, "received vector for pid " << pidK);
                storage->addAdrATParticleFTPL(received[i]); // add AT particle to storage
                pids.push_back(received[i++]);
            }

            // add pids vector to global tuples
            it = globalTuples.insert(it, std::make_pair(pidK, pids));
            pids.clear();
        }

        if (i != size) {
            LOG4ESPP_ERROR(theLogger,
                    "recv particles might have read garbage\n");
        }

        LOG4ESPP_INFO(theLogger,
                "received fixed particle list after receive particles");
        */


        std::vector<longint> pids;
		int size, i, n;
		longint pidK;
		GlobalTuples::iterator it = globalTuples.begin();

		size = pl.size();

		for (i = 0; i < size; ++i) {
		    //std::cout << "i: " << i << "\n";

            // receive the tuple list
            //std::cout << "receive pidK: ";
            buf.read(pidK);
            //std::cout << pidK << " at ";


            /*
            // testing
            Particle* vp = storage->lookupRealParticle(pidK);
            Real3D vpp = vp->position();

            // see where VP is folded
            Real3D vpp_old = vpp;
            Real3D vpp_new = vpp;
            Real3D moved;
            int dir;
            Int3D image(0,0,0);

            for (dir = 0; dir < 3; ++dir) {
                storage->getSystem()->bc->foldCoordinate(vpp_new, image, dir);
                if (vpp_new[dir] != vpp_old[dir]) {
                    moved[dir] = vpp_old[dir] - vpp_new[dir];
                    break; // do not continue looping
                }
            }
            */


            //std::cout << "receive n: ";
            buf.read(n);
            //std::cout << n << "\n";

            //std::cout << storage->getRank() << ": add AT particles ";
            for (; n > 0; --n) {
                LOG4ESPP_DEBUG(theLogger, "received vector for pid " << pidK);
                /*storage->addAdrATParticleFTPL(received[i]); // add AT particle to storage
                pids.push_back(received[i++]);
                Particle *p = storage->addAdrATParticleFTPL();*/

                Particle p;
                //std::cout << " read *p : ";
                buf.read(p);

//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:espressopp,代码行数:101,代码来源:FixedTupleListAdress.cpp


注:本文中的ParticleList::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。