/** Check that given edge is in current sector */ bool NodeNav::isEdgeInSector( GEdge * edge) const { GNode *n = otherEnd( edge); /* item corresponding to other (than node_priv) node */ if ( isNullP( n) || sector() == UNDEF_SECTOR) return false; NodeItem *item = n->item(); // Both points in current node's coordinates QPointF p_center = node_priv->item()->boundingRect().center(); QPointF s_center = node_priv->item()->mapFromItem( item, item->boundingRect().center()); qreal angle = QLineF( p_center, s_center).angle(); qreal max_angle = sectorMaxAngle(); qreal min_angle = sectorMinAngle(); if ( angle > 270 && sector() == RIGHT_SECTOR) { max_angle +=360; } if ( angle < 90 && sector() == RIGHT_SECTOR) { min_angle -=360; } if ( angle <= max_angle && angle >= min_angle) return true; return false; }
DiskFile * iso9660_enumfiles() { const PrimaryVolumeDescriptor *pvd = sector(16); const DirectoryRecord *rootrecord = &pvd->root_directory_record; assert(rootrecord->record_len == sizeof(DirectoryRecord) + rootrecord->id_len); const DirectoryRecord *entry = sector(rootrecord->data_sector); int i=0; do { DiskFile *fp = &g_files[i++]; strncpy(fp->filename, entry->id, entry->id_len); fp->data = sector(entry->data_sector); fp->length = entry->data_len; DPRINT(1, "CD file: %s at 0x%x (%u bytes)", fp->filename, fp->data, fp->length); entry = NEXT_DIR_ENTRY(entry); } while (entry->record_len > 0); g_files[i].filename[0] = 0; g_files[i].data = NULL; g_files[i].length = 0; return g_files; }
bool NormalDirectoryEntryIterator::internalNext() { ByteMemblock sector(_fs.getSectorSizeInBytes()); // check if need to move if(++_indexWithinSector >= _fs.getBootSector().BPB_BytsPerSec / sizeof(DirectoryEntry)) { if(!_iterator.next()) return false; _indexWithinSector=0; } // copy the current entry out of the sector DirectoryEntry& dirent=_currentEntry.Dirent; if(!_iterator.readSector(sector)) return false; MEM_DataCopy(&dirent,sector + (_indexWithinSector * sizeof(DirectoryEntry)),sizeof(DirectoryEntry)); _currentEntry.SectorNumber=_iterator.current(); _currentEntry.IndexWithinSector=_indexWithinSector; // check for end-of-entries if((dirent.sdir.DIR_Attr & DirectoryEntry::ATTR_LONG_NAME_MASK) != DirectoryEntry::ATTR_LONG_NAME && dirent.sdir.DIR_Name[0] == '\0') return errorProvider.set(ErrorProvider::ERROR_PROVIDER_ITERATOR,E_END_OF_ENTRIES); // done _currentDirentIndex++; return true; }
bool FatFileSystemFormatter::writeFats(uint32_t firstFatFirstSector_,uint32_t sectorsPerFat_) const { ByteMemblock sector(512); uint32_t i,j,sectorIndex; // two copies of the FAT, back to back sectorIndex=firstFatFirstSector_; for(i=0;i<2;i++) { // initialise the two reserved clusters memset(sector,0,512); initReservedClusters(sector); // write this sector if(!_blockDevice.writeBlock(sector,sectorIndex++)) return false; // write the remaining sectors memset(sector,0,512); for(j=0;j<sectorsPerFat_;j++) if(!_blockDevice.writeBlock(sector,sectorIndex++)) return false; } // done return true; }
main() { FILE *fopen(); extern int delaykill(); /* set kill trap */ signal (SIGQUIT,delaykill); signal (SIGINT,delaykill); atbreak = 0; kyll = 0; pltin= stdin; charsz= 30 * (fully / 6144.0); xscale *= scale*xdscale*(float)YMAX/(float)fully; yscale *= scale*ydscale*(float)YMAX/(float)fully; fat=fatbase; erase= -1; newplot= 1; init(); do { sector(); } while(newplot); finish(); exit(0); /*NOTREACHED*/ }
Sector computeSectorForState (const State& s) const { Sector sector(symmetryOperators.size()); for (size_t i=0; i<symmetryOperators.size(); i++) sector[i] = symmetryOperators[i]->operator()(s); return sector; }
void Run() { TC parent; parent.position_valid = false; // Create one with no heightmaps ServerMapSector sector(&parent, v2s16(1,1)); UASSERT(sector.getBlockNoCreateNoEx(0) == 0); UASSERT(sector.getBlockNoCreateNoEx(1) == 0); MapBlock * bref = sector.createBlankBlock(-2); UASSERT(sector.getBlockNoCreateNoEx(0) == 0); UASSERT(sector.getBlockNoCreateNoEx(-2) == bref); //TODO: Check for AlreadyExistsException /*bool exception_thrown = false; try{ sector.getBlock(0); } catch(InvalidPositionException &e){ exception_thrown = true; } UASSERT(exception_thrown);*/ }
void CColStore::SetCollisionRequired(const CVector& pos, int areaCode) { if (areaCode == -1) { CPed* v3 = FindPlayerPed(-1); if (v3) { areaCode = v3->GetAreaCode(); } else { areaCode = CGame::GetCurrentArea(); } } gCollisionRequiredForAreaCode = areaCode; CVector2D sector(pos.x, pos.y); if (areaCode == CGame::GetCurrentArea()) { ms_pQuadTree->ForAllMatching(sector, SetIfCollisionIsRequired); } else { ms_pQuadTree->ForAllMatching(sector, SetIfCollisionIsRequiredReducedBB); } }
std::unique_ptr<Sector> SectorParser::from_nothing(Level& level) { std::unique_ptr<Sector> sector(new Sector(&level)); SectorParser parser(*sector); parser.create_sector(); return sector; }
std::unique_ptr<Sector> SectorParser::from_reader_old_format(Level& level, const ReaderMapping& reader) { std::unique_ptr<Sector> sector(new Sector(&level)); SectorParser parser(*sector); parser.parse_old_format(reader); return sector; }
RefCountedPtr<Sector> GalaxyGenerator::GenerateSector(RefCountedPtr<Galaxy> galaxy, const SystemPath &path, SectorCache *cache) { const Uint32 _init[4] = { Uint32(path.sectorX), Uint32(path.sectorY), Uint32(path.sectorZ), UNIVERSE_SEED }; Random rng(_init, 4); SectorConfig config; RefCountedPtr<Sector> sector(new Sector(galaxy, path, cache)); for (SectorGeneratorStage *secgen : m_sectorStage) if (!secgen->Apply(rng, galaxy, sector, &config)) break; return sector; }
void DOWN(int column,int row) { int x=0,y=0; x=column; y=row; if(y==455&&limit_flag==1) { putimage(x-15,35-15,image,0); sector(x,35,0,360,15,15); return; } if(y==35&&limit_flag==0) limit_flag=1; putimage(x-15,y-45,image,0); getimage(x-15,y-15,x+15,y+15,next_image); sector(x,y,0,360,15,15); image=next_image; return ; }
void UP(int column,int row) { int x=0,y=0; x=column; y=row; putimage(x-15,y+15,image,0); getimage(x-15,y-15,x+15,y+15,next_image); sector(x,y,0,360,15,15); image=next_image; return ; }
bool FatFileSystemFormatter::writeRootDirectoryEntries(uint32_t sectorIndex_) const { ByteMemblock sector(512); // zero the sector and then write the volume label into it memset(sector.getData(),0,512); initVolumeLabelDirent(sector); // write to the device return _blockDevice.writeBlock(sector,sectorIndex_); }
void Move_chessman(void) { int row=35,column=35,count=0,key=0,flag=1; void far *image1=0,*image2=0; setcolor(WHITE); setfillstyle(SOLID_FILL,WHITE); sector(column,row,0,360,15,15); getimage(50,50,80,80,image); image_null=image; while(key!=27) { key=Getkey(); switch(key) { case 72 : row=Limit(72,row); UP(column,row); Trace(72,row); break; case 80 : row=Limit(80,row); DOWN(column,row); Trace(80,row); break; case 75 : column=Limit(75,column); LIFT(column,row); Trace(75,column); break; case 77 : column=Limit(77,column); RIGHT(column,row); Trace(77,column); break; case 13 : Computer(column,row); Move_chessman(); break; case 27 : END(); break; default : break; } } }
/** Get edge to the bottom of current node */ GEdge * NodeNav::firstEdgeInSector() const { GEdge *res = NULL; qreal min_delta = 0; /** For each edge */ for ( Node::EdgeIter e_iter = node()->edgesBegin(), e_end = node()->edgesEnd(); e_iter != e_end; e_iter++ ) { GEdge *e = static_cast<GEdge *>( e_iter.edge()); if ( isEdgeInSector( e)) { NodeItem *p_item = static_cast<GNode *>( e_iter.node())->item(); QPointF center = node()->item()->boundingRect().center(); QPointF point = node()->item()->mapFromItem( p_item, p_item->boundingRect().center()); qreal delta; if ( sector() == TOP_SECTOR || sector() == BOTTOM_SECTOR) { delta = abs<qreal>( center.x() - point.x()); } else { delta = abs<qreal>( center.y() - point.y()); } if ( isNullP( res) || delta < min_delta) // for selection of closest edge { res = e; min_delta = delta; } } } return res; }
void eliminate(void) { extern char statpexp[]; extern int npexp; int i; char request='c'; void sector(int i); while(1) { switch(request) { case 'e': printf("point eliminated "); scanf("%d",&i); if(i<0||i>=npexp) sector(0); else statpexp[i]=0; request='c'; break; case 'i': printf("point inserted "); scanf("%d",&i); if(i<0||i>=npexp) sector(1); else statpexp[i]=1; request='c'; break; case 's': return; default: printf("Eliminate, Insert or Stop "); scanf("%s",&request); break; } } }
void RIGHT(int column,int row) { int x=0,y=0; x=column; y=row; if(column==455&&limit_flag==0) { limit_flag=1; } if(column==455&&limit_flag==1) { putimage(x-15,y+15,image_null,0); sector(x,y,0,360,15,15); limit_flag=0; return; } putimage(x-45,y-15,image,0); getimage(x-15,y-15,x+15,y+15,next_image); sector(x,y,0,360,15,15); image=next_image; return ; }
/** Get edge to the left of given edge */ GEdge * NodeNav::edgeInDir( GEdge * edge, NavDirection dir) const { /* Applicable only for top and bottom sectors */ if ( !isDirApplicable( dir, sector())) { return NULL; } GNode *n = otherEnd( edge); /* item corresponding to other (than node_priv) node */ if ( isNullP( n)) return NULL; NodeItem *item = n->item(); // in current node's coordinates QPointF edge_point = node()->item()->mapFromItem( item, item->boundingRect().center()); GEdge *res = NULL; qreal min_delta = 0; /** For each edge */ for ( Node::EdgeIter e_iter = node()->edgesBegin(), e_end = node()->edgesEnd(); e_iter != e_end; e_iter++ ) { GEdge *e = static_cast<GEdge *>( e_iter.edge()); if ( isEdgeInSector( e) && areNotEqP( e, edge)) { NodeItem *p_item = static_cast<GNode *>( e_iter.node())->item(); QPointF point = node()->item()->mapFromItem( p_item, p_item->boundingRect().center()); if ( isPointInDir( point, edge_point, dir)) { qreal delta = deltaInDir( point, edge_point, dir); if ( isNullP( res) || delta < min_delta) // for selection of closest edge { res = e; min_delta = delta; } } } } return res; }
void Particles::draw() const{ SectorID id(m_position); int x = id.getI(); int y = id.getJ(); int z = id.getK(); for (int i = x - NEARBY_SECTOR; i <= x + NEARBY_SECTOR; i++){ for (int j = y - NEARBY_SECTOR; j <= y + NEARBY_SECTOR; j++){ for (int k = z - NEARBY_SECTOR; k <= z + NEARBY_SECTOR; k++){ int density = SectorID::calculateDensity(i, j, k); Sector sector(i, j, k, density); sector.draw(); } } } }
void Patch1400(const char* runlist1400, const char* srcOCDBPath="alien://folder=/alice/data/2016/OCDB", const char* destOCDBPath="alien://folder=/alice/cern.ch/user/l/laphecet/OCDBCH4L") { // function to patch the OCDB MUON/Calib/HV for the one sector that had problems // runlist1400 = list of runs where Chamber03Left/Quad2Sect1 was struggling at 1400 V // for the runs in runlist1400, the HV will be forced to zero for that sector // note that Chamber04Left/Quad3Sect2 (on DE 402) = Chamber03Left/Quad2Sect1 in DCS alias world AliAnalysisTriggerScalers ts1400(runlist1400,srcOCDBPath); std::vector<int> vrunlist1400 = ts1400.GetRunList(); AliCDBManager* man = AliCDBManager::Instance(); TObjString sector("MchHvLvLeft/Chamber03Left/Quad2Sect1.actual.vMon"); for ( auto r : vrunlist1400 ) { man->SetDefaultStorage(srcOCDBPath); man->SetRun(r); std::cout << "Run " << r << std::endl; AliCDBEntry* entry = man->Get("MUON/Calib/HV"); TMap* hvmap = static_cast<TMap*>(entry->GetObject()->Clone()); TPair* p = hvmap->RemoveEntry(§or); if ( std::find(vrunlist1400.begin(),vrunlist1400.end(),r) != vrunlist1400.end() ) { TObjArray* a1 = static_cast<TObjArray*>(p->Value()); AliDCSValue* first = static_cast<AliDCSValue*>(a1->First()); AliDCSValue* last = static_cast<AliDCSValue*>(a1->Last()); a1->Delete(); a1->Add(new AliDCSValue(0.0f,first->GetTimeStamp())); a1->Add(new AliDCSValue(0.0f,last->GetTimeStamp())); } hvmap->Add(new TObjString(sector),p->Value()); delete p->Key(); man->SetDefaultStorage(destOCDBPath); hvmap->SetUniqueID( hvmap->GetUniqueID() | ( 1 << 9 ) ); AliMUONCDB::WriteToCDB(hvmap,"MUON/Calib/HV",r,r,"Patched for CH4L DE402 Quad3Sect2 struggling at 1400 V","L. Aphecetche"); man->ClearCache(); } }
bool FatFileSystemFormatter::writeBootSector(uint32_t bootSectorIndex_) { ByteMemblock sector(512); // create a new boot sector at the start of the block if(!createNewBootSector()) return false; memcpy(sector.getData(),&_bootSector,sizeof(_bootSector)); // write signature to sector setReservedSectorSignature(sector); // write to the device return _blockDevice.writeBlock(sector,bootSectorIndex_); }
/** * Пересечение круга с прямоугольником. Круг намного больше прямоугольника. */ void testIntersectionCircleBox() { // Планета // (!) Слишком малая точность для круга может привести к тому, что // сектор (см. ниже) и круг не пересекутся. const bgm::polygon< p_t > circle = drawCircle( 5e6, 20 ); cout << "Полигон планеты " << bg::dsv( circle ) << endl; cout << "Площадь " << bg::area( circle ) << endl << endl; // Сектор const auto aimCoord = p_t( 0.0, WORLD_PLANET_RADIUS ); bgm::box< p_t > sector( p_t( aimCoord.x() - SECTOR_HALF_SIZE, aimCoord.y() - SECTOR_HALF_SIZE ), p_t( aimCoord.x() + SECTOR_HALF_SIZE, aimCoord.y() + SECTOR_HALF_SIZE ) ); bg::correct( sector ); cout << "Полигон сектора " << bg::dsv( sector ) << endl; cout << "Площадь " << bg::area( sector ) << endl << endl; // Пересечение std::vector< polygon_t > pv; bg::intersection( circle, sector, pv ); cout << "Количество полигонов после пересечения " << pv.size() << endl << endl; assert( (pv.size() == 1) && "Ожидался 1 полигон." ); // Анализируем полигон for (auto itr = pv.cbegin(); itr != pv.cend(); ++itr) { const polygon_t poly = *itr; // Каждый полигон - это отдельная реальная сущность cout << "Полигон планеты в секторе " << bg::dsv( poly ) << endl; cout << "Площадь " << bg::area( poly ) << endl << endl; // Вершины полигона const auto vertex = poly.outer(); for (auto itrVertex = vertex.cbegin(); itrVertex != vertex.cend(); ++itrVertex) { const auto t = *itrVertex; cout << t.x() << " " << t.y() << endl; } cout << endl; } }
Track &Track::format (const CylHead &cylhead, const Format &fmt) { assert(fmt.sectors != 0); m_sectors.clear(); m_sectors.reserve(fmt.sectors); for (auto id : fmt.get_ids(cylhead)) { Header header(cylhead.cyl, cylhead.head ? fmt.head1 : fmt.head0, id, fmt.size); Sector sector(fmt.datarate, fmt.encoding, header, fmt.gap3); Data data(fmt.sector_size(), fmt.fill); sector.add(std::move(data)); add(std::move(sector)); } return *this; }
bool Particles::isCollide(PhysicsObject &object) const{ Vector3 position = object.getPosition(); SectorID id(position); int x = id.getI(); int y = id.getJ(); int z = id.getK(); int searchSection = 1; for (int i = x - searchSection; i <= x + searchSection; i++){ for (int j = y - searchSection; j <= y + searchSection; j++){ for (int k = z - searchSection; k <= z + searchSection; k++){ int density = SectorID::calculateDensity(i, j, k); Sector sector(i, j, k, density); if (sector.isCollide(object)) { return true; } } } } return false; }
void Computer(int column,int row) { int flag=2,C_row,C_col,*Coorp; int x,y/*,color=WHITE*/; SAVE(column,row,2); /* 把当前玩家的棋子坐标和下棋方存到文件 1--电脑 2--人 */ C_col=(column-5)/30; C_row=(row-5)/30; Coording[C_col][C_row]=flag; Coorp=Think(C_col,C_row); /* 分析棋局的函数 用数组传回 x y 坐标*/ flag=1; /* x=rand()%5; y=rand()%5; */ x=*Coorp; y=*(Coorp+1); /*SAVE(column+x*30,row+y*30,1);*/ SAVE(x,y,1); /*C_col=(column+x*30-5)/30; C_row=(row+y*30-5)/30; */ C_col=(x-5)/30; C_row=(y-5)/30; Coording[C_col][C_row]=flag; /*color=getcolor();*/ setfillstyle(SOLID_FILL,BLACK); setcolor(BLACK); /*sector(column+x*30,row+y*30,0,360,15,15);*/ sector(x,y,0,360,15,15); setcolor(WHITE); return ; }
void ghost::draw_ghbody(short &a) { if(mode!=2) { setfillstyle(1,col); setcolor(col); } else { int col=1; if(warn && a==0) col=15; setfillstyle(1,col); setcolor(col); } sector(x,y,359,1,r,r-r/4); if(a==0) { int drawpts[24]={x-r,y,x+r,y,x+r,y+r,x+(7*r)/10,y+r/2,x+(5*r)/10,y+r,x+(3*r)/10,y+r,x+(3*r)/10,y+r/2,x-(3*r)/10,y+r/2,x-(3*r)/10,y+r,x-(5*r)/10,y+r,x-(7*r)/10,y+r/2,x-r,y+r}; fillpoly(12, drawpts); } else { int drawpts[18]={x-r,y,x+r,y,x+r,y+r-r/8,x+(8*r)/9,y+r,x+r/2,y+r/2,x,y+r,x-r/2,y+r/2,x-(8*r)/9,y+r,x-r,y+r-r/8}; fillpoly(9, drawpts); } if(mode==2) { if(warn && a==0) setcolor(4); else setcolor(15); moveto(x-r+2,y+r/2); lineto(x-(6*r)/10,y+r/4); lineto(x-(4*r)/10,y+r/2); lineto(x,y+r/4); lineto(x+(4*r)/10,y+r/2); lineto(x+(6*r)/10,y+r/4); lineto(x+r-2,y+r/2); } }
int main() { initgraph(640, 480); //第一次设置背景色 setbkcolor(EGERGB(0x0, 0x40, 0x0)); //浅绿色 setcolor(EGERGB(0xFF, 0xFF, 0x0)); setfillcolor(EGERGB(0xFF, 0x0, 0x80)); //画带填充的扇形 sector(200, 200, 45, 135, 150, 100); getch(); //按下一任意键后,再次改变背景色 setbkcolor(EGERGB(0x0, 0x0, 0x40)); //浅蓝色 getch(); closegraph(); return 0; }
vector<WorldInterface::RingParticleData> Particles::getRingParticles(const Vector3& sphere_center, double sphere_radius) const { vector<WorldInterface::RingParticleData> v_particles; SectorID id(sphere_center); int x = id.getI(); int y = id.getJ(); int z = id.getK(); int searchSection = sphere_radius / SectorID::SIDE_LENGTH; if (searchSection == 0) searchSection = 1; for (int i = x - searchSection; i <= x + searchSection; i++){ for (int j = y - searchSection; j <= y + searchSection; j++){ for (int k = z - searchSection; k <= z + searchSection; k++){ int density = SectorID::calculateDensity(i, j, k); Sector sector(i, j, k, density); vector<WorldInterface::RingParticleData> particles = sector.getParticles(sphere_center, sphere_radius); v_particles.insert(std::end(v_particles), std::begin(particles), std::end(particles)); } } } return v_particles; }
void omti5100_device::ExecCommand() { int drive = (command[1] >> 5) & 1; hard_disk_file *image = (drive ? m_image1 : m_image0)->get_hard_disk_file(); if(!image) { if(command[0] == T10SPC_CMD_REQUEST_SENSE) return scsihd_device::ExecCommand(); m_phase = SCSI_PHASE_STATUS; m_status_code = SCSI_STATUS_CODE_CHECK_CONDITION; m_sense_asc = OMTI_STATUS_NOT_READY; m_transfer_length = 0; return; } hard_disk_info *info = hard_disk_get_info(image); switch(command[0]) { case OMTI_READ_DATA_BUFFER: m_phase = SCSI_PHASE_DATAIN; m_status_code = SCSI_STATUS_CODE_GOOD; m_transfer_length = 512; break; case OMTI_ASSIGN_DISK_PARAM: m_phase = SCSI_PHASE_DATAOUT; m_status_code = SCSI_STATUS_CODE_GOOD; m_transfer_length = 10; break; case OMTI_CHECK_TRACK_FORMAT: m_phase = SCSI_PHASE_STATUS; m_status_code = SCSI_STATUS_CODE_GOOD; m_transfer_length = 0; break; case T10SBC_CMD_READ_6: { int track = ((command[1]&0x1f)<<16 | command[2]<<8 | command[3]) / (m_param[drive].sectors ? m_param[drive].sectors : 1); int heads = m_param[drive].heads ? m_param[drive].heads : 1; if(((track % heads) > info->heads) || (track >= (info->cylinders * heads))) { m_phase = SCSI_PHASE_STATUS; m_status_code = SCSI_STATUS_CODE_CHECK_CONDITION; m_sense_asc = OMTI_STATUS_SEEK_FAIL; m_transfer_length = 0; } else { SetDevice(image); scsihd_device::ExecCommand(); } break; } case OMTI_FORMAT_TRACK: { int track = ((command[1]&0x1f)<<16 | command[2]<<8 | command[3]) / m_param[drive].sectors; if(((track % m_param[drive].heads) <= info->heads) && (track < (info->cylinders * m_param[drive].heads))) { dynamic_buffer sector(info->sectorbytes); memset(§or[0], 0xe5, info->sectorbytes); m_phase = SCSI_PHASE_STATUS; m_status_code = SCSI_STATUS_CODE_GOOD; m_transfer_length = 0; for(int i = 0; i < info->sectors; i++) hard_disk_write(image, track * info->sectors + i, §or[0]); } else { m_phase = SCSI_PHASE_STATUS; m_status_code = SCSI_STATUS_CODE_CHECK_CONDITION; m_sense_asc = OMTI_STATUS_SEEK_FAIL; m_transfer_length = 0; } break; } default: SetDevice(image); scsihd_device::ExecCommand(); break; } }