blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 2 247 | content_id stringlengths 40 40 | detected_licenses listlengths 0 57 | license_type stringclasses 2 values | repo_name stringlengths 4 111 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 58 | visit_date timestamp[ns]date 2015-07-25 18:16:41 2023-09-06 10:45:08 | revision_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | committer_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | github_id int64 3.89k 689M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 25 values | gha_event_created_at timestamp[ns]date 2012-06-07 00:51:45 2023-09-14 21:58:52 ⌀ | gha_created_at timestamp[ns]date 2008-03-27 23:40:48 2023-08-24 19:49:39 ⌀ | gha_language stringclasses 159 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 7 10.5M | extension stringclasses 111 values | filename stringlengths 1 195 | text stringlengths 7 10.5M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8672c782c9783229090ae6f4a49f3c8afb0cc860 | e4417f38ab4f54f8f3099261c80bc36f0c0ba703 | /resources/sources/Game/MapPartManager.cpp | 2c3d8786e9363427d3bd61fbc6e5afd1a50f48af | [] | no_license | Codibri/HardrockHoliday | 65b68ca81312903e33dc4e0e307a4050e81789a0 | 5c9b4f92196ba0f2da010b0da91633f4f7347589 | refs/heads/master | 2016-09-05T13:22:02.351272 | 2015-01-16T01:51:05 | 2015-01-16T01:51:05 | 26,432,093 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 3,329 | cpp | MapPartManager.cpp | #include "Game\MapPartManager.h"
MapPartManager::MapPartManager()
{
mLastMapPartLoaded = false;
mCheck = false;
}
MapPartManager::~MapPartManager()
{
}
void MapPartManager::setScene(CScene* scene){
mScenePtr = scene;
}
void MapPartManager::initWithActiveLevel(Level* level, Vektoria::CRoot* root){
mActiveLevelPtr = level;
preRenderMapParts(root);
// Ersten MapPart laden und zur Scene hinzufügen
mFirstActiveMapPart = mActiveLevelPtr->getNextMapPart();
//mScenePtr->AddPlacement(mFirstActiveMapPart->getPlacement());
mFirstActiveMapPart->getPlacement()->SwitchOn();
// Falls weitere Mapparts vorhanden: zweiten Mapparte ladens
if (!mFirstActiveMapPart->getIsLastMapPartOfLevel()){
mSecondActiveMapPart = mActiveLevelPtr->getNextMapPart();
//mSecondActiveMapPart->getPlacement()->TranslateZDelta(-MAP_PART_SIZE);
//mScenePtr->AddPlacement(mSecondActiveMapPart->getPlacement());
mSecondActiveMapPart->getPlacement()->SwitchOn();
}
}
const void MapPartManager::preRenderMapParts(Vektoria::CRoot* r) const {
// Alle Parts an Szene anhängen und switchOff aufrufen
mActiveLevelPtr->attachAllMapPartsToScene(mScenePtr);
mActiveLevelPtr->switchOnAllMapParts();
float f = 0.001f;
r->Tick(f);
mActiveLevelPtr->switchOffAllMapParts();
}
void MapPartManager::update(float deltaMillis, float fTime) {
float playerZPos = mActiveLevelPtr->getPlayer()
->getPlacement()->GetTranslation().z;
// Wenn sich der Spieler in der Mitte eines MapPartsbefinden soll
// der Nächste Mappart geladen werden
if (checkLoadNextMapPart(playerZPos)){
switchMapsParts();
}
}
/*
* Tick nur die aktiven GameObjects/Mapparts und den Player
*/
void MapPartManager::tickActiveObjects(float deltaMillis, float time) const {
// Spieler ticken
mActiveLevelPtr->getPlayer()->update(deltaMillis, time);
// Aktive MapParts ticken
mFirstActiveMapPart->tick(deltaMillis, time);
mSecondActiveMapPart->tick(deltaMillis, time);
}
/*
* Prüft ob sch der Spieler in der Mitte eines MapParts befindet
*
*/
const bool MapPartManager::checkLoadNextMapPart(float absoluteZPos){
int activePartProgress = (int)-absoluteZPos % MapPart::MAP_PART_SIZE;
if (activePartProgress == 1 && mCheck){
mCheck = false;
return true;
}
else if (activePartProgress > 1){
mCheck = true;
}
return false;
}
/*
* Entfernt den hinteren aktive Mappart aus der Szene
* und lädt den nächsten
*/
void MapPartManager::switchMapsParts(){
// Placement aus sczene entfernen
//mScenePtr->m_placements.Sub(mFirstActiveMapPart->getPlacement());
//Placement ausschalten
//mFirstActiveMapPart->getPlacement()->SwitchOff();
// Hinterer Mappart nun erster
mFirstActiveMapPart = mSecondActiveMapPart;
// Vorne Neuen MapPart laden
loadNextMapPart();
}
/*
* Fügt den nächsten Mappart zur Szene hinzu
*
*/
void MapPartManager::loadNextMapPart(){
mSecondActiveMapPart = mActiveLevelPtr->getNextMapPart();
// neuen MapPart an sezene anhängen
//mSecondActiveMapPart->getPlacement()->TranslateZDelta(-MAP_PART_SIZE * 2);
// Placement anschalten statt an scene anhängen
//mScenePtr->AddPlacement(mSecondActiveMapPart->getPlacement());
mSecondActiveMapPart->getPlacement()->SwitchOn();
}
void MapPartManager::checkIfLastMapPart(MapPart* part){
if (part->getIsLastMapPartOfLevel())
mLastMapPartLoaded = true;
} |
98f9115ff94cb8fcddb9908b06cb141961eac6c4 | 598e1b350648db9fc0b3ce8a5a75b4a7d2382b65 | /JsonApp_Andrusenko_2020/JsonLibrary/BoolValue.cpp | 7808d08c7de80e15ab77af6365842658dfd459b6 | [] | no_license | Maureus/CPP_Andrusenko | d629e39d192434c3fd465a417e1c7fbb3ef56395 | ad69042e8f0d21868344d8f046efbd12d9c8f2a4 | refs/heads/main | 2023-02-11T06:25:59.207782 | 2021-01-05T17:28:35 | 2021-01-05T17:28:35 | 300,827,284 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 416 | cpp | BoolValue.cpp | #include "pch.h"
#include "api.h"
BoolValue::BoolValue(bool value)
{
this->value = value;
}
bool BoolValue::get() const
{
return value;
}
std::string BoolValue::serialize() const
{
return value ? "true" : "false";
}
BoolValue BoolValue::deserialize(const std::string& value)
{
if (value == "true")
{
return BoolValue(true);
}
else if (value == "false")
{
return BoolValue(false);
}
return "???";
} |
2afeea75238ba5eb1b4f3e35b3c2ff7a872f8ee6 | 359242f0fe641d6d98411132515f22d7490a5790 | /Programs-Btech/DS/Queue by 2 stacks.cpp | d1405bec843d64c87b632677c2fd01ecf7923324 | [] | no_license | sudhanshu-jha/c-cplusplus | ae0fdc75475590761f54123e3f084641b50a96d9 | 272e7e9b3437906bb5fbbddbb1c2296c86fb5572 | refs/heads/master | 2020-03-06T17:23:50.113916 | 2019-01-19T13:12:56 | 2019-01-19T13:12:56 | 126,989,057 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,967 | cpp | Queue by 2 stacks.cpp | #include <iostream>
#include "Stack.h"
using namespace std;
int main()
{
stack<int> S1;
stack<int> S2;
int choice,item,item1;
do
{
cout<<"Enter your choice"<<endl;
cout<<"1: Enqueue"<<endl;
cout<<"2: Dequeue"<<endl;
cout<<"3: Display"<<endl;
cout<<"4: Exit"<<endl;
cin>>choice;
switch(choice)
{
case 1: cout<<"Enter the vaule to be enqueued"<<endl;
cin>>item;
if(S2.isEmpty())
S2.push(item);
else
{
while(!S2.isEmpty())
{
item1=S2.pop();
S1.push(item1);
}
S1.push(item);
while(!S1.isEmpty())
{
item1=S1.pop();
S2.push(item1);
}
}
break;
case 2: if (S2.isEmpty())
cout<<"The Queue is empty"<<endl;
else
cout<<"The dequeued value is"<<S2.pop()<<endl;
break;
case 3: cout<<"The Queue is"<<endl;
S2.display();
break;
case 4: cout<<"You are exiting now"<<endl;
break;
default : cout<<"Invalid choice"<<endl;
break;
};
}while(choice!=4);
system("pause");
return 0;
}
|
8e8538e1a62adf1c3dcebcb06e5884a31fa62bbf | 568048d9134c6d5b24cd2682a3a5d5f7ede226be | /pocky/jni/src/PockyGame.cpp | dffe20180d5bdb294733d072e786853b3a6637ad | [] | no_license | nheffelman/Pocky | 8e47153dfa9b2239bd58aba9154f0cb211acafc7 | e0111f7038daf7b28b5069d4b2d0c5b3eccf5e8f | refs/heads/master | 2021-04-15T09:25:57.036315 | 2011-12-13T19:05:01 | 2011-12-13T19:05:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 22,476 | cpp | PockyGame.cpp | /*
* PockyGame.cpp
*
* Created on: Dec 4, 2011
* Author: psastras
*/
#include "../include/PockyGame.h"
#include <pineapple/jni/extern/Engine.h>
#include <pineapple/jni/extern/Compile.h>
#include <pineapple/jni/extern/Common.h>
#include <pineapple/jni/extern/GL.h>
#include <pineapple/jni/extern/GLText.h>
#include <pineapple/jni/extern/Audio.h>
#ifndef _DESKTOP
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#define GL_GLEXT_PROTOTYPES
#include <qdebug.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include <qgl.h>
#endif
#include <sstream>
#include <iomanip>
#define CELL(X, Y) cell_[(Y) * ncellsx_ + (X)]
#define NUM_TOUCHPOINTS 100
#define SPAWN_SIZE 0.5
using namespace Pineapple;
namespace Pocky {
PockyGame::PockyGame(const PockyGameParams ¶ms) {
// TODO Auto-generated constructor stub
previousTime_ = 0;
fps_ = 30;
params_ = params;
cell_ = new PockyGridCell[(params.gridx * 2 + 1) * (params.gridy * 2 + 1)];
ncellsx_ = (params.gridx * 2 + 1);
ncellsy_ = (params.gridy * 2 + 1);
for (int i = 0; i < (ncellsx_ * ncellsy_); i++) {
cell_[i].life = -1;
}
score_ = 0;
state_ = 0;
}
PockyGame::~PockyGame() {
delete[] cell_;
}
GLFramebufferObject *fbo2;
void PockyGame::init() {
this->applyGLSettings();
this->loadShaders();
this->generateAssets();
int w = GL::instance()->width();
int h = GL::instance()->height();
square_ = new GLQuad(Float3(1, 1, 1), Float3(0.f, 0.f, -5.f),
Float3(1.f, 1.f, 1.f));
quad_ = GL::instance()->primitive("quad");
topbar_ = new GLQuad(Float3(1, 1, 1), Float3(w / 2, 15, 0.f),
Float3(w, 30, 1.f));
touchprim_ = new GLCircle(
Float3(6, 10, 10),
Float3(0,0, 0.f),
Float3(50, 50, 1.f));
touchfill_ = new GLDisc( Float3(6, 10, 10),
Float3(0,0, 0.f),
Float3(50, 50, 1.f));
//botbar_ = new GLQuad(Float3(1, 1, 1), Float3(w/2,h-10, 0.f), Float3(w, 20, 1.f), true);
button_ = new GLQuad(Float3(1,1,1), Float3(w/2,0.f, 0.f), Float3(w, 70, 1.f));
glViewport(0, 0, GL::instance()->width(), GL::instance()->height());
// CELL(5, 3).life = 1.f;
// CELL(1, 2).life = 0.4f;
// CELL(3, 0).life = 0.2f;
// CELL(3, 1).life = 0.7f;
// CELL(3, 2).life = 1.4f;
// CELL(4, 0).life = 1.2f;
// CELL(0, 1).life = 1.7f;
GL::instance()->perspective(60.f, 0.01f, 1000.f, GL::instance()->width(),
GL::instance()->height());
//glClearColor(0.1f, 0.1f, 0.1f, 1.f);
Float3 p1 = GL::instance()->project(float2(0.f, 0.f), -5.f);
Float3 p2 = GL::instance()->project(float2(800.f, 480.f), -5.f);
LOGI("[%f, %f, %f]", p1.x, p1.y, p1.z);
LOGI("[%f, %f, %f]", p2.x, p2.y, p2.z);
// Audio::instance()->addSound("test", "assets/audio/short.ogg", true,
// AudioType::OGG);
// //Audio::instance()->addSound("test", "assets/audio/technika2.wav", true, AudioType::WAV);
// Audio::instance()->playSound("test");
}
float prog = 0.f;
void PockyGame::setState(PockyState *s){
state_= s;
}
void IdxToRGB565(int idx, Float3 &rgb) {
int r = idx / (32 * 64);
int g = (idx - r * 32 * 64) / 32;
int b = (idx - r * 32 * 64 - g * 32);
rgb.x = r * 8;
rgb.y = g * 4;
rgb.z = b * 8;
rgb /= 255.f;
}
void PockyGame::draw(int time) {
glClear(GL_COLOR_BUFFER_BIT);
int dt = time - previousTime_;
if (dt > 0) {
fps_ = 0.99f * fps_ + 0.01f * (1000 / dt);
previousTime_ = time;
}
int w = GL::instance()->width();
int h = GL::instance()->height();
//draw stuff behind the overlay
if(state_->state() == PLAY)
{
GL::instance()->perspective(60.f, 0.01f, 1000.f, GL::instance()->width(),
GL::instance()->height());
VSML::instance()->scale(9.6f, 5.97f, 1.f);;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
int nLights = 0;
//float color = sinf(time / 1000.f) * 2.f;
Engine::instance()->lock();
for (int i = 0; i < ncellsx_ * ncellsy_; i++) {
if (cell_[i].life > 0.f && nLights < MAX_ACTIVE) {
lightPositions_[nLights].x = cell_[i].sspos.x;
lightPositions_[nLights].y = cell_[i].sspos.y;
lightPositions_[nLights].z = 20.f * (cell_[i].life + 0.5f);
nLights++;
GL::instance()->perspective(60.f, 0.01f, 1000.f,
GL::instance()->width(), GL::instance()->height());
VSML::instance()->translate(cell_[i].wspos.x, cell_[i].wspos.y,
0.f);
VSML::instance()->scale(MIN(2*(SPAWN_SIZE-1)*cell_[i].life + 2 - SPAWN_SIZE, 1.f)
, MIN(2*(SPAWN_SIZE-1)*cell_[i].life + 2 - SPAWN_SIZE, 1.f), 1.f);
float2 tc(cell_[i].sspos.x / w, 1.f - cell_[i].sspos.y / h);
hexShader_->bind(VSML::instance());
glActiveTexture(GL_TEXTURE0);
framebuffer0_->bindsurface(0);
hexShader_->setUniformValue("tex", 0);
float v = (cell_[i].life - 0.5f) * 2.f;
if (cell_[i].life <= 0.45f)
hexShader_->setUniformValue("life", -(v * v) + 1.5f);
else
hexShader_->setUniformValue(
"life",
-((cell_[i].life - 0.5f) * (cell_[i].life - 0.5f))
+ 0.7f);
hexShader_->setUniformValue("tcOffset", tc);
square_->draw(hexShader_);
hexShader_->release();
} else if(cell_[i].life > -1.f && cell_[i].life <= 0.f && nLights < MAX_ACTIVE) {
lightPositions_[nLights].x = cell_[i].sspos.x;
lightPositions_[nLights].y = cell_[i].sspos.y;
lightPositions_[nLights].z = 20.f * (cell_[i].life + 1.5f);
nLights++;
GL::instance()->perspective(60.f, 0.01f, 1000.f,
GL::instance()->width(), GL::instance()->height());
VSML::instance()->translate(cell_[i].wspos.x, cell_[i].wspos.y,
0.f);
VSML::instance()->scale(MAX((-cell_[i].life + 1.f)*0.75, 1.f)
, MAX((-cell_[i].life+1.f)*0.75, 1.f), 1.f);
float2 tc(cell_[i].sspos.x / w, 1.f - cell_[i].sspos.y / h);
hit_->bind(VSML::instance());
glActiveTexture(GL_TEXTURE0);
framebuffer0_->bindsurface(0);
hit_->setUniformValue("tex", 0);
hit_->setUniformValue(
"life",
-((cell_[i].life - 0.5f) * (cell_[i].life - 0.5f))
+ 2.0f);
hit_->setUniformValue("tcOffset", tc);
if(cell_[i].judge == 0){
// good, so white
hit_->setUniformValue("color", Float3(1.0f, 1.0f, 1.0f));
}else if(cell_[i].judge == 1){
// okay so green
hit_->setUniformValue("color", Float3(0, 1.0f, 0));
}else{
// bad so red
hit_->setUniformValue("color", Float3(1.0f, 0, 0));
}
square_->draw(hit_);
hit_->release();
}
}
// draw finger trail
if(state_){
TouchTracker *tp = state_->getTouchPoints();
for(int i = 0; i < NUM_TOUCHPOINTS; i++){
const TouchTracker ¤t = tp[i];
if(current.life_ <= 0){
continue;
}
// GL::instance()->ortho();
// VSML::instance()->translate(400, 200,
// 0.f);
// VSML::instance()->scale(100.0, 100.0, 1);
//
// float2 tc(1.f, 1.f);
// hexShader_->bind(VSML::instance());
// glActiveTexture(GL_TEXTURE0);
// framebuffer0_->bindsurface(0);
// hexShader_->setUniformValue("tex", 0);
// hexShader_->setUniformValue(
// "life",
// 10.f);
// hexShader_->setUniformValue("tcOffset", tc);
// square_->draw(hexShader_);
// hexShader_->release();
GL::instance()->ortho();
VSML::instance()->translate(current.touchpoint_.x, current.touchpoint_.y, 0.0f);
VSML::instance()->scale(current.life_, current.life_, 1.0f);
touch_->bind(VSML::instance());
touch_->setUniformValue("life", current.life_);
touchprim_->draw(touch_);
touchfill_->draw(touch_);
touch_->release();
}
}
Engine::instance()->unlock();
// get the closeness to a beat
// draw background
GL::instance()->ortho();
float2 scale1 = { w / 1024.f, h / 1024.f };
glActiveTexture(GL_TEXTURE0);
framebuffer1_->bindsurface(0);
texLight_->bind(VSML::instance());
texLight_->setUniformValue("tex", 0);
texLight_->setUniformValue("beat", state_->getBeat());
texLight_->setUniformValue("nLights", nLights);
texLight_->setUniformValue("lightpositions", lightPositions_, 10);
texLight_->setUniformValue("texScale", scale1);
quad_->draw(texLight_);
texLight_->release();
//overlay
prog += dt / 100000.f;
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA);
overlay_->bind(VSML::instance());
overlay_->setUniformValue("height", 1.f / 30.f);
overlay_->setUniformValue("progress", (float) Audio::instance()->getPercentComplete("sim"));
topbar_->draw(overlay_);
overlay_->release();
glDisable(GL_BLEND);
std::stringstream ss;
ss << std::setfill('0') << std::setw(9) << score_;//"FPS > " << (int) fps_; // << " <> " << progress;// << "\nRES > " << GL::instance()->width() << " X " << GL::instance()->height();
GL::instance()->renderText(ss.str(), Float3(2.f, -7.f, 0.f),
FONTS::FontLekton);
}
else if(state_->state() == MENU) {
const float2 &offset = state_->dragOffset();
// Float3 color;
// IdxToRGB565(cell_[j].id, color);
// id_->setUniformValue("id", color);
// disc->draw(id_);
// id_->release();
// for(int i=0;i <9; i++) {
// VSML::instance()->translate(0.f, 80.f, 0.f);
// buttonShader_->bind(VSML::instance());
// buttonShader_->setUniformValue("life", 0.5f);
// button_->draw(buttonShader_);
// buttonShader_->release();
// }
// #ifndef _DESKTOP
// GLushort *texdata = new GLushort[GL::instance()->width()
// * GL::instance()->height()];
// ids_ = new int[GL::instance()->width() * GL::instance()->height()];
// glReadPixels(0, 0, GL::instance()->width(), GL::instance()->height(),
// GL_RGB, GL_UNSIGNED_SHORT_5_6_5, texdata);
// #else
// GLbyte *texdata = new GLbyte[GL::instance()->width() * GL::instance()->height()*4];
// ids_ = new int[GL::instance()->width() * GL::instance()->height()];
// glReadPixels(0, 0, GL::instance()->width(), GL::instance()->height(), GL_RGBA, GL_BYTE, texdata);
// #endif
// for (int y = 0, i = 0; y < GL::instance()->height(); y++) {
// for (int x = 0; x < GL::instance()->width(); x++, i++) {
// #ifndef _DESKTOP
// int r = (255 * ((texdata[i]) >> 11) + 15) / 31;
// int g = (255 * ((texdata[i] & 0x7E0) >> 5) + 31) / 63;
// int b = (255 * ((texdata[i] & 0x01F)) + 15) / 31;
// ids_[i] = (r * 32 * 64 / 8 + g * 32 / 4 + b / 8) - 1;
// #else
// int r = texdata[i*4];
// int g = texdata[i*4+1];
// int b = texdata[i*4+2];
// ids_[i] = (r*32*64/8+g*32/4+b/8)-1;
// // if(r!=0||g!=0||b!=0)
// // qDebug() << "test:: " << r << ", " << g << ", " << b << ":::" << ids_[i];
// #endif
// }
// }
// delete[] texdata;
glClear(GL_COLOR_BUFFER_BIT);
GL::instance()->ortho();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA);
// glClear(GL_COLOR_BUFFER_BIT);
// GL::instance()->ortho();
// Float3 color;
// IdxToRGB565(1, color);
// VSML::instance()->translate(0.f, 55.f + offset.y, 0.f);
// id_->bind(VSML::instance());
// id_->setUniformValue("id", 0.5f);
// button_->draw(id_);
// id_->release();
overlay_->bind(VSML::instance());
overlay_->setUniformValue("height", 0.f);
overlay_->setUniformValue("progress", 50.f / (float)w);
quad_->draw(overlay_);
overlay_->release();
VSML::instance()->translate(0.f,offset.y, 0.f);
for(int i=0;i <state_->headers()->size(); i++) {
VSML::instance()->translate(0.f, 80.f, 0.f);
buttonShader_->bind(VSML::instance());
buttonShader_->setUniformValue("life", 0.5f);
button_->draw(buttonShader_);
buttonShader_->release();
}
GL::instance()->renderText("SONG SELECT", Float3(70.f, 5.f+ offset.y, 0.f), FONTS::FontLekton, 0.6f);
for(int i=0;i<state_->headers()->size(); i++) {
std::stringstream ss;
double seconds = state_->headers()->at(i)->getData()->length_;
int minutes = seconds / 60;
int secondsr = seconds - minutes*60;
ss << state_->headers()->at(i)->getData()->title_ << "\n" <<minutes << ":" << std::setfill('0') << std::setw(2) << secondsr;
GL::instance()->renderText(ss.str(), Float3(70.f, 55.f + 80*i + offset.y, 0.f), FONTS::FontLekton, 0.5f);
}
}
// GL::instance()->renderText("P\nI\nD\nG\nE\nY", Float3(15.f, 5.f, 0.f), FONTS::FontLekton);
else if(state_->state() == SCORE){
// render the score screen
GL::instance()->renderText("YOUR RATING", Float3(70.f, 5.f, 0.f), FONTS::FontLekton, 0.6f);
std::stringstream sstm;
sstm << ((state_->getSwipes() > 0) ? (((float) score_ * score_) / ((float) state_->getSwipes())) : 0);
GL::instance()->renderText(sstm.str(), Float3(70.f, 50.f, 0.f), FONTS::FontLekton, 1.0f);
GL::instance()->renderText("MENU", Float3(500.f, 300.f, 0.f), FONTS::FontLekton, 1.0f);
VSML::instance()->translate(552.f, 150.f, 0.f);
VSML::instance()->scale(2.8f, 2.8f, 0.0f);
touch_->bind(VSML::instance());
touch_->setUniformValue("life", 1.0f);
touchprim_->draw(touch_);
touch_->release();
}
else if(state_->state() == TITLE){
// draw background
GL::instance()->ortho();
float2 scale1 = { w / 1024.f, h / 1024.f };
glActiveTexture(GL_TEXTURE0);
framebuffer1_->bindsurface(0);
texLight_->bind(VSML::instance());
texLight_->setUniformValue("tex", 0);
texLight_->setUniformValue("beat", state_->getBeat());
texLight_->setUniformValue("nLights", 0);
texLight_->setUniformValue("lightpositions", lightPositions_, 10);
texLight_->setUniformValue("texScale", scale1);
quad_->draw(texLight_);
texLight_->release();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA);
id_->bind(VSML::instance());
id_->setUniformValue("id", Float3(0.2f, 0.2f, 0.2f));
quad_->draw(id_);
id_->release();
// render the title screen
GL::instance()->renderText("CUPCAKE SHADER EDITOR", Float3(100.f, 20.f, 0.f), FONTS::FontLekton, 1.0f);
GL::instance()->renderText("TOUCH ANYWHERE TO START", Float3(200.f, 300.f, 0.f), FONTS::FontLekton, 0.6f);
}
}
void PockyGame::DrawGrid(int radx, int rady, bool solid) {
GLPrimitive *square = new GLQuad(Float3(10, 10, 10), Float3(0.f, 0.f, -5.f),
Float3(1.f, 1.f, 1.f));
if (!solid) {
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
} else {
glDisable(GL_BLEND);
}
GLPrimitive *disc = new GLDisc(Float3(6, 1, 1), Float3(0.f, 0.f, -5.f),
Float3(1.f, 1.f, 1.f));
float2 scale = { 1.f, 1.f };
for (int y = -rady, i = 0, j = 0; y <= rady; y++, i++) {
for (int x = -radx; x <= radx; x++, j++) {
// cell_[j].life = 0.f;
cell_[j].id = j + 1;
GL::instance()->perspective(60.f, 0.01f, 1000.f,
GL::instance()->width(), GL::instance()->height());
if (i % 2 == 0) {
cell_[j].wspos = Float3(x * (1.05), -y * 0.95, -5.f);
VSML::instance()->translate(x * (1.05), y * 0.95, 0.f);
} else {
cell_[j].wspos = Float3(x * (1.05) + 0.5f, -y * 0.95, -5.f);
VSML::instance()->translate(x * (1.05) + 0.5f, y * 0.95, 0.f);
}
cell_[j].sspos = GL::instance()->unproject(cell_[j].wspos);
if (solid) {
id_->bind(VSML::instance());
//convert j=1...65535 to r5g6b5
//32 - 64 - 32
//r*32*64+g*32+b
//r = idx / (32*64), g = (idx - r*32*64) / 32, b=(idx - r*32*64-g*32)
Float3 color;
IdxToRGB565(cell_[j].id, color);
id_->setUniformValue("id", color);
disc->draw(id_);
id_->release();
} else {
GL::instance()->shader("texmap")->bind(VSML::instance());
glActiveTexture(GL_TEXTURE0);
fbo2->bindsurface(0);
GL::instance()->shader("texmap")->setUniformValue("tex", 0);
GL::instance()->shader("texmap")->setUniformValue("texScale",
scale);
square->draw("texmap");
GL::instance()->shader("texmap")->release();
}
}
}
delete disc;
delete square;
glDisable(GL_BLEND);
}
void PockyGame::generateAssets() {
GL::instance()->createShader("blur", "assets/shaders/blur.glsl");
GLFramebufferObjectParams parms;
parms.width = 128;
parms.height = 128;
parms.type = GL_TEXTURE_2D;
parms.format = GL_RGBA;
parms.hasDepth = false;
framebuffer0_ = new GLFramebufferObject(parms);
fbo2 = new GLFramebufferObject(parms);
framebuffer0_->bind();
glClearColor(0.0f, 0.f, 0.f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, parms.width, parms.height);
GL::instance()->ortho(parms.width, parms.height);
GL::instance()->shader("default")->bind(VSML::instance());
for (int i = 0; i < 2; i++) {
GLPrimitive *hexagon = new GLCircle(
Float3(6, 10, 10),
Float3(parms.width / 2.f, parms.height / 2.f, 0.f),
Float3(parms.width - i * 20 - 2, parms.height - i * 20 - 2,
1.f));
hexagon->draw("default");
delete hexagon;
}
GL::instance()->shader("default")->release();
framebuffer0_->release();
GLQuad *fx = new GLQuad(Float3(10, 10, 10),
Float3(parms.width / 2, parms.height / 2, 1.f),
Float3(parms.width, parms.height, 1.f));
fbo2->bind();
//antialiasing pass
GL::instance()->shader("blur")->bind(VSML::instance());
glActiveTexture(GL_TEXTURE0);
framebuffer0_->bindsurface(0);
GL::instance()->shader("blur")->setUniformValue("tex", 0);
fx->draw("blur");
fbo2->release();
delete framebuffer0_;
parms.width = 1024;
parms.height = 1024;
glClearColor(0.f, 0.f, 0.0f, 1.0f);
glViewport(0, 0, GL::instance()->width(), GL::instance()->height());
framebuffer1_ = new GLFramebufferObject(parms);
//framebuffer1_->bind();
glClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_DITHER);
GL::instance()->perspective(60.f, 0.01f, 1000.f, GL::instance()->width(),
GL::instance()->height());
DrawGrid(params_.gridx, params_.gridy, true);
#ifndef _DESKTOP
GLushort *texdata = new GLushort[GL::instance()->width()
* GL::instance()->height()];
ids_ = new int[GL::instance()->width() * GL::instance()->height()];
glReadPixels(0, 0, GL::instance()->width(), GL::instance()->height(),
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, texdata);
#else
GLbyte *texdata = new GLbyte[GL::instance()->width() * GL::instance()->height()*4];
ids_ = new int[GL::instance()->width() * GL::instance()->height()];
glReadPixels(0, 0, GL::instance()->width(), GL::instance()->height(), GL_RGBA, GL_BYTE, texdata);
#endif
for (int y = 0, i = 0; y < GL::instance()->height(); y++) {
for (int x = 0; x < GL::instance()->width(); x++, i++) {
#ifndef _DESKTOP
int r = (255 * ((texdata[i]) >> 11) + 15) / 31;
int g = (255 * ((texdata[i] & 0x7E0) >> 5) + 31) / 63;
int b = (255 * ((texdata[i] & 0x01F)) + 15) / 31;
ids_[i] = (r * 32 * 64 / 8 + g * 32 / 4 + b / 8) - 1;
#else
int r = texdata[i*4];
int g = texdata[i*4+1];
int b = texdata[i*4+2];
ids_[i] = (r*32*64/8+g*32/4+b/8)-1;
// if(r!=0||g!=0||b!=0)
// qDebug() << "test:: " << r << ", " << g << ", " << b << ":::" << ids_[i];
#endif
}
}
delete[] texdata;
framebuffer1_->bind();
glClear(GL_COLOR_BUFFER_BIT);
GL::instance()->perspective(60.f, 0.01f, 1000.f, GL::instance()->width(),
GL::instance()->height());
DrawGrid(params_.gridx, params_.gridy, false);
framebuffer1_->release();
//begine active hex generation
framebuffer1_->releaseFramebuffer();
parms.width = 128;
parms.height = 128;
framebuffer0_ = new GLFramebufferObject(parms);
framebuffer0_->bind();
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, parms.width, parms.height);
GL::instance()->ortho(parms.width, parms.height);
GLPrimitive *hexagon = new GLDisc(Float3(6, 10, 10),
Float3(parms.width / 2.f, parms.height / 2.f, 0.f),
Float3(parms.width - 20, parms.height - 20, 1.f));
GL::instance()->shader("default2")->bind(VSML::instance());
glActiveTexture(GL_TEXTURE0);
fbo2->bindsurface(0);
GL::instance()->shader("default2")->setUniformValue("tex", 0);
hexagon->draw("default2");
GL::instance()->shader("default2")->release();
delete hexagon;
framebuffer0_->release();
delete fx;
delete fbo2;
}
void PockyGame::loadShaders() {
GL::instance()->createShader("default2", "assets/shaders/default2.glsl"); //i have no fucking clue why this is necessary to prevent a segfault on the desktop...just deal with it - paul
GL::instance()->createShader("hex", "assets/shaders/hex.glsl");
hexShader_ = GL::instance()->shader("hex");
GL::instance()->createShader("texlit", "assets/shaders/texmaplit.glsl");
texLight_ = GL::instance()->shader("texlit");
// GL::instance()->createShader("bg", "assets/shaders/background.glsl");
// bg_ = GL::instance()->shader("bg");
// GL::instance()->createShader("alpha", "assets/shaders/alpha.glsl");
// bg_ = GL::instance()->shader("alpha");
GL::instance()->createShader("overlay", "assets/shaders/overlay.glsl");
overlay_ = GL::instance()->shader("overlay");
GL::instance()->createShader("id", "assets/shaders/id.glsl");
id_ = GL::instance()->shader("id");
GL::instance()->createShader("touch", "assets/shaders/touch.glsl");
touch_ = GL::instance()->shader("touch");
GL::instance()->createShader("button", "assets/shaders/button.glsl");
buttonShader_ = GL::instance()->shader("button");
GL::instance()->createShader("hit", "assets/shaders/hithex.glsl");
hit_ = GL::instance()->shader("hit");
}
void PockyGame::applyGLSettings() {
glEnable(GL_TEXTURE_2D);
glClearColor(0.f, 0.f, 0.f, 1.0f);
glClearColor(0.f, 0.f, 0.f, 1.0f);
glDisable(GL_DEPTH_TEST);
glLineWidth(1.5f);
}
int PockyGame::getGridLocation(int x, int y) {
return ids_[y * GL::instance()->width() + x];
}
} /* namespace Pineapple */
|
09bc68ddc45031b9237d8a6e010f9e5704b11707 | 71b21a371a7d0e133be611868b38d5abbcb33c02 | /Tool/ToolUIScript.h | f2849223f044a8e334f316f110e86e157b464d7f | [] | no_license | snrkgotdj/Tera_SoulLike | 7ad77694b7425609688408bf6e5319be3907a2c6 | b513f4e451d6f838392389d8fc913c1856d28e21 | refs/heads/master | 2020-04-08T14:11:39.370877 | 2018-11-28T01:50:55 | 2018-11-28T01:50:55 | 159,426,065 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 284 | h | ToolUIScript.h | #pragma once
#include "Script.h"
class CToolUIScript :
public CScript
{
private:
Matrix m_matProj;
public:
virtual void Start();
virtual int Update();
public:
void SetUINumber(UINT _i);
public:
CLONE(CToolUIScript)
public:
CToolUIScript();
virtual ~CToolUIScript();
};
|
57068caa5a4410494bcd4f621123015a294ee802 | bd6e36612cd2e00f4e523af0adeccf0c5796185e | /src/core/candoClass.cc | 214ad431e15ad1bdedf05d62aae2e0bad15d8aa9 | [] | no_license | robert-strandh/clasp | 9efc8787501c0c5aa2480e82bb72b2a270bc889a | 1e00c7212d6f9297f7c0b9b20b312e76e206cac2 | refs/heads/master | 2021-01-21T20:07:39.855235 | 2015-03-27T20:23:46 | 2015-03-27T20:23:46 | 33,315,546 | 1 | 0 | null | 2015-04-02T15:13:04 | 2015-04-02T15:13:04 | null | UTF-8 | C++ | false | false | 4,424 | cc | candoClass.cc | /*
File: candoClass.cc
*/
/*
Copyright (c) 2014, Christian E. Schafmeister
CLASP is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
See directory 'clasp/licenses' for full details.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* -^- */
#define DEBUG_LEVEL_FULL
#include <clasp/core/foundation.h>
#include <candoClass.h>
#include <clasp/core/lisp.h>
#include <effectiveSlotDefinition.h>
#include <clasp/core/evaluator.h>
#include <clasp/core/standardObject.h>
#include <clasp/core/package.h>
#include <clasp/core/lambdaListHandler.h>
#include <clasp/core/wrappers.h>
namespace core {
void CandoClass_O::initialize()
{
this->Base::initialize();
this->_CoreObjectClass = _Nil<Class_O>();
}
CandoClass_sp CandoClass_O::create(Lisp_sp lisp,Symbol_sp name)
{_G();
GC_ALLOCATE(CandoClass_O);
oclass->_Name = name;
// Lets create a predefined symbol here for the class name
oclass->_InstanceClassSymbol = UNDEFINED_SYMBOL;
_lisp->createPredefinedSymbol(oclass->_InstanceClassSymbol,name);
// oclass->_InstanceVariableNames = _Nil<Cons_O>();
IMPLEMENT_MEF(BF("What do I do about superclasses of the CandoClass here? - I should call setInstanceBaseClasses with something or just StandardObject "));
return oclass;
}
#if defined(XML_ARCHIVE)
void CandoClass_O::archiveBase(ArchiveP node)
{_OF();
IMPLEMENT_MEF(BF("Implement CandoClass_O::archiveBase"));
}
#endif // defined(XML_ARCHIVE)
Class_sp CandoClass_O::getCoreObjectClass()
{_G();
return this->_CoreObjectClass;
}
void CandoClass_O::setCoreObjectClass(Class_sp mc)
{_G();
this->_CoreObjectClass = mc;
}
void CandoClass_O::describe()
{_G();
_lisp->print(BF("------------ CandoClass name: %s instanceClassSymbol: %d") % this->_Name->__repr__() % this->_InstanceClassSymbol );
// _lisp->print(BF("Instance variables: %s") % this->_InstanceVariableNames->__repr__().c_str() );
_lisp->print(BF("%s") % this->dumpInfo() );
}
string CandoClass_O::dumpInfo()
{_G();
stringstream ss;
ss << this->Base::dumpInfo();
ss << "CoreObjectClass: " << this->_CoreObjectClass->getPackagedName() << std::endl;
return ss.str();
}
string CandoClass_O::dumpMethods()
{
return this->Base::dumpMethods();
}
Cons_sp CandoClass_O::find(Symbol_sp sym)
{_G();
IMPLEMENT_MEF(BF("Handle find slot by name"));
#if 0
ASSERTNOTNULL(sym);
LOG(BF("Looking in CandoClass for slot for symbol: %s") % sym->fullName() );
CandoClass_O::slotIterator fnd = this->_SlotNames.find(sym);
return this->_SlotNames.find(sym);
#endif
}
void CandoClass_O::setupAccessors(Cons_sp slotNames)
{_G();
IMPLEMENT_ME(); // Dont pass the slot names, use the slots already defined
#if 0
this->_InstanceVariableNames = slotNames;
while ( slotNames.notnilp() )
{
Symbol_sp slotName = slotNames->ocar().as<Symbol_O>();
string setterName = "set_"+slotName->symbolNameAsString();
Symbol_sp setterSymbol = _lisp->internKeyword(setterName);
SlotSetter_sp setterForm = SlotSetter_O::create(setterSymbol,_lisp);
this->addMethod(setterSymbol,setterForm);
string getterName = "get_"+slotName->symbolNameAsString();
Symbol_sp getterSymbol = _lisp->internKeyword(getterName);
SlotGetter_sp getterForm = SlotGetter_O::create(getterSymbol,_lisp);
this->addMethod(getterSymbol,getterForm);
slotNames = slotNames->cdr();
}
#endif
}
void CandoClass_O::exposeCando(Lisp_sp lisp)
{
class_<CandoClass_O>()
;
}
void CandoClass_O::exposePython(Lisp_sp lisp)
{_G();
PYTHON_CLASS(CorePkg,CandoClass,"","",_lisp)
;
}
EXPOSE_CLASS(core,CandoClass_O);
};
|
7b31c1f43759c380a8ec8a7adb69097510febc36 | 0370b81e9ec3f1b1d4bf0da224a613ff576e8dd4 | /CodeForces/R237Div2/D.cpp | 658a3a677b54ea84e6f5127ca24126553f0ddd1d | [] | no_license | Rolight/ACM_ICPC | c511bc58ac5038ca521bb500a40fcbdf5468832d | 6208a20ea66a42b4a06249d97494c77f55121847 | refs/heads/master | 2021-01-10T22:08:48.336023 | 2015-07-17T21:46:48 | 2015-07-17T21:46:48 | 27,808,805 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,982 | cpp | D.cpp | #include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 1000000 + 5;
const int mod = 1000000000 + 7;
const int mine = 3;
char buf[maxn];
int len;
LL f[maxn][5][5];
int tmp[maxn],val[maxn];
LL dfs(int now,int p1,int p2) {
tmp[now - 1] = p1;
if(now == len + 1) {
if(p1 == 2 || (p1 == 1 && p2 != mine)) return 0;
//for(int i = 1;i <= len;i++) printf("%d",tmp[i]); putchar('\n');
return 1;
}
if(p1 >= 0 && p2 >= 0 && f[now][p1][p2] != -1) return f[now][p1][p2];
LL ret = 0;
if(val[now] == -1) {
if(p1 == 0 || p1 == 3 || (p1 == 1 && p2 == 3)) ret = (ret + dfs(now + 1,1,p1)) % mod;
if(p1 == 3) ret = (ret + dfs(now + 1,2,p1)) % mod;
if(p1 == 0 || (p1 == 1 && p2 == 3)) ret = (ret + dfs(now + 1,0,p1)) % mod;
if(now == 1 || (p1 == 1 && p2 != 3) || p1 == 2 || p1 == 3) ret = (ret + dfs(now + 1,3,p1)) % mod;
}
if(val[now] == 0) {
if(p1 == 0 || (p1 == 1 && p2 == 3)) ret = dfs(now + 1,0,p1);
}
if(val[now] == 1) {
if(!(p1 == 2 || (p1 == 1 && p2 != 3))) ret = dfs(now + 1,1,p1);
}
if(val[now] == 2) {
if(p1 == 3) ret = dfs(now + 1,2,p1);
}
if(val[now] == 3) {
if(now == 1 || p1 == 2 || (p1 == 1 && p2 != 3) || p1 == 3) ret = dfs(now + 1,3,p1);
}
if(p1 >= 0 && p2 >= 0) f[now][p1][p2] = ret % mod;
return ret % mod;
}
int main() {
memset(f,-1,sizeof(f));
scanf("%s",buf + 1);
len = strlen(buf + 1);
int cnt = 0;
for(int i = 1;i <= len;i++) {
if(buf[i] == '*') val[i] = mine;
else if(buf[i] == '?') val[i] = -1;
else val[i] = buf[i] - '0';
}
LL ret = dfs(0,0,-1);
cout << ret % mod << endl;
return 0;
}
|
69157a49b1bc219703f8a5f01604ded27472fc5a | 5b1f023772fc08c2301dc22c9bfcf866f2d14174 | /Windows/Sources/ContextAgent.cpp | d9a1e744683ba4a55747ef09dbacc5f5f8172877 | [
"MIT"
] | permissive | FocusCompany/daemon | 20651308c27fddba7b19ccc16ca1c202444d08a8 | a8004229dcd51641cd971bcb62b56c08fd0eb07a | refs/heads/development | 2021-05-15T13:19:00.188649 | 2018-11-29T11:10:04 | 2018-11-29T11:10:04 | 107,158,706 | 1 | 0 | MIT | 2018-11-29T11:10:05 | 2017-10-16T17:13:36 | C++ | UTF-8 | C++ | false | false | 2,110 | cpp | ContextAgent.cpp | //
// Created by Etienne Pasteur on 17/10/2017.
//
#include "ContextAgent.hpp"
#include "FocusSerializer.hpp"
#include "FocusContextEventPayload.pb.h"
ContextAgent::ContextAgent() : _isRunning(false),
_sigReceived(false),
_eventListener(),
_eventEmitter(std::make_unique<FocusEventEmitter>()) {}
ContextAgent::~ContextAgent() {
if (_isRunning) {
_isRunning = false;
_eventListener->detach();
}
}
void ContextAgent::Run(std::atomic<bool> &sigReceived) {
_sigReceived = sigReceived.load();
_isRunning = true;
_eventListener = std::make_unique<std::thread>(std::bind(&ContextAgent::EventListener, this));
}
void ContextAgent::EventListener() {
std::string oldProcessName;
std::string oldWindowsTitle;
while (_isRunning && !_sigReceived) {
HWND hwnd = GetForegroundWindow();
DWORD processId = GetProcessId(hwnd);
char tmp[0xFF] = {0};
GetWindowThreadProcessId(hwnd, &processId);
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processId);
GetProcessImageFileName(hProcess, tmp, 0xFF);
std::string processName = std::string(tmp);
processName = processName.substr(processName.find_last_of("/\\") + 1);
GetWindowText(hwnd, tmp, 0xFF);
std::string windowsTitle = std::string(tmp);
if (oldProcessName != processName || oldWindowsTitle != windowsTitle) {
oldProcessName = processName;
oldWindowsTitle = windowsTitle;
OnContextChanged(processName, windowsTitle);
}
std::this_thread::sleep_for(std::chrono::seconds(2));
}
}
void ContextAgent::OnContextChanged(const std::string &processName, const std::string &windowTitle) const {
Focus::ContextEventPayload context;
context.set_processname(processName);
context.set_windowname(windowTitle);
Focus::Event event = FocusSerializer::CreateEventFromContext("ContextChanged", context);
_eventEmitter->Emit("NewEvent", event);
}
|
b16c0d3780b6ba6d444c88794a74e08bfb9d4b42 | 9a55e0ea1d227f0ede63d941a4093fbafd56c523 | /components/WS/src/HttpParser.h | 614638c9ae8cf34d59c1ba8ddf05d2c2af60e772 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | gustavosinbandera1/turpial-firmware | 0f22b05bb48e33edd095455dba1c0ff41d18bbde | eb8bd14999acb2716e66c27a7ab6f835ecb499cf | refs/heads/master | 2020-11-27T22:11:07.115497 | 2020-02-13T14:19:23 | 2020-02-13T14:19:23 | 210,370,697 | 0 | 0 | Apache-2.0 | 2019-09-23T14:04:15 | 2019-09-23T14:04:15 | null | UTF-8 | C++ | false | false | 978 | h | HttpParser.h | #ifndef CPP_UTILS_HTTPPARSER_H_
#define CPP_UTILS_HTTPPARSER_H_
#include "Socket.h"
#include <map>
#include <string>
class HttpParser
{
public:
HttpParser();
virtual ~HttpParser();
std::string getBody();
std::string getHeader(const std::string& name);
std::map<std::string, std::string> getHeaders();
std::string getMethod();
std::string getURL();
std::string getVersion();
std::string getStatus();
std::string getReason();
bool hasHeader(const std::string& name);
void parse(std::string message);
void parse(Socket s);
void parseResponse(std::string message);
private:
std::string m_method;
std::string m_url;
std::string m_version;
std::string m_body;
std::string m_status;
std::string m_reason;
std::map<std::string, std::string> m_headers;
void dump();
void parseRequestLine(std::string& line);
void parseStatusLine(std::string& line);
};
#endif /* CPP_UTILS_HTTPPARSER_H_ */ |
401675222acf1204e1ea50328ffe5c873c083b91 | e910c65ddec02e0a14cda848398626c2cd7987ef | /src/数据结构与算法/MyTree.hpp | a4c8052202e9e2ebf69600f626d71ec57ceb6292 | [] | no_license | JiangChenrui/mycode | c3d0c2c8939a200ffce71f5d77e35e2a45cfa4b6 | ac37cb56f57f9f72a7d5caaa74ca954e4c848fdd | refs/heads/master | 2023-01-21T17:55:25.818180 | 2020-12-01T03:44:57 | 2020-12-01T03:44:57 | 280,095,305 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,491 | hpp | MyTree.hpp | #ifndef MYTREE_HPP
#define MYTREE_HPP
#include <iostream>
using namespace std;
#define TYPE char
//树的节点
struct TreeNode{
TYPE element; //该节点的元素
TreeNode *firstChild; //指向该节点的第一个孩子
TreeNode *nextSibling; //指向该节点的兄弟节点
};
class Tree {
public:
Tree(TreeNode * r = NULL):root(r){}
Tree(int node_num);
~Tree();
void addNode(int i, int j);
void preOrder();//前序遍历
void print();//打印
private:
void print(TreeNode* node, int num);
void addBrotherNode(TreeNode* bro, TreeNode* node);
void preOrder(TreeNode* parent);//前序遍历
TreeNode * root;//该树的根
};
//打印树的形状
void Tree::print()
{
print(root, 0);
}
void printSpace(int num)
{
int i = 0;
for(i = 0; i < num-3; i++)
cout << " ";
for(; i < num-2; ++i)
cout << "|";
for(; i < num; ++i)
cout << "_";
}
void Tree::print(TreeNode* node, int num)
{
if(node != NULL){
printSpace(num);
cout << node->element << endl;
print(node->firstChild, num+4);
print(node->nextSibling, num);
}
}
//前序遍历
void Tree::preOrder()
{
cout << "前序遍历: ";
preOrder(root);
cout << endl;
}
void Tree::preOrder(TreeNode* parent)
{
if(parent != NULL){
cout << parent->element << " ";
preOrder(parent->firstChild);
preOrder(parent->nextSibling);
}
}
//分配并初始化所有的树结点
Tree::Tree(int node_num)
{
root = new TreeNode[node_num];
char ch = 'A';
for(int i = 0; i < node_num; ++i){
root[i].element = ch + i;
root[i].firstChild = NULL;
root[i].nextSibling = NULL;
}
}
//释放所有节点的内存空间
Tree::~Tree()
{
if(root != NULL)
delete [] root;
}
//addNode将父子结点组对
//如果父节点的firstChild==NULL, 则firstChild = node;
//如果父节点的firstChild != NULL, 则
void Tree::addNode(int i, int j)
{
TreeNode* parent = &root[i];
TreeNode* node = &root[j];
if(parent->firstChild == NULL)
parent->firstChild = node;
else
addBrotherNode(parent->firstChild, node);
}
//将节点插入到兄弟节点
void Tree::addBrotherNode(TreeNode* bro, TreeNode* node)
{
if(bro->nextSibling == NULL)
bro->nextSibling = node;
else
addBrotherNode(bro->nextSibling, node);
}
#endif |
28068cb54dab5d55d979a91c319283ba75e8aac1 | 4754fcf030ee22029811b324d0b4109631c432f0 | /Control.h | f56246381db6878cdc85d04ac60b90533158b413 | [] | no_license | haojialiu/Blacklist-project | b81a208f509e8575ccf10a1da55849cade029911 | 7c19841ed490026e94a8d83fe12b929617428fd3 | refs/heads/master | 2020-04-26T12:31:36.171192 | 2019-03-03T09:06:35 | 2019-03-03T09:06:35 | 173,552,583 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,426 | h | Control.h | #ifndef control_H
#define control_H
#include"model.h"
class Control
{
private:
Model _MODEL;
public:
void process()
{
while (1)
{
cout << "输入命令" << endl;
cout << "1:插入 " << "2:删除 " << "3:更改 " << "4:查询 " << "6:退出 " << endl;
char c ;
cin >> c;
if (c == '6')
{
cout << "关闭程序" << endl;
return;
}
else if (c == '1')
{
cout << "请输入插入信息" << endl;
_MODEL._model[1]->process();
cout <<endl;
// cout << "插入完成" << endl;
}
else if (c == '2')
{
cout << "请输入id" << endl;
_MODEL._model[2]->process();;
cout <<endl;
//cout << "删除完成" << endl;
}
else if (c == '3')
{
cout << "请输入id及更改内容" << endl;
_MODEL._model[3]->process();;
cout <<endl;
//cout << "更改完成"<< endl;
}
else if (c == '4')
{
cout << "请输入id" << endl;
_MODEL._model[4]->process();;
cout <<endl;
}
else if (c == '5')
{
cout << "打印结果:" << endl;
_MODEL._model[5]->process();;
cout <<endl;
}
//_model.search(c)();
}
/*_model.show();*/
}
Control()
{
}
Control(const Control&src)
{
Model _model(src._MODEL);
}
Control &operator=(const Control& src)
{
if (this == &src)
{
return *this;
}
_MODEL = src._MODEL;
}
};
#endif
|
e3b04c04b3445ab4d82f89033714c56eaad42109 | b6d3e89588fc404988f893d0dc256e5c141bf742 | /swtest/kakao/2022kakao/d.cc | 4caffa6d82e9668f83a9e7b80646687736969ff2 | [] | no_license | ingyeoking13/algorithm | 236a526929947fc0a118c795513962e75dd589e3 | 5bd7575468f4794b1c71baa6c59c45a25bfada2c | refs/heads/master | 2023-01-12T07:48:46.135702 | 2022-12-28T14:57:45 | 2022-12-28T14:57:45 | 105,534,031 | 2 | 5 | null | 2022-12-08T06:08:04 | 2017-10-02T12:54:39 | C++ | UTF-8 | C++ | false | false | 1,751 | cc | d.cc | #include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
string buildTree(string str) {
int height = 1;
int len = str.size();
while(true) {
int elem = pow(2, height)-1;
if (elem >= len) break;
height++;
}
string suffix;
int elem = pow(2, height) -1;
for (int i=0; i<elem-len; i++) {
suffix += "0";
}
string result = suffix + str;
return result;
}
bool validCheck(string str, int f, int t) {
int mid = (f+t)/2;
// cout << f << " , " << t << ", " << "idx: " << mid <<"\n";
if (f == t) return true;
if (str[mid]=='1') {
bool result = validCheck(str, f, mid-1);
result &= validCheck(str, mid+1, t);
return result;
}
bool result = true;
for (int i=f; i<=t; i++) {
result &= str[i]=='0';
}
return result;
}
vector<int> solution(vector<long long> numbers) {
vector<int> answer;
for (long long number: numbers){
long long origin = number;
string str;
while(number){
str += ('0' + (number%2));
number /= 2;
}
reverse(str.begin(), str.end());
cout << str <<"\n";
string treeStr = buildTree(str);
int len = treeStr.size();
// cout << len <<"\n";
int _answer = validCheck(treeStr, 0, len-1);
answer.push_back(_answer);
}
// for (bool ans: answer) {
// cout << ans << " ";
// }
// cout <<"\n-------\n";
return answer;
}
int main(){
solution({7, 5});
solution({63, 111, 95});
solution({2, 4});
solution({1024});
solution({0b11111111111111111111111111111111111111111111111111111111111111});
}
|
6e892d44a3d8cfd66c3746175682e5cdfda70ae1 | 60bbec4f781503810a89d8ca1fceac6e9292e558 | /Forest/main.cpp | c6ff06c894f767eb29266e0c70bb076d4d8547e9 | [] | no_license | Massterr59rus/C-and-C-plus-plus | f1ae9e517a6a0055531b238daedd0d58fe56ecbd | 4e23eecb5afd429709db99fd3b38402369d5ff63 | refs/heads/master | 2021-03-15T04:46:14.393008 | 2015-03-20T09:57:54 | 2015-03-20T09:57:54 | null | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 4,692 | cpp | main.cpp | // Создать класс живущих с местоположением.
// Определить наследуемые классы - лиса, кролик и трава.
// Лиса ест кролика.
// Кролик ест траву.
// Лиса может умереть - определен возраст.
// Кролик тоже может умереть.
// Кроме этого определен класс - отсутствие жизни.
// Если в окрестности имеется больше травы, чем кроликов, то трава остается, иначе трава съедена.
// Если лис слишком старый он может умереть.
// Если лис слишком много(больше 5 в окрестности), лисы больше не появляются.
// Если кроликов меньше лис, то лис ест кролика.????????
// Если кроликов меньше лис, то лисы съедят всех кроликов.
#include <iostream>
using namespace std;
#include"Grass.h"
#include"Rabbits.h"
#include"Foxes.h"
int main() {
Island island;
size_t day;
size_t noPlantSpan = 7; // days
while (island.getTime() < noPlantSpan)
{
day = island.getTime();
cout << day << "\n";
island.putTime(++day);
}
Grass grass;
size_t tot;
size_t noAnimalSpan = 70;
while (island.getTime() < noPlantSpan + noAnimalSpan)
{
tot = grass.getTotalGrass();
tot += grass.incrementPerDay();
if (tot > grass.getMaxWeight())
tot = grass.getMaxWeight();
grass.putTotalGrass(tot);
cout << island.getTime() << "\t" << tot << "\t" << grass.incrementPerDay() << "\n";
island.putTime(++day);
}
Rabbits rabbits(150);
size_t noFoxSpan = 200;
while (island.getTime() < noPlantSpan + noAnimalSpan + noFoxSpan)
{
tot = grass.getTotalGrass();
tot += grass.incrementPerDay();
if (tot > grass.getMaxWeight())
tot = grass.getMaxWeight();
if (rabbits.herd != nullptr)
{
if (tot > rabbits.eat())
tot -= rabbits.eat();
else {
int die = (int)((rabbits.eat() - tot) / rabbits.herd[0].eat_day);
rabbits.herd = rabbits.Birth_Die(rabbits.herd, rabbits.size - die);
tot = 0;
}
}
size_t RabSpan = island.getTime() - noPlantSpan - noAnimalSpan;
if ((RabSpan) % (rabbits.herd[0].reproductionTime) == 0 && RabSpan != 0)
rabbits.herd = rabbits.Birth_Die(rabbits.herd, rabbits.size + rabbits.size * rabbits.herd[0].offspring / 2);
grass.putTotalGrass(tot);
cout << island.getTime() << "\t" << tot << "\t" << rabbits.size << "\n";
island.putTime(++day);
}
Foxes foxes(2, island.getTime());
size_t FoxSpan = 1500;
while (island.getTime() < noPlantSpan + noAnimalSpan + noFoxSpan + FoxSpan)
{
tot = grass.getTotalGrass();
tot += grass.incrementPerDay();
if (tot > grass.getMaxWeight())
tot = grass.getMaxWeight();
if (rabbits.herd != nullptr)
{
if (tot > rabbits.eat())
tot -= rabbits.eat();
else {
int die = (int)((rabbits.eat() - tot) / rabbits.herd[0].eat_day);
rabbits.herd = rabbits.Birth_Die(rabbits.herd, rabbits.size - die);
tot = 0;
}
}
size_t RabSpan = island.getTime() - noPlantSpan - noAnimalSpan;
if (rabbits.size > 0){
if ((RabSpan) % (rabbits.herd[0].reproductionTime) == 0 && RabSpan != 0)
rabbits.herd = rabbits.Birth_Die(rabbits.herd, rabbits.size + rabbits.size * rabbits.herd[0].offspring / 2);
}
if (foxes.pride != nullptr)
{
if (rabbits.size > foxes.eat())
rabbits.herd = rabbits.Birth_Die(rabbits.herd, rabbits.size - foxes.eat());
else{
int die = (int)((foxes.eat() - rabbits.size) / foxes.pride[0].eat_day);
foxes.pride = foxes.Birth_Die(foxes.pride, foxes.size - die, island.getTime());
rabbits.herd = rabbits.Birth_Die(rabbits.herd, 0);
}
}
size_t FoxSpan = island.getTime() - noPlantSpan - noAnimalSpan - noFoxSpan;
if (foxes.pride != nullptr){
if ((FoxSpan) % (foxes.pride[0].reproductionTime) == 0 && FoxSpan != 0 && foxes.size < foxes.pride[0].maxPride)
foxes.pride = foxes.Birth_Die(foxes.pride, foxes.size + foxes.size * foxes.pride[0].offspring / 2, island.getTime());
}
if (foxes.pride != nullptr){
for (size_t i = 0; i < foxes.size; i++){
// cout << foxes.pride[i].birthDay << " ";
if (island.getTime() >= foxes.pride[i].birthDay + foxes.pride[i].lifeSpan * 365)
foxes.pride = foxes.Birth_Die(foxes.pride, foxes.size - 1, island.getTime());
}
// cout << "\n";
}
grass.putTotalGrass(tot);
cout << island.getTime() << "\t" << tot << "\t" << rabbits.size << "\t" << foxes.size << "\n";
island.putTime(++day);
}
system("pause");
return 0;
} |
d743d8065c08b79e254e41617359c955da347390 | 320a98c766f78f0b964f92cf4fb9cc16a9e9a715 | /Engine/Include/Component/EffectAssist.h | dd81d5296caeeef03c034a7b6c505ee43806987d | [] | no_license | LipCoding/ProjectGOD | 058b217ba7705da3b1d38c2cf40ae67fcf462aaa | c63462d800cbbcb36d7fc0a11d909f77f287c980 | refs/heads/master | 2022-03-12T21:04:53.374351 | 2019-10-16T02:53:07 | 2019-10-16T02:53:07 | 166,417,935 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,168 | h | EffectAssist.h | #pragma once
#include "../PGEngine.h"
PG_BEGIN
class PG_DLL CEffectAssist
{
public:
enum ASSIST_TYPE
{
ASSIST_SCALE,
ASSIST_ROT,
ASSIST_FADE_IN,
ASSIST_FADE_OUT,
ASSIST_UV_ANI,
ASSIST_UV_MOVE,
ASSIST_POS,
ASSIST_END
};
enum EASE_TYPE
{
EASE_NONE,
EASE_SINE_IN,
EASE_SINE_OUT,
EASE_QUAD_IN,
EASE_QUAD_OUT,
EASE_CUBIC_IN,
EASE_CUBIC_OUT,
EASE_QUART_IN,
EASE_QUART_OUT,
EASE_QUINT_IN,
EASE_QUINT_OUT,
EASE_EXPO_IN,
EASE_EXPO_OUT,
EASE_CIRC_IN,
EASE_CIRC_OUT,
EASE_BACK_IN,
EASE_BACK_OUT,
EASE_ELASTIC_IN,
EASE_ELASTIC_OUT,
EASE_BOUNCE_IN,
EASE_BOUNCE_OUT,
EASE_END
};
enum SPRITE_TYPE
{
SPRITE_ATLAS,
SPRITE_FRAME,
SPRITE_END
};
public:
CEffectAssist();
~CEffectAssist();
public:
void SetShareBuffer(SHARECBUFFER * sharebuffer) { m_pShareBuffer = sharebuffer; }
/* Getter */
ASSIST_TYPE GetType() { return m_AssistType; }
EASE_TYPE GetEaseType() { return m_EaseType; }
SPRITE_TYPE GetSpriteType() { return m_SpriteType; }
float GetStartTime() { return m_StartTime; }
float GetEndTime() { return m_EndTime; }
float GetTime() { return m_Time; }
float GetPowerX() { return m_PowerX; }
float GetPowerY() { return m_PowerY; }
float GetPowerZ() { return m_PowerZ; }
float GetDegree() { return m_Degree; }
int GetNum() { return m_Num; }
int GetWidth() { return m_Width; }
int GetHeight() { return m_Height; }
int GetMaxX() { return m_Max_X; }
int GetMaxY() { return m_Max_Y; }
int GetRepeat() { return m_Repeat; }
float GetMoveUV_X() { return m_AniX; }
float GetMoveUV_Y() { return m_AniY; }
bool GetInifiniteCheck() { return m_InfiniteAssistCheck; }
/* Setter */
void SetSpriteType(SPRITE_TYPE type) { m_SpriteType = type; }
void SetStartCheck(bool check) { m_StartCheck = check; }
void SetStartFromMain(bool check) { m_StartFromMain = check; }
void SetStartTime(const float& start) { m_StartTime = start; }
void SetEndTime(const float& end) { m_EndTime = end; }
void SetPowerX(const float& x) { m_PowerX = x; }
void SetPowerY(const float& y) { m_PowerY = y; }
void SetPowerZ(const float& z) { m_PowerZ = z; }
void SetDegree(const float& degree) { m_Degree = degree; }
void SetNum(const int& num) { m_Num = num; }
void SetWidth(const int& width) { m_Width = width; }
void SetHeight(const int& height) { m_Height = height; }
void SetMaxX(const int& X) { m_Max_X = X; }
void SetMaxY(const int& Y) { m_Max_Y = Y; }
void SetRepeat(const int& repeat) { m_Repeat = repeat; }
void SetMoveUV_X(const float& x) { m_AniX = x; }
void SetMoveUV_Y(const float& y) { m_AniY = y; }
void SetInfiniteCheck(bool check) { m_InfiniteAssistCheck = check; }
public:
void Init(class CGameObject *object, ASSIST_TYPE AssistType, EASE_TYPE easeType = EASE_END);
void Update(class CGameObject *object, const float& deltaTime);
void UpdateForTimeLimit(class CGameObject *object, const float& deltaTime);
void UpdateForInfinite(class CGameObject *object, const float& deltaTime);
void FirstStatusSet(class CGameObject *object);
private:
void ReturnToFirstSet(class CGameObject *object);
float Calc_Ease(EASE_TYPE type, const float& startValue, const float& variation, const float& duration);
private:
/* Type */
ASSIST_TYPE m_AssistType = ASSIST_END;
EASE_TYPE m_EaseType = EASE_END;
SPRITE_TYPE m_SpriteType = SPRITE_END;
/* Common */
float m_StartTime = 0.f;
float m_EndTime = 0.f;
float m_Time = 0.f;
/* Life Time */
bool m_StartCheck = false;
bool m_StartFromMain = false;
float m_LifeTime = 0.f;
/* Infinite */
bool m_InfiniteAssistCheck = false;
/* For Pattern */
float m_StartX = 0.f;
float m_StartY = 0.f;
float m_StartZ = 0.f;
float m_PowerX = 0.f;
float m_PowerY = 0.f;
float m_PowerZ = 0.f;
/* For Fade (In / Out) */
float m_StartFadeIn = 0.f;
float m_StartFadeOut = 0.f;
float m_Degree = 0.f;
bool m_FadeEndCheck = false;
/* For UV */
class CAnimation2D *m_pAnimation = nullptr;
int m_Repeat = 0;
int m_Num = 0;
int m_Width = 0;
int m_Height = 0;
int m_Max_X = 0;
int m_Max_Y = 0;
/* Move */
float m_AniX = 0.f;
float m_AniY = 0.f;
SHARECBUFFER *m_pShareBuffer = nullptr;
};
PG_END
|
787fec143c9387a5c2bd7640f834a45db275bca5 | 29c6a2c33739db57e3764bd445be0aa1f10c91c2 | /Program-2/Program-2/wumpus-2.5/Agent.h | b664594c082364acfa49b28390676e76da198577 | [] | no_license | alanachtenberg/CSCE-420 | ec5382cdf4a30fe571a6752ceab8d50b86f70911 | 91352045bdaf8b3c2b3285020519d05c05f74f76 | refs/heads/master | 2016-09-05T17:49:01.825586 | 2015-05-04T22:09:07 | 2015-05-04T22:09:07 | 29,836,862 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,414 | h | Agent.h | // Agent.h
#ifndef AGENT_H
#define AGENT_H
#define WORLD_WIDTH 4
#include "Action.h"
#include "Percept.h"
#include "BayesianNetwork.h"
#include "Orientation.h"
#include <stack>
#include <queue>
class Agent
{
private:
struct Position{
int x;
int y;
};
BayesianNetwork network;//bayesian network to determine where pits may be
bool stenchMemory[WORLD_WIDTH][WORLD_WIDTH];//use these arrays to remember where things occured
bool breezeMemory[WORLD_WIDTH][WORLD_WIDTH];
bool exploredMemory[WORLD_WIDTH][WORLD_WIDTH];//if explored is true then we have been there, note if we have been there and havent died, cell must not be a pit or wumpus
Position position;
Orientation orientation;
bool goldFound;
bool wumpusKilled;
stack<Action> actionStack;//stack to keep track of position
queue<Action> backTrackSequence;//sequence generated when we find gold, to climb back out
void backTrack();//generate the sequence
BayesianNetwork::Nodes getNode(Position p);
void supplyEvidence();
queue<Action> actionSequence;//use to generate a sequence that moves to a sqaure
void generateActions();
void updateOrientation(Action left_right);
bool updatePosition();//we assume we are moving forward, returns true if it is in range
bool isPositionValid(Position p);
public:
Agent ();
~Agent ();
void Initialize ();
Action Process (Percept& percept);
void GameOver (int score);
};
#endif // AGENT_H
|
01fd8a57feba7967866dd7f5bebc59d6e9032014 | 6b167a083ec7dacbb7ac5e8038f52a7c35c1e0b8 | /src/lib/importex/importex.cpp | a253c9c348f5245395df4bf7e0f08062d1043a87 | [
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause"
] | permissive | niftools/nifskope | 6b706f657f3ebaaa76060bb0f1ae0837e1fded79 | 3a85ac55e65cc60abc3434cc4aaca2a5cc712eef | refs/heads/develop | 2023-09-05T18:23:17.061692 | 2018-02-23T04:16:15 | 2018-02-23T04:16:15 | 10,436,113 | 542 | 232 | NOASSERTION | 2023-09-04T08:11:35 | 2013-06-02T11:44:24 | C++ | UTF-8 | C++ | false | false | 3,325 | cpp | importex.cpp | /***** BEGIN LICENSE BLOCK *****
BSD License
Copyright (c) 2005-2015, NIF File Format Library and Tools
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the NIF File Format Library and Tools project may not be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***** END LICENCE BLOCK *****/
#include "nifskope.h"
#include "model/nifmodel.h"
#include "model/nifproxymodel.h"
#include "ui/widgets/nifview.h"
#include <QDockWidget>
#include <QFileInfo>
#include <QMenu>
#include <QModelIndex>
void exportObj( const NifModel * nif, const QModelIndex & index );
void exportCol( const NifModel * nif, QFileInfo );
void importObj( NifModel * nif, const QModelIndex & index );
void import3ds( NifModel * nif, const QModelIndex & index );
void NifSkope::fillImportExportMenus()
{
mExport->addAction( tr( "Export .OBJ" ) );
//mExport->addAction( tr( "Export .DAE" ) );
//mImport->addAction( tr( "Import .3DS" ) );
mImport->addAction( tr( "Import .OBJ" ) );
}
void NifSkope::sltImportExport( QAction * a )
{
QModelIndex index;
//Get the currently selected NiBlock index in the list or tree view
if ( dList->isVisible() ) {
if ( list->model() == proxy ) {
index = proxy->mapTo( list->currentIndex() );
} else if ( list->model() == nif ) {
index = list->currentIndex();
}
} else if ( dTree->isVisible() ) {
if ( tree->model() == proxy ) {
index = proxy->mapTo( tree->currentIndex() );
} else if ( tree->model() == nif ) {
index = tree->currentIndex();
}
}
if ( nif && nif->getVersionNumber() >= 0x14050000 ) {
mExport->setDisabled( true );
mImport->setDisabled( true );
return;
} else {
if ( nif->getUserVersion2() >= 100 )
mImport->setDisabled( true );
else
mImport->setDisabled( false );
mExport->setDisabled( false );
}
if ( a->text() == tr( "Export .OBJ" ) )
exportObj( nif, index );
else if ( a->text() == tr( "Import .OBJ" ) )
importObj( nif, index );
//else if ( a->text() == tr( "Import .3DS" ) )
// import3ds( nif, index );
//else if ( a->text() == tr( "Export .DAE" ) )
// exportCol( nif, currentFile );
}
|
48fa1bb582e64865fa45aba9ec8c8bba2ae1d5ca | 32b601fc86c18de429794e632d5f81bebaa4b21f | /Q9.cpp | 638b523731f68c48ed52f58b3a2081714a008d36 | [] | no_license | jaaniyk/reverse-string | 941dc851489c5e8bd365d9ff1751baeb019ba884 | d096ddf584c222f8eaf329643535d2fea9c86aca | refs/heads/master | 2021-01-14T01:30:51.086034 | 2020-02-27T11:43:57 | 2020-02-27T11:43:57 | 242,557,567 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 362 | cpp | Q9.cpp | #include<iostream>
using namespace std;
int main(){
int size;
cout<<"enter the size of array :";
cin>>size;
int array[size];
cout<<"Enter Array elements:";
for(int i=0; i<size; i++){
cin>>array[i];
}
cout<<"Displaying Array Elements....\n";
for(int i =0; i< size; i++){
cout <<array[i]<< " ";
}
}
|
7a5d02c4920d764804a998b73c87d7b9d8ec8cc7 | b1aff0dc98ba204e18e3a28cf806e22a69aabee9 | /src/objetos/armas/Bomba20Kilotons.cpp | f523f9180df22b03a3d3fff3b685059ac98a11b8 | [] | no_license | flpduarte/cg-tank-wars-3d | 827f697bb7e3aad09dac29f34ad9d701b2d81287 | 6c02e3c427a9eaa2f169560732a2d1df817d879c | refs/heads/master | 2021-06-17T14:33:30.030928 | 2021-01-12T17:01:33 | 2021-01-12T17:01:33 | 134,923,377 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 605 | cpp | Bomba20Kilotons.cpp | //
// Created by Felipe on 11/01/2021.
//
#include <objetos/armas/Bomba20Kilotons.h>
#include <objetos/explosoes/BolaDeFogo.h>
// constexpr precisam ser declarados no arquivo CPP para serem iniciados antes da chamada do construtor.
constexpr char Bomba20Kilotons::NOME[];
/**
* Bomba 20 kilotons: Dobro da forma do Mark II. Faz um estrago!
*/
Bomba20Kilotons::Bomba20Kilotons() :
Arma(NOME,
PRECO_POR_LOTE,
QUANTIDADE_POR_LOTE,
QUANTIDADE_INICIAL
) {}
Explosao *Bomba20Kilotons::detonar(double *epicentro) {
return BolaDeFogo::Explosao20KilotonNuke(epicentro);
} |
89eada9c7bc45dc0fc1e36cc05132c0b6c16a072 | 12d9335eaee4e7acac078fb314436e3cf0e8b853 | /userspace/apps/demo/main.cpp | 0c73277cd5808fef168b987afc7cff97e4b5be8e | [
"MIT",
"BSD-2-Clause"
] | permissive | FMMazur/skift | 385ae04878f18bf7ee8e9a8ee89758de50e79510 | 8a837fdbdcb6b64215ce1abb3fb6cc5a9881eab5 | refs/heads/main | 2023-04-21T11:48:19.648979 | 2021-05-06T19:04:20 | 2021-05-06T19:29:48 | 364,786,643 | 0 | 0 | NOASSERTION | 2021-05-06T04:42:24 | 2021-05-06T04:42:23 | null | UTF-8 | C++ | false | false | 162 | cpp | main.cpp | #include "demo/DemoApplication.h"
int main(int argc, char const *argv[])
{
UNUSED(argc);
UNUSED(argv);
DemoApplication app;
return app.run();
}
|
c03ffba5e26623ed5ec841b64878a62c6cdebb99 | 90131d07324205ce24748157e4657546ffb09688 | /Game.h | 06b71c6acc302c5d48d0b82cc14bac5287f5f15d | [] | no_license | chengpeng1999/snake | 303704388e2f59c922d7a0c1e229fc2083bda0d1 | 1f181ffd51d1b551395e3d634527f8628d24ad36 | refs/heads/main | 2023-03-10T15:24:20.858942 | 2021-03-01T10:24:21 | 2021-03-01T10:24:21 | 343,347,779 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 532 | h | Game.h | #pragma once
#include "Food.h"
#include "Snake.h"
#include<Windows.h>
class CGame
{
public:
CGame();
virtual ~CGame();
void run();
bool checkFailed();
bool checkLevel();
void changeInfo();
void drawGameArea();
void drawGameInfo();
public:
static const int KLEFT;
static const int KUP;
static const int KWIDTH;
static const int KHEIGHT;
static const int KSCORE_OFFSET;
static const int KLEVEL_OFFSET;
public:
CFood *m_pFood;
CSnake *m_pSnake;
int m_iScore;
int m_iLevel;
};
|
e5612cc70045387ec974ddf198f408353934630d | 8ca6c5fd41de1f5e5f255a7bbb8659a20850035d | /test/src/test_math.cpp | 3bcb0cc1c379926b01728597852e5c737a5f9ce8 | [
"MIT"
] | permissive | emrsmsrli/gameboi | 482bddd067dabf9cfdbf57d63ddd828e1bac62c7 | 6448722529bc64184e30a945f0e5ec4203265e10 | refs/heads/master | 2021-08-15T00:15:11.262161 | 2021-08-04T14:37:58 | 2021-08-04T14:37:58 | 201,642,246 | 24 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,504 | cpp | test_math.cpp | #include <gtest/gtest.h>
#include "gameboy/util/mathutil.h"
TEST(math, mask_test) {
ASSERT_TRUE(gameboy::mask::test(0x100, 0x100));
ASSERT_FALSE(gameboy::mask::test(0x100, 0x01));
ASSERT_TRUE(gameboy::mask::test(0xFC, 0x0C));
ASSERT_TRUE(gameboy::mask::test(0x111, 0x110));
}
TEST(math, bit_test) {
ASSERT_FALSE(gameboy::bit::test(0x0, 7));
ASSERT_TRUE(gameboy::bit::test(0xFC, 7));
ASSERT_TRUE(gameboy::bit::test(0xFC, 6));
ASSERT_FALSE(gameboy::bit::test(0xFC, 0));
ASSERT_FALSE(gameboy::bit::test(0xFC, 1));
}
TEST(math, bit_reset) {
ASSERT_EQ(gameboy::bit::reset(0x01, 0), 0x0);
ASSERT_EQ(gameboy::bit::reset(0xFC, 7), 0x7C);
ASSERT_EQ(gameboy::bit::reset(0xFC, 6), 0xBC);
ASSERT_EQ(gameboy::bit::reset(0xFC, 0), 0xFC);
ASSERT_EQ(gameboy::bit::reset(0xFC, 1), 0xFC);
}
TEST(math, extract_bit) {
ASSERT_EQ(gameboy::bit::extract(0x0F, 0), 1);
ASSERT_EQ(gameboy::bit::extract(0x0F, 1), 1);
ASSERT_EQ(gameboy::bit::extract(0x0F, 2), 1);
ASSERT_EQ(gameboy::bit::extract(0x0F, 3), 1);
ASSERT_EQ(gameboy::bit::extract(0x0F, 4), 0);
ASSERT_EQ(gameboy::bit::extract(0x0F, 5), 0);
ASSERT_EQ(gameboy::bit::extract(0x0F, 6), 0);
ASSERT_EQ(gameboy::bit::extract(0x0F, 7), 0);
}
TEST(math, bit_flip) {
ASSERT_EQ(gameboy::bit::flip(0b1001, 0), 0b1000);
ASSERT_EQ(gameboy::bit::flip(0b1001, 1), 0b1011);
ASSERT_EQ(gameboy::bit::flip(0b1001, 2), 0b1101);
ASSERT_EQ(gameboy::bit::flip(0b1001, 3), 0b0001);
}
|
8c743b6e3f70b155a24600c249264b8ae5e7acb5 | f838cf744d486aab379767771c1ab233842c187c | /Hackerrank/NWD i NWW/main.cpp | 297e27b4e0fbeac4587ae6b363d86461451a0b71 | [] | no_license | Busiu/ProblemSolving | 574ea488a32a4037fd351330edfb7381b5301eef | c64455ce969d7993cd5049183f6ae7ba3bd92f2a | refs/heads/master | 2021-02-13T22:55:02.399346 | 2020-03-03T21:48:16 | 2020-03-03T21:48:16 | 244,742,252 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 468 | cpp | main.cpp | #include <iostream>
using namespace std;
int main()
{
long long int n, a, b, c, d, NWD;
cin >> n;
for(int i=0; i<n; i++)
{
cin >> a >> b;
c = a;
d = b;
while(a!=0 && b!=0)
{
if(a>b)
a%=b;
else
b%=a;
}
if(a>0)
NWD = a;
else
NWD = b;
cout << NWD << " " << c/NWD*d << endl;
}
return 0;
}
|
7d8b30cb12c5f179561d12b3db9f1880b929bab6 | b367fe5f0c2c50846b002b59472c50453e1629bc | /xbox_leak_may_2020/xbox trunk/xbox/private/test/ui/tools/inc/memoryunit.h | 52f6d46920aa9bad8d1647c09fa27fa42d5cb1ca | [] | no_license | sgzwiz/xbox_leak_may_2020 | 11b441502a659c8da8a1aa199f89f6236dd59325 | fd00b4b3b2abb1ea6ef9ac64b755419741a3af00 | refs/heads/master | 2022-12-23T16:14:54.706755 | 2020-09-27T18:24:48 | 2020-09-27T18:24:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,694 | h | memoryunit.h | /*****************************************************
*** memoryunit.h
***
*** Header file for our Memory Unit class.
*** This class will contain functions and information
*** pertaining to an Xbox Memory Unit
***
*** by James N. Helm
*** March 28th, 2001
***
*****************************************************/
#ifndef _MEMORYUNIT_H_
#define _MEMORYUNIT_H_
#include "memoryarea.h"
class CMemoryUnit : public CMemoryArea
{
public:
// Contructor and Destructors
CMemoryUnit();
~CMemoryUnit();
// Public Methods
HRESULT Format( BOOL bMount=FALSE ); // Format the Memory Unit
HRESULT Unformat(); // Unformat the Memory Unit
HRESULT Mount( BOOL bAsGameTitle=FALSE ); // Mount the Memory Unit
HRESULT Unmount(); // Unmount the Memory Unit
HRESULT Name( WCHAR* wpszName ); // Name the Memory Unit
HRESULT RefreshName(); // Refresh the name of the Memory Unit (it could change)
HRESULT GetName( WCHAR* wpszNameBuffer, // Get the name of the MU
unsigned int uiBufSize );
WCHAR* GetNamePtr() { return m_pwszMUName; }; // Get the name pointer of the MU
DWORD GetFreeBlocks(); // Get the number of blocks that are free on the MU
DWORD GetTotalBlocks(); // Get the total number of blocks on the MU
DWORD GetPort() { return m_dwPort; }; // Get the port of the MU
DWORD GetSlot() { return m_dwSlot; }; // Get the slot of the MU
BOOL IsFormatted() { return m_bFormatted; }; // Returns the format state of the MU
BOOL IsMounted() { return m_bMounted; }; // Returns the mount state of the MU
BOOL IsNamed(); // Used to determine if the MU is named
HRESULT SetPortSlot( DWORD dwPort, // Set the port and the slot this MU will be on
DWORD dwSlot );
HRESULT MapUDataToOrigLoc(); // Map the UDATA drive back to it's original location
HRESULT MapUDataToTitleID( char* pszTitleID ); // Map the UDATA drive letter to the specified Title ID and Mount the MU
HRESULT MapUDataToTitleID( WCHAR* pwszTitleID ); // Map the UDATA drive letter to the specified Title ID and Mount the MU
HRESULT MapUDataToTitleID( DWORD dwTitleID ); // Map the UDATA drive letter to the specified Title ID and Mount the MU
unsigned int GetIndex(); // Get the Index of the current MU
private:
// char m_cDriveLetter; // The drive letter the MU is mounted on
WCHAR* m_pwszMUName; // The name of the MU
BOOL m_bMounted; // When the MU is mounted, this is set to TRUE
BOOL m_bFormatted; // Used to determine if the MU is formatted
DWORD m_dwPort; // The port the MU is on (XDEVICE_PORT0 through XDEVICE_PORT3)
DWORD m_dwSlot; // The slot of the Controller the MU is in (XDEVICE_TOP_SLOT or XDEVICE_BOTTOM_SLOT)
// Private Methods
HRESULT ProcessMountedMU(); // Process a mounted MU (Get the name, etc)
};
#define MEMORY_UNIT_NAME_PATTERN L"Memory Unit"
#endif // _MEMORYUNIT_H_ |
7c0742b43192163bd39682f4bbec3fb966e18b48 | 010905f19364465e606716910ee03a85eefea219 | /TMW2017/src/OI.h | 65a8accc7d7f83cb36afd1fa57ef4bd2c611b746 | [] | no_license | FRCTeam16/TMW2017 | 6370768af75f5c47483620db36ac705c1a7506c6 | f9b57e1f7345aa0e2ad6bd9737bba142af26f69c | refs/heads/master | 2021-07-06T06:29:45.177099 | 2017-05-09T00:00:46 | 2017-05-09T00:00:46 | 80,792,469 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,953 | h | OI.h | // RobotBuilder Version: 2.0
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// C++ from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in the future.
#ifndef OI_H
#define OI_H
#include "WPILib.h"
#include "BSButton.h"
class OI {
private:
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
std::shared_ptr<Joystick> gamepad;
std::shared_ptr<Joystick> driverRight;
std::shared_ptr<Joystick> driverLeft;
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
double scaledRadians(double radians);
public:
OI();
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=PROTOTYPES
std::shared_ptr<Joystick> getDriverLeft();
std::shared_ptr<Joystick> getDriverRight();
std::shared_ptr<Joystick> getGamepad();
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=PROTOTYPES
std::shared_ptr<BSButton> GPX;
std::shared_ptr<BSButton> GPY;
std::shared_ptr<BSButton> GPB;
std::shared_ptr<BSButton> GPA;
std::shared_ptr<BSButton> GPLB;
std::shared_ptr<BSButton> GPRB;
std::shared_ptr<BSButton> GPBack;
std::shared_ptr<BSButton> GPStart;
std::shared_ptr<BSButton> DL1;
std::shared_ptr<BSButton> DL2;
std::shared_ptr<BSButton> DL3;
std::shared_ptr<BSButton> DL4;
std::shared_ptr<BSButton> DL5;
std::shared_ptr<BSButton> DL6;
std::shared_ptr<BSButton> DL7;
std::shared_ptr<BSButton> DL8;
std::shared_ptr<BSButton> DL9;
std::shared_ptr<BSButton> DL10;
std::shared_ptr<BSButton> DL11;
std::shared_ptr<BSButton> DL12;
std::shared_ptr<BSButton> DR1;
std::shared_ptr<BSButton> DR2;
std::shared_ptr<BSButton> DR3;
std::shared_ptr<BSButton> DR4;
std::shared_ptr<BSButton> DR5;
std::shared_ptr<BSButton> DR6;
std::shared_ptr<BSButton> DR7;
std::shared_ptr<BSButton> DR8;
std::shared_ptr<BSButton> DR9;
std::shared_ptr<BSButton> DR10;
std::shared_ptr<BSButton> DR11;
std::shared_ptr<BSButton> DR12;
enum DPad {
kUnpressed = -1,
kUp = 0,
kUpRight = 45,
kRight = 90,
kDownRight = 135,
kDown = 180,
kDownLeft = 225,
kLeft = 270,
kUpLeft = 315,
kUnknown = 999
};
DPad GetGamepadDPad();
double GetJoystickTwist(double threshold = 0.1);
double GetJoystickX(double threshold = 0.1);
double GetJoystickY(double threshold = 0.1);
double GetGamepadLeftStick();
double GetGamepadRightStick();
double GetGamepadLT();
double GetGamepadRT();
void SetGamepadLeftRumble(double rumble);
void SetGamepadRightRumble(double rumble);
void SetGamepadBothRumble(double rumble);
double getLeftJoystickXRadians();
double getScaledJoystickRadians();
};
#endif
|
a64e3cc969ce5bc21996d457c32fcb991b019f97 | ccf3050509bb661dd2cfcce5fc8bb5817615b449 | /src/chesspiece.cpp | b00a2b07013f59d29a772efb2328b9031fab2baa | [] | no_license | smolck/Qt5ChessGame | 63c01309e60535f75ded736626f4fec63a9bf498 | 6396c9b79b32bea13c03de56cbc92561a524ba53 | refs/heads/master | 2020-05-26T17:04:58.135304 | 2019-06-26T16:51:31 | 2019-06-26T16:51:31 | 188,312,427 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,894 | cpp | chesspiece.cpp | #include "chesspiece.h"
#include "validatepiecemove.h"
#include <QList>
#include <memory>
#include <QProcess>
ChessPiece::ChessPiece(QGraphicsItem *parent) : QGraphicsPixmapItem(parent), dragOver(false)
{
setAcceptDrops(true);
}
void ChessPiece::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
// Set the previous position of the chesspiece equal to its current position
// To prepare for it to be moved
this->setPreviousPos(this->pos());
Q_UNUSED(event)
}
void ChessPiece::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
// Move the pawn with the cursor as it drags the pawn
QPointF lastPoint = mapToScene(event->lastPos());
this->setPos(lastPoint.x() + -30, lastPoint.y() + -30);
}
// TODO: Handle capturing of pieces
void ChessPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event)
QList<QGraphicsItem *> colliders = this->collidingItems();
// Handle capturing pieces
if (colliders.length() > 0) {
foreach(QGraphicsItem * collider, colliders) {
QGraphicsPixmapItem *target = dynamic_cast<QGraphicsPixmapItem*>(collider);
if (target)
{
// TODO: Check if the QImage of targeted piece is equal to a certain piece, then verify pawn, then
// move the piece
if (this->m_Name == "Pawn" || this->m_Name == "B_Pawn") {
if (ValidatePieceMove::verifyPawnCapture(this, static_cast<ChessPiece*>(target))) {
// Move pawn, remove target, set variables
this->setPos(target->pos());
this->hasLeftStart = true;
this->getPieceScene()->removeItem(target);
this->setPreviousPos(this->pos());
return;
} else {
this->setPos(this->getPreviousPos());
return;
}
}
this->setPos(target->pos());
this->hasLeftStart = true;
this->getPieceScene()->removeItem(target);
qDebug() << "Removed item from board";
this->m_PreviousPos = this->pos();
return;
}
}
// Handle piece movement (one collider means it is a square in this case)
if (colliders.length() == 1) {
// Handle pawns
if (this->m_Name == "Pawn" || this->m_Name == "B_Pawn") {
// If pawn's move is valid, move it to new pos and return
if (ValidatePieceMove::verifyPawn(this, colliders[0])) {
this->setPos(colliders[0]->pos());
this->m_PreviousPos = this->pos();
if (!hasLeftStart) {
hasLeftStart = true;
}
return;
// Else, move it back where it was
} else {
this->setPos(m_PreviousPos);
return;
}
// Handle rooks
} else if (this->m_Name == "Rook" || this->m_Name == "B_Rook") {
// If rook's move is valid, move it to new pos and return
if (ValidatePieceMove::verifyRook(this, colliders)) {
this->setPos(colliders[0]->pos());
this->m_PreviousPos = this->pos();
if (!hasLeftStart) {
hasLeftStart = true;
}
return;
// Else, move it back where it was
} else {
this->setPos(m_PreviousPos);
return;
}
// Handle bishops
} else if (this->m_Name == "Bishop" || this->m_Name == "B_Bishop") {
// If bishop's move is valid, move it to new pos and return
if (ValidatePieceMove::verifyBishop(this, colliders)) {
this->setPos(colliders[0]->pos());
this->m_PreviousPos = this->pos();
if (!hasLeftStart) {
hasLeftStart = true;
}
return;
// Else, move it back where it was
} else {
this->setPos(m_PreviousPos);
return;
}
// Handle knights
} else if (this->m_Name == "Knight" || this->m_Name == "B_Knight") {
// If knight's move is valid, move it to new pos and return
if (ValidatePieceMove::verifyKnight(this, colliders)) {
this->setPos(colliders[0]->pos());
this->m_PreviousPos = this->pos();
if (!hasLeftStart) {
hasLeftStart = true;
}
return;
// Else, move it back where it was
} else {
this->setPos(m_PreviousPos);
return;
}
// Handle kings
} else if (this->m_Name == "King" || this->m_Name == "B_King") {
// If knight's move is valid, move it to new pos and return
if (ValidatePieceMove::verifyKing(this, colliders)) {
this->setPos(colliders[0]->pos());
this->m_PreviousPos = this->pos();
if(!hasLeftStart) {
hasLeftStart = true;
}
return;
// Else, move it back where it was
} else {
this->setPos(m_PreviousPos);
return;
}
// Handle queens
} else if (this->m_Name == "Queen" || this->m_Name == "B_Queen") {
// If queen's move is valid, move it to new pos and return
if (ValidatePieceMove::verifyQueen(this, colliders)) {
this->setPos(colliders[0]->pos());
this->m_PreviousPos = this->pos();
if (!hasLeftStart) {
hasLeftStart = true;
}
return;
// Else, move it back where it was
} else {
this->setPos(m_PreviousPos);
return;
}
}
// Move piece back to its previous position if it is colliding
// with more than one piece/square
} else {
this->setPos(this->m_PreviousPos);
}
}
}
|
8e3ad1d5b51ea50d54460bab0659ac9f4a89a929 | 31d6b871bc2c07542d770ea42199a36870be9224 | /temp/server/nodes.h | c18a41969e0e5da0cbad872c648e63f5eacda725 | [] | no_license | rohitdureja/Smart-Sensing | 6b2543373bc2f66d6052d4780ff207883ba5b0e3 | cd39e014e6f031bb6ddfce029d91cb5d99e6595b | refs/heads/master | 2020-04-24T14:27:16.502842 | 2014-05-11T04:49:00 | 2014-05-11T04:49:00 | 25,706,229 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,331 | h | nodes.h | #ifndef NODES_H_
#define NODES_H_
#define _(x)
#include <queue>
#include <string>
#include <map>
#include <list>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
using namespace std;
int extract_key(struct sockaddr_in addr);
class Actuator {
struct sockaddr_in address;
int key;
bool status;
timer_t tid;
time_t event_time;
struct sigaction timeup;
public:
Actuator(){};
Actuator(struct sockaddr_in addr);
void set_status(int time_out);
void reset();
bool get_status();
double get_time();
struct sockaddr_in get_addr();
static void TimerHandler(int);
timer_t SetTimer(int);
};
class Sensor {
int key;
struct sockaddr_in address;
list<int> N_keys; //Keys of the neighbouring nodes
int act_key; //key of the actuator where the actuator is stored
public:
Sensor(){};
Sensor(sockaddr_in addr);
void set_self();
void set_N(int time);
int get_key();
int get_act();
struct sockaddr_in get_addr();
void add_N(int n_key);
void add_act(int a_key);
};
class Server_Main {
public:
map<int,Sensor> S_map;
map<int,Actuator> A_map;
queue<frame> send_queue;
queue<frame> recv_queue;
Server_Main(){};
void set_localize();
};
#endif
|
432c9ee0883957ef7cce4709a8facf170a5dba31 | 62c7cb1e664abecc1050ec912a3e424277b07654 | /RocketAnalyticsLib/src/BinaryReader.cpp | d55efcf8ed8ebb7f48be7b2e6860be5949b82264 | [
"MIT"
] | permissive | michaeldoylecs/RocketAnalytics | 460a6b17790e23dd87aad8e53f43d7f4a2fcb371 | 24ad101fd1adc123ea2760930de9144575dbd2a6 | refs/heads/master | 2020-09-04T10:11:03.987578 | 2018-09-01T22:20:24 | 2018-09-01T22:20:24 | 94,410,186 | 2 | 0 | null | 2018-06-15T05:09:48 | 2017-06-15T07:02:31 | C++ | UTF-8 | C++ | false | false | 6,148 | cpp | BinaryReader.cpp | /******************************************************************************
* Author: Michael Doyle
* Date: 8/13/17
* File: BinaryReader.cpp
*****************************************************************************/
#include "../include/BinaryReader.hpp"
#include <array>
#include <cstring>
#include <fstream>
#include <iostream>
namespace rocketanalytics {
BinaryReader::BinaryReader(const std::string& filepath) {
try {
byte_position = 0;
bit_position = 0;
read_file(filepath);
}
catch(const std::runtime_error &e) {
throw;
}
}
void BinaryReader::read_file(const std::string& filepath) {
std::ifstream file_stream(filepath, std::ios::binary | std::ios::in);
if (file_stream.is_open()) {
auto f_size = file_size(file_stream);
file_bytes.resize(f_size);
file_stream.read(reinterpret_cast<char*>(file_bytes.data()), f_size); // NOLINT
file_stream.close();
}
else {
throw std::runtime_error("Failed to open file " + filepath);
}
}
size_t BinaryReader::file_size(std::ifstream &file_stream) {
size_t file_start = file_stream.tellg();
file_stream.seekg(0, std::ios::end);
size_t file_size = file_stream.tellg();
file_stream.seekg(file_start, std::ios::beg);
return file_size;
}
std::vector<Byte> BinaryReader::read_bytes(int length) {
try {
std::vector<Byte> list_of_bytes;
list_of_bytes.resize(length);
for (int i = 0; i < length; ++i) {
list_of_bytes.at(i) = read_aligned_byte();
}
return list_of_bytes;
}
catch(std::runtime_error &e){
std::cerr << "Exception caught: " << e.what() << std::endl;
return std::vector<Byte>();
}
}
float BinaryReader::read_aligned_float() {
try {
constexpr int FLOAT_SIZE = sizeof(float);
static_assert(FLOAT_SIZE == 4,
"BinaryReader::read_aligned_float() requires 'float' to be 4 bytes");
std::array<Byte, FLOAT_SIZE> list_of_bytes;
for (int index = 0; index < FLOAT_SIZE; index++) {
list_of_bytes.at(index) = read_aligned_byte();
}
return bytes_to_float(list_of_bytes);
}
catch (std::runtime_error &e) {
std::cerr << "Exception caught: " << e.what() << std::endl;
return 0;
}
}
float BinaryReader::bytes_to_float(std::array<Byte, 4> bytes) {
static_assert(sizeof(float) == 4,
"BinaryReader::bytes_to_float() requires 'float' to be 4 bytes");
float combined_value = 0.0f;
memcpy(&combined_value, &bytes, sizeof(combined_value)); // NOLINT
return combined_value;
}
uint8_t BinaryReader::read_aligned_uint8() {
try {
Byte next_byte = read_aligned_byte();
uint8_t read_value = std::to_integer<uint32_t>(next_byte.value());
return read_value;
}
catch (const std::runtime_error &e) {
std::cerr << e.what() << std::endl;
return 0;
}
}
uint32_t BinaryReader::read_aligned_uint32() {
try {
const int BYTES_TO_READ = 4;
std::array<Byte, BYTES_TO_READ> list_of_bytes;
for (int index = 0; index < BYTES_TO_READ; index++) {
list_of_bytes.at(index) = read_aligned_byte();
}
std::uint32_t read_value = bytes_to_uint32(list_of_bytes);
return read_value;
}
catch(const std::runtime_error &e){
std::cerr << e.what() << std::endl;
throw e;
}
}
std::uint32_t BinaryReader::bytes_to_uint32(std::array<Byte, 4> bytes) {
static_assert(sizeof(std::uint32_t) == 4,
"BinaryReader::bytes_to_uint32() requires 'std::uin32_t' to be 4 bytes");
std::uint32_t combined_value = 0;
memcpy(&combined_value, &bytes, sizeof(combined_value)); // NOLINT
return combined_value;
}
uint64_t BinaryReader::read_aligned_uint64() {
try {
const int AMOUNT_OF_BYTES_TO_READ = 8;
std::array<Byte, AMOUNT_OF_BYTES_TO_READ> list_of_bytes;
for (int index = 0; index < AMOUNT_OF_BYTES_TO_READ; index++) {
list_of_bytes.at(index) = read_aligned_byte();
}
uint64_t read_value = bytes_to_uint64(list_of_bytes);
return read_value;
}
catch (const std::runtime_error &e) {
std::cerr << e.what() << std::endl;
return 0;
}
}
uint64_t BinaryReader::bytes_to_uint64(std::array<Byte, 8> bytes) {
static_assert(sizeof(uint64_t),
"BinaryReader::byte_to_uint64() requires 'uint64_t' to be 8 bytes");
uint64_t combined_value = 0;
memcpy(&combined_value, &bytes, sizeof(combined_value)); // NOLINT
return combined_value;
}
std::string BinaryReader::read_length_prefixed_string() {
std::string string_value;
std::uint32_t str_length = read_aligned_uint32();
string_value = read_string_of_n_length(str_length);
return string_value.substr(0, str_length - 1);
}
std::string BinaryReader::read_string_of_n_length(std::uint32_t length) {
try {
std::string read_string;
for (std::uint32_t i = 0; i < length; i++) {
Byte next_byte = read_aligned_byte();
auto byte_value = std::to_integer<std::uint8_t>(next_byte.value());
char next_char;
memcpy(&next_char, &byte_value, sizeof(next_char));
read_string += next_char;
}
return read_string;
}
catch (const std::runtime_error &e) {
throw e;
}
}
Byte BinaryReader::read_aligned_byte() {
if (bit_position != 0) {
throw std::runtime_error(
"Attempted to read byte with bit pointer misaligned"
);
}
try {
Byte next_byte = file_bytes.at(byte_position);
increment_byte_position();
return next_byte;
} catch (std::out_of_range& e) {
throw e;
}
}
void BinaryReader::increment_byte_position() {
byte_position++;
}
void BinaryReader::increment_bit_position() {
bit_position++;
if (bit_position > 7) {
bit_position = 0;
increment_byte_position();
}
}
size_t BinaryReader::size() {
return file_bytes.size();
}
void BinaryReader::close() {
file_bytes.clear();
byte_position = 0;
bit_position = 0;
}
} // namespace rocketanalytics
|
c11024f6e272d0e7655a0b5e61602272e0808b0f | d30f2520323cd6bdbd02b7d11c87ddcb7daf6085 | /c++/groupAnagrams.cc | 9fd7a306e6c0145e8a38b99f7d500d6c587180d0 | [] | no_license | liuxieric123/data-structure-and-algorithm | 90a2769f59843caf04331caf36387290c9bf8ea5 | 47253fdbbb242cf9fd7a0254fcb3ffbdbd44656e | refs/heads/master | 2020-03-26T19:44:59.878027 | 2020-01-17T02:44:33 | 2020-01-17T02:44:33 | 145,284,198 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,710 | cc | groupAnagrams.cc | class Solution {
public:
vector<vector<string>> groupAnagrams(vector<string>& strs) {
int size = strs.size();
if (size == 0) return vector<vector<string>> {};
unordered_map<string, vector<string>> key_vector;
for (auto str: strs) {
string tmp = getKey(str);
if (key_vector.find(tmp) == key_vector.end()) {
vector<string> vec_string{str};
key_vector[tmp] = vec_string;
} else {
key_vector[tmp].push_back(str);
}
}
vector<vector<string>> ret;
for (auto pair: key_vector) {
ret.push_back(pair.second);
}
return ret;
}
string getKey(string str) {
int count[26];
for (int i = 0; i < 26; ++i) {
count[i] = 0;
}
for (auto c : str) {
++count[c-'a'];
}
string tmp;
for (int i = 0; i < 26; ++i) {
tmp.push_back(count[i]);
}
return tmp;
}
vector<vector<string>> groupAnagrams1(vector<string>& strs) {
int size = strs.size();
if (size == 0) return vector<vector<string>> {};
unordered_map<string, vector<string>> key_vector;
for (auto str: strs) {
string tmp = str;
sort(tmp.begin(), tmp.end());
if (key_vector.find(tmp) == key_vector.end()) {
key_vector[tmp] = vector<string>{str};
} else {
key_vector[tmp].push_back(str);
}
}
vector<vector<string>> ret;
for (auto pair: key_vector) {
ret.push_back(pair.second);
}
return ret;
}
}; |
56c38c34f2fee18c6521c6b7b68e1b65d15d4b40 | 36183993b144b873d4d53e7b0f0dfebedcb77730 | /GameDevelopment/3D Game Engine Architecture/Linux/MagicSoftware/WildMagic3/Source/SceneGraph/Wm3Light.h | 152d7e3be421f8024e3d9a95f7e92ae3686b3b54 | [] | no_license | alecnunn/bookresources | b95bf62dda3eb9b0ba0fb4e56025c5c7b6d605c0 | 4562f6430af5afffde790c42d0f3a33176d8003b | refs/heads/master | 2020-04-12T22:28:54.275703 | 2018-12-22T09:00:31 | 2018-12-22T09:00:31 | 162,790,540 | 20 | 14 | null | null | null | null | UTF-8 | C++ | false | false | 3,053 | h | Wm3Light.h | // Magic Software, Inc.
// http://www.magic-software.com
// http://www.wild-magic.com
// Copyright (c) 2004. All Rights Reserved
//
// The Wild Magic Library (WM3) source code is supplied under the terms of
// the license agreement http://www.wild-magic.com/License/WildMagic3.pdf and
// may not be copied or disclosed except in accordance with the terms of that
// agreement.
#ifndef WM3LIGHT_H
#define WM3LIGHT_H
#include "Wm3Spatial.h"
#include "Wm3ColorRGBA.h"
namespace Wm3
{
class WM3_ITEM Light : public Spatial
{
WM3_DECLARE_RTTI;
WM3_DECLARE_NAME_ID;
WM3_DECLARE_STREAM;
public:
enum // Type
{
LT_AMBIENT,
LT_DIRECTIONAL,
LT_POINT,
LT_SPOT,
LT_QUANTITY
};
Light (int iType = LT_AMBIENT);
virtual ~Light ();
// light frame (local coordinates)
// default location E = (0,0,0)
// default direction D = (0,0,-1)
// default up U = (0,1,0)
// default right R = (1,0,0)
void SetFrame (const Vector3f& rkLocation, const Vector3f& rkDVector,
const Vector3f& rkUVector, const Vector3f& rkRVector);
void SetFrame (const Vector3f& rkLocation, const Matrix3f& rkAxes);
void SetLocation (const Vector3f& rkLocation);
void SetAxes (const Vector3f& rkDVector, const Vector3f& rkUVector,
const Vector3f& rkRVector);
void SetAxes (const Matrix3f& rkAxes);
Vector3f GetLocation () const; // Local.Translate
Vector3f GetDVector () const; // Local.Rotate column 0
Vector3f GetUVector () const; // Local.Rotate column 1
Vector3f GetRVector () const; // Local.Rotate column 2
// For directional lights. The direction vector must be unit length.
// The up vector and left vector are generated automatically.
void SetDirection (const Vector3f& rkDirection);
// light frame (world coordinates)
Vector3f GetWorldLocation () const; // World.Translate
Vector3f GetWorldDVector () const; // World.Rotate column 0
Vector3f GetWorldUVector () const; // World.Rotate column 1
Vector3f GetWorldRVector () const; // World.Rotate column 2
int Type; // default: LT_AMBIENT
ColorRGBA Ambient; // default: ColorRGBA(0,0,0,1)
ColorRGBA Diffuse; // default: ColorRGBA(0,0,0,1)
ColorRGBA Specular; // default: ColorRGBA(0,0,0,1)
float Intensity; // default: 1
float Constant; // default: 1
float Linear; // default: 0
float Quadratic; // default: 0
bool Attenuate; // default: false
bool On; // default: true
// spot light parameters (valid only when Type = LT_SPOT)
float Exponent;
float Angle;
private:
// updates
virtual void UpdateWorldBound ();
void OnFrameChange ();
// base class functions not supported
virtual void UpdateState (TStack<GlobalState*>*, TStack<Light*>*) { /**/ }
virtual void Draw (Renderer&, bool) { /**/ }
};
WM3_REGISTER_STREAM(Light);
typedef Pointer<Light> LightPtr;
#include "Wm3Light.inl"
}
#endif
|
42d2d52d89a52c0bfa72a309bc440fe6a337a2e3 | b26d705f81aff8b2ad6c8e5a975895b1752c90ed | /cpp/1061. 按字典序排列最小的等效字符串.cpp | a343bef18024dbabd33e2ca26fbca6b79eb49387 | [] | no_license | zianed/leetcode | 61623b1538185d5c23ac2dbb97e230f46dc4f47e | ee143656e218ffea2f15ae7425b4feb29550adb6 | refs/heads/master | 2021-07-23T16:54:32.067235 | 2020-09-20T03:33:58 | 2020-09-20T03:33:58 | 217,878,948 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,213 | cpp | 1061. 按字典序排列最小的等效字符串.cpp | /**
1061. 按字典序排列最小的等效字符串
给出长度相同的两个字符串:A 和 B,其中 A[i] 和 B[i] 是一组等价字符。举个例子,如果 A = "abc" 且 B = "cde",那么就有 'a' == 'c', 'b' == 'd', 'c' == 'e'。
等价字符遵循任何等价关系的一般规则:
自反性:'a' == 'a'
对称性:'a' == 'b' 则必定有 'b' == 'a'
传递性:'a' == 'b' 且 'b' == 'c' 就表明 'a' == 'c'
例如,A 和 B 的等价信息和之前的例子一样,那么 S = "eed", "acd" 或 "aab",这三个字符串都是等价的,而 "aab" 是 S 的按字典序最小的等价字符串
利用 A 和 B 的等价信息,找出并返回 S 的按字典序排列最小的等价字符串。
示例 1:
输入:A = "parker", B = "morris", S = "parser"
输出:"makkek"
解释:根据 A 和 B 中的等价信息,我们可以将这些字符分为 [m,p], [a,o], [k,r,s], [e,i] 共 4 组。每组中的字符都是等价的,并按字典序排列。所以答案是 "makkek"。
示例 2:
输入:A = "hello", B = "world", S = "hold"
输出:"hdld"
解释:根据 A 和 B 中的等价信息,我们可以将这些字符分为 [h,w], [d,e,o], [l,r] 共 3 组。所以只有 S 中的第二个字符 'o' 变成 'd',最后答案为 "hdld"。
示例 3:
输入:A = "leetcode", B = "programs", S = "sourcecode"
输出:"aauaaaaada"
解释:我们可以把 A 和 B 中的等价字符分为 [a,o,e,r,s,c], [l,p], [g,t] 和 [d,m] 共 4 组,因此 S 中除了 'u' 和 'd' 之外的所有字母都转化成了 'a',最后答案为 "aauaaaaada"。
提示:
字符串 A,B 和 S 仅有从 'a' 到 'z' 的小写英文字母组成。
字符串 A,B 和 S 的长度在 1 到 1000 之间。
字符串 A 和 B 长度相同。
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/lexicographically-smallest-equivalent-string
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
**/
class Solution {
public:
string smallestEquivalentString(string A, string B, string S) {
map<char, char> cMap;
int len = A.size();
for (int i = 0; i < len; i++) {
auto itA = cMap.find(A[i]);
char vA = A[i];
if (itA != cMap.end()) {
vA = itA->second;
}
auto itB = cMap.find(B[i]);
char vB = B[i];
if (itB != cMap.end()) {
vB = itB->second;
}
// 找到最小值
char low = min(vA, min(vB, min(A[i], B[i])));
for (auto it = cMap.begin(); it != cMap.end(); it++) {
// 如果是其中一个都设置为最小值
if (it->second == vA || it->second == vB || it->second == A[i] || it->second == B[i]) {
it->second = low;
}
}
cMap[vA] = low;
cMap[vB] = low;
}
int sSize = S.size();
for (int i = 0; i < sSize; i++) {
if (cMap.find(S[i]) != cMap.end()) {
S[i] = cMap[S[i]];
}
}
return S;
}
};
|
be264fe279048db922c4ea3c9110185274fe8ceb | e5b52bbff31d20e0bc5af9b0126d0cc0ab005d5c | /Kernel/general_assembly.hpp | 88c7b90266195fa51cd8e4a42ae55676e2cb1402 | [] | no_license | MinusGix/MinuxNotOS | 2bcd76524717d96e247f299efd58e8a07cb4fc1c | 901e0493d14ed85a977dc07904e187fea2f31031 | refs/heads/master | 2020-08-29T04:40:42.588784 | 2019-10-31T10:50:42 | 2019-10-31T10:50:42 | 217,930,460 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 109 | hpp | general_assembly.hpp | #ifndef INCLUDE_GENERAL_ASSEMBLY_H
#define INCLUDE_GENERAL_ASSEMBLY_H
#include "../Include/stdint.h"
#endif |
8343f7714a1de4194819bd4dd96906322fc3a15d | 211c23bbb8914423134cca963328fc13906940d3 | /clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp | 3a670509ec2e204c980c7f4a1628205b504d5e39 | [
"Apache-2.0",
"LLVM-exception",
"NCSA"
] | permissive | polymage-labs/mlirx | 465d8486464858f3b898fa7ffd9e3761b557fd11 | d169855eb40142019af5d40162e673f1edeb2363 | refs/heads/master | 2022-12-19T01:00:02.265620 | 2022-11-12T01:05:22 | 2022-11-13T07:09:56 | 238,610,630 | 41 | 8 | null | 2022-12-06T15:16:05 | 2020-02-06T04:54:21 | null | UTF-8 | C++ | false | false | 4,996 | cpp | ContainerDataPointerCheck.cpp | //===--- ContainerDataPointerCheck.cpp - clang-tidy -----------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "ContainerDataPointerCheck.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/StringRef.h"
using namespace clang::ast_matchers;
namespace clang {
namespace tidy {
namespace readability {
ContainerDataPointerCheck::ContainerDataPointerCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
void ContainerDataPointerCheck::registerMatchers(MatchFinder *Finder) {
const auto Record =
cxxRecordDecl(
isSameOrDerivedFrom(
namedDecl(
has(cxxMethodDecl(isPublic(), hasName("data")).bind("data")))
.bind("container")))
.bind("record");
const auto NonTemplateContainerType =
qualType(hasUnqualifiedDesugaredType(recordType(hasDeclaration(Record))));
const auto TemplateContainerType =
qualType(hasUnqualifiedDesugaredType(templateSpecializationType(
hasDeclaration(classTemplateDecl(has(Record))))));
const auto Container =
qualType(anyOf(NonTemplateContainerType, TemplateContainerType));
Finder->addMatcher(
unaryOperator(
unless(isExpansionInSystemHeader()), hasOperatorName("&"),
hasUnaryOperand(anyOf(
ignoringParenImpCasts(
cxxOperatorCallExpr(
callee(cxxMethodDecl(hasName("operator[]"))
.bind("operator[]")),
argumentCountIs(2),
hasArgument(
0,
anyOf(ignoringParenImpCasts(
declRefExpr(
to(varDecl(anyOf(
hasType(Container),
hasType(references(Container))))))
.bind("var")),
ignoringParenImpCasts(hasDescendant(
declRefExpr(
to(varDecl(anyOf(
hasType(Container),
hasType(pointsTo(Container)),
hasType(references(Container))))))
.bind("var"))))),
hasArgument(1,
ignoringParenImpCasts(
integerLiteral(equals(0)).bind("zero"))))
.bind("operator-call")),
ignoringParenImpCasts(
cxxMemberCallExpr(
hasDescendant(
declRefExpr(to(varDecl(anyOf(
hasType(Container),
hasType(references(Container))))))
.bind("var")),
argumentCountIs(1),
hasArgument(0,
ignoringParenImpCasts(
integerLiteral(equals(0)).bind("zero"))))
.bind("member-call")),
ignoringParenImpCasts(
arraySubscriptExpr(
hasLHS(ignoringParenImpCasts(
declRefExpr(to(varDecl(anyOf(
hasType(Container),
hasType(references(Container))))))
.bind("var"))),
hasRHS(ignoringParenImpCasts(
integerLiteral(equals(0)).bind("zero"))))
.bind("array-subscript")))))
.bind("address-of"),
this);
}
void ContainerDataPointerCheck::check(const MatchFinder::MatchResult &Result) {
const auto *UO = Result.Nodes.getNodeAs<UnaryOperator>("address-of");
const auto *DRE = Result.Nodes.getNodeAs<DeclRefExpr>("var");
std::string ReplacementText;
ReplacementText = std::string(Lexer::getSourceText(
CharSourceRange::getTokenRange(DRE->getSourceRange()),
*Result.SourceManager, getLangOpts()));
if (DRE->getType()->isPointerType())
ReplacementText += "->data()";
else
ReplacementText += ".data()";
FixItHint Hint =
FixItHint::CreateReplacement(UO->getSourceRange(), ReplacementText);
diag(UO->getBeginLoc(),
"'data' should be used for accessing the data pointer instead of taking "
"the address of the 0-th element")
<< Hint;
}
} // namespace readability
} // namespace tidy
} // namespace clang
|
7fc664d1188e744a2bd69262916e672eed64c65e | e07976a89008a156878c8016de3d9743558925fc | /C02/ex01/Fixed.cpp | b7bbe499d78f3e9344ca39c8701645da1c831d6d | [] | no_license | joann8/CPP | 071975257cf6e79d6dc28abc8686824bb4291a19 | 0978431cd09a21c2a28f32f36e5ba36096daf697 | refs/heads/master | 2023-07-10T09:04:38.031587 | 2021-08-09T15:28:02 | 2021-08-09T15:28:02 | 368,610,197 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,400 | cpp | Fixed.cpp | #include "Fixed.hpp"
#include <cmath>
Fixed::Fixed(void) : _nb(0)
{
std::cout << "Default constructor called" << std::endl;
return ;
}
Fixed::Fixed(Fixed const & src)
{
std::cout << "Copy constructor called" << std::endl;
*this = src;
return ;
}
Fixed::Fixed(const int i) : _nb(i << Fixed::_bits) //valeur en binaire sur 8 bits
{
std::cout << "Int constructor called" << std::endl;
return ;
}
Fixed::Fixed(const float f) : _nb(roundf(f * (1 << Fixed::_bits))) //sur 8 bits, valeur binaire
{
std::cout << "Float constructor called" << std::endl;
return ;
}
Fixed::~Fixed(void)
{
std::cout << "Destructor called" << std::endl;
return ;
}
Fixed & Fixed::operator=(Fixed const & src)
{
std::cout << "Assignation operator called" << std::endl;
this->_nb = src.getRawBits();
return *this;
}
int Fixed::getRawBits(void) const
{
// std::cout << "getRawBits member function called" << std::endl;
return this->_nb;
}
void Fixed::setRawBits(int const raw)
{
// std::cout << "setRawBits member function called" << std::endl;
this->_nb = raw;
return ;
}
int Fixed::toInt(void) const
{
return this->_nb >> Fixed::_bits; // this value on 8 bits
}
float Fixed::toFloat(void) const
{
return (float)this->_nb / (1 << Fixed::_bits); // / 256
}
std::ostream & operator<<(std::ostream & output, Fixed const & rhs)
{
output << rhs.toFloat();
return output;
}
int const Fixed::_bits = 8;
|
b1a35a122f5cf86bba2e1f73ad4157bd066e29b4 | a33c767141d8a5ab4452a6ae9c556f60329b576d | /src/Simulation/EXIT/EXIT.hpp | 97b39e3d13b67d4897f703c2e3c9cd5be5054f43 | [
"MIT"
] | permissive | sqf-ice/aff3ct | 6d885bceb43ab88f61c27b2ccf4e04458b800269 | fcd41ffd04238e314b48ec5d391265e1407975a8 | refs/heads/master | 2020-04-22T13:21:11.568787 | 2019-01-18T14:47:37 | 2019-01-18T14:52:32 | 170,405,919 | 0 | 1 | MIT | 2019-02-12T23:13:05 | 2019-02-12T23:13:05 | null | UTF-8 | C++ | false | false | 2,624 | hpp | EXIT.hpp | #if !defined(AFF3CT_8BIT_PREC) && !defined(AFF3CT_16BIT_PREC)
#ifndef SIMULATION_EXIT_HPP_
#define SIMULATION_EXIT_HPP_
#include <vector>
#include <mipp.h>
#include "Module/Source/Source.hpp"
#include "Module/Codec/Codec_SISO.hpp"
#include "Module/Modem/Modem.hpp"
#include "Module/Channel/Channel.hpp"
#include "Module/Decoder/Decoder_SISO.hpp"
#include "Module/Monitor/EXIT/Monitor_EXIT.hpp"
#include "Tools/Display/Terminal/Terminal.hpp"
#include "Tools/Noise/Noise.hpp"
#include "Tools/Display/Reporter/EXIT/Reporter_EXIT.hpp"
#include "Tools/Display/Reporter/Noise/Reporter_noise.hpp"
#include "Tools/Display/Reporter/Throughput/Reporter_throughput.hpp"
#include "Factory/Simulation/EXIT/EXIT.hpp"
#include "../Simulation.hpp"
namespace aff3ct
{
namespace simulation
{
template <typename B = int, typename R = float>
class EXIT : public Simulation
{
protected:
const factory::EXIT::parameters ¶ms_EXIT; // simulation parameters
// code specifications
tools::Sigma<R> noise; // current noise simulated
tools::Sigma<R> noise_a; // current noise simulated for the "a" part
R sig_a;
// communication chain
std::unique_ptr<module::Source <B >> source;
std::unique_ptr<module::Codec_SISO <B,R>> codec;
std::unique_ptr<module::Modem <B,R>> modem;
std::unique_ptr<module::Modem <B,R>> modem_a;
std::unique_ptr<module::Channel < R>> channel;
std::unique_ptr<module::Channel < R>> channel_a;
std::unique_ptr<module::Decoder_SISO< R>> siso;
std::unique_ptr<module::Monitor_EXIT<B,R>> monitor;
// terminal and reporters (for the output of the code)
std::vector<std::unique_ptr<tools::Reporter>> reporters;
std::unique_ptr<tools::Terminal> terminal;
public:
explicit EXIT(const factory::EXIT::parameters ¶ms_EXIT);
virtual ~EXIT() = default;
void launch();
protected:
void _build_communication_chain();
void sockets_binding ();
void simulation_loop ();
std::unique_ptr<module::Source <B >> build_source ( );
std::unique_ptr<module::Codec_SISO <B,R>> build_codec ( );
std::unique_ptr<module::Modem <B,R>> build_modem ( );
std::unique_ptr<module::Modem <B,R>> build_modem_a ( );
std::unique_ptr<module::Channel < R>> build_channel (const int size);
std::unique_ptr<module::Channel < R>> build_channel_a(const int size);
std::unique_ptr<module::Monitor_EXIT<B,R>> build_monitor ( );
std::unique_ptr<tools::Terminal > build_terminal ( );
};
}
}
#endif /* SIMULATION_EXIT_HPP_ */
#endif |
7d910f6fcaadad4d7dcb8e20f6885d78f6654a6e | 43e5b9b997fe79f3289487bd08812990a0a8c221 | /GLAC/flow/flow.h | 840ac1836fb85b94f34ee15d7f09e955483d6ded | [
"MIT"
] | permissive | hmvege/GLAC | 1e3b2e3eab7ed2b0c3b1dd1c0d49b672d21c816f | 9bb7466fce408bf51cb98d65f639acd37d034d62 | refs/heads/master | 2023-07-23T07:12:24.684819 | 2020-07-01T09:40:55 | 2020-07-01T09:40:55 | 90,118,468 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,190 | h | flow.h | /*!
* \class Flow
*
* \brief Class for applying gradient flow on lattice.
*
* Performs one step with gradient flow on the lattice, see <a href="https://arxiv.org/abs/1006.4518">this paper</a> for a detailed description.
*
* \author Mathias M. Vege
* \version 1.0
* \date 2017-2019
* \copyright MIT Licence
*/
#ifndef FLOW_H
#define FLOW_H
#include "math/lattice.h"
#include "math/flowexpfunctions.h"
#include "actions/action.h"
class Flow
{
private:
// Flow update step
double m_epsilon = 0.02;
// Lattice constants
std::vector<unsigned int> m_N;
unsigned long int m_subLatticeSize;
// Temporary lattice to use when flowing
Lattice<SU3> *m_tempLattice;
Lattice<SU3> m_tempExpLattice;
// Updates the lattice with the exponantiated lattice values using move semantics
inline Lattice<SU3> matrixExp(const Lattice<SU3> &lattice);
inline Lattice<SU3> matrixExp(Lattice<SU3> &&lattice);
// SU3 exponentiation function
SU3Exp *m_SU3ExpFunc = nullptr;
void setSU3ExpFunc();
// Action pointer
Action *m_S = nullptr;
public:
Flow(Action *S);
~Flow();
void flowField(Lattice<SU3> *lattice);
};
#endif // FLOW_H
|
5e71285e767efd205c3dace6e9b99d29d5836a1b | 761af5d51c662c20096c50ae7a00d03ceeab2ac7 | /libraries/libsystem/system/Random.cpp | 2c270044d1641ee877bac10b231cc3ca72e7c850 | [
"Zlib",
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | cristian-programmer/skift | 1eedaec88ba1c09518b7c11110fa4b96a2b2b0eb | daff5533da1610f754305f8805889b536e9efb54 | refs/heads/master | 2021-06-14T17:02:38.612380 | 2020-11-08T19:18:25 | 2020-11-08T19:18:25 | 162,073,493 | 1 | 0 | MIT | 2018-12-17T04:15:16 | 2018-12-17T04:15:16 | null | UTF-8 | C++ | false | false | 1,140 | cpp | Random.cpp | #include <abi/Paths.h>
#include <libsystem/io/Stream.h>
#include <libsystem/system/Random.h>
Random random_create()
{
Random random = {};
Stream *random_device = stream_open(UNIX_DEVICE_PATH("random"), OPEN_READ);
stream_read(random_device, &random, sizeof(Random));
stream_close(random_device);
return random;
}
uint32_t random_uint32(Random *random)
{
// *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / pcg-random.org
// Licensed under Apache License 2.0 (NO WARRANTY, etc. see website)
uint64_t oldstate = random->state;
// Advance internal state
random->state = oldstate * 6364136223846793005ULL + (random->inc | 1);
// Calculate output function (XSH RR), uses old state for max ILP
uint32_t xorshifted = ((oldstate >> 18u) ^ oldstate) >> 27u;
uint32_t rot = oldstate >> 59u;
return (xorshifted >> rot) | (xorshifted << ((-rot) & 31));
}
uint32_t random_uint32_max(Random *random, uint32_t max)
{
return random_uint32(random) % max;
}
#ifndef __KERNEL__
double random_double(Random *random)
{
return random_uint32(random) / ((double)UINT32_MAX);
}
#endif
|
9b54ab6bee9bdfb9329ca623ca66894ced14ce3e | ebb2fd2be1c8d5e17d9edbc4c47c22fbb0fa509f | /IsenburgStreamingMesh/OOC/psreader_dist/inc/psreader_oocc.h | 44680c592987867c7e245af508e6380e6e161c15 | [] | no_license | adishavit/mesh | e827d95ac0b07bb3a9229da1f548fbe0464059ca | f91b5aafa62dede899b0d6ec25b62d3ffceb8402 | refs/heads/master | 2021-01-15T10:06:19.652253 | 2013-01-12T16:27:16 | 2013-01-12T16:27:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,799 | h | psreader_oocc.h | /*
===============================================================================
FILE: psreader_oocc.h
CONTENTS:
Reads a mesh from our oocc compressed format (SIGGRAPH 2003) and provides
access to it in form of a Processing Sequence.
PROGRAMMERS:
martin isenburg@cs.unc.edu
COPYRIGHT:
copyright (C) 2003 martin isenburg@cs.unc.edu
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
CHANGE HISTORY:
21 December 2004 -- make the new t_idx_orig field point to the t_idx field
13 January 2004 -- fill in the new t_orig field during read_triangle
02 September 2003 -- changed into an instance of a psreader interface
16 August 2003 -- added support for per edge user data
22 March 2003 -- updated based on Peter's input
03 March 2003 -- created initial version (psmesh) while waiting at IAD airport
===============================================================================
*/
#ifndef PSREADER_OOCC_H
#define PSREADER_OOCC_H
#include "psreader.h"
#include <stdio.h>
class PSreader_oocc : public PSreader
{
public:
// additional psreader_oocc triangle variables
int* t_pos_i[3];
// additional psreader_oocc mesh variables
int bits;
int* bb_min_i;
int* bb_max_i;
// psreader interface function implementations
PSevent read_triangle();
void set_vdata(const void* data, int i);
void* get_vdata(int i) const;
void set_edata(const void* data, int i);
void* get_edata(int i) const;
void close();
// psreader_oocc functions
bool open(const char* file_name);
bool open(FILE* fp);
PSreader_oocc();
~PSreader_oocc();
};
#endif
|
23ebad0b70523b24e43d858fccb557c36e7df76f | 33afac035da1c3fd1fa8ed78695199ede089e17f | /d03/ex03/NinjaTrap.cpp | 11d87efa54fd145af584447f763bcc993857152e | [] | no_license | Melchizerderk/PiscineCPP | 3ccb5d9de3be5ea442ae7d84b00c801f9fe412ac | 68386a18bb6a4294c9f76c9b36cef07564562b19 | refs/heads/master | 2020-12-24T11:53:15.083941 | 2015-07-04T15:18:06 | 2015-07-04T15:18:06 | 73,010,212 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,199 | cpp | NinjaTrap.cpp | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* NinjaTrap.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bcrespin <bcrespin@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/01/08 17:56:40 by bcrespin #+# #+# */
/* Updated: 2015/01/08 20:06:11 by bcrespin ### ########.fr */
/* */
/* ************************************************************************** */
#include "NinjaTrap.hpp"
#include "ScavTrap.hpp"
#include "FragTrap.hpp"
#include <iostream>
#include <cstdlib>
#include <time.h>
NinjaTrap::NinjaTrap(void) : ClapTrap() {
return;
}
NinjaTrap::NinjaTrap(std::string const name) : ClapTrap() {
this->_Hp = 60;
this->_Mhp = 60;
this->_Ep = 120;
this->_Mep = 120;
this->_lvl = 1;
this->_name = name;
this->_claptype = "NINJ4-TP";
this->_Mad = 60;
this->_Rad = 5;
this->_Adr = 0;
std::cout << this->_claptype <<" TO THE RESCUE!!" << std::endl;
std::cout << "The name is " << this->_name << std::endl;
return;
}
NinjaTrap::~NinjaTrap(void) {
std::cout << "My...mission....here...is..done..*bzzzt*" << std::endl;
return;
}
NinjaTrap::NinjaTrap(NinjaTrap const &) : ClapTrap() {
return;
}
void NinjaTrap::ninjaShoebox(FragTrap const & target) {
(void) target;
std::cout << this->_name << \
" open his shoebox to use his dooooom laaaaser" << std::endl;
return;
}
void NinjaTrap::ninjaShoebox(ScavTrap const & target) {
(void) target;
std::cout << this->_name << \
" open his shoebox to use his nail gun!" << std::endl;
return;
}
void NinjaTrap::ninjaShoebox(NinjaTrap const & target) {
(void) target;
std::cout << this->_name << \
"and open his shoebox to use his special beam canon!" << std::endl;
return;
}
|
809f8033d03593156a73f4eb0b9b60045c94e55a | 81fea7e421f7a8dce11870ca64d4aed1d1c75e04 | /c++03/vector_test2.cpp | 9b3105bf51b3a70c057aad8bed74fdbafecc8f5c | [] | no_license | petergottschling/dmc2 | d88b258717faf75f2bc808233d1b6237cbe92712 | cbb1df755cbfe244efa0f87ac064382d87a1f4d2 | refs/heads/master | 2020-03-26T14:34:26.143182 | 2018-08-16T14:00:58 | 2018-08-16T14:00:58 | 144,994,456 | 27 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 706 | cpp | vector_test2.cpp | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main (int argc, char* argv[])
{
vector<int> v;
v.push_back(3); v.push_back(4); v.push_back(7); v.push_back(9);
vector<int>::iterator it= find(v.begin(), v.end(), 4);
cout << "After " << *it << " comes " << *(it+1) << '\n';
v.insert(it+1, 5); // insert value 5 at position 2
v.erase(v.begin()); // delete entry at position 1
cout << "Size = " << v.size() << ", capacity = " << v.capacity() << '\n';
{
vector<int> tmp(v);
swap(v, tmp);
}
v.push_back(7);
for (vector<int>::iterator it= v.begin(); it < v.end(); ++it)
cout << *it << ",";
cout << '\n';
return 0;
}
|
a8bc8977d9ccd0539bf0940042bc93391a72fd5c | 2fe22b3e0e7769b42aeb1f6a6c5c136a210f234d | /native_library/win/WebViewANE/WebViewANE/FreNamespace.h | 3b34cbefde0ac3ad60c323c71edf9505ca772dd9 | [
"Apache-2.0"
] | permissive | tuarua/WebViewANE | 691f950860154fe7c14db4cfa36e1696d0622e5c | 1619b4b62a28b0bc4d77439c2980b6ae7a958382 | refs/heads/master | 2023-01-28T00:14:43.988458 | 2023-01-14T21:20:40 | 2023-01-14T21:20:40 | 78,140,240 | 209 | 55 | Apache-2.0 | 2023-01-14T21:21:14 | 2017-01-05T19:05:47 | ActionScript | UTF-8 | C++ | false | false | 117 | h | FreNamespace.h | #pragma once
// Set FreNamespace to the same as that in your C# Class Library
namespace FreNamespace = WebViewANELib; |
e60e38fdc16c974b205d30680430522fafb56567 | 205585c79f4acae688ebac944c6e47d1eb8c619e | /tp_imperativo/src/reserva.h | a962075294e1edfda2248163c748cbe3ef71013f | [] | no_license | matiaschapresto/Algoritmos-I | 0c0d37b02fa316dbf7901ea2592d531cfda9a1a2 | 62ee8f066705101ab937679aaa58651edf6557dd | refs/heads/master | 2021-01-21T01:16:09.312926 | 2014-05-08T14:23:32 | 2014-05-08T14:23:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,061 | h | reserva.h | #ifndef RESERVA_H
#define RESERVA_H
#include "tipos.h"
#include "lista.h"
class Reserva
{
public:
Reserva();
Reserva(const DNI documento, const Fecha fechaDesde, const Fecha fechaHasta,
const TipoHabitacion tipo);
DNI documento() const;
Fecha fechaDesde() const;
Fecha fechaHasta() const;
TipoHabitacion tipo() const;
bool confirmada() const;
void confirmar();
bool operator==(const Reserva& r) const;
void mostrar(std::ostream& os) const;
void guardar(std::ostream& os) const;
void cargar (std::istream& is);
private:
DNI _documento;
Fecha _fechaDesde;
Fecha _fechaHasta;
TipoHabitacion _tipo;
bool _confirmada;
enum {ENCABEZADO_ARCHIVO = 'R'};
//parsing
istream& tomarTipoHabitacion(istream& is, TipoHabitacion & th) const;
istream& tomarConfirmada (istream& is, bool & val) const;
};
std::ostream & operator<<(std::ostream & os,const Reserva & r);
#endif // RESERVA_H
|
202ef6968894796db9010200d4235cf4cdc79612 | 50edab9babae446ac188df34a8c37d4fa537e946 | /libccif/src/bp/CaInfo.cpp | 185b473432ec4fd3bb57ae7e10b956be6c8c296b | [] | no_license | krishnact/projects | e1cae86e05d30ad6bd4935ba7e4c25985f58d5d1 | 940a17ffa42afc28dbd8af2656e3611b87033116 | refs/heads/master | 2020-12-24T13:36:24.259601 | 2019-10-31T14:54:36 | 2019-10-31T14:54:36 | 24,039,232 | 0 | 0 | null | 2020-10-13T02:36:47 | 2014-09-15T02:04:17 | C++ | UTF-8 | C++ | false | false | 3,332 | cpp | CaInfo.cpp | //**//
//@Created(date = "Mon Feb 01 22:30:11 EST 2016")
// Copyright (2012) Krishna C Tripathi. All rights reserved.
//
// You are not allowed to read/copy/distribute following code without explicit written authorization from Krishna C Tripathi
//
//**//
#include "stdio.h"
#include "CaInfo.h"
#ifdef org_himalay_ccif_CaInfo__USE_SMART_PTR
#define ArrayList(x) SmartPtrList<x>
#define ArrayList_iterator(x) SmartPtrList<x>::iterator
#include "SmartPtrList.h"
#else
#define ArrayList(x) BinMessagePtrList
#define ArrayList_iterator(x) BinMessagePtrList::iterator
#include "BinMessagePtrList.h"
#endif
// Namespace
namespace org {
namespace himalay {
namespace ccif {
using namespace ::org::himalay::msgs::runtime;
// Constructor
CaInfo::CaInfo() {
references= 0;
// caPmtId
caPmtId= (ui8)0;
// CaDescriptors
org_himalay_msgs_runtime_ByteArray_NEW(CaDescriptors);
CaDescriptors->setSizeType("EOS");
}
// Destructor
CaInfo::~CaInfo() {
// caPmtId
// CaDescriptors
org_himalay_msgs_runtime_ByteArray_DELETE( CaDescriptors);
}
int CaInfo::readNoHeader(DataInputStream& istream ) { // throws IOException
int retVal = 0;
// caPmtId
{
caPmtId=(istream.readUI8());
retVal+=1;
}
// CaDescriptors
{
retVal+=CaDescriptors->read(istream);
}
return retVal;
}
int CaInfo::read(DataInputStream& istream ) { // throws IOException
int retVal = 0;
// read caPmtId
{
caPmtId=(istream.readUI8());
retVal+=1;
}
// read CaDescriptors
{
retVal+=CaDescriptors->read(istream);
}
return retVal;
}
int CaInfo::write(DataOutputStream& ostream) { // throws IOException
{ /** fix dependent sizes for CaDescriptors**/
}
int retVal= 0;
// write caPmtId
ostream.writeUI8(caPmtId);
retVal +=1;
// write CaDescriptors
{
retVal += CaDescriptors->write(ostream);
}
return retVal;
}
int CaInfo::dump(DumpContext& dc) { // throws IOException
dc.indent();
dc.getPs().print("CaInfo\n");
dc.increaseIndent();
int retVal= 0;
// write caPmtId
dc.indent();
dc.getPs().print("caPmtId=");
dc.getPs().println((long)caPmtId);
// write CaDescriptors
dc.indent();
dc.getPs().print("CaDescriptors");
CaDescriptors->dump(dc);
dc.decreaseIndent();
return retVal;
}
// Getter for caPmtId
//ui8 CaInfo::getCaPmtId()
//{
//return this->caPmtId;
//}
// Setter for caPmtId
//void CaInfo::setCaPmtId(ui8 val)
//{
//this->caPmtId= val;
//}
// Getter for CaDescriptors
//org_himalay_msgs_runtime_ByteArray_PTR_TYPE CaInfo::getCaDescriptors()
//{
//return this->CaDescriptors;
//}
// Setter for CaDescriptors
//void CaInfo::setCaDescriptors(org_himalay_msgs_runtime_ByteArray_PTR_TYPE val)
//{
//this->CaDescriptors= val;
//}
int CaInfo::getSize() { // throws IOException
int retVal = 0;
return retVal;
}
#ifdef org_himalay_ccif_CaInfo__USE_SMART_PTR
void intrusive_ptr_add_ref(org::himalay::ccif::CaInfo* p) {
p->increaseRef();
};
void intrusive_ptr_release(org::himalay::ccif::CaInfo* p) {
p->decreaseRef();
};;
#endif
}
}
}
// End of code |
584377340df1eba09dda0468dcf10507d16ece01 | 4dad3e137f89638cc1c13903d2f82cfee9e9a611 | /366-FindLeavesOfBinaryTree.cpp | 92568da0754d5bcadf97ed2046b5a1ef6f052550 | [] | no_license | AbubakirovRA/leetcode | 5b510c34b89b207319f65d7a925d37f02c6924a5 | 6eb9d5a4f978f9bf31a45b356a09b93322e192fd | refs/heads/master | 2023-03-16T22:40:06.209726 | 2019-07-14T05:12:43 | 2019-07-14T05:12:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,453 | cpp | 366-FindLeavesOfBinaryTree.cpp | /*
Given a binary tree, find all leaves and then remove those leaves.
Then repeat the previous steps until the tree is empty.
Example:
Given binary tree
1
/ \
2 3
/ \
4 5
Returns [4, 5, 3], [2], [1].
Explanation:
1. Remove the leaves [4, 5, 3] from the tree
1
/
2
2. Remove the leaf [2] from the tree
1
3. Remove the leaf [1] from the tree
[]
Returns [4, 5, 3], [2], [1].
*/
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
// Time: O(n)
// Space: O(h)
class Solution {
public:
vector<vector<int>> findLeaves(TreeNode* root) {
vector<vector<int>> result;
findLeavesHelper(root, result); // calculates depth and updates result
return result;
}
private:
int findLeavesHelper(TreeNode *node, vector<vector<int>>& result) { // leaf is 0
if (node == NULL) return -1;
const int level = 1 + max(findLeavesHelper(node->left, result),
findLeavesHelper(node->right, result));
//if (result.size() <= level){
if (result.size() == level) { // means extend
result.push_back();
}
result[level].push_back(node->val);
return level;
}
};
|
c48b81f4f9b431dc25388aa6010cb15ffaaf66ad | 17524586122634768010c67e4df7892017d63137 | /pizzeria.cpp | 1f8256a7613c3b42ce448ba8f8149261c92a5a24 | [] | no_license | julioasp03/pizzeria-JASP-00085518 | 19413cefad3cef2ff9757b2d1c4e2c8b90776d88 | ccbfbf27d9c622bc1caa4f88f51a3c23ebf763a2 | refs/heads/master | 2020-12-11T22:03:08.480125 | 2020-02-10T04:47:14 | 2020-02-10T04:47:14 | 233,970,552 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,953 | cpp | pizzeria.cpp | #include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#define PASSWORD "union" //defino la contrasenia//
using namespace std;
//creo mis enum//
enum maindish{pizza,pasta,lasagna};
enum drink{Beer,soda,tea};
enum entrance{garlicbread,pizzarolls,cheesesticks};
enum payment{cash,card};
//struct para la informacion de direccion//
struct address{
string settlement,municipality, department;
int housnumber;
int cellphone;
};
//struct para la informacion personal//
struct maininfo{
string name;
maindish pdish;
drink pdrink;
entrance pdentrance;
payment pay;
int iDorder;
float total;
};
//struct para las ordenes a domicilio//
struct delivery{
address deliveryaddress,despach02;//subregistros para las ordenes a domicilio y despacho//
maininfo deliveryinfo;//subrefistro para informacion personal//
maininfo despach;//subregistro para informacion personal para el despacho//
};
//struct para las ordenes a restaurante//
struct houseorder{
int ptable,ptable02;//ptable = numero de personas, ptable 02= numero de personas para el despacho//
int cont;
maininfo houseinfo;//subrefistro para informacion personal//
maininfo despach03;//subregistro para informacion personal para el despacho//
};
//variables globales//
bool isadmin= false;
int idorder=0;
int add=1;
vector<delivery> orderDely,despadely;
vector<houseorder> orderRest,desparest;
delivery dely,Dd;
houseorder house,Dr;
//prototipos//
bool login();
void printmenu();
void addorderdely();
void addorderhouse();
void showdely();
void showhouse();
void despachdely();
void despachrest();
int timeDely();
int timeRest();
void erase();
double total();
int main(void){
int option=0;
if (login()==false)//inicio sesion//
{
return 0;
}
do
{
cout<<endl;
printmenu(); cin>> option; //despliego menu e ingreso la opcion//
cin.ignore();
cout<<endl;
switch (option)
{
case 1://ordenes a domicilio//
addorderdely();
break;
case 2://ordenes a restaurante//
addorderhouse();
break;
case 3:
showdely();//mostrar ordenes a domicilio//
break;
case 4:
showhouse();//mostrar ordenes a restaurante//
break;
case 5: despachdely(); break;//despachar ordenes a domicilio//
case 6: despachrest(); break;//despachar ordenes a restaurante//
case 7: cout<<"Tiempo estimado: "<<timeDely()<<" min"; break;//tiempo de espera a domicilio//
case 8: cout<<"Tiempo estimado: "<<timeRest()<<" min"; break;//tiempo de espera restaurante//
case 9: if(isadmin==true){//verifico si es administrador//
erase();//eliminar cualquier orden//
}
else
{
cout<<"Solo un administrador tiene autorizacion\n";
}
break;
case 10:
cout<<"El total de ventas fue de: "<<total()<<"$";//el total gananci en ventas//
break;
case 11: main(); break;//cambio de usuario//
}
} while (option!=12);//cierro menu con opc 12.//
return 0;
}
bool login(){
string password;
char option;
cout<<"INICIO DE SESION"<< endl;
cout<<"A - Administrador"<<endl;
cout<<"E - Empleado"<<endl;
cout<<"su opcion: "; cin>>option;//elige con que seion iniciar//
switch (option)
{
case 'A':
case 'a': //en caso que sea administrador pido contrasenia y verifico si es correcta//
cout<<"digite contrasenia: "; cin>> password; cin.ignore();
if (password.compare(PASSWORD)==0)
{
isadmin= true;
return true;
}
else
{
cout<<"contrasenia incorrecta"<<endl;
}
break;
case 'E':
case 'e':
isadmin =false;//si no es administrador //
return true;
break;
}
return false;
}
void printmenu(){ //muestro el menu//
cout<<"---------------------------------------\n";
cout<<"Sistema de despacho pizzeria Santillana"<<endl;
cout<<"---------------------------------------\n";
cout<<"1. Agregar ordenes a domicilio."<<endl;
cout<<"2. Agregar ordenes a restaurante."<<endl;
cout<<"3. Ver ordenes a domicilio."<<endl;
cout<<"4. Ver ordenes a restaurante."<<endl;
cout<<"5. Despachar ordenes a domicilio."<<endl;
cout<<"6. Despachar ordenes a restaurante."<<endl;
cout<<"7. Ver tiempo promedio de espera a domicilio."<<endl;
cout<<"8. Ver tiempo promedio de espera a restaurante."<<endl;
cout<<"9. Eliminar orden realizada.\n";
cout<<"10. Calcular total de ventas.\n";
cout<<"11. Cambiar de usuario.\n";
cout<<"12. Salir del menu.";
cout<<endl;
cout<<"Su opcion: ";
return;
}
void addorderdely(){
int aux=0;
float montototal=0;
cout<<endl;
cout<<"Nombre: "; getline(cin,dely.deliveryinfo.name);//ingreso toda la informacion necesaria de mi struct a domicilio//
cout<<"****************************\n";
cout<<"Direccion"<<endl;
cout<<"Colonia: "; getline(cin,dely.deliveryaddress.settlement);
cout<<"Municipio: "; getline(cin,dely.deliveryaddress.municipality);
cout<<"Departamento: "; getline(cin,dely.deliveryaddress.department);
cout<<"No. de casa: "; cin>>dely.deliveryaddress.housnumber; cin.ignore();
cout<<"****************************\n";
cout<<"Plato principal\n";
cout<<"1. Pizza\n";
cout<<"2. Pasta\n";
cout<<"3. Ensalada\n";
cout<<"Su opcion: "; cin>>aux; cin.ignore();
cout<<endl;
if (aux==1)
{
dely.deliveryinfo.pdish=pizza; //lleno mis enum//
montototal=montototal+13.99;//acumulo el las ganancias en una variable//
}
else if(aux==2){
dely.deliveryinfo.pdish= pasta;
montototal=montototal+5.55;
}
else
{
dely.deliveryinfo.pdish=lasagna;
montototal=montototal+6.25;
}
cout<<"Entrada principal\n";
cout<<"1. Pan con ajo\n";
cout<<"2. Pizza rolls\n";
cout<<"3. Cheese sticks\n";
cout<<"Su opcion: "; cin>>aux; cin.ignore();
cout<<endl;
if (aux==1)
{
dely.deliveryinfo.pdentrance=garlicbread;
montototal=montototal+3.99;
}
else if(aux==2){
dely.deliveryinfo.pdentrance= pizzarolls;
montototal=montototal+4.99;
}
else
{
dely.deliveryinfo.pdentrance=cheesesticks;
montototal=montototal+3.75;
}
cout<<"Bebida principal\n";
cout<<"1. Cerveza\n";
cout<<"2. Soda\n";
cout<<"3. Te\n";
cout<<"Su opcion: "; cin>>aux; cin.ignore();
cout<<endl;
if (aux==1)
{
dely.deliveryinfo.pdrink=Beer;
montototal=montototal+1.99;
}
else if(aux==2){
dely.deliveryinfo.pdrink= soda;
montototal=montototal+0.95;
}
else
{
dely.deliveryinfo.pdrink=tea;
montototal=montototal+1.15;
}
cout<<endl;
idorder=idorder+1;//implemento un contador global que me servira como numero de orden//
dely.deliveryinfo.iDorder=idorder;
cout<<"Tipo de pago\n";
cout<<"1. Efectivo\n";
cout<<"2. Tarjeta\n";
cout<<"Su opcion: "; cin>>aux; cin.ignore();//lleno mis enum y campo de mi struct//
cout<<endl;
if (aux==1)
{
dely.deliveryinfo.pay=cash;
}
else
{
dely.deliveryinfo.pay=card;
}
dely.deliveryinfo.total=montototal;
cout<<"Monto: "<<montototal<<"$";
cout<<endl;
cout<<"Telefono: "; cin>>dely.deliveryaddress.cellphone; cin.ignore();
orderDely.insert(orderDely.end(),dely);//inserto todo en mi lista a domicilio//
return;
}
void addorderhouse(){
int aux=0;
float montototal=0;
cout<<endl; //ingreso toda la informacion necesaria de mi struct a restaurante//
cout<<"Nombre: "; getline(cin,house.houseinfo.name);
cout<<"Numero de personas: ";cin>>house.ptable; cin.ignore();
cout<<endl;
cout<<"Plato principal\n";
cout<<"1. Pizza\n";
cout<<"2. Pasta\n";
cout<<"3. Ensalada\n";
cout<<"Su opcion: "; cin>>aux; cin.ignore();
cout<<endl;
if (aux==1)
{
house.houseinfo.pdish=pizza; //lleno mis enum//
montototal=montototal+13.99; //acumulo el las ganancias en una variable//
}
else if(aux==2){
house.houseinfo.pdish= pasta;
montototal=montototal+5.55;
}
else
{
house.houseinfo.pdish=lasagna;
montototal=montototal+6.25;
}
cout<<"Entrada principal\n";
cout<<"1. Pan con ajo\n";
cout<<"2. Pizza rolls\n";
cout<<"3. Cheese sticks\n";
cout<<"Su opcion: "; cin>>aux; cin.ignore();
cout<<endl;
if (aux==1)
{
house.houseinfo.pdentrance=garlicbread;
montototal=montototal+3.99;
}
else if(aux==2){
house.houseinfo.pdentrance= pizzarolls;
montototal=montototal+4.99;
}
else
{
house.houseinfo.pdentrance=cheesesticks;
montototal=montototal+3.75;
}
cout<<"Bebida principal\n";
cout<<"1. Cerveza\n";
cout<<"2. Soda\n";
cout<<"3. Te\n";
cout<<"Su opcion: "; cin>>aux; cin.ignore();
cout<<endl;
if (aux==1)
{
house.houseinfo.pdrink=Beer;
montototal=montototal+1.99;
}
else if(aux==2){
house.houseinfo.pdrink= soda;
montototal=montototal+0.95;
}
else
{
house.houseinfo.pdrink=tea;
montototal=montototal+1.15;
}
cout<<endl;
idorder=idorder+1; //implemento un contador global que me servira como numero de orden//
house.houseinfo.iDorder=idorder;
cout<<"Tipo de pago\n";
cout<<"1. Efectivo\n";
cout<<"2. Tarjeta\n";
cout<<"Su opcion: "; cin>>aux; cin.ignore(); //lleno mis enum y campo de mi struct//
cout<<endl;
if (aux==1)
{
house.houseinfo.pay=cash;
}
else
{
house.houseinfo.pay=card;
}
house.houseinfo.total=montototal;
cout<<"Monto: "<<montototal<<"$";
cout<<endl;
orderRest.insert(orderRest.end(),house);//inserto todo en mi lista a restaurante//
return;
}
void showdely(){
if(!orderDely.size()==0){//mientras mi lista no este vacia//
for (int i = 0; i < orderDely.size(); i++)//recorro la lista//
{
cout<<"********************************\n"; //muestro los campos de mi primer puesto en la lista y si hay mas continuo//
cout<<"Nombre del cliente: "<<orderDely[i].deliveryinfo.name<<endl;
cout<<"Reside en la colonia: "<<orderDely[i].deliveryaddress.settlement<<endl;
cout<<"Municipio: "<<orderDely[i].deliveryaddress.municipality<<endl;
cout<<"Departamento: "<<orderDely[i].deliveryaddress.department<<endl;
cout<<"No. de casa: "<<orderDely[i].deliveryaddress.housnumber<<endl;
cout<<"Plato principal: ";
switch (orderDely[i].deliveryinfo.pdish)//vero que num es//
{
case 0:
cout<<" Pizza\n";
break;
case 1: cout<<" Pasta\n";
break;
case 2: cout<<" Lasagna\n"; break;
}
cout<<"Entrada principal: ";
switch (orderDely[i].deliveryinfo.pdentrance)
{
case 0:
cout<<" Pan con ajo\n";
break;
case 1: cout<<" Pizza rolls\n";
break;
case 2: cout<<" Cheese sticks\n"; break;
}
cout<<"Bebida: ";
switch (orderDely[i].deliveryinfo.pdrink)
{
case 0:
cout<<" Cerveza\n";
break;
case 1: cout<<" Soda\n";
break;
case 2: cout<<" Te\n"; break;
}
cout<<"Id de orden: "<<orderDely[i].deliveryinfo.iDorder<<endl;
cout<<"Monto: "<<orderDely[i].deliveryinfo.total<<"$"<<endl;
cout<<"Metodo de pago: ";
switch (orderDely[i].deliveryinfo.pay)
{
case 0:
cout<<" Efectivo\n";
break;
case 1:cout<<" Tarjeta\n";
break;
}
cout<<"Telefono: "<<orderDely[i].deliveryaddress.cellphone<<endl;
cout<<"********************************\n";
}
}
else
{
cout<<"No hay ordenes a domicilio.\n";
}
return;
}
void showhouse(){
if(!orderRest.size()==0){ //mientras mi lista no este vacia//
for (int i = 0; i < orderRest.size(); i++)
{
cout<<"********************************\n";//muestro los campos de mi primer puesto en la lista y si hay mas continuo//
cout<<"Nombre del cliente: "<<orderRest[i].houseinfo.name<<endl;
cout<<"Numero de comensales; "<<orderRest[i].ptable<<endl;
cout<<"Plato principal: ";
switch (orderRest[i].houseinfo.pdish) //vero que num es//
{
case 0:
cout<<" Pizza";
break;
case 1: cout<<" Pasta";
break;
case 2: cout<<" Lasagna"; break;
}
cout<<" ";
cout<<endl;
cout<<"Entrada principal: ";
switch (orderRest[i].houseinfo.pdentrance)
{
case 0:
cout<<" Pan con ajo";
break;
case 1: cout<<" Pizza rolls";
break;
case 2: cout<<" Cheese sticks"; break;
}
cout<<" ";
cout<<endl;
cout<<"Bebida: ";
switch (orderRest[i].houseinfo.pdrink)
{
case 0:
cout<<" Cerveza";
break;
case 1: cout<<" Soda";
break;
case 2: cout<<" Te"; break;
}
cout<<" ";
cout<<endl;
cout<<"Id order: "<<orderRest[i].houseinfo.iDorder<<endl;
cout<<"Monto: "<<orderRest[i].houseinfo.total<<"$"<<endl;
cout<<"Metodo de pago: ";
switch (orderRest[i].houseinfo.pay)
{
case 0:
cout<<" Efectivo\n";
break;
case 1:cout<<" Tarjeta\n";
break;
}
cout<<"********************************\n";
}
}
else
{
cout<<"No hay ordenes a restaurante.\n";
}
return;
}
void despachdely(){ //guardo todo los campos de mi primer puesto en mi lista a domicilio en una campo difernete de mi struct//
Dd.despach.name=orderDely[0].deliveryinfo.name;
Dd.despach02.settlement=orderDely[0].deliveryaddress.settlement;
Dd.despach02.municipality=orderDely[0].deliveryaddress.municipality;
Dd.despach02.department=orderDely[0].deliveryaddress.department;
Dd.despach.pdish=orderDely[0].deliveryinfo.pdish;
Dd.despach.pdentrance=orderDely[0].deliveryinfo.pdentrance;
Dd.despach.pdrink=orderDely[0].deliveryinfo.pdrink;
Dd.despach.pay=orderDely[0].deliveryinfo.pay;
Dd.despach.total=orderDely[0].deliveryinfo.total;
Dd.despach02.cellphone=orderDely[0].deliveryaddress.cellphone;
despadely.insert(despadely.end(),Dd); //meto mi nuevo campo en una lista de despacho a domicilio//
orderDely.erase(orderDely.begin());//borro el primer puesto de mi lista a domicilio//
cout<<"Oreden despachada\n";
return;
}
void despachrest(){ //guardo todo los campos de mi primer puesto en mi lista a restaurante en una campo difernete de mi struct//
Dr.despach03.name=orderRest[0].houseinfo.name;
Dr.ptable02=orderRest[0].ptable;
Dr.despach03.pdish=orderRest[0].houseinfo.pdish;
Dr.despach03.pdentrance=orderRest[0].houseinfo.pdentrance;
Dr.despach03.pdrink=orderRest[0].houseinfo.pdrink;
Dr.despach03.pay=orderRest[0].houseinfo.pay;
Dr.despach03.total=orderRest[0].houseinfo.total;
desparest.insert(desparest.end(),Dr); //meto mi nuevo campo en una lista de despacho a restaurante//
orderRest.erase(orderRest.begin()); //borro el primer puesto de mi lista a restaurante//
cout<<"Oreden despachada\n";
return;
}
int timeDely(){
float timedely;
int cont=0,a=0;
if(orderDely.size()!=0){
for (int i = 0; i < orderDely.size(); i++) //calculo las ordenes que tengo a domicilio//
{
cont++;
}
timedely=((cont*1.10)+(cont*1.5)+(cont*1.35))+15;//calculo el tiempo por cada orden//
a=static_cast<int>(timedely);//transformo mi flotante a entero//
}
return a;
}
int timeRest(){
float timerest=0;
int cont=0;
int b=0;
if (orderRest.size()!=0)
{
for (int i = 0; i < orderRest.size(); i++) //calculo las ordenes que tengo a restaurante//
{
cont++;
}
timerest=((cont*1.10)+(cont*1.5)+(cont*1.35)); //calculo el tiempo por cada orden//
b=static_cast<int>(timerest); //transformo mi flotante a entero//
}
return b;
}
void erase(){
int n;
cout<<"Ingrese el Id de orden a eliminar: "; cin>>n; cin.ignore();//busco el id de la orden a eliminar//
for (auto iter = orderDely.begin(); iter !=orderDely.end(); ++iter)//elimino la orden//
{
if ((*iter).deliveryinfo.iDorder==n)
{
iter=orderDely.erase(iter);
cout<<"Orden eliminada.\n";
break;
}
else
{
}
}
for (auto iter = orderRest.begin(); iter !=orderRest.end(); ++iter)
{
if ((*iter).houseinfo.iDorder==n)
{
iter=orderRest.erase(iter);
cout<<"Orden eliminada.\n";
break;
}
else
{
cout<<"Orden no encontrada\n";
}
}
return;
}
double total(){
double total=0,iva=0;
for (int i = 0; i < despadely.size(); i++)//recorro mi lista a domicilio//
{
iva=(iva+despadely[i].despach.total)+((despadely[i].despach.total*13)/100);//calculo el monto mas el iva//
total=total+iva; //la guardo en una variable a retornar//
}
for (int i = 0; i < desparest.size(); i++)//recorro mi lista a restaurante//
{
iva=(iva+desparest[i].despach03.total)+((desparest[i].despach03.total*13)/100);//calculo el monto mas el iva//
total=total+iva; //la guardo en una variable a retornar//
}
return total;
} |
df46f969753355937bd6b8258e1315fd899dc799 | 2c63c061d5e55f5cf134a44ffcfb0a9c2d92b826 | /libssco/shift_close.cpp | ac6b3ee4d1a69be93b00709b2697532733fee74e | [] | no_license | axisd/fnsapp | 40be8c606596707c459036da3ecf099aaa590fd3 | 9d98d6b150bd0e59c1bbebf9491e3562514e5b65 | refs/heads/master | 2021-01-16T18:43:16.105594 | 2014-12-23T07:06:19 | 2014-12-23T07:06:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,477 | cpp | shift_close.cpp | #include "shift_close.h"
using namespace SSCO;
ShiftClose::ShiftClose() : SaxSerializerBase("ShiftClose")
{
}
void ShiftClose::serialize (QXmlStreamWriter& __writer)
{
writeTag(__writer, "id", m_id);
writeTag(__writer, "date", m_date);
writeOptional(__writer, "kkm_shift_number", m_kkm_shift_number);
writeTag(__writer, "kkm_serial_number", m_kkm_serial_number);
writeTag(__writer, "kkm_registration_number", m_kkm_registration_number);
writeTag(__writer, "kkm_owner_number", m_kkm_owner_number);
writeTag(__writer, "eklz_number", m_eklz_number);
writeOptional(__writer, "eklz_date_activate", m_eklz_date_activate);
writeOptional(__writer, "eklz_fast_full", m_eklz_fast_full);
writeTag(__writer, "kkm_model_name", m_kkm_model_name);
writeTag(__writer, "uploaded", m_uploaded);
}
void ShiftClose::deserialize (QXmlStreamReader& __reader)
{
readTag(__reader, "id", m_id);
readTag(__reader, "date", m_date);
readOptional(__reader, "kkm_shift_number", m_kkm_shift_number);
readTag(__reader, "kkm_serial_number", m_kkm_serial_number);
readTag(__reader, "kkm_registration_number", m_kkm_registration_number);
readTag(__reader, "kkm_owner_number", m_kkm_owner_number);
readTag(__reader, "eklz_number", m_eklz_number);
readOptional(__reader, "eklz_date_activate", m_eklz_date_activate);
readOptional(__reader, "eklz_fast_full", m_eklz_fast_full);
readTag(__reader, "kkm_model_name", m_kkm_model_name);
readTag(__reader, "uploaded", m_uploaded);
}
|
e7cf2db9d3270ebd6b0bcc3c4dfcd45493763b09 | b0df00fc7be37493eb282a1693f7facc534166be | /main.cpp | 62011836205f2f9a15cf3f126a8ba6a0e286f097 | [] | no_license | mic0331/PFMCPP_Project6 | 8921338786ad04b17acbc9f68165c9ee5fef5b3c | 5614ab33c75a50e332bea150becde260f8f073a9 | refs/heads/master | 2023-08-25T02:32:15.478169 | 2021-10-06T21:58:43 | 2021-10-06T21:58:43 | 411,501,282 | 0 | 0 | null | 2021-10-06T08:24:55 | 2021-09-29T02:16:14 | C++ | UTF-8 | C++ | false | false | 3,467 | cpp | main.cpp | /*
Project 6: Part 2 / 2
Video: Chapter 3 Part 3
Create a branch named Part2
References
1) convert the pointer usage (except for 'const char*') to reference types or
const reference types **>>> WHERE POSSIBLE <<<**
Not every pointer can be converted.
hint: There is no reference equivalent to nullptr.
if a pointer (including nullptr) is being returned anywhere, don't try to convert it to a reference.
You have to ask yourself if each pointer can be converted to a (const) reference.
Think carefully when making your changes.
2) After you finish, click the [run] button. Clear up any errors or warnings as best you can.
*/
#include <iostream>
#include <string>
struct T
{
T(int v, const char* p); //1
//2
int value;
//3
std::string name;
};
T::T(int v, const char* p): value(v), name(p) {}
struct Comparator //4
{
T* compare(T& a, T& b) //5
{
if( a.value < b.value ) return &a;
if( a.value > b.value ) return &b;
return nullptr;
}
};
struct U
{
float x { 0 }, y{ 0 };
float computeDistance(const float& xUpdated) //12
{
std::cout << "U's x value: " << this->x << std::endl;
this->x = xUpdated;
std::cout << "U's y updated value: " << this->x << std::endl;
while( std::abs( this->y - this->x ) > 0.001f )
{
this->y += .1f;
}
std::cout << "U's computeDistance updated value: " << this->y << std::endl;
return this->y * this->x;
}
};
struct StaticU
{
static float computeDistance(U& that, const float& xUpdated ) //10
{
std::cout << "U's x value: " << that.x << std::endl;
that.x = xUpdated;
std::cout << "U's y updated value: " << that.x << std::endl;
while( std::abs( that.y - that.x ) > 0.001f )
{
/*
write something that makes the distance between that->yand that->x get smaller
*/
that.y += .1f;
}
std::cout << "U's computeDistance updated value: " << that.y << std::endl;
return that.y * that.x;
}
};
/*
MAKE SURE YOU ARE NOT ON THE MASTER BRANCH
Commit your changes by clicking on the Source Control panel on the left, entering a message, and click [Commit and push].
If you didn't already:
Make a pull request after you make your first commit
pin the pull request link and this repl.it link to our DM thread in a single message.
send me a DM to review your pull request when the project is ready for review.
Wait for my code review.
*/
int main()
{
T t1(6, "value 6"); //6
T t2(8, "value 8"); //6
Comparator f; //7
auto* smaller = f.compare(t1, t2); //8
if(smaller != nullptr)
std::cout << "the smaller one is << " << smaller->name << std::endl; //9
std::cout << "Non allocated pointer" << std::endl; //9
U distance1;
float updatedValue = 5.f;
std::cout << "[static func] distance1's multiplied values: " << StaticU::computeDistance(distance1, updatedValue) << std::endl; //11
U distance2;
std::cout << "[member func] distance2's multiplied values: " << distance2.computeDistance( updatedValue ) << std::endl;
}
|
b8fa077bd7d7ce3b15d69681376e26c30db6f436 | ce0539b7bff12d88fba5df4beed41c7315aed16e | /Engine/Pipeline/GaussianBlurEffect.cpp | a6a992b6198fddb6cd666798f71b4a393b88de76 | [] | no_license | wppr/Source | a87c1bdb790747b06e6156a72968ff238a7ce771 | eaad33c0149399001eb15f833c7fc3d189c77941 | refs/heads/master | 2020-07-10T18:02:15.766930 | 2016-10-30T11:34:28 | 2016-10-30T11:34:28 | 66,618,626 | 1 | 1 | null | 2016-08-26T07:31:24 | 2016-08-26T05:15:55 | C++ | UTF-8 | C++ | false | false | 1,625 | cpp | GaussianBlurEffect.cpp | #include "GaussianBlurEffect.h"
#include "RenderTarget.h"
#include "SceneManager.h"
#include "engine_struct.h"
#include "ResourceManager.h"
#include "pass.h"
#include "RenderSystem.h"
#include "TextureManager.h"
void GaussianBlurEffect::Init()
{
auto& rt_mgr = RenderTargetManager::getInstance();
auto& tm = TextureManager::getInstance();
auto& pm = PassManager::getInstance();
mRenderSystem = GlobalResourceManager::getInstance().m_RenderSystem;
string presetname = BlurFloatTexture ? "basic_float" : "basic";
blur1 = rt_mgr.CreateRenderTargetFromPreset(presetname, "effect_blur1");
blur2 = rt_mgr.CreateRenderTargetFromPreset(presetname, "effect_blur2");
blur_pass = pm.LoadPass("blur_prog.json");
blur1_texture=blur1->m_attach_textures["color0"];
out_blur = blur2->m_attach_textures["color0"];
}
void GaussianBlurEffect::Render()
{
//get a screen quad
auto quad = GlobalResourceManager::getInstance().as_meshManager.get("ScreenQuad.obj");
RenderQueueItem item;
item.asMesh = quad;
RenderQueue queue2;
queue2.push_back(item);
auto p = blur_pass->mProgram;
Vector2 a(1.0, 0), b(0, 1.0);
p->setProgramConstantData("u_texture", input_color);
p->setSampler("u_texture", SamplerManager::getInstance().get("ClampLinear"));
p->setProgramConstantData("dir", &a, "vec2", sizeof(Vector2));
p->setProgramConstantData("radius", &radius, "float", sizeof(float));
mRenderSystem->RenderPass(NULL, queue2, blur_pass, blur1);
p->setProgramConstantData("u_texture", blur1_texture);
p->setProgramConstantData("dir", &b, "vec2", sizeof(Vector2));
mRenderSystem->RenderPass(NULL, queue2, blur_pass, blur2);
}
|
7ac29e01cdf416b38ba07512290a6e04293213b2 | 635c344550534c100e0a86ab318905734c95390d | /wpimath/src/test/native/cpp/geometry/Transform2dTest.cpp | 1b0934d6ca0b39cf8fbe83549ad78dcef141c6e8 | [
"BSD-3-Clause"
] | permissive | wpilibsuite/allwpilib | 2435cd2f5c16fb5431afe158a5b8fd84da62da24 | 8f3d6a1d4b1713693abc888ded06023cab3cab3a | refs/heads/main | 2023-08-23T21:04:26.896972 | 2023-08-23T17:47:32 | 2023-08-23T17:47:32 | 24,655,143 | 986 | 769 | NOASSERTION | 2023-09-14T03:51:22 | 2014-09-30T20:51:33 | C++ | UTF-8 | C++ | false | false | 1,881 | cpp | Transform2dTest.cpp | // Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <cmath>
#include "frc/geometry/Pose2d.h"
#include "frc/geometry/Rotation2d.h"
#include "frc/geometry/Transform2d.h"
#include "frc/geometry/Translation2d.h"
#include "gtest/gtest.h"
using namespace frc;
TEST(Transform2dTest, Inverse) {
const Pose2d initial{1_m, 2_m, 45_deg};
const Transform2d transform{{5_m, 0_m}, 5_deg};
auto transformed = initial + transform;
auto untransformed = transformed + transform.Inverse();
EXPECT_EQ(initial, untransformed);
}
TEST(Transform2dTest, Composition) {
const Pose2d initial{1_m, 2_m, 45_deg};
const Transform2d transform1{{5_m, 0_m}, 5_deg};
const Transform2d transform2{{0_m, 2_m}, 5_deg};
auto transformedSeparate = initial + transform1 + transform2;
auto transformedCombined = initial + (transform1 + transform2);
EXPECT_EQ(transformedSeparate, transformedCombined);
}
TEST(Transform2dTest, Constexpr) {
constexpr Transform2d defaultCtor;
constexpr Transform2d translationRotationCtor{Translation2d{},
Rotation2d{10_deg}};
constexpr auto multiplied = translationRotationCtor * 5;
constexpr auto divided = translationRotationCtor / 2;
static_assert(defaultCtor.Translation().X() == 0_m);
static_assert(translationRotationCtor.X() == 0_m);
static_assert(translationRotationCtor.Y() == 0_m);
static_assert(multiplied.Rotation().Degrees() == 50_deg);
static_assert(translationRotationCtor.Inverse().Rotation().Degrees() ==
(-10_deg));
static_assert(translationRotationCtor.Inverse().X() == 0_m);
static_assert(translationRotationCtor.Inverse().Y() == 0_m);
static_assert(divided.Rotation().Degrees() == 5_deg);
}
|
72aac3177de9692e575f5952ea582bfeb4ac692a | 0edf993888543e9279214ac8b4a2970f2e2e7be3 | /dp-06/decorator_1.5.cpp | e8c2ac123488de3e2500f14f35e06046c59952d6 | [] | no_license | JeffYoung17/DesignPattern | 248da7799c8b590ac3049cd12fc8e1ab6e32869e | 36281c42fb81202f78aed30eca1bfc86933d1de3 | refs/heads/master | 2023-04-20T16:50:14.365862 | 2021-03-31T13:11:30 | 2021-03-31T13:11:30 | 346,646,767 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,491 | cpp | decorator_1.5.cpp | //业务操作
class Stream{
public:
virtual char Read(int number)=0;
virtual void Seek(int position)=0;
virtual void Write(char data)=0;
virtual ~Stream(){}
};
//主体类
class FileStream: public Stream{
public:
virtual char Read(int number){
//读文件流
}
virtual void Seek(int position){
//定位文件流
}
virtual void Write(char data){
//写文件流
}
};
class NetworkStream :public Stream{
public:
virtual char Read(int number){
//读网络流
}
virtual void Seek(int position){
//定位网络流
}
virtual void Write(char data){
//写网络流
}
};
class MemoryStream :public Stream{
public:
virtual char Read(int number){
//读内存流
}
virtual void Seek(int position){
//定位内存流
}
virtual void Write(char data){
//写内存流
}
};
//扩展操作
// Optx代表优化的步骤x
// 通过Opt1和Opt2以后发现CryptoFileStream/BufferedFileStream的类体完全相同
// 则Opt3为:
class CryptoStream : public Stream {
Stream* stream;
}
/**
* 相当于File,Network和Memory三个流类是通过组合的方式
* 放到了Crypto,Buffered两种功能的流类里面
* 同时这两个流类还是需要继承Stream基类,保留流类本身的接口规范
*/
class CryptoFileStream { //Opt1 :public FileStream{
public:
// !!!用组合替代继承
// Opt2: FileStream* stream;
// !!! 编译时一样, 运行时(未来)不一样
Stream* stream; // 未来: =new FileStream();
virtual char Read(int number){
//额外的加密操作...
// Opt1: FileStream::Read(number);//读文件流
stream->Read(number);
}
virtual void Seek(int position){
//额外的加密操作...
// Opt1: FileStream::Seek(position);//定位文件流
//额外的加密操作...
stream->Seek(position);
}
virtual void Write(byte data){
//额外的加密操作...
// Opt1: FileStream::Write(data);//写文件流
//额外的加密操作...
stream->Write(data);
}
};
class CryptoNetworkStream { // Opt1: public NetworkStream{
public:
// !!!用组合替代继承
// Opt2: NetworkStream* stream;
Stream* stream; // = new NetworkStream();
virtual char Read(int number){
//额外的加密操作...
// Opt1: NetworkStream::Read(number);//读网络流
stream->Read(number);
}
virtual void Seek(int position){
//额外的加密操作...
// Opt1: NetworkStream::Seek(position);//定位网络流
//额外的加密操作...
stream->Seek(position);
}
virtual void Write(byte data){
//额外的加密操作...
// Opt1: NetworkStream::Write(data);//写网络流
//额外的加密操作...
stream->Write(data);
}
};
class CryptoMemoryStream { // Opt1: public MemoryStream{
public:
// Opt2: MemoryStream* stream;
Stream* stream; // = new MemoryStream();
virtual char Read(int number){
//额外的加密操作...
// Opt1: MemoryStream::Read(number);//读内存流
stream->Read(number);
}
virtual void Seek(int position){
//额外的加密操作...
// Opt1: MemoryStream::Seek(position);//定位内存流
//额外的加密操作...
stream->Seek(position);
}
virtual void Write(byte data){
//额外的加密操作...
// Opt1: MemoryStream::Write(data);//写内存流
//额外的加密操作...
stream->Write(data);
}
};
class BufferedFileStream : public FileStream{
//...
};
class BufferedNetworkStream : public NetworkStream{
//...
};
class BufferedMemoryStream : public MemoryStream{
//...
}
class CryptoBufferedFileStream :public FileStream{
public:
virtual char Read(int number){
//额外的加密操作...
//额外的缓冲操作...
FileStream::Read(number);//读文件流
}
virtual void Seek(int position){
//额外的加密操作...
//额外的缓冲操作...
FileStream::Seek(position);//定位文件流
//额外的加密操作...
//额外的缓冲操作...
}
virtual void Write(byte data){
//额外的加密操作...
//额外的缓冲操作...
FileStream::Write(data);//写文件流
//额外的加密操作...
//额外的缓冲操作...
}
};
void Process(){
// 运行时装配
// CryptoFileStream *fs1 = new CryptoFileStream();
// 需要构造器去初始化CryptoStream中的"多态"Stream* stream
FileStream* s1 = new FileStream();
CryptoStream* s2 = new CryptoStream(s1);
// BufferedFileStream *fs2 = new BufferedFileStream();
BufferedStream* s3 = new BufferStream(s1);
// CryptoBufferedFileStream *fs3 =new CryptoBufferedFileStream();
// 套娃: 此处传入的s2是一个加密文件流对象,再传给BufferedStream的Stream,功能叠加!!!
BufferedStream* s4 = new BufferedStream(s2);
// 编译时不存在加密文件流,缓存文件流,而是在运行时通过组合的方式进行装配
} |
c26efd9877fc6552a88ba1ffe37d081ff08bf4c5 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_2645486_0/C++/Ginkgobiloba/b1.cpp | 374864613862b3a0a53bdc28049cfbd175737081 | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 1,009 | cpp | b1.cpp | #include <iostream>
using namespace std;
int v[100];
int s[50][50];
int main()
{
int e, r, n, t;
cin>>t;
for(int a=1; a<=t; ++a)
{
cin>>e>>r>>n;
for(int i=1; i<=n; ++i)
cin>>v[i];
for(int i=0; i<=e; ++i)
s[0][i]=0;
for(int i=1; i<=n; ++i)
{
for(int j=0; j<=e; ++j)
s[i][j]=-1;
for(int j=0; j<=e; ++j)
if(s[i-1][j]!=-1)
{
for(int k=0; k<=j; ++k)
{
int t=s[i-1][j]+k*v[i];
int tt=j-k+r;
if(tt>e) tt=e;
if(s[i][tt]==-1||s[i][tt]<t)
s[i][tt]=t;
}
}
}
int max=-1;
for(int i=0; i<=e; ++i)
max=max>s[n][i]?max:s[n][i];
cout<<"Case #"<<a<<": "<<max<<endl;
}
return 0;
}
|
1e34f522068d6b7866631adcf4644dde9f51fca3 | 0006f89c8d952bcf14a6150e9c26c94e47fab040 | /src/trace/DXInterceptor/dxtraceman/DXBuffer.cpp | 217edb90a55a38b4a7a95162a1434041aa43de23 | [
"BSD-3-Clause"
] | permissive | cooperyuan/attila | eceb5d34b8c64c53ffcc52cd96b684d4f88b706f | 29a0ceab793b566c09cf81af26263e4855842c7a | refs/heads/master | 2016-09-05T18:55:56.472248 | 2013-06-29T14:42:02 | 2013-06-29T14:42:02 | 10,222,034 | 8 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 12,331 | cpp | DXBuffer.cpp | ////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CRC32.h"
#include "MD5.h"
#include "DXTypeHelper.h"
#include "DXFileManagerBase.h"
#include "DXBuffer.h"
using namespace dxtraceman;
////////////////////////////////////////////////////////////////////////////////
#define POP_BUFFER_MACRO(type) \
bool DXBuffer::Pop_##type(char** ptr) \
{ \
*ptr = &m_data[sizeof(char)]; \
return true; \
}
////////////////////////////////////////////////////////////////////////////////
#define PUSH_BUFFER_MACRO(type) \
bool DXBuffer::Push_##type(const type##* value) \
{ \
return BufferWrite((const char*) value, sizeof(##type), DXTypeHelper::TT_##type); \
}
////////////////////////////////////////////////////////////////////////////////
#define BUFFER_MACRO(type) \
POP_BUFFER_MACRO(type) \
PUSH_BUFFER_MACRO(type)
////////////////////////////////////////////////////////////////////////////////
DXBuffer::DXBuffer() :
m_mustFreeData(false),
m_data(NULL)
{
Clear();
}
////////////////////////////////////////////////////////////////////////////////
DXBuffer::~DXBuffer()
{
Clear();
}
////////////////////////////////////////////////////////////////////////////////
void DXBuffer::Clear()
{
m_type = DXTypeHelper::TT_DummyType;
m_size = 0;
if (m_mustFreeData && m_data)
{
delete[] m_data;
m_data = NULL;
}
m_mustFreeData = false;
}
////////////////////////////////////////////////////////////////////////////////
DXTypeHelper::DXTypeType DXBuffer::GetType() const
{
return m_type;
}
////////////////////////////////////////////////////////////////////////////////
void DXBuffer::SetType(DXTypeHelper::DXTypeType type)
{
m_type = type;
}
////////////////////////////////////////////////////////////////////////////////
unsigned int DXBuffer::GetSize() const
{
return m_size;
}
////////////////////////////////////////////////////////////////////////////////
unsigned int DXBuffer::GetSerializedSize() const
{
return sizeof(char) + m_size;
}
////////////////////////////////////////////////////////////////////////////////
unsigned int DXBuffer::GetCRC32()
{
unsigned int crc32 = 0x00000000;
if (m_mustFreeData)
{
crc32 = CRC32::Calculate(m_data, sizeof(char) + m_size);
}
else
{
crc32 = CRC32::Calculate((const char*) &m_type, sizeof(char));
crc32 = CRC32::Calculate(m_data, m_size, crc32);
}
return crc32;
}
////////////////////////////////////////////////////////////////////////////////
void DXBuffer::GetMD5(unsigned char* md5_hash)
{
MD5::md5_t md5;
if (m_mustFreeData)
{
MD5::Calculate((const unsigned char*) m_data, sizeof(char) + m_size, md5.value);
}
else
{
MD5::Init();
MD5::Update((const unsigned char*) &m_type, sizeof(char));
MD5::Update((const unsigned char*) m_data, m_size);
MD5::Finalize();
MD5::GetMD5(md5.value);
}
memcpy(md5_hash, md5.value, sizeof(md5.value));
}
////////////////////////////////////////////////////////////////////////////////
bool DXBuffer::SerializeToFile(DXFileManagerBase* file)
{
#ifdef _DEBUG
if (m_type == DXTypeHelper::TT_DummyType)
{
return false;
}
#endif // ifdef _DEBUG
if (!file->Write((char*) &m_type, sizeof(char)))
{
return false;
}
return file->Write((m_mustFreeData ? &m_data[sizeof(char)] : m_data), m_size);
}
////////////////////////////////////////////////////////////////////////////////
bool DXBuffer::DeserializeFromFile(DXFileManagerBase* file, unsigned int size)
{
#ifdef _DEBUG
if (size <= sizeof(char))
{
return false;
}
#endif // ifdef _DEBUG
Clear();
m_data = new char[size];
if (!m_data)
{
return false;
}
m_mustFreeData = true;
m_size = size - sizeof(char);
if (file->Read(m_data, size))
{
memcpy(&m_type, m_data, sizeof(char));
return true;
}
else
{
return false;
}
}
////////////////////////////////////////////////////////////////////////////////
bool DXBuffer::SerializeToBuffer(char* buffer, unsigned int* size)
{
#ifdef _DEBUG
if (m_type == DXTypeHelper::TT_DummyType)
{
return false;
}
if (!buffer || *size < GetSerializedSize())
{
return false;
}
#endif // ifdef _DEBUG
if (m_mustFreeData)
{
memcpy(buffer, m_data, GetSerializedSize());
}
else
{
memcpy(buffer, (const char*) m_type, sizeof(char));
memcpy(&buffer[sizeof(char)], m_data, m_size);
}
*size = GetSerializedSize();
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool DXBuffer::DeserializeFromBuffer(const char* buffer, unsigned int size)
{
#ifdef _DEBUG
if (size <= sizeof(DXTypeHelper::DXTypeType))
{
return false;
}
#endif // ifdef _DEBUG
Clear();
m_data = new char[size];
if (!m_data)
{
return false;
}
m_mustFreeData = true;
m_size = size - sizeof(char);
memcpy(m_data, buffer, size);
memcpy(&m_type, m_data, sizeof(char));
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool DXBuffer::BufferRead(char* buffer, unsigned int& size)
{
if (size)
{
memcpy(buffer, (const char*) &m_data[sizeof(char)], m_size);
size = m_size;
return true;
}
else
{
return false;
}
}
////////////////////////////////////////////////////////////////////////////////
bool DXBuffer::BufferWrite(const char* buffer, unsigned int size, DXTypeHelper::DXTypeType type)
{
Clear();
m_type = type;
m_data = (char*) buffer;
m_size = size;
m_mustFreeData = false;
return true;
}
////////////////////////////////////////////////////////////////////////////////
POP_BUFFER_MACRO(DXRawData);
bool DXBuffer::Push_DXRawData(const void* buffer, unsigned int size)
{
return BufferWrite((const char*) buffer, size, DXTypeHelper::TT_DXRawData);
}
////////////////////////////////////////////////////////////////////////////////
unsigned int DXBuffer::CalculateSize_ARR_D3DVERTEXELEMENT9(const D3DVERTEXELEMENT9* value)
{
if (!value)
{
return 0;
}
D3DVERTEXELEMENT9 end = D3DDECL_END();
unsigned int size = 0;
while (memcmp(&value[size], &end, sizeof(end)))
{
size++;
}
return sizeof(D3DVERTEXELEMENT9)*(size+1);
}
////////////////////////////////////////////////////////////////////////////////
POP_BUFFER_MACRO(ARR_D3DVERTEXELEMENT9);
bool DXBuffer::Push_ARR_D3DVERTEXELEMENT9(const D3DVERTEXELEMENT9* value)
{
return BufferWrite((const char*) value, CalculateSize_ARR_D3DVERTEXELEMENT9(value), DXTypeHelper::TT_ARR_D3DVERTEXELEMENT9);
}
////////////////////////////////////////////////////////////////////////////////
unsigned int DXBuffer::CalculateSize_ARR_RGNDATA(const RGNDATA* value)
{
if (!value)
{
return 0;
}
RGNDATAHEADER header;
memcpy(&header, (const char*) value, sizeof(RGNDATAHEADER));
return sizeof(RGNDATAHEADER) + header.nRgnSize;
}
////////////////////////////////////////////////////////////////////////////////
POP_BUFFER_MACRO(ARR_RGNDATA);
bool DXBuffer::Push_ARR_RGNDATA(const RGNDATA* value)
{
return BufferWrite((const char*) value, CalculateSize_ARR_RGNDATA(value), DXTypeHelper::TT_ARR_RGNDATA);
}
////////////////////////////////////////////////////////////////////////////////
POP_BUFFER_MACRO(ARR_D3DRECT);
bool DXBuffer::Push_ARR_D3DRECT(const D3DRECT* value, UINT count)
{
return BufferWrite((const char*) value, count*sizeof(D3DRECT), DXTypeHelper::TT_ARR_D3DRECT);
}
////////////////////////////////////////////////////////////////////////////////
unsigned int DXBuffer::CalculateSize_ARR_DRAWPRIMITIVEUP(D3DPRIMITIVETYPE primitiveType, UINT primitiveCount, UINT vertexStride)
{
unsigned int numVertex = 0;
switch (primitiveType)
{
case D3DPT_POINTLIST:
numVertex = primitiveCount;
break;
case D3DPT_LINELIST:
numVertex = primitiveCount*2;
break;
case D3DPT_LINESTRIP:
numVertex = primitiveCount*2 + 1;
break;
case D3DPT_TRIANGLELIST:
numVertex = primitiveCount*3;
break;
case D3DPT_TRIANGLESTRIP:
numVertex = primitiveCount + 2;
break;
case D3DPT_TRIANGLEFAN:
numVertex = primitiveCount + 2;
break;
}
return numVertex * vertexStride;
}
////////////////////////////////////////////////////////////////////////////////
POP_BUFFER_MACRO(ARR_DRAWPRIMITIVEUP);
bool DXBuffer::Push_ARR_DRAWPRIMITIVEUP(const void* value, D3DPRIMITIVETYPE primitiveType, UINT primitiveCount, UINT vertexStride)
{
return BufferWrite((const char*) value, CalculateSize_ARR_DRAWPRIMITIVEUP(primitiveType, primitiveCount, vertexStride), DXTypeHelper::TT_ARR_DRAWPRIMITIVEUP);
}
////////////////////////////////////////////////////////////////////////////////
POP_BUFFER_MACRO(ARR_DRAWINDEXEDPRIMITIVEUPINDICES);
bool DXBuffer::Push_ARR_DRAWINDEXEDPRIMITIVEUPINDICES(const void* value, D3DPRIMITIVETYPE primitiveType, UINT primitiveCount, D3DFORMAT indexDataFormat)
{
return BufferWrite((const char*) value, CalculateSize_ARR_DRAWPRIMITIVEUP(primitiveType, primitiveCount, (indexDataFormat == D3DFMT_INDEX16 ? 2 : 4)), DXTypeHelper::TT_ARR_DRAWINDEXEDPRIMITIVEUPINDICES);
}
////////////////////////////////////////////////////////////////////////////////
POP_BUFFER_MACRO(ARR_DRAWINDEXEDPRIMITIVEUPVERTICES);
bool DXBuffer::Push_ARR_DRAWINDEXEDPRIMITIVEUPVERTICES(const void* value, UINT minVertexIndex, UINT numVertices, UINT vertexStreamZeroStride)
{
return BufferWrite((const char*) value, (minVertexIndex+numVertices)*vertexStreamZeroStride, DXTypeHelper::TT_ARR_DRAWINDEXEDPRIMITIVEUPVERTICES);
}
////////////////////////////////////////////////////////////////////////////////
unsigned int DXBuffer::CalculateSize_ARR_SHADERFUNCTIONTOKEN(const DWORD* value)
{
if (!value)
{
return 0;
}
DWORD length = 1;
while (*value != 0x0000FFFF)
{
if ((*value & D3DSI_OPCODE_MASK) == D3DSIO_COMMENT)
{
DWORD commentLength;
commentLength = (*value & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT;
length += commentLength;
value += commentLength;
}
length++;
value++;
}
return length*4;
}
////////////////////////////////////////////////////////////////////////////////
POP_BUFFER_MACRO(ARR_SHADERFUNCTIONTOKEN);
bool DXBuffer::Push_ARR_SHADERFUNCTIONTOKEN(const DWORD* value)
{
return BufferWrite((const char*) value, CalculateSize_ARR_SHADERFUNCTIONTOKEN(value), DXTypeHelper::TT_ARR_SHADERFUNCTIONTOKEN);
}
////////////////////////////////////////////////////////////////////////////////
POP_BUFFER_MACRO(ARR_SHADERCONSTANTBOOL);
bool DXBuffer::Push_ARR_SHADERCONSTANTBOOL(const BOOL* value, UINT count)
{
return BufferWrite((const char*) value, count*sizeof(BOOL), DXTypeHelper::TT_ARR_SHADERCONSTANTBOOL);
}
////////////////////////////////////////////////////////////////////////////////
POP_BUFFER_MACRO(ARR_SHADERCONSTANTFLOAT);
bool DXBuffer::Push_ARR_SHADERCONSTANTFLOAT(const float* value, UINT count)
{
return BufferWrite((const char*) value, count*4*sizeof(float), DXTypeHelper::TT_ARR_SHADERCONSTANTFLOAT);
}
////////////////////////////////////////////////////////////////////////////////
POP_BUFFER_MACRO(ARR_SHADERCONSTANTINT);
bool DXBuffer::Push_ARR_SHADERCONSTANTINT(const int* value, UINT count)
{
return BufferWrite((const char*) value, count*4*sizeof(int), DXTypeHelper::TT_ARR_SHADERCONSTANTINT);
}
////////////////////////////////////////////////////////////////////////////////
POP_BUFFER_MACRO(ARR_SETCLIPPLANE);
bool DXBuffer::Push_ARR_SETCLIPPLANE(const float* value)
{
return BufferWrite((const char*) value, 4*sizeof(float), DXTypeHelper::TT_ARR_SETCLIPPLANE);
}
////////////////////////////////////////////////////////////////////////////////
POP_BUFFER_MACRO(ARR_PALETTEENTRY);
bool DXBuffer::Push_ARR_PALETTEENTRY(const PALETTEENTRY* value)
{
return BufferWrite((const char*) value, 256*sizeof(PALETTEENTRY), DXTypeHelper::TT_ARR_PALETTEENTRY);
}
////////////////////////////////////////////////////////////////////////////////
BUFFER_MACRO(D3DPRESENT_PARAMETERS);
BUFFER_MACRO(D3DLIGHT9);
BUFFER_MACRO(D3DMATRIX);
BUFFER_MACRO(D3DMATERIAL9);
BUFFER_MACRO(D3DVIEWPORT9);
BUFFER_MACRO(D3DGAMMARAMP);
////////////////////////////////////////////////////////////////////////////////
|
b0a6f06d77f377e138539ccbf752f35aea48a08f | 64ba3317082921cc483c5273e9f051b4c0134e80 | /src/main.cpp | 13ae3d59eaac6e6f496d28deaa0863c85d75b5d8 | [] | no_license | MrShedman/spectrum_teensy | 441408d1c05b5f9301ea29062816b3fedba59dd3 | feba384a9d60774b3051da6b56c8d72dc27f1d78 | refs/heads/master | 2020-04-07T23:37:21.933720 | 2018-11-24T13:19:46 | 2018-11-24T13:19:46 | 158,819,406 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,982 | cpp | main.cpp |
// FFT Test
//
// Compute a 1024 point Fast Fourier Transform (spectrum analysis)
// on audio connected to the Left Line-In pin. By changing code,
// a synthetic sine wave can be input instead.
//
// The first 40 (of 512) frequency analysis bins are printed to
// the Arduino Serial Monitor. Viewing the raw data can help you
// understand how the FFT works and what results to expect when
// using the data to control LEDs, motors, or other fun things!
//
// This example code is in the public domain.
// JJ test edit
#include <Arduino.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
const int myInput = AUDIO_INPUT_LINEIN;
//const int myInput = AUDIO_INPUT_MIC;
// Create the Audio components. These should be created in the
// order data flows, inputs/sources -> processing -> outputs
//
AudioInputI2S audioInput; // audio shield: mic or line-in
AudioSynthWaveformSine sinewave;
AudioAnalyzeFFT1024 myFFT;
AudioOutputI2S audioOutput; // audio shield: headphones & line-out
// Connect either the live input or synthesized sine wave
AudioConnection patchCord1(audioInput, 0, myFFT, 0);
//AudioConnection patchCord1(sinewave, 0, myFFT, 0);
AudioControlSGTL5000 audioShield;
// An array to hold the 16 frequency bands
float level[16];
void setup()
{
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(12);
// Enable the audio shield and set the output volume.
audioShield.enable();
audioShield.inputSelect(myInput);
audioShield.volume(0.5);
// Configure the window algorithm to use
myFFT.windowFunction(AudioWindowHanning1024);
//myFFT.windowFunction(NULL);
// Create a synthetic sine wave, for testing
// To use this, edit the connections above
sinewave.amplitude(0.8);
sinewave.frequency(1034.007);
}
void loop()
{
if (myFFT.available())
{
// read the 512 FFT frequencies into 16 levels
// music is heard in octaves, but the FFT data
// is linear, so for the higher octaves, read
// many FFT bins together.
level[0] = myFFT.read(0);
level[1] = myFFT.read(1);
level[2] = myFFT.read(2, 3);
level[3] = myFFT.read(4, 6);
level[4] = myFFT.read(7, 10);
level[5] = myFFT.read(11, 15);
level[6] = myFFT.read(16, 22);
level[7] = myFFT.read(23, 32);
level[8] = myFFT.read(33, 46);
level[9] = myFFT.read(47, 66);
level[10] = myFFT.read(67, 93);
level[11] = myFFT.read(94, 131);
level[12] = myFFT.read(132, 184);
level[13] = myFFT.read(185, 257);
level[14] = myFFT.read(258, 359);
level[15] = myFFT.read(360, 511);
for (uint8_t i = 0; i < 16; i++)
{
Serial.print(level[i]);
Serial.print(" ");
}
Serial.println();
}
} |
6328f671322c35063df7fd36228d9dad4f957dd5 | e4c432f43fb1711d7307a25d5bc07f64e26ae9de | /network/vnetwork/VNetwork.cpp | de7c853a296b4d32631e156eb653fc85a3d62ed5 | [] | no_license | longshadian/zylib | c456dc75470f9c6512a7d63b1182cb9eebcca999 | 9fde01c76a1c644d5daa46a645c8e1300e72c5bf | refs/heads/master | 2021-01-22T23:49:11.912633 | 2020-06-16T09:13:50 | 2020-06-16T09:13:50 | 85,669,581 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 10,512 | cpp | VNetwork.cpp | #include "stdafx.h"
#include "VNetwork.h"
namespace vnetwork
{
ChatMessage::ChatMessage()
: body_length_(),
buffer_()
{
buffer_.resize(HEADER_LENGTH);
}
ChatMessage::~ChatMessage()
{
}
void ChatMessage::Create(const std::string& data, ChatMessage* out)
{
out->body_length_ = static_cast<std::int32_t>(data.length());
out->PrepareBody(out->body_length_);
std::memcpy(out->Body(), data.data(), out->body_length_);
out->EncodeHeader();
}
void ChatMessage::Create(const void* data, std::size_t length, ChatMessage* out)
{
out->body_length_ = static_cast<std::int32_t>(length);
out->PrepareBody(out->body_length_);
std::memcpy(out->Body(), data, out->body_length_);
out->EncodeHeader();
}
const char* ChatMessage::Data() const
{
return buffer_.data();
}
char* ChatMessage::Data()
{
return buffer_.data();
}
std::size_t ChatMessage::Length() const
{
return HEADER_LENGTH + body_length_;
}
const char* ChatMessage::Body() const
{
return buffer_.data() + HEADER_LENGTH;
}
char* ChatMessage::Body()
{
return buffer_.data() + HEADER_LENGTH;
}
std::size_t ChatMessage::BodyLength() const
{
return static_cast<std::size_t>(body_length_);
}
bool ChatMessage::DecodeHeader()
{
std::int32_t body_len = 0;
std::memcpy(&body_len, Data(), 4);
if (body_len < 0)
return false;
if (MAX_BODY_LENGTH > 0) {
if (body_len > MAX_BODY_LENGTH)
return false;
}
body_length_ = body_len;
PrepareBody(body_length_);
return true;
}
void ChatMessage::EncodeHeader()
{
std::array<char, HEADER_LENGTH> head_buffer{};
head_buffer.fill(0);
std::memcpy(head_buffer.data(), &body_length_, sizeof(body_length_));
std::copy(head_buffer.begin(), head_buffer.end(), Data());
}
void ChatMessage::Reset()
{
buffer_.clear();
buffer_.resize(HEADER_LENGTH, '\0');
}
void ChatMessage::PrepareBody(std::size_t len)
{
std::array<char, HEADER_LENGTH> head_bk{};
std::copy(buffer_.begin(), buffer_.begin() + HEADER_LENGTH, head_bk.begin());
buffer_.clear();
buffer_.resize(HEADER_LENGTH + len, '\0');
std::copy(head_bk.begin(), head_bk.end(), buffer_.begin());
}
TcpClient::TcpClient(boost::asio::io_service& io_service)
: io_service_(io_service),
socket_(io_service),
read_msg_(std::make_shared<ChatMessage>()),
write_msgs_(),
default_event_(),
client_event_(&default_event_),
closed_()
{
//DoConnect(endpoint_iterator);
}
TcpClient::~TcpClient()
{
}
void TcpClient::Connect(const std::string& ip, std::uint16_t port)
{
boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address::from_string(ip), port);
socket_.async_connect(endpoint,
[this](boost::system::error_code ec)
{
client_event_->OnConnected(ec);
if (!ec)
{
DoReadHeader();
}
});
}
void TcpClient::SetEvent(ClientEvent* evt)
{
if (!evt)
return;
client_event_ = evt;
}
void TcpClient::AsyncSend(const std::string& msg)
{
auto cm = std::make_shared<ChatMessage>();
ChatMessage::Create(msg, cm.get());
AsyncSend(cm);
}
void TcpClient::AsyncSend(ChatMessagePtr msg)
{
io_service_.post(
[this, msg]()
{
bool write_in_progress = !write_msgs_.empty();
write_msgs_.push_back(msg);
if (!write_in_progress)
{
DoWrite();
}
});
}
void TcpClient::AsyncClose()
{
io_service_.post(
[this]()
{
Shutdown();
});
}
void TcpClient::DoConnect(tcp::resolver::iterator endpoint_iterator)
{
boost::asio::async_connect(socket_, endpoint_iterator,
[this](boost::system::error_code ec, tcp::resolver::iterator)
{
if (!ec)
{
DoReadHeader();
}
});
}
void TcpClient::DoReadHeader()
{
boost::asio::async_read(socket_,
boost::asio::buffer(read_msg_->Data(), ChatMessage::HEADER_LENGTH),
[this](boost::system::error_code ec, std::size_t /*length*/)
{
if (!ec && read_msg_->DecodeHeader())
{
if (read_msg_->BodyLength() == 0) {
client_event_->OnReceived(read_msg_);
DoReadHeader();
} else {
DoReadBody();
}
} else {
Shutdown();
}
});
}
void TcpClient::DoReadBody()
{
boost::asio::async_read(socket_,
boost::asio::buffer(read_msg_->Body(), read_msg_->BodyLength()),
[this](boost::system::error_code ec, std::size_t /*length*/)
{
if (!ec) {
client_event_->OnReceived(read_msg_);
DoReadHeader();
} else {
Shutdown();
}
});
}
void TcpClient::DoWrite()
{
boost::asio::async_write(socket_,
boost::asio::buffer(write_msgs_.front()->Data(),
write_msgs_.front()->Length()),
[this](boost::system::error_code ec, std::size_t /*length*/)
{
if (!ec)
{
write_msgs_.pop_front();
if (!write_msgs_.empty())
{
DoWrite();
}
} else {
Shutdown();
}
});
}
void TcpClient::Shutdown()
{
if (closed_) {
return;
}
closed_ = true;
boost::system::error_code ec{};
socket_.shutdown(boost::asio::socket_base::shutdown_both, ec);
socket_.close(ec);
client_event_->OnClosed();
}
ServerSession::ServerSession(tcp::socket socket, TcpServer& server, std::int64_t index)
: socket_(std::move(socket)),
server_(server),
index_(index),
read_msg_(std::make_shared<ChatMessage>()),
write_msgs_(),
closed_()
{
}
void ServerSession::Start()
{
DoReadHeader();
}
void ServerSession::AsyncSend(const std::string& msg)
{
auto cm = std::make_shared<ChatMessage>();
ChatMessage::Create(msg, cm.get());
AsyncSend(cm);
}
void ServerSession::AsyncSend(ChatMessagePtr msg)
{
auto& io_ctx = server_.GetIoService();
auto self(shared_from_this());
io_ctx.post([this, self, msg]()
{
bool write_in_progress = !write_msgs_.empty();
write_msgs_.push_back(msg);
if (!write_in_progress)
{
DoWrite();
}
});
}
std::int64_t ServerSession::GetIndex() const
{
return index_;
}
void ServerSession::AsyncClose()
{
auto self(shared_from_this());
server_.GetIoService().post(
[this, self]()
{
Shutdown(self);
});
}
void ServerSession::DoReadHeader()
{
read_msg_->Reset();
auto self(shared_from_this());
boost::asio::async_read(socket_,
boost::asio::buffer(read_msg_->Data(), ChatMessage::HEADER_LENGTH),
[this, self](boost::system::error_code ec, std::size_t /*length*/)
{
if (!ec && read_msg_->DecodeHeader())
{
if (read_msg_->BodyLength() == 0) {
server_.GetServerEvent()->OnReceived(self, read_msg_);
DoReadHeader();
} else {
DoReadBody();
}
} else {
Shutdown(self);
}
});
}
void ServerSession::DoReadBody()
{
auto self(shared_from_this());
boost::asio::async_read(socket_,
boost::asio::buffer(read_msg_->Body(), read_msg_->BodyLength()),
[this, self](boost::system::error_code ec, std::size_t /*length*/)
{
if (!ec)
{
server_.GetServerEvent()->OnReceived(self, read_msg_);
DoReadHeader();
} else {
Shutdown(self);
}
});
}
void ServerSession::DoWrite()
{
auto self(shared_from_this());
boost::asio::async_write(socket_,
boost::asio::buffer(write_msgs_.front()->Data(),
write_msgs_.front()->Length()),
[this, self](boost::system::error_code ec, std::size_t /*length*/)
{
if (!ec)
{
write_msgs_.pop_front();
if (!write_msgs_.empty())
{
DoWrite();
}
} else {
Shutdown(self);
}
});
}
void ServerSession::Shutdown(const ServerSessionPtr& self)
{
if (closed_) {
return;
}
closed_ = true;
boost::system::error_code ec{};
socket_.shutdown(boost::asio::socket_base::shutdown_both, ec);
socket_.close(ec);
server_.GetServerEvent()->OnClosed(self);
server_.SessionLeave(self);
}
//----------------------------------------------------------------------
TcpServer::TcpServer(boost::asio::io_service& io_service)
: ip_(),
port_(),
io_service_(io_service),
acceptor_(),
socket_(io_service),
default_event_(),
server_event_(&default_event_),
index_generator_(),
session_map_()
{
}
TcpServer::~TcpServer()
{
}
bool TcpServer::Init(const std::string& ip, std::uint16_t port)
{
if (!Listen(ip, port))
return false;
DoAccept();
return true;
}
void TcpServer::SetEvent(ServerEvent* evt)
{
if (evt) {
server_event_ = evt;
}
}
ServerEvent* TcpServer::GetServerEvent()
{
return server_event_;
}
boost::asio::io_service& TcpServer::GetIoService()
{
return io_service_;
}
void TcpServer::DoAccept()
{
acceptor_->async_accept(socket_,
[this](boost::system::error_code ec)
{
if (!ec)
{
auto idx = NextIndex();
auto p_session = std::make_shared<ServerSession>(std::move(socket_), *this, idx);
p_session->Start();
SessionJoin(p_session);
GetServerEvent()->OnAccepted(p_session);
}
DoAccept();
});
}
std::int64_t TcpServer::NextIndex()
{
return ++index_generator_;
}
bool TcpServer::Listen(const std::string& ip, std::uint16_t port)
{
ip_ = ip;
port_ = port;
boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address::from_string(ip), port);
acceptor_ = std::make_shared<boost::asio::ip::tcp::acceptor>(io_service_);
try
{
acceptor_->open(endpoint.protocol());
acceptor_->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
acceptor_->bind(endpoint);
acceptor_->listen();
return true;
} catch (const std::exception& e) {
(void)e;
return false;
}
}
void TcpServer::SessionJoin(ServerSessionPtr session)
{
session_map_[session->GetIndex()] = session;
}
void TcpServer::SessionLeave(ServerSessionPtr session)
{
session_map_.erase(session->GetIndex());
}
} // namespace vnetwork
|
b010e75cbe0a253bef34ef14329bb968ed887429 | 8094f49b192e3a00fb4128091ec7958bbc097c01 | /source/lib/state_representation/src/Robot/JointState.cpp | 24f25643e94d906e30f015034834247b36df50bd | [
"MIT"
] | permissive | mcx/modulo | b13960d1d80e55e3df0122e69ae17875f40c13e9 | 02cf36d553dabae1064c0963f72cfe29e97cfd94 | refs/heads/master | 2023-02-11T09:40:50.244965 | 2021-01-12T14:56:11 | 2021-01-12T14:56:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,852 | cpp | JointState.cpp | #include "state_representation/Robot/JointState.hpp"
#include "state_representation/Exceptions/IncompatibleStatesException.hpp"
#include "state_representation/Exceptions/EmptyStateException.hpp"
#include "state_representation/Exceptions/NotImplementedException.hpp"
namespace StateRepresentation
{
JointState::JointState():
State(StateType::JOINTSTATE)
{
this->initialize();
}
JointState::JointState(const std::string& robot_name, unsigned int nb_joints):
State(StateType::JOINTSTATE, robot_name), names(nb_joints)
{
this->set_names(nb_joints);
}
JointState::JointState(const std::string& robot_name, const std::vector<std::string>& joint_names):
State(StateType::JOINTSTATE, robot_name)
{
this->set_names(joint_names);
}
JointState::JointState(const JointState& state):
State(state), names(state.names), positions(state.positions), velocities(state.velocities),
accelerations(state.accelerations), torques(state.torques)
{}
void JointState::initialize()
{
this->State::initialize();
// resize
unsigned int size = this->names.size();
this->positions.resize(size);
this->velocities.resize(size);
this->accelerations.resize(size);
this->torques.resize(size);
// set to zeros
this->set_zero();
}
void JointState::set_zero()
{
this->positions.setZero();
this->velocities.setZero();
this->accelerations.setZero();
this->torques.setZero();
}
JointState& JointState::operator+=(const JointState& state)
{
// sanity check
if(this->is_empty()) throw EmptyStateException(this->get_name() + " state is empty");
if(state.is_empty()) throw EmptyStateException(state.get_name() + " state is empty");
if(!this->is_compatible(state)) throw IncompatibleStatesException("The two joint states are incompatible, check name, joint names and order or size");
// operation
this->set_positions(this->get_positions() + state.get_positions());
this->set_velocities(this->get_velocities() + state.get_velocities());
this->set_accelerations(this->get_accelerations() + state.get_accelerations());
this->set_torques(this->get_torques() + state.get_torques());
return (*this);
}
const JointState JointState::operator+(const JointState& state) const
{
JointState result(*this);
result += state;
return result;
}
JointState& JointState::operator-=(const JointState& state)
{
// sanity check
if(this->is_empty()) throw EmptyStateException(this->get_name() + " state is empty");
if(state.is_empty()) throw EmptyStateException(state.get_name() + " state is empty");
if(!this->is_compatible(state)) throw IncompatibleStatesException("The two joint states are incompatible, check name, joint names and order or size");
// operation
this->set_positions(this->get_positions() - state.get_positions());
this->set_velocities(this->get_velocities() - state.get_velocities());
this->set_accelerations(this->get_accelerations() - state.get_accelerations());
this->set_torques(this->get_torques() - state.get_torques());
return (*this);
}
const JointState JointState::operator-(const JointState& state) const
{
JointState result(*this);
result -= state;
return result;
}
JointState& JointState::operator*=(const Eigen::MatrixXd& lambda)
{
if(this->is_empty()) throw EmptyStateException(this->get_name() + " state is empty");
if(lambda.rows() != this->get_size() || lambda.cols() != this->get_size()) throw IncompatibleSizeException("Gain matrix is of incorrect size: expected " + std::to_string(this->get_size()) + "x" + std::to_string(this->get_size()) + ", given " + std::to_string(lambda.cols()) + "x" + std::to_string(lambda.cols()));
this->set_positions(lambda * this->get_positions());
this->set_velocities(lambda * this->get_velocities());
this->set_accelerations(lambda * this->get_accelerations());
this->set_torques(lambda * this->get_torques());
return (*this);
}
const JointState JointState::copy() const
{
JointState result(*this);
return result;
}
std::ostream& operator<<(std::ostream& os, const JointState& state)
{
if(state.is_empty())
{
os << "Empty " << state.get_name() << " JointState";
}
else
{
os << state.get_name() << " JointState" << std::endl;
os << "names: [";
for(auto& n:state.names) os << n << ", ";
os << "]" << std::endl;
os << "positions: [";
for(unsigned int i=0; i<state.positions.size(); ++i) os << state.positions(i) << ", ";
os << "]" << std::endl;
os << "velocities: [";
for(unsigned int i=0; i<state.velocities.size(); ++i) os << state.velocities(i) << ", ";
os << "]" << std::endl;
os << "accelerations: [";
for(unsigned int i=0; i<state.accelerations.size(); ++i) os << state.accelerations(i) << ", ";
os << "]" << std::endl;
os << "torques: [";
for(unsigned int i=0; i<state.torques.size(); ++i) os << state.torques(i) << ", ";
os << "]";
}
return os;
}
const JointState operator*(double lambda, const JointState& state)
{
if(state.is_empty()) throw EmptyStateException(state.get_name() + " state is empty");
JointState result(state);
result.set_positions(lambda * state.get_positions());
result.set_velocities(lambda * state.get_velocities());
result.set_accelerations(lambda * state.get_accelerations());
result.set_torques(lambda * state.get_torques());
return result;
}
const JointState operator*(const Eigen::MatrixXd& lambda, const JointState& state)
{
JointState result(state);
result *= lambda;
return result;
}
const std::vector<double> JointState::to_std_vector() const
{
throw(NotImplementedException("to_std_vector() is not implemented for the base JointState class"));
return std::vector<double>();
}
void JointState::from_std_vector(const std::vector<double>&)
{
throw(NotImplementedException("from_std_vector() is not implemented for the base JointState class"));
}
} |
8341a648cb7d279d6d6e93f229005125cc5db28c | ef755cfa5d2c32ccbaa4326d2138d60e7e3fadf8 | /StepperMotorDrivetrainK.cpp | 920413cdb0242592ffa71f3ab4e0b9eaa8358e65 | [] | no_license | SoonerRobotics/IEEErobot2019 | 388a30853c735fad0b7d30e9469f5ef2f856506f | a66a1307f80dfd1c8f6df025c2737e64c868518b | refs/heads/master | 2020-03-29T07:55:38.934020 | 2019-04-10T20:30:05 | 2019-04-10T20:30:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 24,875 | cpp | StepperMotorDrivetrainK.cpp | #include "StepperMotorDrivetrain.h"
#include <String.h>
const double WHEEL_DIAMETER = 4;
// Constructor
StepperMotorDrivetrain::StepperMotorDrivetrain()
{
//sets steps and step counter to 0
this->frontLeftSteps = 0;
this->frontLeftCounter = 0;
this->backLeftSteps = 0;
this->backLeftCounter = 0;
this->frontRightSteps = 0;
this->frontRightCounter = 0;
this->backRightSteps = 0;
this->backRightCounter = 0;
//Set this to a medium speed
this->rpm = 25;
}
// Set a drivetrain's pins equal to another
void StepperMotorDrivetrain::operator=(const StepperMotorDrivetrain& drivetrain)
{
// Sets private variables from each drivetrain equal to one other
this->fLeftIN1 = drivetrain.fLeftIN1;
this->fLeftIN2 = drivetrain.fLeftIN2;
this->fLeftIN3 = drivetrain.fLeftIN3;
this->fLeftIN4 = drivetrain.fLeftIN4;
this->bLeftIN1 = drivetrain.bLeftIN1;
this->bLeftIN2 = drivetrain.bLeftIN2;
this->bLeftIN3 = drivetrain.bLeftIN3;
this->bLeftIN4 = drivetrain.bLeftIN4;
this->fRightIN1 = drivetrain.fRightIN1;
this->fRightIN2 = drivetrain.fRightIN2;
this->fRightIN3 = drivetrain.fRightIN3;
this->fRightIN4 = drivetrain.fRightIN4;
this->bRightIN1 = drivetrain.bRightIN1;
this->bRightIN2 = drivetrain.bRightIN2;
this->bRightIN3 = drivetrain.bRightIN3;
this->bRightIN4 = drivetrain.bRightIN4;
// Copy the rpm from previous drivetrain
this->rpm = drivetrain.rpm;
this->frontLeftSteps = drivetrain.frontLeftSteps;
this->backLeftSteps = drivetrain.backLeftSteps;
this->frontRightSteps = drivetrain.frontRightSteps;
this->backRightSteps = drivetrain.backRightSteps;
this->frontLeftCounter = drivetrain.frontLeftCounter;
this->backLeftCounter = drivetrain.backLeftCounter;
this->frontRightCounter = drivetrain.frontRightCounter;
this->backRightCounter = drivetrain.backRightCounter;
}
// Sets pins for front left motors
void StepperMotorDrivetrain::initFrontLeft(int in1, int in2, int in3, int in4)
{
this->fLeftIN1 = in1;
this->fLeftIN2 = in2;
this->fLeftIN3 = in3;
this->fLeftIN4 = in4;
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
// Sets pins for back left motors
void StepperMotorDrivetrain::initBackLeft(int in1, int in2, int in3, int in4)
{
this->bLeftIN1 = in1;
this->bLeftIN2 = in2;
this->bLeftIN3 = in3;
this->bLeftIN4 = in4;
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
// Sets pins for front right motors
void StepperMotorDrivetrain::initFrontRight(int in1, int in2, int in3, int in4)
{
this->fRightIN1 = in1;
this->fRightIN2 = in2;
this->fRightIN3 = in3;
this->fRightIN4 = in4;
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
// Sets pins for back right motors
void StepperMotorDrivetrain::initBackRight(int in1, int in2, int in3, int in4)
{
this->bRightIN1 = in1;
this->bRightIN2 = in2;
this->bRightIN3 = in3;
this->bRightIN4 = in4;
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
// Sets speed of drivetrain
void StepperMotorDrivetrain::setRPM(float speed)
{
this->rpm = abs(speed);
}
// Moves the drivetrain
void StepperMotorDrivetrain::step(int left, int right)
{
bool millisecond_interval = false;
// We basically force left and right to be equal here, because they should be.
// NO CURVE TURNS ALLOWED (Down with tank steer)
int steps = min(abs(left), abs(right));
// If direction param is negative then set its direction to -1, otherwise 1.
int leftDirection = left < 0 ? -1 : 1;
int rightDirection = right < 0 ? -1 : 1;
// Determine how many microseconds we want to wait, and convert to an integer
double T = calculateStepWait(steps);
// Convert to milliseconds if delay would be greater than 5,000 us.
if(T > 5000)
{
T /= 1000;
millisecond_interval = true;
}
unsigned long stepWait = static_cast<int>(T);
// Step steps number of times
for(int i = 0; i < steps; ++i)
{
this->frontLeftSteps += leftDirection;
this->backLeftSteps += leftDirection;
this->frontRightSteps += rightDirection;
this->backRightSteps += rightDirection;
this->frontLeftCounter += leftDirection;
this->backLeftCounter += leftDirection;
this->frontRightCounter += rightDirection;
this->backRightCounter += rightDirection;
// Constrain the counters to the step boundaries
// Left
this->frontLeftCounter = this->frontLeftCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->frontLeftCounter;
this->frontLeftCounter = this->frontLeftCounter >= STEPS_PER_REVOLUTION ? 0 : this->frontLeftCounter;
this->backLeftCounter = this->backLeftCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->backLeftCounter;
this->backLeftCounter = this->backLeftCounter >= STEPS_PER_REVOLUTION ? 0 : this->backLeftCounter;
// Right
this->frontRightCounter = this->frontRightCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->frontRightCounter;
this->frontRightCounter = this->frontRightCounter >= STEPS_PER_REVOLUTION ? 0 : this->frontRightCounter;
this->backRightCounter = this->backRightCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->backRightCounter;
this->backRightCounter = this->backRightCounter >= STEPS_PER_REVOLUTION ? 0 : this->backRightCounter;
// Step according to interval
if(millisecond_interval)
{
singleStep(stepWait);
}
else
{
singleStep_us(stepWait);
}
}
}
// A really cool function for allowing stepping with a single side for more "accurate" turning
// Best to only use values: -1, 0, 1
bool StepperMotorDrivetrain::steppe(int left, int right)
{
bool millisecond_interval = false;
//We basically force left and right to be equal here, because they should be.
//NO CURVE TURNS ALLOWED (Down with tank steer)
int steps = max(abs(left), abs(right));
//int leftDirection = left < 0 ? -1 : 1;
//int rightDirection = right < 0 ? -1 : 1;
int leftDirection = constrain(left, -1, 1);
int rightDirection = constrain(right, -1, 1);
//Determine how many microseconds we want to wait, and convert to an integer
//double totalTime = (static_cast<double>(steps) / STEPS_PER_REVOLUTION) / this->rpm * 60.0 * 1000.0 * 1000.0;
double T = calculateStepWait(steps);
//Convert to milliseconds if delay would be greater than 5,000 us.
if(T > 5000)
{
T /= 1000;
millisecond_interval = true;
}
unsigned long stepWait = static_cast<int>(T);
for(int i = 0; i < steps; ++i)
{
this->frontLeftSteps += leftDirection;
this->backLeftSteps += leftDirection;
this->frontRightSteps += rightDirection;
this->backRightSteps += rightDirection;
this->frontLeftCounter += leftDirection;
this->backLeftCounter += leftDirection;
this->frontRightCounter += rightDirection;
this->backRightCounter += rightDirection;
//Constrain the counters to the step boundaries
//Left
this->frontLeftCounter = this->frontLeftCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->frontLeftCounter;
this->frontLeftCounter = this->frontLeftCounter >= STEPS_PER_REVOLUTION ? 0 : this->frontLeftCounter;
this->backLeftCounter = this->backLeftCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->backLeftCounter;
this->backLeftCounter = this->backLeftCounter >= STEPS_PER_REVOLUTION ? 0 : this->backLeftCounter;
//Right
this->frontRightCounter = this->frontRightCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->frontRightCounter;
this->frontRightCounter = this->frontRightCounter >= STEPS_PER_REVOLUTION ? 0 : this->frontRightCounter;
this->backRightCounter = this->backRightCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->backRightCounter;
this->backRightCounter = this->backRightCounter >= STEPS_PER_REVOLUTION ? 0 : this->backRightCounter;
if(millisecond_interval)
{
singleStep(stepWait);
}
else
{
singleStep_us(stepWait);
}
}
}
bool StepperMotorDrivetrain::stepToAngle(float target, float current)
{
// Turn right
if (target > 0)
{
if (inRange(target, current, ANGLETHRESHOLD))
{
step(0, 0);
return true;
}
else
{
if (current < target)
{
step(-1, 1);
return false;
}
else
{
step(1, -1);
return false;
}
}
}
// Turn left
else //(target < 0)
{
if (inRange(target, current, ANGLETHRESHOLD))
{
step(0, 0);
return true;
}
else
{
if (current > target)
{
step(1, -1);
return false;
}
else
{
step(-1, 1);
return false;
}
}
}
}
// Calculate the amount of time the amount of steps will take
// Returns time in microseconds
double StepperMotorDrivetrain::calculateStepWait(int steps) {
// Determine how many microseconds we want to wait, and convert to an integer
double totalTime = (static_cast<double>(steps) / STEPS_PER_REVOLUTION) / this->rpm * 60.0 * 1000.0 * 1000.0;
double T = (totalTime / steps) / 2;
return T;
}
// Resets the step counters to 0
void StepperMotorDrivetrain::resetStepCounter()
{
frontLeftSteps = 0;
frontRightSteps = 0;
backLeftSteps = 0;
backRightSteps = 0;
}
// Getter method for left motor steps
long StepperMotorDrivetrain::getFrontLeftSteps()
{
return this->frontLeftCounter;
}
// Getter method for left motor steps
long StepperMotorDrivetrain::getBackLeftSteps()
{
return this->backLeftCounter;
}
// Getter method for right motor steps
long StepperMotorDrivetrain::getFrontRightSteps()
{
return this->frontRightCounter;
}
// Getter method for right motor steps
long StepperMotorDrivetrain::getBackRightSteps()
{
return this->backRightCounter;
}
// Helper method to convert inches to steps
int StepperMotorDrivetrain::convertInchesToSteps(float inches)
{
// number of steps / circumference of wheel = ratio
return static_cast<int>((STEPS_PER_REVOLUTION/(WHEEL_DIAMETER*3.141592653589))*inches * 1.04);
}
// Private Functions
void StepperMotorDrivetrain::singleStep(unsigned int stepWait)
{
sendStepSignalToFrontLeft(frontLeftCounter % 8);
sendStepSignalToFrontRight(frontRightCounter % 8);
sendStepSignalToBackLeft(backLeftCounter % 8);
sendStepSignalToBackRight(backRightCounter % 8);
delay(stepWait); // Wait
}
// same as above but with a different delay function
void StepperMotorDrivetrain::singleStep_us(unsigned int stepWait)
{
sendStepSignalToFrontLeft(frontLeftCounter % 8);
sendStepSignalToFrontRight(frontRightCounter % 8);
sendStepSignalToBackLeft(backLeftCounter % 8);
sendStepSignalToBackRight(backRightCounter % 8);
delayMicroseconds(stepWait); // Wait
}
void StepperMotorDrivetrain::sendStepSignalToFrontLeft(int stepID)
{
switch (stepID) {
case 0: // 1010
digitalWrite(fLeftIN1, HIGH);
digitalWrite(fLeftIN2, LOW);
digitalWrite(fLeftIN3, HIGH);
digitalWrite(fLeftIN4, LOW);
break;
case 1: // 1110
digitalWrite(fLeftIN1, HIGH);
digitalWrite(fLeftIN2, HIGH);
digitalWrite(fLeftIN3, HIGH);
digitalWrite(fLeftIN4, LOW);
break;
case 2: // 0110
digitalWrite(fLeftIN1, LOW);
digitalWrite(fLeftIN2, HIGH);
digitalWrite(fLeftIN3, HIGH);
digitalWrite(fLeftIN4, LOW);
break;
case 3: // 0111
digitalWrite(fLeftIN1, LOW);
digitalWrite(fLeftIN2, HIGH);
digitalWrite(fLeftIN3, HIGH);
digitalWrite(fLeftIN4, HIGH);
break;
case 4: //0101
digitalWrite(fLeftIN1, LOW);
digitalWrite(fLeftIN2, HIGH);
digitalWrite(fLeftIN3, LOW);
digitalWrite(fLeftIN4, HIGH);
break;
case 5: //1101
digitalWrite(fLeftIN1, HIGH);
digitalWrite(fLeftIN2, HIGH);
digitalWrite(fLeftIN3, LOW);
digitalWrite(fLeftIN4, HIGH);
break;
case 6: //1001
digitalWrite(fLeftIN1, HIGH);
digitalWrite(fLeftIN2, LOW);
digitalWrite(fLeftIN3, LOW);
digitalWrite(fLeftIN4, HIGH);
break;
case 7: //1011
digitalWrite(fLeftIN1, HIGH);
digitalWrite(fLeftIN2, LOW);
digitalWrite(fLeftIN3, HIGH);
digitalWrite(fLeftIN4, HIGH);
break;
}
}
void StepperMotorDrivetrain::sendStepSignalToBackLeft(int stepID)
{
switch (stepID) {
case 0: // 1010
digitalWrite(bLeftIN1, HIGH);
digitalWrite(bLeftIN2, LOW);
digitalWrite(bLeftIN3, HIGH);
digitalWrite(bLeftIN4, LOW);
break;
case 1: // 1110
digitalWrite(bLeftIN1, HIGH);
digitalWrite(bLeftIN2, HIGH);
digitalWrite(bLeftIN3, HIGH);
digitalWrite(bLeftIN4, LOW);
break;
case 2: // 0110
digitalWrite(bLeftIN1, LOW);
digitalWrite(bLeftIN2, HIGH);
digitalWrite(bLeftIN3, HIGH);
digitalWrite(bLeftIN4, LOW);
break;
case 3: // 0111
digitalWrite(bLeftIN1, LOW);
digitalWrite(bLeftIN2, HIGH);
digitalWrite(bLeftIN3, HIGH);
digitalWrite(bLeftIN4, HIGH);
break;
case 4: //0101
digitalWrite(bLeftIN1, LOW);
digitalWrite(bLeftIN2, HIGH);
digitalWrite(bLeftIN3, LOW);
digitalWrite(bLeftIN4, HIGH);
break;
case 5: //1101
digitalWrite(bLeftIN1, HIGH);
digitalWrite(bLeftIN2, HIGH);
digitalWrite(bLeftIN3, LOW);
digitalWrite(bLeftIN4, HIGH);
break;
case 6: //1001
digitalWrite(bLeftIN1, HIGH);
digitalWrite(bLeftIN2, LOW);
digitalWrite(bLeftIN3, LOW);
digitalWrite(bLeftIN4, HIGH);
break;
case 7: //1011
digitalWrite(bLeftIN1, HIGH);
digitalWrite(bLeftIN2, LOW);
digitalWrite(bLeftIN3, HIGH);
digitalWrite(bLeftIN4, HIGH);
break;
}
}
void StepperMotorDrivetrain::sendStepSignalToFrontRight(int stepID)
{
switch (stepID) {
case 0: // 1010
digitalWrite(fRightIN1, HIGH);
digitalWrite(fRightIN2, LOW);
digitalWrite(fRightIN3, HIGH);
digitalWrite(fRightIN4, LOW);
break;
case 1: // 1110
digitalWrite(fRightIN1, HIGH);
digitalWrite(fRightIN2, HIGH);
digitalWrite(fRightIN3, HIGH);
digitalWrite(fRightIN4, LOW);
break;
case 2: // 0110
digitalWrite(fRightIN1, LOW);
digitalWrite(fRightIN2, HIGH);
digitalWrite(fRightIN3, HIGH);
digitalWrite(fRightIN4, LOW);
break;
case 3: // 0111
digitalWrite(fRightIN1, LOW);
digitalWrite(fRightIN2, HIGH);
digitalWrite(fRightIN3, HIGH);
digitalWrite(fRightIN4, HIGH);
break;
case 4: //0101
digitalWrite(fRightIN1, LOW);
digitalWrite(fRightIN2, HIGH);
digitalWrite(fRightIN3, LOW);
digitalWrite(fRightIN4, HIGH);
break;
case 5: //1101
digitalWrite(fRightIN1, HIGH);
digitalWrite(fRightIN2, HIGH);
digitalWrite(fRightIN3, LOW);
digitalWrite(fRightIN4, HIGH);
break;
case 6: //1001
digitalWrite(fRightIN1, HIGH);
digitalWrite(fRightIN2, LOW);
digitalWrite(fRightIN3, LOW);
digitalWrite(fRightIN4, HIGH);
break;
case 7: //1011
digitalWrite(fRightIN1, HIGH);
digitalWrite(fRightIN2, LOW);
digitalWrite(fRightIN3, HIGH);
digitalWrite(fRightIN4, HIGH);
break;
}
}
void StepperMotorDrivetrain::sendStepSignalToBackRight(int stepID)
{
switch (stepID) {
case 0: // 1010
digitalWrite(bRightIN1, HIGH);
digitalWrite(bRightIN2, LOW);
digitalWrite(bRightIN3, HIGH);
digitalWrite(bRightIN4, LOW);
break;
case 1: // 1110
digitalWrite(bRightIN1, HIGH);
digitalWrite(bRightIN2, HIGH);
digitalWrite(bRightIN3, HIGH);
digitalWrite(bRightIN4, LOW);
break;
case 2: // 0110
digitalWrite(bRightIN1, LOW);
digitalWrite(bRightIN2, HIGH);
digitalWrite(bRightIN3, HIGH);
digitalWrite(bRightIN4, LOW);
break;
case 3: // 0111
digitalWrite(bRightIN1, LOW);
digitalWrite(bRightIN2, HIGH);
digitalWrite(bRightIN3, HIGH);
digitalWrite(bRightIN4, HIGH);
break;
case 4: //0101
digitalWrite(bRightIN1, LOW);
digitalWrite(bRightIN2, HIGH);
digitalWrite(bRightIN3, LOW);
digitalWrite(bRightIN4, HIGH);
break;
case 5: //1101
digitalWrite(bRightIN1, HIGH);
digitalWrite(bRightIN2, HIGH);
digitalWrite(bRightIN3, LOW);
digitalWrite(bRightIN4, HIGH);
break;
case 6: //1001
digitalWrite(bRightIN1, HIGH);
digitalWrite(bRightIN2, LOW);
digitalWrite(bRightIN3, LOW);
digitalWrite(bRightIN4, HIGH);
break;
case 7: //1011
digitalWrite(bRightIN1, HIGH);
digitalWrite(bRightIN2, LOW);
digitalWrite(bRightIN3, HIGH);
digitalWrite(bRightIN4, HIGH);
break;
}
}
// Sets all stepper motors to LOW. Allows power saving and reduces heat.
void StepperMotorDrivetrain::rest()
{
if(millisecond_interval)
{
delay(5*waitTime); // gives some time for momentum to be dampened.
}
else
{
delayMicroseconds(5*waitTime);
}
digitalWrite(fRightIN1, LOW);
digitalWrite(fRightIN2, LOW);
digitalWrite(fRightIN3, LOW);
digitalWrite(fRightIN4, LOW);
digitalWrite(bRightIN1, LOW);
digitalWrite(bRightIN2, LOW);
digitalWrite(bRightIN3, LOW);
digitalWrite(bRightIN4, LOW);
digitalWrite(fLeftIN1, LOW);
digitalWrite(fLeftIN2, LOW);
digitalWrite(fLeftIN3, LOW);
digitalWrite(fLeftIN4, LOW);
digitalWrite(bLeftIN1, LOW);
digitalWrite(bLeftIN2, LOW);
digitalWrite(bLeftIN3, LOW);
digitalWrite(bLeftIN4, LOW);
}
/* Pass ints for direction
*
* forwardDirection: 0-->None 1-->Forward -1-->Backwards
* sidewayDirection: 0-->None 1-->Right -1-->Left
*
* Use drivetrain.convertInchesToSteps(inches) in your .ino for steps
*/
void StepperMotorDrivetrain::strafe(int forwardDirection, int sidewayDirection, unsigned int stepsActual)
{
//We basically force left and right to be equal here, because they should be.
//NO CURVE TURNS ALLOWED (Down with tank steer)
int steps = abs(stepsActual);
//TODO: delete Step and implement it here (not priority)
// Straight Forward
if(forwardDirection == 1 && sidewayDirection == 0)
{
Serial.println("Forward Strafe");
step(steps, steps);
}
// Straight Backwards
else if(forwardDirection == -1 && sidewayDirection == 0)
{
Serial.println("Backward Strafe");
step(-steps, -steps);
}
// Non basic movement (strafing)
else
{
bool millisecond_interval = false;
//Calculating amount of time for function
double T = calculateStepWait(steps);
//Convert to milliseconds if delay would be greater than 5,000 us.
if(T > 5000)
{
T /= 1000;
millisecond_interval = true;
}
unsigned long stepWait = static_cast<int>(T);
// Left Strafe
if(forwardDirection == 0 && sidewayDirection == -1)
{
Serial.println("Left Strafe");
for(int i = 0; i < steps; i++)
{
//right motors turn outward, left motors turn inward
backRightCounter -= 1;
frontRightCounter += 1;
backLeftCounter += 1;
frontLeftCounter -= 1;
//Constrain the counters to the step boundaries
//Left
this->frontLeftCounter = this->frontLeftCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->frontLeftCounter;
this->frontLeftCounter = this->frontLeftCounter >= STEPS_PER_REVOLUTION ? 0 : this->frontLeftCounter;
this->backLeftCounter = this->backLeftCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->backLeftCounter;
this->backLeftCounter = this->backLeftCounter >= STEPS_PER_REVOLUTION ? 0 : this->backLeftCounter;
//Right
this->frontRightCounter = this->frontRightCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->frontRightCounter;
this->frontRightCounter = this->frontRightCounter >= STEPS_PER_REVOLUTION ? 0 : this->frontRightCounter;
this->backRightCounter = this->backRightCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->backRightCounter;
this->backRightCounter = this->backRightCounter >= STEPS_PER_REVOLUTION ? 0 : this->backRightCounter;
if(millisecond_interval)
{
singleStep(stepWait);
}
else
{
singleStep_us(stepWait);
}
}
}
// Right Strafe
else if(forwardDirection == 0 && sidewayDirection == 1)
{
Serial.println("Right Strafe");
for(int i = 0; i < steps; i++)
{
//right motors turn inward, left motors turn outward
backRightCounter += 1;
frontRightCounter -= 1;
backLeftCounter -= 1;
frontLeftCounter += 1;
//Constrain the counters to the step boundaries
//Left
this->frontLeftCounter = this->frontLeftCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->frontLeftCounter;
this->frontLeftCounter = this->frontLeftCounter >= STEPS_PER_REVOLUTION ? 0 : this->frontLeftCounter;
this->backLeftCounter = this->backLeftCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->backLeftCounter;
this->backLeftCounter = this->backLeftCounter >= STEPS_PER_REVOLUTION ? 0 : this->backLeftCounter;
//Right
this->frontRightCounter = this->frontRightCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->frontRightCounter;
this->frontRightCounter = this->frontRightCounter >= STEPS_PER_REVOLUTION ? 0 : this->frontRightCounter;
this->backRightCounter = this->backRightCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->backRightCounter;
this->backRightCounter = this->backRightCounter >= STEPS_PER_REVOLUTION ? 0 : this->backRightCounter;
if(millisecond_interval)
{
singleStep(stepWait);
}
else
{
singleStep_us(stepWait);
}
}
}
// Forward Left Strafe
else if(forwardDirection == 1 && sidewayDirection == -1)
{
Serial.println("Forward Left Strafe");
for(int i = 0; i < steps; i++)
{
//frontright turns forward, backright turns forward
frontLeftCounter += 1;
backRightCounter += 1;
//Constrain the counters to the step boundaries
//Left
this->frontLeftCounter = this->frontLeftCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->frontLeftCounter;
this->frontLeftCounter = this->frontLeftCounter >= STEPS_PER_REVOLUTION ? 0 : this->frontLeftCounter;
//Right
this->backRightCounter = this->backRightCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->backRightCounter;
this->backRightCounter = this->backRightCounter >= STEPS_PER_REVOLUTION ? 0 : this->backRightCounter;
if(millisecond_interval)
{
singleStep(stepWait);
}
else
{
singleStep_us(stepWait);
}
}
}
// Backward Left Strafe
else if(forwardDirection == -1 && sidewayDirection == -1)
{
Serial.println("Backward Left Strafe");
for(int i = 0; i < steps; i++)
{
//frontright turns backward, backleft turns backward
frontRightCounter -= 1;
backLeftCounter -= 1;
//Constrain the counters to the step boundaries
//Right
this->frontRightCounter = this->frontRightCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->frontRightCounter;
this->frontRightCounter = this->frontRightCounter >= STEPS_PER_REVOLUTION ? 0 : this->frontRightCounter;
//Left
this->backLeftCounter = this->backLeftCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->backLeftCounter;
this->backLeftCounter = this->backLeftCounter >= STEPS_PER_REVOLUTION ? 0 : this->backLeftCounter;
if(millisecond_interval)
{
singleStep(stepWait);
}
else
{
singleStep_us(stepWait);
}
}
}
// Forward Right Strafe
else if(forwardDirection == 1 && sidewayDirection == 1)
{
Serial.println("Forward Right Strafe");
for(int i = 0; i < steps; i++)
{
//backright turns forward, frontleft turns forward
backLeftCounter += 1;
frontRightCounter += 1;
//Constrain the counters to the step boundaries
//Right
this->frontRightCounter = this->frontRightCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->frontRightCounter;
this->frontRightCounter = this->frontRightCounter >= STEPS_PER_REVOLUTION ? 0 : this->frontRightCounter;
//Left
this->backLeftCounter = this->backLeftCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->backLeftCounter;
this->backLeftCounter = this->backLeftCounter >= STEPS_PER_REVOLUTION ? 0 : this->backLeftCounter;
if(millisecond_interval)
{
singleStep(stepWait);
}
else
{
singleStep_us(stepWait);
}
}
}
// Backward Right Strafe
else if(forwardDirection == -1 && sidewayDirection == 1)
{
Serial.println("Backward Right Strafe");
for(int i = 0; i < steps; i++)
{
//backright turns backward, frontleft turns backward
backRightCounter -= 1;
frontLeftCounter -= 1;
//Constrain the counters to the step boundaries
//Right
this->backRightCounter = this->backRightCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->backRightCounter;
this->backRightCounter = this->backRightCounter >= STEPS_PER_REVOLUTION ? 0 : this->backRightCounter;
//Left
this->frontLeftCounter = this->frontLeftCounter < 0 ? STEPS_PER_REVOLUTION - 1 : this->frontLeftCounter;
this->frontLeftCounter = this->frontLeftCounter >= STEPS_PER_REVOLUTION ? 0 : this->frontLeftCounter;
if(millisecond_interval)
{
singleStep(stepWait);
}
else
{
singleStep_us(stepWait);
}
}
}
}
}
/*
boolPIDdrive(float targetDistance, float targetAngle, float currentAngle)
{;
float currentSteps = 0;
while(currentSteps < targetDistance)
{
strafe(1,0,);
}
}
*/
bool StepperMotorDrivetrain::inRange(float variable, float constant, float range)
{
if (abs(variable - constant) < range )
{
return true;
}
else
{
return false;
}
}
|
4c3c2ebe1d711e69aacf55effcbc4db72e975f62 | 1367b4c420e193c35e87f1660ee445e7c0063977 | /ptr-genericos-func/filter-versão-2/include/filter.h | 5add51f6e2a501cc9adae763d881fb3b42b54eb1 | [] | no_license | fernando-ff/LP | 6391beaf0ce8139cda3ee9b5c851a33d0ed369b4 | 3af49540d0eb13eb2069c0d0feb75256892227c6 | refs/heads/master | 2023-02-07T23:39:22.998823 | 2020-12-20T09:47:22 | 2020-12-20T09:47:22 | 250,061,878 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 147 | h | filter.h | #ifndef FILTER_LIB_H
#define FILTER_LIB_H
#include <iostream> //std::cin,std::cout
int* filter(int* first, int* last, bool(*pred)(int) );
#endif |
29682f840653f4d99526ba09f805e850ba4467fd | 183b96661938399377e1a78d1134ec1e9370e316 | /tests/gtest_ports.cpp | 968abce8328be5befa98264674b8a823af6d019c | [
"MIT"
] | permissive | hiter-fzq/BehaviorTree.CPP | 3b6c3804cdda71b019c05127e45f630dd0f90eaf | 5f961942d74e2f441a51a126cb6b8eb9298ff445 | refs/heads/master | 2022-11-12T11:54:30.322222 | 2022-11-03T11:28:29 | 2022-11-03T11:28:29 | 252,464,467 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,418 | cpp | gtest_ports.cpp | #include <gtest/gtest.h>
#include "behaviortree_cpp/bt_factory.h"
using namespace BT;
class NodeWithPorts : public SyncActionNode
{
public:
NodeWithPorts(const std::string& name, const NodeConfig& config) :
SyncActionNode(name, config)
{
std::cout << "ctor" << std::endl;
}
NodeStatus tick()
{
int val_A = 0;
int val_B = 0;
if (getInput("in_port_A", val_A) && getInput("in_port_B", val_B) && val_A == 42 &&
val_B == 66)
{
return NodeStatus::SUCCESS;
}
return NodeStatus::FAILURE;
}
static PortsList providedPorts()
{
return {BT::InputPort<int>("in_port_A", 42, "magic_number"), BT::InputPort<int>("in_"
"port"
"_"
"B")};
}
};
TEST(PortTest, DefaultPorts)
{
std::string xml_txt = R"(
<root main_tree_to_execute = "MainTree" >
<BehaviorTree ID="MainTree">
<NodeWithPorts name = "first" in_port_B="66" />
</BehaviorTree>
</root>)";
BehaviorTreeFactory factory;
factory.registerNodeType<NodeWithPorts>("NodeWithPorts");
auto tree = factory.createTreeFromText(xml_txt);
NodeStatus status = tree.tickWhileRunning();
ASSERT_EQ(status, NodeStatus::SUCCESS);
}
TEST(PortTest, Descriptions)
{
std::string xml_txt = R"(
<root main_tree_to_execute = "MainTree" >
<BehaviorTree ID="MainTree" _description="this is my tree" >
<Sequence>
<NodeWithPorts name="first" in_port_B="66" _description="this is my action" />
<SubTree ID="SubTree" name="second" _description="this is a subtree"/>
</Sequence>
</BehaviorTree>
<BehaviorTree ID="SubTree" _description="this is a subtree" >
<NodeWithPorts name="third" in_port_B="99" />
</BehaviorTree>
</root>)";
BehaviorTreeFactory factory;
factory.registerNodeType<NodeWithPorts>("NodeWithPorts");
auto tree = factory.createTreeFromText(xml_txt);
NodeStatus status = tree.tickWhileRunning();
while (status == NodeStatus::RUNNING)
{
status = tree.tickWhileRunning();
}
ASSERT_EQ(status, NodeStatus::FAILURE); // failure because in_port_B="99"
}
struct MyType
{
std::string value;
};
class NodeInPorts : public SyncActionNode
{
public:
NodeInPorts(const std::string& name, const NodeConfig& config) :
SyncActionNode(name, config)
{}
NodeStatus tick()
{
int val_A = 0;
MyType val_B;
if (getInput("int_port", val_A) && getInput("any_port", val_B))
{
return NodeStatus::SUCCESS;
}
return NodeStatus::FAILURE;
}
static PortsList providedPorts()
{
return {BT::InputPort<int>("int_port"), BT::InputPort<MyType>("any_port")};
}
};
class NodeOutPorts : public SyncActionNode
{
public:
NodeOutPorts(const std::string& name, const NodeConfig& config) :
SyncActionNode(name, config)
{}
NodeStatus tick()
{
return NodeStatus::SUCCESS;
}
static PortsList providedPorts()
{
return {BT::OutputPort<int>("int_port"), BT::OutputPort<MyType>("any_port")};
}
};
TEST(PortTest, EmptyPort)
{
std::string xml_txt = R"(
<root main_tree_to_execute = "MainTree" >
<BehaviorTree ID="MainTree">
<Sequence>
<NodeInPorts int_port="{ip}" any_port="{ap}" />
<NodeOutPorts int_port="{ip}" any_port="{ap}" />
</Sequence>
</BehaviorTree>
</root>)";
BehaviorTreeFactory factory;
factory.registerNodeType<NodeOutPorts>("NodeOutPorts");
factory.registerNodeType<NodeInPorts>("NodeInPorts");
auto tree = factory.createTreeFromText(xml_txt);
NodeStatus status = tree.tickWhileRunning();
// expect failure because port is not set yet
ASSERT_EQ(status, NodeStatus::FAILURE);
}
class IllegalPorts : public SyncActionNode
{
public:
IllegalPorts(const std::string& name, const NodeConfig& config) :
SyncActionNode(name, config)
{}
NodeStatus tick()
{
return NodeStatus::SUCCESS;
}
static PortsList providedPorts()
{
return {BT::InputPort<std::string>("name")};
}
};
TEST(PortTest, IllegalPorts)
{
BehaviorTreeFactory factory;
ASSERT_ANY_THROW(factory.registerNodeType<IllegalPorts>("nope"));
}
|
8b1d472d761dbe3fecec4198154771c9faa2995c | b0eacb1339ed04bf5bac6a27c9e95d890c4aea2b | /Osteotomia_Code/library/imebra/src/dataSet.cpp | ec9351ede140fd66818c6b3e59f692af759ac134 | [] | no_license | david-branco/osteotomy | e1ed5b45dfd5edc5350ee5bd2ad60dae213cf7a6 | 7ff851cd43e4d69f3249bf3c9dfa0dd253e574d6 | refs/heads/master | 2020-04-09T05:31:57.366761 | 2018-12-02T16:55:30 | 2018-12-02T16:55:30 | 160,068,228 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 49,684 | cpp | dataSet.cpp | /*
Imebra community build 20151130-002
Imebra: a C++ Dicom library
Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
by Paolo Brandoli/Binarno s.p.
All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as published by
the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-------------------
If you want to use Imebra commercially then you have to buy the commercial
license available at http://imebra.com
After you buy the commercial license then you can use Imebra according
to the terms described in the Imebra Commercial License Version 2.
A copy of the Imebra Commercial License Version 2 is available in the
documentation pages.
Imebra is available at http://imebra.com
The author can be contacted by email at info@binarno.com or by mail at
the following address:
Binarno s.p., Paolo Brandoli
Rakuseva 14
1000 Ljubljana
Slovenia
*/
/*! \file dataSet.cpp
\brief Implementation of the class dataSet.
*/
#include "../../base/include/exception.h"
#include "../../base/include/streamReader.h"
#include "../../base/include/streamWriter.h"
#include "../../base/include/memoryStream.h"
#include "../include/dataSet.h"
#include "../include/dataGroup.h"
#include "../include/dataHandlerNumeric.h"
#include "../include/dicomDict.h"
#include "../include/codecFactory.h"
#include "../include/codec.h"
#include "../include/image.h"
#include "../include/LUT.h"
#include "../include/waveform.h"
#include "../include/colorTransformsFactory.h"
#include "../include/transformsChain.h"
#include "../include/transformHighBit.h"
#include "../include/transaction.h"
#include "../include/modalityVOILUT.h"
#include <iostream>
#include <string.h>
namespace puntoexe
{
namespace imebra
{
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
//
// dataSet
//
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Retrieve the requested tag
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
ptr<data> dataSet::getTag(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, bool bCreate /* =false */)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getTag");
lockObject lockAccess(this);
ptr<data> pData;
ptr<dataGroup> group=getGroup(groupId, order, bCreate);
if(group != 0)
{
pData=group->getTag(tagId, bCreate);
}
return pData;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get the requested group
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
ptr<dataGroup> dataSet::getGroup(std::uint16_t groupId, std::uint16_t order, bool bCreate /* =false */)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getGroup");
lockObject lockAccess(this);
ptr<dataGroup> pData=getData(groupId, order);
if(pData == 0 && bCreate)
{
pData = new dataGroup(this);
setGroup(groupId, order, pData);
}
return pData;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Set the requested group
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
void dataSet::setGroup(std::uint16_t groupId, std::uint16_t order, ptr<dataGroup> pGroup)
{
PUNTOEXE_FUNCTION_START(L"dataSet::setGroup");
setData(groupId, order, pGroup);
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Retrieve the image from the structure
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
ptr<image> dataSet::getImage(std::uint32_t frameNumber)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getImage");
// Lock this object
///////////////////////////////////////////////////////////
lockObject lockAccess(this);
// Retrieve the transfer syntax
///////////////////////////////////////////////////////////
std::wstring transferSyntax=getUnicodeString(0x0002, 0x0, 0x0010, 0x0);
// Get the right codec
///////////////////////////////////////////////////////////
ptr<codecs::codec> pCodec=codecs::codecFactory::getCodec(transferSyntax);
// Return if the codec has not been found
///////////////////////////////////////////////////////////
if(pCodec == 0)
{
PUNTOEXE_THROW(dataSetExceptionUnknownTransferSyntax, "None of the codecs support the specified transfer syntax");
}
ptr<imebra::data> imageTag = getTag(0x7fe0, 0x0, 0x0010, false);
if(imageTag == 0)
{
PUNTOEXE_THROW(dataSetImageDoesntExist, "The requested image doesn't exist");
}
std::string imageStreamDataType = imageTag->getDataType();
// Get the number of frames
///////////////////////////////////////////////////////////
std::uint32_t numberOfFrames = 1;
if(!getDataType(0x0028, 0, 0x0008).empty())
{
numberOfFrames = getUnsignedLong(0x0028, 0, 0x0008, 0);
}
if(frameNumber >= numberOfFrames)
{
PUNTOEXE_THROW(dataSetImageDoesntExist, "The requested image doesn't exist");
}
// Placeholder for the stream containing the image
///////////////////////////////////////////////////////////
ptr<streamReader> imageStream;
// Retrieve the second item in the image's tag.
// If the second item is present, then a multiframe
// image is present.
///////////////////////////////////////////////////////////
bool bDontNeedImagesPositions = false;
{
if(imageTag->getBufferSize(1) != 0)
{
std::uint32_t firstBufferId(0), endBufferId(0), totalLength(0);
if(imageTag->getBufferSize(0) == 0 && numberOfFrames + 1 == imageTag->getBuffersCount())
{
firstBufferId = frameNumber + 1;
endBufferId = firstBufferId + 1;
totalLength = imageTag->getBufferSize(firstBufferId);
}
else
{
totalLength = getFrameBufferIds(frameNumber, &firstBufferId, &endBufferId);
}
if(firstBufferId == endBufferId - 1)
{
imageStream = imageTag->getStreamReader(firstBufferId);
if(imageStream == 0)
{
PUNTOEXE_THROW(dataSetImageDoesntExist, "The requested image doesn't exist");
}
}
else
{
ptr<memory> temporaryMemory(memoryPool::getMemoryPool()->getMemory(totalLength));
const std::uint8_t* pDest = temporaryMemory->data();
for(std::uint32_t scanBuffers = firstBufferId; scanBuffers != endBufferId; ++scanBuffers)
{
ptr<handlers::dataHandlerRaw> bufferHandler = imageTag->getDataHandlerRaw(scanBuffers, false, "");
std::uint8_t* pSource = bufferHandler->getMemoryBuffer();
::memcpy((void*)pDest, (void*)pSource, bufferHandler->getSize());
pDest += bufferHandler->getSize();
}
ptr<baseStream> compositeStream(new memoryStream(temporaryMemory));
imageStream = ptr<streamReader>(new streamReader(compositeStream));
}
bDontNeedImagesPositions = true;
}
}
// If the image cannot be found, then probably we are
// handling an old dicom format.
// Then try to read the image from the next group with
// id=0x7fe
///////////////////////////////////////////////////////////
if(imageStream == 0)
{
imageStream = getStreamReader(0x7fe0, (std::uint16_t)frameNumber, 0x0010, 0x0);
bDontNeedImagesPositions = true;
}
// We are dealing with an old dicom format that doesn't
// include the image offsets and stores all the images
// in one buffer
///////////////////////////////////////////////////////////
if(imageStream == 0)
{
imageStream = imageTag->getStreamReader(0x0);
if(imageStream == 0)
{
PUNTOEXE_THROW(dataSetImageDoesntExist, "The requested image doesn't exist");
}
// Reset an internal array that keeps track of the
// images position
///////////////////////////////////////////////////////////
if(m_imagesPositions.size() != numberOfFrames)
{
m_imagesPositions.resize(numberOfFrames);
for(std::uint32_t resetImagesPositions = 0; resetImagesPositions < numberOfFrames; m_imagesPositions[resetImagesPositions++] = 0)
{}// empty loop
}
// Read all the images before the desidered one so we set
// reading position in the stream
///////////////////////////////////////////////////////////
for(std::uint32_t readImages = 0; readImages < frameNumber; readImages++)
{
std::uint32_t offsetPosition = m_imagesPositions[readImages];
if(offsetPosition == 0)
{
ptr<image> tempImage = pCodec->getImage(this, imageStream, imageStreamDataType);
m_imagesPositions[readImages] = imageStream->position();
continue;
}
if((m_imagesPositions[readImages + 1] == 0) || (readImages == (frameNumber - 1)))
{
imageStream->seek(offsetPosition);
}
}
}
double pixelDistanceX=getDouble(0x0028, 0x0, 0x0030, 0);
double pixelDistanceY=getDouble(0x0028, 0x0, 0x0030, 1);
if(bDontNeedImagesPositions)
{
lockAccess.unlock();
}
ptr<image> pImage;
pImage = pCodec->getImage(this, imageStream, imageStreamDataType);
if(!bDontNeedImagesPositions && m_imagesPositions.size() > frameNumber)
{
m_imagesPositions[frameNumber] = imageStream->position();
}
// If the image has been returned correctly, then set
// the image's size
///////////////////////////////////////////////////////////
if(pImage != 0)
{
std::uint32_t sizeX, sizeY;
pImage->getSize(&sizeX, &sizeY);
pImage->setSizeMm(pixelDistanceX*(double)sizeX, pixelDistanceY*(double)sizeY);
}
if(pImage->getColorSpace() == L"PALETTE COLOR")
{
ptr<lut> red(new lut), green(new lut), blue(new lut);
red->setLut(getDataHandler(0x0028, 0x0, 0x1101, 0, false), getDataHandler(0x0028, 0x0, 0x1201, 0, false), L"");
green->setLut(getDataHandler(0x0028, 0x0, 0x1102, 0, false), getDataHandler(0x0028, 0x0, 0x1202, 0, false), L"");
blue->setLut(getDataHandler(0x0028, 0x0, 0x1103, 0, false), getDataHandler(0x0028, 0x0, 0x1203, 0, false), L"");
ptr<palette> imagePalette(new palette(red, green, blue));
pImage->setPalette(imagePalette);
}
return pImage;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get an image from the dataset and apply the modality
// transform.
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
ptr<image> dataSet::getModalityImage(std::uint32_t frameNumber)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getImage");
ptr<image> originalImage = getImage(frameNumber);
ptr<transforms::colorTransforms::colorTransformsFactory> colorFactory(transforms::colorTransforms::colorTransformsFactory::getColorTransformsFactory());
if(originalImage == 0 || !colorFactory->isMonochrome(originalImage->getColorSpace()))
{
return originalImage;
}
ptr<transforms::modalityVOILUT> modalityVOILUT(new transforms::modalityVOILUT(this));
// Convert to MONOCHROME2 if a modality transform is not present
////////////////////////////////////////////////////////////////
if(modalityVOILUT->isEmpty())
{
ptr<transforms::colorTransforms::colorTransform> monochromeColorTransform(colorFactory->getTransform(originalImage->getColorSpace(), L"MONOCHROME2"));
if(monochromeColorTransform != 0)
{
std::uint32_t width, height;
originalImage->getSize(&width, &height);
ptr<image> outputImage = monochromeColorTransform->allocateOutputImage(originalImage, width, height);
monochromeColorTransform->runTransform(originalImage, 0, 0, width, height, outputImage, 0, 0);
return outputImage;
}
return originalImage;
}
// Apply the modality VOI/LUT transform
///////////////////////////////////////
std::uint32_t width, height;
originalImage->getSize(&width, &height);
ptr<image> outputImage = modalityVOILUT->allocateOutputImage(originalImage, width, height);
modalityVOILUT->runTransform(originalImage, 0, 0, width, height, outputImage, 0, 0);
return outputImage;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Insert an image into the dataset
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
void dataSet::setImage(std::uint32_t frameNumber, ptr<image> pImage, std::wstring transferSyntax, codecs::codec::quality quality)
{
PUNTOEXE_FUNCTION_START(L"dataSet::setImage");
// Lock the entire dataset
///////////////////////////////////////////////////////////
lockObject lockAccess(this);
// All the commit are in one transaction
///////////////////////////////////////////////////////////
transaction localTransaction(true);
// The group, order, tag and buffer where the image must
// be stored
///////////////////////////////////////////////////////////
std::uint16_t groupId(0x7fe0), orderId(0), tagId(0x0010);
std::uint32_t firstBufferId(0);
// bDontChangeAttributes is true if some images already
// exist in the dataset and we must save the new image
// using the attributes already stored
///////////////////////////////////////////////////////////
std::uint32_t numberOfFrames = getUnsignedLong(0x0028, 0, 0x0008, 0);
if(frameNumber != numberOfFrames)
{
PUNTOEXE_THROW(dataSetExceptionWrongFrame, "The frames must be inserted in sequence");
}
bool bDontChangeAttributes = (numberOfFrames != 0);
if(bDontChangeAttributes)
{
transferSyntax = getUnicodeString(0x0002, 0x0, 0x0010, 0x0);
}
// Select the right codec
///////////////////////////////////////////////////////////
ptr<codecs::codec> saveCodec(codecs::codecFactory::getCodec(transferSyntax));
if(saveCodec == 0L)
{
PUNTOEXE_THROW(dataSetExceptionUnknownTransferSyntax, "None of the codec support the requested transfer syntax");
}
// Do we have to save the basic offset table?
///////////////////////////////////////////////////////////
bool bEncapsulated = saveCodec->encapsulated(transferSyntax) ||
(getDataHandlerRaw(groupId, 0x0, tagId, 0x1, false) != 0);
// Check if we are dealing with an old Dicom format...
///////////////////////////////////////////////////////////
std::string dataHandlerType = getDataType(0x7fe0, 0x1, 0x0010);
if(!dataHandlerType.empty())
{
orderId = (std::uint16_t)frameNumber;
bEncapsulated = false;
}
// Set the subsampling flags
///////////////////////////////////////////////////////////
bool bSubSampledX = quality > codecs::codec::high;
bool bSubSampledY = quality > codecs::codec::medium;
if( !transforms::colorTransforms::colorTransformsFactory::canSubsample(pImage->getColorSpace()) )
{
bSubSampledX = bSubSampledY = false;
}
image::bitDepth depth = pImage->getDepth();
bool b2complement = (depth == image::depthS32 || depth == image::depthS16 || depth == image::depthS8);
std::uint32_t channelsNumber = pImage->getChannelsNumber();
std::uint8_t allocatedBits = (std::uint8_t)(saveCodec->suggestAllocatedBits(transferSyntax, pImage->getHighBit()));
bool bInterleaved(false);
if(getDataType(0x0028, 0, 0x0006).empty())
{
if(channelsNumber > 1)
{
bInterleaved = true;
setUnsignedLong(0x0028, 0, 0x0006, 0, 0, "US");
}
}
else
{
bInterleaved = (getUnsignedLong(0x0028, 0x0, 0x0006, 0x0) == 0x0);
}
// If the attributes cannot be changed, then check the
// attributes already stored in the dataset
///////////////////////////////////////////////////////////
if(bDontChangeAttributes)
{
pImage = convertImageForDataSet(pImage);
std::wstring currentColorSpace = getUnicodeString(0x0028, 0x0, 0x0004, 0x0);
bSubSampledX = transforms::colorTransforms::colorTransformsFactory::isSubsampledX(currentColorSpace);
bSubSampledY = transforms::colorTransforms::colorTransformsFactory::isSubsampledY(currentColorSpace);
b2complement = (getUnsignedLong(0x0028, 0, 0x0103, 0) != 0);
allocatedBits = (std::uint8_t)getUnsignedLong(0x0028, 0x0, 0x0100, 0x0);
channelsNumber = getUnsignedLong(0x0028, 0x0, 0x0002, 0x0);
}
// Select the data type OB if not already set in the
// dataset
///////////////////////////////////////////////////////////
if(dataHandlerType.empty())
{
if(transferSyntax == L"1.2.840.10008.1.2")
{
dataHandlerType = getDefaultDataType(0x7FE0, 0x0010);
}
else
{
dataHandlerType = (bEncapsulated || allocatedBits <= 8) ? "OB" : "OW";
}
}
// Encapsulated mode. Check if we have the offsets table
///////////////////////////////////////////////////////////
if(bEncapsulated)
{
// We have to add the offsets buffer
///////////////////////////////////////////////////////////
ptr<handlers::dataHandlerRaw> imageHandler0 = getDataHandlerRaw(groupId, 0x0, tagId, 0x0, false);
ptr<handlers::dataHandlerRaw> imageHandler1 = getDataHandlerRaw(groupId, 0x0, tagId, 0x1, false);
if(imageHandler0 != 0L && imageHandler0->getSize() != 0 && imageHandler1 == 0L)
{
// The first image must be moved forward, in order to
// make some room for the offset table
///////////////////////////////////////////////////////////
dataHandlerType = imageHandler0->getDataType();
ptr<handlers::dataHandlerRaw> moveFirstImage = getDataHandlerRaw(groupId, 0x0, tagId, 0x1, true, dataHandlerType);
if(moveFirstImage == 0L)
{
PUNTOEXE_THROW(dataSetExceptionOldFormat, "Cannot move the first image");
}
std::uint32_t bufferSize=imageHandler0->getSize();
moveFirstImage->setSize(bufferSize);
::memcpy(moveFirstImage->getMemoryBuffer(), imageHandler0->getMemoryBuffer(), bufferSize);
}
// An image in the first buffer already exists.
///////////////////////////////////////////////////////////
if(imageHandler1 != 0)
{
dataHandlerType = imageHandler1->getDataType();
}
firstBufferId = getFirstAvailFrameBufferId();
}
// Get a stream to save the image
///////////////////////////////////////////////////////////
ptr<streamWriter> outputStream;
ptr<memory> uncompressedImage(new memory);
if(bEncapsulated || frameNumber == 0)
{
outputStream = getStreamWriter(groupId, orderId, tagId, firstBufferId, dataHandlerType);
}
else
{
ptr<puntoexe::memoryStream> memStream(new memoryStream(uncompressedImage));
outputStream = new streamWriter(memStream);
}
// Save the image in the stream
///////////////////////////////////////////////////////////
saveCodec->setImage(
outputStream,
pImage,
transferSyntax,
quality,
dataHandlerType,
allocatedBits,
bSubSampledX, bSubSampledY,
bInterleaved,
b2complement);
outputStream->flushDataBuffer();
if(!bEncapsulated && frameNumber != 0)
{
ptr<handlers::dataHandlerRaw> copyUncompressed(getDataHandlerRaw(groupId, orderId, tagId, firstBufferId, true));
copyUncompressed->setSize((frameNumber + 1) * uncompressedImage->size());
std::uint8_t* pSource = uncompressedImage->data();
std::uint8_t* pDest = copyUncompressed->getMemoryBuffer() + (frameNumber * uncompressedImage->size());
::memcpy(pDest, pSource, uncompressedImage->size());
}
// The images' positions calculated by getImage are not
// valid now. They must be recalculated.
///////////////////////////////////////////////////////////
m_imagesPositions.clear();
// Write the attributes in the dataset
///////////////////////////////////////////////////////////
if(!bDontChangeAttributes)
{
ptr<handlers::dataHandler> dataHandlerTransferSyntax = getDataHandler(0x0002, 0x0, 0x0010, 0x0, true);
dataHandlerTransferSyntax->setUnicodeString(0, transferSyntax);
std::wstring colorSpace = pImage->getColorSpace();
setUnicodeString(0x0028, 0x0, 0x0004, 0x0, transforms::colorTransforms::colorTransformsFactory::makeSubsampled(colorSpace, bSubSampledX, bSubSampledY));
setUnsignedLong(0x0028, 0x0, 0x0006, 0x0, bInterleaved ? 0 : 1);
setUnsignedLong(0x0028, 0x0, 0x0100, 0x0, allocatedBits); // allocated bits
setUnsignedLong(0x0028, 0x0, 0x0101, 0x0, pImage->getHighBit() + 1); // stored bits
setUnsignedLong(0x0028, 0x0, 0x0102, 0x0, pImage->getHighBit()); // high bit
setUnsignedLong(0x0028, 0x0, 0x0103, 0x0, b2complement ? 1 : 0);
setUnsignedLong(0x0028, 0x0, 0x0002, 0x0, channelsNumber);
std::uint32_t imageSizeX, imageSizeY;
pImage->getSize(&imageSizeX, &imageSizeY);
setUnsignedLong(0x0028, 0x0, 0x0011, 0x0, imageSizeX);
setUnsignedLong(0x0028, 0x0, 0x0010, 0x0, imageSizeY);
if(colorSpace == L"PALETTECOLOR")
{
ptr<palette> imagePalette(pImage->getPalette());
if(imagePalette != 0)
{
imagePalette->getRed()->fillHandlers(getDataHandler(0x0028, 0x0, 0x1101, 0, true), getDataHandler(0x0028, 0x0, 0x1201, 0, true));
imagePalette->getGreen()->fillHandlers(getDataHandler(0x0028, 0x0, 0x1102, 0, true), getDataHandler(0x0028, 0x0, 0x1202, 0, true));
imagePalette->getBlue()->fillHandlers(getDataHandler(0x0028, 0x0, 0x1103, 0, true), getDataHandler(0x0028, 0x0, 0x1203, 0, true));
}
}
double imageSizeMmX, imageSizeMmY;
pImage->getSizeMm(&imageSizeMmX, &imageSizeMmY);
}
// Update the number of frames
///////////////////////////////////////////////////////////
numberOfFrames = frameNumber + 1;
setUnsignedLong(0x0028, 0, 0x0008, 0, numberOfFrames );
// Update the offsets tag with the image's offsets
///////////////////////////////////////////////////////////
if(!bEncapsulated)
{
return;
}
std::uint32_t calculatePosition(0);
ptr<data> tag(getTag(groupId, 0, tagId, true));
for(std::uint32_t scanBuffers = 1; scanBuffers != firstBufferId; ++scanBuffers)
{
calculatePosition += tag->getBufferSize(scanBuffers);
calculatePosition += 8;
}
ptr<handlers::dataHandlerRaw> offsetHandler(getDataHandlerRaw(groupId, 0, tagId, 0, true, dataHandlerType));
offsetHandler->setSize(4 * (frameNumber + 1));
std::uint8_t* pOffsetFrame(offsetHandler->getMemoryBuffer() + (frameNumber * 4));
*( (std::uint32_t*)pOffsetFrame ) = calculatePosition;
streamController::adjustEndian(pOffsetFrame, 4, streamController::lowByteEndian, 1);
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
// Get the offset, in bytes, of the specified frame
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
std::uint32_t dataSet::getFrameOffset(std::uint32_t frameNumber)
{
// Retrieve the buffer containing the offsets
///////////////////////////////////////////////////////////
ptr<handlers::dataHandlerRaw> framesPointer = getDataHandlerRaw(0x7fe0, 0x0, 0x0010, 0, false);
if(framesPointer == 0)
{
return 0xffffffff;
}
// Get the offset table's size, in number of offsets
///////////////////////////////////////////////////////////
std::uint32_t offsetsCount = framesPointer->getSize() / sizeof(std::uint32_t);
// If the requested frame doesn't exist then return
// 0xffffffff (the maximum value)
///////////////////////////////////////////////////////////
if(frameNumber >= offsetsCount && frameNumber != 0)
{
return 0xffffffff;
}
// Return the requested offset. If the requested frame is
// the first and is offset is not specified, then return
// 0 (the first position)
///////////////////////////////////////////////////////////
if(frameNumber < offsetsCount)
{
std::uint32_t* pOffsets = (std::uint32_t*)(framesPointer->getMemoryBuffer());
std::uint32_t returnOffset(pOffsets[frameNumber]);
streamController::adjustEndian((std::uint8_t*)&returnOffset, 4, streamController::lowByteEndian);
return returnOffset;
}
return 0;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
// Return the buffer that starts at the specified offset
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
std::uint32_t dataSet::getFrameBufferId(std::uint32_t offset, std::uint32_t* pLengthToBuffer)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getFrameBufferId");
*pLengthToBuffer = 0;
ptr<data> imageTag = getTag(0x7fe0, 0, 0x0010, false);
if(imageTag == 0)
{
return 0;
}
// Start from the buffer n. 1 (the buffer 0 contains
// the offset table
///////////////////////////////////////////////////////////
std::uint32_t scanBuffers(1);
if(offset == 0xffffffff)
{
while(imageTag->bufferExists(scanBuffers))
{
++scanBuffers;
}
return scanBuffers;
}
while(offset != 0)
{
// If the handler isn't connected to any buffer, then
// the buffer doesn't exist: return
///////////////////////////////////////////////////////////
if(!imageTag->bufferExists(scanBuffers))
{
break;
}
// Calculate the total size of the buffer, including
// its descriptor (tag group and id and length)
///////////////////////////////////////////////////////////
std::uint32_t bufferSize = imageTag->getBufferSize(scanBuffers);;
(*pLengthToBuffer) += bufferSize; // Increase the total size
bufferSize += 4; // one WORD for the group id, one WORD for the tag id
bufferSize += 4; // one DWORD for the tag length
if(bufferSize > offset)
{
PUNTOEXE_THROW(dataSetImageDoesntExist, "Image not in the offset table");
}
offset -= bufferSize;
++scanBuffers;
}
if(offset != 0)
{
PUNTOEXE_THROW(dataSetCorruptedOffsetTable, "The basic offset table is corrupted");
}
return scanBuffers;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get the first buffer and the end buffer occupied by an
// image
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
std::uint32_t dataSet::getFrameBufferIds(std::uint32_t frameNumber, std::uint32_t* pFirstBuffer, std::uint32_t* pEndBuffer)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getFrameBufferIds");
std::uint32_t startOffset = getFrameOffset(frameNumber);
std::uint32_t endOffset = getFrameOffset(frameNumber + 1);
if(startOffset == 0xffffffff)
{
PUNTOEXE_THROW(dataSetImageDoesntExist, "Image not in the table offset");
}
std::uint32_t startLength, endLength;
*pFirstBuffer = getFrameBufferId(startOffset, &startLength);
*pEndBuffer = getFrameBufferId(endOffset, &endLength);
ptr<data> imageTag = getTag(0x7fe0, 0, 0x0010, false);
if(imageTag == 0)
{
return 0;
}
std::uint32_t totalSize(0);
for(std::uint32_t scanBuffers(*pFirstBuffer); scanBuffers != *pEndBuffer; ++scanBuffers)
{
totalSize += imageTag->getBufferSize(scanBuffers);
}
return totalSize;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Return the id of the first available buffer that can
// be used to store a new frame
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
std::uint32_t dataSet::getFirstAvailFrameBufferId()
{
PUNTOEXE_FUNCTION_START(L"dataSet::getFirstAvailFrameBufferId");
ptr<data> imageTag = getTag(0x7fe0, 0, 0x0010, false);
if(imageTag == 0)
{
return 1;
}
std::uint32_t availableId(1);
while(imageTag->bufferExists(availableId))
{
++availableId;
}
return availableId;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Converts an image using the attributes specified in
// the dataset.
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
ptr<image> dataSet::convertImageForDataSet(ptr<image> sourceImage)
{
PUNTOEXE_FUNCTION_START(L"dataSet::convertImageForDataSet");
std::uint32_t imageWidth, imageHeight;
sourceImage->getSize(&imageWidth, &imageHeight);
std::wstring colorSpace = sourceImage->getColorSpace();
std::uint32_t highBit = sourceImage->getHighBit();
std::uint32_t currentWidth = getUnsignedLong(0x0028, 0x0, 0x0011, 0x0);
std::uint32_t currentHeight = getUnsignedLong(0x0028, 0x0, 0x0010, 0x0);
std::uint32_t currentHighBit = getUnsignedLong(0x0028, 0x0, 0x0102, 0x0);
std::wstring currentColorSpace = transforms::colorTransforms::colorTransformsFactory::normalizeColorSpace(getUnicodeString(0x0028, 0x0, 0x0004, 0x0));
if(currentWidth != imageWidth || currentHeight != imageHeight)
{
PUNTOEXE_THROW(dataSetExceptionDifferentFormat, "The dataset already contains an image with a different size");
}
if(currentHighBit < highBit)
{
PUNTOEXE_THROW(dataSetExceptionDifferentFormat, "The high bit in the dataset is smaller than the requested one");
}
if( !transforms::colorTransforms::colorTransformsFactory::isMonochrome(colorSpace) && colorSpace != currentColorSpace)
{
PUNTOEXE_THROW(dataSetExceptionDifferentFormat, "The requested color space doesn't match the one already stored in the dataset");
}
ptr<transforms::transformsChain> chain(new transforms::transformsChain);
if(colorSpace != currentColorSpace)
{
ptr<transforms::colorTransforms::colorTransformsFactory> pColorFactory(transforms::colorTransforms::colorTransformsFactory::getColorTransformsFactory());
ptr<transforms::transform> colorChain = pColorFactory->getTransform(colorSpace, currentColorSpace);
if(colorChain->isEmpty())
{
PUNTOEXE_THROW(dataSetExceptionDifferentFormat, "The image color space cannot be converted to the dataset color space");
}
chain->addTransform(colorChain);
}
if(currentHighBit != highBit)
{
chain->addTransform(new transforms::transformHighBit);
}
if(chain->isEmpty())
{
return sourceImage;
}
ptr<image> destImage(new image);
bool b2Complement(getUnsignedLong(0x0028, 0x0, 0x0103, 0x0)!=0x0);
image::bitDepth depth;
if(b2Complement)
depth=highBit>=8 ? image::depthS16 : image::depthS8;
else
depth=highBit>=8 ? image::depthU16 : image::depthU8;
destImage->create(currentWidth, currentHeight, depth, currentColorSpace, currentHighBit);
chain->runTransform(sourceImage, 0, 0, imageWidth, imageHeight, destImage, 0, 0);
return destImage;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Retrieve a sequence item as a dataset
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
ptr<dataSet> dataSet::getSequenceItem(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t itemId)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getSequenceItem");
ptr<data> tag=getTag(groupId, order, tagId, false);
ptr<dataSet> pDataSet;
if(tag != 0)
{
pDataSet = tag->getDataSet(itemId);
}
return pDataSet;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Retrieve a LUT from the data set
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
ptr<lut> dataSet::getLut(std::uint16_t groupId, std::uint16_t tagId, std::uint32_t lutId)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getLut");
lockObject lockAccess(this);
ptr<lut> pLUT;
ptr<dataSet> embeddedLUT=getSequenceItem(groupId, 0, tagId, lutId);
std::string tagType = getDataType(groupId, 0, tagId);
if(embeddedLUT != 0)
{
ptr<lut> tempLut(new lut);
pLUT = tempLut;
ptr<handlers::dataHandler> descriptorHandle=embeddedLUT->getDataHandler(0x0028, 0x0, 0x3002, 0x0, false);
ptr<handlers::dataHandler> dataHandle=embeddedLUT->getDataHandler(0x0028, 0x0, 0x3006, 0x0, false);
pLUT->setLut(
descriptorHandle,
dataHandle,
embeddedLUT->getUnicodeString(0x0028, 0x0, 0x3003, 0x0));
}
return pLUT;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Retrieve a waveform
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
ptr<waveform> dataSet::getWaveform(std::uint32_t waveformId)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getWaveform");
lockObject lockAccess(this);
ptr<dataSet> embeddedWaveform(getSequenceItem(0x5400, 0, 0x0100, waveformId));
if(embeddedWaveform == 0)
{
return 0;
}
return new waveform(embeddedWaveform);
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get a tag as a signed long
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
std::int32_t dataSet::getSignedLong(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t elementNumber)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getSignedLong");
ptr<handlers::dataHandler> dataHandler=getDataHandler(groupId, order, tagId, 0, false);
if(dataHandler == 0)
{
return 0;
}
return dataHandler->pointerIsValid(elementNumber) ? dataHandler->getSignedLong(elementNumber) : 0;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Set a tag as a signed long
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
void dataSet::setSignedLong(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t elementNumber, std::int32_t newValue, std::string defaultType /* = "" */)
{
PUNTOEXE_FUNCTION_START(L"dataSet::setSignedLong");
ptr<handlers::dataHandler> dataHandler=getDataHandler(groupId, order, tagId, 0, true, defaultType);
if(dataHandler != 0)
{
if(dataHandler->getSize() <= elementNumber)
{
dataHandler->setSize(elementNumber + 1);
}
dataHandler->setSignedLong(elementNumber, newValue);
}
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get the requested tag as an unsigned long
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
std::uint32_t dataSet::getUnsignedLong(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t elementNumber)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getUnignedLong");
ptr<handlers::dataHandler> dataHandler=getDataHandler(groupId, order, tagId, 0, false);
if(dataHandler == 0)
{
return 0;
}
return dataHandler->pointerIsValid(elementNumber) ? dataHandler->getUnsignedLong(elementNumber) : 0;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Set the requested tag as an unsigned long
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
void dataSet::setUnsignedLong(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t elementNumber, std::uint32_t newValue, std::string defaultType /* = "" */)
{
PUNTOEXE_FUNCTION_START(L"dataSet::setUnsignedLong");
ptr<handlers::dataHandler> dataHandler=getDataHandler(groupId, order, tagId, 0, true, defaultType);
if(dataHandler != 0)
{
if(dataHandler->getSize() <= elementNumber)
{
dataHandler->setSize(elementNumber + 1);
}
dataHandler->setUnsignedLong(elementNumber, newValue);
}
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get the requested tag as a double
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
double dataSet::getDouble(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t elementNumber)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getDouble");
ptr<handlers::dataHandler> dataHandler=getDataHandler(groupId, order, tagId, 0, false);
if(dataHandler == 0)
{
return 0.0;
}
return dataHandler->pointerIsValid(elementNumber) ? dataHandler->getDouble(elementNumber) : 0.0;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Set the requested tag as a double
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
void dataSet::setDouble(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t elementNumber, double newValue, std::string defaultType /* = "" */)
{
PUNTOEXE_FUNCTION_START(L"dataSet::setDouble");
ptr<handlers::dataHandler> dataHandler=getDataHandler(groupId, order, tagId, 0, true, defaultType);
if(dataHandler != 0)
{
if(dataHandler->getSize() <= elementNumber)
{
dataHandler->setSize(elementNumber + 1);
}
dataHandler->setDouble(elementNumber, newValue);
}
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get the requested tag as a string
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
std::string dataSet::getString(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t elementNumber)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getString");
ptr<handlers::dataHandler> dataHandler=getDataHandler(groupId, order, tagId, 0L, false);
std::string returnValue;
if(dataHandler != 0)
{
if(dataHandler->pointerIsValid(elementNumber))
{
returnValue = dataHandler->getString(elementNumber);
}
}
return returnValue;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get the requested tag as an unicode string
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
std::wstring dataSet::getUnicodeString(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t elementNumber)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getUnicodeString");
ptr<handlers::dataHandler> dataHandler=getDataHandler(groupId, order, tagId, 0L, false);
std::wstring returnValue;
if(dataHandler != 0)
{
if(dataHandler->pointerIsValid(elementNumber))
{
returnValue = dataHandler->getUnicodeString(elementNumber);
}
}
return returnValue;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Set the requested tag as a string
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
void dataSet::setString(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t elementNumber, std::string newString, std::string defaultType /* = "" */)
{
PUNTOEXE_FUNCTION_START(L"dataSet::setString");
ptr<handlers::dataHandler> dataHandler=getDataHandler(groupId, order, tagId, 0L, true, defaultType);
if(dataHandler != 0)
{
if(dataHandler->getSize() <= elementNumber)
{
dataHandler->setSize(elementNumber + 1);
}
dataHandler->setString(elementNumber, newString);
}
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Set the requested tag as a string
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
void dataSet::setUnicodeString(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t elementNumber, std::wstring newString, std::string defaultType /* = "" */)
{
PUNTOEXE_FUNCTION_START(L"dataSet::setUnicodeString");
ptr<handlers::dataHandler> dataHandler=getDataHandler(groupId, order, tagId, 0L, true, defaultType);
if(dataHandler != 0)
{
if(dataHandler->getSize() <= elementNumber)
{
dataHandler->setSize(elementNumber + 1);
}
dataHandler->setUnicodeString(elementNumber, newString);
}
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get a data handler for the requested tag
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
ptr<handlers::dataHandler> dataSet::getDataHandler(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t bufferId, bool bWrite, std::string defaultType /* ="" */)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getDataHandler");
lockObject lockAccess(this);
ptr<dataGroup> group=getGroup(groupId, order, bWrite);
ptr<handlers::dataHandler> pDataHandler;
if(group == 0)
{
return pDataHandler;
}
if(defaultType.length()!=2L)
{
defaultType=getDefaultDataType(groupId, tagId);
}
pDataHandler = group->getDataHandler(tagId, bufferId, bWrite, defaultType);
return pDataHandler;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get a stream reader that works on the specified tag
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
ptr<streamReader> dataSet::getStreamReader(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t bufferId)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getStream");
lockObject lockAccess(this);
ptr<dataGroup> group=getGroup(groupId, order, false);
ptr<streamReader> returnStream;
if(group != 0)
{
returnStream = group->getStreamReader(tagId, bufferId);
}
return returnStream;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Retrieve a stream writer for the specified tag
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
ptr<streamWriter> dataSet::getStreamWriter(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t bufferId, std::string dataType /* = "" */)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getStream");
lockObject lockAccess(this);
ptr<dataGroup> group=getGroup(groupId, order, true);
ptr<streamWriter> returnStream;
if(group != 0)
{
returnStream = group->getStreamWriter(tagId, bufferId, dataType);
}
return returnStream;
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get a raw data handler for the requested tag
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
ptr<handlers::dataHandlerRaw> dataSet::getDataHandlerRaw(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId, std::uint32_t bufferId, bool bWrite, std::string defaultType /* ="" */)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getDataHandlerRaw");
lockObject lockAccess(this);
ptr<dataGroup> group=getGroup(groupId, order, bWrite);
if(group == 0)
{
ptr<handlers::dataHandlerRaw> emptyDataHandler;
return emptyDataHandler;
}
if(defaultType.length()!=2)
{
defaultType=getDefaultDataType(groupId, tagId);
}
return group->getDataHandlerRaw(tagId, bufferId, bWrite, defaultType);
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Retrieve the requested tag's default data type
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
std::string dataSet::getDefaultDataType(std::uint16_t groupId, std::uint16_t tagId)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getDefaultDataType");
return dicomDictionary::getDicomDictionary()->getTagType(groupId, tagId);
PUNTOEXE_FUNCTION_END();
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get the data type of a tag
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
std::string dataSet::getDataType(std::uint16_t groupId, std::uint16_t order, std::uint16_t tagId)
{
PUNTOEXE_FUNCTION_START(L"dataSet::getDataType");
std::string bufferType;
ptr<data> tag = getTag(groupId, order, tagId, false);
if(tag != 0)
{
bufferType = tag->getDataType();
}
return bufferType;
PUNTOEXE_FUNCTION_END();
}
void dataSet::updateCharsetTag()
{
charsetsList::tCharsetsList charsets;
getCharsetsList(&charsets);
ptr<handlers::dataHandler> charsetHandler(getDataHandler(0x0008, 0, 0x0005, 0, true));
charsetHandler->setSize((std::uint32_t)(charsets.size()));
std::uint32_t pointer(0);
for(charsetsList::tCharsetsList::iterator scanCharsets = charsets.begin(); scanCharsets != charsets.end(); ++scanCharsets)
{
charsetHandler->setUnicodeString(pointer++, *scanCharsets);
}
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Update the list of the used charsets
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
void dataSet::updateTagsCharset()
{
charsetsList::tCharsetsList charsets;
ptr<handlers::dataHandler> charsetHandler(getDataHandler(0x0008, 0, 0x0005, 0, false));
if(charsetHandler != 0)
{
for(std::uint32_t pointer(0); charsetHandler->pointerIsValid(pointer); ++pointer)
{
charsets.push_back(charsetHandler->getUnicodeString(pointer));
}
}
setCharsetsList(&charsets);
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Set the item's position in the stream
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
void dataSet::setItemOffset(std::uint32_t offset)
{
m_itemOffset = offset;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get the item's position in the stream
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
std::uint32_t dataSet::getItemOffset()
{
return m_itemOffset;
}
} // namespace imebra
} // namespace puntoexe
|
8f4339dad4781dac5cd007e13a404b99ca3badb3 | 636c39ed78d7c61a1fcc33e9af311f52cb2b8af8 | /thanm_ex/thanm_ex.cpp | 5042278f4cc3c3010b85755ca8bccfa0299aac99 | [] | no_license | Natashi/thanm-ex | 827f86f9f768471b14c3db43a895b1d5a73d46a4 | c8c1b09fce70f0563a78ee90cfe5af7b131d2424 | refs/heads/master | 2022-11-23T17:45:42.559499 | 2020-07-23T16:38:05 | 2020-07-23T16:38:05 | 282,003,797 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 756 | cpp | thanm_ex.cpp | #include "pch.h"
#include "Instruction.h"
#include "Archive.h"
void PrintHelp() {
printf(
"Format: COMMAND ARGS...\n"
" COMMAND can be:\n"
" l ARCHIVE OUTPUT - Decompiles the archive.\n"
//" x \n"
);
}
int wmain(int argc, wchar_t* argv[]) {
if (argc < 2) {
PrintHelp();
return 0;
}
switch (*argv[1]) {
case L'l':
{
if (argc != 4) {
PrintHelp();
break;
}
InstructionDataManager* instrListManager = new InstructionDataManager;
Archive anm;
anm.Load(argv[2]);
anm.Write(argv[3]);
delete instrListManager;
break;
}
default:
PrintHelp();
}
return 0;
}
|
038b6c57c30781ba1114e956cbfd98a4d9c8b65e | 8a73ceef91ee13bd9ab7c3c0bfb8e95fa26447e5 | /src/engine/RPSEngine.h | 2ea8d7e944ce113f3a204c433c280a79a4f8c180 | [] | no_license | chupAkabRRa/RPSGame | 0922fe744bd4ce225281c680ff6d99c434cf932b | 0204229959c45ecd1a859d231883c4976b3a2f11 | refs/heads/master | 2021-09-22T01:27:47.562366 | 2018-09-04T17:46:37 | 2018-09-04T17:46:37 | 146,426,671 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 800 | h | RPSEngine.h | #ifndef _RPS_ENGINE_H_
#define _RPS_ENGINE_H_
#include <memory>
#include <map>
#include "IScene.h"
#include "IGameState.h"
#include "sdl/SDL.h"
class RPSEngine
{
public:
enum eScene
{
eScene_Menu = 0,
eScene_Game = 1,
eScene_LobbyCreate = 2,
eScene_LobbyJoin = 3
};
RPSEngine() = default;
~RPSEngine();
bool Initialize(IGameState* cb);
void Close();
void Animate();
void SetActiveScene(eScene scene);
private:
bool m_bSDLInitialized = false;
bool m_bSDLImgInitialized = false;
bool m_bTTFInitialized = false;
SDL_Window* m_pWindow;
SDL_Renderer* m_pRenderer;
IGameState* m_pGameStateCb;
std::map<eScene, std::unique_ptr<IScene>> m_vScenes;
eScene m_iActiveScene;
};
#endif // _RPS_ENGINE_H_ |
fc574347a810d1bab6e623a083ad4b341a0c1daf | 41f673ad07afb77223bb9ea8afb212f9a81fc010 | /src/json_importer.cpp | 122a62aeee3f7761805d75957a3cddc3bdd1dc47 | [] | no_license | DiMonster07/Roguelike | a605e5c53b6269f116f1666114557cbf544ebb94 | 4b4065e62e4b358edf87c60691e2c45e8d53c0c5 | refs/heads/master | 2021-01-24T21:53:39.295378 | 2016-06-29T03:35:45 | 2016-06-29T03:35:45 | 54,559,221 | 2 | 0 | null | 2016-06-24T06:00:52 | 2016-03-23T12:47:40 | C++ | UTF-8 | C++ | false | false | 1,723 | cpp | json_importer.cpp | #include "json_importer.h"
Json_importer::Json_importer(char *file_name)
{
file = std::fopen(file_name, "r");
if (!file) {
std::cout << "Config file " << file_name << " was not found\n";
exit(1);
}
this->parse();
}
Json_importer::~Json_importer()
{
std::fclose(file);
}
int Json_importer::get_int(char* class_name, char* attr)
{
auto obj = get_obj(class_name);
auto iter = obj.FindMember(attr);
if (iter != obj.MemberEnd())
{
auto type = iter->value.GetType();
if (type != rapidjson::kNumberType)
{
std::cout << class_name << "." << attr << " is not an integer\n";
exit(1);
}
else {
return iter->value.GetInt();
}
}
else
{
std::cout << "Key " << attr << " in object " << class_name << " was not found\n";
exit(1);
}
}
char Json_importer::get_char(char* class_name, char* attr)
{
auto obj = get_obj(class_name);
auto iter = obj.FindMember(attr);
if (iter != obj.MemberEnd())
{
auto type = iter->value.GetType();
if (type != rapidjson::kStringType)
{
std::cout << class_name << "." << attr << " is not a string\n";
exit(1);
}
else
if (iter->value.GetStringLength())
return iter->value.GetString()[0];
else {
std::cout << "Key " << attr << " in object " << class_name << " is empty string\n";
exit(1);
}
}
else
{
std::cout << "Key " << attr << " in object " << class_name << " was not found\n";
exit(1);
}
}
void Json_importer::parse()
{
char buffer[65536];
rapidjson::FileReadStream source(file, buffer, sizeof(buffer));
rapidjson::ParseResult result = data.ParseStream(source);
if (!result) {
std::cout << "JSON parse error: "
<< rapidjson::GetParseError_En(result.Code()) << std::endl;
exit(1);
}
}
|
e9c7e7ea6ec45133d602620df8e5859efe2d910c | 189f52bf5454e724d5acc97a2fa000ea54d0e102 | /ras/fluidisedBed/0.96/T.air | 5bfe65430d0bb783899bdb262c5ed3fc50598b80 | [] | no_license | pyotr777/openfoam_samples | 5399721dd2ef57545ffce68215d09c49ebfe749d | 79c70ac5795decff086dd16637d2d063fde6ed0d | refs/heads/master | 2021-01-12T16:52:18.126648 | 2016-11-05T08:30:29 | 2016-11-05T08:30:29 | 71,456,654 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 47,423 | air | T.air | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1606+ |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0.96";
object T.air;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 1 0 0 0];
internalField nonuniform List<scalar>
6000
(
540.08
544.025
544.955
544.065
542.881
541.022
539.564
537.183
534.174
531.458
529.835
528.59
527.536
526.463
525.708
525.04
524.415
524.036
523.945
525.286
526.013
528.698
534.364
538.026
540.125
541.748
543.165
544.253
543.75
540.564
595.773
597.281
597.089
596.604
595.447
592.913
591.671
589.854
588.803
588.389
588.168
588.046
588.493
588.587
588.492
588.064
587.22
586.78
586.073
585.929
586.349
587.091
588.727
591.123
591.893
593.963
595.931
596.91
597.101
593.257
599.798
599.86
599.842
599.803
599.611
598.873
598.153
596.681
596.026
595.989
596.071
596.207
596.803
597.499
597.831
597.694
597.187
596.505
595.426
595.007
595.204
595.322
595.892
597.629
598.375
599.229
599.722
599.827
599.82
599.329
599.963
599.964
599.962
599.959
599.94
599.802
599.555
598.975
598.385
598.225
598.234
598.293
598.7
599.241
599.498
599.475
599.277
598.823
597.856
597.549
597.754
597.898
598.425
599.321
599.648
599.884
599.954
599.96
599.961
599.945
599.97
599.97
599.97
599.968
599.961
599.933
599.857
599.6
599.242
599.174
599.194
599.306
599.581
599.794
599.88
599.873
599.804
599.589
598.98
598.742
598.906
598.971
599.205
599.745
599.902
599.956
599.968
599.97
599.972
599.971
599.973
599.972
599.972
599.968
599.958
599.936
599.886
599.742
599.625
599.601
599.63
599.773
599.902
599.95
599.964
599.961
599.942
599.876
599.671
599.487
599.446
599.452
599.547
599.841
599.929
599.959
599.97
599.973
599.974
599.975
599.976
599.976
599.974
599.969
599.956
599.927
599.881
599.817
599.796
599.804
599.823
599.888
599.944
599.966
599.974
599.976
599.972
599.956
599.909
599.839
599.714
599.66
599.701
599.835
599.92
599.957
599.972
599.976
599.978
599.978
599.979
599.979
599.977
599.971
599.957
599.924
599.883
599.864
599.889
599.908
599.912
599.917
599.94
599.957
599.968
599.973
599.973
599.967
599.949
599.908
599.816
599.764
599.77
599.828
599.91
599.956
599.974
599.979
599.98
599.98
599.983
599.983
599.98
599.973
599.959
599.932
599.904
599.909
599.933
599.945
599.947
599.947
599.951
599.958
599.966
599.972
599.973
599.968
599.949
599.909
599.847
599.819
599.82
599.842
599.899
599.954
599.976
599.981
599.983
599.983
599.986
599.987
599.985
599.978
599.965
599.945
599.934
599.943
599.956
599.962
599.964
599.966
599.969
599.971
599.973
599.975
599.977
599.973
599.956
599.915
599.881
599.866
599.864
599.872
599.899
599.953
599.977
599.984
599.985
599.985
599.989
599.989
599.989
599.985
599.973
599.961
599.957
599.962
599.969
599.971
599.973
599.975
599.979
599.981
599.982
599.983
599.983
599.98
599.966
599.933
599.909
599.899
599.897
599.9
599.913
599.951
599.978
599.985
599.987
599.987
599.991
599.99
599.99
599.989
599.984
599.976
599.973
599.974
599.977
599.978
599.979
599.982
599.984
599.986
599.986
599.987
599.986
599.985
599.977
599.954
599.933
599.925
599.922
599.922
599.929
599.954
599.979
599.986
599.988
599.988
599.991
599.991
599.991
599.99
599.989
599.985
599.982
599.982
599.982
599.983
599.984
599.986
599.988
599.988
599.988
599.989
599.988
599.988
599.985
599.975
599.958
599.946
599.941
599.937
599.94
599.958
599.981
599.987
599.989
599.99
599.992
599.992
599.992
599.991
599.99
599.989
599.987
599.987
599.987
599.987
599.987
599.989
599.99
599.99
599.99
599.99
599.99
599.989
599.988
599.985
599.978
599.968
599.961
599.953
599.951
599.967
599.983
599.988
599.99
599.991
599.993
599.993
599.992
599.992
599.991
599.991
599.99
599.99
599.99
599.989
599.99
599.99
599.991
599.991
599.991
599.991
599.991
599.99
599.99
599.989
599.986
599.981
599.975
599.968
599.964
599.978
599.987
599.99
599.991
599.991
599.993
599.994
599.993
599.993
599.993
599.992
599.992
599.992
599.991
599.991
599.991
599.992
599.991
599.992
599.992
599.991
599.991
599.991
599.991
599.99
599.989
599.988
599.984
599.98
599.976
599.987
599.99
599.991
599.991
599.992
599.996
599.997
599.996
599.994
599.993
599.993
599.993
599.993
599.993
599.993
599.992
599.992
599.993
599.992
599.992
599.992
599.992
599.991
599.991
599.991
599.991
599.991
599.99
599.988
599.988
599.991
599.992
599.992
599.992
599.992
599.998
599.998
599.997
599.996
599.994
599.994
599.994
599.994
599.994
599.993
599.993
599.993
599.993
599.993
599.993
599.992
599.992
599.992
599.991
599.991
599.992
599.993
599.993
599.993
599.993
599.992
599.992
599.993
599.993
599.993
599.998
599.998
599.997
599.996
599.995
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.993
599.993
599.993
599.992
599.992
599.992
599.992
599.992
599.993
599.993
599.993
599.993
599.993
599.993
599.993
599.993
599.993
599.999
599.998
599.998
599.997
599.995
599.995
599.994
599.995
599.994
599.995
599.995
599.994
599.994
599.994
599.994
599.993
599.993
599.993
599.993
599.993
599.993
599.993
599.993
599.994
599.993
599.993
599.993
599.993
599.993
599.993
599.999
599.998
599.998
599.997
599.996
599.995
599.995
599.994
599.995
599.995
599.995
599.995
599.995
599.995
599.994
599.994
599.994
599.994
599.993
599.993
599.993
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.999
599.998
599.998
599.998
599.996
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.999
599.998
599.998
599.998
599.997
599.996
599.995
599.995
599.995
599.996
599.996
599.996
599.996
599.995
599.995
599.994
599.995
599.995
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.994
599.998
599.998
599.998
599.998
599.998
599.996
599.995
599.995
599.995
599.996
599.996
599.996
599.996
599.996
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.994
599.994
599.994
599.994
599.994
599.994
599.998
599.998
599.998
599.998
599.998
599.998
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.994
599.994
599.994
599.998
599.998
599.998
599.998
599.998
599.998
599.997
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.998
599.998
599.998
599.998
599.998
599.998
599.998
599.997
599.997
599.997
599.997
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.995
599.995
599.995
599.995
599.995
599.995
599.995
599.999
599.998
599.999
599.998
599.998
599.998
599.998
599.998
599.998
599.997
599.997
599.997
599.997
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.995
599.995
599.995
599.995
599.999
599.999
599.998
599.998
599.998
599.998
599.998
599.998
599.998
599.998
599.997
599.997
599.997
599.997
599.996
599.996
599.996
599.997
599.997
599.997
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.995
599.995
600
599.999
599.999
599.999
599.999
599.999
599.999
599.998
599.998
599.998
599.997
599.997
599.997
599.997
599.997
599.997
599.997
599.997
599.997
599.997
599.997
599.997
599.996
599.996
599.996
599.996
599.996
599.996
599.996
599.995
600
600
599.999
599.999
599.998
599.998
599.999
599.999
599.999
599.998
599.998
599.997
599.997
599.997
599.997
599.997
599.997
599.997
599.997
599.997
599.997
599.997
599.997
599.997
599.996
599.996
599.996
599.996
599.996
599.995
600
600
600
600
599.999
599.998
599.999
599.999
599.999
599.999
599.998
599.998
599.997
599.997
599.997
599.997
599.998
599.998
599.998
599.998
599.998
599.998
599.997
599.997
599.997
599.996
599.996
599.996
599.996
599.995
600
600
600
600
599.999
599.999
599.998
599.998
599.999
599.999
599.999
599.998
599.998
599.998
599.998
599.998
599.998
599.998
599.998
599.999
599.999
599.999
599.998
599.997
599.997
599.996
599.996
599.996
599.996
599.996
600.001
600.001
600
600
599.999
599.999
599.999
599.999
599.999
599.999
599.999
599.998
599.998
599.998
599.998
599.998
599.998
599.998
599.999
599.999
599.999
599.999
599.998
599.998
599.997
599.996
599.996
599.996
599.996
599.996
600.001
600.001
600
600
600
599.999
599.999
599.999
599.999
599.999
599.999
599.999
599.998
599.998
599.998
599.998
599.998
599.998
599.998
599.997
599.996
599.997
599.997
599.998
599.997
599.996
599.996
599.996
599.996
599.996
600.001
600.001
600
600
600
599.999
599.999
599.999
599.999
599.999
599.999
599.999
599.999
599.998
599.998
599.998
599.998
599.998
599.997
599.995
599.993
599.992
599.994
599.996
599.997
599.996
599.996
599.996
599.996
599.996
600.001
600
600
600
600
600
599.999
599.999
599.998
599.999
599.999
599.999
599.999
599.999
599.998
599.998
599.998
599.998
599.996
599.994
599.993
599.992
599.992
599.994
599.996
599.996
599.996
599.996
599.996
599.996
599.999
599.999
599.999
599.999
599.998
599.998
599.997
599.998
599.998
599.999
599.999
599.999
599.999
599.999
599.998
599.998
599.998
599.997
599.997
599.996
599.996
599.996
599.994
599.994
599.995
599.995
599.996
599.996
599.996
599.996
599.988
599.991
599.991
599.99
599.989
599.99
599.991
599.995
599.997
599.998
599.999
599.999
599.999
599.999
599.999
599.999
599.998
599.998
599.999
599.999
599.999
599.999
599.999
599.998
599.996
599.995
599.995
599.995
599.996
599.996
599.967
599.973
599.976
599.977
599.979
599.982
599.986
599.991
599.996
599.998
599.998
599.999
599.999
599.998
599.998
599.999
599.999
600
600.001
600.001
600.002
600.002
600.002
600.001
600
599.998
599.995
599.995
599.996
599.996
599.981
599.98
599.981
599.981
599.983
599.984
599.986
599.991
599.996
599.998
599.998
599.998
599.998
599.999
600
600.001
600.001
600.002
600.002
600.003
600.003
600.003
600.004
600.004
600.003
600.001
599.998
599.994
599.996
599.996
599.993
599.991
599.99
599.989
599.989
599.988
599.988
599.99
599.996
599.998
599.998
599.998
599.999
599.999
600
600.001
600.003
600.003
600.004
600.003
600.003
600.004
600.005
600.005
600.005
600.004
600.001
599.996
599.996
599.998
600.003
599.999
599.997
599.995
599.993
599.992
599.989
599.99
599.995
599.998
599.998
599.999
599.999
599.999
600
600.001
600.002
600.003
600.004
600.003
600.003
600.004
600.005
600.006
600.006
600.005
600.003
599.998
599.997
599.999
600.006
600.002
600
599.998
599.996
599.994
599.991
599.99
599.994
599.998
599.999
599.999
599.999
599.999
600
600
600.001
600.002
600.003
600.003
600.003
600.003
600.005
600.006
600.006
600.006
600.004
600.001
599.997
599.999
600.006
600.003
600.001
599.999
599.997
599.995
599.992
599.99
599.993
599.998
599.999
599.999
599.999
599.999
599.999
599.999
600
600.002
600.003
600.003
600.003
600.003
600.004
600.005
600.006
600.006
600.005
600.002
599.997
599.998
600.006
600.003
600.001
599.999
599.998
599.995
599.993
599.991
599.993
599.997
599.999
599.999
599.999
599.998
599.997
599.997
599.998
600
600.002
600.003
600.003
600.003
600.004
600.005
600.005
600.005
600.005
600.002
599.998
599.998
600.004
600.002
600
599.999
599.997
599.995
599.994
599.992
599.993
599.996
599.999
599.999
599.999
599.999
599.996
599.996
599.996
599.998
600.001
600.003
600.003
600.002
600.003
600.004
600.005
600.005
600.004
600.003
600.002
599.999
600.002
600
599.999
599.998
599.996
599.995
599.994
599.993
599.993
599.996
599.999
599.999
599.999
599.999
599.997
599.995
599.994
599.996
600
600.002
600.002
600.001
600.001
600.003
600.004
600.004
600.004
600.004
600.004
599.999
599.999
599.998
599.997
599.996
599.995
599.994
599.994
599.994
599.995
599.997
599.999
599.999
599.999
600
599.998
599.995
599.992
599.994
599.999
600.001
600.002
600.001
600
600.001
600.002
600.003
600.003
600.003
600.004
599.999
599.996
599.996
599.995
599.994
599.994
599.993
599.993
599.993
599.995
599.997
599.999
599.999
600
600
599.999
599.995
599.992
599.993
599.997
600.001
600.002
600.001
600
600
600.001
600.001
600.002
600.002
600.003
599.999
599.994
599.993
599.993
599.993
599.992
599.992
599.992
599.993
599.994
599.996
600
600
600
600
600
599.997
599.993
599.992
599.996
600
600.002
600.001
600
599.999
600
600
600
600.001
600.001
599.999
599.991
599.991
599.991
599.991
599.991
599.991
599.991
599.992
599.993
599.995
599.998
600
600
600
600
599.998
599.994
599.992
599.995
600
600.002
600.003
600.001
600
599.999
599.999
599.999
599.999
599.998
600
599.989
599.989
599.989
599.989
599.989
599.99
599.99
599.991
599.992
599.993
599.996
599.999
600
600
600
600
599.995
599.992
599.995
599.999
600.002
600.003
600.001
600
599.999
599.999
599.999
599.999
599.999
600.001
599.986
599.987
599.987
599.988
599.988
599.989
599.989
599.99
599.991
599.992
599.995
599.998
600
600
600.001
600
599.996
599.993
599.994
599.999
600.002
600.003
600.003
600.001
599.999
599.999
599.999
599.999
600
600
599.984
599.985
599.985
599.986
599.987
599.988
599.989
599.99
599.991
599.992
599.995
599.998
600
600
600
599.999
599.997
599.994
599.995
599.998
600.001
600.003
600.003
600.001
599.999
599.998
599.998
599.998
599.999
599.997
599.982
599.983
599.983
599.984
599.985
599.987
599.988
599.989
599.99
599.992
599.995
599.997
599.999
600
600
600
599.999
599.996
599.995
599.998
600.001
600.003
600.002
600.001
599.999
599.997
599.996
599.996
599.997
599.993
599.979
599.981
599.982
599.983
599.984
599.986
599.987
599.989
599.99
599.992
599.995
599.998
599.999
600
599.999
600.001
599.999
599.996
599.995
599.998
600.001
600.003
600.002
600.001
599.999
599.997
599.995
599.994
599.993
599.988
599.977
599.979
599.98
599.981
599.983
599.985
599.987
599.989
599.99
599.992
599.995
599.998
599.999
599.999
600.003
600.001
599.999
599.997
599.995
599.998
600.002
600.003
600.002
600
599.998
599.996
599.993
599.991
599.988
599.981
599.975
599.977
599.978
599.98
599.982
599.984
599.987
599.989
599.991
599.993
599.996
599.998
599.999
600
600
600
600
599.997
599.996
599.999
600.002
600.003
600.002
600
599.997
599.995
599.992
599.989
599.985
599.978
599.973
599.975
599.976
599.978
599.981
599.984
599.987
599.99
599.992
599.994
599.997
599.999
600
600
600
600
600
599.998
599.997
600
600.003
600.003
600.002
599.999
599.996
599.993
599.99
599.987
599.983
599.977
599.971
599.973
599.975
599.977
599.979
599.983
599.988
599.992
599.994
599.996
599.998
599.999
600
600
600
600
600
599.999
599.997
600.001
600.004
600.003
600.001
599.998
599.995
599.992
599.989
599.985
599.981
599.975
599.969
599.971
599.973
599.975
599.978
599.983
599.988
599.993
599.995
599.997
599.999
599.999
600
600
600
600
600
599.999
599.998
600.002
600.004
600.003
600
599.997
599.994
599.991
599.987
599.983
599.979
599.973
599.966
599.969
599.971
599.973
599.977
599.982
599.988
599.994
599.996
599.998
599.999
600
600
600
600
600
600
600
599.999
600.003
600.005
600.003
599.999
599.996
599.993
599.989
599.985
599.981
599.977
599.972
599.964
599.966
599.969
599.971
599.975
599.981
599.988
599.994
599.996
599.998
599.999
600
600
600
600
600
600
600
600
600.004
600.005
600.002
599.998
599.995
599.991
599.987
599.983
599.979
599.975
599.969
599.962
599.964
599.967
599.971
599.975
599.98
599.988
599.995
599.996
599.998
600
600
600
600
600
600
600
600
600
600.005
600.005
600.001
599.996
599.993
599.99
599.986
599.981
599.976
599.972
599.968
599.959
599.962
599.964
599.968
599.972
599.978
599.987
599.995
599.997
599.999
600
600
600
600
600
600
600
600
600.001
600.006
600.004
599.999
599.995
599.992
599.989
599.985
599.979
599.974
599.97
599.965
599.957
599.959
599.962
599.964
599.968
599.976
599.986
599.996
599.998
599.999
600
600
600
599.999
600
600
600
600
600.001
600.007
600.004
599.997
599.992
599.99
599.987
599.983
599.978
599.973
599.968
599.964
599.954
599.957
599.959
599.961
599.965
599.973
599.984
599.997
600.001
600
600
600
599.999
599.999
599.999
600
600
600
600.002
600.009
600.003
599.995
599.99
599.987
599.985
599.982
599.978
599.972
599.967
599.962
599.952
599.954
599.956
599.958
599.962
599.97
599.983
599.999
600.004
600.001
600
600
600
600
600
600
600
600
600.005
600.01
600.002
599.993
599.987
599.984
599.983
599.981
599.978
599.973
599.967
599.963
599.949
599.952
599.953
599.955
599.958
599.966
599.981
600.001
600.011
600.002
600
600
600
600
600
600
600
600.002
600.014
600.014
600.001
599.99
599.984
599.981
599.981
599.98
599.978
599.975
599.969
599.965
599.946
599.949
599.95
599.952
599.955
599.963
599.977
600.002
600.02
600.007
600.001
600
600
600
600
600
600
600.007
600.029
600.018
600.001
599.988
599.981
599.978
599.978
599.979
599.978
599.977
599.974
599.971
599.944
599.947
599.948
599.949
599.952
599.959
599.973
599.997
600.015
600.011
600.003
600
600
600
600
600
600.001
600.014
600.039
600.018
599.997
599.984
599.978
599.975
599.975
599.977
599.978
599.978
599.977
599.976
599.942
599.944
599.946
599.947
599.949
599.956
599.968
599.985
600.004
600.009
600.005
600.002
600
600
600
600
600.002
600.021
600.03
600.01
599.992
599.98
599.974
599.972
599.972
599.975
599.977
599.978
599.979
599.979
599.939
599.942
599.944
599.945
599.947
599.955
599.969
599.981
599.995
600.002
600.004
600.003
600.001
600
600
600
600.004
600.015
600.016
600
599.985
599.975
599.97
599.968
599.969
599.972
599.975
599.978
599.979
599.98
599.937
599.941
599.944
599.945
599.948
599.957
599.975
599.985
599.99
599.998
600
600.002
600.001
600
600
600
600.002
600.006
600.003
599.99
599.978
599.971
599.966
599.965
599.966
599.969
599.973
599.976
599.978
599.98
599.935
599.94
599.945
599.947
599.949
599.961
599.982
599.991
599.992
599.993
599.998
600
600
600
600
600
599.999
599.997
599.993
599.982
599.972
599.966
599.963
599.962
599.963
599.966
599.97
599.974
599.977
599.979
599.934
599.941
599.948
599.95
599.953
599.966
599.988
599.997
599.996
599.995
599.995
599.997
600
600.001
600
599.999
599.997
599.994
599.99
599.978
599.968
599.963
599.96
599.959
599.96
599.963
599.967
599.971
599.976
599.978
599.933
599.942
599.953
599.955
599.958
599.971
599.991
600
599.999
599.998
599.997
599.998
599.999
600
600
599.999
599.998
599.998
599.991
599.976
599.966
599.96
599.957
599.956
599.957
599.96
599.964
599.969
599.974
599.977
599.933
599.945
599.958
599.96
599.964
599.977
599.993
600.001
600
599.999
599.999
599.999
599.999
600
600
600
600
600.001
599.993
599.976
599.964
599.958
599.955
599.954
599.955
599.958
599.962
599.967
599.972
599.976
599.933
599.948
599.962
599.965
599.971
599.983
599.994
600
600
600
599.999
599.999
600
600
600
600
600.001
600.005
599.994
599.975
599.962
599.956
599.954
599.953
599.953
599.955
599.96
599.965
599.97
599.975
599.934
599.952
599.967
599.97
599.976
599.988
599.995
599.999
600
599.999
599.999
599.999
600
599.999
600
600
600.001
600.006
599.994
599.974
599.961
599.955
599.953
599.952
599.952
599.954
599.958
599.963
599.968
599.973
599.936
599.956
599.97
599.974
599.981
599.991
599.997
599.999
600
600
599.999
599.999
599.999
599.999
600
600
600
600.005
599.993
599.973
599.96
599.955
599.953
599.952
599.951
599.952
599.956
599.961
599.966
599.97
599.94
599.961
599.973
599.978
599.984
599.994
600
600
600
600
600
600
600
600
600
600
600.001
600.005
599.995
599.975
599.961
599.955
599.954
599.953
599.952
599.952
599.955
599.959
599.963
599.967
599.95
599.966
599.977
599.981
599.987
599.997
600.002
600.001
600
600
600
600
600
600
600
600
600.001
600.008
600
599.978
599.964
599.958
599.956
599.955
599.953
599.952
599.955
599.958
599.961
599.963
599.962
599.973
599.98
599.984
599.989
599.999
600.003
600.002
600
600
600
600
600
600
600
600
600.004
600.017
600.004
599.981
599.967
599.961
599.959
599.958
599.955
599.954
599.956
599.958
599.96
599.962
599.973
599.979
599.983
599.986
599.991
600
600.002
600.001
600
600
600
600
600
600
600
600
600.008
600.025
600.007
599.983
599.97
599.965
599.964
599.962
599.959
599.957
599.958
599.959
599.959
599.958
599.981
599.985
599.987
599.988
599.992
599.999
599.999
599.999
600
600
600
600
600
600
600
600.001
600.011
600.027
600.006
599.984
599.973
599.969
599.968
599.967
599.964
599.962
599.962
599.961
599.959
599.958
599.987
599.989
599.99
599.99
599.993
599.998
599.999
599.999
600
600
600
600
600
600
600
600.001
600.012
600.022
600.002
599.984
599.975
599.973
599.973
599.972
599.97
599.968
599.967
599.964
599.96
599.957
599.993
599.992
599.993
599.993
599.994
599.999
600
599.999
599.999
599.999
599.999
599.999
599.999
600
599.999
600
600.01
600.013
599.997
599.983
599.978
599.977
599.978
599.977
599.975
599.973
599.971
599.967
599.96
599.955
599.995
599.995
599.995
599.995
599.995
599.999
600.001
600
600
599.999
599.999
600
599.999
599.999
599.999
600
600.008
600.006
599.992
599.984
599.981
599.982
599.982
599.981
599.98
599.978
599.976
599.971
599.961
599.949
600.001
599.999
599.997
599.996
599.996
600
600.003
600
600
600
600
600
599.999
600
599.999
600
600.012
600.002
599.99
599.985
599.985
599.986
599.986
599.985
599.984
599.983
599.981
599.975
599.964
599.95
600.002
599.981
599.998
599.997
599.997
600
600.003
600.001
600
600
600
600
600
600
600
600.003
600.012
600
599.99
599.988
599.989
599.989
599.989
599.989
599.988
599.987
599.985
599.98
599.969
599.953
600.002
600.013
599.998
599.998
599.997
599.998
600.002
600.003
599.999
600
600
600
600
600
600.001
600.01
600.007
599.997
599.991
599.99
599.991
599.992
599.992
599.992
599.991
599.991
599.99
599.986
599.978
599.963
599.998
599.999
599.998
599.998
599.997
599.998
600.002
600.003
600
600
599.999
600
599.999
600
600.004
600.012
600.002
599.995
599.992
599.992
599.993
599.994
599.994
599.994
599.994
599.994
599.994
599.992
599.988
599.98
599.993
599.999
599.998
599.998
599.998
599.998
600.001
600.003
600.001
599.999
599.999
599.999
599.999
600.001
600.01
600.008
599.999
599.994
599.993
599.993
599.994
599.995
599.996
599.996
599.997
599.997
599.997
599.996
599.994
599.992
599.991
599.999
599.999
599.999
599.999
599.999
600
600.002
600
599.999
600
600
599.999
600.003
600.009
600.003
599.997
599.994
599.994
599.994
599.994
599.995
599.996
599.997
599.998
599.998
599.998
599.998
599.997
599.997
599.998
599.999
600
599.999
599.999
599.999
600
600
599.999
600
599.999
600
600
600.003
600.006
600
599.996
599.995
599.994
599.994
599.995
599.995
599.996
599.998
599.999
599.999
599.999
599.997
599.999
599.998
599.999
600
600
600
600
600
600
599.999
599.999
600
600
600
600
600.002
600.004
600
599.996
599.995
599.995
599.995
599.995
599.995
599.996
599.997
599.998
599.998
599.999
599.998
599.997
599.998
600.001
600.001
600.001
600
600
600
600
599.999
599.999
600
600
600
600
600.002
600.003
600
599.997
599.996
599.995
599.995
599.995
599.995
599.996
599.997
599.997
599.997
599.998
600.001
600.001
599.998
600.001
600.001
600.001
600.001
600.001
600
600
600
599.999
600
600
600
600
600.002
600.003
600.001
599.999
599.997
599.996
599.996
599.995
599.995
599.995
599.996
599.996
599.997
599.997
599.998
599.998
599.994
600.001
600.001
600.001
600.001
600.001
600.001
600
600
599.999
600
600
600
600
600.002
600.003
600.002
600
599.999
599.997
599.996
599.996
599.995
599.995
599.995
599.996
599.997
599.998
599.998
599.998
600.021
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
600
600
600
600
600
600.002
600.004
600.003
600.002
600
599.999
599.997
599.996
599.995
599.995
599.995
599.996
599.997
599.998
599.998
599.997
599.997
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
600
600
600
600
600
600.002
600.004
600.004
600.003
600.002
600
599.998
599.997
599.996
599.995
599.995
599.996
599.997
599.998
599.998
599.997
599.994
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
600
600
600
600
600
600.002
600.003
600.004
600.004
600.003
600.002
600
599.998
599.996
599.996
599.995
599.996
599.997
599.998
599.998
599.997
599.996
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
600
600
600
600
600
600.001
600.002
600.004
600.005
600.005
600.003
600.001
599.999
599.997
599.997
599.996
599.997
599.998
599.999
599.998
599.997
599.995
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
600
600
600
600
600
600.001
600.002
600.003
600.005
600.006
600.005
600.003
600
599.999
599.998
599.998
599.999
599.999
600
599.998
599.998
599.986
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
600
600
600
600.001
600.001
600.001
600.002
600.004
600.006
600.006
600.005
600.003
600.001
600
600
600
600.001
600.001
600
599.999
599.983
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.003
600.006
600.007
600.006
600.005
600.004
600.003
600.002
600.002
600.003
600.003
600.002
600.001
599.997
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.004
600.007
600.007
600.006
600.006
600.005
600.004
600.004
600.004
600.004
600.004
600.003
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.003
600.006
600.007
600.007
600.006
600.006
600.005
600.005
600.006
600.006
600.006
600.006
600.006
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.003
600.004
600.005
600.005
600.005
600.005
600.004
600.005
600.006
600.006
600.007
600.007
600.007
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.003
600.004
600.004
600.004
600.003
600.003
600.003
600.004
600.005
600.006
600.007
600.007
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.003
600.003
600.005
600.005
600.006
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.003
600.004
600.004
599.998
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.003
600.003
600.003
599.999
599.997
600
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.003
600.003
600.003
600.002
600.001
599.999
599.998
600
600.001
600.001
600.001
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.003
600.003
600.003
600.003
600.003
600.001
600.001
600
599.999
600.001
600.001
600.001
600.002
600.001
600.001
600.001
600.001
600.001
600.002
600.002
600.001
600.001
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.003
600.003
600.002
600.003
600.003
600
600
600.001
600.001
599.996
599.999
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.003
600.004
600.001
600.003
600.003
600.003
600.003
600.002
600
599.999
599.997
600.001
599.998
599.998
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.001
600.003
600.004
600.003
600.002
600.002
600.002
600.002
600
600.001
599.999
600
600.001
600
599.999
599.998
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.001
600.002
600.002
600.002
600.002
600.002
600.003
600.001
600.003
600.002
600.004
600.002
600.001
600.001
600.001
600.002
600
600
600
600.001
600.001
600
599.998
599.999
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.002
600.002
600.003
600.002
600.001
599.995
600.003
600.001
600.001
600.001
600
600
600
600.001
600.001
600.001
600.001
600.001
600.001
600.001
599.999
599.999
600.001
600.001
600.001
600.001
600.001
600.002
600.002
600.002
600.001
600
599.996
599.991
599.992
600
599.996
600.002
600.001
600
600.001
600
600.001
600.001
600.002
600.002
600.002
600.002
600.003
600.002
600
600
600
600.001
600.001
600.001
600.001
600
599.999
599.995
599.991
599.984
599.977
599.978
599.98
599.99
600
599.999
599.997
600.001
600
600.001
600.001
600.001
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.001
600
600
600.001
600
599.998
599.992
599.983
599.976
599.976
599.981
599.989
599.992
599.993
599.99
599.996
599.998
599.998
600
600.001
600.001
600.001
599.998
600.001
600.001
600.001
600.002
600.002
600.002
600.002
600.001
600.001
600
599.999
599.997
599.99
599.983
599.982
599.99
599.992
599.993
599.995
599.996
599.996
599.998
599.998
599.998
600
600.001
600.001
600.001
600.001
600.004
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
599.999
599.996
599.995
599.997
599.997
599.995
599.995
599.997
599.999
599.999
600
600.002
599.999
600
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
600
599.999
599.999
600
600.003
600.004
600.001
600.003
600.006
600.005
600.005
600.006
600.005
600
600
600
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
600
600
600.001
600.005
600.007
600.008
600.008
600.008
600.008
600.007
600.007
600.006
600.004
600.001
599.999
600
600.001
600.001
600.002
600.001
600.001
600.001
600
600.001
600.001
600.001
600.001
600.001
600
600
600
600
600.002
600.005
600.008
600.008
600.008
600.007
600.006
600.006
600.005
600.004
600.002
600
599.998
599.996
600.002
600.002
600.001
600.001
600.001
600.001
600.002
600.001
600.001
600.001
600.001
600.001
600
600
600
600
600.001
600.004
600.006
600.007
600.006
600.005
600.004
600.004
600.004
600.003
600.001
599.999
599.999
600
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
600
600
600.001
600.003
600.004
600.005
600.005
600.003
600.003
600.002
600.002
600.002
600.001
600
599.999
599.999
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.003
600.003
600.002
600.002
600.001
600.001
600.002
600.001
600.001
599.999
599.999
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.002
600.001
600.001
600.001
600.001
600.001
600.002
600.003
600.002
599.999
600.001
600.001
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.003
600.003
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.003
600.004
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.004
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
600.001
600.002
600.003
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.001
600.001
600.002
600.002
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600
600.001
600.001
600.001
600.001
600.001
600.001
600
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
600.002
600.002
599.995
600.001
600.002
600.001
600.001
600.001
600
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.002
600.002
599.984
599.999
600.002
600.001
600
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.001
600.002
600.001
600.001
600.002
600.003
599.997
599.992
600
600.001
600.001
600
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
600.001
600
600.001
600.002
600.002
600
600.001
599.991
599.995
600
600.001
600
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
600.001
600.002
600.001
599.992
600
600.002
600.001
600
600.001
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.003
600.001
600.001
599.997
599.993
600.004
600.009
600.006
600.002
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
599.998
600.001
599.999
599.992
600
600.011
600.01
600.006
600.003
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
599.997
599.997
600.002
600.009
600.006
600.003
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600
600.002
600.003
600
600.005
600.003
600.002
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.001
600.005
600.009
600.007
600.003
600.003
600.002
600.002
600.002
600.002
600.001
600.001
600.001
600.001
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.001
600.001
600.001
600.001
600.001
600.001
600.002
600.005
600.009
600.011
600.003
600.003
600.003
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.003
600.005
600.007
600.002
600.001
600.002
600.002
600.003
600.003
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.002
600.003
600.003
600.003
600.004
599.982
599.974
599.986
599.991
599.996
599.997
600
600
600.001
600.001
600.001
600.002
600.001
600
600
600.001
600.001
600.001
600.001
600.001
600.002
600.001
600.001
600.001
600.001
600.001
600
600
599.997
600.002
599.887
599.896
599.91
599.926
599.941
599.956
599.969
599.976
599.98
599.983
599.985
599.988
599.985
599.979
599.978
599.98
599.981
599.982
599.983
599.988
599.99
599.988
599.986
599.984
599.98
599.974
599.966
599.963
599.958
599.968
599.949
599.982
600.002
600.01
600
599.983
599.965
599.957
599.953
599.948
599.944
599.943
599.937
599.928
599.927
599.929
599.93
599.929
599.931
599.939
599.944
599.943
599.943
599.941
599.934
599.926
599.918
599.901
599.892
599.863
600.094
600.161
600.202
600.218
600.214
600.201
600.181
600.163
600.146
600.13
600.112
600.095
600.086
600.083
600.083
600.083
600.082
600.078
600.074
600.073
600.082
600.097
600.107
600.111
600.109
600.102
600.087
600.056
600.014
599.965
600.33
600.396
600.441
600.459
600.459
600.448
600.433
600.416
600.4
600.383
600.365
600.348
600.336
600.33
600.328
600.327
600.325
600.323
600.322
600.325
600.335
600.349
600.36
600.365
600.364
600.355
600.334
600.296
600.234
600.161
600.541
600.616
600.662
600.68
600.681
600.673
600.659
600.644
600.629
600.613
600.598
600.583
600.571
600.565
600.561
600.56
600.559
600.559
600.561
600.567
600.577
600.589
600.598
600.604
600.604
600.596
600.577
600.542
600.483
600.412
600.743
600.823
600.864
600.877
600.875
600.865
600.852
600.837
600.822
600.808
600.794
600.782
600.771
600.764
600.76
600.759
600.759
600.761
600.765
600.772
600.782
600.793
600.803
600.81
600.813
600.81
600.797
600.769
600.717
600.639
600.969
601.027
601.05
601.053
601.044
601.031
601.016
601
600.985
600.971
600.958
600.947
600.938
600.931
600.927
600.926
600.927
600.93
600.936
600.943
600.954
600.965
600.976
600.986
600.994
600.997
600.994
600.98
600.944
600.881
601.214
601.225
601.221
601.208
601.192
601.174
601.156
601.139
601.123
601.109
601.096
601.085
601.077
601.071
601.067
601.067
601.068
601.072
601.078
601.087
601.098
601.11
601.123
601.136
601.149
601.16
601.169
601.173
601.167
601.151
601.441
601.401
601.37
601.343
601.318
601.296
601.275
601.257
601.24
601.226
601.213
601.203
601.194
601.189
601.186
601.185
601.187
601.192
601.198
601.208
601.219
601.233
601.248
601.264
601.282
601.3
601.32
601.343
601.371
601.412
601.617
601.543
601.493
601.456
601.426
601.4
601.378
601.358
601.341
601.326
601.313
601.303
601.295
601.29
601.287
601.287
601.289
601.294
601.301
601.311
601.323
601.337
601.354
601.373
601.394
601.418
601.447
601.484
601.536
601.617
601.734
601.648
601.591
601.55
601.517
601.489
601.466
601.445
601.428
601.413
601.4
601.39
601.382
601.377
601.375
601.374
601.377
601.382
601.389
601.399
601.412
601.427
601.445
601.465
601.489
601.517
601.55
601.594
601.657
601.753
601.806
601.723
601.667
601.626
601.592
601.565
601.541
601.521
601.503
601.489
601.476
601.466
601.459
601.454
601.452
601.452
601.454
601.459
601.467
601.477
601.49
601.505
601.523
601.544
601.568
601.597
601.632
601.677
601.739
601.832
601.848
601.775
601.725
601.687
601.655
601.629
601.606
601.587
601.57
601.556
601.544
601.534
601.527
601.522
601.52
601.52
601.523
601.528
601.535
601.545
601.558
601.573
601.59
601.611
601.635
601.663
601.697
601.739
601.795
601.875
601.873
601.813
601.77
601.736
601.708
601.684
601.663
601.645
601.629
601.615
601.604
601.595
601.588
601.584
601.582
601.582
601.584
601.589
601.596
601.606
601.618
601.632
601.649
601.668
601.691
601.717
601.748
601.785
601.832
601.898
601.889
601.841
601.806
601.777
601.753
601.731
601.712
601.695
601.681
601.668
601.658
601.65
601.643
601.639
601.637
601.637
601.639
601.644
601.651
601.66
601.671
601.684
601.7
601.718
601.738
601.761
601.788
601.819
601.858
601.91
601.901
601.863
601.835
601.812
601.791
601.772
601.755
601.74
601.727
601.716
601.706
601.698
601.693
601.689
601.687
601.687
601.689
601.693
601.699
601.708
601.718
601.73
601.744
601.76
601.778
601.799
601.821
601.847
601.878
601.917
601.91
601.882
601.86
601.841
601.824
601.808
601.794
601.78
601.768
601.758
601.749
601.742
601.737
601.733
601.731
601.732
601.733
601.737
601.743
601.75
601.76
601.771
601.783
601.797
601.813
601.83
601.849
601.87
601.893
601.922
601.919
601.899
601.883
601.868
601.853
601.84
601.827
601.815
601.805
601.795
601.788
601.781
601.776
601.773
601.771
601.771
601.773
601.776
601.781
601.788
601.796
601.806
601.817
601.83
601.843
601.858
601.873
601.889
601.907
601.928
601.93
601.916
601.904
601.892
601.88
601.868
601.857
601.847
601.837
601.828
601.821
601.815
601.81
601.807
601.806
601.806
601.807
601.81
601.815
601.821
601.828
601.837
601.847
601.858
601.87
601.882
601.895
601.908
601.921
601.935
601.946
601.935
601.925
601.914
601.904
601.894
601.883
601.874
601.865
601.857
601.85
601.844
601.84
601.837
601.835
601.835
601.837
601.839
601.844
601.849
601.856
601.864
601.873
601.883
601.893
601.904
601.915
601.926
601.936
601.947
601.971
601.957
601.947
601.937
601.927
601.917
601.907
601.898
601.889
601.881
601.875
601.869
601.865
601.862
601.86
601.86
601.861
601.864
601.868
601.873
601.88
601.887
601.896
601.905
601.914
601.924
601.934
601.944
601.954
601.966
602.006
601.984
601.97
601.959
601.948
601.937
601.927
601.918
601.909
601.902
601.895
601.889
601.885
601.882
601.88
601.88
601.881
601.884
601.888
601.893
601.899
601.906
601.915
601.924
601.933
601.944
601.954
601.965
601.977
601.995
602.05
602.014
601.995
601.98
601.968
601.956
601.945
601.935
601.926
601.918
601.911
601.905
601.901
601.898
601.896
601.896
601.897
601.899
601.903
601.908
601.915
601.922
601.931
601.94
601.95
601.961
601.973
601.986
602.003
602.033
602.096
602.046
602.019
602.001
601.985
601.972
601.96
601.949
601.939
601.93
601.923
601.917
601.912
601.909
601.907
601.907
601.908
601.91
601.914
601.92
601.926
601.934
601.943
601.954
601.965
601.978
601.992
602.009
602.032
602.076
602.137
602.076
602.042
602.019
602
601.985
601.971
601.958
601.948
601.938
601.93
601.924
601.919
601.915
601.913
601.913
601.914
601.917
601.921
601.927
601.934
601.943
601.953
601.964
601.977
601.992
602.009
602.03
602.061
602.118
602.165
602.099
602.06
602.033
602.011
601.993
601.978
601.964
601.952
601.942
601.933
601.926
601.921
601.917
601.915
601.915
601.916
601.919
601.924
601.93
601.938
601.947
601.958
601.971
601.986
602.003
602.023
602.048
602.085
602.15
602.178
602.114
602.072
602.042
602.018
601.998
601.981
601.966
601.953
601.942
601.932
601.925
601.919
601.915
601.913
601.913
601.914
601.917
601.922
601.929
601.937
601.948
601.96
601.974
601.991
602.01
602.033
602.061
602.103
602.168
602.18
602.119
602.076
602.044
602.019
601.998
601.979
601.963
601.949
601.938
601.928
601.92
601.914
601.909
601.907
601.907
601.908
601.912
601.917
601.925
601.934
601.945
601.958
601.973
601.991
602.012
602.037
602.068
602.11
602.173
602.177
602.118
602.075
602.042
602.016
601.993
601.974
601.956
601.941
601.929
601.918
601.91
601.903
601.899
601.896
601.896
601.898
601.902
601.908
601.915
601.926
601.938
601.952
601.969
601.988
602.01
602.036
602.068
602.111
602.172
602.162
602.11
602.068
602.034
602.007
601.983
601.962
601.944
601.928
601.915
601.904
601.895
601.889
601.884
601.882
601.881
601.883
601.887
601.894
601.902
601.913
601.926
601.941
601.959
601.979
602.003
602.03
602.063
602.107
602.163
602.123
602.088
602.05
602.017
601.99
601.966
601.945
601.927
601.911
601.897
601.886
601.877
601.87
601.865
601.863
601.863
601.865
601.869
601.876
601.885
601.896
601.909
601.925
601.943
601.965
601.989
602.017
602.05
602.091
602.134
602.073
602.053
602.022
601.993
601.967
601.944
601.923
601.905
601.889
601.875
601.863
601.854
601.847
601.843
601.84
601.84
601.843
601.847
601.854
601.863
601.874
601.888
601.904
601.923
601.944
601.968
601.995
602.026
602.06
602.086
602.019
602.012
601.988
601.962
601.938
601.916
601.896
601.878
601.862
601.849
601.837
601.828
601.821
601.817
601.814
601.814
601.817
601.821
601.828
601.838
601.849
601.863
601.879
601.898
601.918
601.941
601.967
601.994
602.021
602.032
601.961
601.966
601.948
601.926
601.904
601.884
601.865
601.847
601.832
601.819
601.807
601.798
601.792
601.787
601.785
601.785
601.788
601.792
601.799
601.809
601.82
601.834
601.85
601.868
601.888
601.909
601.932
601.956
601.976
601.974
601.902
601.916
601.904
601.886
601.866
601.847
601.829
601.813
601.798
601.785
601.774
601.766
601.759
601.755
601.753
601.753
601.755
601.76
601.767
601.776
601.788
601.801
601.817
601.834
601.853
601.873
601.893
601.913
601.927
601.915
601.84
601.863
601.856
601.842
601.825
601.807
601.791
601.775
601.761
601.749
601.738
601.73
601.723
601.719
601.717
601.718
601.72
601.725
601.732
601.741
601.752
601.765
601.78
601.796
601.814
601.832
601.85
601.866
601.875
601.853
601.782
601.809
601.807
601.795
601.78
601.765
601.749
601.735
601.721
601.71
601.7
601.692
601.685
601.681
601.679
601.68
601.682
601.687
601.694
601.702
601.713
601.726
601.74
601.755
601.772
601.788
601.804
601.817
601.821
601.794
601.718
601.753
601.755
601.746
601.733
601.719
601.705
601.692
601.679
601.668
601.659
601.651
601.645
601.641
601.639
601.64
601.642
601.647
601.653
601.662
601.672
601.684
601.697
601.712
601.727
601.742
601.755
601.765
601.765
601.729
601.661
601.698
601.702
601.696
601.685
601.672
601.659
601.647
601.635
601.624
601.615
601.608
601.603
601.599
601.597
601.598
601.6
601.604
601.611
601.619
601.629
601.64
601.653
601.666
601.68
601.693
601.705
601.712
601.709
601.671
601.594
601.64
601.648
601.644
601.634
601.623
601.611
601.6
601.589
601.579
601.57
601.564
601.558
601.555
601.553
601.554
601.556
601.56
601.566
601.574
601.583
601.594
601.606
601.618
601.631
601.643
601.653
601.658
601.65
601.603
601.539
601.584
601.593
601.591
601.583
601.573
601.562
601.551
601.541
601.532
601.524
601.517
601.512
601.509
601.508
601.508
601.51
601.514
601.52
601.527
601.536
601.546
601.557
601.569
601.58
601.591
601.599
601.603
601.593
601.547
601.466
601.522
601.537
601.536
601.53
601.521
601.512
601.502
601.492
601.484
601.476
601.47
601.466
601.463
601.461
601.462
601.464
601.467
601.473
601.48
601.488
601.497
601.508
601.518
601.529
601.538
601.545
601.546
601.531
601.473
601.413
601.468
601.481
601.482
601.477
601.469
601.46
601.451
601.443
601.435
601.428
601.422
601.418
601.415
601.414
601.414
601.416
601.42
601.425
601.431
601.439
601.447
601.457
601.466
601.476
601.484
601.489
601.489
601.475
601.42
601.328
601.398
601.421
601.425
601.422
601.416
601.408
601.4
601.393
601.386
601.38
601.375
601.371
601.368
601.367
601.368
601.369
601.373
601.377
601.383
601.39
601.397
601.405
601.414
601.422
601.429
601.432
601.428
601.404
601.334
601.28
601.351
601.368
601.37
601.367
601.362
601.357
601.351
601.345
601.339
601.334
601.33
601.327
601.325
601.324
601.325
601.326
601.329
601.333
601.337
601.343
601.349
601.356
601.362
601.368
601.373
601.376
601.374
601.357
601.286
601.164
601.253
601.29
601.306
601.313
601.314
601.313
601.311
601.307
601.304
601.3
601.298
601.295
601.294
601.293
601.293
601.295
601.297
601.3
601.303
601.307
601.311
601.315
601.318
601.32
601.318
601.312
601.296
601.258
601.169
)
;
boundaryField
{
inlet
{
type fixedValue;
value uniform 300;
}
outlet
{
type inletOutlet;
phi phi.air;
inletValue uniform 300;
value nonuniform List<scalar>
30
(
601.164
601.253
601.29
601.306
601.313
601.314
601.313
601.311
601.307
601.304
601.3
601.297
601.295
601.294
601.293
601.293
601.295
601.297
601.3
601.303
601.307
601.311
601.315
601.318
601.32
601.318
601.312
601.296
601.258
601.168
)
;
}
walls
{
type zeroGradient;
}
frontAndBackPlanes
{
type empty;
}
}
// ************************************************************************* //
|
553b8b6d04ac028d22322a2a83231d4d96d2df14 | c130f4ba7463751429915bdc58251bc757cefe73 | /source/StringSwitch.hpp | b459dad79253cad5d8ca8f08d6e1f47ac2acbd06 | [
"Unlicense"
] | permissive | Amaranese/mario-bros-cplusplus | 39c04986180621bf24ad29dd87f80a9469acf5c1 | b5aefffbd3650cfa0ff5e846f43748efde8666c5 | refs/heads/main | 2023-07-09T06:11:10.012967 | 2021-08-15T00:57:46 | 2021-08-15T00:57:46 | 396,171,352 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 960 | hpp | StringSwitch.hpp | #ifndef STRINGSWITCH_HPP
#define STRINGSWITCH_HPP
#include <map>
#include <string>
/**
* A class that can be used to create switch statements from strings.
*/
class StringSwitch
{
public:
StringSwitch();
/**
* Add a string to the switch.
*
* @param str the string.
* @param value a value to assign to the string.
*/
void addString(const std::string& str, int value);
/**
* Get the value that will be returned from a test on an
* unrecognized string.
*
* @return the default value.
*/
int getDefaultValue() const;
/**
* Set the default value when an unrecognized string is tested.
*
* @param value the default value to use.
*/
void setDefaultValue(int value);
/**
* Test the switch given a string.
*
* @param str the string to test.
* @return the integer index assigned to the string.
*/
int test(const std::string& str) const;
private:
int defaultValue;
std::map<std::string, int> stringMap;
};
#endif // STRINGSWITCH_HPP
|
6fd781f2bb0d3f73f83a6f8024bc091d3cfbcb69 | 0c1503373ff498a5d903eba610185a310b86cdee | /SluaghEngine/includes/Gameplay/NuckelaveeNormalAttackLeaf.h | d1acc930044d2c9068af70955dd53a0b869365da | [] | no_license | dastyk/SE | cee62f56e34387b4eb11e34ca87e602c7b41151d | cbee091f35a4926bb44d5098a5adda0a38150714 | refs/heads/master | 2021-01-21T12:32:17.066005 | 2017-12-15T15:18:37 | 2017-12-15T15:18:37 | 102,079,165 | 0 | 1 | null | 2017-12-15T15:18:38 | 2017-09-01T06:03:22 | C++ | UTF-8 | C++ | false | false | 769 | h | NuckelaveeNormalAttackLeaf.h | #ifndef SE_GAMEPLAY_NUCKELAVEE_NORMAL_ATTACK_LEAF_H
#define SE_GAMEPLAY_NUCKELAVEE_NORMAL_ATTACK_LEAF_H
#include "IBehaviour.h"
#include "Utilz/GUID.h"
namespace SE
{
namespace Gameplay
{
class NuckelaveeNormalAttackLeaf : public IBehaviour
{
private:
NuckelaveeNormalAttackLeaf() = delete;
public:
NuckelaveeNormalAttackLeaf(EnemyBlackboard* enemyBlackboard, GameBlackboard* gameBlackboard);
~NuckelaveeNormalAttackLeaf()
{
};
static const Utilz::GUID NuckelaveeNormalAttackFileGUID;
Status Update() override;
inline IBehaviour* CopyBehaviour(GameBlackboard* gameBlackboard, EnemyBlackboard* enemyBlackboard) const override
{
return new NuckelaveeNormalAttackLeaf(enemyBlackboard, gameBlackboard);
};
};
}
}
#endif
|
103b5b12ea8600e6d3c29f5f994e5f0b887b5265 | 65e56335184265a9dccf16b57bf7ccdd14f9f889 | /include/openmapper_desktop/window.h | 99a8ce0da1ed5a987f8c3e5bfc9b249f391a3294 | [
"Apache-2.0"
] | permissive | OpenMapper/OpenMapperDesktop | b8de37b1506bbab61e929a4c719b9664fd787a53 | c62a7ef0e7ce6d73aa2ef55b1acdbcf268f5a56d | refs/heads/master | 2021-04-15T11:56:22.012087 | 2017-07-30T14:37:52 | 2017-07-30T14:37:52 | 94,576,589 | 1 | 0 | null | 2017-07-26T12:09:54 | 2017-06-16T19:52:52 | C++ | UTF-8 | C++ | false | false | 1,040 | h | window.h | // (c) 2017 OpenMapper
#ifndef OPENMAPPER_DESKTOP_WINDOW_H_
#define OPENMAPPER_DESKTOP_WINDOW_H_
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <QSlider>
#include <QWidget>
#include <opencv2/core/core.hpp>
#include <openmapper_desktop/config.h>
namespace Ui {
class Window;
}
class Window : public QWidget {
Q_OBJECT
public:
explicit Window(QWidget *parent = 0);
~Window();
protected:
void keyPressEvent(QKeyEvent *event);
void timerEvent(QTimerEvent *event);
void initialize_input();
private:
Ui::Window *ui;
int timerId;
//
// The input source manages the input images. It gets the images over opencv
// from a camera or movie.
//
std::shared_ptr<openmapper::InputSource> input_source_;
std::vector<std::string> flags_;
std::shared_ptr<openmapper::OpenMapper> openmapper_engine_;
// Is true if the engine should run, and false if not.
bool tracking_image_;
};
#endif // OPENMAPPER_DESKTOP_WINDOW_H_
|
99905c68208214fb85be3d0c936e3821080bff16 | 966dc17abfc38c3a11e4d4798813350448f25dd5 | /0401-0500/0406.cpp | 07bca701d858837d85b577d218209bc3aec4fe32 | [] | no_license | superlb/MyLeetcode | fa8b041339c1f803b4f0432fe6bd593a2f4e8949 | ae617c7e858636b026ba3c323f37972dda64b87e | refs/heads/master | 2021-08-04T02:43:16.049436 | 2021-07-24T14:03:05 | 2021-07-24T14:03:05 | 205,500,460 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 555 | cpp | 0406.cpp | class Solution {
public:
vector<vector<int>> reconstructQueue(vector<vector<int>>& people) {
sort(people.begin(),people.end());
vector<vector<int>> res(people.size());
for(auto & p : people)
{
int count = -1;
for(int i=0;i<res.size();++i)
{
if(res[i].empty() || res[i][0]==p[0]) ++count;
if(count == p[1])
{
res[i]=p;
break;
}
}
}
return res;
}
}; |
d2157cdf5485783fb9b8b42c4085d173956b9694 | 0bf4e9718ac2e2845b2227d427862e957701071f | /codeforces/150/e.cpp | 7fda8b67aa3b1ef638ff8ba163f4b97e68a13b17 | [] | no_license | unjambonakap/prog_contest | adfd6552d396f4845132f3ad416f98d8a5c9efb8 | e538cf6a1686539afb1d06181252e9b3376e8023 | refs/heads/master | 2022-10-18T07:33:46.591777 | 2022-09-30T14:44:47 | 2022-09-30T15:00:33 | 145,024,455 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,281 | cpp | e.cpp | #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include<unistd.h>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <climits>
//#include <ext/hash_map>
using namespace std;
using namespace __gnu_cxx;
#define REP(i,n) for(int i = 0; i < int(n); ++i)
#define REPV(i, n) for (int i = (n) - 1; (int)i >= 0; --i)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define FE(i,t) for (__typeof((t).begin())i=(t).begin();i!=(t).end();++i)
#define FEV(i,t) for (__typeof((t).rbegin())i=(t).rbegin();i!=(t).rend();++i)
#define two(x) (1LL << (x))
#define ALL(a) (a).begin(), (a).end()
#define pb push_back
#define ST first
#define ND second
#define MP(x,y) make_pair(x, y)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
template<class T> void checkmin(T &a, T b){if (b<a)a=b;}
template<class T> void checkmax(T &a, T b){if (b>a)a=b;}
template<class T> void out(T t[], int n){REP(i, n)cout<<t[i]<<" "; cout<<endl;}
template<class T> void out(vector<T> t, int n=-1){for (int i=0; i<(n==-1?t.size():n); ++i) cout<<t[i]<<" "; cout<<endl;}
inline int count_bit(int n){return (n==0)?0:1+count_bit(n&(n-1));}
inline int low_bit(int n){return (n^n-1)&n;}
inline int ctz(int n){return (n==0?-1:ctz(n>>1)+1);}
int toInt(string s){int a; istringstream(s)>>a; return a;}
string toStr(int a){ostringstream os; os<<a; return os.str();}
const int maxn=555;
int n;
int a[maxn][maxn], res[maxn][maxn];
int cntb[maxn];
vi e[maxn];
char buf[maxn];
int perm[maxn];
int mark[maxn];
int split(vector<vi> &u, vi &b, vector<vi> &wh, int x){
int y=b[x];
swap(b[x],b.back()); b.pop_back();
vector<vi> nu, nwh;
REP(dir,2){
int seen=0;
nu.clear();
nwh.clear();
REP(i,u.size()){
vi xx[2];
REP(j,u[i].size()){
int z=u[i][j];
xx[a[y][z]].pb(z);
}
vi &xa=xx[0], &xb=xx[1];
int pp[2]={nu.size()+1,nu.size()};
if (!seen && i!=u.size()-1){
swap(pp[0],pp[1]);
if (xa.size()) nu.pb(xa);
if (xb.size()) nu.pb(xb), seen=1;
}else{
if (xb.size() && seen==2) goto fail;
if (xb.size()) nu.pb(xb);
if (xa.size()) nu.pb(xa), seen=2;
}
nwh.resize(nu.size());
if (xa.size() && xb.size()){
int p=1;
if (xa.size()<xb.size()) p=0;
REP(j,wh[i].size()){
int cnt=0;
int z=wh[i][j];
if (z==y) continue;
REP(k,xx[p].size()) cnt+=a[z][xx[p][k]];
if (cnt && cnt!=cntb[z]) mark[z]=1;
else{
if (cnt==cntb[z]) nwh[pp[p]].pb(z);
else nwh[pp[p^1]].pb(z);
}
}
}else if (xa.size() || xb.size()) nwh.back()=wh[i];
if (i==u.size()-1 && !xa.size()) nwh.pb(vi()), nu.pb(vi());
}
u=nu;
wh=nwh;
//puts("XXXXXXXXXXXXXXXX");
//printf("PICKING %d, %d\n",y,u.back().size());
//REP(i,u.size()) out(u[i]), out(wh[i]), puts("==");
//out(mark,n);
//puts("");
return 1;
fail:
reverse(u.begin(),u.end()-1);
reverse(wh.begin(),wh.end()-1);
}
return 0;
}
int go(vi &b, vi &in, int pad=0){
REP(i,b.size()) if (mark[b[i]] || cntb[b[i]]==in.size()) swap(b[i],b.back()), b.pop_back();
if (!b.size()){
REP(i,in.size()) perm[in[i]]=pad+i;
return 1;
}
int best=0;
REP(i,b.size()) if (cntb[b[i]]>cntb[b[best]]) best=i;
vector<vi> uu; uu.pb(in);
vector<vi> wh; wh.pb(b);
mark[b[best]]=1;
if (!split(uu,b,wh,best)) return 0;
while(b.size()){
int cnd=-1;
REP(i,b.size()) if (mark[b[i]]){cnd=i; break;}
if (cnd==-1){
REP(i,uu.size()){
if (!go(wh[i],uu[i],pad)) return 0;
pad+=uu[i].size();
}
return 1;
}else{
if (!split(uu,b,wh,cnd)) return 0;
}
}
REP(i,uu.size()){
assert(go(wh[i],uu[i],pad));
pad+=uu[i].size();
}
return 1;
}
int main(){
while(scanf(" %d",&n)>0){
memset(cntb,0,sizeof(cntb));
REP(i,n){
scanf(" %s",buf);
REP(j,n) a[i][j]=buf[j]-'0';
REP(j,n) if (a[i][j]) e[i].pb(j), ++cntb[i];
}
vi tb; vi in;
REP(i,n) in.pb(i);
REP(i,n) if (cntb[i] && cntb[i]<n) tb.pb(i);
memset(mark,0,sizeof(mark));
if (go(tb,in)){
puts("YES");
REP(i,n) REP(j,n) res[i][perm[j]]=a[i][j];
REP(i,n){
REP(j,n) printf("%c",res[i][j]+'0');
puts("");
}
}else puts("NO");
REP(i,n) e[i].clear();
}
return 0;
}
|
457a22b7f95d616e93226978ceea222a475d9ca8 | df536edb964c3c1cdcafd57ff8ad3a6b69ca5cbe | /test/Expr/AddLabelExpr.cpp | 4793bddd99cbef974b4a302958b10a2e09a23982 | [] | no_license | philipc/clang-ast | 2fdb69794ca815f099fbd94e45c3c76d66539981 | a827312e44573751191b7657387d12f534dd2907 | refs/heads/master | 2016-09-09T17:41:53.072539 | 2015-10-07T21:32:56 | 2015-10-07T21:32:56 | 5,884,831 | 6 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 479 | cpp | AddLabelExpr.cpp | // RUN: ast -f test "%s" 2>&1 | FileCheck %s
// CHECK: CompoundStmt
void test() {
// CHECK-NEXT: LabelStmt
// CHECK-NEXT: LabelDeclRef l
// CHECK-NEXT: NullStmt
l:;
// CHECK-NEXT: DeclStmt
// CHECK-NEXT: VarDecl
// CHECK-NEXT: DeclarationName p
// CHECK-NEXT: PointerType
// CHECK-NEXT: BuiltinType void
// CHECK-NEXT: AddrLabelExpr
// CHECK-NEXT: LabelDeclRef l
void *p = &&l;
};
|
7e877ba995612c460017b3917d032da317ae8207 | 409684fd8c319af0941358ece6477b23e12a5a68 | /Project4/Source.cpp | 426e4c98a6ec85644d9b3be577086cc8ba2e90cb | [] | no_license | fatenallache/Project4 | 1defeb22c3450e3980663b270c7c685cfb8864a2 | 740202706a085f2cec7d43e630f111d9e5e45be1 | refs/heads/master | 2023-01-27T17:44:52.519605 | 2020-11-27T18:04:55 | 2020-11-27T18:04:55 | 316,567,838 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 150 | cpp | Source.cpp | #include<iostream>
using namespace std;
int main(){
cout<< "hello jasso" << endl;
cout << "Wsh lizoooom" << endl;
cout << "y3tik saha" << endl;
}
|
b4e91d529bc3adb815d24b0147169eb9be25610a | a3d6556180e74af7b555f8d47d3fea55b94bcbda | /ash/webui/media_app_ui/test/media_app_ui_browsertest.cc | 4eefe230c24e06fc08afb003f46ca85bf30ba8b0 | [
"BSD-3-Clause"
] | permissive | chromium/chromium | aaa9eda10115b50b0616d2f1aed5ef35d1d779d6 | a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c | refs/heads/main | 2023-08-24T00:35:12.585945 | 2023-08-23T22:01:11 | 2023-08-23T22:01:11 | 120,360,765 | 17,408 | 7,102 | BSD-3-Clause | 2023-09-10T23:44:27 | 2018-02-05T20:55:32 | null | UTF-8 | C++ | false | false | 1,906 | cc | media_app_ui_browsertest.cc | // Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/webui/media_app_ui/test/media_app_ui_browsertest.h"
#include "ash/webui/media_app_ui/media_app_guest_ui.h"
#include "ash/webui/media_app_ui/media_app_ui.h"
#include "ash/webui/media_app_ui/url_constants.h"
#include "ash/webui/web_applications/test/sandboxed_web_ui_test_base.h"
#include "base/files/file_path.h"
namespace {
// File containing the test utility library, shared with integration tests.
constexpr base::FilePath::CharType kTestLibraryPath[] =
FILE_PATH_LITERAL("ash/webui/system_apps/public/js/dom_testing_helpers.js");
// Test cases that run in the guest context.
constexpr char kGuestTestCases[] = "media_app_guest_ui_browsertest.js";
// Path to test files loaded via the TestFileRequestFilter.
constexpr base::FilePath::CharType kTestFileLocation[] =
FILE_PATH_LITERAL("ash/webui/media_app_ui/test");
// Paths requested on the media-app origin that should be delivered by the test
// handler.
constexpr const char* kTestFiles[] = {
kGuestTestCases, "media_app_ui_browsertest.js", "driver.js",
"test_worker.js", "guest_query_receiver.js",
};
} // namespace
MediaAppUiBrowserTest::MediaAppUiBrowserTest()
: SandboxedWebUiAppTestBase(ash::kChromeUIMediaAppURL,
ash::kChromeUIMediaAppGuestURL,
{base::FilePath(kTestLibraryPath)},
kGuestTestCases) {
ConfigureDefaultTestRequestHandler(
base::FilePath(kTestFileLocation),
{std::begin(kTestFiles), std::end(kTestFiles)});
}
MediaAppUiBrowserTest::~MediaAppUiBrowserTest() = default;
// static
std::string MediaAppUiBrowserTest::AppJsTestLibrary() {
return SandboxedWebUiAppTestBase::LoadJsTestLibrary(
base::FilePath(kTestLibraryPath));
}
|
74c4f77f2fd3ff32ac6caae6f80a996fdf92b757 | c312e781f9fea0434b052479fba5e86d9c48fc77 | /ofxLoopin/src/ofxLoopinApp.h | 0f9ea497af8ba7bb5df98bf1c3c406cf0f5b0b51 | [] | no_license | koopero/loopin-native | 53a428b21e69bdb077e11530214d2da584f3ecd5 | 4101fb910b5fdd16c702396cf911ed48ab3eb4f4 | refs/heads/master | 2023-07-22T11:22:28.482105 | 2021-02-27T09:15:12 | 2021-02-27T09:15:12 | 62,488,388 | 0 | 0 | null | 2020-04-27T08:19:36 | 2016-07-03T08:44:05 | C++ | UTF-8 | C++ | false | false | 5,956 | h | ofxLoopinApp.h | #pragma once
#include "./base/Buffer.hpp"
#include "./clock/Clock.hpp"
#include "./clock/Frame.hpp"
#include "./base/Input.hpp"
#include "./control/Map.hpp"
#include "./control/Reference.hpp"
#include "./base/Root.hpp"
#include "./base/Reader.hpp"
#include "./base/Stdio.hpp"
// #include "ofxLoopinAudioAnalyzer.h"
#include "./image/Image.hpp"
#include "./render/Camera.hpp"
#include "./base/Info.hpp"
#include "./kinect/Kinect.hpp"
#include "./render/Layer.hpp"
#include "./mesh/Mesh.hpp"
#include "./render/Render.hpp"
#include "./image/Saver.hpp"
#include "./shader/Shaders.hpp"
#include "./misc/Text.hpp"
#include "./video/Video.hpp"
#include "./pixels/PixelRender.hpp"
#include "./audio/waveform.hpp"
#include "./window/MainWindow.hpp"
#include "./window/Windows.hpp"
#include "./misc/Syphon.hpp"
#include "./grabber/Grabber.hpp"
#include "./blobs/Blobs.hpp"
#include "ofMain.h"
#include "boost/filesystem/path.hpp"
#include <stdlib.h>
class ofxLoopinApp :
public ofBaseApp,
public ofxLoopin::base::Root,
public ofxLoopin::shader::HasShaders,
public ofxLoopin::mesh::HasMeshes,
public ofxLoopin::render::HasCameras,
public ofxLoopin::shader::HasUniforms
{
public:
ofxLoopinApp();
ofxLoopinApp( int argc, char* argv[] );
~ofxLoopinApp() {
stdio.waitForThread();
}
void startFromArgs( int argc, char* argv[] );
//
// Root elements, accessible as controls.
//
// clock/ - Clock parameters
/** loopin/root/clock
type: clock
*/
ofxLoopin::clock::Clock clock;
// input/ - Input parameters
/** loopin/root/input
type: input
*/
ofxLoopin::base::Input input;
// window/ - Window parameters such as fullscreen
/** loopin/root/window
type: window
*/
ofxLoopin::window::MainWindow window;
ofxLoopin::window::Windows windows;
// image/:buffer - Load image files
/** loopin/root/image
map: image
*/
ofxLoopin::render::Renders<ofxLoopin::image::Image> images;
// kinect/:buffer - Kinect 1
/** loopin/root/kinect
map: kinect
*/
ofxLoopin::render::Renders<ofxLoopin::kinect::Kinect> kinects;
// text/:buffer
/** loopin/root/text
map: text
*/
ofxLoopin::render::Renders<ofxLoopin::misc::Text> texts;
// save/:buffer - saves buffers to image files
/** loopin/root/save
map: save
*/
ofxLoopin::render::Renders<ofxLoopin::image::Saver> savers;
ofxLoopin::render::Renders<ofxLoopin::blobs::Blobs> blobs;
// render/:buffer - renders
/** loopin/root/kinect
map: kinect
*/
ofxLoopin::render::OrderedRenders<ofxLoopin::render::Layer> renders;
// pixels/:buffer - pixels
/** loopin/root/pixels
map: pixels
*/
ofxLoopin::pixels::Map pixels;
// video/:buffer - video file input
/** loopin/root/video
map: video
*/
ofxLoopin::render::Renders<ofxLoopin::video::Video> videos;
// waveform/:buffer - waveform input ( experimental )
/** loopin/root/waveform
map: waveform
*/
ofxLoopin::render::waveform waveforms;
// fft/:buffer - ofxFft wrapper.
/** loopin/root/fft
map: fft
*/
// ofxLoopin::render::Renders<ofxLoopinFft> fft;
#ifdef LOOPIN_SYPHON
ofxLoopin::misc::SyphonRoot syphon;
#endif
ofxLoopin::grabber::GrabberList grabbers;
ofxLoopin::base::Info info;
// openFrameWorks master overrides.
void setup ();
void draw ();
// Master render function
void render ();
// Master event dispatcher.
// Called by ofxLoopin::control::Control::dispatch
void dispatch( ofxLoopin::control::Event & event );
void update();
protected:
void updateLocal ();
void addAppControls() {
addSubControl( "uniform", &uniforms );
addSubControl( "clock", &clock );
addSubControl( "input", &input );
buffers.defaultKey = "output";
addSubControl( "shader", &shaders );
shaders.getByKey( "blank", true );
shaders.defaultKey = "blank";
addSubControl( "mesh", &meshes );
meshes.getByKey( "sprite", true );
meshes.defaultKey = "sprite";
addSubControl( "camera", &cameras );
cameras.getByKey( "front", true );
cameras.defaultKey = "front";
addSubControl( "read", &reader );
addSubControl( "info", &info );
addSubControl( "image", &images );
addSubControl( "text", &texts );
addSubControl( "kinect", &kinects );
addSubControl( "video", &videos );
addSubControl( "render", &renders );
addSubControl( "pixels", &pixels );
addSubControl( "waveform", &waveforms );
addSubControl( "grabber", &grabbers );
#ifdef LOOPIN_SYPHON
addSubControl( "syphon", &syphon );
#endif
addSubControl( "save", &savers );
addSubControl( "blobs", &blobs );
addSubControl( "show", &(window.show) );
addSubControl( "osd", &(window.osd) );
addSubControl( "window", &window );
addSubControl( "windows", &windows );
window.setAppBaseWindow( ofGetWindowPtr() );
}
void addRenderLists () {
renderLists.push_back( &waveforms );
renderLists.push_back( &images );
renderLists.push_back( &texts );
renderLists.push_back( &kinects );
renderLists.push_back( &videos );
renderLists.push_back( &grabbers );
renderLists.push_back( &renders );
renderLists.push_back( &windows );
renderLists.push_back( &blobs );
renderLists.push_back( &savers );
renderLists.push_back( &pixels );
#ifdef LOOPIN_SYPHON
renderLists.push_back( &syphon );
#endif
}
// Utility for reading from stdio
ofxLoopin::base::Stdio stdio;
// Utility for reading to stdio
ofxLoopin::base::Reader reader;
void keyPressed(int key) {
// std::cerr << "keyPressed " << key << endl;
switch ( key ) {
case OF_KEY_LEFT:
window.show.buffer.prev();
break;
case OF_KEY_RIGHT:
window.show.buffer.next();
break;
}
}
static ofxLoopin::shader::Shader shaderDefault;
private:
int exitAfterFrames = 0;
std::vector<ofxLoopin::render::RenderList *> renderLists;
};
|
fede93c54e5e2a78d92d25f6169942b151d6ab75 | 3a7c1ef392ea8654033886ea4f608c46de16c9a2 | /Source/Misc/Polytempo_ImageButton.h | 8ab0343f66e61ac1c4a2232a02b988fd748d95b7 | [] | no_license | michaseidenberg/polytempo | ad585a692827cbbb65e94ef03c7b65f65783a084 | cea853d6f47c678228e418b9126baa9ac5b8d3e9 | refs/heads/master | 2023-04-01T23:18:06.066886 | 2021-04-07T15:46:27 | 2021-04-07T15:46:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 360 | h | Polytempo_ImageButton.h | #pragma once
class Polytempo_ImageButton : public DrawableButton
{
public:
Polytempo_ImageButton() : DrawableButton("xxx", DrawableButton::ButtonStyle::ImageOnButtonBackground)
{}
Rectangle<float> getImageBounds() const
{
auto r = getLocalBounds();
r = r.reduced(3, 3);
return r.toFloat();
}
};
|
3c8b00b53f18b7e34f5801754caf0f6bf1d0b856 | 36f65a7a1010ef00832220873acd4c1ad7a1fd4f | /yae_libraries/Tnet/ConnectionClosedException.h | f7110bbef7220df78389a8f941943eb3c3340939 | [] | no_license | trakos/yae-be | 1d08d50e901c0daa2a83ef6b69719202914d94d5 | 2e143276ab007a9668f38907dfeb9cc9c95e2580 | refs/heads/master | 2020-04-27T20:51:25.965460 | 2014-08-12T13:40:22 | 2014-08-12T14:02:53 | 22,880,278 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 408 | h | ConnectionClosedException.h | /*
* Exception.h
*
* Created on: 2011-01-25
* Author: trakos
*/
#ifndef TNET_CONNECTIONCLOSEDEXCEPTION_H_
#define TNET_CONNECTIONCLOSEDEXCEPTION_H_
#include <string>
#include <Tnet/Exception.h>
class Tnet_ConnectionClosedException : public Tnet_Exception
{
public:
Tnet_ConnectionClosedException() : Tnet_Exception("connection closed") {};
};
#endif /* TNET_CONNECTIONCLOSEDEXCEPTION_H_ */
|
793bbb44703a9a43df5e136e71b780c1560d935d | e15e0252e353d26cda7758066bc4a73fb866dcc3 | /Semester 2/ADS/ADS Assignment 8/8.2/RedBlackTree.h | 3722b5b3b95c7d8380bd338749a485a3cc06820b | [] | no_license | RittmayerJ/College | 2d441533febf7d5ac175bc2b242ed4d95cade980 | ce41092692629930a1caed2751514142dfe3e3a6 | refs/heads/master | 2021-06-30T00:00:42.056925 | 2020-07-08T11:36:27 | 2020-07-08T11:36:27 | 169,301,959 | 0 | 0 | null | 2020-10-13T23:24:42 | 2019-02-05T19:47:30 | C++ | UTF-8 | C++ | false | false | 1,264 | h | RedBlackTree.h | /*
CH08-320201
Problem a8.p2.cpp
Jonathan Rittmayer
jo.rittmayer@jacobs-university.de
*/
#ifndef _RED_BLACK_TREE
#define _RED_BLACK_TREE
#include <bits/stdc++.h>
using namespace std;
enum Color{RED, BLACK, DOUBLE_BLACK};
struct Node{
int data;
Color color;
Node *left, *right, *parent;
Node(const int& data);
};
class RedBlackTree{
private:
int count;
ofstream out;
Node* root;
string getColorString(Node*& ptr);
bool isRed(Node* node);
void setColor(Node*& node, Color color);
void changeColors(Node*& uncle, Node*& parent, Node*& grandparent);
Node* insert(Node*& node, Node*& newNode);
void print(Node*& node);
void print(Node*& node, ofstream& out);
Node* getMin(Node* node);
Node* getMax(Node* node);
Node* search(Node* node, int data);
Node* delVal(Node*& node, int data);
void fixInsertViolation(Node*& ptr);
void fixDeleteViolation(Node*& node);
protected:
void rotateLeft(Node*& h);
void rotateRight(Node*& h);
public:
RedBlackTree();
~RedBlackTree();
void insert(int data);
void delNode(Node*& p);
Node* predecessor(Node*& node);
Node* successor(Node*& node);
Node* getMin();
Node* getMax();
Node* search(int data);
void print();
void print(ofstream& out);
};
#endif // !_R_B_TREE
|
7839d1622893670df36f3225dc852a8b182a143a | 510cfe880a475f0c572cc34c1b544e41911c3e6c | /630A.cpp | acbfb7c0eaf28e026e6cc57608073a1c17e24c58 | [] | no_license | ptkhai1203/cf-problems | aa40a1233b490c0daa977f978bed5b517bc47190 | 421c8e43401aa409363d6653540d8d6238b0e1d3 | refs/heads/main | 2023-04-14T14:03:45.795965 | 2021-04-12T13:35:05 | 2021-04-12T13:35:05 | 340,100,309 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 306 | cpp | 630A.cpp | #include <bits/stdc++.h>
#define nl '\n'
using namespace std;
int main(){
#ifdef PTK
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
long long n;
cin >> n;
cout << 25;
return 0;
}
|
b82dd6f4c0beb04a69ffece9c0cf62ca413278c8 | 98b8435aca84385bd39070df199641d7a770e4d4 | /src/Warps.cpp | 34183650181c3e5de8e56fe97d2f970bac0ccf07 | [
"MIT",
"BSD-3-Clause"
] | permissive | audiomic/AudibleInstruments | 862a89d03a623a841f56017b8626eb19fb8b8591 | 8edc0bfc5e5a9b3f875dd13c55977bca8d061573 | refs/heads/master | 2021-07-17T18:22:57.359780 | 2017-10-24T06:22:20 | 2017-10-24T06:22:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,627 | cpp | Warps.cpp | #include <string.h>
#include "AudibleInstruments.hpp"
#include "dsp/digital.hpp"
#include "warps/dsp/modulator.h"
struct Warps : Module {
enum ParamIds {
ALGORITHM_PARAM,
TIMBRE_PARAM,
STATE_PARAM,
LEVEL1_PARAM,
LEVEL2_PARAM,
NUM_PARAMS
};
enum InputIds {
LEVEL1_INPUT,
LEVEL2_INPUT,
ALGORITHM_INPUT,
TIMBRE_INPUT,
CARRIER_INPUT,
MODULATOR_INPUT,
NUM_INPUTS
};
enum OutputIds {
MODULATOR_OUTPUT,
AUX_OUTPUT,
NUM_OUTPUTS
};
int frame = 0;
warps::Modulator modulator;
warps::ShortFrame inputFrames[60] = {};
warps::ShortFrame outputFrames[60] = {};
float lights[2] = {};
SchmittTrigger stateTrigger;
Warps();
void step() override;
json_t *toJson() override {
json_t *rootJ = json_object();
warps::Parameters *p = modulator.mutable_parameters();
json_object_set_new(rootJ, "shape", json_integer(p->carrier_shape));
return rootJ;
}
void fromJson(json_t *rootJ) override {
json_t *shapeJ = json_object_get(rootJ, "shape");
warps::Parameters *p = modulator.mutable_parameters();
if (shapeJ) {
p->carrier_shape = json_integer_value(shapeJ);
}
}
void reset() override {
warps::Parameters *p = modulator.mutable_parameters();
p->carrier_shape = 0;
}
void randomize() override {
warps::Parameters *p = modulator.mutable_parameters();
p->carrier_shape = randomu32() % 4;
}
};
Warps::Warps() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {
memset(&modulator, 0, sizeof(modulator));
modulator.Init(96000.0f);
stateTrigger.setThresholds(0.0, 1.0);
}
void Warps::step() {
// State trigger
warps::Parameters *p = modulator.mutable_parameters();
if (stateTrigger.process(params[STATE_PARAM].value)) {
p->carrier_shape = (p->carrier_shape + 1) % 4;
}
lights[0] = p->carrier_shape;
// Buffer loop
if (++frame >= 60) {
frame = 0;
p->channel_drive[0] = clampf(params[LEVEL1_PARAM].value + inputs[LEVEL1_INPUT].value / 5.0, 0.0, 1.0);
p->channel_drive[1] = clampf(params[LEVEL2_PARAM].value + inputs[LEVEL2_INPUT].value / 5.0, 0.0, 1.0);
p->modulation_algorithm = clampf(params[ALGORITHM_PARAM].value / 8.0 + inputs[ALGORITHM_INPUT].value / 5.0, 0.0, 1.0);
lights[1] = p->modulation_algorithm * 8.0;
p->modulation_parameter = clampf(params[TIMBRE_PARAM].value + inputs[TIMBRE_INPUT].value / 5.0, 0.0, 1.0);
p->frequency_shift_pot = params[ALGORITHM_PARAM].value / 8.0;
p->frequency_shift_cv = clampf(inputs[ALGORITHM_INPUT].value / 5.0, -1.0, 1.0);
p->phase_shift = p->modulation_algorithm;
p->note = 60.0 * params[LEVEL1_PARAM].value + 12.0 * inputs[LEVEL1_INPUT].normalize(2.0) + 12.0;
p->note += log2f(96000.0 / engineGetSampleRate()) * 12.0;
modulator.Process(inputFrames, outputFrames, 60);
}
inputFrames[frame].l = clampf(inputs[CARRIER_INPUT].value / 16.0 * 0x8000, -0x8000, 0x7fff);
inputFrames[frame].r = clampf(inputs[MODULATOR_INPUT].value / 16.0 * 0x8000, -0x8000, 0x7fff);
outputs[MODULATOR_OUTPUT].value = (float)outputFrames[frame].l / 0x8000 * 5.0;
outputs[AUX_OUTPUT].value = (float)outputFrames[frame].r / 0x8000 * 5.0;
}
struct WarpsModeLight : ModeValueLight {
WarpsModeLight() {
addColor(COLOR_BLACK_TRANSPARENT);
addColor(COLOR_GREEN);
addColor(COLOR_YELLOW);
addColor(COLOR_RED);
}
};
struct WarpsAlgoLight : ValueLight {
WarpsAlgoLight() {
box.size = Vec(67, 67);
}
void step() override {
// TODO Set these to Warps' actual colors
static NVGcolor colors[9] = {
nvgHSL(0.5, 0.3, 0.85),
nvgHSL(0.6, 0.3, 0.85),
nvgHSL(0.7, 0.3, 0.85),
nvgHSL(0.8, 0.3, 0.85),
nvgHSL(0.9, 0.3, 0.85),
nvgHSL(0.0, 0.3, 0.85),
nvgHSL(0.1, 0.3, 0.85),
nvgHSL(0.2, 0.3, 0.85),
nvgHSL(0.3, 0.3, 0.85),
};
int i = clampi((int) *value, 0, 7);
NVGcolor color0 = colors[i];
NVGcolor color1 = colors[i + 1];
float p = fmodf(*value, 1.0);
color = nvgLerpRGBA(color0, color1, p);
}
};
WarpsWidget::WarpsWidget() {
Warps *module = new Warps();
setModule(module);
box.size = Vec(15*10, 380);
{
Panel *panel = new LightPanel();
panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Warps.png"));
panel->box.size = box.size;
addChild(panel);
}
addChild(createScrew<ScrewSilver>(Vec(15, 0)));
addChild(createScrew<ScrewSilver>(Vec(120, 0)));
addChild(createScrew<ScrewSilver>(Vec(15, 365)));
addChild(createScrew<ScrewSilver>(Vec(120, 365)));
addParam(createParam<Rogan6PSWhite>(Vec(30, 53), module, Warps::ALGORITHM_PARAM, 0.0, 8.0, 0.0));
addParam(createParam<Rogan1PSWhite>(Vec(95, 173), module, Warps::TIMBRE_PARAM, 0.0, 1.0, 0.5));
addParam(createParam<TL1105>(Vec(16, 182), module, Warps::STATE_PARAM, 0.0, 1.0, 0.0));
addParam(createParam<Trimpot>(Vec(15, 214), module, Warps::LEVEL1_PARAM, 0.0, 1.0, 1.0));
addParam(createParam<Trimpot>(Vec(54, 214), module, Warps::LEVEL2_PARAM, 0.0, 1.0, 1.0));
addInput(createInput<PJ301MPort>(Vec(8, 273), module, Warps::LEVEL1_INPUT));
addInput(createInput<PJ301MPort>(Vec(44, 273), module, Warps::LEVEL2_INPUT));
addInput(createInput<PJ301MPort>(Vec(80, 273), module, Warps::ALGORITHM_INPUT));
addInput(createInput<PJ301MPort>(Vec(116, 273), module, Warps::TIMBRE_INPUT));
addInput(createInput<PJ301MPort>(Vec(8, 316), module, Warps::CARRIER_INPUT));
addInput(createInput<PJ301MPort>(Vec(44, 316), module, Warps::MODULATOR_INPUT));
addOutput(createOutput<PJ301MPort>(Vec(80, 316), module, Warps::MODULATOR_OUTPUT));
addOutput(createOutput<PJ301MPort>(Vec(116, 316), module, Warps::AUX_OUTPUT));
addChild(createValueLight<SmallLight<WarpsModeLight>>(Vec(20, 167), &module->lights[0]));
addChild(createValueLight<WarpsAlgoLight>(Vec(41, 64), &module->lights[1]));
}
|
28a769dcf0119fd0ad1bde19d76a91d44279cfb5 | 79e35b3844aeb0c35f5705758a44d424a5b3df3a | /Simulator/PortTree.h | d4c465940666336946debe991bfd536a6d4e3dfc | [
"Apache-2.0"
] | permissive | longwinds/mstp-lib | c17d85790c79ce29645781ba312fc7878971b41c | 513091b31d967cba635811640250ee7a2b9b82e6 | refs/heads/master | 2020-05-07T08:11:05.875737 | 2017-09-19T14:11:53 | 2017-09-19T14:11:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 696 | h | PortTree.h | #pragma once
#include "Object.h"
class Port;
class PortTree : public Object
{
using base = Object;
Port* const _parent;
unsigned int const _treeIndex;
public:
PortTree (Port* parent, unsigned int treeIndex)
: _parent(parent), _treeIndex(treeIndex)
{ }
HRESULT Serialize (IXMLDOMDocument3* doc, IXMLDOMElementPtr& elementOut) const;
HRESULT Deserialize (IXMLDOMElement* portTreeElement);
//std::wstring GetPriorityLabel () const;
int GetPriority() const;
void SetPriority (int priority);
static const EnumProperty Priority;
static const PropertyOrGroup* const Properties[];
virtual const PropertyOrGroup* const* GetProperties() const override final { return Properties; }
};
|
d2a3c83dd902eebf4f4214949b1b8868c0247753 | 40487796b93e8f5e253790ddd7524498a8c6439a | /src/Gogh/MainWindowStyle.cpp | b4649ee849ac6c93f1dbe1292b9d64ad07531b8d | [
"MIT"
] | permissive | eliemichel/CodenameGogh | 9f1d9fdcd3f4802e57dbf6d81a53346f4645f4d5 | 6fea1a03b7a86d19dfaed7a5093784200ca7815f | refs/heads/main | 2021-06-23T15:55:39.958404 | 2020-12-18T10:59:02 | 2020-12-18T10:59:02 | 142,702,250 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 626 | cpp | MainWindowStyle.cpp | #include <QStyleFactory>
#include "MainWindowStyle.h"
MainWindowStyle::MainWindowStyle()
{
setBaseStyle(QStyleFactory::create("Fusion"));
}
QPalette MainWindowStyle::standardPalette() const
{
QPalette pal = QProxyStyle::standardPalette();
pal.setColor(QPalette::Window, QColor(68, 68, 68));
pal.setColor(QPalette::WindowText, Qt::white);
pal.setColor(QPalette::Base, QColor(51, 51, 51));
pal.setColor(QPalette::AlternateBase, QColor(61, 61, 61));
pal.setColor(QPalette::Text, Qt::white);
pal.setColor(QPalette::Button, QColor(61, 61, 61));
pal.setColor(QPalette::ButtonText, QColor(232, 232, 232));
return pal;
}
|
526aac31dd12ac0bd5c8d9c421a3b5099603dbef | 09b62b21d4450cf737a62da16d2d6006dbcba86a | /yl_32/sourcecode/server/coordinator2/relation/tmpfriendfactory.h | 1071a29d654d661ac9a9b684b2a7076a29b47186 | [] | no_license | hw233/clua_yol | fa16cf913092286f9ea3d11db1e911568f569363 | bbc2e55290c185f6cfff72af9e1b9a96f9e6f074 | refs/heads/master | 2020-03-19T06:24:23.486101 | 2016-02-23T10:04:58 | 2016-02-23T10:04:58 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,486 | h | tmpfriendfactory.h | /* -------------------------------------------------------------------------
// 文件名 : tmpfriendfactory.h
// 创建者 :
// 创建时间 :
// 功能描述 : 临时好友工厂
//
// -----------------------------------------------------------------------*/
#ifndef __KTMPFRIENDFACTORY_H__
#define __KTMPFRIENDFACTORY_H__
#include "unirelationfactory.h"
class KTmpFriendFactory : public KUniRelationFactory
{
typedef KUniRelationFactory SUPER_CLASS;
public:
KTmpFriendFactory();
virtual ~KTmpFriendFactory();
public:
/***********************************************************
Function : CanCreateRelation
Description : 检查是否可以创建玩家关系
Return : BOOL
Param : pMaster 主位玩家
Param : pTarget 次位玩家
***********************************************************/
virtual BOOL CanCreateRelation(
INT nMaster,
INT nTarget);
/***********************************************************
Function : CreateRelation
Description : 创建玩家关系
Return : BOOL
Param : pMaster 主位玩家
Param : pTarget 次位玩家
Param : bIsMasterActive 主位玩家为主动申请方
Param : ppRelation 创建的玩家关系
***********************************************************/
virtual BOOL CreateRelation(
INT nMaster,
INT nTarget,
BOOL bIsMasterActive,
IKRelation** ppRelation);
};
#endif //__KTMPFRIENDFACTORY_H__
|
4783694b85267e413b1cc685a5ed0fa183764818 | 87c53d435d709293536f376730a160eb48834b23 | /Decimal to any base.cpp | b073a1d914fad2c65d3d5e7cda1c488aeb2bff68 | [] | no_license | Sagorika28/C-plus-plus-codes | 9e4e05ac768cd7c368f04ea713253a222b7a3ffa | 531f4abdb171b37d23430178d56a5c96bda3a77b | refs/heads/master | 2023-06-02T00:43:02.134535 | 2021-06-18T07:51:37 | 2021-06-18T07:51:37 | 278,141,365 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 302 | cpp | Decimal to any base.cpp | #include <iostream>
#include <iomanip>
using namespace std;
void change(int n, int b) {
int ans=0,dig, p=1;
while(n) {
dig = n%b;
ans += p*dig;
p *= 10;
n /= b;
}
cout<<ans;
}
int main() {
int n,b;
cin>>n>>b;
change(n, b);
return 0;
}
|
8fd2d75c798d5593f73cbdc35d670d389c97eeac | 1336ec5333bc3c3fe3ebd77da979ed0919291e8b | /plaintextdialog.h | 8f5da43bd735fd638c9d6d9756de0094037b7578 | [] | no_license | quartorz/Qhyphen | a6ff54c6d5014a6308fd70b64f1c13c9bb2b9555 | d3ee7bd643a2a08116abddffc325f3cd6d45c1dc | refs/heads/master | 2021-01-20T02:25:15.418421 | 2017-04-25T20:54:06 | 2017-04-25T20:54:06 | 89,403,133 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 357 | h | plaintextdialog.h | #ifndef PLAINTEXTDIALOG_H
#define PLAINTEXTDIALOG_H
#include <QDialog>
namespace Ui {
class PlainTextDialog;
}
class PlainTextDialog : public QDialog
{
Q_OBJECT
public:
explicit PlainTextDialog(QWidget *parent = 0);
~PlainTextDialog();
QString content() const;
private:
Ui::PlainTextDialog *ui;
};
#endif // PLAINTEXTDIALOG_H
|
f2f21ae6d3f7386a285d186340b6707d49ca7832 | e71807c58b97bc7c7ee286b5eb6c42421c0c0c22 | /ZClanListBox.h | 1e3a68653081fdabb9fc65edaa662a2b816e508e | [] | no_license | henriquegnandt/Gunz1.5 | b42e086e3fe77084023c8aa6c2d037466d49c7ba | 36678e8c367e1a2ce8af6eed4fd54b3d76e67709 | refs/heads/master | 2022-04-13T13:20:24.702946 | 2020-03-27T00:47:37 | 2020-03-27T00:47:37 | 250,406,234 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 1,113 | h | ZClanListBox.h | #ifndef _ZCLANLISTBOX_H
#define _ZCLANLISTBOX_H
#include "MWidget.h"
#include "MMatchGlobal.h"
#define NUM_DISPLAY_CLAN 4
struct ZCLANINFO {
int nClanEmblemID;
char szClanName[CLAN_NAME_LENGTH];
int nPlayers; // 대기중인 사람수
bool bEmpty; // 비어있는방인지
//bool bIsAntiLead;
//int GameType;
};
class ZClanListBox : public MWidget {
protected:
int m_nPrevStageCount;
int m_nNextStageCount;
int m_iNumRoom;
float m_RoomWidth;
float m_RoomHeight;
ZCLANINFO m_pClanInfo[NUM_DISPLAY_CLAN];
MBitmap* m_pRoomFrame;/*, *AntiLead,*Lead, *TeamDeathMatch, *Assassinate,*Gladiator;*/
int m_Selection;
int m_currPage;
protected:
virtual void OnDraw( MDrawContext* pDC );
public:
void SetWidth( float width ) { m_RoomWidth = width; }
void SetHeight( float height ) { m_RoomHeight = height; }
public:
ZClanListBox(const char* szName=NULL, MWidget* pParent=NULL, MListener* pListener=NULL);
virtual ~ZClanListBox(void);
void SetInfo(int nIndex, int nEmblemID, const char *szName, int nPlayers);
void Clear(int nIndex);
void ClearAll();
};
#endif |
b34ee6ad47687fa3d2ae9e16905ee2f30d0cf936 | 37baa0aef8d78dea826cec48cce02a4fa045f403 | /src/FeatureSelection.cpp | 53e783c0d66bfc16819bc8d74520aac4c25798cd | [] | no_license | a686432/FR2017 | 22d9e4aa52772c1ca8b5ee88ebaeaaf150319203 | de88d20690b94a49e65dcc05eb108f30f16afd37 | refs/heads/master | 2021-05-09T06:57:10.711839 | 2018-01-29T07:33:42 | 2018-01-29T07:33:42 | 119,347,362 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,119 | cpp | FeatureSelection.cpp | //
// Created by jdq on 17-12-26.
//
#include "FeatureSelection.h"
FeatureSelection::FeatureSelection(FeatureDescriptor fd)
{
//this->features = fd.get;
}
FeatureSelection::~FeatureSelection()
{
}
void FeatureSelection::LDA(vector<int> &a)
{
shark::LDA();
}
ClassificationDataset FeatureSelection::vec2labelData(vector<mylabelData>& a) {
std::size_t dimensions = a[0].input.size();
ClassificationDataset dataset;
const int maximumBatchSize = 256;
std::vector<std::size_t> batchSizes = shark::detail::optimalBatchSizes(a.size(), maximumBatchSize);
cout<<"batchSizes: "<< batchSizes[1] <<endl;
dataset = ClassificationDataset(batchSizes.size());
std::size_t currentIndex = 0;
for (std::size_t b = 0; b != batchSizes.size(); ++b) {
RealMatrix& inputs = dataset.batch(b).input;
UIntVector& labels = dataset.batch(b).label;
inputs.resize(batchSizes[b], dimensions);
labels.resize(batchSizes[b]);
for (std::size_t i = 0; i != batchSizes[b]; ++i, currentIndex++) {
for (std::size_t j = 0; j != dimensions; ++j) {
inputs(i, j) = a[currentIndex].input[j];
labels[i] = a[currentIndex].label;
}
}
}
RealMatrix& inputs = dataset.batch(0).input;
cout<<"batchSizes: "<< inputs(1,1) <<endl;
cout<<"batchSizes: "<< a[0].input[0] <<endl;
return dataset;
}
vector<mylabelData> FeatureSelection::loadData(const string &inputpath="../data/input/feature/combine/1.txt")
{
ifstream in(inputpath, ios::in);
char tmp;
int count,dim;
std::string buff;
in>>tmp>>count>>dim;
vector<mylabelData> Mydata;
cout<<tmp<<"Number of data: "<<count<<" dimension of data: "<<dim<<endl;
getline(in,buff);
for (int i=0; i<count; i++) {
vector<double> vec;
getline(in,buff);
istringstream ss(buff);
cout<<buff<<endl;
for (int j = 0; j < dim; j++) {
double a;
ss >> a;
vec.push_back(a);
}
unsigned int label;
ss>>label;
mylabelData mydata{vec,label};
Mydata.push_back(mydata);
}
in.close();
return Mydata;
} |
134f33bb6a38425091b4a4be2ec941861c6f14a9 | b9f9b6141c5b2470c0633b92e54ccbcc85f1bbc2 | /kcppPlikiPodzial/Makefile.example/mainDwaPlikiC.cc | 130682df21b104d1d73a029c2c87446cea070dde | [] | no_license | epittek/kcpp | a8bb66e96eeea45d53abc9218c13d772cb49880e | 1226253b0f09a6cc64d75d5e4c98b9a710ed8a1e | refs/heads/master | 2021-07-23T07:21:29.220822 | 2020-05-18T08:40:53 | 2020-05-18T08:40:53 | 169,242,177 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 372 | cc | mainDwaPlikiC.cc | #include "dwaPlikiC.hh"
int main()
{
int zmienna = 0;
KlasaA *obj = new KlasaA();
cout <<"Podaj zmienna: ";
cin >> zmienna;
obj->SetZmienna(zmienna);
obj->DisplayZmienna();
int innaZmienna = obj->GetZmienna() + 7;
cout <<"Wartosc zmiennej: "<< innaZmienna << endl;
cout <<"Wartosc zmiennej: "<< obj->GetZmienna() << endl;
return 0;
}
|
58092b805e8c808083ca89e699143a4013ee54ca | ee00ee2d12c76ce0fd416beb4cd8c7ba9cbf57a8 | /2021-04-21/game.cpp | d221ecc52c2db3ae079a7e3d7f1dfedd502dfbe3 | [] | no_license | hyestar/SBS_cpp | 3f96b5e6dca27c2d0cdf3fc8ccc0608967bbbae0 | 9fba8135d4cb92a999bb6611bdc427ad60083f51 | refs/heads/main | 2023-07-10T21:28:16.257289 | 2021-08-05T13:38:02 | 2021-08-05T13:38:02 | 360,016,139 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,612 | cpp | game.cpp | #define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
class character {
public:
char name[50];
int power;
int attack;
int range;
int speed;
character(int power, int attack, int range, int speed) {
this->power = power;
this->attack = attack;
this->range = range;
this->speed = speed;
}
void printfInfo() {
printf("%s의 능력\n", name);
printf("최대체력: %d\n", power);
printf("최대공격: %d\n", attack);
printf("공격거리: %d\n", range);
printf("최대속도: %d\n", speed);
}
};
class Goblin : public character {
public:
Goblin() : character(10,5,10,10){
strcpy(name, "고블린");
}
};
class Orc : public character {
public:
Orc() : character(15,7,12,8) {
strcpy(name, "오크");
}
};
class slaim : public character {
public:
slaim() : character(20,3,11,9) {
strcpy(name, "슬라임");
}
};
class gol : public character {
public:
gol() : character(12,9,9,5) {
strcpy(name, "해골");
}
};
int main() {
character* units[10];
srand(time(0)); //시드값 변경
for (int i = 0; i < 10; i++) {
switch (rand() % 4) {
case 0:
units[i] = new Orc();
break;
case 1:
units[i] = new Goblin();
break;
case 2:
units[i] = new gol();
break;
case 3:
units[i] = new slaim();
break;
}
}
for (int i = 0; i < 10; i++) {
units[i]->printfInfo();
}
/*
for (int i = 0; i < 10; i++) {
delete units[i];
}
=> delete 안해줘도 되는 이유는 main함수에 있기 때문에 어짜피 끝나면 힙도 다 날아가 버리기 때문에 상관 없어서
*/
return 0;
}
|
b8e97035a36353788d4af07d51ace859aa8af00b | 15d6686ad1f75b5e4ada159c4bccd61cc4b31fc2 | /day-02/step2.cpp | c7cd28280d88d4ce74a4ea940ecee07725359c0c | [] | no_license | andre-ws/advent-of-code-2019 | 120fbb957a4e3c3056eba1b66bd0c8f11569ab46 | 0bc4f920fc76ffed6fa0619bf73ddebfdcaa0214 | refs/heads/master | 2020-09-23T13:09:19.963910 | 2019-12-07T23:17:09 | 2019-12-07T23:17:09 | 225,507,997 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,535 | cpp | step2.cpp | #include <iostream>
#include <fstream>
#include <vector>
using namespace std;
constexpr int Addition = 1;
constexpr int Multiplication = 2;
constexpr int Eof = 99;
bool isEof(int value)
{
return value == Eof;
}
void Add(vector<int>::iterator it, vector<int> &input)
{
input[*(it+3)] = input[*(it+1)] + input[*(it+2)];
}
void Multiply(vector<int>::iterator it, vector<int> &input)
{
input[*(it+3)] = input[*(it+1)] * input[*(it+2)];
}
vector<int>::iterator Next(vector<int>::iterator it)
{
return it + 4;
}
int processInputFile(vector<int> &input)
{
for (auto it = input.begin(); it != input.end() && !isEof(*it);)
{
auto value = *it;
switch (value)
{
case Addition:
Add(it, input);
it = Next(it);
break;
case Multiplication:
Multiply(it, input);
it = Next(it);
break;
default:
++it;
break;
}
}
return input[0];
}
int process(int noun, int verb, vector<int> input)
{
input[1] = noun;
input[2] = verb;
return processInputFile(input);
}
int main(int argc, char* argv[])
{
string temp;
vector<int> input;
ifstream inputFile("input.txt");
while (getline(inputFile, temp, ','))
{
auto token = atoi(temp.c_str());
input.push_back(token);
}
for (auto i = 0; i < 99; i++)
{
for (auto j = 0; j < 99; j++)
{
cout << "Trying combination " << (i+1)*(j+1) << "\r" << flush;
if (process(i, j, input) == 19690720)
{
cout << "Yay! Combination is " << i << " and " << j << endl;
return 0;
}
}
}
cout << "Oops, something is terribly wrong!";
return 1;
}
|
486cd5916f8b3ac8ad5a9d17d9045a82376e35a7 | 37b7c4d71ef2b375c8f20b0e3e4e1ce7ae5a3b3c | /dicomlib/include/RISObject.h | 5cfc16bfb7d78610f7a7a889e33437146b99ec70 | [] | no_license | albertzeng/eRadQueue | 35789276b83dbed4738ba5360e2c66871263655a | 8cf50e3821b9efb0aff57eaccab6370cc6691355 | refs/heads/master | 2021-01-23T19:56:21.282964 | 2015-08-03T07:49:50 | 2015-08-03T07:49:50 | 40,111,849 | 0 | 0 | null | null | null | null | WINDOWS-1258 | C++ | false | false | 39,482 | h | RISObject.h | // RISObject.h: interface for the RIS Object classes.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_RISOBJECT_H__BFF71E48_3501_4119_8FE7_DC3389648A48__INCLUDED_)
#define AFX_RISOBJECT_H__BFF71E48_3501_4119_8FE7_DC3389648A48__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define PATIENT_CREATED_EVENT 1
#define PATIENT_DELETED_EVENT 2
#define PATIENT_UPDATED_EVENT 3
#define VISIT_CREATED_EVENT 1
#define VISIT_SCHEDULED_EVENT 2
#define VISIT_ADMITTED_EVENT 3
#define VISIT_TRANSFERRED_EVENT 4
#define VISIT_DISCHARGED_EVENT 5
#define VISIT_DELETED_EVENT 6
#define VISIT_UPDATED_EVENT 7
#define STUDY_CREATED_EVENT 1
#define STUDY_SCHEDULED_EVENT 2
#define STUDY_ARRIVED_EVENT 3
#define STUDY_STARTED_EVENT 4
#define STUDY_COMPLETED_EVENT 5
#define STUDY_VERIFIED_EVENT 6
#define STUDY_READ_EVENT 7
#define STUDY_DELETED_EVENT 8
#define STUDY_UPDATED_EVENT 9
#define MPPS_IN_PROGRESS_EVENT 1
#define MPPS_COMPLETED_EVENT 2
#define MPPS_DISCONTINUED_EVENT 3
#define MPPS_UPDATED_EVENT 4
#define MPPS_DELETED_EVENT 5
#define STORAGE_COMMITMENT_REQUEST_ACTION 1
#define STORAGE_COMMITMENT_SUCCESSFUL_EVENT 1
#define STORAGE_COMMITMENT_FAILURES_EXIST_EVENT 2
#define RESULTS_CREATED_EVENT 1
#define RESULTS_DELETED_EVENT 2
#define RESULTS_UPDATED_EVENT 3
#define INTERPRETATION_CREATED_EVENT 1
#define INTERPRETATION_RECORDED_EVENT 2
#define INTERPRETATION_TRANSCRIBED_EVENT 3
#define INTERPRETATION_APPROVED_EVENT 4
#define INTERPRETATION_DELETED_EVENT 5
#define INTERPRETATION_UPDATED_EVENT 6
#define GSPS_STATUS_MODIFICATION_REQUEST_ACTION 1
#define VISIT_CREATED_STATUS "CREATED"
#define VISIT_SCHEDULED_STATUS "SCHEDULED"
#define VISIT_ADMITTED_STATUS "ADMITTED"
#define VISIT_DISCHARGED_STATUS "DISCHARGED"
#define VISIT_OUT_PATIENT "OUTPATIENT"
#define VISIT_IN_PATIENT "INPATIENT"
#define VISIT_EMERGENCY "EMERGENCY"
#define STUDY_CREATED_STATUS "CREATED"
#define STUDY_SCHEDULED_STATUS "SCHEDULED"
#define STUDY_ARRIVED_STATUS "ARRIVED"
#define STUDY_STARTED_STATUS "STARTED"
#define STUDY_COMPLETED_STATUS "COMPLETED"
#define STUDY_VERIFIED_STATUS "VERIFIED"
#define STUDY_READ_STATUS "READ"
#define STUDY_LOW_PRIORITY "LOW"
#define STUDY_MED_PRIORITY "MED"
#define STUDY_HIGH_PRIORITY "HIGH"
#define STUDY_COMPONENT_CREATED_STATUS "CREATED"
#define STUDY_COMPONENT_INCOMPLETE_STATUS "INCOMPLETE"
#define STUDY_COMPONENT_COMPLETED_STATUS "COMPLETED"
#define STUDY_COMPONENT_VERIFIED_STATUS "VERIFIED"
#define STUDY_COMPONENT_POSTINTERPRET_STATUS "POSTINTERPRET"
#define MPPS_IN_PROGRESS_STATUS "IN PROGRESS"
#define MPPS_DISCONTINUED_STATUS "DISCONTINUED"
#define MPPS_COMPLETED_STATUS "COMPLETED"
#define INTERPRETATION_CREATED_STATUS "CREATED"
#define INTERPRETATION_RECORDED_STATUS "RECORDED"
#define INTERPRETATION_TRANSCRIBED_STATUS "TRANSCRIBED"
#define INTERPRETATION_APPROVED_STATUS "APPROVED"
#define INTERPRETATION_REPORT_TYPE "REPORT"
#define INTERPRETATION_AMENDMENT_TYPE "AMENDMENT"
#define MSPS_SCHEDULED_STATUS "SCHEDULED"
#define MSPS_ARRIVED_STATUS "ARRIVED"
#define REQUESTED_PROCEDURE_STAT_PRIORITY "STAT"
#define REQUESTED_PROCEDURE_HIGH_PRIORITY "HIGH"
#define REQUESTED_PROCEDURE_ROUTINE_PRIORITY "ROUTINE"
#define REQUESTED_PROCEDURE_MEDIUM_PRIORITY "MEDIUM"
#define REQUESTED_PROCEDURE_LOW_PRIORITY "LOW"
#define REPORTING_HIGH_PRIORITY "HIGH"
#define REPORTING_ROUTINE_PRIORITY "ROUTINE"
#define REPORTING_MEDIUM_PRIORITY "MEDIUM"
#define REPORTING_LOW_PRIORITY "LOW"
#define GSPS_SCHEDULED_STATUS "SCHEDULED"
#define GSPS_IN_PROGRESS_STATUS "IN PROGRESS"
#define GSPS_SUSPENDED_STATUS "SUSPENDED"
#define GSPS_COMPLETED_STATUS "COMPLETED"
#define GSPS_DISCONTINUED_STATUS "DISCONTINUED"
#define GSPS_PARTIAL_AVAILABILITY_FLAG "PARTIAL"
#define GSPS_COMPLETE_AVAILABILITY_FLAG "COMPLETE"
#define GSPS_HIGH_PRIORITY "HIGH"
#define GSPS_MEDIUM_PRIORITY "MEDIUM"
#define GSPS_LOW_PRIORITY "LOW"
#define GPPS_IN_PROGRESS_STATUS "IN PROGRESS"
#define GPPS_COMPLETED_STATUS "COMPLETED"
#define GPPS_DISCONTINUED_STATUS "DISCONTINUED"
class CObCodeItem : public CObBasic
{
DECLARE_MEMBER_TABLE(CObCodeItem)
public:
CString m_strCodeValue; // (0008,0100) >Code Value
CString m_strCodeScheme; // (0008,0102) >Coding Scheme Designator
CString m_strCodeVersion; // (0008,0103) >Coding Scheme Version
CString m_strMeaning; // (0008,0104) >Code Meaning
public:
CObCodeItem();
virtual ~CObCodeItem();
};
typedef CTypedPtrArray<CObSQ, CObCodeItem*> CObCodeSQ;
class CObLangCodeItem : public CObBasic
{
DECLARE_MEMBER_TABLE(CObLangCodeItem)
public:
CString m_strCodeValue; // (0008,0100) >Code Value
CString m_strCodeScheme; // (0008,0102) >Coding Scheme Designator
CString m_strCodeVersion; // (0008,0103) >Coding Scheme Version
CString m_strMeaning; // (0008,0104) >Code Meaning
CObCodeSQ m_SQModifierCode; // (0010,0102) >Patient's Primary Language Code Modifier Sequence
public:
CObLangCodeItem();
virtual ~CObLangCodeItem();
};
typedef CTypedPtrArray<CObSQ, CObLangCodeItem*> CObLangCodeSQ;
class CObPatient : public CObBasic
{
DECLARE_MEMBER_TABLE(CObPatient)
public:
CString m_strCharacter; // (0008,0005) Specific Character Set
CString m_strCreateDate; // (0008,0012) Instance Creation Date
CString m_strCreateTime; // (0008,0013) Instance Creation Time
CString m_strCreatorUID; // (0008,0014) Instance Creator UID
CObRefInstanceSQ m_SQStudyInstance; // (0008,1110) Referenced Study Sequence
CObRefInstanceSQ m_SQVisitInstance; // (0008,1125) Referenced Visit Sequence
CObRefInstanceSQ m_SQAliasInstance; // (0038,0004) Referenced Patient Alias Sequence
CString m_strPatientName; // (0010,0010) Patient's Name
CString m_strPatientID; // (0010,0020) Patient ID
CString m_strIDIssuer; // (0010,0021) Issuer of Patient ID
CString m_strOtherPatientID; // (0010,1000) Other Patient IDs
CString m_strOtherPatientName; // (0010,1001) Other Patient Names
CString m_strBirthName; // (0010,1005) Patient's Birth Name
CString m_strMotherName; // (0010,1060) Patient's Mother's Birth Name
CString m_strRecordLocator; // (0010,1090) Medical Record Locator
CString m_strPatientAge; // (0010,1010) Patient's Age
CString m_strOccupation; // (0010,2180) Occupation
CString m_strConfidentiality; // (0040,3001) Patient Data Confidentiality Constraint Description
CString m_strPatientDOB; // (0010,0030) Patient's Birth Date
CString m_strBirthTime; // (0010,0032) Patient's Birth Time
CString m_strPatientSex; // (0010,0040) Patient's Sex
CObCodeSQ m_SQInsuranceCode; // (0010,0050) Patient's Insurance Plan Code Sequence
CObLangCodeSQ m_SQLanguageCode; // (0010,0101) Patient's Primary Language Code Sequence
CString m_strPatSize; // (0010,1020) Patient's Size
CString m_strPatWeight; // (0010,1030) Patient's Weight
CString m_strPatAddress; // (0010,1040) Patient's Address
CString m_strMilitaryRank; // (0010,1080) Military Rank
CString m_strMilitaryBranch; // (0010,1081) Branch of Service
CString m_strCountry; // (0010,2150) Country of Residence
CString m_strRegion; // (0010,2152) Region of Residence
CString m_strPatPhone; // (0010,2154) Patient's Telephone Numbers
CString m_strEthnicGroup; // (0010,2160) Ethnic Group
CString m_strReligion; // (0010,21F0) Patient's Religious Preference
CString m_strPatComments; // (0010,4000) Patient Comments
CString m_strMedAlert; // (0010,2000) Medical Alerts
CString m_strMedAllergy; // (0010,2110) Contrast Allergies
CString m_strSmoking; // (0010,21A0) Smoking Status
CString m_strPatHistory; // (0010,21B0) Additional Patient History
Uint16 m_nPregnant; // (0010,21C0) Pregnancy Status
CString m_strLastMenses; // (0010,21D0) Last Menstrual Date
CString m_strSpecialNeed; // (0038,0050) Special Needs
CString m_strPatState; // (0038,0500) Patient State
public:
CObPatient();
virtual ~CObPatient();
};
class CObVisit : public CObBasic
{
DECLARE_MEMBER_TABLE(CObVisit)
public:
CString m_strCharacter; // (0008,0005) Specific Character Set
CString m_strCreateDate; // (0008,0012) Instance Creation Date
CString m_strCreateTime; // (0008,0013) Instance Creation Time
CString m_strCreatorUID; // (0008,0014) Instance Creator UID
CObRefInstanceSQ m_SQStudyInstance; // (0008,1110) Referenced Study Sequence
CObRefInstanceSQ m_SQPatientInstance; // (0008,1120) Referenced Patient Sequence
CString m_strInstitutionName; // (0008,0080) Institution Name
CString m_strInstitutionAddress;// (0008,0081) Institution Address
CObCodeSQ m_SQInstitutionCode; // (0008,0082) Institution Code Sequence
CString m_strAdmissionID; // (0038,0010) Admission ID
CString m_strIDIssuer; // (0038,0011) Issuer of Admission ID
CString m_strStatusID; // (0038,0008) Visit Status ID
CString m_strPatLocation; // (0038,0300) Current Patient Location
CString m_strPatResidence; // (0038,0400) Patient¡¯s Institution Residence
CString m_strVisitComments; // (0038,4000) Visit Comments
CString m_strReferName; // (0008,0090) Referring Physician's Name
CString m_strReferAddress; // (0008,0092) Referring Physician's Address
CString m_strReferPhone; // (0008,0094) Referring Physician's Phone Numbers
CString m_strAdmDiagDesc; // (0008,1080) Admitting Diagnoses Description
CObCodeSQ m_SQAdmDiagCode; // (0008,1084) Admitting Diagnoses Code Sequence
CString m_strAdmRoute; // (0038,0016) Route of Admissions
CString m_strAdmDate; // (0038,0020) Admitting Date
CString m_strAdmTime; // (0038,0021) Admitting Time
CString m_strDischDate; // (0038,0030) Discharge Date
CString m_strDischTime; // (0038,0032) Discharge Time
CString m_strDischDiagDesc; // (0038,0040) Discharge Diagnosis Description
CObCodeSQ m_SQDischDiagCode; // (0038,0044) Discharge Diagnosis Code Sequence
CString m_strSchAdmDate; // (0038,001A) Scheduled Admission Date
CString m_strSchAdmTime; // (0038,001B) Scheduled Admission Time
CString m_strSchDischDate; // (0038,001C) Scheduled Discharge Date
CString m_strSchDischTime; // (0038,001D) Scheduled Discharge Time
CString m_strSchResidence; // (0038,001E) Scheduled Patient Institution Residence
public:
CObVisit();
virtual ~CObVisit();
};
class CObStudy : public CObBasic
{
DECLARE_MEMBER_TABLE(CObStudy)
public:
CString m_strCharacter; // (0008,0005) Specific Character Set
CString m_strCreateDate; // (0008,0012) Instance Creation Date
CString m_strCreateTime; // (0008,0013) Instance Creation Time
CString m_strCreatorUID; // (0008,0014) Instance Creator UID
CObRefInstanceSQ m_SQVisitInstance; // (0008,1125) Referenced Visit Sequence
CObRefInstanceSQ m_SQPatientInstance; // (0008,1120) Referenced Patient Sequence
CObRefInstanceSQ m_SQResultsInstance; // (0008,1100) Referenced Results Sequence
CObRefInstanceSQ m_SQComponentInstance; // (0008,1111) Referenced Study Component Sequence
CString m_strStudyInstUID; // (0020,000D) Study Instance UID
CString m_strAccessionNumber; // (0008,0050) Accession Number
CString m_strStudyID; // (0020,0010) Study ID
CString m_strIDIssuer; // (0032,0012) Study ID Issuer
CString m_strOtherNumbers; // (0020,1070) Other Study Numbers
CString m_strStatusID; // (0032,000A) Study Status ID
CString m_strPriorityID; // (0032,000C) Study Priority ID
CString m_strStudyComments; // (0032,4000) Study Comments
CString m_strStartDate; // (0032,1000) Scheduled Study Start Date
CString m_strStartTime; // (0032,1001) Scheduled Study Start Time
CString m_strStopDate; // (0032,1010) Scheduled Study Stop Date
CString m_strStopTime; // (0032,1011) Scheduled Study Stop Time
CString m_strSchLocation; // (0032,1020) Scheduled Study Location
CString m_strAETitle; // (0032,1021) Scheduled Study Location AE Title
CString m_strReason; // (0032,1030) Reason for Study
CString m_strRequester; // (0032,1032) Requesting Physician
CString m_strService; // (0032,1033) Requesting Service
CString m_strProcDesc; // (0032,1060) Requested Procedure Description
CObCodeSQ m_SQProcCode; // (0032,1064) Requested Procedure Code Sequence
CString m_strContrastAgent; // (0032,1070) Requested Contrast Agent
CString m_strArriveDate; // (0032,1040) Study Arrival Date
CString m_strArriveTime; // (0032,1041) Study Arrival Time
CString m_strStudyDate; // (0008,0020) Study Date
CString m_strStudyTime; // (0008,0030) Study Time
CString m_strDoneDate; // (0032,1050) Study Completion Date
CString m_strDoneTime; // (0032,1051) Study Completion Time
CString m_strVerifyDate; // (0032,0032) Study Verified Date
CString m_strVerifyTime; // (0032,0033) Study Verified Time
CString m_strModality; // (0008,0061) Modalities in Study
CString m_strTotalSeries; // (0020,1000) Series in Study
CString m_strTotalImage; // (0020,1004) Acquisitions in Study
CString m_strReader; // (0008,1060) Name of Physician (s) Reading Study
CString m_strReadDate; // (0032,0034) Study Read Date
CString m_strReadTime; // (0032,0035) Study Read Time
public:
CObStudy();
virtual ~CObStudy();
};
class CObSOPInstanceItem : public CObBasic
{
DECLARE_MEMBER_TABLE(CObSOPInstanceItem)
public:
CString m_strSOPClassUID; // (0008,1150) >>Referenced SOP Class UID
CString m_strSOPInstanceUID; // (0008,1155) >>Referenced SOP Instance UID
CString m_strAETitle; // (0008,0054) >>Retrieve AE Title
CString m_strFileSetID; // (0088,0130) >>Storage Media File-Set ID
CString m_strFileSetUID; // (0088,0140) >>Storage Media File-Set UID
public:
CObSOPInstanceItem();
virtual ~CObSOPInstanceItem();
};
typedef CTypedPtrArray<CObSQ, CObSOPInstanceItem*> CObSOPInstanceSQ;
class CObSeriesItem : public CObBasic
{
DECLARE_MEMBER_TABLE(CObSeriesItem)
public:
CString m_strSeriesDate; // (0008,0021) >Series Date
CString m_strSeriesTime; // (0008,0031) >Series Time
CString m_strSeriesInstUID; // (0020,000E) >Series Instance UID
CString m_strAETitle; // (0008,0054) >Retrieve AE Title
CString m_strFileSetID; // (0088,0130) >Storage Media File-Set ID
CString m_strFileSetUID; // (0088,0140) >Storage Media File-Set UID
CObSOPInstanceSQ m_SQReferencedImage; // (0008,1140) >Referenced Image Sequence
public:
CObSeriesItem();
virtual ~CObSeriesItem();
};
typedef CTypedPtrArray<CObSQ, CObSeriesItem*> CObSeriesSQ;
class CObComponent : public CObBasic
{
DECLARE_MEMBER_TABLE(CObComponent)
public:
CString m_strCharacter; // (0008,0005) Specific Character Set
CString m_strCreateDate; // (0008,0012) Instance Creation Date
CString m_strCreateTime; // (0008,0013) Instance Creation Time
CString m_strCreatorUID; // (0008,0014) Instance Creator UID
CString m_strStudyID; // (0020,0010) Study ID
CString m_strStudyInstUID; // (0020,000D) Study Instance UID
CObSeriesSQ m_SQReferencedSeries; // (0008,1115) Referenced Series Sequence
CObRefInstanceSQ m_SQStudyInstance; // (0008,1110) Referenced Study Sequence
CString m_strModality; // (0008,0060) Modality
CString m_strStudyDescription; // (0008,1030) Study Description
CObCodeSQ m_SQProcCode; // (0008,1032) Procedure Code Sequence
CString m_strPerformer; // (0008,1050) Performing Physician's Name
CString m_strStatusID; // (0032,1055) Study Component Status ID
public:
CObComponent();
virtual ~CObComponent();
};
class CObScheduledStepItem : public CObBasic
{
DECLARE_MEMBER_TABLE(CObScheduledStepItem)
public:
CString m_strStudyInstUID; // (0020,000D) >Study Instance UID
CObRefInstanceSQ m_SQStudyInstance; // (0008,1110) >Referenced Study Sequence
CString m_strAccessionNumber; // (0008,0050) >Accession Number
CString m_strPlacerOrder; // (0040,2016) >Placer Order Number/Imaging Service Request
CString m_strFillerOrder; // (0040,2017) >Filler Order Number/Imaging Service Request
CString m_strProcID; // (0040,1001) >Requested Procedure ID
CString m_strProcDesc; // (0032,1060) >Requested Procedure Description
CString m_strStepID; // (0040,0009) >Scheduled Procedure Step ID
CString m_strStepDesc; // (0040,0007) >Scheduled Procedure Step Description
CObCodeSQ m_SQProtCode; // (0040,0008) >Scheduled Protocol Code Sequence
public:
CObScheduledStepItem();
virtual ~CObScheduledStepItem();
};
typedef CTypedPtrArray<CObSQ, CObScheduledStepItem*> CObScheduledStepSQ;
class CObPerformSeriesItem : public CObBasic
{
DECLARE_MEMBER_TABLE(CObPerformSeriesItem)
public:
CString m_strPerformer; // (0008,1050) >Performing Physician's Name
CString m_strOperator; // (0008,1070) >Operator's Name
CString m_strProtName; // (0018,1030) >Protocol Name
CString m_strSeriesInstUID; // (0020,000E) >Series Instance UID
CString m_strSeriesDescription; // (0008,103E) >Series Description
CString m_strAETitle; // (0008,0054) >Retrieve AE Title
CObRefInstanceSQ m_SQImageInstance; // (0008,1140) >Referenced Image Sequence
CObRefInstanceSQ m_SQNonImageInstance; // (0040,0220) >Referenced Non-Image Composite SOP Instance Sequence
public:
CObPerformSeriesItem();
virtual ~CObPerformSeriesItem();
};
typedef CTypedPtrArray<CObSQ, CObPerformSeriesItem*> CObPerformSeriesSQ;
class CObMpps : public CObBasic
{
DECLARE_MEMBER_TABLE(CObMpps)
public:
CString m_strCharacter; // (0008,0005) Specific Character Set
CString m_strCreateDate; // (0008,0012) Instance Creation Date
CString m_strCreateTime; // (0008,0013) Instance Creation Time
CString m_strCreatorUID; // (0008,0014) Instance Creator UID
CString m_strPatientName; // (0010,0010) Patient's Name
CString m_strPatientID; // (0010,0020) Patient ID
CString m_strPatientDOB; // (0010,0030) Patient's Birth Date
CString m_strPatientSex; // (0010,0040) Patient's Sex
CObRefInstanceSQ m_SQPatientInstance; // (0008,1120) Referenced Patient Sequence
CObScheduledStepSQ m_SQScheduledStep; // (0040,0270) Scheduled Step Attributes Sequence
CString m_strStationAETitle; // (0040,0241) Performed Station AE Title
CString m_strStationName; // (0040,0242) Performed Station Name
CString m_strLocation; // (0040,0243) Performed Location
CString m_strStartDate; // (0040,0244) Performed Procedure Step Start Date
CString m_strStartTime; // (0040,0245) Performed Procedure Step Start Time
CString m_strMppsID; // (0040,0253) Performed Procedure Step ID
CString m_strEndDate; // (0040,0250) Performed Procedure Step End Date
CString m_strEndTime; // (0040,0251) Performed Procedure Step End Time
CString m_strMppsStatus; // (0040,0252) Performed Procedure Step Status
CString m_strMppsDesc; // (0040,0254) Performed Procedure Step Description
CString m_strMppsComments; // (0040,0280) Comments on the Performed Procedure Step
CString m_strMppsProcType; // (0040,0255) Performed Procedure Type Description
CObCodeSQ m_SQProcCode; // (0008,1032) Procedure Code Sequence
CString m_strModality; // (0008,0060) Modality
CString m_strStudyID; // (0020,0010) Study ID
CObCodeSQ m_SQMppsProtCode; // (0040,0260) Performed Protocol Code Sequence
CObPerformSeriesSQ m_SQPerformSeries; // (0040,0340) Performed Series Sequence
public:
CObMpps();
virtual ~CObMpps();
};
class CObResults : public CObBasic
{
DECLARE_MEMBER_TABLE(CObResults)
public:
CString m_strCharacter; // (0008,0005) Specific Character Set
CString m_strCreateDate; // (0008,0012) Instance Creation Date
CString m_strCreateTime; // (0008,0013) Instance Creation Time
CString m_strCreatorUID; // (0008,0014) Instance Creator UID
CObRefInstanceSQ m_SQStudyInstance; // (0008,1110) Referenced Study Sequence
CObRefInstanceSQ m_SQInterInstance; // (4008,0050) Referenced Interpretation Sequence
CString m_strResultsID; // (4008,0040) Results ID
CString m_strIDIssuer; // (4008,0042) Results ID Issuer
CString m_strImpressions; // (4008,0300) Impressions
CString m_strResultsComments; // (4008,4000) Results Comments
public:
CObResults();
virtual ~CObResults();
};
class CObApproverItem : public CObBasic
{
DECLARE_MEMBER_TABLE(CObApproverItem)
public:
CString m_strApproveDate; // (4008,0112) >Interpretation Approval Date
CString m_strApproveTime; // (4008,0113) >Interpretation Approval Time
CString m_strApprover; // (4008,0114) >Physicians Approving Interpretation
public:
CObApproverItem();
virtual ~CObApproverItem();
};
typedef CTypedPtrArray<CObSQ, CObApproverItem*> CObApproverSQ;
class CObDistributeItem : public CObBasic
{
DECLARE_MEMBER_TABLE(CObDistributeItem)
public:
CString m_strName; // (4008,0119) >Distribution Name
CString m_strAddress; // (4008,011A) >Distribution Address
public:
CObDistributeItem();
virtual ~CObDistributeItem();
};
typedef CTypedPtrArray<CObSQ, CObDistributeItem*> CObDistributeSQ;
class CObInterpretation : public CObBasic
{
DECLARE_MEMBER_TABLE(CObInterpretation)
public:
CString m_strCharacter; // (0008,0005) Specific Character Set
CString m_strCreateDate; // (0008,0012) Instance Creation Date
CString m_strCreateTime; // (0008,0013) Instance Creation Time
CString m_strCreatorUID; // (0008,0014) Instance Creator UID
CObRefInstanceSQ m_SQResultsInstance; // (0008,1100) Referenced Results Sequence
CString m_strInterID; // (4008,0200) Interpretation ID
CString m_strIDIssuer; // (4008,0202) Interpretation ID Issuer
CString m_strTypeID; // (4008,0210) Interpretation Type ID
CString m_strStatusID; // (4008,0212) Interpretation Status ID
CString m_strRecordDate; // (4008,0100) Interpretation Recorded Date
CString m_strRecordTime; // (4008,0101) Interpretation Recorded Time
CString m_strRecorder; // (4008,0102) Interpretation Recorder
CString m_strRecordSound; // (4008,0103) Reference to Recorded Sound
CString m_strTransDate; // (4008,0108) Interpretation Transcription Date
CString m_strTransTime; // (4008,0109) Interpretation Transcription Time
CString m_strTranscriber; // (4008,010A) Interpretation Transcriber
CString m_strInterText; // (4008,010B) Interpretation Text
CString m_strAuthor; // (4008,010C) Interpretation Author
CObApproverSQ m_SQApprover; // (4008,0111) Interpretation Approver Sequence
CString m_strDiagDesc; // (4008,0115) Interpretation Diagnosis Description
CObCodeSQ m_SQDiagCode; // (4008,0117) Interpretation Diagnosis Codes Sequence
CObDistributeSQ m_SQDistribute; // (4008,0118) Results Distribution List Sequence
public:
CObInterpretation();
virtual ~CObInterpretation();
};
class CObFailedItem : public CObBasic
{
DECLARE_MEMBER_TABLE(CObFailedItem)
public:
CString m_strSOPClassUID; // (0008,1150) >Referenced SOP Class UID
CString m_strSOPInstanceUID; // (0008,1155) >Referenced SOP Instance UID
Uint16 m_nFailureReason; // (0008,1197) >Failure Reason
public:
CObFailedItem();
virtual ~CObFailedItem();
};
typedef CTypedPtrArray<CObSQ, CObFailedItem*> CObFailedSQ;
class CObStorageCommitment : public CObBasic
{
DECLARE_MEMBER_TABLE(CObStorageCommitment)
public:
CString m_strCharacter; // (0008,0005) Specific Character Set
CString m_strTransactionUID; // (0008,1195) Transaction UID
CString m_strAETitle; // (0008,0054) Retrieve AE Title
CString m_strFileSetID; // (0088,0130) Storage Media File-Set ID
CString m_strFileSetUID; // (0088,0140) Storage Media File-Set UID
CObSOPInstanceSQ m_SQReferencedInstance; // (0008,1199) Referenced SOP Sequence
CObRefInstanceSQ m_SQComponentInstance; // (0008,1111) Referenced Study Component Sequence
CObFailedSQ m_SQFailedInstance; // (0008,1198) Failed SOP Sequence
public:
CObStorageCommitment();
virtual ~CObStorageCommitment();
};
class CObMwlStepItem : public CObBasic
{
DECLARE_MEMBER_TABLE(CObMwlStepItem)
public:
CString m_strAETitle; // (0040,0001) >Scheduled Station AE Title
CString m_strStationName; // (0040,0010) >Scheduled Station Name
CString m_strStepLocation; // (0040,0011) >Scheduled Procedure Step Location
CString m_strStartDate; // (0040,0002) >Scheduled Procedure Step Start Date
CString m_strStartTime; // (0040,0003) >Scheduled Procedure Step Start Time
CString m_strEndDate; // (0040,0004) >Scheduled Procedure Step End Date
CString m_strEndTime; // (0040,0005) >Scheduled Procedure Step End Time
CString m_strSchPerformer; // (0040,0006) >Scheduled Performing Physician's Name
CString m_strStepDesc; // (0040,0007) >Scheduled Procedure Step Description
CObCodeSQ m_SQProtCode; // (0040,0008) >Scheduled Protocol Code Sequence
CString m_strStepID; // (0040,0009) >Scheduled Procedure Step ID
CString m_strStepStatus; // (0040,0020) >Scheduled Procedure Step Status
CString m_strStepComments; // (0040,0400) >Comments on the Scheduled Procedure Step
CString m_strModality; // (0008,0060) >Modality
CString m_strContrastAgent; // (0032,1070) >Requested Contrast Agent
CString m_strPreMedication; // (0040,0012) >Pre-Medication
public:
CObMwlStepItem();
virtual ~CObMwlStepItem();
};
typedef CTypedPtrArray<CObSQ, CObMwlStepItem*> CObMwlStepSQ;
class CObMwlManagement : public CObBasic
{
DECLARE_MEMBER_TABLE(CObMwlManagement)
public:
CString m_strCharacter; // (0008,0005) Specific Character Set
CObMwlStepSQ m_SQStep; // (0040,0100) Scheduled Procedure Step Sequence
CString m_strProcID; // (0040,1001) Requested Procedure ID
CString m_strProcReason; // (0040,1002) Reason for the Requested Procedure
CString m_strProcComments; // (0040,1400) Requested Procedure Comments
CObCodeSQ m_SQProcCode; // (0032,1064) Requested Procedure Code Sequence
CString m_strStudyInstUID; // (0020,000D) Study Instance UID
CObRefInstanceSQ m_SQStudyInstance; // (0008,1110) Referenced Study Sequence
CString m_strProcDesc; // (0032,1060) Requested Procedure Description
CString m_strProcPriority; // (0040,1003) Requested Procedure Priority
CString m_strTransport; // (0040,1004) Patient Transport Arrangements
CString m_strProcLocation; // (0040,1005) Requested Procedure Location
CString m_strConfidentiality; // (0040,1008) Confidentiality Code
CString m_strReportPriority; // (0040,1009) Reporting Priority
CString m_strRecipients; // (0040,1010) Names of Intended Recipients of Results
CString m_strSvcReason; // (0040,2001) Reason for the Imaging Service Request
CString m_strSvcComments; // (0040,2400) Imaging Service Request Comments
CString m_strRequester; // (0032,1032) Requesting Physician
CString m_strReferName; // (0008,0090) Referring Physician's Name
CString m_strService; // (0032,1033) Requesting Service
CString m_strAccessionNumber; // (0008,0050) Accession Number
CString m_strIssueDate; // (0040,2004) Issue Date of Imaging Service Request
CString m_strIssueTime; // (0040,2005) Issue Time of Imaging Service Request
CString m_strPlacerOrder; // (0040,2016) Placer Order Number / Imaging Service Request
CString m_strFillerOrder; // (0040,2017) Filler Order Number / Imaging Service Request
CString m_strEnterer; // (0040,2008) Order entered by ...
CString m_strEnterLocation; // (0040,2009) Order Enterer's Location
CString m_strEnterPhone; // (0040,2010) Order Callback Phone Number
CString m_strAdmissionID; // (0038,0010) Admission ID
CString m_strPatLocation; // (0038,0300) Current Patient Location
CObRefInstanceSQ m_SQPatientInstance; // (0008,1120) Referenced Patient Sequence
CString m_strPatientName; // (0010,0010) Patient's Name
CString m_strPatientID; // (0010,0020) Patient ID
CString m_strOtherPatientID; // (0010,1000) Other Patient IDs
CString m_strOtherPatientName; // (0010,1001) Other Patient Names
CString m_strPatientAge; // (0010,1010) Patient's Age
CString m_strPatientDOB; // (0010,0030) Patient's Birth Date
CString m_strPatientSex; // (0010,0040) Patient's Sex
CObLangCodeSQ m_SQLanguageCode; // (0010,0101) Patient's Primary Language Code Sequence
CString m_strPatWeight; // (0010,1030) Patient's Weight
CString m_strPatConfidentiality;// (0040,3001) Patient Data Confidentiality Constraint Description
CString m_strPatState; // (0038,0500) Patient State
Uint16 m_nPregnant; // (0010,21C0) Pregnancy Status
CString m_strMedAlert; // (0010,2000) Medical Alerts
CString m_strMedAllergy; // (0010,2110) Contrast Allergies
CString m_strSpecialNeed; // (0038,0050) Special Needs
public:
CObMwlManagement();
virtual ~CObMwlManagement();
};
class CObGpHumanItem : public CObBasic
{
DECLARE_MEMBER_TABLE(CObGpHumanItem)
public:
CObCodeSQ m_SQHumanCode; // (0040,4009) >Human Performer Code Sequence
CString m_strName; // (0040,4037) >Human Performer's Name
CString m_strOrganization; // (0040,4036) >Human Performer's Organization
public:
CObGpHumanItem();
virtual ~CObGpHumanItem();
};
typedef CTypedPtrArray<CObSQ, CObGpHumanItem*> CObGpHumanSQ;
class CObGpRequestItem : public CObBasic
{
DECLARE_MEMBER_TABLE(CObGpRequestItem)
public:
CString m_strStudyInstUID; // (0020,000D) >Study Instance UID
CObRefInstanceSQ m_SQStudyInstance; // (0008,1110) >Referenced Study Sequence
CString m_strAccessionNumber; // (0008,0050) >Accession Number
CObCodeSQ m_SQProcCode; // (0032,1064) >Requested Procedure Code Sequence
CString m_strPlacerOrder; // (0040,2016) >Placer Order Number / Imaging Service Request
CString m_strFillerOrder; // (0040,2017) >Filler Order Number / Imaging Service Request
CString m_strProcID; // (0040,1001) >Requested Procedure ID
CString m_strProcDesc; // (0032,1060) >Requested Procedure Description
CString m_strProcReason; // (0040,1002) >Reason for the Requested Procedure
CString m_strProcComments; // (0040,1400) >Requested Procedure Comments
CString m_strConfidentiality; // (0040,1008) >Confidentiality Code
CString m_strRecipients; // (0040,1010) >Names of Intended Recipients of Results
CString m_strSvcReason; // (0040,2001) >Reason for the Imaging Service Request
CString m_strSvcComments; // (0040,2400) >Imaging Service Request Comments
CString m_strRequester; // (0032,1032) >Requesting Physician
CString m_strService; // (0032,1033) >Requesting Service
CString m_strIssueDate; // (0040,2004) >Issue Date of Imaging Service Request
CString m_strIssueTime; // (0040,2005) >Issue Time of Imaging Service Request
CString m_strReferName; // (0008,0090) >Referring Physician's Name
public:
CObGpRequestItem();
virtual ~CObGpRequestItem();
};
typedef CTypedPtrArray<CObSQ, CObGpRequestItem*> CObGpRequestSQ;
class CObGpInfoItem : public CObBasic
{
DECLARE_MEMBER_TABLE(CObGpInfoItem)
public:
CString m_strStudyInstUID; // (0020,000D) >Study Instance UID
CObSeriesSQ m_SQReferencedSeries; // (0008,1115) >Referenced Series Sequence
public:
CObGpInfoItem();
virtual ~CObGpInfoItem();
};
typedef CTypedPtrArray<CObSQ, CObGpInfoItem*> CObGpInfoSQ;
class CObGpwlManagement : public CObBasic
{
DECLARE_MEMBER_TABLE(CObGpwlManagement)
public:
CString m_strCharacter; // (0008,0005) Specific Character Set
CString m_strSOPClassUID; // (0008,0016) SOP Class UID
CString m_strSOPInstanceUID; // (0008,0018) SOP Instance UID
CString m_strStepStatus; // (0040,4001) General Purpose Scheduled Procedure Step Status
CString m_strStepPriority; // (0040,4003) General Purpose Scheduled Procedure Step Priority
CString m_strStepID; // (0040,0009) Scheduled Procedure Step ID
CObCodeSQ m_SQApplicationCode; // (0040,4004) Scheduled Processing Applications Code Sequence
CObCodeSQ m_SQNameCode; // (0040,4025) Scheduled Station Name Code Sequence
CObCodeSQ m_SQClassCode; // (0040,4026) Scheduled Station Class Code Sequence
CObCodeSQ m_SQLocationCode; // (0040,4027) Scheduled Station Geographic Location Code Sequence
CObGpHumanSQ m_SQScheduledHuman; // (0040,4034) Scheduled Human Performers Sequence
CString m_strStartDateTime; // (0040,4005) Scheduled Procedure Step Start Date and Time
CString m_strEndDateTime; // (0040,4011) Expected Completion Date and Time
CObCodeSQ m_SQWorkItemCode; // (0040,4018) Scheduled Workitem Code Sequence
CString m_strStepComments; // (0040,0400) Comments on the Scheduled Procedure Step
CObRefInstanceSQ m_SQComponentInstance; // (0008,1111) Referenced Study Component Sequence
CString m_strAvailability; // (0040,4020) Input Availability Flag
CObGpInfoSQ m_SQInput; // (0040,4021) Input Information Sequence
CObGpInfoSQ m_SQRelevant; // (0040,4022) Relevant Information Sequence
CString m_strStudyInstUID; // (0020,000D) Study Instance UID
CString m_strMultipleCopies; // (0040,4006) Multiple Copies Flag
CObRefInstanceSQ m_SQGppsInstance; // (0040,4015) Resulting General Purpose Performed Procedure Steps Sequence
CObGpHumanSQ m_SQActualHuman; // (0040,4035) Actual Human Performers Sequence
CString m_strPatientName; // (0010,0010) Patient's Name
CString m_strPatientID; // (0010,0020) Patient ID
CString m_strPatientDOB; // (0010,0030) Patient's Birth Date
CString m_strPatientSex; // (0010,0040) Patient's Sex
CObGpRequestSQ m_SQGpwlRequest; // (0040,A370) Referenced Request Sequence
public:
CObGpwlManagement();
virtual ~CObGpwlManagement();
};
class CObGsps : public CObBasic
{
DECLARE_MEMBER_TABLE(CObGsps)
public:
CString m_strCharacter; // (0008,0005) Specific Character Set
CString m_strCreateDate; // (0008,0012) Instance Creation Date
CString m_strCreateTime; // (0008,0013) Instance Creation Time
CString m_strCreatorUID; // (0008,0014) Instance Creator UID
CString m_strTransactionUID; // (0008,1195) Transaction UID
CString m_strPatientName; // (0010,0010) Patient's Name
CString m_strPatientID; // (0010,0020) Patient ID
CString m_strPatientDOB; // (0010,0030) Patient's Birth Date
CString m_strPatientSex; // (0010,0040) Patient's Sex
CObGpRequestSQ m_SQGspsRequest; // (0040,A370) Referenced Request Sequence
CString m_strStepStatus; // (0040,4001) General Purpose Scheduled Procedure Step Status
CString m_strStepPriority; // (0040,4003) General Purpose Scheduled Procedure Step Priority
CString m_strStepID; // (0040,0009) Scheduled Procedure Step ID
CObCodeSQ m_SQApplicationCode; // (0040,4004) Scheduled Processing Applications Code Sequence
CObCodeSQ m_SQNameCode; // (0040,4025) Scheduled Station Name Code Sequence
CObCodeSQ m_SQClassCode; // (0040,4026) Scheduled Station Class Code Sequence
CObCodeSQ m_SQLocationCode; // (0040,4027) Scheduled Station Geographic Location Code Sequence
CObGpHumanSQ m_SQScheduledHuman; // (0040,4034) Scheduled Human Performers Sequence
CString m_strStartDateTime; // (0040,4005) Scheduled Procedure Step Start Date and Time
CString m_strEndDateTime; // (0040,4011) Expected Completion Date and Time
CObCodeSQ m_SQWorkItemCode; // (0040,4018) Scheduled Workitem Code Sequence
CString m_strStepComments; // (0040,0400) Comments on the Scheduled Procedure Step
CObRefInstanceSQ m_SQComponentInstance; // (0008,1111) Referenced Study Component Sequence
CString m_strAvailability; // (0040,4020) Input Availability Flag
CObGpInfoSQ m_SQInput; // (0040,4021) Input Information Sequence
CObGpInfoSQ m_SQRelevant; // (0040,4022) Relevant Information Sequence
CString m_strStudyInstUID; // (0020,000D) Study Instance UID
CString m_strMultipleCopies; // (0040,4006) Multiple Copies Flag
CObRefInstanceSQ m_SQGppsInstance; // (0040,4015) Resulting General Purpose Performed Procedure Steps Sequence
CObGpHumanSQ m_SQActualHuman; // (0040,4035) Actual Human Performers Sequence
public:
CObGsps();
virtual ~CObGsps();
};
class CObGspsItem : public CObBasic
{
DECLARE_MEMBER_TABLE(CObGspsItem)
public:
CString m_strSOPClassUID; // (0008,1150) >Referenced SOP Class UID
CString m_strSOPInstanceUID; // (0008,1155) >Referenced SOP Instance UID
CString m_strTransactionUID; // (0040,4023) >Referenced General Purpose Scheduled Procedure Step Transaction UID
public:
CObGspsItem();
virtual ~CObGspsItem();
};
typedef CTypedPtrArray<CObSQ, CObGspsItem*> CObGspsSQ;
class CObGpps : public CObBasic
{
DECLARE_MEMBER_TABLE(CObGpps)
public:
CString m_strCharacter; // (0008,0005) Specific Character Set
CString m_strCreateDate; // (0008,0012) Instance Creation Date
CString m_strCreateTime; // (0008,0013) Instance Creation Time
CString m_strCreatorUID; // (0008,0014) Instance Creator UID
CString m_strPatientName; // (0010,0010) Patient's Name
CString m_strPatientID; // (0010,0020) Patient ID
CString m_strPatientDOB; // (0010,0030) Patient's Birth Date
CString m_strPatientSex; // (0010,0040) Patient's Sex
CObGpRequestSQ m_SQGppsRequest; // (0040,A370) Referenced Request Sequence
CObGspsSQ m_SQGspsInstance; // (0040,4016) Referenced General Purpose Scheduled Procedure Step Sequence
CObGpHumanSQ m_SQActualHuman; // (0040,4035) Actual Human Performers Sequence
CObCodeSQ m_SQNameCode; // (0040,4028) Performed Station Name Code Sequence
CObCodeSQ m_SQClassCode; // (0040,4029) Performed Station Class Code Sequence
CObCodeSQ m_SQLocationCode; // (0040,4030) Performed Station Geographic Location Code Sequence
CObCodeSQ m_SQApplicationCode; // (0040,4007) Performed Processing Applications Code Sequence
CString m_strStartDate; // (0040,0244) Performed Procedure Step Start Date
CString m_strStartTime; // (0040,0245) Performed Procedure Step Start Time
CString m_strStepID; // (0040,0253) Performed Procedure Step ID
CString m_strEndDate; // (0040,0250) Performed Procedure Step End Date
CString m_strEndTime; // (0040,0251) Performed Procedure Step End Time
CString m_strStepStatus; // (0040,4002) General Purpose Performed Procedure Step Status
CString m_strStepDesc; // (0040,0254) Performed Procedure Step Description
CString m_strStepComments; // (0040,0280) Comments on the Performed Procedure Step
CObCodeSQ m_SQWorkitemCode; // (0040,4019) Performed Workitem Code Sequence
CObGpInfoSQ m_SQOutput; // (0040,4033) Output Information Sequence
CObCodeSQ m_SQSubWorkitemCode; // (0040,4031) Requested Subsequent Workitem Code Sequence
CObCodeSQ m_SQOutputCode; // (0040,4032) Non-DICOM Output Code Sequence
public:
CObGpps();
virtual ~CObGpps();
};
#endif // !defined(AFX_RISOBJECT_H__BFF71E48_3501_4119_8FE7_DC3389648A48__INCLUDED_)
|
60fb34077d59545a4cb17aa80f06cb36a044603a | 9608d6b322335b6a8dda8558c30349aecbfab03e | /Grid/threads/Pragmas.h | dfefc38a49f9498b7a9d0d9855533ed72572d493 | [] | no_license | vlkale/GridMini | 2d07c1a7939a428a5031a270609ff7b94b5eaca4 | 7a2925bb115e3d13f2c184c88d47d8c70c572513 | refs/heads/master | 2020-11-30T21:01:52.510035 | 2019-10-30T14:33:18 | 2019-10-30T14:33:18 | 230,478,503 | 0 | 0 | null | 2019-12-27T16:42:18 | 2019-12-27T16:42:18 | null | UTF-8 | C++ | false | false | 5,368 | h | Pragmas.h | /*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: ./lib/Threads.h
Copyright (C) 2015
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
Author: paboyle <paboyle@ph.ed.ac.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
See the full license in the file "LICENSE" in the top level distribution directory
*************************************************************************************/
/* END LEGAL */
#pragma once
#ifndef MAX
#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)>(y)?(y):(x))
#endif
#define strong_inline __attribute__((always_inline)) inline
#define UNROLL _Pragma("unroll")
//////////////////////////////////////////////////////////////////////////////////
// New primitives; explicit host thread calls, and accelerator data parallel calls
//////////////////////////////////////////////////////////////////////////////////
#ifdef _OPENMP
#define GRID_OMP
#include <omp.h>
#endif
#ifdef GRID_OMP
#define DO_PRAGMA_(x) _Pragma ("x")
#define DO_PRAGMA(x) DO_PRAGMA_(x)
#define thread_num(a) omp_get_thread_num()
#define thread_max(a) omp_get_max_threads()
#else
#define DO_PRAGMA_(x)
#define DO_PRAGMA(x)
#define thread_num(a) (0)
#define thread_max(a) (1)
#endif
#define naked_for(i,num,...) for ( uint64_t i=0;i<num;i++) { __VA_ARGS__ } ;
#define naked_foreach(i,container,...) for ( uint64_t i=container.begin();i<container.end();i++) { __VA_ARGS__ } ;
#define thread_for( i, num, ... ) DO_PRAGMA(omp parallel for schedule(static)) naked_for(i,num,{__VA_ARGS__});
#define thread_foreach( i, num, ... ) DO_PRAGMA(omp parallel for schedule(static)) naked_foreach(i,num,{__VA_ARGS__});
#define thread_for_in_region( i, num, ... ) DO_PRAGMA(omp for schedule(static)) naked_for(i,num,{__VA_ARGS__});
#define thread_for_collapse2( i, num, ... ) DO_PRAGMA(omp parallel for collapse(2)) naked_for(i,num,{__VA_ARGS__});
#define thread_for_collapse( N , i, num, ... ) DO_PRAGMA(omp parallel for collapse ( N ) ) naked_for(i,num,{__VA_ARGS__});
#define thread_for_collapse_in_region( N , i, num, ... ) DO_PRAGMA(omp for collapse ( N )) naked_for(i,num,{__VA_ARGS__});
#define thread_region DO_PRAGMA(omp parallel)
#define thread_critical DO_PRAGMA(omp critical)
//////////////////////////////////////////////////////////////////////////////////
// Accelerator primitives; fall back to threading
//////////////////////////////////////////////////////////////////////////////////
#ifdef __NVCC__
#define GRID_NVCC
#endif
#ifdef GRID_NVCC
extern uint32_t gpu_threads;
#define accelerator __host__ __device__
#define accelerator_inline __host__ __device__ inline
template<typename lambda> __global__
void LambdaApplySIMT(uint64_t Isites, uint64_t Osites, lambda Lambda)
{
uint64_t isite = threadIdx.y;
uint64_t osite = threadIdx.x+blockDim.x*blockIdx.x;
if ( (osite <Osites) && (isite<Isites) ) {
Lambda(isite,osite);
}
}
/////////////////////////////////////////////////////////////////
// Internal only really... but need to call when
/////////////////////////////////////////////////////////////////
#define accelerator_barrier(dummy) \
{ \
cudaDeviceSynchronize(); \
cudaError err = cudaGetLastError(); \
if ( cudaSuccess != err ) { \
printf("Cuda error %s \n", cudaGetErrorString( err )); \
puts(__FILE__); \
printf("Line %d\n",__LINE__); \
exit(0); \
} \
}
// Copy the for_each_n style ; Non-blocking variant
#define accelerator_forNB( iterator, num, nsimd, ... ) \
{ \
typedef uint64_t Iterator; \
auto lambda = [=] accelerator (Iterator lane,Iterator iterator) mutable { \
__VA_ARGS__; \
}; \
dim3 cu_threads(gpu_threads,nsimd); \
dim3 cu_blocks ((num+gpu_threads-1)/gpu_threads); \
LambdaApplySIMT<<<cu_blocks,cu_threads>>>(nsimd,num,lambda); \
}
// Copy the for_each_n style ; Non-blocking variant (default
#define accelerator_for( iterator, num, nsimd, ... ) \
accelerator_forNB(iterator, num, nsimd, { __VA_ARGS__ } ); \
accelerator_barrier(dummy);
#else
#define accelerator
#define accelerator_inline strong_inline
#define accelerator_for(iterator,num,nsimd, ... ) thread_for(iterator, num, { __VA_ARGS__ });
#define accelerator_forNB(iterator,num,nsimd, ... ) thread_for(iterator, num, { __VA_ARGS__ });
#define accelerator_barrier(dummy)
#endif
|
86bd0ae72dcea67b000566d38093d1adc215215d | fab6f199e628aaa2e5e06fb3d0c9a50ea60edbfc | /codes/216.combination-sum-iii.cpp | 74cf0108f14bf78748588994035e588555805958 | [] | no_license | sunmiaozju/leetcode | 76a389a0ef6b037a980749ca333d455480e5fa63 | a7e52930ed5467ca1e500b0af7847ade9b38f165 | refs/heads/master | 2020-07-21T18:49:43.843343 | 2020-06-25T15:47:58 | 2020-06-25T15:47:58 | 206,946,122 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,752 | cpp | 216.combination-sum-iii.cpp | /*
* @lc app=leetcode id=216 lang=cpp
*
* [216] Combination Sum III
*
* https://leetcode.com/problems/combination-sum-iii/description/
*
* algorithms
* Medium (52.92%)
* Likes: 819
* Dislikes: 45
* Total Accepted: 145.8K
* Total Submissions: 269.1K
* Testcase Example: '3\n7'
*
*
* Find all possible combinations of k numbers that add up to a number n, given
* that only numbers from 1 to 9 can be used and each combination should be a
* unique set of numbers.
*
* Note:
*
*
* All numbers will be positive integers.
* The solution set must not contain duplicate combinations.
*
*
* Example 1:
*
*
* Input: k = 3, n = 7
* Output: [[1,2,4]]
*
*
* Example 2:
*
*
* Input: k = 3, n = 9
* Output: [[1,2,6], [1,3,5], [2,3,4]]
*
*
*/
#include <iostream>
#include <vector>
using namespace std;
// @lc code=start
class Solution {
public:
vector<vector<int>> combinationSum3(int k, int n)
{
vector<vector<int>> ans;
vector<int> path;
int path_sum = 0;
help(ans, path, k, n, path_sum);
return ans;
}
void help(vector<vector<int>>& paths, vector<int>& path, int k, int n, int& path_sum)
{
if (path_sum > n) {
return;
}
if (path.size() == k) {
if (path_sum == n) {
paths.push_back(path);
}
return;
}
for (size_t i = 1; i <= 9; i++) {
if (!path.empty() && path[path.size() - 1] >= i) {
continue;
}
path.push_back(i);
path_sum += i;
help(paths, path, k, n, path_sum);
path_sum -= i;
path.pop_back();
}
}
};
// @lc code=end
|
c3c1ab9ff054c95617ee51f5fa0e5e1b7c56d175 | 100d31faf4b459bafe51a7f1cc3cbbe694011f91 | /examples/cpp/smart_ptr_aligned.cpp | 84ca78eb7ef27772ff3538574c50de9ee6474d79 | [
"CC0-1.0"
] | permissive | embeddedartistry/embedded-resources | aabbc962ab9354f773caadae5e3945e5c4e364bf | 1b25c30902fd34a69ed1001af741d564e8df0df1 | refs/heads/master | 2023-04-29T22:08:01.069233 | 2023-04-21T03:32:28 | 2023-04-21T16:25:23 | 76,132,197 | 569 | 412 | CC0-1.0 | 2023-04-21T16:25:24 | 2016-12-10T19:11:21 | Makefile | UTF-8 | C++ | false | false | 3,307 | cpp | smart_ptr_aligned.cpp | #include <memory>
#include <cstdio>
#include <cstdint>
#include <string>
#include "memory.h"
static void aligned_free_wrapper(void* ptr)
{
printf("Calling aligned_free on ptr: %p\n", ptr);
aligned_free(ptr);
}
/**
* Here we create aliases for our aligned pointer types.
* We are specifying that our alias has a fixed value: the deleter function type
* We use this for unique_ptr as it requires the type of the deleter in the declaration
*/
template<class T>
using unique_ptr_aligned = std::unique_ptr<T, decltype(&aligned_free)>;
/**
* We can create a template function that simplifies our declarations of aligned
* unique pointers. Alignment and size are passed through to aligned malloc, and
* aligned free is always used as the deleter. We then generate the correct pointer
* type based on the templated call
*/
template<class T>
unique_ptr_aligned<T> aligned_uptr(size_t align, size_t size)
{
return unique_ptr_aligned<T>(static_cast<T*>(aligned_malloc(align, size)),
&aligned_free_wrapper);
}
/**
* We can create a template function that simplifies our declarations of aligned
* shared pointers. Alignment and size are passed through to aligned malloc, and
* aligned free is always used as the deleter. We then generate the correct pointer
* type based on the templated call
*
* Notice here that the shared pointer doesn't need a special type due to the deleter
* The deleter type is only required for the unique pointer.
*/
template<class T>
std::shared_ptr<T> aligned_sptr(size_t align, size_t size)
{
return std::shared_ptr<T>(static_cast<T*>(aligned_malloc(align, size)), &aligned_free_wrapper);
}
int main(void)
{
/**
* Using our unique_ptr_aligned type, we declare an aligned uint8_t unique ptr.
* I use my wrapper function as the deleter to print values as things are getting freed
* Note that rather than calling new(uint8_t), we call aligned_malloc to get our aligned memory
*/
unique_ptr_aligned<uint8_t[]> x(static_cast<uint8_t*>(aligned_malloc(8, 1024)),
&aligned_free_wrapper);
/*
* Instead of the lengthy declaration above, we can use our templated
* aligned_uptr function for a much simpler declaration
*/
auto y = aligned_uptr<uint8_t>(32, 100);
/**
* Why don't we need a shared pointer to also have an alias?
* The deleter is not part of the type, simply the constructor
*/
std::shared_ptr<uint8_t> z(static_cast<uint8_t*>(aligned_malloc(32, 128)),
&aligned_free_wrapper);
/*
* Instead of the lengthy declaration above, we can use our templated
* aligned_sptr function for a much simpler declaration
*/
auto a = aligned_sptr<uint8_t>(64, 100);
printf("x (unique) has alignment 8: %p\n", x.get());
printf("y (unique) has alignment 32: %p\n", y.get());
printf("z (shared) has alignment 32: %p\n", z.get());
printf("a (shared) has alignment 64: %p\n", a.get());
/**
* This will cause the deleter to be called (aligned_free)
*/
printf("Freeing y pointer by reset()\n");
y.reset();
/*
* Since these pointers are allocated on the stack, they are bound by RAII
* Once we leave main() the pointers will go out of scope and the deleter we specified
* will be called automatically.
*/
printf("Leaving main. Remaining pointers will be automatically destructed\n");
return 0;
}
|
447592723ba3796295168ae8988706d996be35fb | f99bab361a5789c270f10fe17a70d11fda24ae92 | /pro_con/producer_consumer.cc | 4f48c527cc1396d81dea1b3730b82d54da90a897 | [] | no_license | cailun01/cpp_concurrency | 1901660cd8c348b069d62abab87c4075edcebf9d | 789fcab9139b52bcfddd971366e81f40c316e7e0 | refs/heads/master | 2020-05-14T15:11:10.338218 | 2019-04-23T12:33:50 | 2019-04-23T12:33:50 | 181,847,388 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,491 | cc | producer_consumer.cc | // https://segmentfault.com/a/1190000006703543
#include <iostream>
using std::cout; using std::endl;
#include <mutex>
using std::mutex; using std::lock_guard; using std::unique_lock;
#include <string>
using std::string;
#include <thread>
using std::thread; using std::this_thread::sleep_for;
#include <condition_variable>
using std::condition_variable;
#include <chrono>
#include <vector>
using std::vector;
#include <cstddef>
using std::size_t;
// 生产者 - 消费者(Producer-Consumer),也叫有限缓冲(Bounded-Buffer),是多线程同步的经典问题之一。
#define DISALLOW_COPY_AND_ASSIGN(ClassName) \
ClassName(const ClassName&) = delete; \
void operator=(const ClassName&) = delete;
// class BoundedBuffer {
struct BoundedBuffer {
public:
BoundedBuffer(size_t size)
: begin_(0), end_(0), buffered_(0), circular_buffer_(size) {}
void Produce(int n);
int Consume();
DISALLOW_COPY_AND_ASSIGN(BoundedBuffer);
// private:
size_t begin_;
size_t end_;
size_t buffered_;
// circular_buffer_;
// begin_ end_
// consume <- [int][int][int][int][int][int][int] <- produce
vector<int> circular_buffer_;
condition_variable not_full_cv_;
condition_variable not_empty_cv_;
mutex mutex_;
};
// cv.wait(lock, [] { return ready; }); 相当于:while (!ready) { cv.wait(lock); }。
void BoundedBuffer::Produce(int n) {
std::cout << "BoundedBuffer::Produce" << std::endl;
{
unique_lock<mutex> lock(mutex_);
// 缓冲区满,生产者等待
while (buffered_ >= circular_buffer_.size()) {
not_full_cv_.wait(lock);
} // 或not_full_cv_.wait(lock, [=]{ return buffered_ < circular_buffer_.size(); });
// 插入新的元素,更新下标
circular_buffer_[end_] = n;
for (auto c : circular_buffer_)
cout << "circular_buffer_ elements: " << c << endl;
// (end_ + 1) < circular_buffer_.size() 时,等号左边end_ = circular_buffer_.size()
// (end_ + 1) == circular_buffer_.size() 时,等号左边end_ = 0
// (end_ + 1) > circular_buffer_.size() 时,等号左边 = end_ + 1 - circular_buffer_.size()
// 注意,vector的下标[]不能添加元素
end_ = (end_ + 1) % circular_buffer_.size(); // % 取余数
std::cout << "end_: " << end_ << endl;
++buffered_;
} // 通知前,自动解锁。
// 通知消费者。
not_empty_cv_.notify_one();
}
int BoundedBuffer::Consume() {
std::cout << "BoundedBuffer::Consume" << std::endl;
unique_lock<mutex> lock(mutex_);
// 缓冲区为空时,消费者等待
while (buffered_ <= 0) {
not_empty_cv_.wait(lock);
} //或 not_empty_cv_.wait(lock, [=] { return buffered_ > 0; });
// 移除一个元素。
int n = circular_buffer_[begin_];
begin_ = (begin_ + 1) % circular_buffer_.size();
std::cout << "begin_: " << begin_ << endl;
--buffered_;
// 通知前,手动解锁。
lock.unlock();
// 通知生产者。
not_full_cv_.notify_one();
return n;
}
BoundedBuffer g_buffer(2);
mutex g_io_mutex;
// 生产 100000 个元素,每 10000 个打印一次。
void Producer() {
std::cout << "\t\tProducer" << std::endl;
int n = 0;
while (n < 3) {
g_buffer.Produce(n);
if ((n % 1) == 0) {
unique_lock<mutex> lock(g_io_mutex);
cout << "Produce: " << n << endl;
}
++n;
}
g_buffer.Produce(-1);
}
// 每消费到 10000 的倍数,打印一次。
void Consumer() {
std::cout << "\t\tConsumer" << std::endl;
std::thread::id thread_id = std::this_thread::get_id();
int n = 0;
do {
n = g_buffer.Consume();
if ((n % 1) == 0) {
unique_lock<mutex> lock(g_io_mutex);
cout << "Consume: " << n << " (" << thread_id << ")" << endl;
}
} while (n != -1); // -1 表示缓冲已达末尾。
// 往缓冲里再放一个 -1,这样其他消费者才能结束。
g_buffer.Produce(-1);
}
int main() {
vector<thread> threads;
cout << "main(), circular_buffer_.size(): " << g_buffer.circular_buffer_.size() << endl;
threads.push_back(thread(&Producer));
threads.push_back(thread(&Consumer));
// threads.push_back(thread(&Consumer));
// threads.push_back(thread(&Consumer));
for (auto& t : threads) {
t.join();
}
return 0;
} |
a27951b0701674458bc9393c86a165c7a69ee27a | e7e9930456e74ce09f0c81cc938c2ae639d241a5 | /architecture/p1232.cpp | 8ee63d986040ca17b47212c8b93ee72f04f037c3 | [] | no_license | jcyesc/assembly-language-computer-architecture | 46fda5f5ef3a7d91902baec834bd3411689d7707 | bb0ef69393a3b542a6d91026214293ba206b3f7c | refs/heads/master | 2020-06-04T05:07:08.557454 | 2019-06-14T06:05:17 | 2019-06-14T06:05:17 | 191,882,228 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 201 | cpp | p1232.cpp | #include <iostream>
using namespace std;
void f(int a[])
{
a[3] = 45;
}
void g(void)
{
int z[10];
int x = 5;
f(z);
cout << *(z+3) << endl;
}
int main(void)
{
g();
return 0;
}
|
a4b6c807d0775679082a138dc0153fdb9424482e | 9a9a34390f5479643d9d5afae4d59fc4101f5e18 | /Murga_Lab8/SkewHeap/SkewHeap.h | d8f419ec813a8c942111d0623d34ca0d87046ef0 | [] | no_license | danmur14/DataStructures560 | 9eab5aa918579bd745cb3b952d863e103119841d | 4a820f11bc9f93281e02e679d8c4cffad5e9b917 | refs/heads/master | 2021-01-23T21:16:03.348112 | 2017-09-08T17:38:42 | 2017-09-08T17:38:42 | 102,888,223 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,127 | h | SkewHeap.h | /*
* @file: SkewHeap.h
* @author: Daniel Murga
* @date: 2017.3.26
* @brief: Header file for SkewHeap.cpp
*/
#ifndef SkewHeap_h
#define SkewHeap_h
#include <fstream>
#include <iostream>
struct NodeS
{
//NodeS properties
int key;
struct NodeS *m_left;
struct NodeS *m_right;
//normal constructor not used
NodeS()
{
key = 0;
m_left = nullptr;
m_right = nullptr;
}
//used constructor with value
NodeS(int val)
{
key = val;
m_left = nullptr;
m_right = nullptr;
}
//destructor
~NodeS()
{
delete m_left;
delete m_right;
}
};
class SkewHeap
{
public:
SkewHeap(int size);
~SkewHeap();
void build(int data[], int size);
bool insert(int value);
bool deleteMin();
NodeS* merge(NodeS* H1, NodeS* H2);
void inOrder();
void preOrder();
void levelOrder();
private:
NodeS *m_root;
void preOrder(NodeS* cNode);
void inOrder(NodeS* cNode);
int height(NodeS* cNode);
void swapChildren(NodeS * H1);
void levelOrder(NodeS* cNode, int level);
};
#endif |
53f8645e5781978d8d0edb3d0965df1bfdfa8281 | 011194ceea8076561d0817c685f59e37ef5c7894 | /Source.cpp | f89419a35afb4b811382a266e59245f6f8f466c9 | [] | no_license | ramsesCastro/Student-gestion | 9b2b1a9abf571a54846cf282d8f352bb9b15a0c2 | 900431807dd7d2589d62600b195b05644d6f4701 | refs/heads/master | 2020-04-20T23:40:47.944872 | 2019-02-05T01:16:38 | 2019-02-05T01:16:38 | 169,174,677 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 163 | cpp | Source.cpp | #include <iostream>
using namespace std;
#include "Etudiant.h"
void main()
{
//creation dn objet
CEtudiant Etu;
cin >> Etu;
cout << Etu;
} |
5f8e255a0453dd1365987ceca1b1ffbdb496a06f | b776cbc6e9e7bffa49054a313611783f5a742321 | /materials/Metal.cpp | 9925fb48349b956078e7b942ac62d5bea83d50c8 | [] | no_license | Gagerdude/raytracer | 8ce17a1d780e51223b02e24e80fc508a1b1e6f73 | e9b886dc66301b3b7c99e10eed573b7737d989b1 | refs/heads/master | 2020-05-29T11:18:54.859417 | 2019-07-29T17:29:28 | 2019-07-29T17:29:28 | 189,111,953 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 570 | cpp | Metal.cpp | #include "Metal.h"
Metal::Metal(Texture* a, double f){
albedo = a;
if(f < 1){
fuzz = 1;
} else {
fuzz = f;
}
}
Metal::~Metal(){
delete albedo;
}
bool Metal::scatter(const Ray& ray_in, const hit_record& rec, vec3& attenuation, Ray& ray_scattered) const{
vec3 reflected = reflect(ray_in.direction(), rec.normal);
ray_scattered = Ray(rec.p, reflected + fuzz * vec3::random(), ray_in.time());
attenuation = albedo->value(rec.u, rec.v, rec.p);
return dot(ray_scattered.direction(), rec.normal) > 0;
} |
b8138dff273e9e2600110d4ff5f1eefa2150adcd | bdf09003695716725c98f28a79aa9c6a8c8a1b3d | /hybrid_lock/test1_hybrid.cpp | e36b29f42e9e2b216fc40d380c5494191322f60a | [] | no_license | crystal07/system_prog | 3c6f351b87ddc009bd1ad3c0c26738db62320910 | 8267edb60bfa29e02e2d6c137985c41598c012b3 | refs/heads/master | 2021-03-22T03:34:43.690839 | 2017-12-26T05:09:23 | 2017-12-26T05:09:23 | 110,926,493 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,400 | cpp | test1_hybrid.cpp | #include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <chrono>
#include <sys/time.h>
#include "hybrid_lock.h"
long g_count = 0;
pthread_mutex_t g_mutex;
hybrid_lock_t hybrid;
float while_time;
long long int while_count;
long long int get_count_while_per_sec() {
long long int i = 0;
std::mutex mtx_lock;
bool result = false;
auto start = std::chrono::high_resolution_clock::now();
auto end = std::chrono::high_resolution_clock::now();
while (((end - start).count() < 1000000000)) {
end = std::chrono::high_resolution_clock::now();
result = mtx_lock.try_lock();
i++;
}
return i;
}
void *thread_func(void *arg)
{
long i, count = (long)arg;
/*
* Increase the global variable, g_count.
* This code should be protected by
* some locks, e.g. spin lock, and the lock that
* you implemented for assignment,
* because g_count is shared by other threads.
*/
//pthread_mutex_lock(&g_mutex);
for (i = 0; i<count; i++) {
hybrid_lock_lock(&hybrid, while_count);
//pthread_mutex_unlock(&g_mutex);
//printf("%d thead : %d count\n", pthread_self(), g_count);
/************ Critical Section ************/
g_count++;
/******************************************/
hybrid_lock_unlock(&hybrid);
}
}
int main(int argc, char *argv[])
{
pthread_t *tid;
long i, thread_count, value, v;
int rc;
//while_time = get_while_time();
while_count = get_count_while_per_sec();
//printf("cout %d\n", count);
//scanf("%ld", &v);
/*
* Check that the program has three arguments
* If the number of arguments is not 3, terminate the process.
*/
if (3 != argc) {
fprintf(stderr, "usage: %s <thread count> <value>\n", argv[0]);
exit(0);
}
if (pthread_mutex_init(&g_mutex, NULL) != 0) {
fprintf(stderr, "g_mutex init error\n");
exit(-1);
}
if (hybrid_lock_init(&hybrid) != 0) {
fprintf(stderr, "hybrid init error\n");
exit(-1);
}
/*
* Get the values of the each arguments as a long type.
* It is better that use long type instead of int type,
* because sizeof(long) is same with sizeof(void*).
* It will be better when we pass argument to thread
* that will be created by this thread.
*/
thread_count = atol(argv[1]);
value = atol(argv[2]);
/*
* Create array to get tids of each threads that will
* be created by this thread.
*/
tid = (pthread_t*)malloc(sizeof(pthread_t)*thread_count);
if (!tid) {
fprintf(stderr, "malloc() error\n");
exit(0);
}
/*
* Create a threads by the thread_count value received as
* an argument. Each threads will increase g_count for
* value times.
*/
for (i = 0; i<thread_count; i++) {
rc = pthread_create(&tid[i], NULL, thread_func, (void*)value);
if (rc) {
fprintf(stderr, "pthread_create() error\n");
free(tid);
pthread_mutex_destroy(&g_mutex);
hybrid_lock_destroy(&hybrid);
exit(0);
}
}
/*
* Wait until all the threads you created above are finished.
*/
for (i = 0; i<thread_count; i++) {
rc = pthread_join(tid[i], NULL);
if (rc) {
fprintf(stderr, "pthread_join() error\n");
free(tid);
pthread_mutex_destroy(&g_mutex);
hybrid_lock_destroy(&hybrid);
exit(0);
}
}
pthread_mutex_destroy(&g_mutex);
hybrid_lock_destroy(&hybrid);
/*
* Print the value of g_count.
* It must be (thread_count * value)
*/
printf("value: %ld\n", g_count);
free(tid);
}
|
cf1add9610c7b4147f2b025a6348ef3fc7fbb6e5 | 6e608cfaa9316e777beac2f5aa51bb3fcc3120e5 | /qt/build-streamer-Desktop-Debug/ui_mainwindow_streamer.h | ee6e5c99e9587d613bf3bb8efc8cbdfe459e50d8 | [
"BSD-3-Clause"
] | permissive | ida-zrt/thermalvis | 9b18808c6c423096faf5dedca276d324339815a7 | 36a6ba0d12ab91097435630586e3eb760130582c | refs/heads/master | 2022-12-15T06:57:43.736121 | 2020-09-20T08:33:18 | 2020-09-20T08:33:18 | 297,032,390 | 0 | 0 | BSD-3-Clause | 2020-09-20T08:22:22 | 2020-09-20T08:22:21 | null | UTF-8 | C++ | false | false | 24,190 | h | ui_mainwindow_streamer.h | /********************************************************************************
** Form generated from reading UI file 'mainwindow_streamer.ui'
**
** Created by: Qt User Interface Compiler version 4.8.6
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_MAINWINDOW_STREAMER_H
#define UI_MAINWINDOW_STREAMER_H
#include <QVariant>
#include <QAction>
#include <QApplication>
#include <QButtonGroup>
#include <QCheckBox>
#include <QComboBox>
#include <QGroupBox>
#include <QHeaderView>
#include <QLabel>
#include <QLineEdit>
#include <QMainWindow>
#include <QMenuBar>
#include <QStatusBar>
#include <QToolBar>
#include <QWidget>
QT_BEGIN_NAMESPACE
class Ui_MainWindow_streamer
{
public:
QWidget *centralWidget;
QGroupBox *groupBox_Output;
QCheckBox *outputColor;
QCheckBox *output16bit;
QCheckBox *output8bit;
QGroupBox *groupBox_Scaling;
QLabel *minTemp_label;
QLabel *maxTemp_label;
QLineEdit *maxTemp;
QCheckBox *autoTemperature;
QLineEdit *minTemp;
QGroupBox *groupBox_Graylevel;
QLineEdit *zeroDegreesOffset;
QLabel *degreesPerGraylevel_label;
QLabel *desiredDegreesPerGraylevel_label;
QLineEdit *desiredDegreesPerGraylevel;
QLineEdit *degreesPerGraylevel;
QLabel *zeroDegreesOffset_label;
QGroupBox *groupBox_ImageProcessing;
QLineEdit *threshFactor;
QLabel *threshFactor_label;
QLineEdit *normFactor;
QLabel *fusionFactor_label;
QLabel *normFactor_label;
QLineEdit *fusionFactor;
QCheckBox *undistortImages;
QComboBox *denoisingMethod;
QLabel *denoising_label;
QLabel *normMode_label;
QComboBox *normMode;
QComboBox *mapCode;
QLabel *mapCode_label;
QGroupBox *groupBox_Frames;
QLineEdit *maxReadAttempts;
QLabel *framerate_label;
QLabel *maxReadAttempts_label;
QLineEdit *framerate;
QGroupBox *groupBox_Comms;
QLineEdit *serialPollingRate;
QLabel *serialPollingRate_label;
QLineEdit *maxNucInterval;
QLabel *maxNucThreshold_label;
QLineEdit *maxNucThreshold;
QLabel *maxNucInterval_label;
QGroupBox *groupBox_Input;
QComboBox *detectorMode;
QLabel *detectorMode_label;
QComboBox *inputDatatype;
QComboBox *usbMode;
QLabel *inputDatatype_label;
QLabel *usbMode_label;
QGroupBox *groupBox_Development;
QCheckBox *debugMode;
QCheckBox *verboseMode;
QMenuBar *menuBar;
QToolBar *mainToolBar;
QStatusBar *statusBar;
void setupUi(QMainWindow *MainWindow_streamer)
{
if (MainWindow_streamer->objectName().isEmpty())
MainWindow_streamer->setObjectName(QString::fromUtf8("MainWindow_streamer"));
MainWindow_streamer->resize(640, 320);
centralWidget = new QWidget(MainWindow_streamer);
centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
groupBox_Output = new QGroupBox(centralWidget);
groupBox_Output->setObjectName(QString::fromUtf8("groupBox_Output"));
groupBox_Output->setGeometry(QRect(200, 4, 71, 91));
outputColor = new QCheckBox(groupBox_Output);
outputColor->setObjectName(QString::fromUtf8("outputColor"));
outputColor->setGeometry(QRect(10, 68, 131, 17));
output16bit = new QCheckBox(groupBox_Output);
output16bit->setObjectName(QString::fromUtf8("output16bit"));
output16bit->setGeometry(QRect(10, 44, 121, 17));
output8bit = new QCheckBox(groupBox_Output);
output8bit->setObjectName(QString::fromUtf8("output8bit"));
output8bit->setGeometry(QRect(10, 20, 131, 17));
outputColor->raise();
output16bit->raise();
output8bit->raise();
groupBox_Scaling = new QGroupBox(centralWidget);
groupBox_Scaling->setObjectName(QString::fromUtf8("groupBox_Scaling"));
groupBox_Scaling->setGeometry(QRect(200, 194, 231, 71));
minTemp_label = new QLabel(groupBox_Scaling);
minTemp_label->setObjectName(QString::fromUtf8("minTemp_label"));
minTemp_label->setGeometry(QRect(-19, 41, 71, 20));
minTemp_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
maxTemp_label = new QLabel(groupBox_Scaling);
maxTemp_label->setObjectName(QString::fromUtf8("maxTemp_label"));
maxTemp_label->setGeometry(QRect(91, 41, 71, 20));
maxTemp_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
maxTemp = new QLineEdit(groupBox_Scaling);
maxTemp->setObjectName(QString::fromUtf8("maxTemp"));
maxTemp->setGeometry(QRect(171, 41, 41, 20));
autoTemperature = new QCheckBox(groupBox_Scaling);
autoTemperature->setObjectName(QString::fromUtf8("autoTemperature"));
autoTemperature->setGeometry(QRect(10, 21, 161, 17));
minTemp = new QLineEdit(groupBox_Scaling);
minTemp->setObjectName(QString::fromUtf8("minTemp"));
minTemp->setGeometry(QRect(61, 41, 41, 20));
groupBox_Graylevel = new QGroupBox(centralWidget);
groupBox_Graylevel->setObjectName(QString::fromUtf8("groupBox_Graylevel"));
groupBox_Graylevel->setGeometry(QRect(200, 100, 231, 91));
zeroDegreesOffset = new QLineEdit(groupBox_Graylevel);
zeroDegreesOffset->setObjectName(QString::fromUtf8("zeroDegreesOffset"));
zeroDegreesOffset->setGeometry(QRect(150, 64, 61, 20));
degreesPerGraylevel_label = new QLabel(groupBox_Graylevel);
degreesPerGraylevel_label->setObjectName(QString::fromUtf8("degreesPerGraylevel_label"));
degreesPerGraylevel_label->setGeometry(QRect(20, 14, 121, 20));
degreesPerGraylevel_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
desiredDegreesPerGraylevel_label = new QLabel(groupBox_Graylevel);
desiredDegreesPerGraylevel_label->setObjectName(QString::fromUtf8("desiredDegreesPerGraylevel_label"));
desiredDegreesPerGraylevel_label->setGeometry(QRect(0, 39, 141, 20));
desiredDegreesPerGraylevel_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
desiredDegreesPerGraylevel = new QLineEdit(groupBox_Graylevel);
desiredDegreesPerGraylevel->setObjectName(QString::fromUtf8("desiredDegreesPerGraylevel"));
desiredDegreesPerGraylevel->setGeometry(QRect(150, 39, 61, 20));
degreesPerGraylevel = new QLineEdit(groupBox_Graylevel);
degreesPerGraylevel->setObjectName(QString::fromUtf8("degreesPerGraylevel"));
degreesPerGraylevel->setGeometry(QRect(150, 14, 61, 20));
zeroDegreesOffset_label = new QLabel(groupBox_Graylevel);
zeroDegreesOffset_label->setObjectName(QString::fromUtf8("zeroDegreesOffset_label"));
zeroDegreesOffset_label->setGeometry(QRect(10, 64, 131, 20));
zeroDegreesOffset_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
groupBox_ImageProcessing = new QGroupBox(centralWidget);
groupBox_ImageProcessing->setObjectName(QString::fromUtf8("groupBox_ImageProcessing"));
groupBox_ImageProcessing->setGeometry(QRect(440, 4, 191, 261));
threshFactor = new QLineEdit(groupBox_ImageProcessing);
threshFactor->setObjectName(QString::fromUtf8("threshFactor"));
threshFactor->setGeometry(QRect(100, 70, 51, 20));
threshFactor_label = new QLabel(groupBox_ImageProcessing);
threshFactor_label->setObjectName(QString::fromUtf8("threshFactor_label"));
threshFactor_label->setGeometry(QRect(-10, 70, 101, 20));
threshFactor_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
normFactor = new QLineEdit(groupBox_ImageProcessing);
normFactor->setObjectName(QString::fromUtf8("normFactor"));
normFactor->setGeometry(QRect(100, 19, 51, 20));
fusionFactor_label = new QLabel(groupBox_ImageProcessing);
fusionFactor_label->setObjectName(QString::fromUtf8("fusionFactor_label"));
fusionFactor_label->setGeometry(QRect(-10, 44, 101, 20));
fusionFactor_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
normFactor_label = new QLabel(groupBox_ImageProcessing);
normFactor_label->setObjectName(QString::fromUtf8("normFactor_label"));
normFactor_label->setGeometry(QRect(-10, 19, 101, 20));
normFactor_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fusionFactor = new QLineEdit(groupBox_ImageProcessing);
fusionFactor->setObjectName(QString::fromUtf8("fusionFactor"));
fusionFactor->setGeometry(QRect(100, 44, 51, 20));
undistortImages = new QCheckBox(groupBox_ImageProcessing);
undistortImages->setObjectName(QString::fromUtf8("undistortImages"));
undistortImages->setGeometry(QRect(50, 100, 151, 17));
denoisingMethod = new QComboBox(groupBox_ImageProcessing);
denoisingMethod->setObjectName(QString::fromUtf8("denoisingMethod"));
denoisingMethod->setGeometry(QRect(70, 140, 111, 22));
denoising_label = new QLabel(groupBox_ImageProcessing);
denoising_label->setObjectName(QString::fromUtf8("denoising_label"));
denoising_label->setGeometry(QRect(10, 140, 51, 20));
denoising_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
normMode_label = new QLabel(groupBox_ImageProcessing);
normMode_label->setObjectName(QString::fromUtf8("normMode_label"));
normMode_label->setGeometry(QRect(40, 210, 81, 20));
normMode_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
normMode = new QComboBox(groupBox_ImageProcessing);
normMode->setObjectName(QString::fromUtf8("normMode"));
normMode->setGeometry(QRect(10, 230, 171, 22));
mapCode = new QComboBox(groupBox_ImageProcessing);
mapCode->setObjectName(QString::fromUtf8("mapCode"));
mapCode->setGeometry(QRect(70, 170, 111, 22));
mapCode_label = new QLabel(groupBox_ImageProcessing);
mapCode_label->setObjectName(QString::fromUtf8("mapCode_label"));
mapCode_label->setGeometry(QRect(-10, 170, 71, 20));
mapCode_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
groupBox_Frames = new QGroupBox(centralWidget);
groupBox_Frames->setObjectName(QString::fromUtf8("groupBox_Frames"));
groupBox_Frames->setGeometry(QRect(280, 4, 151, 91));
maxReadAttempts = new QLineEdit(groupBox_Frames);
maxReadAttempts->setObjectName(QString::fromUtf8("maxReadAttempts"));
maxReadAttempts->setGeometry(QRect(110, 50, 31, 20));
framerate_label = new QLabel(groupBox_Frames);
framerate_label->setObjectName(QString::fromUtf8("framerate_label"));
framerate_label->setGeometry(QRect(0, 20, 101, 20));
framerate_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
maxReadAttempts_label = new QLabel(groupBox_Frames);
maxReadAttempts_label->setObjectName(QString::fromUtf8("maxReadAttempts_label"));
maxReadAttempts_label->setGeometry(QRect(-30, 50, 131, 20));
maxReadAttempts_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
framerate = new QLineEdit(groupBox_Frames);
framerate->setObjectName(QString::fromUtf8("framerate"));
framerate->setGeometry(QRect(110, 20, 31, 20));
groupBox_Comms = new QGroupBox(centralWidget);
groupBox_Comms->setObjectName(QString::fromUtf8("groupBox_Comms"));
groupBox_Comms->setGeometry(QRect(10, 100, 181, 91));
serialPollingRate = new QLineEdit(groupBox_Comms);
serialPollingRate->setObjectName(QString::fromUtf8("serialPollingRate"));
serialPollingRate->setGeometry(QRect(109, 62, 51, 20));
serialPollingRate_label = new QLabel(groupBox_Comms);
serialPollingRate_label->setObjectName(QString::fromUtf8("serialPollingRate_label"));
serialPollingRate_label->setGeometry(QRect(10, 62, 91, 20));
serialPollingRate_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
maxNucInterval = new QLineEdit(groupBox_Comms);
maxNucInterval->setObjectName(QString::fromUtf8("maxNucInterval"));
maxNucInterval->setGeometry(QRect(109, 13, 51, 20));
maxNucThreshold_label = new QLabel(groupBox_Comms);
maxNucThreshold_label->setObjectName(QString::fromUtf8("maxNucThreshold_label"));
maxNucThreshold_label->setGeometry(QRect(10, 37, 91, 20));
maxNucThreshold_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
maxNucThreshold = new QLineEdit(groupBox_Comms);
maxNucThreshold->setObjectName(QString::fromUtf8("maxNucThreshold"));
maxNucThreshold->setGeometry(QRect(109, 37, 51, 20));
maxNucInterval_label = new QLabel(groupBox_Comms);
maxNucInterval_label->setObjectName(QString::fromUtf8("maxNucInterval_label"));
maxNucInterval_label->setGeometry(QRect(10, 13, 91, 20));
maxNucInterval_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
groupBox_Input = new QGroupBox(centralWidget);
groupBox_Input->setObjectName(QString::fromUtf8("groupBox_Input"));
groupBox_Input->setGeometry(QRect(10, 4, 181, 91));
detectorMode = new QComboBox(groupBox_Input);
detectorMode->setObjectName(QString::fromUtf8("detectorMode"));
detectorMode->setGeometry(QRect(89, 62, 81, 22));
detectorMode_label = new QLabel(groupBox_Input);
detectorMode_label->setObjectName(QString::fromUtf8("detectorMode_label"));
detectorMode_label->setGeometry(QRect(-21, 62, 101, 20));
detectorMode_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
inputDatatype = new QComboBox(groupBox_Input);
inputDatatype->setObjectName(QString::fromUtf8("inputDatatype"));
inputDatatype->setGeometry(QRect(89, 12, 81, 22));
usbMode = new QComboBox(groupBox_Input);
usbMode->setObjectName(QString::fromUtf8("usbMode"));
usbMode->setGeometry(QRect(89, 37, 81, 22));
inputDatatype_label = new QLabel(groupBox_Input);
inputDatatype_label->setObjectName(QString::fromUtf8("inputDatatype_label"));
inputDatatype_label->setGeometry(QRect(-21, 12, 101, 20));
inputDatatype_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
usbMode_label = new QLabel(groupBox_Input);
usbMode_label->setObjectName(QString::fromUtf8("usbMode_label"));
usbMode_label->setGeometry(QRect(9, 37, 71, 20));
usbMode_label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
groupBox_Development = new QGroupBox(centralWidget);
groupBox_Development->setObjectName(QString::fromUtf8("groupBox_Development"));
groupBox_Development->setGeometry(QRect(50, 200, 101, 61));
debugMode = new QCheckBox(groupBox_Development);
debugMode->setObjectName(QString::fromUtf8("debugMode"));
debugMode->setGeometry(QRect(10, 20, 91, 17));
verboseMode = new QCheckBox(groupBox_Development);
verboseMode->setObjectName(QString::fromUtf8("verboseMode"));
verboseMode->setGeometry(QRect(10, 40, 91, 17));
MainWindow_streamer->setCentralWidget(centralWidget);
groupBox_Output->raise();
groupBox_Scaling->raise();
groupBox_Graylevel->raise();
groupBox_ImageProcessing->raise();
groupBox_Frames->raise();
groupBox_Comms->raise();
groupBox_Input->raise();
groupBox_Development->raise();
debugMode->raise();
menuBar = new QMenuBar(MainWindow_streamer);
menuBar->setObjectName(QString::fromUtf8("menuBar"));
menuBar->setGeometry(QRect(0, 0, 640, 21));
MainWindow_streamer->setMenuBar(menuBar);
mainToolBar = new QToolBar(MainWindow_streamer);
mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
MainWindow_streamer->addToolBar(Qt::TopToolBarArea, mainToolBar);
statusBar = new QStatusBar(MainWindow_streamer);
statusBar->setObjectName(QString::fromUtf8("statusBar"));
MainWindow_streamer->setStatusBar(statusBar);
retranslateUi(MainWindow_streamer);
denoisingMethod->setCurrentIndex(0);
normMode->setCurrentIndex(3);
mapCode->setCurrentIndex(7);
detectorMode->setCurrentIndex(2);
inputDatatype->setCurrentIndex(1);
usbMode->setCurrentIndex(0);
QMetaObject::connectSlotsByName(MainWindow_streamer);
} // setupUi
void retranslateUi(QMainWindow *MainWindow_streamer)
{
MainWindow_streamer->setWindowTitle(QApplication::translate("MainWindow_streamer", "MainWindow_streamer", 0));
groupBox_Output->setTitle(QApplication::translate("MainWindow_streamer", "Output", 0));
outputColor->setText(QApplication::translate("MainWindow_streamer", "Color", 0));
output16bit->setText(QApplication::translate("MainWindow_streamer", "16-bit", 0));
output8bit->setText(QApplication::translate("MainWindow_streamer", "8-bit", 0));
groupBox_Scaling->setTitle(QApplication::translate("MainWindow_streamer", "Temperature Scaling", 0));
minTemp_label->setText(QApplication::translate("MainWindow_streamer", "minTemp", 0));
maxTemp_label->setText(QApplication::translate("MainWindow_streamer", "maxTemp", 0));
maxTemp->setText(QString());
autoTemperature->setText(QApplication::translate("MainWindow_streamer", "autoTemperature", 0));
minTemp->setText(QString());
groupBox_Graylevel->setTitle(QApplication::translate("MainWindow_streamer", "Graylevel Scaling", 0));
zeroDegreesOffset->setText(QString());
degreesPerGraylevel_label->setText(QApplication::translate("MainWindow_streamer", "degreesPerGraylevel", 0));
desiredDegreesPerGraylevel_label->setText(QApplication::translate("MainWindow_streamer", "desiredDegreesPerGraylevel", 0));
desiredDegreesPerGraylevel->setText(QString());
degreesPerGraylevel->setText(QString());
zeroDegreesOffset_label->setText(QApplication::translate("MainWindow_streamer", "zeroDegreesOffset", 0));
groupBox_ImageProcessing->setTitle(QApplication::translate("MainWindow_streamer", "Image Processing", 0));
threshFactor->setText(QString());
threshFactor_label->setText(QApplication::translate("MainWindow_streamer", "threshFactor", 0));
normFactor->setText(QString());
fusionFactor_label->setText(QApplication::translate("MainWindow_streamer", "fusionFactor", 0));
normFactor_label->setText(QApplication::translate("MainWindow_streamer", "normFactor", 0));
fusionFactor->setText(QString());
undistortImages->setText(QApplication::translate("MainWindow_streamer", "undistortImages", 0));
denoisingMethod->clear();
denoisingMethod->insertItems(0, QStringList()
<< QApplication::translate("MainWindow_streamer", "NONE", 0)
<< QApplication::translate("MainWindow_streamer", "METHOD X", 0)
);
denoisingMethod->setCurrentIndex(0);
denoising_label->setText(QApplication::translate("MainWindow_streamer", "Denoising", 0));
normMode_label->setText(QApplication::translate("MainWindow_streamer", "normMode", 0));
normMode->clear();
normMode->insertItems(0, QStringList()
<< QApplication::translate("MainWindow_streamer", "FULL_STRETCHING", 0)
<< QApplication::translate("MainWindow_streamer", "EQUALIZATION", 0)
<< QApplication::translate("MainWindow_streamer", "CENTRALIZED", 0)
<< QApplication::translate("MainWindow_streamer", "FIXED_TEMP_RANGE", 0)
<< QApplication::translate("MainWindow_streamer", "FIXED_TEMP_LIMITS", 0)
);
normMode->setCurrentIndex(0);
mapCode->clear();
mapCode->insertItems(0, QStringList()
<< QApplication::translate("MainWindow_streamer", "GRAYSCALE", 0)
<< QApplication::translate("MainWindow_streamer", "CIECOMP", 0)
<< QApplication::translate("MainWindow_streamer", "BLACKBODY", 0)
<< QApplication::translate("MainWindow_streamer", "RAINBOW", 0)
<< QApplication::translate("MainWindow_streamer", "IRON", 0)
<< QApplication::translate("MainWindow_streamer", "BLUERED", 0)
<< QApplication::translate("MainWindow_streamer", "JET", 0)
<< QApplication::translate("MainWindow_streamer", "CIELUV", 0)
<< QApplication::translate("MainWindow_streamer", "ICEIRON", 0)
<< QApplication::translate("MainWindow_streamer", "ICEFIRE", 0)
<< QApplication::translate("MainWindow_streamer", "REPEATED", 0)
<< QApplication::translate("MainWindow_streamer", "HIGHLIGHTED", 0)
);
mapCode->setCurrentIndex(0);
mapCode_label->setText(QApplication::translate("MainWindow_streamer", "mapCode", 0));
groupBox_Frames->setTitle(QApplication::translate("MainWindow_streamer", "Frame Processing", 0));
maxReadAttempts->setText(QString());
framerate_label->setText(QApplication::translate("MainWindow_streamer", "framerate", 0));
maxReadAttempts_label->setText(QApplication::translate("MainWindow_streamer", "maxReadAttempts", 0));
framerate->setText(QString());
groupBox_Comms->setTitle(QApplication::translate("MainWindow_streamer", "Serial Comms", 0));
serialPollingRate->setText(QString());
serialPollingRate_label->setText(QApplication::translate("MainWindow_streamer", "serialPollingRate", 0));
maxNucInterval->setText(QString());
maxNucThreshold_label->setText(QApplication::translate("MainWindow_streamer", "maxNucThreshold", 0));
maxNucThreshold->setText(QString());
maxNucInterval_label->setText(QApplication::translate("MainWindow_streamer", "maxNucInterval", 0));
groupBox_Input->setTitle(QApplication::translate("MainWindow_streamer", "Input", 0));
detectorMode->clear();
detectorMode->insertItems(0, QStringList()
<< QApplication::translate("MainWindow_streamer", "RAW", 0)
<< QApplication::translate("MainWindow_streamer", "LUM", 0)
<< QApplication::translate("MainWindow_streamer", "INS", 0)
<< QApplication::translate("MainWindow_streamer", "RAD", 0)
<< QApplication::translate("MainWindow_streamer", "TMP", 0)
);
detectorMode->setCurrentIndex(0);
detectorMode_label->setText(QApplication::translate("MainWindow_streamer", "detectorMode", 0));
inputDatatype->clear();
inputDatatype->insertItems(0, QStringList()
<< QApplication::translate("MainWindow_streamer", "8BIT", 0)
<< QApplication::translate("MainWindow_streamer", "RAW", 0)
<< QApplication::translate("MainWindow_streamer", "MULTIMODAL", 0)
<< QApplication::translate("MainWindow_streamer", "DEPTH", 0)
);
inputDatatype->setCurrentIndex(0);
usbMode->clear();
usbMode->insertItems(0, QStringList()
<< QApplication::translate("MainWindow_streamer", "USB_16", 0)
<< QApplication::translate("MainWindow_streamer", "USB_8", 0)
);
usbMode->setCurrentIndex(0);
inputDatatype_label->setText(QApplication::translate("MainWindow_streamer", "inputDatatype", 0));
usbMode_label->setText(QApplication::translate("MainWindow_streamer", "usbMode", 0));
groupBox_Development->setTitle(QApplication::translate("MainWindow_streamer", "Development", 0));
debugMode->setText(QApplication::translate("MainWindow_streamer", "debugMode", 0));
verboseMode->setText(QApplication::translate("MainWindow_streamer", "verboseMode", 0));
} // retranslateUi
};
namespace Ui {
class MainWindow_streamer: public Ui_MainWindow_streamer {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MAINWINDOW_STREAMER_H
|
553f9ebd7df0ac7177e1f129a5d61ddb4e92776f | c3c2d6cb7077a18b9e354cafbf3c23ef870c7b3a | /position.cpp | 52db353ae710254a865c0f6db575a5279817a8bc | [] | no_license | YuriiHrushko/TestTranslator--LexicalAnalyzer- | be0d23e827843fc5561ebfab6da129811e92218f | 93fee05c6e331d69b6e211009e48110ee492e088 | refs/heads/master | 2021-01-23T08:21:21.146658 | 2017-03-28T20:50:17 | 2017-03-28T20:50:17 | 86,505,458 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 435 | cpp | position.cpp | #include "position.h"
Position::Position(int Pos, int Line){
this->currentPos = Pos;
this->currentLine = Line;
}
void Position::nextLine(){
currentPos = 0;
++currentLine;
}
void Position::nextPos(){
++currentPos;
}
int Position::getLine(){
return currentLine;
}
int Position::getPos(){
return currentPos;
}
QString Position::toString(){
return QString("%1 %2").arg(currentLine).arg(currentPos);
}
|
837dde1be2d4ed087431f31ed6f602eda587ea28 | 9dacf653d3f285ac31ab636fd6a7f08146b1dac9 | /SkyneyHK-Aerial/SkyneyHK-Aerial/SkyneyHK-Aerial.cpp | f6a7920b93abe8e2f0d81b58e9f6bf793bc8a4ba | [] | no_license | zzzzzz2468/SkynetHK-Aerial | da3242a700c3db02c17e1649e01317bf093b72c3 | f424abaaf45ed0e8da0b5204b70f5147d1350221 | refs/heads/master | 2022-12-23T14:43:51.820432 | 2020-09-27T11:54:15 | 2020-09-27T11:54:15 | 299,010,038 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,783 | cpp | SkyneyHK-Aerial.cpp | #include <iostream>
#include <stdlib.h> //Including srand and rand
#include <time.h> //Including time
using namespace std;
int main()
{
//Initializing different variables that the code needs
int prediction = 0, gridHighNum = 0, gridLowNum = 0, totGrid = 0, totPings = 0, enemyPos;
//For loop that creates the grid, first loop being row, second being col, this is more for if we later show off the grid
for (int row = 0; row < 8; row++)
{
for (int col = 0; col < 8; col++)
{
totGrid++;
//cout << " " << row << "," << col << " ";
}
//cout << endl;
}
//Initilizes seed value and then calls a random number
srand(time(NULL));
enemyPos = rand() % (totGrid + 1);
//Intro code that provides info
cout << "Generating enemy location on 8x8 grid...\n";
cout << "Enemy is located at sector #" << enemyPos << "\n";
cout << "Skynet HK-Aerial Initializing software...\n";
cout << "============================================\n";
//Sets low and high numbers
gridLowNum = 0;
gridHighNum = totGrid;
//checks if prediction is not equal to enemy position, and runs code if the it is still trying to get them to match
while (prediction != enemyPos)
{
//changes prediction based of other variables
prediction = ((gridHighNum - gridLowNum) / 2) + gridLowNum;
//tells user number of pings
cout << "Skynet HK-Aerial Radar sending out ping " << (totPings + 1) << "\n";
if (prediction < enemyPos)
{
//if the prediction was to low, changes the lownum and gives user info
gridLowNum = prediction + 1;
cout << "The target location of " << prediction << " was lower than the enemy\n";
cout << "The new low number is = " << gridLowNum;
}
else if (prediction > enemyPos)
{
//if the prediction was to high, changes the highnum and gives user info
gridHighNum = prediction - 1;
cout << "The target location of " << prediction << " was higher than the enemy\n";
cout << "The new high number is = " << gridHighNum;
}
else
{
//if the prediction was right, gives the user information that they did, also breaks out of code because while is no longer true
cout << "The enemy was hiding at sector #" << prediction << "\n";
cout << "Skynet HK-Aerial Software took " << (totPings + 1) << " predictions to find the enemy";
}
//adds barriers between pings
cout << "\n============================================\n";
//adds 1 to the number of pings
totPings++;
}
//ends the program
return 0;
} |
26b1c359f1fbf8460d8fb801db3f3f30291ca61e | 2b23787a70cf8c2ccb3b3987976c48c9cb826d49 | /src/ofApp.h | 243a441332b6eeb1f5bbf1a3d4b6fb8397a3148c | [] | no_license | edap/karaoke-keyboards | 4536809e3fe58ff979da3312f75680dfa6a0b96c | 7eb6f55958c2b6198d1bd442bc7ff6927cf9b5a0 | refs/heads/master | 2021-01-19T13:01:07.522200 | 2015-10-14T20:37:44 | 2015-10-14T20:37:44 | 42,768,455 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 942 | h | ofApp.h | #pragma once
#include "ofMain.h"
#include "Player.h"
#include "Lyric.h"
#include "Score.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void startSongFromBeginning();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseEntered(int x, int y);
void mouseExited(int x, int y);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
ofColor colorTextToType;
ofColor colorTextTyped;
ofColor colorBgGradientFirst;
ofColor colorBgGradientSecond;
Player player;
Lyric lyric;
Score score;
ofTrueTypeFont font;
};
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.