本文整理汇总了C++中GridType类的典型用法代码示例。如果您正苦于以下问题:C++ GridType类的具体用法?C++ GridType怎么用?C++ GridType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GridType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: g
void
ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map)
{
#ifndef NOTSAFE_SEMAPHORE_OVERHANDLING
HashMapHolder<Corpse>::ReadGuard g(HashMapHolder<Corpse>::GetLock());
#endif
for(Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter)
if(iter->second->GetGrid() == gridpair)
{
// verify, if the corpse in our instance (add only corpses which are)
if (map->Instanceable())
{
if (iter->second->GetInstanceId() == map->GetInstanceId())
{
grid.AddWorldObject(iter->second);
}
}
else
{
grid.AddWorldObject(iter->second);
}
}
}
示例2: readData
void GameController::readData(std::istream& input)
{
BlockPairQueue nextBlocks;
GridType myNewGrid;
GridType opponentNewGrid;
for (int i = 0; i < QUEUE_LENGTH; i++)
{
int colorA;
int colorB;
input >> colorA >> colorB; input.ignore();
nextBlocks.push_back(std::make_pair(Block(colorA), Block(colorB)));
}
for (int i = 0; i < GRID_HEIGHT; i++)
{
std::string row;
input >> row; input.ignore();
myNewGrid.push_back(row);
}
for (int i = 0; i < GRID_HEIGHT; i++)
{
std::string row;
input >> row; input.ignore();
opponentNewGrid.push_back(row);
}
nextBlocks_ = nextBlocks;
currentGrid_.reset(myNewGrid);
opponentGrid_.reset(opponentNewGrid);
}
示例3: fnAdvectSemiLagrange_time_fraction
void fnAdvectSemiLagrange_time_fraction(FluidSolver* parent, FlagGrid& flags, MACGrid& vel, GridType& orig, int order, Real strength, Real time_fraction) {
typedef typename GridType::BASETYPE T;
Real dt = (time_fraction) * parent->getDt();
std::cout << " time_fraction = " << time_fraction << std::endl ;
std::cout << " dt = " << dt << std::endl ;
bool levelset = orig.getType() & GridBase::TypeLevelset;
// forward step
GridType fwd(parent);
SemiLagrange<T> (flags, vel, fwd, orig, dt, levelset);
if (order == 1) {
orig.swap(fwd);
}
else if (order == 2) { // MacCormack
GridType bwd(parent);
GridType newGrid(parent);
// bwd <- backwards step
SemiLagrange<T> (flags, vel, bwd, fwd, -dt, levelset);
// newGrid <- compute correction
MacCormackCorrect<T> (flags, newGrid, orig, fwd, bwd, strength, levelset);
// clamp values
MacCormackClamp<T> (flags, vel, newGrid, orig, fwd, dt);
orig.swap(newGrid);
}
}
开发者ID:tusharuiit,项目名称:2014-2015_MastersThesisPressureTemplatesForSmokeSimulationIn3D,代码行数:31,代码来源:advection.cpp
示例4: Rs
bool singleRPAJastrowBuilder::put(xmlNodePtr cur, int addOrbital)
{
MyName="Jep";
string rpafunc="RPA";
OhmmsAttributeSet a;
a.add(MyName,"name");
a.add(rpafunc,"function");
a.put(cur);
ParameterSet params;
RealType Rs(-1.0);
RealType Kc(-1.0);
params.add(Rs,"rs","double");
params.add(Kc,"kc","double");
params.put(cur);
if(Rs<0) {
Rs=tlen;
}
if(Kc<0){
Kc = 1e-6 ;
};
if (rpafunc=="RPA"){
myHandler= new LRRPAHandlerTemp<EPRPABreakup<RealType>,LPQHIBasis>(targetPtcl,Kc);
app_log()<<" using e-p RPA"<<endl;
}
else if (rpafunc=="dRPA") {
myHandler= new LRRPAHandlerTemp<derivEPRPABreakup<RealType>,LPQHIBasis>(targetPtcl,Kc);
app_log()<<" using e-p derivRPA"<<endl;
}
myHandler->Breakup(targetPtcl,Rs);
// app_log() << " Maximum K shell " << myHandler->MaxKshell << endl;
// app_log() << " Number of k vectors " << myHandler->Fk.size() << endl;
//Add short range part
Rcut = myHandler->get_rc()-0.1;
GridType* myGrid = new GridType;
int npts=static_cast<int>(Rcut/0.01)+1;
myGrid->set(0,Rcut,npts);
//create the numerical functor
nfunc = new FuncType;
SRA = new ShortRangePartAdapter<RealType>(myHandler);
SRA->setRmax(Rcut);
nfunc->initialize(SRA, myGrid);
J1s = new JneType (*sourcePtcl,targetPtcl);
for(int ig=0; ig<ng; ig++) {
J1s->addFunc(ig,nfunc);
}
app_log()<<" Only Short range part of E-I RPA is implemented"<<endl;
if (addOrbital) targetPsi.addOrbital(J1s,MyName);
return true;
}
示例5: Event_AddedToWorld
void Camera::Event_AddedToWorld()
{
GridType* grid = m_source->GetViewPoint().m_grid;
MANGOS_ASSERT(grid);
grid->AddWorldObject(this);
UpdateVisibilityForOwner();
}
示例6: ResetView
void Camera::Event_AddedToWorld()
{
if (!IsInitialized())
ResetView();
GridType* grid = GetBody()->GetViewPoint().m_grid;
MANGOS_ASSERT(grid);
grid->AddWorldObject(this);
UpdateVisibilityForOwner();
}
示例7: stepFinished
void stepFinished(const GridType& grid, unsigned step, WriterEvent event)
{
avrgTemperature = 0;
CoordBox<2> box = grid.boundingBox();
for (CoordBox<2>::Iterator i = box.begin(); i != box.end(); ++i) {
avrgTemperature += grid.get(*i).temperature;
}
avrgTemperature /= box.dimensions.prod();
std::cout << "averageTemperature(" << step << ") = " << avrgTemperature << "\n";
}
示例8: loader
void ObjectGridLoader::Load(GridType &grid)
{
{
TypeContainerVisitor<ObjectGridLoader, GridTypeMapContainer > loader(*this);
grid.Visit(loader);
}
{
ObjectWorldLoader wloader(*this);
TypeContainerVisitor<ObjectWorldLoader, WorldTypeMapContainer > loader(wloader);
grid.Visit(loader);
i_corpses = wloader.i_corpses;
}
}
示例9: main
int main(int argc, const char **argv){
if (argc != 3 && argc != 5){
printf("Usage: prog sides num_blanks [wid hei]\n");
return 1;
}
size_t blanks = atol(argv[2]);
size_t sides = atol(argv[1]);
size_t wid = DEFAULT_WIDTH;
size_t hei = DEFAULT_HEIGHT;
if (argc == 5){
wid = atol(argv[3]);
hei = atol(argv[4]);
}
sierp2d::Model<double, ModelType, GridType> model;
for (int blank=0; blank < blanks; ++blank){
model.points.push_back(sierp2d::Point<double>(wid/2, hei/2));
}
model.add_regular(wid, hei, sides);
GridType * front = new GridType( {wid, hei} );
GridType * back = new GridType( {wid, hei} );
GridType * temp = NULL;
front->get_point({wid/2, hei/2}) = INITIAL;
while (true){
bool hit_max = model.next(*front, *back);
if (hit_max) break;
temp = back;
back = front;
front = temp;
}
temp = NULL;
delete back;
ModelType maxval = front->max();
double scale = UIMAX(ModelType) / ((double)maxval);
for (ModelType &val : *front){
val *= scale;
}
front->invert();
char file_name[255];
sprintf(file_name, "out-%zu-%zu.png", blanks, sides);
png::write(*front, file_name);
delete front;
}
示例10: LoadHelper
void LoadHelper(CellGuidSet const& guid_set, CellPair& cell, GridRefManager<T>& /*m*/, uint32& count, Map* map, GridType& grid)
{
BattleGround* bg = map->IsBattleGroundOrArena() ? ((BattleGroundMap*)map)->GetBG() : NULL;
for (CellGuidSet::const_iterator i_guid = guid_set.begin(); i_guid != guid_set.end(); ++i_guid)
{
uint32 guid = *i_guid;
T* obj = new T;
// sLog.outString("DEBUG: LoadHelper from table: %s for (guid: %u) Loading",table,guid);
if (!obj->LoadFromDB(guid, map))
{
delete obj;
continue;
}
grid.AddGridObject(obj);
addUnitState(obj, cell);
obj->SetMap(map);
obj->AddToWorld();
if (obj->isActiveObject())
map->AddToActive(obj);
obj->GetViewPoint().Event_AddedToWorld(&grid);
if (bg)
bg->OnObjectDBLoad(obj);
++count;
}
}
示例11: AddCorpsesToGrid
void ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map)
{
ACE_GUARD(LockType, g, i_corpseGuard);
for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter)
if (iter->second->GetGrid()==gridpair)
{
// verify, if the corpse in our instance (add only corpses which are)
if (map->Instanceable())
{
if (iter->second->GetInstanceId() == map->GetInstanceId())
grid.AddWorldObject(iter->second);
}
else
grid.AddWorldObject(iter->second);
}
}
示例12: guard
void
ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair, GridType& grid, Map* map)
{
Guard guard(i_corpseGuard);
for (auto& iter : i_player2corpse)
if (iter.second->GetGrid() == gridpair)
{
// verify, if the corpse in our instance (add only corpses which are)
if (map->Instanceable())
{
if (iter.second->GetInstanceId() == map->GetInstanceId())
{
grid.AddWorldObject(iter.second);
}
}
else
{
grid.AddWorldObject(iter.second);
}
}
}
示例13: computeDistanceMap26_WithQueue
Grid3D<uint32_t> computeDistanceMap26_WithQueue(const GridType& grid, Predicate isInObject, bool outsideIsObject) {
auto w = grid.width(), h = grid.height(), d = grid.depth();
uint32_t maxDist = std::numeric_limits<uint32_t>::max();
Grid3D<uint32_t> distanceGrid(w, h, d, maxDist);
std::queue<Vec4i> queue;
for(auto z = 0u; z < d; ++z) {
for(auto y = 0u; y < h; ++y) {
for(auto x = 0u; x < w; ++x) {
auto voxel = Vec3i(x, y, z);
if(!isInObject(x, y, z, grid)) {
queue.push(Vec4i(voxel, 0u));
} else if(!outsideIsObject && (x == 0 || y == 0 || z == 0 || x == w - 1 || y == h - 1 || z == d - 1)) {
queue.push(Vec4i(voxel, 1u));
}
}
}
}
while(!queue.empty()) {
auto voxel = Vec3i(queue.front());
auto dist = queue.front().w;
queue.pop();
if(dist < distanceGrid(voxel)) {
distanceGrid(voxel) = dist;
foreach26Neighbour(grid.resolution(), voxel, [&](const Vec3i& neighbour) {
auto newDist = dist + 1;
if(newDist < distanceGrid(neighbour)) {
queue.push(Vec4i(neighbour, newDist));
}
});
}
}
return distanceGrid;
}
示例14: AddCorpsesToGrid
void ObjectAccessor::AddCorpsesToGrid(GridCoord const& gridpair, GridType& grid, Map* map)
{
TRINITY_READ_GUARD(ACE_RW_Thread_Mutex, i_corpseLock);
for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter)
{
// We need this check otherwise a corpose may be added to a grid twice
if (iter->second->IsInGrid())
continue;
if (iter->second->GetGridCoord() == gridpair)
{
// verify, if the corpse in our instance (add only corpses which are)
if (map->Instanceable())
{
if (iter->second->GetInstanceId() == map->GetInstanceId())
grid.AddWorldObject(iter->second);
}
else
grid.AddWorldObject(iter->second);
}
}
}
示例15: stoper
void
ObjectGridCleaner::Stop(GridType &grid)
{
TypeContainerVisitor<ObjectGridCleaner, GridTypeMapContainer > stoper(*this);
grid.Visit(stoper);
}