bool addSingleCustomBuildingConfig( TiXmlElement* elemRoot, vector<BuildingConfiguration>* knownBuildings ){ const char* strName = elemRoot->Attribute("name"); const char* strGameID = elemRoot->Attribute("gameID"); if (strName == NULL || strGameID == NULL || strName[0] == 0 || strGameID[0] == 0) { contentError("<building> node must have name and gameID attributes",elemRoot); return false; } int gameID = TranslateBuildingName(strGameID, contentLoader.custom_workshop_types ); if (gameID == INVALID_INDEX) { return false; } BuildingConfiguration building(strName, gameID ); RootBlock* spriteroot = new RootBlock(); building.sprites = spriteroot; if (!parseSpriteNode(spriteroot,elemRoot)) { delete(spriteroot); return false; } //add a copy of 'building' to known buildings knownBuildings->push_back( building ); return true; }
std::auto_ptr< Geometry > building( const Geometry& g, const Kernel::FT& wallHeight, const Kernel::FT& roofSlope ) { switch ( g.geometryTypeId() ) { case TYPE_POLYGON: return building( g.as< Polygon >(), wallHeight, roofSlope ) ; case TYPE_MULTIPOLYGON: return building( g.as< MultiPolygon >(), wallHeight, roofSlope ) ; default: BOOST_THROW_EXCEPTION( Exception( ( boost::format( "bad geometry type (%s) in generator::building" ) % g.geometryType() ).str() ) ); return std::auto_ptr< Geometry >( new GeometryCollection() ); } }
int main(int argc, char **argv) { SimpleElevatorStrategy strategy; Building building(10, &strategy); building.addPeopleToFloor(2, createPeopleList(5)); building.addPeopleToFloor(3, createPeopleList(5)); building.addPeopleToFloor(7, createPeopleList(5)); building.runSimulation(); }
void OsmAnd::ObfAddressSectionReader_P::readBuildingsFromStreet( const ObfReader_P& reader, const std::shared_ptr<const Model::Street>& street, QList< std::shared_ptr<const Model::Building> >* resultOut, std::function<bool (const std::shared_ptr<const OsmAnd::Model::Building>&)> visitor, const IQueryController* const controller) { auto cis = reader._codedInputStream.get(); for(;;) { if (controller && controller->isAborted()) return; auto tag = cis->ReadTag(); switch(gpb::internal::WireFormatLite::GetTagFieldNumber(tag)) { case 0: return; case OBF::StreetIndex::kIntersectionsFieldNumber: { gpb::uint32 length; cis->ReadVarint32(&length); cis->Skip(length); } break; case OBF::StreetIndex::kBuildingsFieldNumber: { auto offset = cis->CurrentPosition(); gpb::uint32 length; cis->ReadVarint32(&length); auto oldLimit = cis->PushLimit(length); std::shared_ptr<Model::Building> building(new Model::Building()); building->_offset = offset; readBuilding(reader, street, building); cis->PopLimit(oldLimit); if (!visitor || visitor(building)) { if (resultOut) resultOut->push_back(qMove(building)); } } break; default: ObfReaderUtilities::skipUnknownField(cis, tag); break; } } }
std::auto_ptr< Geometry > building( const MultiPolygon& g, const Kernel::FT& wallHeight, const Kernel::FT& roofSlope ) { std::auto_ptr< MultiSolid > multiSolid( new MultiSolid ); for ( size_t i = 0; i < g.numGeometries(); i++ ) { multiSolid->addGeometry( building( g.polygonN( i ), wallHeight, roofSlope ).release() ); } return std::auto_ptr< Geometry >( multiSolid.release() ); }
void MemoryMap::build(MemoryMapBuilderType type, float minProbability, const QString& slubObjFile) { // Set _isBuilding to true now and to false later VarSetter<bool> building(&_isBuilding, true, false); _buildType = type; // Clean up everything clearRevmap(); _shared->reset(); _shared->minProbability = minProbability; operationStarted(); if (type == btSibi) { _verifier.resetWatchNodes(); _probPropagation = true; } else { _probPropagation = false; } if (!_symbols || !_vmem) { debugerr("Factory or VirtualMemory is NULL! Aborting!"); return; } _useRuleEngine = true; _knowSrc = ksNoAltTypes; debugmsg("Building map with TYPE RULES"); // Initialization of non-rule engine based map if (!_useRuleEngine) _perCpuOffset = perCpuOffsets(); // NON-PARALLEL PART OF BUILDING PROCESS // Read slubs object file, if given if (!slubObjFile.isEmpty()) { _verifier.parseSlubData(slubObjFile); } else { debugmsg("No slub object file given."); } // How many threads to create? _shared->threadCount = qMin(qMax(MultiThreading::maxThreads(), 1), MAX_BUILDER_THREADS); // _shared->threadCount = 1; if (_shared->threadCount > 1) debugmsg("Building reverse map with " << _shared->threadCount << " threads."); // Enable thread safety for VirtualMemory object bool wasThreadSafe = _vmem->setThreadSafety(_shared->threadCount > 1); // Create the builder threads _threads = new MemoryMapBuilder*[_shared->threadCount]; for (int i = 0; i < _shared->threadCount; ++i) { switch (type) { case btSibi: _threads[i] = new MemoryMapBuilderSV(this, i); break; case btChrschn: case btSlubCache: _threads[i] = new MemoryMapBuilderCS(this, i); break; } } // Find the list of loaded kernel modules QStringList loadedModules = loadedKernelModules(); // Go through the global vars and add their instances to the queue for (VariableList::const_iterator it = factory()->vars().begin(), e = factory()->vars().end(); !interrupted() && it != e; ++it) { const Variable* v = *it; // // For testing now only start with this one variable // if (v->name() != "dentry_hashtable") // continue; // Skip all variables from kernel modules that are not loaded if (v->symbolSource() == ssModule) { // We must use the rule engine to process module variables if (!_useRuleEngine) continue; // Ignore symbols in the ".modinfo" and "__versions" sections, they // can't be resolved anyway if (v->section() == ".modinfo" || v->section() == "__versions") continue; // Get file name of kernel module without path QString name = v->origFileName(); int index = name.lastIndexOf('/'); if (index >= 0) name = name.right(name.size() - index - 1); if (!loadedModules.contains(name)) continue; } // Process all variables try { if (_useRuleEngine) addVariableWithRules(v); else addVariableWithCandidates(v); } catch (ExpressionEvalException& e) { // Do nothing } catch (GenericException& e) { debugerr("Caught exception for variable " << v->name() << " at " << e.file << ":" << e.line << ": " << e.message); } checkOperationProgress(); } // Add all functions to the map, but not to the queue for (BaseTypeList::const_iterator it = factory()->types().begin(), e = factory()->types().end(); it != e; ++it) { const BaseType* t = *it; // Skip non-kernel and non-function types if (!t->symbolSource() == ssKernel || t->type() != rtFunction || !t->size()) continue; const Function* f = dynamic_cast<const Function*>(t); MemoryMapNode* node = 0; switch(_buildType) { case btSlubCache: case btChrschn: node = new MemoryMapNode(this, f->name(), f->pcLow(), t, t->id()); break; case btSibi: node = new MemoryMapNodeSV(this, f->name(), f->pcLow(), t, t->id(), 0, 0, false); break; } _roots.append(node); addNodeToHashes(node); } // The btSlubCache type ONLY adds all slub objects to the map and does not // follow any further pointers. if (type == btSlubCache) { // Add all slub objects to the map for (AddressMap::const_iterator it = _verifier.slub().objects().begin(), e = _verifier.slub().objects().end(); it != e; ++it) { const SlubCache& cache = _verifier.slub().caches().at(it.value()); MemoryMapNode* node; if (cache.baseType) node = new MemoryMapNode(this, cache.name, it.key(), cache.baseType, 0); else node = new MemoryMapNode(this, cache.name, it.key(), cache.objSize, 0); _roots.append(node); addNodeToHashes(node); } } // Regular mode, process all instances in the queue. else { for (int i = 0; i < _shared->threadCount; ++i) _threads[i]->start(); } // PARALLEL PART OF BUILDING PROCESS // Let the builders do the work, but regularly output some statistics while (!interrupted() && //!_shared->queue.isEmpty() && (!_shared->lastNode || _shared->lastNode->probability() >= _shared->minProbability) && builderRunning()) { checkOperationProgress(); // Sleep for 100ms usleep(100*1000); bool isRunning = false; for (int i = _shared->threadCount - 1; i >= 0; i--) { if (_threads[i]->isRunning()) isRunning = true; } if (!isRunning) break; } Console::out() << endl; // Interrupt all threads, doesn't harm if they are not running anymore for (int i = 0; i < _shared->threadCount; ++i) _threads[i]->interrupt(); // Now wait for all threads and free them again // Threads need calculateNodeProbability of thread[0] so delete that at last for (int i = _shared->threadCount - 1; i >= 0; i--) { if (_threads[i]->isRunning()) { _threads[i]->wait(); } delete _threads[i]; } delete _threads; _threads = 0; // Restore previous value _vmem->setThreadSafety(wasThreadSafe); debugmsg("Processed " << std::dec << _shared->processed << " instances in " << elapsedTime() << " minutes, statistic is being generated..."); operationStopped(); // Show statistics _verifier.statistics(); debugmsg("Processed " << std::dec << _shared->processed << " instances in " << elapsedTime() << " minutes."); }
bool PhysicalLocation::operator==(const PhysicalLocation& o) const { return country() == o.country() && region() == o.region() && locality() == o.locality() && area() == o.area() && street() == o.street() && building() == o.building() && floor() == o.floor() && room() == o.room() && postalcode() == o.postalcode() && text() == o.text(); }
void display3() { glClear(GL_COLOR_BUFFER_BIT); road(); mountain(); //brown glBegin(GL_POLYGON); glColor3f(0.9,0.3,0.0); glVertex2i(-10,300); glVertex2i(645,310); glVertex2i(940,100); glVertex2i(-10,100); glEnd(); building(); glPushMatrix(); glTranslated(e,300.0,0.0); glColor3f(1.0,1.0,1.0); glBegin(GL_POLYGON); glVertex2f(0.0,30.0); glVertex2f(0.0,55.0); glVertex2f(135.0,55.0); glVertex2f(135.0,30.0); glEnd(); glPopMatrix(); glPushMatrix(); glTranslated(e,300.0,0.0); glColor3f(1.0,1.0,1.0); glBegin(GL_POLYGON); glVertex2f(135.0,55.0); glVertex2f(150.0,50.0); glVertex2f(155.0,45.0); glVertex2f(160.0,40.0); glVertex2f(135.0,40.0); glEnd(); glPopMatrix(); glPushMatrix(); glTranslated(e,300.0,0.0); glColor3f(0.0,0.0,0.0); glBegin(GL_LINE_LOOP); glVertex2f(135.0,55.0); glVertex2f(150.0,50.0); glVertex2f(155.0,45.0); glVertex2f(160.0,40.0); glVertex2f(135.0,40.0); glEnd(); glPopMatrix(); glPushMatrix(); glTranslated(e,300.0,0.0); glColor3f(1.0,0.0,0.0); glBegin(GL_POLYGON); glVertex2f(135.0,40.0); glVertex2f(160.0,40.0); glVertex2f(160.0,37.0); glVertex2f(145.0,30.0); glVertex2f(135.0,30.0); glEnd(); glPopMatrix(); glPushMatrix(); glTranslated(e,300.0,0.0); glColor3f(1.0,0.0,0.0); glBegin(GL_POLYGON); glVertex2f(0.0,55.0); glVertex2f(0.0,80.0); glVertex2f(10.0,80.0); glVertex2f(40.0,55.0); //glVertex2f(165.0,40.0); glEnd(); glPopMatrix(); glPushMatrix(); glTranslated(e,300.0,0.0); glColor3f(1.0,0.0,0.0); glBegin(GL_POLYGON); glVertex2f(65.0,55.0); glVertex2f(50.0,70.0); glVertex2f(75.0,70.0); glVertex2f(90.0,55.0); //glVertex2f(165.0,40.0); glEnd(); glPopMatrix(); glPushMatrix(); glTranslated(e,300.0,0.0); glColor3f(1.0,0.0,0.0); glBegin(GL_POLYGON); glVertex2f(70.0,40.0); glVertex2f(100.0,40.0); glVertex2f(80.0,15.0); glVertex2f(50.0,15.0); glEnd(); glPopMatrix(); glutSwapBuffers(); }
void ComponentConstruction::update() { building(); }