TEST(CoordinateSetTest, Resize)
{
  CoordinateSet<Vector3> data;
  data.resize(5);
  EXPECT_EQ(data.size(), static_cast<size_t>(5));

  data.resize(3);
  EXPECT_EQ(data.size(), static_cast<size_t>(3));
}
/**
 * Get the set of coordinates that are not locked
 *
 * @param rUnlockedCoordinates set of unlocked coordinates is returned here
 */
void SimbodyEngine::getUnlockedCoordinates(const SimTK::State &s, CoordinateSet& rUnlockedCoordinates) const
{
    rUnlockedCoordinates.setSize(0);
    rUnlockedCoordinates.setMemoryOwner(false);

    for (int i = 0; i < _model->getCoordinateSet().getSize(); i++)
        if (!_model->getCoordinateSet().get(i).getLocked(s))
            rUnlockedCoordinates.adoptAndAppend(&_model->getCoordinateSet().get(i));
}
TEST(CoordinateSetTest, Store)
{
  CoordinateSet<Vector3> data;
  data.resize(5);
  data[0] = Vector3(0.0, 1.0, 2.0);
  EXPECT_EQ(data[0].x(), 0.0);
  EXPECT_EQ(data[0].y(), 1.0);
  EXPECT_EQ(data[0].z(), 2.0);
}
TEST(CoordinateSetTest, StoreTypeRetrieve)
{
  CoordinateSet<Vector3> data;
  data.resize(5);
  data[0] = Vector3(0.0, 1.0, 2.0);

  ArraySet *array = &data;
  CoordinateSet<Vector3> &ref = *reinterpret_cast< CoordinateSet<Vector3> *>(array);
  EXPECT_EQ(ref[0].x(), 0.0);
  EXPECT_EQ(ref[0].y(), 1.0);
  EXPECT_EQ(ref[0].z(), 2.0);
}
示例#5
0
unsigned int Game::coordstofieldindex(CoordinateSet pos) {
	unsigned int idx = 0;
	SizeVectorIt i;
	CoordinateSetIt j;
	for (i = this->dimensions.begin(), j = pos.begin();
		i != this->dimensions.end() && j != pos.end();
		++i, ++j) {
		assert(*j < *i);
		idx *= *i;
		idx += *j;
	}
	return idx;
}
示例#6
0
    inline void buildMesh( const osg::Vec3& v1, const osg::Vec3& v2, const osg::Vec3& v3 )
    {
        osg::Vec3* cb = &(_coordArray->front());
        int p1=&v1-cb, p2=&v2-cb, p3=&v3-cb;
        PolyMesh::Face* face =  new PolyMesh::Face( _coordArray, p1, p2, p3 );
        _meshFaces->push_back( face );

        EqualGroup g1=_coordSet.equal_range(&v1),
                   g2=_coordSet.equal_range(&v2),
                   g3=_coordSet.equal_range(&v3);
        buildEdge( g1, g2, face );
        buildEdge( g2, g3, face );
        buildEdge( g3, g1, face );
    }
示例#7
0
void CoordinateSets::write_xyz(std::string filename) {
    ofstream ofile(filename.c_str());
	for(size_t i = 0; i < size(); ++i) {
        CoordinateSet* pcset = load(i);
        ofile << pcset->size() << endl;
        ofile << "generated by s_coordump" << endl;
        for(size_t j = 0; j < pcset->size(); ++j)
        {
            ofile << j << " " << pcset->c1[j] << " " << pcset->c2[j] << " " << pcset->c3[j] << endl;
        }
        delete pcset;
	}
    ofile.close();
}
示例#8
0
    void setVerticsPtr( osg::Vec3Array* ca, unsigned int cs )
    {
        _coordSize = cs;
        _coordArray = ca;

        osg::Vec3* vptr = &(ca->front());
        for ( unsigned int i=0; i<cs; ++i )
            _coordSet.insert( vptr++ );
    }
示例#9
0
void Game::pressborders() {
	CoordinateSetList::const_iterator i;
	for (i = coordbegin(); i != coordend(); ++i) {
		CoordinateSet c = *i;
		CoordinateSetIt x;
		SizeVectorIt s;
		bool isborder = false;
		for (x = c.begin(), s = dimensions.begin(); x != c.end() && s != dimensions.end(); ++x, ++s) {
			if (*x == 0 || *x+1 == *s) {
				isborder = true;
				break;
			}
		}
		if (isborder) {
			Tile *tile = getTile(c);
			if (!tile->amIDeadNow())
				amIDeadNow(c);
		}
	}
}
示例#10
0
    void setVerticsPtr( vEngine::Vec3* cb, unsigned int cs )
    {
        _coordSize = cs;
        _coordBase = cb;

        vEngine::Vec3* vptr = cb;
        for ( unsigned int i=0; i<cs; ++i )
        {
            _coordSet.insert( vptr++ );
            _lastNormalRecorder.push_back( vEngine::Vec3(0.0f,0.0f,0.0f) );
        }
    }
示例#11
0
void Game::deploythemines(int mines) {
	std::vector<unsigned int> minelist;
	std::vector<unsigned int>::iterator minelistit, minelistit2;
	minelist.reserve(mines);
	while (mines-- > 0 && this->tilecount > minelist.size()) {
		unsigned int loc = ((unsigned int) rand()) % (this->tilecount-minelist.size());
		std::sort(minelist.begin(), minelist.end());
		for (minelistit = minelist.begin(); minelistit != minelist.end(); ++minelistit) {
			if (loc >= *minelistit) ++loc;
		}
		assert(loc < this->tilecount);
		if (opts.noborderbombs) {
			CoordinateSet c = fieldindextocoords(loc);
			SizeVectorIt i;
			CoordinateSetIt j;
			bool border = false;
			for (i = dimensions.begin(), j = c.begin(); i != dimensions.end() && j != c.end(); ++i, ++j) {
				if (*j == 0 || *j+1 == *i) {
					border = true;
					break;
				}
			}
			if (border) {
				++mines;
				continue;
			}
		}
		minelist.push_back(loc);
	}
	for (minelistit = minelist.begin(); minelistit != minelist.end(); ++minelistit) {
		this->tiles[*minelistit]->setBlarg(true);
		PTileSet neighbours = this->neighbourhood(this->fieldindextocoords(*minelistit));
		PTileSetIt i;
		for (i = neighbours.begin(); i != neighbours.end(); ++i) {
			assert(*i != NULL);
			(*i)->addNeighbouringBomb();
		}
	}
}
示例#12
0
    inline void incNormal( const vEngine::Vec3& vec, const vEngine::Vec3& normal, double weight )
    {
        std::pair<CoordinateSet::iterator, CoordinateSet::iterator> p =
            _coordSet.equal_range( &vec );

        for ( CoordinateSet::iterator itr=p.first; itr!=p.second; ++itr )
        {
            int pos = *itr - _coordBase;
            double t = normal * _lastNormalRecorder[pos];
            if ( _threshold<1.0f )
            {
                if ( !equivalent(_lastNormalRecorder[pos], vEngine::Vec3(0.0f,0.0f,0.0f)) 
                    && t<_threshold && t>-_threshold )
                    continue;
            }

            vEngine::Vec3* nptr = _normalBase + pos;
            *nptr += normal * weight;
            _lastNormalRecorder[pos] = normal;
        }
    }
示例#13
0
CoordinateSet Game::origo() {
	CoordinateSet res;
	res.resize(this->dimensioncount, 0);
	return res;
}