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
3fb96ac477892d1df91d66c0438813006d0e0628
0d1b5db4da112ca12f236b6ca33a30b50fd7c839
/OpenGLStudy/Engine/Graphics/EnvironmentCaptureManager.h
16e358e8eff43f23251260afd0af1984475dccff
[]
no_license
BosonHBC/GraphicsEngine_OpenGL
fd8f86f764a17a74432f6b1f2823e5dd01d34067
a59c8564a3e9b17d986374b769f8bc50251d9353
refs/heads/master
2020-11-24T09:49:02.829849
2020-10-04T23:13:56
2020-10-04T23:13:56
228,088,171
6
1
null
2020-10-04T23:13:57
2019-12-14T20:59:47
C++
UTF-8
C++
false
false
2,765
h
EnvironmentCaptureManager.h
#pragma once #include "Graphics/EnvironmentProbes/EnvProbe.h" #include "Math/Shape/Sphere.h" namespace Graphics { // Forward declaration struct sDataRequiredToRenderAFrame; namespace EnvironmentCaptureManager { struct sCaptureProbes { cEnvProbe EnvironmentProbe; // Environment probe, it capture the very detail version of the environment, by rendering the whole scene(actual geometries) 6 times. cEnvProbe IrradianceProbe; // Storing the irradiance map for ambient lighting, by rendering a cube map to a cube and convolute it with special fragment shader cEnvProbe PrefilterProbe; // pre-filtering cube map for environment reflection cSphere BV; // The bounding volume of this probe, should not change after initialization; cSphere InnerBV; // If a sphere is inside the inner sphere, this weight should be 1 float Influence; // 1 at the inner boundary; 0 at the outer boundary; > 1 inside the inner boundary. < 0, outside the outer boundary GLuint Resolution; // Resolution of Environment cubemap(each size) sCaptureProbes() {} ~sCaptureProbes() {} sCaptureProbes(const cSphere& i_sphere, const cSphere& i_innerSphere, float i_influence, GLuint i_resolution) : BV(i_sphere), InnerBV(i_innerSphere), Influence(i_influence), Resolution(i_resolution) { } sCaptureProbes(const sCaptureProbes& i_other) = default; sCaptureProbes& operator = (const sCaptureProbes& i_other) = default; bool operator < (const sCaptureProbes& i_other) { return (*this).Influence < i_other.Influence; } void CleanUp() { EnvironmentProbe.CleanUp(); IrradianceProbe.CleanUp(); PrefilterProbe.CleanUp(); } // 1 at the inner boundary; 0 at the outer boundary; > 1 inside the inner boundary. < 0, outside the outer boundary void CalcInfluenceWeight(const glm::vec3& i_POI) { float dist2center = glm::distance(i_POI, BV.c()); Influence = 1 - (dist2center - InnerBV.r()) / (BV.r() - InnerBV.r()); } }; // Initialization and clean up bool Initialize(); bool CleanUp(); bool AddCaptureProbes(const cSphere& i_outerSphere, float i_innerRadius, GLuint i_environmentCubemapSize); // Pre-render frame, after adding all capture probes, start to capture void CaptureEnvironment(Graphics::sDataRequiredToRenderAFrame* i_renderThreadData); // During rendering, update the weights according to the point of interest void UpdatePointOfInterest(const glm::vec3& i_position); // After adding all capture probes, build the octTree void BuildAccelerationStructure(); const std::vector<sCaptureProbes*>& GetCapturesReferences(); const sCaptureProbes& GetCaptureProbesAt(int i_idx); GLuint GetReadyCapturesCount(); const GLuint MaximumCubemapMixingCount(); } }
975a609f5d4ce31d125a0072211dd1d3efe6b01e
9493f455c8e28a660b559deb3ecb06f679e40f25
/ChainFunctor.cpp
0ecb5d012fd706b09d478a5c7ba9024382e49e90
[]
no_license
davidkazlauskas/tests-templatious
ccb2994df6a52ac2a3b8629d834f6b73b0e85654
b73bd631d4ce5fee888bcc0fe541560fe5279394
refs/heads/master
2021-01-10T21:18:24.531408
2015-09-08T17:03:36
2015-09-08T17:03:36
35,752,387
0
0
null
null
null
null
UTF-8
C++
false
false
6,225
cpp
ChainFunctor.cpp
/* * ===================================================================================== * * Filename: ChainFunctor.hpp * * Description: Chain functor tests * * Version: 1.0 * Created: 10/21/2014 07:54:38 PM * Revision: none * Compiler: gcc * * Author: David Kazlauskas (dk), david@templatious.org * * ===================================================================================== */ #include <cstring> #include <string> #include "TestDefs.hpp" namespace roost { void replace_all(std::string& str,const char* find,const char* repl) { int lena = strlen(find); int lenb = strlen(repl); size_t pos = str.find(find); while (std::string::npos != pos) { str.replace(pos,lena,repl); pos = str.find(find); } } std::string replace_all_copy(const std::string& str,const char* find,const char* repl) { std::string val(str); replace_all(val,find,repl); return val; } template <class T> std::string to_upper_copy(const T& str,const std::locale& loc) { std::string ret(str); for (auto i = ret.begin(); i != ret.end(); ++i) { *i = std::toupper(*i,loc); } return ret; } } std::string profanityFilter(const std::string& s) { std::string mutant = s; roost::replace_all(mutant,"shizzle","*******"); roost::replace_all(mutant,"drizzle","*******"); roost::replace_all(mutant,"SHIZZLE","*******"); roost::replace_all(mutant,"DRIZZLE","*******"); return mutant; } TEST_CASE( "chain_functor_string_filter", "[chain_functor]" ) { std::string str = "What I'm I doing? Don't shizzle my drizzle yo."; auto underSqr = [](std::string s) { return roost::replace_all_copy(s," ","_"); }; auto func = SF::chainFunctor( roost::to_upper_copy<std::string>, profanityFilter, underSqr); // unfortunately, if template function has // default argument we HAVE to pass it // or it won't compile. std::string res = func(str,std::locale()); REQUIRE( res == "WHAT_I'M_I_DOING?_DON'T_*******_MY_*******_YO." ); } namespace { // STATEFUL auto mulDo = [](int& a) { a = a * 7; }; auto mulUndo = [](int& a) { a = a / 7; }; auto addDo = [](int& a) { a = a + 7; }; auto addUndo = [](int& a) { a = a - 7; }; auto mulDo2 = [](int& a) { a = a * 17; }; auto mulUndo2 = [](int& a) { a = a / 17; }; auto addDo2 = [](int& a) { a = a + 17; }; auto addUndo2 = [](int& a) { a = a - 17; }; // FUNCTIONAL auto mulDoF = [](int a) { return a * 7; }; auto mulUndoF = [](int a) { return a / 7; }; auto addDoF = [](int a) { return a + 7; }; auto addUndoF = [](int a) { return a - 7; }; auto mulDo2F = [](int a) { return a * 17; }; auto mulUndo2F = [](int a) { return a / 17; }; auto addDo2F = [](int a) { return a + 17; }; auto addUndo2F = [](int a) { return a - 17; }; auto fF = SF::chainFunctor( SF::functorPair(mulDoF,mulUndoF), SF::functorPair(addDoF,addUndoF), SF::functorPair(mulDo2F,mulUndo2F), SF::functorPair(addDo2F,addUndo2F) ); auto fS = SF::chainFunctor<true>( SF::functorPair(mulDo,mulUndo), SF::functorPair(addDo,addUndo), SF::functorPair(mulDo2,mulUndo2), SF::functorPair(addDo2,addUndo2) ); } TEST_CASE( "chain_functor_math_reverse_functional", "[chain_functor]" ) { int inter = fF(7); REQUIRE(inter == 969); int back = fF.doBwd(inter); REQUIRE(back == 7); } TEST_CASE( "chain_functor_math_reverse_stateful", "[chain_functor]" ) { int curr = 7; fS(curr); REQUIRE(curr == 969); fS.doBwd(curr); REQUIRE(curr == 7); } TEST_CASE( "chain_functor_math_invert_functional", "[chain_functor]" ) { auto rv = fF.reverse(); int curr = rv.doBwd(7); REQUIRE(curr == 969); int back = rv(curr); REQUIRE(back == 7); } TEST_CASE( "chain_functor_math_invert_stateful", "[chain_functor]" ) { auto rv = fS.reverse(); int curr = 7; rv.doBwd(curr); REQUIRE(curr == 969); rv(curr); REQUIRE(curr == 7); } TEST_CASE( "chain_functor_math_get_do_undo_functional", "[chain_functor]" ) { auto d = fF.getDo(); auto u = fF.getUndo(); int curr = d(7); REQUIRE(curr == 969); int back = u(curr); REQUIRE(back == 7); } TEST_CASE( "chain_functor_math_get_do_undo_stateful", "[chain_functor]" ) { auto d = fS.getDo(); auto u = fS.getUndo(); int curr = 7; d(curr); REQUIRE(curr == 969); u(curr); REQUIRE(curr == 7); } namespace { struct SomeData { SomeData(int a,double b,char c) : _a(a), _b(b), _c(c) {} int _a; double _b; char _c; bool operator==(const SomeData& s) const { return s._a == _a && s._b == _b && s._c == _c; } }; auto encryptF = [](const std::vector<char>& v) { std::vector<char> vn; SA::addCustom(vn, [](char c) { return c ^ '7'; }, v ); return vn; }; auto turnToBytesF = [](const SomeData& d) { std::vector<char> res; const int sz = sizeof(SomeData); char tmp[sz]; memcpy(tmp,&d,sz); SA::add(res,tmp); return res; }; auto makeFromBytesF = [](const std::vector<char>& v) { const int sz = sizeof(SomeData); char tmp[sz]; SM::distribute(v,tmp); SomeData* ptr = reinterpret_cast<SomeData*>(tmp); return SomeData(*ptr); }; auto sdFctor = SF::chainFunctor( SF::functorPair(turnToBytesF,makeFromBytesF), SF::functorPair(encryptF,encryptF) ); // PR UTIL auto prnt = SF::streamOutFunctor(std::cout); auto prSomeData = [](const SomeData& s) { SM::callEach(prnt, "_a: ",s._a,", _b: ",s._b,", _c: ",s._c,"\n"); }; auto prAny = SF::matchFunctor( SF::matchLoose<SomeData>(prSomeData), SF::matchAny(prnt) ); } TEST_CASE( "chain_functor_serialize_and_deserialize", "[chain_functor]" ) { SomeData d(7,7.777,'7'); auto gargle = sdFctor(d); auto back = sdFctor.doBwd(gargle); REQUIRE( back == d ); }
5402aa860dbb425c2a4ea9701a3d018a0de651a6
8df198126a11543066c64a98a9d5ee24c7fa7618
/(((... All online judge practice and contest ...)))/@Codeforces/CF 341B.cpp
c03482970893148860d846142c3e7628219afc6b
[]
no_license
mehadi-trackrep/ACM_Programming_related
eef0933febf44e3b024bc45afb3195b854eba719
7303931aa9f2ab68d76bbe04b06157b00ac9f6a6
refs/heads/master
2021-10-09T03:15:09.188172
2018-12-20T09:35:22
2018-12-20T09:35:22
117,265,703
0
0
null
null
null
null
UTF-8
C++
false
false
767
cpp
CF 341B.cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; #define INF 1e9 #define FOR(i, a, b) for(int i=int(a); i<int(b); i++) #define FORC(cont, it) for(decltype((cont).begin()) it = (cont).begin(); it != (cont).end(); it++) #define pb push_back #define MAXN 100000 //x1 + y1 == x2 + y2 //x1 - y1 == x2 - y2 int main() { int n; map<ll, ll> m1, m2; cin >> n; FOR(i, 0, n) { int x, y; scanf("%d %d", &x, &y); m1[x+y]++; m2[x-y]++; } ll ans = 0; for (auto it : m1) { ans += it.second * (it.second - 1) / 2; } for (auto it : m2) { ans += it.second * (it.second - 1) / 2; } cout << ans << endl; return 0; }
4ce5b41c3cefa688dd2c4bf49ec1e03572ca1594
1bdccbe765fd32947c4434c2293f77484782ae58
/src/PlayerState.cpp
b5c2eeba107edc8b12e191e067241b2f0bf24300
[]
no_license
douxl5516/Monopoly
fe46cacc868ca4cffb679ada2dce4d547c6ebea0
308a3fcc516f78aaecbf1f9d706c16d9ec84a3a6
refs/heads/master
2020-03-28T12:44:38.545220
2018-11-01T17:39:28
2018-11-01T17:39:28
148,329,812
0
0
null
null
null
null
UTF-8
C++
false
false
2,067
cpp
PlayerState.cpp
#include "PlayerState.h" #include "player.h" #include <iostream> using namespace std; PlayerState::PlayerState(int _round) { round = _round; } PlayerState::~PlayerState() { } FreezeState::FreezeState(int round):PlayerState(round) { } void FreezeState::execute(Player* p) { if (!p->getAct() && round-- > 0) { cout << "## Freeze state! "<<p->name()<< " goes one step! " << round << " rounds left!" << endl; p->go(); } } FlyState::FlyState(int round):PlayerState(round) { } void FlyState::execute(Player* p) { if (!p->getAct()&& round-- > 0) { cout << "## Fly state! " << p->name() << " goes six steps! " << round << " rounds left!" << endl; int i = 6; while (i--&& p->go()); } } HumanCommonState::HumanCommonState():PlayerState(0) { } void HumanCommonState::execute(Player * p) { if (!p->getAct()) { int i = 3; while (i--&&p->go()); } } AutoCommonState::AutoCommonState():PlayerState(0) { } void AutoCommonState::execute(Player * p) { if (!p->getAct()) { int i = 2; while (i--&&p->go()); } } HurtState::HurtState(int round) :PlayerState(round) { } void HurtState::execute(Player * p) { if (round-- > 0) { cout << "## Hurt state! " << p->name() << " lost 5 coins! "<<round<<" rounds left!" << endl; int loseMoney = p->getMoney() < 5 ? p->getMoney() : 5; p->setMoney(p->getMoney() - loseMoney); } } LuckState::LuckState(int round) :PlayerState(round) { } void LuckState::execute(Player * p) { if (round-- > 0) { cout << "## Luck state! " << p->name() << " got 200 coins! " << round << " rounds left!"<< endl; p->setMoney(p->getMoney() + 200); } } ExFlyState::ExFlyState(int round) :PlayerState(round) { } void ExFlyState::execute(Player * p) { if (round-- > 0) { p->setExFly(true); } else if(round==-1) { p->setExFly(false); } } MacroState::MacroState(PlayerState * _prev, PlayerState * _new):prevState(_prev),newState(_new),PlayerState(0) { } MacroState::~MacroState() { delete prevState; delete newState; } void MacroState::execute(Player * p) { newState->execute(p); prevState->execute(p); }
f5985c12e25fc0765c5f218f17dad5170bad8eb5
67702ab2376dcae588baf2288fc73071d96f06b9
/src/FillOps.cpp
1c67ec2d6a12c0bb8b7aceef9b2999d9b4308c55
[ "MIT" ]
permissive
tdp-libs/tp_caffe2_utils
29679913aac22216eb93b6bbd500fe402e1c5cab
b4ca6e5bb30e7320c2c70fdb5375187253db7fde
refs/heads/master
2021-08-06T00:42:43.228088
2020-04-27T16:06:59
2020-04-27T16:06:59
171,952,464
0
2
null
null
null
null
UTF-8
C++
false
false
5,380
cpp
FillOps.cpp
#include "tp_caffe2_utils/FillOps.h" namespace tp_caffe2_utils { //################################################################################################## caffe2::OperatorDef* addXavierFillOp(caffe2::NetDef& net, const std::vector<int64_t>& shape, const std::string& output) { auto op = net.add_op(); op->set_type("XavierFill"); addShapeArg(op, shape); op->add_output(output); return op; } //################################################################################################## caffe2::OperatorDef* addMSRAFillOp(caffe2::NetDef& net, const std::vector<int64_t>& shape, const std::string& output) { auto op = net.add_op(); op->set_type("MSRAFill"); addShapeArg(op, shape); op->add_output(output); return op; } //################################################################################################## caffe2::OperatorDef* addConstantFillOp(caffe2::NetDef& net, const std::vector<int64_t>& shape, float value, const std::string& output) { auto op = net.add_op(); op->set_type("ConstantFill"); addShapeArg(op, shape); addFloatArg(op, "value", value); op->add_output(output); return op; } //################################################################################################## caffe2::OperatorDef* addConstantFillOp(caffe2::NetDef& net, const std::vector<int64_t>& shape, int64_t value, const std::string& output) { auto op = net.add_op(); op->set_type("ConstantFill"); addShapeArg(op, shape); addIntArg(op, "value", value); op->add_output(output); return op; } //################################################################################################## caffe2::OperatorDef* addConstantFillOp_copy(caffe2::NetDef& net, const std::string& copyShape, float value, const std::string& output) { auto op = net.add_op(); op->set_type("ConstantFill"); addFloatArg(op, "value", value); op->add_input(copyShape); op->add_output(output); return op; } //################################################################################################## caffe2::OperatorDef* addGaussianFillOp(caffe2::NetDef& net, const std::vector<int64_t>& shape, float mean, float sd, const std::string& output) { auto op = net.add_op(); op->set_type("GaussianFill"); addShapeArg(op, shape); addFloatArg(op, "mean", mean); addFloatArg(op, "std", sd); op->add_output(output); return op; } //################################################################################################## caffe2::OperatorDef* addGaussianFillOp_copy(caffe2::NetDef& net, const std::string& copyShape, float mean, float sd, const std::string& output) { auto op = net.add_op(); op->set_type("GaussianFill"); addFloatArg(op, "mean", mean); addFloatArg(op, "std", sd); op->add_input(copyShape); op->add_output(output); return op; } //################################################################################################## caffe2::OperatorDef* addGivenTensorFillOp(caffe2::NetDef& net, const std::vector<int64_t>& shape, const std::vector<float>& values, const std::string& output) { auto op = net.add_op(); op->set_type("GivenTensorFill"); addShapeArg(op, shape); addFloatsArg(op, "values", values); op->add_output(output); return op; } //################################################################################################## caffe2::OperatorDef* addGivenTensorIntFillOp(caffe2::NetDef& net, const std::vector<int64_t>& shape, const std::vector<int64_t>& values, const std::string& output) { auto op = net.add_op(); op->set_type("GivenTensorIntFill"); addShapeArg(op, shape); addIntsArg(op, "values", values); op->add_output(output); return op; } //################################################################################################## caffe2::OperatorDef* addGivenTensorInt64FillOp(caffe2::NetDef& net, const std::vector<int64_t>& shape, const std::vector<int64_t>& values, const std::string& output) { auto op = net.add_op(); op->set_type("GivenTensorInt64Fill"); addShapeArg(op, shape); addIntsArg(op, "values", values); op->add_output(output); return op; } }
bc871484e252c1131102e9fa1be46a4038fc7479
e9fd094bf1657e4282b992c4edcc056ee53dc1ae
/GameDev_Demo/OptionsMenu.cpp
5549d91e7719d1da9ecd9fc6d4f6fc351c2f8530
[]
no_license
DanNixon/CSC3224_CSC3222_Gaming
09e661c27967b711cb117b6a1e1c9ffeff6e6a38
ee964339d5605a0ae0b702657f609926e5539ea0
refs/heads/master
2020-12-31T04:07:29.606492
2016-07-17T18:33:54
2016-07-17T18:33:54
48,428,962
3
1
null
null
null
null
UTF-8
C++
false
false
4,118
cpp
OptionsMenu.cpp
/** * @file * @author Dan Nixon (120263697) * * For CSC3224 Project 1. */ #include "OptionsMenu.h" #include <Engine_Utility/StringUtils.h> #include "DemoGame.h" using namespace Engine::Common; using namespace Engine::Maths; using namespace Engine::UIMenu; using namespace Engine::Utility; namespace GameDev { namespace Demo { /** * @copydoc TopBarMenu::TopBarMenu */ OptionsMenu::OptionsMenu(Game *game, TTF_Font *font, float textSize) : TopBarMenu(game, font, textSize) , m_simulatorGame(dynamic_cast<DemoGame *>(m_game)) { setMargin(Vector2()); addNewItem(nullptr, "exit", "Exit"); addNewItem(nullptr, "pause", "Pause"); addNewItem(nullptr, "reset", "Reset"); MenuItem *cameraMenu = addNewItem(nullptr, "camera", "Camera"); addNewItem(cameraMenu, "los", "Line of Sight"); addNewItem(cameraMenu, "fpv", "First Person View"); MenuItem *uiMenu = addNewItem(nullptr, "ui", "HUD"); m_telemetryOption = addNewItem(uiMenu, "telemetry", "Telemetry"); m_sticksOption = addNewItem(uiMenu, "sticks", "Sticks"); m_aircraftMenu = addNewItem(nullptr, "aircraft", "Aircraft"); m_terrainMenu = addNewItem(nullptr, "terrain", "Terrain"); // Update initial names updateOptionNames(); } OptionsMenu::~OptionsMenu() { } /** * @brief Populates the aircraft list. * @param items List of aircraft */ void OptionsMenu::populateAircraftMenu(const NameValueList &items) { populateMenu(m_aircraftMenu, items); } /** * @brief Populates the terrain list. * @param items List of terrains */ void OptionsMenu::populateTerrainMenu(const NameValueList &items) { populateMenu(m_terrainMenu, items); } /** * @brief Sets the names of certain menu options based on the state of the game. */ void OptionsMenu::updateOptionNames() { bool showTelem = StringUtils::ToBool(m_simulatorGame->rootKVNode().children()["hud"].keys()["show_telemetry"]); bool showSticks = StringUtils::ToBool(m_simulatorGame->rootKVNode().children()["hud"].keys()["show_sticks"]); m_telemetryOption->setText(showTelem ? "Hide Telemetry" : "Show Telemetry"); m_sticksOption->setText(showSticks ? "Hide Sticks" : "Show Sticks"); } /** * @copydoc IMenu::handleMenuOptionSelection */ void OptionsMenu::handleMenuOptionSelection(Engine::UIMenu::MenuItem *item) { if (item->name() == "exit") { m_game->exit(); } else if (item->name() == "pause") { auto system = m_simulatorGame->m_physicalSystem; bool run = !system->simulationRunning(); system->setSimulationState(run); item->setText(run ? "Pause" : "Resume", true); } else if (item->parent()->name() == "camera") { dynamic_cast<DemoGame *>(m_game)->setCameraMode(item->name()); } else if (item->name() == "telemetry") { bool state = !StringUtils::ToBool(m_simulatorGame->rootKVNode().children()["hud"].keys()["show_telemetry"]); m_simulatorGame->setTelemetryVisible(state); updateOptionNames(); } else if (item->name() == "sticks") { bool state = !StringUtils::ToBool(m_simulatorGame->rootKVNode().children()["hud"].keys()["show_sticks"]); m_simulatorGame->setSticksVisible(state); updateOptionNames(); } else if (item->parent()->name() == "aircraft") { std::string selectedAircraftName = item->name(); m_simulatorGame->rootKVNode().children()["aircraft"].keys()["selected"] = selectedAircraftName; } else if (item->parent()->name() == "terrain") { std::string selectedAircraftName = item->name(); m_simulatorGame->rootKVNode().children()["terrain"].keys()["default_model"] = selectedAircraftName; } } /** * @brief Adds a set of new items to a given list node. * @param parent Parent menu item * @param items List of new items */ void OptionsMenu::populateMenu(Engine::UIMenu::MenuItem *parent, const NameValueList &items) { for (auto it = items.begin(); it != items.end(); ++it) addNewItem(parent, it->second, it->first); } } }
5f46701149097e111b0c95dcf5b1790665a19834
d84852c821600c3836952b78108df724f90e1096
/exams/2558/02204111/1/midterm/1_1_711_5820501730.cpp
23fad3b620fd575b9471ceb7b85de09f11159890
[ "MIT" ]
permissive
btcup/sb-admin
4a16b380bbccd03f51f6cc5751f33acda2a36b43
c2c71dce1cd683f8eff8e3c557f9b5c9cc5e168f
refs/heads/master
2020-03-08T05:17:16.343572
2018-05-07T17:21:22
2018-05-07T17:21:22
127,944,367
0
1
null
null
null
null
UTF-8
C++
false
false
403
cpp
1_1_711_5820501730.cpp
#include <iostream> #include <cmath> using namespace std; int main() { int usage,voltage; cin>>usage>> cin>>voltage>> Electricity Cost : 320.437; Service : 228.17; Ft : 60.294; Vat 7 % : 38.0289; X = Electricity Cost + Service + Ft + Vat 7 %; cout<<"Total cost : Bath"<<X; system ("pause"); return 0; }
292b23f16eb5607687ee779a64b71b3f35fb1eb6
747336d891514ad5f6a9e95220590f9253de590d
/leet_code_old/src/number_of_islands_tests.cpp
99339a32e92aeccbff25789a27619f251067374d
[]
no_license
alexcthompson/algo_learning
cf89de42d2784806c450187a8d5fbab6af662a3a
0e6be95b26bbc7285f7b544deed267aae9d85fad
refs/heads/master
2023-08-06T03:10:38.884767
2023-07-29T19:03:40
2023-07-29T19:03:40
159,570,983
0
0
null
null
null
null
UTF-8
C++
false
false
885
cpp
number_of_islands_tests.cpp
#define CATCH_CONFIG_MAIN #include <vector> #include "catch2/catch.hpp" #include "number_of_islands.hpp" TEST_CASE( "island counting tests" ) { Solution soln; SECTION( "known results" ) { std::vector<std::vector<char>> grid; int expected_result; grid = {}; expected_result = 0; CHECK ( soln.numIslands(grid) == expected_result ); grid = {{'1','1','1','1','0'}, {'1','1','0','1','0'}, {'1','1','0','0','0'}, {'0','0','0','0','0'}}; expected_result = 1; CHECK ( soln.numIslands(grid) == expected_result ); grid = {{'1','1','0','0','0'}, {'1','1','0','0','0'}, {'0','0','1','0','0'}, {'0','0','0','1','1'}}; expected_result = 3; CHECK ( soln.numIslands(grid) == expected_result ); } }
d8f8faa445153d5d95e5fe5178c02fdf5e167bcc
32eb44863da691b5e755c99123252d5c4ed33fcd
/logic.h
aa3998d0e12f9eb9b00f9a2ebbcb0a433bca49cd
[]
no_license
iccicci/VM167
c237e6b0dc31f9606d2dd589ccdd639cc86e03d7
cef05d6c7a7babfbf1f71f5ace2c68521e9152e5
refs/heads/master
2023-01-19T16:43:19.402749
2020-11-26T17:36:51
2020-11-26T17:36:51
310,894,991
0
0
null
null
null
null
UTF-8
C++
false
false
400
h
logic.h
#pragma once namespace logic { public struct TickInfo { int button; const char* log; }; public ref class LogicInterface { private: class Logic* logic; public: LogicInterface(); ~LogicInterface(); void clearScreen(int buttonId); System::Boolean connect(); float getFontSize(); System::Boolean init(); struct TickInfo* tick(); }; }
57070f4961e4df9b3619f499ac8062ae30e1e851
5c1a874d5c28870da4975da040f096cbc87f4390
/register/Register_TB.cpp
5723be28978e9a192122a17f6b2e775dd6b7186a
[ "MIT" ]
permissive
varunnagpaal/systemc
b7d9eaa3cfbea324e95ad4195e29b476f2a7fdd7
6b6099d5108538174e71ba2564865aa303f176aa
refs/heads/master
2020-03-29T23:15:26.909364
2014-11-23T20:43:32
2014-11-23T20:43:32
26,684,062
1
0
null
null
null
null
UTF-8
C++
false
false
1,997
cpp
Register_TB.cpp
#include "Register_TB.h" #include <iostream> // Stimulus Generator Implementation template<int W> testbench<W>::testbench( sc_module_name name, double clkPeriod, sc_time_unit timeUnit ): sc_module( name ), _clkPeriod( clkPeriod ), _timeUnit( timeUnit ), clock( "CLOCK", clkPeriod, timeUnit, 0.5, 0.0, timeUnit, false ) { SC_THREAD( thread_stimulus ); dont_initialize(); // Tells simulator kernel not to call this simulation process at simultation time 0 sensitive << clock.posedge_event(); SC_THREAD( thread_monitor ); dont_initialize(); // Tells simulator kernel not to call this simulation process at simultation time 0 sensitive << clock.posedge_event(); } template<int W> void testbench<W>::thread_stimulus( void ) { clear.write( SC_LOGIC_Z ); // Tri-stated reset.write( SC_LOGIC_Z ); // Tri-stated preset.write( SC_LOGIC_Z ); // Tri-stated load.write( SC_LOGIC_Z ); // Tri-stated enable.write( SC_LOGIC_Z ); // Tri-stated wait( _clkPeriod, _timeUnit ); // Assert async clear clear.write( SC_LOGIC_1 ); wait( 0.5*_clkPeriod, _timeUnit ); clear.write( SC_LOGIC_0 ); // De-assert // Assert synch reset reset.write( SC_LOGIC_0 ); wait( 1.5*_clkPeriod, _timeUnit ); reset.write( SC_LOGIC_1 ); // De-assert // Assert async preset preset.write( SC_LOGIC_1 ); wait(); // wait for clk positive edge preset.write( SC_LOGIC_0 ); // De-assert // Assert async load out_load_data.write( static_cast<sc_lv<W>>( 4 ) ); load.write( SC_LOGIC_1 ); wait( _clkPeriod, _timeUnit ); load.write( SC_LOGIC_0 ); // De-assert // Enable enable.write( SC_LOGIC_1 ); for( unsigned i=0; i<10; ++i) { out_data.write( static_cast<sc_lv<W>>( 1<<(i+3) ) ); // shift 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 wait( _clkPeriod, _timeUnit ); } wait( _clkPeriod, _timeUnit ); } template<int W> void testbench<W>::thread_monitor( void ) { }
aec4561f5e18d66ccb139223dcea9642c1740825
272b280b0f51f64666a00d6625a36da66713eb80
/include/source/GameObjects.cpp
2d15a922fb0df6d851074843312b527243f9e65b
[]
no_license
MatthewJDowling/GraphicsSections
ede269dede4b8fd5b29883ac26677649b4d42790
058ee0081ab96c3e22b4c8d10b8228de7681312b
refs/heads/master
2021-01-18T20:35:14.921744
2017-09-15T00:45:17
2017-09-15T00:45:17
100,546,231
0
0
null
null
null
null
UTF-8
C++
false
false
1,662
cpp
GameObjects.cpp
#include "..\include\graphics\GameObjects.h" #include "graphics\draw.h" #include "graphics\Load.h" void __internal::t_setUniform(const Shader & s, int & loc_io, int & tex_io, const Camera & val) { t_setUniform(s, loc_io, tex_io, val.proj); // 0 t_setUniform(s, loc_io, tex_io, val.view); } void __internal::t_setUniform(const Shader &s, int & loc_io, int &tex_io, const SpecGloss & val) { t_setUniform(s, loc_io, tex_io, val.model); t_setUniform(s, loc_io, tex_io, val.diffuse); t_setUniform(s, loc_io, tex_io, val.specular); t_setUniform(s, loc_io, tex_io, val.normal); t_setUniform(s, loc_io, tex_io, val.gloss); } void __internal::t_setUniform(const Shader & s, int & loc_io, int & tex_io, const Dlite & val) { // } void createAllAssets(SpecGloss objects[], int size) { //SoulSpear objects[0].objName = "SoulSpear"; objects[0].geo = loadGeometry("../../resources/models/soulspear.obj"); //objects[1].geo = "soulspear"; objects[0].normal = loadTexture("../../resources/textures/soulspear_normal.tga"); objects[0].diffuse = loadTexture("../../resources/textures/soulspear_diffuse.tga"); objects[0].specular = loadTexture("../../resources/textures/soulspear_specular.tga"); objects[0].gloss = 4.0f; objects[2] = objects[0]; objects[2].objName = "GLOSSY AS FUCK SOUL SPEAR"; objects[2].gloss = 24556; objects[1].geo = loadGeometry("../../resources/models/cube.obj"); objects[1].diffuse = loadTexture("../../resources/textures/four_diffuse.tga"); objects[1].specular = loadTexture("../../resources/textures/four specular.tga"); objects[1].normal = loadTexture("../../resources/textures/four_normal.tga"); objects[1].gloss = 4; }
9e230fe29ec892cd2bb1bfef87f52ad8d7f58853
4b62774fb7958d8917ff0eca29b105c160aa3408
/Contest Programming/Codes/Light OJ/1201 - A Perfect Murder.cpp
07969bb972a0c4acca1bba0663bc56a13f264f54
[]
no_license
talhaibnaziz/projects
1dd6e43c281d45ea29ee42ad93dd7faa9c845bbd
95a5a05a938bc06a65a74f7b7b75478694e175db
refs/heads/master
2022-01-21T08:00:37.636644
2021-12-30T01:58:34
2021-12-30T01:58:34
94,550,719
0
0
null
2021-12-26T02:01:24
2017-06-16T14:16:24
Java
UTF-8
C++
false
false
1,370
cpp
1201 - A Perfect Murder.cpp
#include <bits/stdc++.h> using namespace std; int n; vector <int> tree[1010]; bool vis[1010], vis2[1010]; int dp[1010][3]; int rec(int node, bool ik) { if(dp[node][ik]!=-1) return dp[node][ik]; vis[node]=1; vis2[node]=1; //cout<<node<<' '<<ik<<endl; int ans=0; if(ik) { ans++; for(int i=0; i<(int)tree[node].size(); i++) { if(!vis[tree[node][i]]) ans+=rec(tree[node][i], 0); } } else { for(int i=0; i<(int)tree[node].size(); i++) { if(!vis[tree[node][i]]) ans+=max(rec(tree[node][i], 0), rec(tree[node][i], 1)); } } //cout<<ans<<endl; vis[node]=0; return dp[node][ik]=ans; } int main() { int cases, t=0; cin>>cases; while(t<cases) { int m; for(int i=0; i<1005; i++) tree[i].clear(); cin>>n>>m; for(int i=0; i<m; i++) { int u, v; cin>>u>>v; tree[u].push_back(v); tree[v].push_back(u); } memset(vis2, 0, sizeof(vis2)); memset(dp, -1, sizeof(dp)); int ans=0; for(int i=1; i<=n; i++) { if(!vis2[i]) ans+=max(rec(i, 0), rec(i, 1)); } cout<<"Case "<<++t<<": "<<ans<<"\n"; } return 0; }
0e8dbc5cf1d2d8eb7af8deb83ade56836437430b
0a9c86bd80cd0238b4ad46eb14141f8764c4d13d
/game/InputContextMechTS.cpp
128b487817911814cd98ccb2c5b8af8b531a4473
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
sd2017/TriggerTime
744665719f68d0b7fe107ff537db046ec12ce671
9265dee6a178e43bf7365e3aa2f7f2ca22df074f
refs/heads/master
2023-08-18T12:29:23.032342
2021-09-18T10:35:56
2021-09-18T10:35:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,790
cpp
InputContextMechTS.cpp
/* * Copyright (c) 2014, Stanislav Vorobiov * 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ #include "InputContextMechTS.h" #include "InputManager.h" #include "AssetManager.h" #include "Settings.h" #include "Scene.h" #include <boost/make_shared.hpp> namespace af { InputContextMechTS::InputContextMechTS(Scene* scene) : InputContextMech(scene), primaryImage_(assetManager.getImage("subway1/mechfist_icon.png")), secondaryImage_(assetManager.getImage("subway1/mechgun_icon.png")) { moveRadius_ = settings.touchScreen.moveRadius; movePos_ = settings.touchScreen.movePadding + b2Vec2(moveRadius_, moveRadius_); moveHandleRadius_ = settings.touchScreen.moveHandleRadius; primaryRadius_ = settings.touchScreen.primaryRadius; primaryPos_ = settings.touchScreen.primaryPadding + b2Vec2(primaryRadius_, primaryRadius_); primaryPos_.x = scene->gameWidth() - primaryPos_.x; primaryHandleRadius_ = settings.touchScreen.primaryHandleRadius; secondaryRadius_ = settings.touchScreen.secondaryRadius; secondaryPos_ = settings.touchScreen.secondaryPadding + b2Vec2(secondaryRadius_, secondaryRadius_); secondaryPos_.x = scene->gameWidth() - secondaryPos_.x; secondaryHandleRadius_ = settings.touchScreen.secondaryHandleRadius; doDeactivate(); } InputContextMechTS::~InputContextMechTS() { doDeactivate(); } void InputContextMechTS::update(float dt) { if (!moveKnob_) { SceneObjectPtr obj = boost::make_shared<SceneObject>(); obj->setPos(movePos_); moveKnob_ = boost::make_shared<KnobComponent>(); moveKnob_->setRadius(moveRadius_); moveKnob_->setHandleRadius(moveHandleRadius_); moveKnob_->setDrawRing(true); moveKnob_->setAlpha(settings.touchScreen.alpha); obj->addComponent(moveKnob_); scene()->addObject(obj); } if (!primaryKnob_) { SceneObjectPtr obj = boost::make_shared<SceneObject>(); obj->setPos(primaryPos_); primaryKnob_ = boost::make_shared<KnobComponent>(-1); primaryKnob_->setRadius(primaryRadius_); primaryKnob_->setHandleRadius(primaryHandleRadius_); primaryKnob_->setDrawRing(true); primaryKnob_->setAlpha(settings.touchScreen.alpha); primaryKnob_->setImage(primaryImage_); obj->addComponent(primaryKnob_); scene()->addObject(obj); } if (!secondaryKnob_) { SceneObjectPtr obj = boost::make_shared<SceneObject>(); obj->setPos(secondaryPos_); secondaryKnob_ = boost::make_shared<KnobComponent>(); secondaryKnob_->setRadius(secondaryRadius_); secondaryKnob_->setHandleRadius(secondaryHandleRadius_); secondaryKnob_->setDrawRing(true); secondaryKnob_->setAlpha(settings.touchScreen.alpha); secondaryKnob_->setImage(secondaryImage_); obj->addComponent(secondaryKnob_); scene()->addObject(obj); } for (int i = 0; i < InputMaxFingers; ++i) { b2Vec2 point; bool pressed = inputManager.touchScreen().pressed(i, &point); bool triggered = inputManager.touchScreen().triggered(i); if (i == moveFinger_) { if (pressed) { moveTouchPoint_ = point; } else { moveFinger_ = -1; } } else if (i == primaryFinger_) { if (pressed) { primaryTouchPoint_ = point; } else { primaryFinger_ = -1; } } else if (i == secondaryFinger_) { if (pressed) { secondaryTouchPoint_ = point; } else { secondaryFinger_ = -1; } } else if (triggered && ((point - movePos_).Length() <= moveRadius_)) { moveFinger_ = i; moveDownPoint_ = moveTouchPoint_ = point; } else if (triggered && ((point - primaryPos_).Length() <= primaryRadius_)) { primaryFinger_ = i; primaryDownPoint_ = primaryTouchPoint_ = point; } else if (triggered && ((point - secondaryPos_).Length() <= secondaryRadius_)) { secondaryFinger_ = i; secondaryDownPoint_ = secondaryTouchPoint_ = point; } } b2Vec2 dir = b2Vec2_zero; movePressed(dir); moveKnob_->setHandlePos((moveRadius_ - moveHandleRadius_) * dir); dir = b2Vec2_zero; primaryPressed(dir); if (dir.Length() <= (primaryRadius_ - primaryHandleRadius_)) { primaryKnob_->setHandlePos(dir); } else { dir.Normalize(); primaryKnob_->setHandlePos((primaryRadius_ - primaryHandleRadius_) * dir); } dir = b2Vec2_zero; secondaryPressed(dir); if (dir.Length() <= (secondaryRadius_ - secondaryHandleRadius_)) { secondaryKnob_->setHandlePos(dir); } else { dir.Normalize(); secondaryKnob_->setHandlePos((secondaryRadius_ - secondaryHandleRadius_) * dir); } } bool InputContextMechTS::movePressed(b2Vec2& direction) const { if ((moveFinger_ >= 0) && (moveTouchPoint_ != movePos_)) { b2Vec2 tmp = moveTouchPoint_ - movePos_; if (tmp.LengthSquared() >= (1.0f * 1.0f)) { float maxRadius = moveRadius_ - moveHandleRadius_; float len = tmp.Normalize(); if (len > maxRadius) { len = maxRadius; } direction = (len / maxRadius) * tmp; return true; } } return false; } bool InputContextMechTS::primaryPressed(b2Vec2& direction) const { if (primaryFinger_ >= 0) { direction = primaryTouchPoint_ - primaryDownPoint_; if (direction.LengthSquared() < (0.5f * 0.5f)) { direction = b2Vec2_zero; } return true; } return false; } bool InputContextMechTS::secondaryPressed(b2Vec2& direction) const { if (secondaryFinger_ >= 0) { direction = secondaryTouchPoint_ - secondaryDownPoint_; if (direction.LengthSquared() < (0.5f * 0.5f)) { direction = b2Vec2_zero; } return true; } return false; } bool InputContextMechTS::lookPressed(b2Vec2& pos, bool& relative) const { return false; } void InputContextMechTS::doActivate() { moveFinger_ = -1; primaryFinger_ = -1; secondaryFinger_ = -1; } void InputContextMechTS::doDeactivate() { moveFinger_ = -1; primaryFinger_ = -1; secondaryFinger_ = -1; if (moveKnob_) { moveKnob_->parent()->removeFromParent(); moveKnob_.reset(); } if (primaryKnob_) { primaryKnob_->parent()->removeFromParent(); primaryKnob_.reset(); } if (secondaryKnob_) { secondaryKnob_->parent()->removeFromParent(); secondaryKnob_.reset(); } } }
450e43ef464b4a9c1b9f8632fea6765e2f382ec7
29f3596b596193479a2fd53a5b8b76c0d3434de8
/main.cpp
f07d815d2610c4f455aa9e84dea898fdfe59825a
[]
no_license
omabdullah/HW2
dcaf2d354f38714c0ae6766a043fe1ba005a0404
f83a5df3cc895b99f5941e685787e6020eae5762
refs/heads/main
2022-12-24T20:31:51.758705
2020-10-09T04:31:40
2020-10-09T04:31:40
302,264,215
0
0
null
null
null
null
UTF-8
C++
false
false
5,835
cpp
main.cpp
#include <iostream> #include <cmath> #include <cstdio> #include <cstdlib> #if __APPLE__ #include <GLUT/glut.h> #else #include <GL/glut.h> #endif using namespace std; bool leftDown = false, rightDown = false; int lastPos[2]; float cameraPos[4] = {0, 1, 4, 1}; // TODO: Your code here! setup a proper camera position. It should be 4 dimentions homogeneous coordinate, first three elements represent position and 4th element should be 1. int windowWidth = 640, windowHeight = 480; double yRot = 0; int curProblem = 1; // TODO: change this number to try different examples. press SPACE to cycle between problems float specular[] = { 1.0, 1.0, 1.0, 1.0 }; float shininess[] = { 50.0 }; void problem1() { for (int i = 0; i < 360; i = i + 36) { // 360 / 10, each pot is placed 36 degrees apart from each other glPushMatrix(); glRotatef(i, 0, 0, 1); // Takes the angle from i to rotate glTranslatef(1, 0, 0); // Distances the teapots from the center glutSolidTeapot(0.25); // Sets size of teapot to 0.25 glPopMatrix(); } } void problem2() { float spacing = 0.0; // Initial distance between each pot for equal distance (changes after a new row is created to create a pyramid float height = 1.0; // Initial height for top layer (changes as a new row is created to be placed under the previous row properly) for (int row = 0; row < 6; row++) { // creates 6 rows for (int teapot = 0; teapot <= row; teapot++) { // creates same amount of pots as row, first row = 1 pot, second two = 2 pots, etc glPushMatrix(); glTranslatef(teapot + spacing, height, 0); // sets proper x and y coordinates glutSolidTeapot(0.25); // size of teapot 2.5 glPopMatrix(); } spacing = spacing - 1.0 / 2.0; // formula to change pot position on x axis to create a pyramid height = height - 0.5; // formula to change height of new row to properly position pot row under each other } } void problem3() { //sun glPushMatrix(); glTranslatef(1.75, 1.25, -.75); for (int i = 0; i < 360; i = i + 36) { // 360 / 10, each pot is placed 36 degrees apart from each other glPushMatrix(); glRotatef(i, 0, 0, 1); // Takes the angle from i to rotate glutSolidTeapot(0.25); // Sets size of teapot to 0.25 glPopMatrix(); } glPopMatrix(); //building glPushMatrix(); glutSolidCube(1.5); //roof glTranslatef(0, .75, 0); glPushMatrix(); glRotatef(-90, 1, 0, 0); glutSolidCone(.8, 1, 14, 8); glPopMatrix(); // chimney glTranslatef(.45, .5, 0); glPushMatrix(); glScalef(1, 2.75, 1); glutSolidCube(.20); glPopMatrix(); glPopMatrix(); // door glTranslatef(0, -.45, .61); glPushMatrix(); glScalef(2, 3, 2); glutSolidCube(.20); glPopMatrix(); glPopMatrix(); // window 1 glTranslatef(-.35, 0.75, 0); glPushMatrix(); glScalef(2, 2, 2); glutSolidCube(.20); glPopMatrix(); glPopMatrix(); // window 2 glTranslatef(.70, 0, 0); glPushMatrix(); glScalef(2, 2, 2); glutSolidCube(.20); glPopMatrix(); glPopMatrix(); } void display() { glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDisable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); glBegin(GL_LINES); glColor3f(1, 0, 0); glVertex3f(0, 0, 0); glVertex3f(1, 0, 0); // x axis glColor3f(0, 1, 0); glVertex3f(0, 0, 0); glVertex3f(0, 1, 0); // y axis glColor3f(0, 0, 1); glVertex3f(0, 0, 0); glVertex3f(0, 0, 1); // z axis glEnd(/*GL_LINES*/); glEnable(GL_LIGHTING); glShadeModel(GL_SMOOTH); glMaterialfv(GL_FRONT, GL_SPECULAR, specular); glMaterialfv(GL_FRONT, GL_SHININESS, shininess); glEnable(GL_LIGHT0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // TODO: Your code here! Use glViewport() and gluPerspective() to setup projection matrix. glViewport(0, 0, windowWidth, windowHeight); gluPerspective(50, 1.333, 1, 1000); // 1.333 from 640 / 480 glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // TODO: Your code here! Use gluLookAt() to setup model-view matrix. gluLookAt(cameraPos[0], cameraPos[1], cameraPos[2], 0, 0, 0, 0, 1, 0); glLightfv(GL_LIGHT0, GL_POSITION, cameraPos); glRotatef(yRot, 0, 1, 0); if (curProblem == 1) problem1(); if (curProblem == 2) problem2(); if (curProblem == 3) problem3(); glutSwapBuffers(); } void mouse(int button, int state, int x, int y) { if (button == GLUT_LEFT_BUTTON) leftDown = (state == GLUT_DOWN); else if (button == GLUT_RIGHT_BUTTON) rightDown = (state == GLUT_DOWN); lastPos[0] = x; lastPos[1] = y; } void mouseMoved(int x, int y) { if (leftDown) yRot += (x - lastPos[0]) * .1; if (rightDown) { for (int i = 0; i < 3; i++) cameraPos[i] *= pow(1.1, (y - lastPos[1]) * .1); } lastPos[0] = x; lastPos[1] = y; glutPostRedisplay(); } void keyboard(unsigned char key, int x, int y) { if (key == 32) { // When pressing space, it will rotate between each model if (curProblem != 3) { // will rotate until it hits the third model curProblem++; } else { curProblem = 1; // will reset the model to the first since there are only 3 models } } if (key == 'q' || key == 'Q' || key == 27) { // when q, Q, or escape is pressed, program will exit exit(0); } glutPostRedisplay(); } void reshape(int width, int height) { windowWidth = width; windowHeight = height; glutPostRedisplay(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(windowWidth, windowHeight); glutCreateWindow("HW2"); glutDisplayFunc(display); glutMotionFunc(mouseMoved); glutMouseFunc(mouse); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }
4a4e20ad08e956bc426b97ce738707a81ce8416b
3533549c2c6a870eb97cd6ef40a430d433aa4bf5
/app/mail.cpp
812dea6108158b0460ec6bdd761ce7a4faef2efa
[]
no_license
czeidler/fejoaOLD
8077286670b292ea8b4f375ca06a4b11680e66f9
aab7affb5eabe5cb5402daf462a59ccdec3630af
refs/heads/master
2020-12-31T02:02:20.890399
2014-05-04T10:11:14
2014-05-04T10:11:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
18,859
cpp
mail.cpp
#include "mail.h" #include <QBuffer> #include <QString> const QByteArray DataParcel::getSignature() const { return signature; } const QString DataParcel::getSignatureKey() const { return signatureKey; } const Contact *DataParcel::getSender() const { return sender; } QString DataParcel::getUid() const { return uid; } WP::err DataParcel::toRawData(Contact *_sender, const QString &_signatureKey, QIODevice &rawData) { sender = _sender; signatureKey = _signatureKey; CryptoInterface *crypto = CryptoInterfaceSingleton::getCryptoInterface(); QByteArray containerData; QDataStream containerDataStream(&containerData, QIODevice::WriteOnly); containerDataStream.device()->write(sender->getUid().toLatin1()); containerDataStream << (qint8)0; containerDataStream.device()->write(signatureKey.toLatin1()); containerDataStream << (qint8)0; QByteArray mainData; QDataStream mainDataStream(&mainData, QIODevice::WriteOnly); WP::err error = writeMainData(mainDataStream); if (error != WP::kOk) return error; uid = crypto->toHex(crypto->sha1Hash(mainData)); containerDataStream << mainData.length(); if (containerDataStream.device()->write(mainData) != mainData.length()) return WP::kError; QByteArray signatureHash = crypto->toHex(crypto->sha2Hash(containerData)).toLatin1(); error = sender->sign(signatureKey, signatureHash, signature); if (error != WP::kOk) return error; // write signature header QDataStream rawDataStream(&rawData); rawDataStream << signature.length(); if (rawData.write(signature) != signature.length()) return WP::kError; if (rawData.write(containerData) != containerData.length()) return WP::kError; return WP::kOk; } QString DataParcel::readString(QIODevice &data) const { QString string; char c; while (data.getChar(&c)) { if (c == '\0') break; string += c; } return string; } WP::err DataParcel::fromRawData(ContactFinder *contactFinder, QByteArray &rawData) { QDataStream stream(&rawData, QIODevice::ReadOnly); quint32 signatureLength; stream >> signatureLength; if (signatureLength <= 0 || signatureLength >= (quint32)rawData.size()) return WP::kBadValue; char *buffer = new char[signatureLength]; stream.device()->read(buffer, signatureLength); signature.clear(); signature.append(buffer, signatureLength); delete[] buffer; int position = stream.device()->pos(); QByteArray signedData; signedData.setRawData(rawData.data() + position, rawData.length() - position); CryptoInterface *crypto = CryptoInterfaceSingleton::getCryptoInterface(); QByteArray signatureHash = crypto->toHex(crypto->sha2Hash(signedData)).toLatin1(); QString senderUid = readString(*stream.device()); signatureKey = readString(*stream.device()); sender = contactFinder->find(senderUid); if (sender == NULL) return WP::kContactNotFound; int mainDataLength; stream >> mainDataLength; // TODO do proper QIODevice reading QByteArray mainData = stream.device()->read(mainDataLength); if (mainData.length() != mainDataLength) return WP::kError; uid = crypto->toHex(crypto->sha1Hash(mainData)); QBuffer mainDataBuffer(&mainData); mainDataBuffer.open(QBuffer::ReadOnly); WP::err error = readMainData(mainDataBuffer); if (error != WP::kOk) return error; // validate data if (!sender->verify(signatureKey, signatureHash, signature)) return WP::kBadValue; return WP::kOk; } void ParcelCrypto::initNew() { CryptoInterface *crypto = CryptoInterfaceSingleton::getCryptoInterface(); iv = crypto->generateInitalizationVector(kSymmetricKeySize); symmetricKey = crypto->generateSymmetricKey(kSymmetricKeySize); } WP::err ParcelCrypto::initFromPublic(Contact *receiver, const QString &keyId, const QByteArray &iv, const QByteArray &encryptedSymmetricKey) { this->iv = iv; QString certificate; QString publicKey; QString privateKey; WP::err error = receiver->getKeys()->getKeySet(keyId, certificate, publicKey, privateKey); if (error != WP::kOk) return error; CryptoInterface *crypto = CryptoInterfaceSingleton::getCryptoInterface(); error = crypto->decryptAsymmetric(encryptedSymmetricKey, symmetricKey, privateKey, "", certificate); if (error != WP::kOk) return error; return error; } void ParcelCrypto::initFromPrivate(const QByteArray &_iv, const QByteArray &_symmetricKey) { iv = _iv; symmetricKey = _symmetricKey; } WP::err ParcelCrypto::cloakData(const QByteArray &data, QByteArray &cloakedData) { if (symmetricKey.count() == 0) return WP::kNotInit; CryptoInterface *crypto = CryptoInterfaceSingleton::getCryptoInterface(); WP::err error = crypto->encryptSymmetric(data, cloakedData, symmetricKey, iv); return error; } WP::err ParcelCrypto::uncloakData(const QByteArray &cloakedData, QByteArray &data) { if (symmetricKey.count() == 0) return WP::kNotInit; CryptoInterface *crypto = CryptoInterfaceSingleton::getCryptoInterface(); WP::err error = crypto->decryptSymmetric(cloakedData, data, symmetricKey, iv); return error; } const QByteArray &ParcelCrypto::getIV() const { return iv; } const QByteArray &ParcelCrypto::getSymmetricKey() const { return symmetricKey; } WP::err ParcelCrypto::getEncryptedSymmetricKey(Contact *receiver, const QString &keyId, QByteArray &encryptedSymmetricKey) { QString certificate; QString publicKey; WP::err error = receiver->getKeys()->getKeySet(keyId, certificate, publicKey); if (error != WP::kOk) return error; CryptoInterface *crypto = CryptoInterfaceSingleton::getCryptoInterface(); error = crypto->encyrptAsymmetric(symmetricKey, encryptedSymmetricKey, certificate); if (error != WP::kOk) return error; return error; } SecureChannel::SecureChannel(SecureChannelRef channel, Contact *_receiver, const QString &asymKeyId) : AbstractSecureDataParcel(channel->getType()), receiver(_receiver), asymmetricKeyId(asymKeyId) { parcelCrypto = channel->parcelCrypto; } SecureChannel::SecureChannel(qint8 type, Contact *_receiver) : AbstractSecureDataParcel(type), receiver(_receiver) { } SecureChannel::SecureChannel(qint8 type, Contact *_receiver, const QString &asymKeyId) : AbstractSecureDataParcel(type), receiver(_receiver), asymmetricKeyId(asymKeyId) { parcelCrypto.initNew(); } SecureChannel::~SecureChannel() { } WP::err SecureChannel::writeDataSecure(QDataStream &stream, const QByteArray &data) { QByteArray encryptedData; WP::err error = parcelCrypto.cloakData(data, encryptedData); if (error != WP::kOk) return error; stream << encryptedData.length(); if (stream.device()->write(encryptedData) != encryptedData.length()) return WP::kError; return WP::kOk; } WP::err SecureChannel::readDataSecure(QDataStream &stream, QByteArray &data) { int length; stream >> length; QByteArray encryptedData = stream.device()->read(length); return parcelCrypto.uncloakData(encryptedData, data); } WP::err SecureChannel::writeMainData(QDataStream &stream) { QByteArray encryptedSymmetricKey; WP::err error = parcelCrypto.getEncryptedSymmetricKey(receiver, asymmetricKeyId, encryptedSymmetricKey); if (error != WP::kOk) return error; stream.device()->write(asymmetricKeyId.toLatin1()); stream << (qint8)0; stream << encryptedSymmetricKey.length(); stream.device()->write(encryptedSymmetricKey); stream << parcelCrypto.getIV().length(); stream.device()->write(parcelCrypto.getIV()); return WP::kOk; } WP::err SecureChannel::readMainData(QBuffer &mainData) { QDataStream inStream(&mainData); char *buffer; asymmetricKeyId = readString(mainData); int length; inStream >> length; buffer = new char[length]; inStream.device()->read(buffer, length); QByteArray encryptedSymmetricKey; encryptedSymmetricKey.append(buffer, length); delete[] buffer; inStream >> length; buffer = new char[length]; inStream.device()->read(buffer, length); QByteArray iv; iv.append(buffer, length); delete[] buffer; return parcelCrypto.initFromPublic(receiver, asymmetricKeyId, iv, encryptedSymmetricKey); } QString SecureChannel::getUid() const { QByteArray data; data += parcelCrypto.getIV(); CryptoInterface *crypto = CryptoInterfaceSingleton::getCryptoInterface(); return crypto->toHex(crypto->sha1Hash(data)); } SecureChannelParcel::SecureChannelParcel(qint8 type, SecureChannelRef _channel) : AbstractSecureDataParcel(type), channel(_channel) { timestamp = time(NULL); } void SecureChannelParcel::setChannel(SecureChannelRef channel) { this->channel = channel; } SecureChannelRef SecureChannelParcel::getChannel() const { return channel; } time_t SecureChannelParcel::getTimestamp() const { return timestamp; } WP::err SecureChannelParcel::writeMainData(QDataStream &stream) { stream.device()->write(channel->getUid().toLatin1()); stream << (qint8)0; QByteArray secureData; QDataStream secureStream(&secureData, QIODevice::WriteOnly); WP::err error = writeConfidentData(secureStream); if (error != WP::kOk) return error; return channel->writeDataSecure(stream, secureData); } WP::err SecureChannelParcel::readMainData(QBuffer &mainData) { QDataStream stream(&mainData); QString channelId = readString(mainData); channel = findChannel(channelId); if (channel == NULL) return WP::kError; QByteArray confidentData; WP::err error = channel->readDataSecure(stream, confidentData); if (error != WP::kOk) return error; QBuffer confidentDataBuffer(&confidentData); confidentDataBuffer.open(QBuffer::ReadOnly); return readConfidentData(confidentDataBuffer); } WP::err SecureChannelParcel::writeConfidentData(QDataStream &stream) { stream << (qint32)timestamp; return WP::kOk; } WP::err SecureChannelParcel::readConfidentData(QBuffer &mainData) { QDataStream stream(&mainData); qint32 time; stream >> time; timestamp = time; return WP::kOk; } WP::err XMLSecureParcel::write(ProtocolOutStream *outStream, Contact *sender, const QString &signatureKeyId, DataParcel *parcel, const QString &stanzaName) { QBuffer data; data.open(QBuffer::WriteOnly); WP::err error = parcel->toRawData(sender, signatureKeyId, data); if (error != WP::kOk) return error; OutStanza *parcelStanza = new OutStanza(stanzaName); parcelStanza->addAttribute("uid", parcel->getUid()); parcelStanza->addAttribute("sender", parcel->getSender()->getUid()); parcelStanza->addAttribute("signatureKey", parcel->getSignatureKey()); parcelStanza->addAttribute("signature", parcel->getSignature().toBase64()); parcelStanza->setText(data.buffer().toBase64()); outStream->pushChildStanza(parcelStanza); outStream->cdDotDot(); return WP::kOk; } MessageChannel::MessageChannel(MessageChannelRef channel, Contact *receiver, const QString &asymKeyId) : SecureChannel(channel, receiver, asymKeyId), newLocaleInfo(false) { parentChannelUid = channel->parentChannelUid; } MessageChannel::MessageChannel(Contact *receiver) : SecureChannel(kMessageChannelId, receiver), newLocaleInfo(true) { } MessageChannel::MessageChannel(Contact *receiver, const QString &asymKeyId, MessageChannelRef parent) : SecureChannel(kMessageChannelId, receiver, asymKeyId), newLocaleInfo(true) { if (parent != NULL) parentChannelUid =parent->getUid(); } WP::err MessageChannel::writeMainData(QDataStream &stream) { WP::err error = SecureChannel::writeMainData(stream); if (error != WP::kOk) return error; QByteArray extra; QDataStream extraStream(&extra, QIODevice::WriteOnly); error = writeConfidentData(extraStream); if (error != WP::kOk) return error; return writeDataSecure(stream, extra); } WP::err MessageChannel::readMainData(QBuffer &mainData) { WP::err error = SecureChannel::readMainData(mainData); if (error != WP::kOk) return error; QDataStream inStream(&mainData); QByteArray extra; error = SecureChannel::readDataSecure(inStream, extra); if (error != WP::kOk) return error; QBuffer extraBuffer(&extra); extraBuffer.open(QBuffer::ReadOnly); return readConfidentData(extraBuffer); } WP::err MessageChannel::writeConfidentData(QDataStream &stream) { WP::err error = SecureChannel::writeConfidentData(stream); if (error != WP::kOk) return error; stream.device()->write(parentChannelUid.toLatin1()); stream << (qint8)0; return WP::kOk; } WP::err MessageChannel::readConfidentData(QBuffer &mainData) { WP::err error = SecureChannel::readConfidentData(mainData); if (error != WP::kOk) return error; parentChannelUid = readString(mainData); newLocaleInfo = false; return WP::kOk; } QString MessageChannel::getParentChannelUid() const { return parentChannelUid; } bool MessageChannel::isNewLocale() const { return newLocaleInfo; } MessageChannelInfo::MessageChannelInfo(MessageChannelFinder *_channelFinder) : SecureChannelParcel(kMessageChannelInfoId), channelFinder(_channelFinder), newLocaleInfo(true) { } MessageChannelInfo::MessageChannelInfo(MessageChannelRef channel) : SecureChannelParcel(kMessageChannelInfoId, channel), channelFinder(NULL), newLocaleInfo(true) { } void MessageChannelInfo::setSubject(const QString &subject) { this->subject = subject; } const QString &MessageChannelInfo::getSubject() const { return subject; } void MessageChannelInfo::addParticipant(const QString &address, const QString &uid) { Participant participant; participant.address = address; participant.uid = uid; participants.append(participant); } bool MessageChannelInfo::setParticipantUid(const QString &address, const QString &uid) { for (int i = 0; i < participants.size(); i++) { Participant &participant = participants[i]; if (participant.address == address) { participant.uid = uid; return true; } } return false; } bool MessageChannelInfo::isNewLocale() const { return newLocaleInfo; } QVector<MessageChannelInfo::Participant> &MessageChannelInfo::getParticipants() { return participants; } WP::err MessageChannelInfo::writeConfidentData(QDataStream &stream) { WP::err error = SecureChannelParcel::writeConfidentData(stream); if (error != WP::kOk) return error; if (subject != "") { stream << (qint8)kSubject; stream.device()->write(subject.toLatin1()); stream << (qint8)0; } if (participants.count() > 0) { stream << (qint8)kParticipants; stream << (qint32)participants.count(); foreach (const Participant &participant, participants) { stream.device()->write(participant.address.toLatin1()); stream << (qint8)0; stream.device()->write(participant.uid.toLatin1()); stream << (qint8)0; } } return WP::kOk; } WP::err MessageChannelInfo::readConfidentData(QBuffer &mainData) { WP::err error = SecureChannelParcel::readConfidentData(mainData); if (error != WP::kOk) return error; QDataStream stream(&mainData); while (!stream.atEnd()) { qint8 partId; stream >> partId; if (partId == kSubject) { subject = readString(mainData); } else if (partId == kParticipants) { WP::err error = readParticipants(stream); if (error != WP::kOk) return error; } else return WP::kBadValue; } newLocaleInfo = false; return WP::kOk; } SecureChannelRef MessageChannelInfo::findChannel(const QString &channelUid) { return channelFinder->findChannel(channelUid); } WP::err MessageChannelInfo::readParticipants(QDataStream &stream) { qint32 numberOfParticipants; stream >> numberOfParticipants; for (int i = 0; i < numberOfParticipants; i++) { Participant participant; participant.address = readString(*stream.device()); if (participant.address == "") return WP::kBadValue; participant.uid = readString(*stream.device()); // TODO: decide if the uid is mandatory //if (participant.uid == "") // return WP::kBadValue; participants.append(participant); } return WP::kOk; } Message::Message(MessageChannelFinder *_channelFinder) : SecureChannelParcel(kMessageChannelId), channelInfo(NULL), channelFinder(_channelFinder) { } Message::Message(MessageChannelInfoRef info) : SecureChannelParcel(kMessageChannelId, info->getChannel()), channelInfo(info) { setChannel(info->getChannel()); } Message::~Message() { } MessageChannelInfoRef Message::getChannelInfo() const { return channelInfo; } const QByteArray &Message::getBody() const { return body; } void Message::setBody(const QByteArray &_body) { body = _body; } WP::err Message::writeConfidentData(QDataStream &stream) { WP::err error = SecureChannelParcel::writeConfidentData(stream); if (error != WP::kOk) return error; stream.device()->write(channelInfo->getUid().toLatin1()); stream << (qint8)0; stream.device()->write(body); return WP::kOk; } WP::err Message::readConfidentData(QBuffer &mainData) { WP::err error = SecureChannelParcel::readConfidentData(mainData); if (error != WP::kOk) return error; QString channelInfoUid = readString(mainData); channelInfo = channelFinder->findChannelInfo(getChannel()->getUid(), channelInfoUid); if (channelInfo == NULL) return WP::kBadValue; body = mainData.readAll(); return WP::kOk; } SecureChannelRef Message::findChannel(const QString &channelUid) { return channelFinder->findChannel(channelUid); } AbstractSecureDataParcel::AbstractSecureDataParcel(qint8 type) : typeId(type) { } qint8 AbstractSecureDataParcel::getType() const { return typeId; } WP::err AbstractSecureDataParcel::writeConfidentData(QDataStream &stream) { stream << (qint8)typeId; return WP::kOk; } WP::err AbstractSecureDataParcel::readConfidentData(QBuffer &mainData) { QDataStream stream(&mainData); qint8 type; stream >> type; if (type != typeId) return WP::kBadValue; return WP::kOk; }
42669bfcee2bef2109544352479265529291051b
143ce588dbb18c96fe6f344429bbef80dbad0452
/src/gtpV2Codec/gtpV2Stack.cpp
113dc2d75630dbcd9a72794a07990d3e54b6bb7c
[ "Apache-2.0" ]
permissive
sauravpkr/Nucleus
04ef4ad71c9b9eea3bc9b5c6836a2de992bb1d03
099e55a1fb5ccff6da021bf423b9f891cd2d6c42
refs/heads/master
2023-05-31T11:06:40.420840
2021-05-26T10:56:23
2021-05-26T10:56:23
364,496,221
0
6
Apache-2.0
2021-05-26T10:56:24
2021-05-05T07:34:07
C++
UTF-8
C++
false
false
81,345
cpp
gtpV2Stack.cpp
/* * Copyright 2019-present Infosys Limited * * SPDX-License-Identifier: Apache-2.0 */ /****************************************************************************** * * This is an auto generated file. * Please do not edit this file. * All edits to be made through template source file * <TOP-DIR/scripts/GtpV2StackCodeGen/tts/stacktemplate.cpp.tt> ******************************************************************************/ #include <cstring> #include <stdint.h> #include "gtpV2Stack.h" #include "msgClasses/gtpV2MsgFactory.h" #include "msgClasses/manual/gtpV2Message.h" #include "msgClasses/createSessionRequestMsg.h" #include "msgClasses/createSessionResponseMsg.h" #include "msgClasses/modifyBearerRequestMsg.h" #include "msgClasses/modifyBearerResponseMsg.h" #include "msgClasses/deleteSessionRequestMsg.h" #include "msgClasses/deleteSessionResponseMsg.h" #include "msgClasses/releaseAccessBearersRequestMsg.h" #include "msgClasses/releaseAccessBearersResponseMsg.h" #include "msgClasses/createBearerRequestMsg.h" #include "msgClasses/createBearerResponseMsg.h" #include "msgClasses/deleteBearerRequestMsg.h" #include "msgClasses/deleteBearerResponseMsg.h" #include "msgClasses/downlinkDataNotificationMsg.h" #include "msgClasses/downlinkDataNotificationAcknowledgeMsg.h" #include "msgClasses/downlinkDataNotificationFailureIndicationMsg.h" #include "msgClasses/echoRequestMsg.h" #include "msgClasses/echoResponseMsg.h" #include "msgClasses/forwardRelocationRequestMsg.h" #include "msgClasses/forwardRelocationResponseMsg.h" #include "msgClasses/forwardRelocationCompleteNotificationMsg.h" #include "msgClasses/forwardRelocationCompleteAcknowledgeMsg.h" #include "msgClasses/forwardAccessContextNotificationMsg.h" #include "msgClasses/forwardAccessContextAcknowledgeMsg.h" #include "msgClasses/relocationCancelRequestMsg.h" #include "msgClasses/relocationCancelResponseMsg.h" #include "msgClasses/configurationTransferTunnelMsg.h" #include "msgClasses/identificationRequestMsg.h" #include "msgClasses/identificationResponseMsg.h" #include "msgClasses/contextRequestMsg.h" #include "msgClasses/contextResponseMsg.h" thread_local cmn::utils::Debug errorStream; GtpV2Stack::GtpV2Stack () { // TODO Auto-generated constructor stub } GtpV2Stack::~GtpV2Stack () { // TODO Auto-generated destructor stub } bool GtpV2Stack::encodeMessage (GtpV2MessageHeader & msgHeader, MsgBuffer & buffer, void *data_p) { //Clear the global errorStream errorStream.clearStream (); bool rc = false; GtpV2Message & msg = GtpV2MsgFactory::getInstance ().getMsgObject (msgHeader.msgType); uint16_t gtpHeaderStartIdx = buffer.getCurrentIndex(); // Encode the header GtpV2Message::encodeHeader (buffer, msgHeader); Uint16 startIndex = buffer.getCurrentIndex(); switch (msgHeader.msgType) { case CreateSessionRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< CreateSessionRequestMsg & >(msg). encodeCreateSessionRequestMsg(buffer, *((CreateSessionRequestMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< CreateSessionRequestMsg & >(msg). encodeCreateSessionRequestMsg (buffer, createSessionRequestStackData); } break; } case CreateSessionResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< CreateSessionResponseMsg & >(msg). encodeCreateSessionResponseMsg(buffer, *((CreateSessionResponseMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< CreateSessionResponseMsg & >(msg). encodeCreateSessionResponseMsg (buffer, createSessionResponseStackData); } break; } case ModifyBearerRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< ModifyBearerRequestMsg & >(msg). encodeModifyBearerRequestMsg(buffer, *((ModifyBearerRequestMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< ModifyBearerRequestMsg & >(msg). encodeModifyBearerRequestMsg (buffer, modifyBearerRequestStackData); } break; } case ModifyBearerResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< ModifyBearerResponseMsg & >(msg). encodeModifyBearerResponseMsg(buffer, *((ModifyBearerResponseMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< ModifyBearerResponseMsg & >(msg). encodeModifyBearerResponseMsg (buffer, modifyBearerResponseStackData); } break; } case DeleteSessionRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< DeleteSessionRequestMsg & >(msg). encodeDeleteSessionRequestMsg(buffer, *((DeleteSessionRequestMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< DeleteSessionRequestMsg & >(msg). encodeDeleteSessionRequestMsg (buffer, deleteSessionRequestStackData); } break; } case DeleteSessionResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< DeleteSessionResponseMsg & >(msg). encodeDeleteSessionResponseMsg(buffer, *((DeleteSessionResponseMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< DeleteSessionResponseMsg & >(msg). encodeDeleteSessionResponseMsg (buffer, deleteSessionResponseStackData); } break; } case ReleaseAccessBearersRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< ReleaseAccessBearersRequestMsg & >(msg). encodeReleaseAccessBearersRequestMsg(buffer, *((ReleaseAccessBearersRequestMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< ReleaseAccessBearersRequestMsg & >(msg). encodeReleaseAccessBearersRequestMsg (buffer, releaseAccessBearersRequestStackData); } break; } case ReleaseAccessBearersResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< ReleaseAccessBearersResponseMsg & >(msg). encodeReleaseAccessBearersResponseMsg(buffer, *((ReleaseAccessBearersResponseMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< ReleaseAccessBearersResponseMsg & >(msg). encodeReleaseAccessBearersResponseMsg (buffer, releaseAccessBearersResponseStackData); } break; } case CreateBearerRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< CreateBearerRequestMsg & >(msg). encodeCreateBearerRequestMsg(buffer, *((CreateBearerRequestMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< CreateBearerRequestMsg & >(msg). encodeCreateBearerRequestMsg (buffer, createBearerRequestStackData); } break; } case CreateBearerResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< CreateBearerResponseMsg & >(msg). encodeCreateBearerResponseMsg(buffer, *((CreateBearerResponseMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< CreateBearerResponseMsg & >(msg). encodeCreateBearerResponseMsg (buffer, createBearerResponseStackData); } break; } case DeleteBearerRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< DeleteBearerRequestMsg & >(msg). encodeDeleteBearerRequestMsg(buffer, *((DeleteBearerRequestMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< DeleteBearerRequestMsg & >(msg). encodeDeleteBearerRequestMsg (buffer, deleteBearerRequestStackData); } break; } case DeleteBearerResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< DeleteBearerResponseMsg & >(msg). encodeDeleteBearerResponseMsg(buffer, *((DeleteBearerResponseMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< DeleteBearerResponseMsg & >(msg). encodeDeleteBearerResponseMsg (buffer, deleteBearerResponseStackData); } break; } case DownlinkDataNotificationMsgType: { if (data_p != NULL) { rc = dynamic_cast< DownlinkDataNotificationMsg & >(msg). encodeDownlinkDataNotificationMsg(buffer, *((DownlinkDataNotificationMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< DownlinkDataNotificationMsg & >(msg). encodeDownlinkDataNotificationMsg (buffer, downlinkDataNotificationStackData); } break; } case DownlinkDataNotificationAcknowledgeMsgType: { if (data_p != NULL) { rc = dynamic_cast< DownlinkDataNotificationAcknowledgeMsg & >(msg). encodeDownlinkDataNotificationAcknowledgeMsg(buffer, *((DownlinkDataNotificationAcknowledgeMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< DownlinkDataNotificationAcknowledgeMsg & >(msg). encodeDownlinkDataNotificationAcknowledgeMsg (buffer, downlinkDataNotificationAcknowledgeStackData); } break; } case DownlinkDataNotificationFailureIndicationMsgType: { if (data_p != NULL) { rc = dynamic_cast< DownlinkDataNotificationFailureIndicationMsg & >(msg). encodeDownlinkDataNotificationFailureIndicationMsg(buffer, *((DownlinkDataNotificationFailureIndicationMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< DownlinkDataNotificationFailureIndicationMsg & >(msg). encodeDownlinkDataNotificationFailureIndicationMsg (buffer, downlinkDataNotificationFailureIndicationStackData); } break; } case EchoRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< EchoRequestMsg & >(msg). encodeEchoRequestMsg(buffer, *((EchoRequestMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< EchoRequestMsg & >(msg). encodeEchoRequestMsg (buffer, echoRequestStackData); } break; } case EchoResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< EchoResponseMsg & >(msg). encodeEchoResponseMsg(buffer, *((EchoResponseMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< EchoResponseMsg & >(msg). encodeEchoResponseMsg (buffer, echoResponseStackData); } break; } case ForwardRelocationRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< ForwardRelocationRequestMsg & >(msg). encodeForwardRelocationRequestMsg(buffer, *((ForwardRelocationRequestMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< ForwardRelocationRequestMsg & >(msg). encodeForwardRelocationRequestMsg (buffer, forwardRelocationRequestStackData); } break; } case ForwardRelocationResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< ForwardRelocationResponseMsg & >(msg). encodeForwardRelocationResponseMsg(buffer, *((ForwardRelocationResponseMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< ForwardRelocationResponseMsg & >(msg). encodeForwardRelocationResponseMsg (buffer, forwardRelocationResponseStackData); } break; } case ForwardRelocationCompleteNotificationMsgType: { if (data_p != NULL) { rc = dynamic_cast< ForwardRelocationCompleteNotificationMsg & >(msg). encodeForwardRelocationCompleteNotificationMsg(buffer, *((ForwardRelocationCompleteNotificationMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< ForwardRelocationCompleteNotificationMsg & >(msg). encodeForwardRelocationCompleteNotificationMsg (buffer, forwardRelocationCompleteNotificationStackData); } break; } case ForwardRelocationCompleteAcknowledgeMsgType: { if (data_p != NULL) { rc = dynamic_cast< ForwardRelocationCompleteAcknowledgeMsg & >(msg). encodeForwardRelocationCompleteAcknowledgeMsg(buffer, *((ForwardRelocationCompleteAcknowledgeMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< ForwardRelocationCompleteAcknowledgeMsg & >(msg). encodeForwardRelocationCompleteAcknowledgeMsg (buffer, forwardRelocationCompleteAcknowledgeStackData); } break; } case ForwardAccessContextNotificationMsgType: { if (data_p != NULL) { rc = dynamic_cast< ForwardAccessContextNotificationMsg & >(msg). encodeForwardAccessContextNotificationMsg(buffer, *((ForwardAccessContextNotificationMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< ForwardAccessContextNotificationMsg & >(msg). encodeForwardAccessContextNotificationMsg (buffer, forwardAccessContextNotificationStackData); } break; } case ForwardAccessContextAcknowledgeMsgType: { if (data_p != NULL) { rc = dynamic_cast< ForwardAccessContextAcknowledgeMsg & >(msg). encodeForwardAccessContextAcknowledgeMsg(buffer, *((ForwardAccessContextAcknowledgeMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< ForwardAccessContextAcknowledgeMsg & >(msg). encodeForwardAccessContextAcknowledgeMsg (buffer, forwardAccessContextAcknowledgeStackData); } break; } case RelocationCancelRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< RelocationCancelRequestMsg & >(msg). encodeRelocationCancelRequestMsg(buffer, *((RelocationCancelRequestMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< RelocationCancelRequestMsg & >(msg). encodeRelocationCancelRequestMsg (buffer, relocationCancelRequestStackData); } break; } case RelocationCancelResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< RelocationCancelResponseMsg & >(msg). encodeRelocationCancelResponseMsg(buffer, *((RelocationCancelResponseMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< RelocationCancelResponseMsg & >(msg). encodeRelocationCancelResponseMsg (buffer, relocationCancelResponseStackData); } break; } case ConfigurationTransferTunnelMsgType: { if (data_p != NULL) { rc = dynamic_cast< ConfigurationTransferTunnelMsg & >(msg). encodeConfigurationTransferTunnelMsg(buffer, *((ConfigurationTransferTunnelMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< ConfigurationTransferTunnelMsg & >(msg). encodeConfigurationTransferTunnelMsg (buffer, configurationTransferTunnelStackData); } break; } case IdentificationRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< IdentificationRequestMsg & >(msg). encodeIdentificationRequestMsg(buffer, *((IdentificationRequestMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< IdentificationRequestMsg & >(msg). encodeIdentificationRequestMsg (buffer, identificationRequestStackData); } break; } case IdentificationResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< IdentificationResponseMsg & >(msg). encodeIdentificationResponseMsg(buffer, *((IdentificationResponseMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< IdentificationResponseMsg & >(msg). encodeIdentificationResponseMsg (buffer, identificationResponseStackData); } break; } case ContextRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< ContextRequestMsg & >(msg). encodeContextRequestMsg(buffer, *((ContextRequestMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< ContextRequestMsg & >(msg). encodeContextRequestMsg (buffer, contextRequestStackData); } break; } case ContextResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< ContextResponseMsg & >(msg). encodeContextResponseMsg(buffer, *((ContextResponseMsgData *) data_p)); } else { // Application has filled the data structure provided by the stack rc = dynamic_cast< ContextResponseMsg & >(msg). encodeContextResponseMsg (buffer, contextResponseStackData); } break; } } Uint16 endIndex = buffer.getCurrentIndex (); Uint16 messageLength = (endIndex - startIndex) + 4; // sequence number always present if(msgHeader.teidPresent) { messageLength += 4; } buffer.goToIndex (gtpHeaderStartIdx + 2); // 2 is where length is encoded in a gtp message TODO remove hardcoding buffer.writeUint16 (messageLength, false); buffer.goToIndex (endIndex); return rc; } bool GtpV2Stack::decodeGtpMessageHeader(GtpV2MessageHeader& msgHeader, MsgBuffer& buffer) { return GtpV2Message::decodeHeader (buffer, msgHeader); } bool GtpV2Stack::decodeMessage (GtpV2MessageHeader& msgHeader, MsgBuffer& buffer,void* data_p) { errorStream.clearStream(); // First decode the message header bool rc = false; Uint16 msgDataLength = msgHeader.msgLength; if (msgHeader.teidPresent) { msgDataLength = msgDataLength - 8; //teid and sequence number } else { msgDataLength = msgDataLength - 4; //only sequence number } // Validate the length before proceeding if (msgDataLength != buffer.lengthLeft() ) { // Encoded message length does not match the number of bytes left in the message errorStream.add ((char *)"Message length does not match bytes in buffer\n"); errorStream.add ((char *)"Computed Message length: "); errorStream.add (msgDataLength); errorStream.add ((char *)" Bytes Left in buffer: "); errorStream.add (buffer.lengthLeft()); errorStream.endOfLine (); return false; } GtpV2Message& msg = GtpV2MsgFactory::getInstance ().getMsgObject (msgHeader.msgType); switch (msgHeader.msgType){ case CreateSessionRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< CreateSessionRequestMsg & >(msg). decodeCreateSessionRequestMsg(buffer, *(CreateSessionRequestMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&createSessionRequestStackData, 0, sizeof (CreateSessionRequestMsgData)); rc = dynamic_cast< CreateSessionRequestMsg & >(msg). decodeCreateSessionRequestMsg(buffer, createSessionRequestStackData, msgDataLength); } break; } case CreateSessionResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< CreateSessionResponseMsg & >(msg). decodeCreateSessionResponseMsg(buffer, *(CreateSessionResponseMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&createSessionResponseStackData, 0, sizeof (CreateSessionResponseMsgData)); rc = dynamic_cast< CreateSessionResponseMsg & >(msg). decodeCreateSessionResponseMsg(buffer, createSessionResponseStackData, msgDataLength); } break; } case ModifyBearerRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< ModifyBearerRequestMsg & >(msg). decodeModifyBearerRequestMsg(buffer, *(ModifyBearerRequestMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&modifyBearerRequestStackData, 0, sizeof (ModifyBearerRequestMsgData)); rc = dynamic_cast< ModifyBearerRequestMsg & >(msg). decodeModifyBearerRequestMsg(buffer, modifyBearerRequestStackData, msgDataLength); } break; } case ModifyBearerResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< ModifyBearerResponseMsg & >(msg). decodeModifyBearerResponseMsg(buffer, *(ModifyBearerResponseMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&modifyBearerResponseStackData, 0, sizeof (ModifyBearerResponseMsgData)); rc = dynamic_cast< ModifyBearerResponseMsg & >(msg). decodeModifyBearerResponseMsg(buffer, modifyBearerResponseStackData, msgDataLength); } break; } case DeleteSessionRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< DeleteSessionRequestMsg & >(msg). decodeDeleteSessionRequestMsg(buffer, *(DeleteSessionRequestMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&deleteSessionRequestStackData, 0, sizeof (DeleteSessionRequestMsgData)); rc = dynamic_cast< DeleteSessionRequestMsg & >(msg). decodeDeleteSessionRequestMsg(buffer, deleteSessionRequestStackData, msgDataLength); } break; } case DeleteSessionResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< DeleteSessionResponseMsg & >(msg). decodeDeleteSessionResponseMsg(buffer, *(DeleteSessionResponseMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&deleteSessionResponseStackData, 0, sizeof (DeleteSessionResponseMsgData)); rc = dynamic_cast< DeleteSessionResponseMsg & >(msg). decodeDeleteSessionResponseMsg(buffer, deleteSessionResponseStackData, msgDataLength); } break; } case ReleaseAccessBearersRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< ReleaseAccessBearersRequestMsg & >(msg). decodeReleaseAccessBearersRequestMsg(buffer, *(ReleaseAccessBearersRequestMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&releaseAccessBearersRequestStackData, 0, sizeof (ReleaseAccessBearersRequestMsgData)); rc = dynamic_cast< ReleaseAccessBearersRequestMsg & >(msg). decodeReleaseAccessBearersRequestMsg(buffer, releaseAccessBearersRequestStackData, msgDataLength); } break; } case ReleaseAccessBearersResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< ReleaseAccessBearersResponseMsg & >(msg). decodeReleaseAccessBearersResponseMsg(buffer, *(ReleaseAccessBearersResponseMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&releaseAccessBearersResponseStackData, 0, sizeof (ReleaseAccessBearersResponseMsgData)); rc = dynamic_cast< ReleaseAccessBearersResponseMsg & >(msg). decodeReleaseAccessBearersResponseMsg(buffer, releaseAccessBearersResponseStackData, msgDataLength); } break; } case CreateBearerRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< CreateBearerRequestMsg & >(msg). decodeCreateBearerRequestMsg(buffer, *(CreateBearerRequestMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&createBearerRequestStackData, 0, sizeof (CreateBearerRequestMsgData)); rc = dynamic_cast< CreateBearerRequestMsg & >(msg). decodeCreateBearerRequestMsg(buffer, createBearerRequestStackData, msgDataLength); } break; } case CreateBearerResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< CreateBearerResponseMsg & >(msg). decodeCreateBearerResponseMsg(buffer, *(CreateBearerResponseMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&createBearerResponseStackData, 0, sizeof (CreateBearerResponseMsgData)); rc = dynamic_cast< CreateBearerResponseMsg & >(msg). decodeCreateBearerResponseMsg(buffer, createBearerResponseStackData, msgDataLength); } break; } case DeleteBearerRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< DeleteBearerRequestMsg & >(msg). decodeDeleteBearerRequestMsg(buffer, *(DeleteBearerRequestMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&deleteBearerRequestStackData, 0, sizeof (DeleteBearerRequestMsgData)); rc = dynamic_cast< DeleteBearerRequestMsg & >(msg). decodeDeleteBearerRequestMsg(buffer, deleteBearerRequestStackData, msgDataLength); } break; } case DeleteBearerResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< DeleteBearerResponseMsg & >(msg). decodeDeleteBearerResponseMsg(buffer, *(DeleteBearerResponseMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&deleteBearerResponseStackData, 0, sizeof (DeleteBearerResponseMsgData)); rc = dynamic_cast< DeleteBearerResponseMsg & >(msg). decodeDeleteBearerResponseMsg(buffer, deleteBearerResponseStackData, msgDataLength); } break; } case DownlinkDataNotificationMsgType: { if (data_p != NULL) { rc = dynamic_cast< DownlinkDataNotificationMsg & >(msg). decodeDownlinkDataNotificationMsg(buffer, *(DownlinkDataNotificationMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&downlinkDataNotificationStackData, 0, sizeof (DownlinkDataNotificationMsgData)); rc = dynamic_cast< DownlinkDataNotificationMsg & >(msg). decodeDownlinkDataNotificationMsg(buffer, downlinkDataNotificationStackData, msgDataLength); } break; } case DownlinkDataNotificationAcknowledgeMsgType: { if (data_p != NULL) { rc = dynamic_cast< DownlinkDataNotificationAcknowledgeMsg & >(msg). decodeDownlinkDataNotificationAcknowledgeMsg(buffer, *(DownlinkDataNotificationAcknowledgeMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&downlinkDataNotificationAcknowledgeStackData, 0, sizeof (DownlinkDataNotificationAcknowledgeMsgData)); rc = dynamic_cast< DownlinkDataNotificationAcknowledgeMsg & >(msg). decodeDownlinkDataNotificationAcknowledgeMsg(buffer, downlinkDataNotificationAcknowledgeStackData, msgDataLength); } break; } case DownlinkDataNotificationFailureIndicationMsgType: { if (data_p != NULL) { rc = dynamic_cast< DownlinkDataNotificationFailureIndicationMsg & >(msg). decodeDownlinkDataNotificationFailureIndicationMsg(buffer, *(DownlinkDataNotificationFailureIndicationMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&downlinkDataNotificationFailureIndicationStackData, 0, sizeof (DownlinkDataNotificationFailureIndicationMsgData)); rc = dynamic_cast< DownlinkDataNotificationFailureIndicationMsg & >(msg). decodeDownlinkDataNotificationFailureIndicationMsg(buffer, downlinkDataNotificationFailureIndicationStackData, msgDataLength); } break; } case EchoRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< EchoRequestMsg & >(msg). decodeEchoRequestMsg(buffer, *(EchoRequestMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&echoRequestStackData, 0, sizeof (EchoRequestMsgData)); rc = dynamic_cast< EchoRequestMsg & >(msg). decodeEchoRequestMsg(buffer, echoRequestStackData, msgDataLength); } break; } case EchoResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< EchoResponseMsg & >(msg). decodeEchoResponseMsg(buffer, *(EchoResponseMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&echoResponseStackData, 0, sizeof (EchoResponseMsgData)); rc = dynamic_cast< EchoResponseMsg & >(msg). decodeEchoResponseMsg(buffer, echoResponseStackData, msgDataLength); } break; } case ForwardRelocationRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< ForwardRelocationRequestMsg & >(msg). decodeForwardRelocationRequestMsg(buffer, *(ForwardRelocationRequestMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&forwardRelocationRequestStackData, 0, sizeof (ForwardRelocationRequestMsgData)); rc = dynamic_cast< ForwardRelocationRequestMsg & >(msg). decodeForwardRelocationRequestMsg(buffer, forwardRelocationRequestStackData, msgDataLength); } break; } case ForwardRelocationResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< ForwardRelocationResponseMsg & >(msg). decodeForwardRelocationResponseMsg(buffer, *(ForwardRelocationResponseMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&forwardRelocationResponseStackData, 0, sizeof (ForwardRelocationResponseMsgData)); rc = dynamic_cast< ForwardRelocationResponseMsg & >(msg). decodeForwardRelocationResponseMsg(buffer, forwardRelocationResponseStackData, msgDataLength); } break; } case ForwardRelocationCompleteNotificationMsgType: { if (data_p != NULL) { rc = dynamic_cast< ForwardRelocationCompleteNotificationMsg & >(msg). decodeForwardRelocationCompleteNotificationMsg(buffer, *(ForwardRelocationCompleteNotificationMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&forwardRelocationCompleteNotificationStackData, 0, sizeof (ForwardRelocationCompleteNotificationMsgData)); rc = dynamic_cast< ForwardRelocationCompleteNotificationMsg & >(msg). decodeForwardRelocationCompleteNotificationMsg(buffer, forwardRelocationCompleteNotificationStackData, msgDataLength); } break; } case ForwardRelocationCompleteAcknowledgeMsgType: { if (data_p != NULL) { rc = dynamic_cast< ForwardRelocationCompleteAcknowledgeMsg & >(msg). decodeForwardRelocationCompleteAcknowledgeMsg(buffer, *(ForwardRelocationCompleteAcknowledgeMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&forwardRelocationCompleteAcknowledgeStackData, 0, sizeof (ForwardRelocationCompleteAcknowledgeMsgData)); rc = dynamic_cast< ForwardRelocationCompleteAcknowledgeMsg & >(msg). decodeForwardRelocationCompleteAcknowledgeMsg(buffer, forwardRelocationCompleteAcknowledgeStackData, msgDataLength); } break; } case ForwardAccessContextNotificationMsgType: { if (data_p != NULL) { rc = dynamic_cast< ForwardAccessContextNotificationMsg & >(msg). decodeForwardAccessContextNotificationMsg(buffer, *(ForwardAccessContextNotificationMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&forwardAccessContextNotificationStackData, 0, sizeof (ForwardAccessContextNotificationMsgData)); rc = dynamic_cast< ForwardAccessContextNotificationMsg & >(msg). decodeForwardAccessContextNotificationMsg(buffer, forwardAccessContextNotificationStackData, msgDataLength); } break; } case ForwardAccessContextAcknowledgeMsgType: { if (data_p != NULL) { rc = dynamic_cast< ForwardAccessContextAcknowledgeMsg & >(msg). decodeForwardAccessContextAcknowledgeMsg(buffer, *(ForwardAccessContextAcknowledgeMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&forwardAccessContextAcknowledgeStackData, 0, sizeof (ForwardAccessContextAcknowledgeMsgData)); rc = dynamic_cast< ForwardAccessContextAcknowledgeMsg & >(msg). decodeForwardAccessContextAcknowledgeMsg(buffer, forwardAccessContextAcknowledgeStackData, msgDataLength); } break; } case RelocationCancelRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< RelocationCancelRequestMsg & >(msg). decodeRelocationCancelRequestMsg(buffer, *(RelocationCancelRequestMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&relocationCancelRequestStackData, 0, sizeof (RelocationCancelRequestMsgData)); rc = dynamic_cast< RelocationCancelRequestMsg & >(msg). decodeRelocationCancelRequestMsg(buffer, relocationCancelRequestStackData, msgDataLength); } break; } case RelocationCancelResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< RelocationCancelResponseMsg & >(msg). decodeRelocationCancelResponseMsg(buffer, *(RelocationCancelResponseMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&relocationCancelResponseStackData, 0, sizeof (RelocationCancelResponseMsgData)); rc = dynamic_cast< RelocationCancelResponseMsg & >(msg). decodeRelocationCancelResponseMsg(buffer, relocationCancelResponseStackData, msgDataLength); } break; } case ConfigurationTransferTunnelMsgType: { if (data_p != NULL) { rc = dynamic_cast< ConfigurationTransferTunnelMsg & >(msg). decodeConfigurationTransferTunnelMsg(buffer, *(ConfigurationTransferTunnelMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&configurationTransferTunnelStackData, 0, sizeof (ConfigurationTransferTunnelMsgData)); rc = dynamic_cast< ConfigurationTransferTunnelMsg & >(msg). decodeConfigurationTransferTunnelMsg(buffer, configurationTransferTunnelStackData, msgDataLength); } break; } case IdentificationRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< IdentificationRequestMsg & >(msg). decodeIdentificationRequestMsg(buffer, *(IdentificationRequestMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&identificationRequestStackData, 0, sizeof (IdentificationRequestMsgData)); rc = dynamic_cast< IdentificationRequestMsg & >(msg). decodeIdentificationRequestMsg(buffer, identificationRequestStackData, msgDataLength); } break; } case IdentificationResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< IdentificationResponseMsg & >(msg). decodeIdentificationResponseMsg(buffer, *(IdentificationResponseMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&identificationResponseStackData, 0, sizeof (IdentificationResponseMsgData)); rc = dynamic_cast< IdentificationResponseMsg & >(msg). decodeIdentificationResponseMsg(buffer, identificationResponseStackData, msgDataLength); } break; } case ContextRequestMsgType: { if (data_p != NULL) { rc = dynamic_cast< ContextRequestMsg & >(msg). decodeContextRequestMsg(buffer, *(ContextRequestMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&contextRequestStackData, 0, sizeof (ContextRequestMsgData)); rc = dynamic_cast< ContextRequestMsg & >(msg). decodeContextRequestMsg(buffer, contextRequestStackData, msgDataLength); } break; } case ContextResponseMsgType: { if (data_p != NULL) { rc = dynamic_cast< ContextResponseMsg & >(msg). decodeContextResponseMsg(buffer, *(ContextResponseMsgData*) data_p, msgDataLength); } else { // Application wants to use the data structure provided by the stack // let us first clear any data present in the internal data structure memset (&contextResponseStackData, 0, sizeof (ContextResponseMsgData)); rc = dynamic_cast< ContextResponseMsg & >(msg). decodeContextResponseMsg(buffer, contextResponseStackData, msgDataLength); } break; } } return rc; } void GtpV2Stack::display_v(Uint8 msgType, Debug& stream, void* data_p) { // Display the messageType stream.add ((char *)"MessageType: "); stream.add (msgType); stream.endOfLine (); GtpV2Message& msg = GtpV2MsgFactory::getInstance ().getMsgObject (msgType); switch (msgType){ case CreateSessionRequestMsgType: { stream.add ((char *)"Message: CreateSessionRequestMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< CreateSessionRequestMsg & >(msg). displayCreateSessionRequestMsgData_v (* ((CreateSessionRequestMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< CreateSessionRequestMsg & >(msg). displayCreateSessionRequestMsgData_v (createSessionRequestStackData, stream); } break; } case CreateSessionResponseMsgType: { stream.add ((char *)"Message: CreateSessionResponseMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< CreateSessionResponseMsg & >(msg). displayCreateSessionResponseMsgData_v (* ((CreateSessionResponseMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< CreateSessionResponseMsg & >(msg). displayCreateSessionResponseMsgData_v (createSessionResponseStackData, stream); } break; } case ModifyBearerRequestMsgType: { stream.add ((char *)"Message: ModifyBearerRequestMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< ModifyBearerRequestMsg & >(msg). displayModifyBearerRequestMsgData_v (* ((ModifyBearerRequestMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< ModifyBearerRequestMsg & >(msg). displayModifyBearerRequestMsgData_v (modifyBearerRequestStackData, stream); } break; } case ModifyBearerResponseMsgType: { stream.add ((char *)"Message: ModifyBearerResponseMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< ModifyBearerResponseMsg & >(msg). displayModifyBearerResponseMsgData_v (* ((ModifyBearerResponseMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< ModifyBearerResponseMsg & >(msg). displayModifyBearerResponseMsgData_v (modifyBearerResponseStackData, stream); } break; } case DeleteSessionRequestMsgType: { stream.add ((char *)"Message: DeleteSessionRequestMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< DeleteSessionRequestMsg & >(msg). displayDeleteSessionRequestMsgData_v (* ((DeleteSessionRequestMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< DeleteSessionRequestMsg & >(msg). displayDeleteSessionRequestMsgData_v (deleteSessionRequestStackData, stream); } break; } case DeleteSessionResponseMsgType: { stream.add ((char *)"Message: DeleteSessionResponseMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< DeleteSessionResponseMsg & >(msg). displayDeleteSessionResponseMsgData_v (* ((DeleteSessionResponseMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< DeleteSessionResponseMsg & >(msg). displayDeleteSessionResponseMsgData_v (deleteSessionResponseStackData, stream); } break; } case ReleaseAccessBearersRequestMsgType: { stream.add ((char *)"Message: ReleaseAccessBearersRequestMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< ReleaseAccessBearersRequestMsg & >(msg). displayReleaseAccessBearersRequestMsgData_v (* ((ReleaseAccessBearersRequestMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< ReleaseAccessBearersRequestMsg & >(msg). displayReleaseAccessBearersRequestMsgData_v (releaseAccessBearersRequestStackData, stream); } break; } case ReleaseAccessBearersResponseMsgType: { stream.add ((char *)"Message: ReleaseAccessBearersResponseMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< ReleaseAccessBearersResponseMsg & >(msg). displayReleaseAccessBearersResponseMsgData_v (* ((ReleaseAccessBearersResponseMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< ReleaseAccessBearersResponseMsg & >(msg). displayReleaseAccessBearersResponseMsgData_v (releaseAccessBearersResponseStackData, stream); } break; } case CreateBearerRequestMsgType: { stream.add ((char *)"Message: CreateBearerRequestMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< CreateBearerRequestMsg & >(msg). displayCreateBearerRequestMsgData_v (* ((CreateBearerRequestMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< CreateBearerRequestMsg & >(msg). displayCreateBearerRequestMsgData_v (createBearerRequestStackData, stream); } break; } case CreateBearerResponseMsgType: { stream.add ((char *)"Message: CreateBearerResponseMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< CreateBearerResponseMsg & >(msg). displayCreateBearerResponseMsgData_v (* ((CreateBearerResponseMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< CreateBearerResponseMsg & >(msg). displayCreateBearerResponseMsgData_v (createBearerResponseStackData, stream); } break; } case DeleteBearerRequestMsgType: { stream.add ((char *)"Message: DeleteBearerRequestMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< DeleteBearerRequestMsg & >(msg). displayDeleteBearerRequestMsgData_v (* ((DeleteBearerRequestMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< DeleteBearerRequestMsg & >(msg). displayDeleteBearerRequestMsgData_v (deleteBearerRequestStackData, stream); } break; } case DeleteBearerResponseMsgType: { stream.add ((char *)"Message: DeleteBearerResponseMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< DeleteBearerResponseMsg & >(msg). displayDeleteBearerResponseMsgData_v (* ((DeleteBearerResponseMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< DeleteBearerResponseMsg & >(msg). displayDeleteBearerResponseMsgData_v (deleteBearerResponseStackData, stream); } break; } case DownlinkDataNotificationMsgType: { stream.add ((char *)"Message: DownlinkDataNotificationMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< DownlinkDataNotificationMsg & >(msg). displayDownlinkDataNotificationMsgData_v (* ((DownlinkDataNotificationMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< DownlinkDataNotificationMsg & >(msg). displayDownlinkDataNotificationMsgData_v (downlinkDataNotificationStackData, stream); } break; } case DownlinkDataNotificationAcknowledgeMsgType: { stream.add ((char *)"Message: DownlinkDataNotificationAcknowledgeMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< DownlinkDataNotificationAcknowledgeMsg & >(msg). displayDownlinkDataNotificationAcknowledgeMsgData_v (* ((DownlinkDataNotificationAcknowledgeMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< DownlinkDataNotificationAcknowledgeMsg & >(msg). displayDownlinkDataNotificationAcknowledgeMsgData_v (downlinkDataNotificationAcknowledgeStackData, stream); } break; } case DownlinkDataNotificationFailureIndicationMsgType: { stream.add ((char *)"Message: DownlinkDataNotificationFailureIndicationMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< DownlinkDataNotificationFailureIndicationMsg & >(msg). displayDownlinkDataNotificationFailureIndicationMsgData_v (* ((DownlinkDataNotificationFailureIndicationMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< DownlinkDataNotificationFailureIndicationMsg & >(msg). displayDownlinkDataNotificationFailureIndicationMsgData_v (downlinkDataNotificationFailureIndicationStackData, stream); } break; } case EchoRequestMsgType: { stream.add ((char *)"Message: EchoRequestMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< EchoRequestMsg & >(msg). displayEchoRequestMsgData_v (* ((EchoRequestMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< EchoRequestMsg & >(msg). displayEchoRequestMsgData_v (echoRequestStackData, stream); } break; } case EchoResponseMsgType: { stream.add ((char *)"Message: EchoResponseMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< EchoResponseMsg & >(msg). displayEchoResponseMsgData_v (* ((EchoResponseMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< EchoResponseMsg & >(msg). displayEchoResponseMsgData_v (echoResponseStackData, stream); } break; } case ForwardRelocationRequestMsgType: { stream.add ((char *)"Message: ForwardRelocationRequestMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< ForwardRelocationRequestMsg & >(msg). displayForwardRelocationRequestMsgData_v (* ((ForwardRelocationRequestMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< ForwardRelocationRequestMsg & >(msg). displayForwardRelocationRequestMsgData_v (forwardRelocationRequestStackData, stream); } break; } case ForwardRelocationResponseMsgType: { stream.add ((char *)"Message: ForwardRelocationResponseMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< ForwardRelocationResponseMsg & >(msg). displayForwardRelocationResponseMsgData_v (* ((ForwardRelocationResponseMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< ForwardRelocationResponseMsg & >(msg). displayForwardRelocationResponseMsgData_v (forwardRelocationResponseStackData, stream); } break; } case ForwardRelocationCompleteNotificationMsgType: { stream.add ((char *)"Message: ForwardRelocationCompleteNotificationMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< ForwardRelocationCompleteNotificationMsg & >(msg). displayForwardRelocationCompleteNotificationMsgData_v (* ((ForwardRelocationCompleteNotificationMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< ForwardRelocationCompleteNotificationMsg & >(msg). displayForwardRelocationCompleteNotificationMsgData_v (forwardRelocationCompleteNotificationStackData, stream); } break; } case ForwardRelocationCompleteAcknowledgeMsgType: { stream.add ((char *)"Message: ForwardRelocationCompleteAcknowledgeMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< ForwardRelocationCompleteAcknowledgeMsg & >(msg). displayForwardRelocationCompleteAcknowledgeMsgData_v (* ((ForwardRelocationCompleteAcknowledgeMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< ForwardRelocationCompleteAcknowledgeMsg & >(msg). displayForwardRelocationCompleteAcknowledgeMsgData_v (forwardRelocationCompleteAcknowledgeStackData, stream); } break; } case ForwardAccessContextNotificationMsgType: { stream.add ((char *)"Message: ForwardAccessContextNotificationMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< ForwardAccessContextNotificationMsg & >(msg). displayForwardAccessContextNotificationMsgData_v (* ((ForwardAccessContextNotificationMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< ForwardAccessContextNotificationMsg & >(msg). displayForwardAccessContextNotificationMsgData_v (forwardAccessContextNotificationStackData, stream); } break; } case ForwardAccessContextAcknowledgeMsgType: { stream.add ((char *)"Message: ForwardAccessContextAcknowledgeMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< ForwardAccessContextAcknowledgeMsg & >(msg). displayForwardAccessContextAcknowledgeMsgData_v (* ((ForwardAccessContextAcknowledgeMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< ForwardAccessContextAcknowledgeMsg & >(msg). displayForwardAccessContextAcknowledgeMsgData_v (forwardAccessContextAcknowledgeStackData, stream); } break; } case RelocationCancelRequestMsgType: { stream.add ((char *)"Message: RelocationCancelRequestMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< RelocationCancelRequestMsg & >(msg). displayRelocationCancelRequestMsgData_v (* ((RelocationCancelRequestMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< RelocationCancelRequestMsg & >(msg). displayRelocationCancelRequestMsgData_v (relocationCancelRequestStackData, stream); } break; } case RelocationCancelResponseMsgType: { stream.add ((char *)"Message: RelocationCancelResponseMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< RelocationCancelResponseMsg & >(msg). displayRelocationCancelResponseMsgData_v (* ((RelocationCancelResponseMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< RelocationCancelResponseMsg & >(msg). displayRelocationCancelResponseMsgData_v (relocationCancelResponseStackData, stream); } break; } case ConfigurationTransferTunnelMsgType: { stream.add ((char *)"Message: ConfigurationTransferTunnelMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< ConfigurationTransferTunnelMsg & >(msg). displayConfigurationTransferTunnelMsgData_v (* ((ConfigurationTransferTunnelMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< ConfigurationTransferTunnelMsg & >(msg). displayConfigurationTransferTunnelMsgData_v (configurationTransferTunnelStackData, stream); } break; } case IdentificationRequestMsgType: { stream.add ((char *)"Message: IdentificationRequestMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< IdentificationRequestMsg & >(msg). displayIdentificationRequestMsgData_v (* ((IdentificationRequestMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< IdentificationRequestMsg & >(msg). displayIdentificationRequestMsgData_v (identificationRequestStackData, stream); } break; } case IdentificationResponseMsgType: { stream.add ((char *)"Message: IdentificationResponseMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< IdentificationResponseMsg & >(msg). displayIdentificationResponseMsgData_v (* ((IdentificationResponseMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< IdentificationResponseMsg & >(msg). displayIdentificationResponseMsgData_v (identificationResponseStackData, stream); } break; } case ContextRequestMsgType: { stream.add ((char *)"Message: ContextRequestMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< ContextRequestMsg & >(msg). displayContextRequestMsgData_v (* ((ContextRequestMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< ContextRequestMsg & >(msg). displayContextRequestMsgData_v (contextRequestStackData, stream); } break; } case ContextResponseMsgType: { stream.add ((char *)"Message: ContextResponseMsg"); stream.endOfLine (); if (data_p != NULL) { dynamic_cast< ContextResponseMsg & >(msg). displayContextResponseMsgData_v (* ((ContextResponseMsgData*) data_p), stream); } else { // Application wants to use the data structure provided by the stack dynamic_cast< ContextResponseMsg & >(msg). displayContextResponseMsgData_v (contextResponseStackData, stream); } break; } } }
77c4adf1e7908d14654a85e38600a7917d6f5e47
5ac6a4049412058e0416f9015fc13f29322b277f
/Code/TotalSafe/CajaFuerte/CajaFuerte_1.07/Nagivation.ino
ef0453de394f333f8ef09b3027758ad482eaecc6
[]
no_license
CastroAldrick/CajaFuerte
b957d1273f9e16267590b4d182d0a65b7b1fb179
c280beb0cb7c5a58bfe0e9dec8928a432d62ee85
refs/heads/master
2020-04-05T09:18:17.549753
2019-04-25T13:43:00
2019-04-25T13:43:00
156,749,892
2
1
null
null
null
null
UTF-8
C++
false
false
25,094
ino
Nagivation.ino
int CheckHDirection() { if (!digitalRead(LEFT)) { Serial.println("LEFT has been pressed"); buttonDebounceTimer = 5; cleared = false; return -1; } if (!digitalRead(RIGHT)) { Serial.println("RIGHT has been pressed"); buttonDebounceTimer = 5; cleared = false; return 1; } else{return 0;} } int CheckVDirection() { if (!digitalRead(BACK)) { Serial.println("BACK has been pressed"); buttonDebounceTimer = 5; cleared = false; return -1; } if (!digitalRead(ENTER)) { Serial.println("ENTER has been pressed"); buttonDebounceTimer = 5; cleared = false; return 1; } else{return 0;} } void LCD_Map(int mode) { // Pages Number per Menu #define PAGES_MAIN_MENU 3 #define PAGES_SAFE_ACCESS 2 #define PAGES_ADMIN_ACCESS 2 #define PAGES_VALID_PRINT 7 #define PAGES_ENROLL_PRINT 7 #define PAGES_DELETE_PRINT 3 #define PAGES_DELETE_ALL 3 #define PAGES_ADD_CARD 4 #define PAGES_REMOVE_CARD 5 #define PAGES_REMOVE_ALL_CARDS 3 #define LOWEST_PAGE 1 struct LCD { String Main[PAGES_MAIN_MENU] = {"Main Menu", // Title "Safe Access","Admin Access"}; // Options String Safe_Access[PAGES_SAFE_ACCESS] = {"Safe Access", // Title "Enter Card"}; // Options String Admin_Access[PAGES_ADMIN_ACCESS] = {"Admin Access", // Title "Enter Finger"}; // Options String Valid_Print[PAGES_VALID_PRINT] = {"Access Granted", // Title "Enroll New Print", "Delete Existing Print", "Erase All Prints", // Options "Add Card", "Remove Card", "Remove All Cards"}; String Enroll_Print[PAGES_ENROLL_PRINT] = {"Enroll New Print", // Title "Print ID #", "Enter Finger", "Remove Finger", "Enter Finger", "Finger Enrolled", "No More Room"}; // Options String Delete_Print[PAGES_DELETE_PRINT] = {"Delete Print", // Title "Print ID #", "Print Deleted"}; // Options String Delete_All[PAGES_DELETE_ALL] = {"Dlt All Prints", // Title "Are You Sure?", "All Deleted"}; // Options String Add_Card[PAGES_ADD_CARD] = {"Add Card.Space ", // Title "Scan Card", "Card is #: ", "No More Space"}; // Options String Remove_Card[PAGES_REMOVE_CARD] = {"Remove Card", // Title "Scan Card", "Card # ", "Card Removed", "No Cards Saved"} ; // Options String Remove_All_Cards[PAGES_REMOVE_ALL_CARDS] = {"Remove All Cards", // Title "Are You Sure?", "All Removed"}; // Options }sPage; bool emptySlot[5] = {false, false, false, false, false}; bool occupiedSlot[5] = {false, false, false, false, false}; bool match = false; int attempt = 0; int emptySpace = 0; int occupiedSpace = 0; int fingerCount = 0; //digitalWrite(CS_RFID, HIGH); //digitalWrite(CS_SD_CARD, HIGH); switch (mode) { case 0: finger.getTemplateCount(); fingerCount = finger.templateCount; if (fingerCount == 0){ lcd.clear(); lcd.setCursor(0,0); lcd.print("No Fingerprints"); lcd.setCursor(0,1); lcd.print("Are Enrolled"); delay(2000); menu = 4; } digitalWrite(CS_RFID, HIGH); digitalWrite(CS_SD_CARD, HIGH); lcd.setCursor(0,0); lcd.print(sPage.Main[0]); hLocation = hLocation + CheckHDirection(); switch (hLocation) { case PAGES_MAIN_MENU: hLocation = 1; break; case LOWEST_PAGE - 1: hLocation = PAGES_MAIN_MENU - 1; break; } switch (hLocation) { case 1: if (cleared == false){ lcd.setCursor (0, 1); lcd.print(" "); cleared = true; } lcd.setCursor(0,1); lcd.print(sPage.Main[hLocation]); break; case 2: if (cleared == false){ lcd.setCursor (0, 1); lcd.print(" "); cleared = true; } lcd.setCursor(0,1); lcd.print(sPage.Main[hLocation]); } vLocation = vLocation + CheckVDirection(); vLocation = (vLocation == -1)?(0):(vLocation); switch (vLocation){ case 1: lcd.clear(); menu = hLocation; vLocation = 0; hLocation = 1; break; } break; case 1: lcd.setCursor(0,0); lcd.print(sPage.Safe_Access[0]); lcd.setCursor(0,1); lcd.print(sPage.Safe_Access[1]); vLocation = vLocation + CheckVDirection(); switch (vLocation){ case -1: lcd.clear(); menu = 0; vLocation = 0; hLocation = 1; break; } //****// Scan Card //Serial.print("card timer = "); Serial.println(cardScanningTimer); if (resetCardTimer == 0){ digitalWrite(CS_RFID, LOW); digitalWrite(CS_SD_CARD, HIGH); cardScanningTimer = 50; resetCardTimer = 1; } if (cardScanningTimer > 0){ successfulRead = getID(); //Serial.print("READ "); Serial.println(successfulRead); if (successfulRead == 1){ // a Card was scanned Serial.println("Card scanned"); Serial.println(enteredCard); //digitalWrite(CS_RFID, HIGH); // Check if card is Good for (int num = 0; num <= 4; num++){ if (enteredCard == sCards[num]){ Serial.print(enteredCard); Serial.print("Matches Card "); Serial.println(num); match = true; break; } else if(num == 4) Serial.println("No Match was found"); } if (match){ // pull solenoid // Check hall effect sensor } // Save card scanned in LOG.TXT file along with time and Status //digitalWrite(CS_SD_CARD, LOW); Files = SD.open("LOG.TXT", FILE_WRITE); if (Files) { Serial.println("LOG file open"); Files.println(); Files.print(enteredCard); Files.print("\t"); Files.print(rtc.getDateStr()); Files.print("\t"); Files.print(rtc.getTimeStr()); if (match){ Files.print("\t"); Files.println("Valid"); } Files.close(); } else { Serial.println("Failed"); } enteredCard = ""; resetCardTimer = 0; lcd.clear(); cardScanningTimer = 50; menu = 0; hLocation = 1; vLocation = 0; } else{ //Serial.println("No card Scanned"); } } else{ // Timer ran out, back to main menu digitalWrite(CS_RFID, HIGH); Serial.println("Timed out"); resetCardTimer = 0; lcd.clear(); cardScanningTimer = 50; menu = 0; hLocation = 1; vLocation = 0; } break; case 2: lcd.setCursor(0,0); lcd.print(sPage.Admin_Access[0]); lcd.setCursor(0,1); lcd.print(sPage.Admin_Access[1]); vLocation = vLocation + CheckVDirection(); switch (vLocation){ case -1: menu = 0; vLocation = 0; hLocation = 1; break; } //****// Finger Scanning if (resetFingerScanningTimer == 0){ fingerScanTimer = 50; resetFingerScanningTimer = 1; } if (fingerScanTimer > 0){ fingerprintID = getFingerprintID(); if (fingerprintID != -1){ Serial.println("Good"); lcd.clear(); fingerprintID = -1; resetFingerScanningTimer = 0; menu = 3; hLocation = 1; vLocation = 0; } } else{ Serial.println("Took too long"); lcd.clear(); resetFingerScanningTimer = 0; fingerprintID = -1; menu = 0; hLocation = 1; vLocation = 0; } break; case 3: lcd.setCursor(0,0); lcd.print(sPage.Valid_Print[0]); // Access Granted hLocation = hLocation + CheckHDirection(); switch (hLocation){ case PAGES_VALID_PRINT: hLocation = 1; break; case LOWEST_PAGE - 1: hLocation = PAGES_VALID_PRINT - 1; break; } switch (hLocation){ case 1: if (cleared == false){ lcd.setCursor (0, 1); lcd.print(" "); cleared = true; } lcd.setCursor(0,1); lcd.print(sPage.Valid_Print[hLocation]); // Enroll New Print break; case 2: if (cleared == false){ lcd.setCursor (0, 1); lcd.print(" "); cleared = true; } lcd.setCursor(0,1); lcd.print(sPage.Valid_Print[hLocation]); // Delete Existing Print break; case 3: if (cleared == false){ lcd.setCursor (0, 1); lcd.print(" "); cleared = true; } lcd.setCursor(0,1); lcd.print(sPage.Valid_Print[hLocation]); // Add Card break; case 4: if (cleared == false){ lcd.setCursor (0, 1); lcd.print(" "); cleared = true; } lcd.setCursor(0,1); lcd.print(sPage.Valid_Print[hLocation]); // Remove Card break; case 5: if (cleared == false){ lcd.setCursor (0, 1); lcd.print(" "); cleared = true; } lcd.setCursor(0,1); lcd.print(sPage.Valid_Print[hLocation]); // Remove All Cards break; case 6: if (cleared == false){ lcd.setCursor (0, 1); lcd.print(" "); cleared = true; } lcd.setCursor(0,1); lcd.print(sPage.Valid_Print[hLocation]); // Enroll New Print break; } vLocation = vLocation + CheckVDirection(); switch (vLocation){ case -1: lcd.clear(); menu = 0; // Main Menu vLocation = 0; hLocation = 1; break; case 1: lcd.clear(); menu = hLocation + 3; // Enroll New Print = 4, // Delete Existing = 5, // Erase All Prints = 6, // Add Card = 7, // Remove Card = 8, // Remove All Cards = 9 vLocation = 0; hLocation = 1; break; } break; case 4: // Enroll New Print Menu lcd.setCursor(0,0); lcd.print(sPage.Enroll_Print[0]); // Enroll New Print lcd.setCursor(0,1); lcd.print(sPage.Enroll_Print[1]); // Print ID # hLocation = hLocation + CheckHDirection(); switch (hLocation){ case 0: hLocation = 1; break; case 6: hLocation = 5; break; } lcd.print(" "); lcd.print(hLocation); vLocation = CheckVDirection(); switch (vLocation){ case -1: if (fingerCount == 0){ lcd.clear(); lcd.setCursor(0,0); lcd.print("Please Enroll a"); lcd.setCursor(0,1); lcd.print("Finger to Start"); delay(3000); lcd.clear(); } else{ lcd.clear(); menu = 3; vLocation = 0; hLocation = 1; } break; case 1: vLocation = 0; //hLocation = 1; getFingerprintEnroll(hLocation); /* lcd.setCursor (0, 1); lcd.print(" "); lcd.setCursor (0, 1); lcd.print(sPage.Enroll_Print[2]); // Enter Finger // Scan Finger delay(2000); lcd.setCursor (0, 1); lcd.print(" "); lcd.setCursor (0, 1); lcd.print(sPage.Enroll_Print[3]); // Remove Finger delay(2000); lcd.setCursor (0, 1); lcd.print(" "); lcd.setCursor (0, 1); lcd.print(sPage.Enroll_Print[4]); // Enter Finger delay(2000); lcd.setCursor (0, 1); lcd.print(" "); lcd.setCursor (0, 1); lcd.print(sPage.Enroll_Print[5]); // Finger Enrolled delay(2000); */ lcd.clear(); menu = 0; hLocation = 1; // Add finger print counter break; } break; case 5: lcd.setCursor(0,0); lcd.print(sPage.Delete_Print[0]); // Delete Print lcd.setCursor(0,1); lcd.print(sPage.Delete_Print[1]); // Print ID # hLocation = hLocation + CheckHDirection(); switch (hLocation){ case 0: hLocation = 1; break; case 6: hLocation = 5; break; } lcd.print(" "); lcd.print(hLocation); vLocation = CheckVDirection(); switch (vLocation){ case -1: lcd.clear(); menu = 3; vLocation = 0; hLocation = 1; break; case 1: // Delete Print lcd.setCursor (0, 1); lcd.print(" "); lcd.setCursor (0, 1); lcd.print(sPage.Delete_Print[2]); lcd.print(" #"); lcd.print(hLocation); delay(1000); deleteFingerprint(hLocation); lcd.clear(); menu = 0; vLocation = 0; hLocation = 1; break; } break; // case 6: lcd.setCursor(0,0); lcd.print(sPage.Delete_All[0]); // Delete All Prints lcd.setCursor(0,1); lcd.print(sPage.Delete_All[1]); // Are You Sure? vLocation = CheckVDirection(); switch (vLocation){ case -1: lcd.clear(); menu = 3; vLocation = 0; hLocation = 1; break; case 1: // Delete All The Prints lcd.setCursor (0, 1); lcd.print(" "); lcd.setCursor (0, 1); lcd.print("Deleting Prints"); delay(2000); lcd.setCursor (0, 1); lcd.print(" "); lcd.setCursor (0, 1); lcd.print(sPage.Delete_All[2]); delay(2000); lcd.clear(); menu = 0; vLocation = 0; hLocation = 1; break; } break; case 7: // Add Card lcd.setCursor(0,0); lcd.print(sPage.Add_Card[0]); // Add Card for (int card = 0; card <= 4; card++){ if (sCards[card] == "EMPTY EMPTY"){ Serial.println(card); emptySlot[card] = true; emptySpace++; if (emptySlot[card]){ Serial.print("Slot "); Serial.print(card); Serial.println(" empty"); } } } lcd.print(emptySpace); //delay(5000); hLocation = hLocation + CheckHDirection(); switch (hLocation){ case LOWEST_PAGE - 1: hLocation = PAGES_ADD_CARD - 1; break; case PAGES_ADD_CARD: hLocation = LOWEST_PAGE; break; } switch (hLocation){ case 1: if (cleared == false){ lcd.setCursor (0, 1); lcd.print(" "); cleared = true; } lcd.setCursor(0,1); lcd.print(sPage.Add_Card[hLocation]); break; case 2: if (cleared == false){ lcd.setCursor (0, 1); lcd.print(" "); cleared = true; } lcd.setCursor(0,1); lcd.print(sPage.Add_Card[hLocation]); break; case 3: if (cleared == false){ lcd.setCursor (0, 1); lcd.print(" "); cleared = true; } lcd.setCursor(0,1); lcd.print(sPage.Add_Card[hLocation]); break; } vLocation = vLocation + CheckVDirection(); switch (vLocation){ case -1: lcd.clear(); menu = 2; // Admin Access vLocation = 0; hLocation = 1; break; case 1: lcd.clear(); menu = 10; // Scan Card for adding vLocation = 0; hLocation = 1; break; } /*for (int inx = 0; inx <= 4; inx++){ Serial.println(emptySlot[inx]);}*/ break; case 8: lcd.setCursor(0,0); lcd.print(sPage.Remove_Card[0]); for (int card = 0; card <= 4; card++){ // if (sCards[card] != "EMPTY EMPTY"){ // // Serial.print(card); // Serial.println("Card is empty"); occupiedSlot[card] = true; occupiedSpace++; } // Serial.println(occupiedSpace); if (occupiedSpace == 0){ Serial.println("No cards exist"); lcd.clear(); menu = 2; // Admin Access vLocation = 0; hLocation = 1; } vLocation = vLocation + CheckVDirection(); switch (vLocation){ case -1: lcd.clear(); menu = 2; // Admin Access vLocation = 0; hLocation = 1; break; case 1: lcd.clear(); // menu = 11; // Scan Card for removing // vLocation = 0; // hLocation = 1; lcd.setCursor(0,0); lcd.print(sPage.Remove_Card[2]); if (resetCardTimer == 0){ digitalWrite(CS_RFID, LOW); digitalWrite(CS_SD_CARD, HIGH); cardScanningTimer = 50; resetCardTimer = 1; } if (cardScanningTimer > 0){ Serial.println("Scanning"); successfulRead = getID(); if (successfulRead == 1){ digitalWrite(CS_RFID, HIGH); Serial.println(enteredCard); for (int card = 0; card <= 4; card++){ if (enteredCard == sCards[card]){ Serial.print(enteredCard); Serial.print(" Matches "); Serial.println(card); Serial.println("Removing"); sCards[card] = "EMPTY EMPTY"; updateCard(); Serial.println("Removed"); break; } else if(card == 4){ Serial.println("Doesnt match records"); } } enteredCard = ""; resetCardTimer = 0; cardScanningTimer = 50; lcd.clear(); menu = 0; // Main Menu vLocation = 0; hLocation = 1; } } Serial.println(sCards[0]); Serial.println(sCards[1]); Serial.println(sCards[2]); Serial.println(sCards[3]); Serial.println(sCards[4]); break; } break; case 9: // Remove All Cards lcd.setCursor(0,0); lcd.print(sPage.Remove_All_Cards[0]); // Remove All Cards lcd.setCursor(0,1); lcd.print(sPage.Remove_All_Cards[1]); // Are You Sure? vLocation = CheckVDirection(); switch (vLocation){ case -1: // Back was pressed lcd.clear(); menu = 3; vLocation = 0; hLocation = 1; break; case 1: // Enter was pressed lcd.setCursor(0,1); lcd.print(" "); lcd.setCursor(0,1); lcd.print("Deleting all Cards"); for (int i = 0; i <= 4; i++){ sCards[i] = "EMPTY EMPTY"; } rmAllCards(); updateCard(); lcd.clear(); menu = 0; vLocation = 0; hLocation = 1; break; } break; case 10: lcd.setCursor(0,0); lcd.print(sPage.Add_Card[1]); // Scan Card for adding for (int card = 0; card <= 4; card++){ if (sCards[card] == "EMPTY EMPTY"){ //Serial.println(card); emptySlot[card] = true; /*if (emptySlot[card]){ Serial.print("Slot "); Serial.print(card); Serial.println(" empty"); }*/ } } Serial.print("reset "); Serial.println(resetCardTimer); if (resetCardTimer == 0){ digitalWrite(CS_RFID, LOW); digitalWrite(CS_SD_CARD, HIGH); Serial.println("here"); cardScanningTimer = 50; resetCardTimer = 1; } Serial.print("timer "); Serial.println(cardScanningTimer); if (cardScanningTimer > 0){ successfulRead = getID(); Serial.print("success "); Serial.println(successfulRead); if (successfulRead == 1){ // a Card was scanned Serial.println("Card scanned"); Serial.println(enteredCard); digitalWrite(CS_RFID, HIGH); // Check if card already exist for (int num = 0; num <= 4; num++){ if (enteredCard == sCards[num]){ Serial.print(enteredCard); Serial.print(" Matches Card "); Serial.println(num); Serial.println("Cannot Add"); for (int i = 0; i <= 4; i++){ Serial.println(sCards[i]); } //match = true; enteredCard = ""; resetCardTimer = 0; cardScanningTimer = 50; lcd.clear(); menu = 0; // Main Menu vLocation = 0; hLocation = 1; break; } else if(num == 4){ Serial.println("No Match was found"); for (int inx = 0; inx <= 4; inx++){ //Serial.println(emptySlot[inx]); if (emptySlot[inx]){ sCards[inx] = enteredCard; Serial.println("Card added"); // upload changes to sd card Serial.println(sCards[0]); Serial.println(sCards[1]); Serial.println(sCards[2]); Serial.println(sCards[3]); Serial.println(sCards[4]); enteredCard = ""; resetCardTimer = 0; cardScanningTimer = 50; lcd.clear(); menu = 0; // Main Menu vLocation = 0; hLocation = 1; updateCard(); break; } else Serial.println("blah"); } } } } } break; } }
cbfaa86b9a89cf86570a9a5bd38dbaafa7701933
9f5f8e5ca355e3ff5d411e620d7e6b10cb4b1e22
/Courses/Distributed Systems and Midd/Poject/omnet/samples/dsp2/sysReply_m.h
b246e19337ba270ecdd041da1972e9a09745dc62
[]
no_license
djonines/thesisBackUp
fe001b65f6f5d35bceef1792aca730066fd1c685
e81cb9ae2ba257fd31dc979a2134be7b1e0cc5f2
refs/heads/master
2020-05-22T09:48:59.587887
2012-05-04T23:16:10
2012-05-04T23:16:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,066
h
sysReply_m.h
// // Generated file, do not edit! Created by opp_msgc 4.1 from sysReply.msg. // #ifndef _SYSREPLY_M_H_ #define _SYSREPLY_M_H_ #include <omnetpp.h> // opp_msgc version check #define MSGC_VERSION 0x0401 #if (MSGC_VERSION!=OMNETPP_VERSION) # error Version mismatch! Probably this file was generated by an earlier version of opp_msgc: 'make clean' should help. #endif /** * Enum generated from <tt>sysReply.msg</tt> by opp_msgc. * <pre> * enum DSP2_SYSTEM_REPLY_TYPES{ * DSP2_BROKER_NOT_READY = 0; * DSP2_PUBLISHED_MESSAGE = 1; * }; * </pre> */ enum DSP2_SYSTEM_REPLY_TYPES { DSP2_BROKER_NOT_READY = 0, DSP2_PUBLISHED_MESSAGE = 1 }; /** * Class generated from <tt>sysReply.msg</tt> by opp_msgc. * <pre> * message SysReply { * int repType @enum(DSP2_SYSTEM_REPLY_TYPES); * int originator; * string topic; * string content; * } * </pre> */ class SysReply : public ::cMessage { protected: int repType_var; int originator_var; opp_string topic_var; opp_string content_var; // protected and unimplemented operator==(), to prevent accidental usage bool operator==(const SysReply&); public: SysReply(const char *name=NULL, int kind=0); SysReply(const SysReply& other); virtual ~SysReply(); SysReply& operator=(const SysReply& other); virtual SysReply *dup() const {return new SysReply(*this);} virtual void parsimPack(cCommBuffer *b); virtual void parsimUnpack(cCommBuffer *b); // field getter/setter methods virtual int getRepType() const; virtual void setRepType(int repType_var); virtual int getOriginator() const; virtual void setOriginator(int originator_var); virtual const char * getTopic() const; virtual void setTopic(const char * topic_var); virtual const char * getContent() const; virtual void setContent(const char * content_var); }; inline void doPacking(cCommBuffer *b, SysReply& obj) {obj.parsimPack(b);} inline void doUnpacking(cCommBuffer *b, SysReply& obj) {obj.parsimUnpack(b);} #endif // _SYSREPLY_M_H_
cdc24406e7f05ee051f0774dc8e56f25343a4875
b9e177770e38bd2cac9302403a79c343967ab7eb
/Classes/ProgressScene.cpp
d072f6931fb8800b64209c10d3640cf249961596
[]
no_license
KeZongWang/LuoBo
629091236d13690ced5dab64ec77a65e8b72e73b
587b9546eb72138ec6efb9eedaf2a4a60d655e0a
refs/heads/master
2020-03-16T13:13:42.209155
2018-05-11T11:55:40
2018-05-11T11:55:40
132,684,186
0
0
null
null
null
null
UTF-8
C++
false
false
4,522
cpp
ProgressScene.cpp
// // ProgressScene.cpp // DefendRadish // // Created by mac on 18/5/10. // // #include "ProgressScene.hpp" #include "SceneManage.hpp" #include "Constant.h" #include "CocoStudio.h" #include "ui/cocosGUI.h" #include "SceneManage.hpp" using namespace cocos2d; cocos2d::Scene* ProgressScene::createScene() { return ProgressScene::create(); } bool ProgressScene::init() { if(!Scene::init()) { return false; } size = Director::getInstance()->getVisibleSize(); layer =Layer::create(); this->addChild(layer); this->beginScene(); // this->returnTest(); return true; } /* // FileUtils::getInstance()->addSearchPath("Studio"); // node = CSLoader::createNode(ProgressSceneCSB); // this->addChild(node); // this->onEnter(); //void ProgressScene::onEnter() //{ // auto ImageView = static_cast<ui::ImageView*>(node->getChildByName("Image_2")); // auto sprite1 =static_cast<Sprite*>(ImageView->getChildByName("Sprite_1")); // auto Sizesprite1 = sprite1->getContentSize(); // // auto sprite6 =static_cast<Sprite*>(ImageView->getChildByName("Sprite_2")); // auto _rotate=RotateBy::create(4, -360*4); // sprite6 ->runAction(_rotate); // auto NumOne = Sprite::create("countdown_03.png"); // auto Numtwe = Sprite::create("countdown_02.png"); // auto NumThree = Sprite::create("countdown_01.png"); // auto NumGo = Sprite::create("countdown_13.png"); //} */ void ProgressScene::beginScene() { auto backdrop = Sprite::create("Studio/BG1-hd.pvr.png"); backdrop->setPosition(Vec2(size.width/2, size.height/2)); layer->addChild(backdrop); auto countdown = Sprite::create("countdown_11.png"); countdown->setPosition(Vec2(size.width/2, size.height/2)); countdown->setScale(1.2); layer->addChild(countdown); auto countdown1 = Sprite::create("countdown_12.png"); countdown1->setPosition(Vec2(size.width/2, size.height/2)); countdown1->setAnchorPoint(Vec2(1,0.6)); layer->addChild(countdown1); auto _rotate=RotateBy::create(4, -360*4); countdown1->runAction(_rotate); auto NumOne=Sprite::create("countdown_01.png"); NumOne->setTag(11); layer->addChild(NumOne); NumOne->setPosition(Vec2(size.width/2,size.height/2 )); auto blink=Blink::create(1, 1); auto callFunc=CallFunc::create([=]() { layer->removeChildByTag(11); auto NumTwe=Sprite::create("countdown_02.png"); layer->addChild(NumTwe); NumTwe->setTag(22); NumTwe->setPosition(Vec2(size.width/2,size.height/2 )); auto blink2=Blink::create(1, 1); auto callFunc2=CallFunc::create([=]() { layer->removeChildByTag(22); auto NumThree=Sprite::create("countdown_03.png"); layer->addChild(NumThree); NumThree->setTag(33); NumThree->setPosition(Vec2(size.width/2,size.height/2 )); auto blink3=Blink::create(1, 1); auto callFunc3=CallFunc::create([=]() { layer->removeChildByTag(33); auto NumGo=Sprite::create("countdown_13.png"); layer->addChild(NumGo); NumGo->setTag(44); NumGo->setPosition(Vec2(size.width/2,size.height/2 )); auto blink4=Blink::create(1, 1); auto callFunc4=CallFunc::create([=]() { // layer->removeFromParentAndCleanup(true); layer->removeChildByTag(44); SceneManage::gotoGameScene(); }); auto sequence4=Sequence::create(blink4,callFunc4, NULL); NumGo->runAction(sequence4); }); auto sequence3=Sequence::create(blink3,callFunc3, NULL); NumThree->runAction(sequence3); }); auto sequence2=Sequence::create(blink2,callFunc2, NULL); NumTwe->runAction(sequence2); }); auto sequence=Sequence::create(blink,callFunc, NULL); NumOne->runAction(sequence); } void ProgressScene::returnTest() { auto button = ui::Button::create(); button->setTouchEnabled(true); button->setTitleText("返回"); button->setColor(Color3B::RED); button->setPosition(Vec2(240,140)); button->setScale(3); button->addClickEventListener([=](Ref* send){ SceneManage::gotoRadishTestScene(); }); layer->addChild(button); }
c15d99fed0eb2681bd6b106546f9bf5bfe69dfc3
3c3f900dadf850dc7720656a986b3d3db60b14d5
/kaddressbook/plugins/mergelib/autotests/searchandmergecontactduplicatecontactdialogtest.cpp
ea0701c6fc5640b950620eb3a000d27590829536
[ "BSD-3-Clause" ]
permissive
KDE/kdepim-addons
680602d3b8dd1bfecd6e5c5423412cc5bf1b7cbf
d0bff1924db427aae0b6cf40dda52e998293b906
refs/heads/master
2023-09-04T05:08:51.218761
2023-09-04T01:49:13
2023-09-04T01:49:13
46,991,984
11
1
null
null
null
null
UTF-8
C++
false
false
2,635
cpp
searchandmergecontactduplicatecontactdialogtest.cpp
/* SPDX-FileCopyrightText: 2014-2023 Laurent Montel <montel@kde.org> SPDX-License-Identifier: GPL-2.0-or-later */ #include "searchandmergecontactduplicatecontactdialogtest.h" #include "../searchduplicate/searchandmergecontactduplicatecontactdialog.h" #include <QStandardPaths> #include <QTest> #include <QStackedWidget> using namespace KABMergeContacts; SearchAndMergeContactDuplicateContactDialogTest::SearchAndMergeContactDuplicateContactDialogTest(QObject *parent) : QObject(parent) { } void SearchAndMergeContactDuplicateContactDialogTest::initTestCase() { QStandardPaths::setTestModeEnabled(true); } void SearchAndMergeContactDuplicateContactDialogTest::shouldHaveDefaultValueOnCreation() { SearchAndMergeContactDuplicateContactDialog dlg; dlg.show(); auto stackedWidget = dlg.findChild<QStackedWidget *>(QStringLiteral("stackedwidget")); QVERIFY(stackedWidget); QCOMPARE(stackedWidget->currentWidget()->objectName(), QStringLiteral("nocontactselected")); for (int i = 0; i < stackedWidget->count(); ++i) { QWidget *w = stackedWidget->widget(i); const QString objName = w->objectName(); const bool hasGoodNamePage = (objName == QLatin1String("mergecontact") || objName == QLatin1String("nocontactselected") || objName == QLatin1String("nocontactduplicatesfound") || objName == QLatin1String("noenoughcontactselected") || objName == QLatin1String("mergecontactresult") || objName == QLatin1String("selectioninformation")); QVERIFY(hasGoodNamePage); } } void SearchAndMergeContactDuplicateContactDialogTest::shouldShowNoEnoughPageWhenSelectOneContact() { SearchAndMergeContactDuplicateContactDialog dlg; Akonadi::Item::List lst; lst << Akonadi::Item(42); dlg.searchPotentialDuplicateContacts(lst); dlg.show(); auto stackedWidget = dlg.findChild<QStackedWidget *>(QStringLiteral("stackedwidget")); QVERIFY(stackedWidget); QCOMPARE(stackedWidget->currentWidget()->objectName(), QStringLiteral("noenoughcontactselected")); } void SearchAndMergeContactDuplicateContactDialogTest::shouldShowNoContactWhenListIsEmpty() { SearchAndMergeContactDuplicateContactDialog dlg; Akonadi::Item::List lst; dlg.searchPotentialDuplicateContacts(lst); dlg.show(); auto stackedWidget = dlg.findChild<QStackedWidget *>(QStringLiteral("stackedwidget")); QVERIFY(stackedWidget); QCOMPARE(stackedWidget->currentWidget()->objectName(), QStringLiteral("nocontactselected")); } QTEST_MAIN(SearchAndMergeContactDuplicateContactDialogTest)
92ce5dcc42de38c9e0c199a26db8588ce3478498
3eac3a676598dd093504224d1ed97ba5334b4b3c
/Codeforces Round #641 (Div. 2)/A - Orac and Factors.cpp
1cfd4df271ef541f1a41fe322aff490ea98420b4
[]
no_license
jainamandelhi/Competitive-programming-questions
3fd3264062659ba7bf086d97c38c19275113e254
dda005eab0276c6caff0d2bc3bdaf0b12958aeae
refs/heads/master
2021-07-10T11:32:19.463811
2020-06-26T16:23:52
2020-06-26T16:23:52
137,579,279
0
0
null
null
null
null
UTF-8
C++
false
false
1,114
cpp
A - Orac and Factors.cpp
/* Isn't passion overrated?*/ #include<bits/stdc++.h> #define pb push_back #define mp make_pair #define ll long long #define mod 1000000007 using namespace std; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } int main() { ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll t; cin>>t; vector<ll>arr(1000011); for(ll i = 2; i <= sqrt(1000010); i++) { if(arr[i] != 0) continue; for(ll j = 2; i*j <= (1000010); j++){ if(arr[i*j] == 0) arr[i*j] = i; } } while(t--) { ll n,k; cin>>n>>k; while(k) { //cout<<arr[n]<<" "; if(arr[n] == 0) { n += n; k--; n += 2*k; break; } else if(arr[n] == 2) { n += 2*k; break; } else { n += arr[n]; } k--; } cout<<n<<endl; } return 0; }
85f542c0b3c402489f6810a5db688c9f41ca246f
b482d2213c9f38a88e81c45b7421c00b2dbec36e
/6_Chapter_3_DoubleBuffer/mainwindow.h
732720af53e0ac445b460511efdbcfa11026cc8d
[]
no_license
bandaostart/QT5
d400c4bbe15130f08b18b82a9c1d4be8b20131c5
ddc79db78e120013964f822566ff9d36f61925cb
refs/heads/master
2020-04-14T11:37:27.296099
2019-01-16T06:55:13
2019-01-16T06:55:13
163,819,159
1
0
null
null
null
null
UTF-8
C++
false
false
1,234
h
mainwindow.h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QPainter> #include <QMouseEvent> #include <QPaintEvent> #include <QResizeEvent> #include <QColor> #include <QPixmap> #include <QPoint> #include <QPalette> #include <QLabel> #include <QComboBox> #include <QSpinBox> #include <QToolButton> #include <QColorDialog> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); void mouseMoveEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event); void paintEvent(QPaintEvent *); void resizeEvent(QResizeEvent *); void creatToolBar(); public slots: void setStyle(int); void setWidth(int); void setColor(QColor); void setClear(); void ShowStyle(); void ShowColor(); private: Ui::MainWindow *ui; QPixmap *pix; QPoint startPos; QPoint endPos; int style; int weight; QColor color; QLabel *styleLabel; QComboBox *styleComboBox; QLabel *widthLabel; QSpinBox *widthSpinBox; QToolButton *colorBtn; QToolButton *clearBtn; }; #endif // MAINWINDOW_H
4b0e6a161baf5749d32f086a8f17e37688454e4c
f0a860d374cff3c7b142abb3e294d0732dae6148
/Array/quad.cpp
c8f581ab37ada213c904bcf481049de0041f2848
[]
no_license
gari3008ma/Algo-Wiki
84f92020d07962da27e26a1214f7f5bee1df67fd
bc640ee26b8838acfae5bbc522647dbb908ba38e
refs/heads/master
2022-01-05T02:02:35.685934
2019-06-09T16:25:30
2019-06-09T16:25:30
122,847,387
1
0
null
null
null
null
UTF-8
C++
false
false
440
cpp
quad.cpp
#include<bits/stdc++.h> using namespace std; int main() { int t,n,i,arr[1000],j,k,l,sum; cin>>t; while(t--) { cin>>n>>sum; for(i=0;i<n;i++) cin>>arr[i]; for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { for(k=j+1;k<n;k++) { for(l=k+1;l<n;l++) if(sum==(arr[i]+arr[j]+arr[k]+arr[l])) { cout<<arr[i]<<" "<<arr[j]<<" "<<arr[k]<<" "<<arr[l]<<" \n"; break; } } } } } return 0; }
b74a0bd6be2859e1cfaacfd60a43d326767203b7
5a66ab025f1d0f1959eba8b8d077195f1295325d
/manager/executeur_taches/src/CapStation.cpp
4e7a68f4e065b54da2cf2c232b50db07a7785e66
[]
no_license
PyroTeam/robocup-pkg
e07eac96cacb17f2dd3b5232bd39e8f01e7a6535
a38e15f4d1d1c6a2c6660af2ea675c0fa6069c79
refs/heads/devel
2020-12-25T16:54:06.609071
2017-01-07T15:30:13
2017-01-07T15:30:13
26,918,239
9
3
null
2017-01-07T15:30:13
2014-11-20T15:21:22
C++
UTF-8
C++
false
false
3,777
cpp
CapStation.cpp
#include <string> #include "CapStation.h" #include "manager_msg/activity.h" /* Constructeur */ CapStation::CapStation(int teamColor) : Machine(teamColor) { m_name += "CS"; m_faType = FinalApproachingGoal::CS; m_type = "CapStation"; m_blackCap = 0; m_greyCap = 0; m_stockID[0] = 1, m_stockID[1] = 1, m_stockID[2] = 1; m_capID[0] = 1, m_capID[1] = 1, m_capID[2] = 1; } CapStation::CapStation(int teamColor, int number) : CapStation(teamColor) { m_name += std::to_string(number); assert(number >= 1); assert(number <= 2); if (number == 1) { m_activityType = activity::CS1; } else { m_activityType = activity::CS2; } } CapStation::~CapStation(){} int CapStation::getGreyCap() { return m_greyCap; } int CapStation::getBlackCap() { return m_blackCap; } int CapStation::getStockage(int i) { return m_stockID[i]; } void CapStation::majStockID(int i, int val) { m_stockID[i] = val; } void CapStation::majBlack(int nbNoir) { m_blackCap = nbNoir; } void CapStation::majGrey(int nbGris) { m_greyCap = nbGris; } void CapStation::put_cap(int capColor) { ROS_INFO("Putting a Cap, color : %d", capColor); goTo(m_entryMachine); startFinalAp(FinalApproachingGoal::CS, FinalApproachingGoal::IN, FinalApproachingGoal::CONVEYOR); let(); //TODO: demander à la refbox un cap de couleur "color" ) //TODO: attendre fin de livraison //XXX: Retourner qqch pour dire que la tâche est réalisée } void CapStation::take_cap() { goTo(m_exitMachine); startFinalAp(FinalApproachingGoal::CS, FinalApproachingGoal::OUT, FinalApproachingGoal::CONVEYOR); grip(); //XXX: Retourner qqch pour dire que la tâche est réalisée } void CapStation::stock(int id) { int8_t place; ROS_INFO("Stocking @ place : %d", id); goTo(m_entryMachine); if(id == 0) place = FinalApproachingGoal::S1; else if(id == 1) place = FinalApproachingGoal::S2; else if(id == 2) place = FinalApproachingGoal::S3; startFinalAp(FinalApproachingGoal::CS, FinalApproachingGoal::IN, place); let(); majStockID(id, 1); } void CapStation::destock(int id) { int8_t place; ROS_INFO("Destocking @ place : %d", id); goTo(m_entryMachine); if(id == 0) place = FinalApproachingGoal::S1; else if(id == 1) place = FinalApproachingGoal::S2; else if(id == 2) place = FinalApproachingGoal::S3; startFinalAp(FinalApproachingGoal::CS, FinalApproachingGoal::IN, place); let(); majStockID(id, 0); } void CapStation::uncap() { int8_t place; ROS_INFO("Uncaping"); // vérifier si on a déjà uncap avant if(m_capID[0] == 1) { place = FinalApproachingGoal::S1; m_capID[0] == 0; m_stockID[0] = 0; } else if(m_capID[1] == 1) { place = FinalApproachingGoal::S2; m_capID[1] == 0; m_stockID[1] = 0; } else if(m_capID[2] == 1) { place = FinalApproachingGoal::S3; m_capID[2] == 0; m_stockID[2] = 0; } goTo(m_entryMachine); startFinalAp(FinalApproachingGoal::CS, FinalApproachingGoal::IN, place); grip(); startFinalAp(FinalApproachingGoal::CS, FinalApproachingGoal::IN, FinalApproachingGoal::CONVEYOR); let(); //TODO: demander à la refbox de uncap (je sais pas si il faut le demander) // Dire qq part qu'on vient de uncap (voir case orderRequest::BRING_BASE_RS dans GtServerSrv.cpp) //XXX: Retourner qqch pour dire que la tâche est réalisée }
2dfd578600e6216f22c0a069b2b857f0ce247be0
723175a9420efaf6a26aea9dd4e813be8cd8e46a
/source/SceneDeserializeCallback.cpp
e9bce108ffef4634636821b4bc718ec7e8b3f3de
[ "BSL-1.0", "BSD-2-Clause", "Zlib", "MIT" ]
permissive
asdlei99/GTGameEngine
94bb1a19fb3761832cb815b248c40beb57947616
380d1e01774fe6bc2940979e4e5983deef0bf082
refs/heads/master
2022-03-25T10:33:58.551508
2016-12-30T08:55:00
2016-12-30T08:55:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
528
cpp
SceneDeserializeCallback.cpp
// Copyright (C) 2011 - 2014 David Reid. See included LICENCE. #include <GTGE/SceneDeserializeCallback.hpp> namespace GT { SceneDeserializeCallback::SceneDeserializeCallback() { } SceneDeserializeCallback::~SceneDeserializeCallback() { } bool SceneDeserializeCallback::IsChunkHandled(const Serialization::ChunkHeader &) const { return false; } bool SceneDeserializeCallback::HandleChunk(const Serialization::ChunkHeader &, Deserializer &) { return false; } }
2adcd747af7c0cec0ef0887e846cb229edc9137a
0bdc6e9f8df498ea770828e323d004c4a9b0dbbf
/src/naumaxia.cpp
40dd75cb9caa2738117e1ee8e6a0d0f7db259277
[]
no_license
StathisTsirigotis/battleship_simulation
06fb8b3dec68360d07ee3c84959b08f6b143a080
8450dd05feb1807452e2d26a161d95f3e7cc0d68
refs/heads/main
2023-07-22T12:29:11.806903
2021-09-06T13:11:52
2021-09-06T13:11:52
403,624,459
0
0
null
null
null
null
UTF-8
C++
false
false
11,513
cpp
naumaxia.cpp
#include "naumaxia.h" #include "ship.h" #include "episkeuastiko.h" #include "eksereunisis.h" #include "peiratiko.h" #include "emporiko.h" #include "utils.h" #include <iostream> #include <cstdlib> #include <typeinfo> Naumaxia::Naumaxia(int rows, int cols, int num_ship) : rows(rows), cols(cols), num_ships(num_ship), map(rows, std::vector<Cell>(cols)), round_counter(0) { initMap(); populateMap(); } // Initializations void Naumaxia::setWeatherThreshold(int thres) { weather_threshold = thres; } void Naumaxia::setTreasureTarget(int k) { target_treasure=k; } void Naumaxia::initMap() { // Pithanotita thiss: 30% // Pithanotita limani 20% Coords temp; for(int row=0; row<rows; row++) { for(int col=0;col<cols;col++) { int R = rand() % 10; // R = 0-9 if (R < 3) map[row][col].set_thisauros(true); if (R < 2) map[row][col].set_limani(true); map[row][col].set_kairos(R+1); temp.col=col; temp.row = row; map[row][col].set_coords(temp); } } } void Naumaxia::populateMap() { for (int i=0; i<num_ships; i++) { Ship *ship=NULL; // Create a ship of random type int ship_type = rand() % 4; switch (ship_type) { case 0: ship = new Episkeuastiko(this); break; case 1: ship = new Eksereunisis(this); break; case 2: ship = new Peiratiko(this); break; case 3: ship = new Emporiko(this); break; default: break; } int row, col; // Find a random empty spot to place the new ship do { row = rand() % rows; col = rand() % cols; } while (map[row][col].hasShip()); // Set ship coordinates ship->set_row(row); ship->set_col(col); // Add ship to map map[row][col].set_ship(ship); karavia.push_back(ship); } } // Gameplay void Naumaxia::play() { int user_abort=0; do { clrscrn(); std::cout << "Round: " << round_counter << std::endl; //printMap(KARAVI); // Check user if (getAsyncKey() == ' ' ) { // key press detected (SPACEBAR) std::cout << "Simulation paused by key press." << std::endl; user_abort = menu(); } if (user_abort) break; // Execute current round step(); // Slow down for user Sleep(STEP_DELAY_MSEC); } while (alive()); if (user_abort) { std::cout << " - Aborted by user " << std::endl; } else { std::cout << " - Simulation finished " << std::endl; } } void Naumaxia::step() { // A. Actions on round beginning. newRoundActions(); // B. metakinisi(); leitourgia(); // C. Actions on round end. removeDeadShips(); updateWeather(); round_counter++; } bool Naumaxia::alive() { if (getActiveShipNumber() <= 0) return false; bool winner_flag = false; for (int i=0; i<karavia.size(); i++) { if (karavia[i]->get_apo8ema() >= target_treasure) { std::cout << "Winner: " << *karavia[i] << std::endl; winner_flag = true; } } if (winner_flag) return false; else return true; } void Naumaxia::newRoundActions() { for(int row=0; row<rows; row++) { for(int col=0;col<cols;col++) { if (map[row][col].hasShip()) { // Apply weather damage if (map[row][col].get_kairos() > weather_threshold) { Ship *ship = map[row][col].get_ship(); ship->dec_antoxi(1); } // Steal treasure if (map[row][col].get_thisauros()) { Ship *ship = map[row][col].get_ship(); ship->inc_apo8ema(1); map[row][col].set_thisauros(false); } } if (map[row][col].get_limani()) { // Search the 8 neighbor cells and apply rules std::vector<Ship*> geitones; geitones = getNeighbours(row,col); if(geitones.size()>0) { for(int i = 0; i != geitones.size(); i++) { //An einai peiratiko, afairesh antoxhs if( typeid(*geitones[i]) == typeid(Peiratiko) ) { geitones[i]->dec_antoxi((int)(geitones[i]->get_antoxi()*LIM_ZIMIA_EPISKEUI_POSOSTO/100.0)); } //Alliws, auksisi antoxis an xreiazetai episkeui else if(geitones[i]->get_antoxi() < geitones[i]->get_megisti_antoxi()) { geitones[i]->inc_antoxi((int)(geitones[i]->get_antoxi()*LIM_ZIMIA_EPISKEUI_POSOSTO/100.0)); //An i antoxi kseperase to megisto, epanafora } } } } } } } void Naumaxia::removeDeadShips() { for (int i=0; i<karavia.size(); i++) { Ship &ship = *karavia[i]; if (ship.get_antoxi()<0) { int x = ship.get_row(); int y = ship.get_col(); map[x][y].set_ship(NULL); delete &ship; num_ships--; karavia.erase(karavia.begin()+i); // This causes vector size to decrease i--; } } } void Naumaxia::updateWeather() { for(int row=0; row<rows; row++) { for(int col=0;col<cols;col++) { int inc_or_dec = (rand() % 2) ? 1 : -1; map[row][col].set_kairos(map[row][col].get_kairos() + inc_or_dec); } } } void Naumaxia::metakinisi() { for (int i=0; i<karavia.size(); i++) { int row = karavia[i]->get_row(); int col = karavia[i]->get_col(); // Diagrafi ship apo palia thesi map[row][col].set_ship(NULL); // Metakinisi ship karavia[i]->metakinisi(); // Tropopoiisi map[][] symfwna // me tin nea thesi tou karaviou. row = karavia[i]->get_row(); col = karavia[i]->get_col(); map[row][col].set_ship(karavia[i]); } } void Naumaxia::leitourgia() { for (int i=0; i<karavia.size(); i++) { karavia[i]->leitourgia(); int row = karavia[i]->get_row(); int col = karavia[i]->get_col(); map[row][col].set_ship(karavia[i]); } } // Status bool Naumaxia::validLocation(int r, int c) const { return !( r<0 || c<0 || r>=rows || c>=cols); } int Naumaxia::getActiveShipNumber() { return num_ships; } void Naumaxia::printMap(CellAttribute p) { std::cout << " "; for(int col=0;col<cols;col++) std::cout << "|" << col; std::cout << "|" << std::endl << "--"; for(int col=0;col<cols+1;col++) std::cout << "--"; std::cout << std::endl; for(int row=0; row<rows; row++) { std::cout << row << " "; for(int col=0;col<cols;col++) { if (p==THISAUROS) std::cout << (map[row][col].get_thisauros()?"|T":"| "); else if (p==LIMANI) std::cout<< (map[row][col].get_limani()?"|L":"| "); else if (p==KAIROS) std::cout << "|" << map[row][col].get_kairos()-1; else if (p==KARAVI) { if (map[row][col].hasShip()) std::cout << "|" << map[row][col].get_ship()->getCharCode(); else std::cout << "| "; } else return; } std::cout << "|" << std::endl; } std::cout << std::endl; } std::vector<Cell*> Naumaxia::getNeighbourCells(const int row, const int col) { std::vector<Cell*> neighbour_cells; Cell* temp; for(int r=row-1 ; r<row+2 ; r++) { for(int c=col-1 ; c<col+2 ; c++) { // Elegxos ektos oriwn if ( !validLocation(r,c)) continue; // Elegxos me tin kentriki thesi if ( r==row && c==col) continue; temp = &map[r][c]; neighbour_cells.push_back(temp); } } return neighbour_cells; } std::vector<Coords> Naumaxia::getFreeNeigbourCells(const int row, const int col) { std::vector<Coords> avail_cells; Coords coords; for(int r=row-1 ; r<row+2 ; r++) { for(int c=col-1 ; c<col+2 ; c++) { // Elegxos ektos oriwn if ( !validLocation(r,c)) continue; // Elegxos me tin kentriki thesi if ( r==row && c==col) continue; // Elegox yparksis ploiou if (map[r][c].hasShip()) continue; coords.col=c; coords.row=r; avail_cells.push_back(coords); } } return avail_cells; } std::vector<Ship*> Naumaxia::getNeighbours(const int row, const int col) { std::vector<Ship*> neighbours; Ship* temp; for(int r=row-1 ; r<row+2 ; r++) { for(int c=col-1 ; c<col+2 ; c++) { // Elegxos ektos oriwn if ( !validLocation(r,c)) continue; // Elegxos me tin kentriki thesi if ( r==row && c==col) continue; // Elegox yparksis ploiou if (!map[r][c].hasShip()) continue; temp = map[r][c].get_ship(); neighbours.push_back(temp); } } return neighbours; } Cell* Naumaxia::getCell(const int row, const int col) { return &map[row][col]; } // UI int Naumaxia::menu() { std::cout << " --- MENU ---" << std::endl; std::cout << " - Gia exodo, patiste 'E' " << std::endl; std::cout << " - Gia synexeia, patiste SPACE " << std::endl; std::cout << " - Gia na deite ta ploia, patiste 'P' " << std::endl; std::cout << " Gia na deite ton thissauro, patiste 'T' " << std::endl; std::cout << " Gia na deite ton kairo, patiste 'K' " << std::endl; std::cout << " Gia na deite ta limania, patiste 'L' " << std::endl; std::cout << " - Gia plirofories sxetika me:" << std::endl; std::cout << " Karavi, patiste 'I' " << std::endl; std::cout << " Simeio xarti, patiste 'M'" << std::endl; std::cout << " Genikes prosomoiwsis, patiste 'G'" << std::endl; std::cout << std::endl; while (1) { int x,y; int k = tolower(getch()); switch (k) { case 'p': printMap(KARAVI);break; case 't': printMap(THISAUROS);break; case 'k': printMap(KAIROS);break; case 'l': printMap(LIMANI);break; case 'i': printf("Enter [row col]: "); scanf("%d %d", &x, &y); if (validLocation(x,y) && map[x][y].hasShip()) std::cout << *map[x][y].get_ship(); else printf("No ship in [%d, %d] \n", x, y); break; case 'm': printf("Enter [row col]: "); scanf("%d %d", &x, &y); if (validLocation(x,y)) std::cout << map[x][y]; else printf("Invalid location \n", x, y); break; case 'g': std::cout << "Total ships created : " << Ship::get_total_created_counter() << std::endl; std::cout << "Total ships died : " << Ship::get_total_created_died() << std::endl; std::cout << "Total active ships : " << karavia.size() << std::endl; break; case 'e': return 1; case ' ': return 0; } } return 0; }
097cff542ad0315d6075fab9f6945d6d421aaf4f
6158c19a5f7f74aee8c8ca504f87c783a887a99b
/src/FileExplorer.hpp
0e5ddb49151fe234116192bb3870ff20ebe5e2fc
[]
no_license
Motherboard/mp3_gui
0f1c7effabae07b00753367e60d3ddf514bb184a
c8ebfe5b2f26751d09aad61c671f4fe0b9a78767
refs/heads/main
2023-05-24T03:37:14.152625
2021-06-13T19:30:40
2021-06-13T19:30:40
376,624,685
0
0
null
null
null
null
UTF-8
C++
false
false
627
hpp
FileExplorer.hpp
#pragma once #include <vector> #include <string> #include <cstdio> #include <experimental/filesystem> enum class SeekMode { Relative, Absolute }; class FileExplorer { std::vector<unsigned> _line_offsets; std::experimental::filesystem::path _current_path{"/"}; FILE * _sorted_entries_in_dir = nullptr; uint16_t _current_idx = 0; public: FileExplorer(); ~FileExplorer(); void set_dir(const std::string & dir_name, SeekMode seek_mode); std::string get_dir(); std::string next_file_name(); std::string seek_file_name(int offset_idx, SeekMode seek_mode); };
69a690a710ee8ff3e1b6f550d617d3b5e4b71cf4
a0604bbb76abbb42cf83e99f673134c80397b92b
/fldserver/base/task/sequence_manager/sequenced_task_source.h
9480fced748d6e18f69e4b66aa117cee12e78fbb
[ "BSD-3-Clause" ]
permissive
Hussam-Turjman/FLDServer
816910da39b6780cfd540fa1e79c84a03c57a488
ccc6e98d105cfffbf44bfd0a49ee5dcaf47e9ddb
refs/heads/master
2022-07-29T20:59:28.954301
2022-07-03T12:02:42
2022-07-03T12:02:42
461,034,667
2
0
null
null
null
null
UTF-8
C++
false
false
2,185
h
sequenced_task_source.h
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_TASK_SEQUENCE_MANAGER_SEQUENCED_TASK_SOURCE_H_ #define BASE_TASK_SEQUENCE_MANAGER_SEQUENCED_TASK_SOURCE_H_ #include "fldserver/base/optional.h" #include "fldserver/base/pending_task.h" #include "fldserver/base/task/sequence_manager/lazy_now.h" #include "fldserver/base/task/sequence_manager/tasks.h" namespace base { namespace sequence_manager { namespace internal { // Interface to pass tasks to ThreadController. class SequencedTaskSource { public: enum class SelectTaskOption { kDefault, kSkipDelayedTask }; virtual ~SequencedTaskSource() = default; // Returns the next task to run from this source or nullptr if // there're no more tasks ready to run. If a task is returned, // DidRunTask() must be invoked before the next call to SelectNextTask(). // |option| allows control on which kind of tasks can be selected. virtual Task* SelectNextTask(SelectTaskOption option = SelectTaskOption::kDefault) = 0; // Notifies this source that the task previously obtained // from SelectNextTask() has been completed. virtual void DidRunTask() = 0; // Returns the delay till the next task or TimeDelta::Max() // if there are no tasks left. |option| allows control on which kind of tasks // can be selected. virtual TimeDelta DelayTillNextTask(LazyNow* lazy_now, SelectTaskOption option = SelectTaskOption::kDefault) const = 0; // Return true if there are any pending tasks in the task source which require // high resolution timing. virtual bool HasPendingHighResolutionTasks() = 0; // Called when we have run out of immediate work. If more immediate work // becomes available as a result of any processing done by this callback, // return true to schedule a future DoWork. virtual bool OnSystemIdle() = 0; }; } // namespace internal } // namespace sequence_manager } // namespace base #endif // BASE_TASK_SEQUENCE_MANAGER_SEQUENCED_TASK_SOURCE_H_
09bc229d2f758ae4313df4c8a3deb12c4dc4579d
26cc428b3d87f0cd0f1a2e6a51e9da25cd0b651a
/inflowPosition/Blasius_5/linear/0.25/p
a2aaf9aa4df987c50e5db505b67467568ee71e65
[]
no_license
CagriMetin/BlasiusProblem
8f4fe708df8f3332d054b233d99a33fbb3c15c2a
32c4aafd6ddd6ba4c39aef04d01b77a9106125b2
refs/heads/master
2020-12-24T19:37:14.665700
2016-12-27T19:13:04
2016-12-27T19:13:04
57,833,097
0
0
null
null
null
null
UTF-8
C++
false
false
37,988
p
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.3.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0.25"; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField nonuniform List<scalar> 2889 ( 0.00267942 0.00239986 0.00181159 0.00123794 0.00075323 0.000340613 -9.67079e-06 -0.000283392 -0.00046182 -0.000546884 -0.000561863 -0.000536782 -0.000496017 -0.000454677 -0.000420112 -0.000394399 -0.000376676 -0.000364944 -0.000357159 -0.000351688 -0.000347404 -0.000343621 -0.000339985 -0.000336339 -0.000332628 -0.000328836 -0.000324985 -0.000321128 -0.000317335 -0.000313643 -0.000310049 -0.000306529 -0.000303071 -0.00029969 -0.000296398 -0.000293185 -0.000290017 -0.000286866 -0.000283726 -0.000280583 -0.000277416 -0.000274188 -0.000270857 -0.000267392 -0.000263781 -0.000260012 -0.000256049 -0.000251836 -0.000247291 -0.00024233 -0.00023689 -0.00023094 -0.000224451 -0.000217391 -0.000209729 -0.000201439 -0.000192498 -0.000182913 -0.000172753 -0.000162135 -0.000151311 -0.000140451 -0.00012983 -0.000119618 -0.000109932 -0.000100815 -9.22984e-05 -8.43735e-05 -7.7048e-05 -7.03258e-05 -6.4192e-05 -5.8611e-05 -5.35279e-05 -4.88882e-05 -4.4638e-05 -4.07341e-05 -3.71364e-05 -3.38104e-05 -3.07235e-05 -2.78563e-05 -2.52005e-05 -2.2768e-05 -2.05742e-05 -1.86374e-05 -1.6954e-05 -1.55074e-05 -1.4251e-05 -1.31378e-05 -1.21048e-05 -1.11138e-05 -1.01217e-05 -9.12117e-06 -8.09317e-06 -7.05403e-06 -5.99215e-06 -4.93121e-06 -3.85276e-06 -2.77829e-06 -1.67833e-06 -5.71522e-07 0.0022528 0.0021068 0.00169728 0.00120462 0.000748287 0.000355673 2.66776e-05 -0.000229571 -0.000402257 -0.000492302 -0.000516903 -0.000501657 -0.000469393 -0.000434749 -0.000405158 -0.000382902 -0.000367457 -0.000357202 -0.000350401 -0.00034563 -0.000341884 -0.000338548 -0.000335302 -0.000332009 -0.00032862 -0.000325122 -0.000321535 -0.000317916 -0.000314339 -0.000310849 -0.000307442 -0.000304092 -0.00030079 -0.000297552 -0.000294396 -0.000291313 -0.000288268 -0.000285232 -0.000282199 -0.000279161 -0.000276095 -0.000272964 -0.000269726 -0.000266348 -0.000262821 -0.000259134 -0.000255253 -0.000251122 -0.000246658 -0.000241773 -0.000236406 -0.000230526 -0.000224104 -0.000217107 -0.000209504 -0.000201269 -0.00019238 -0.000182843 -0.00017272 -0.000162158 -0.000151326 -0.000140473 -0.00012986 -0.000119648 -0.000109962 -0.000100843 -9.23231e-05 -8.43926e-05 -7.70608e-05 -7.03331e-05 -6.41958e-05 -5.86135e-05 -5.35301e-05 -4.88906e-05 -4.46406e-05 -4.07371e-05 -3.714e-05 -3.38148e-05 -3.07281e-05 -2.78602e-05 -2.52024e-05 -2.27673e-05 -2.05705e-05 -1.86316e-05 -1.69474e-05 -1.55014e-05 -1.42463e-05 -1.31356e-05 -1.21048e-05 -1.11157e-05 -1.01245e-05 -9.12454e-06 -8.09613e-06 -7.05676e-06 -5.99404e-06 -4.93279e-06 -3.85362e-06 -2.7788e-06 -1.67811e-06 -5.71409e-07 0.00195688 0.00186821 0.00158697 0.00118108 0.000764504 0.000396418 9.20107e-05 -0.000145151 -0.000312502 -0.000411508 -0.000452697 -0.000454277 -0.000435562 -0.000411088 -0.000388472 -0.000370563 -0.000357625 -0.000348774 -0.000342802 -0.000338597 -0.000335315 -0.00033241 -0.000329584 -0.000326705 -0.000323718 -0.0003206 -0.000317366 -0.000314068 -0.00031078 -0.000307552 -0.000304381 -0.000301244 -0.000298134 -0.000295069 -0.000292072 -0.000289138 -0.00028623 -0.000283321 -0.000280407 -0.00027748 -0.00027452 -0.000271493 -0.000268354 -0.000265069 -0.000261631 -0.000258031 -0.000254237 -0.000250192 -0.000245813 -0.000241011 -0.000235722 -0.000229915 -0.000223566 -0.000216641 -0.000209108 -0.000200941 -0.000192115 -0.00018263 -0.000172548 -0.000162006 -0.000151193 -0.00014037 -0.000129754 -0.000119558 -0.00010989 -0.000100782 -9.22771e-05 -8.4351e-05 -7.70189e-05 -7.02901e-05 -6.41529e-05 -5.85725e-05 -5.34923e-05 -4.88572e-05 -4.4611e-05 -4.0711e-05 -3.71173e-05 -3.37953e-05 -3.07107e-05 -2.78436e-05 -2.51847e-05 -2.27475e-05 -2.05485e-05 -1.8609e-05 -1.69259e-05 -1.54837e-05 -1.42338e-05 -1.31278e-05 -1.21014e-05 -1.1116e-05 -1.01265e-05 -9.12788e-06 -8.09919e-06 -7.0601e-06 -5.99646e-06 -4.93586e-06 -3.85606e-06 -2.78249e-06 -1.68067e-06 -5.75113e-07 0.00175364 0.00168029 0.00147468 0.00114747 0.000780445 0.000442014 0.000160204 -6.01765e-05 -0.000220709 -0.000324514 -0.000378812 -0.000396206 -0.000391747 -0.000378214 -0.000363411 -0.000350887 -0.000341597 -0.000335224 -0.000330978 -0.000328038 -0.000325747 -0.000323668 -0.000321562 -0.000319324 -0.000316915 -0.000314325 -0.00031157 -0.000308702 -0.000305795 -0.000302898 -0.00030002 -0.000297148 -0.000294277 -0.000291426 -0.000288624 -0.00028587 -0.000283131 -0.000280378 -0.000277606 -0.000274812 -0.000271978 -0.000269071 -0.000266047 -0.000262875 -0.000259547 -0.000256053 -0.000252363 -0.00024842 -0.000244144 -0.000239442 -0.000234251 -0.000228544 -0.000222295 -0.000215471 -0.000208041 -0.000199978 -0.000191257 -0.000181876 -0.000171892 -0.00016144 -0.000150708 -0.00013996 -0.000129423 -0.000119294 -0.000109677 -0.000100638 -9.21552e-05 -8.42484e-05 -7.69266e-05 -7.02038e-05 -6.40724e-05 -5.84963e-05 -5.34229e-05 -4.8793e-05 -4.45528e-05 -4.06583e-05 -3.707e-05 -3.3753e-05 -3.06721e-05 -2.78067e-05 -2.51473e-05 -2.27085e-05 -2.0508e-05 -1.85689e-05 -1.68888e-05 -1.54525e-05 -1.42095e-05 -1.31115e-05 -1.20916e-05 -1.11118e-05 -1.01254e-05 -9.12919e-06 -8.10098e-06 -7.06307e-06 -5.99921e-06 -4.94042e-06 -3.86057e-06 -2.79007e-06 -1.68692e-06 -5.83947e-07 0.0015922 0.00152239 0.0013601 0.00109721 0.000783226 0.000478923 0.000219213 1.3568e-05 -0.000139729 -0.000244897 -0.00030777 -0.000337364 -0.00034503 -0.000341412 -0.000334016 -0.000326862 -0.000321453 -0.000317895 -0.000315718 -0.00031434 -0.000313281 -0.000312221 -0.000310989 -0.000309521 -0.000307805 -0.000305848 -0.000303673 -0.000301332 -0.000298892 -0.000296405 -0.000293889 -0.000291342 -0.000288768 -0.000286186 -0.000283622 -0.000281083 -0.000278541 -0.00027597 -0.000273365 -0.000270725 -0.000268033 -0.000265258 -0.000262361 -0.000259312 -0.000256104 -0.000252729 -0.000249153 -0.000245321 -0.000241156 -0.00023657 -0.0002315 -0.000225917 -0.000219797 -0.000213113 -0.000205832 -0.00019793 -0.000189382 -0.000180183 -0.000170385 -0.000160115 -0.000149566 -0.000138991 -0.000128622 -0.000118651 -0.000109179 -0.000100255 -9.18647e-05 -8.40181e-05 -7.67328e-05 -7.00321e-05 -6.39158e-05 -5.83527e-05 -5.32916e-05 -4.86744e-05 -4.44463e-05 -4.05631e-05 -3.69853e-05 -3.36777e-05 -3.06037e-05 -2.7742e-05 -2.50829e-05 -2.26423e-05 -2.04399e-05 -1.85009e-05 -1.68239e-05 -1.53943e-05 -1.41602e-05 -1.30725e-05 -1.20618e-05 -1.10902e-05 -1.01097e-05 -9.11853e-06 -8.09316e-06 -7.05885e-06 -5.9967e-06 -4.94221e-06 -3.86386e-06 -2.79938e-06 -1.69584e-06 -5.98335e-07 0.00145384 0.00138578 0.00125026 0.00103666 0.000772877 0.000504984 0.000267885 7.58038e-05 -7.04273e-05 -0.00017483 -0.000242822 -0.000281346 -0.000298885 -0.000303996 -0.000303449 -0.000301406 -0.000299764 -0.000298993 -0.0002989 -0.000299113 -0.000299308 -0.000299278 -0.000298924 -0.000298224 -0.000297198 -0.000295873 -0.00029428 -0.000292469 -0.000290504 -0.000288438 -0.000286297 -0.000284089 -0.000281822 -0.000279517 -0.000277197 -0.000274874 -0.000272533 -0.000270148 -0.00026771 -0.000265222 -0.000262671 -0.000260025 -0.000257248 -0.000254317 -0.000251226 -0.000247964 -0.000244497 -0.00024077 -0.000236713 -0.000232248 -0.000227311 -0.00022187 -0.000215904 -0.00020939 -0.000202301 -0.00019461 -0.000186298 -0.000177362 -0.000167846 -0.000157863 -0.0001476 -0.000137296 -0.000127192 -0.000117474 -0.000108239 -9.95168e-05 -9.1289e-05 -8.3561e-05 -7.63572e-05 -6.97102e-05 -6.36301e-05 -5.8095e-05 -5.30579e-05 -4.84629e-05 -4.4256e-05 -4.03939e-05 -3.68364e-05 -3.35475e-05 -3.0489e-05 -2.7638e-05 -2.49839e-05 -2.25436e-05 -2.03386e-05 -1.83972e-05 -1.67199e-05 -1.52938e-05 -1.40666e-05 -1.29888e-05 -1.19886e-05 -1.10283e-05 -1.00575e-05 -9.07608e-06 -8.05809e-06 -7.03226e-06 -5.97589e-06 -4.93023e-06 -3.85674e-06 -2.80285e-06 -1.70215e-06 -6.15698e-07 0.00133205 0.00126635 0.00114976 0.000973521 0.000753154 0.000520876 0.000307068 0.000128506 -1.07554e-05 -0.000113338 -0.000184148 -0.00022897 -0.000254332 -0.000266969 -0.000272676 -0.000275446 -0.000277401 -0.000279322 -0.000281271 -0.000283069 -0.000284531 -0.000285545 -0.000286075 -0.000286145 -0.000285804 -0.000285098 -0.00028407 -0.000282774 -0.000281269 -0.000279609 -0.00027783 -0.000275946 -0.000273969 -0.000271923 -0.000269831 -0.000267707 -0.000265546 -0.000263326 -0.000261032 -0.000258674 -0.000256245 -0.000253712 -0.000251039 -0.000248207 -0.000245211 -0.00024204 -0.000238663 -0.000235023 -0.000231057 -0.000226702 -0.000221898 -0.000216602 -0.000210798 -0.00020447 -0.000197592 -0.000190144 -0.000182111 -0.000173496 -0.000164335 -0.000154725 -0.000144835 -0.000134895 -0.000125136 -0.000115741 -0.000106803 -9.83429e-05 -9.03401e-05 -8.27941e-05 -7.57283e-05 -6.91804e-05 -6.31695e-05 -5.76854e-05 -5.26883e-05 -4.81277e-05 -4.39531e-05 -4.0123e-05 -3.65973e-05 -3.33393e-05 -3.03091e-05 -2.74816e-05 -2.48439e-05 -2.24123e-05 -2.02087e-05 -1.82641e-05 -1.65818e-05 -1.51521e-05 -1.39238e-05 -1.28495e-05 -1.18558e-05 -1.09061e-05 -9.94676e-06 -8.9795e-06 -7.97427e-06 -6.96357e-06 -5.91909e-06 -4.88898e-06 -3.82594e-06 -2.78902e-06 -1.69695e-06 -6.29942e-07 0.00122387 0.00116132 0.00105963 0.000911988 0.000727356 0.00052764 0.000337119 0.000172584 4.06022e-05 -5.9473e-05 -0.000131583 -0.000180679 -0.000212024 -0.000230929 -0.00024218 -0.000249383 -0.000254722 -0.000259206 -0.000263133 -0.000266496 -0.000269233 -0.000271312 -0.000272747 -0.000273599 -0.000273948 -0.000273861 -0.000273393 -0.000272603 -0.000271548 -0.000270283 -0.000268854 -0.000267282 -0.000265582 -0.000263782 -0.000261904 -0.000259965 -0.00025797 -0.000255894 -0.000253727 -0.000251481 -0.000249158 -0.00024672 -0.000244134 -0.000241385 -0.000238467 -0.000235371 -0.000232067 -0.000228496 -0.000224606 -0.000220348 -0.000215667 -0.000210515 -0.000204874 -0.000198736 -0.00019208 -0.000184886 -0.000177149 -0.000168879 -0.000160108 -0.000150921 -0.000141468 -0.000131952 -0.000122587 -0.000113548 -0.000104932 -9.67613e-05 -8.90188e-05 -8.16984e-05 -7.48187e-05 -6.84157e-05 -6.25131e-05 -5.71091e-05 -5.21732e-05 -4.76628e-05 -4.35326e-05 -3.97446e-05 -3.62598e-05 -3.30425e-05 -3.00521e-05 -2.72623e-05 -2.46565e-05 -2.22488e-05 -2.00582e-05 -1.81165e-05 -1.64283e-05 -1.49883e-05 -1.37484e-05 -1.26659e-05 -1.16683e-05 -1.07219e-05 -9.77046e-06 -8.81792e-06 -7.82859e-06 -6.83881e-06 -5.81262e-06 -4.80555e-06 -3.75996e-06 -2.74754e-06 -1.67193e-06 -6.34223e-07 0.0011273 0.00106838 0.000979035 0.000853672 0.000697872 0.000526601 0.0003584 0.000208341 8.42533e-05 -1.26311e-05 -8.49367e-05 -0.000136763 -0.000172494 -0.000196402 -0.000212376 -0.000223541 -0.000231996 -0.000238888 -0.000244701 -0.000249585 -0.000253584 -0.000256732 -0.000259083 -0.000260725 -0.000261769 -0.000262303 -0.000262392 -0.000262098 -0.000261485 -0.000260611 -0.000259527 -0.000258262 -0.000256836 -0.000255274 -0.000253603 -0.000251845 -0.000250009 -0.000248074 -0.000246025 -0.000243885 -0.00024166 -0.000239309 -0.000236802 -0.000234127 -0.000231281 -0.000228255 -0.000225018 -0.000221512 -0.000217691 -0.000213525 -0.000208963 -0.000203953 -0.000198477 -0.000192532 -0.000186101 -0.000179167 -0.00017173 -0.000163808 -0.000155436 -0.00014669 -0.000137698 -0.000128636 -0.000119693 -0.000111031 -0.000102747 -9.48718e-05 -8.73967e-05 -8.03183e-05 -7.36513e-05 -6.74264e-05 -6.16656e-05 -5.63718e-05 -5.15213e-05 -4.70799e-05 -4.3008e-05 -3.92718e-05 -3.58347e-05 -3.26639e-05 -2.97199e-05 -2.69776e-05 -2.44175e-05 -2.20501e-05 -1.98887e-05 -1.79629e-05 -1.62753e-05 -1.48246e-05 -1.35657e-05 -1.24636e-05 -1.14488e-05 -1.04941e-05 -9.54156e-06 -8.59903e-06 -7.62449e-06 -6.65797e-06 -5.65455e-06 -4.67647e-06 -3.65523e-06 -2.67433e-06 -1.62395e-06 -6.25167e-07 0.00104057 0.000985472 0.000906544 0.000798963 0.00066639 0.000519333 0.000371707 0.000236155 0.000120618 2.76853e-05 -4.38952e-05 -9.72569e-05 -0.000136042 -0.000163767 -0.0001836 -0.000198186 -0.000209447 -0.000218561 -0.000226146 -0.000232482 -0.000237704 -0.000241903 -0.000245163 -0.000247593 -0.000249329 -0.000250479 -0.000251117 -0.00025131 -0.000251133 -0.000250648 -0.000249908 -0.000248946 -0.00024779 -0.000246467 -0.000245 -0.000243422 -0.00024175 -0.000239954 -0.000238024 -0.000235991 -0.000233862 -0.000231598 -0.000229171 -0.000226573 -0.000223798 -0.000220842 -0.000217675 -0.00021424 -0.000210494 -0.000206423 -0.000201982 -0.000197116 -0.000191807 -0.00018606 -0.000179858 -0.000173186 -0.000166052 -0.000158479 -0.000150503 -0.000142193 -0.000133662 -0.000125061 -0.000116553 -0.000108281 -0.000100337 -9.2758e-05 -8.55501e-05 -7.87172e-05 -7.22732e-05 -6.62436e-05 -6.06467e-05 -5.54861e-05 -5.0743e-05 -4.63898e-05 -4.23914e-05 -3.87183e-05 -3.53361e-05 -3.22161e-05 -2.9322e-05 -2.66322e-05 -2.41261e-05 -2.18112e-05 -1.96938e-05 -1.77988e-05 -1.61234e-05 -1.46682e-05 -1.33901e-05 -1.22628e-05 -1.12211e-05 -1.02472e-05 -9.28371e-06 -8.34358e-06 -7.37953e-06 -6.4348e-06 -5.45576e-06 -4.5096e-06 -3.518e-06 -2.57359e-06 -1.55674e-06 -6.04365e-07 0.000962102 0.000910827 0.000840803 0.000747736 0.000634056 0.000507385 0.000378185 0.000256664 0.000150135 6.19094e-05 -8.10252e-06 -6.20281e-05 -0.00010278 -0.000133276 -0.000156133 -0.000173566 -0.000187276 -0.000198399 -0.000207619 -0.000215315 -0.000221699 -0.000226906 -0.000231049 -0.00023425 -0.000236663 -0.000238417 -0.000239594 -0.000240267 -0.000240515 -0.000240413 -0.000240014 -0.000239352 -0.000238465 -0.000237382 -0.000236122 -0.000234725 -0.000233217 -0.000231566 -0.000229755 -0.000227832 -0.000225808 -0.000223636 -0.00022129 -0.000218773 -0.000216075 -0.000213193 -0.000210103 -0.000206748 -0.000203089 -0.000199119 -0.000194804 -0.00019009 -0.000184956 -0.00017941 -0.00017344 -0.000167037 -0.000160209 -0.000152982 -0.000145395 -0.000137512 -0.000129434 -0.000121291 -0.000113218 -0.000105339 -9.77382e-05 -9.04612e-05 -8.35242e-05 -7.69398e-05 -7.07234e-05 -6.48974e-05 -5.94765e-05 -5.44646e-05 -4.98456e-05 -4.55969e-05 -4.16866e-05 -3.80884e-05 -3.47698e-05 -3.17063e-05 -2.88656e-05 -2.62312e-05 -2.37834e-05 -2.15284e-05 -1.94652e-05 -1.76128e-05 -1.59614e-05 -1.45112e-05 -1.32196e-05 -1.2068e-05 -1.09968e-05 -9.99803e-06 -9.01694e-06 -8.0726e-06 -7.11442e-06 -6.18808e-06 -5.23298e-06 -4.31888e-06 -3.36019e-06 -2.45476e-06 -1.478e-06 -5.76226e-07 0.000890577 0.000843021 0.000780692 0.000699693 0.00060159 0.000492058 0.000379056 0.00027069 0.000173307 9.04164e-05 2.27494e-05 -3.09042e-05 -7.27257e-05 -0.000105103 -0.000130217 -0.000149923 -0.000165692 -0.000178578 -0.000189275 -0.000198216 -0.000205674 -0.00021183 -0.000216809 -0.000220745 -0.00022381 -0.000226147 -0.000227852 -0.000228994 -0.000229652 -0.00022992 -0.00022986 -0.000229497 -0.000228873 -0.000228027 -0.000226976 -0.000225761 -0.00022442 -0.000222917 -0.00022123 -0.000219419 -0.000217505 -0.000215433 -0.000213174 -0.00021074 -0.000208129 -0.00020533 -0.000202322 -0.000199057 -0.000195498 -0.00019164 -0.000187457 -0.000182903 -0.000177953 -0.000172613 -0.00016688 -0.000160749 -0.000154229 -0.000147348 -0.000140145 -0.000132683 -0.000125048 -0.00011735 -0.000109704 -0.000102216 -9.49633e-05 -8.79952e-05 -8.13362e-05 -7.50059e-05 -6.90217e-05 -6.34049e-05 -5.8168e-05 -5.33153e-05 -4.88328e-05 -4.47015e-05 -4.08919e-05 -3.73799e-05 -3.41342e-05 -3.11341e-05 -2.83518e-05 -2.57764e-05 -2.33902e-05 -2.1199e-05 -1.9196e-05 -1.7394e-05 -1.57759e-05 -1.43399e-05 -1.3043e-05 -1.18729e-05 -1.07754e-05 -9.75175e-06 -8.75155e-06 -7.79965e-06 -6.84452e-06 -5.93329e-06 -5.00104e-06 -4.11764e-06 -3.19345e-06 -2.32762e-06 -1.3952e-06 -5.45015e-07 0.000824906 0.000780923 0.000725311 0.000654493 0.000569403 0.000474334 0.000375432 0.000279111 0.0001907 0.000113563 4.89142e-05 -3.72772e-06 -4.58603e-05 -7.93649e-05 -0.000106054 -0.000127481 -0.000144904 -0.000159279 -0.000171267 -0.000181316 -0.000189741 -0.000196762 -0.000202516 -0.000207142 -0.000210822 -0.000213712 -0.000215919 -0.000217514 -0.00021857 -0.00021919 -0.000219456 -0.000219393 -0.000219029 -0.000218412 -0.000217567 -0.000216535 -0.00021536 -0.000214011 -0.000212456 -0.000210756 -0.000208952 -0.00020699 -0.000204826 -0.000202478 -0.000199959 -0.000197254 -0.000194337 -0.000191171 -0.000187725 -0.000183988 -0.000179947 -0.000175561 -0.000170803 -0.000165675 -0.000160185 -0.000154331 -0.000148121 -0.000141583 -0.000134762 -0.000127714 -0.00012051 -0.000113244 -0.000106015 -9.89158e-05 -9.2015e-05 -8.53623e-05 -7.89887e-05 -7.2919e-05 -6.71729e-05 -6.17712e-05 -5.67255e-05 -5.20406e-05 -4.77048e-05 -4.37017e-05 -4.00036e-05 -3.65877e-05 -3.34241e-05 -3.04955e-05 -2.7778e-05 -2.52661e-05 -2.2945e-05 -2.08205e-05 -1.88812e-05 -1.71344e-05 -1.55563e-05 -1.41424e-05 -1.28489e-05 -1.16681e-05 -1.05511e-05 -9.50675e-06 -8.48995e-06 -7.53043e-06 -6.5778e-06 -5.67967e-06 -4.76934e-06 -3.91499e-06 -3.02583e-06 -2.1992e-06 -1.31313e-06 -5.13392e-07 0.000764197 0.000723619 0.000673923 0.00061179 0.000537697 0.00045491 0.000368233 0.00028277 0.000202922 0.00013173 7.06261e-05 1.96412e-05 -2.21454e-05 -5.61311e-05 -8.37909e-05 -0.000106426 -0.000125107 -0.000140676 -0.000153743 -0.00016474 -0.00017401 -0.000181797 -0.000188249 -0.000193508 -0.000197753 -0.000201155 -0.000203832 -0.000205856 -0.000207294 -0.000208252 -0.000208824 -0.000209045 -0.00020894 -0.000208548 -0.000207903 -0.000207053 -0.000206042 -0.000204845 -0.000203432 -0.000201848 -0.000200148 -0.0001983 -0.000196248 -0.000193994 -0.000191565 -0.000188959 -0.000186148 -0.000183094 -0.000179767 -0.000176161 -0.00017227 -0.000168063 -0.000163505 -0.000158595 -0.000153351 -0.000147779 -0.000141882 -0.000135689 -0.000129244 -0.0001226 -0.000115817 -0.000108973 -0.000102155 -9.54405e-05 -8.88924e-05 -8.25601e-05 -7.64788e-05 -7.06769e-05 -6.51753e-05 -5.9995e-05 -5.51478e-05 -5.06392e-05 -4.64594e-05 -4.25941e-05 -3.90172e-05 -3.57069e-05 -3.26344e-05 -2.97852e-05 -2.71397e-05 -2.46969e-05 -2.2445e-05 -2.039e-05 -1.85172e-05 -1.6829e-05 -1.5296e-05 -1.39108e-05 -1.26289e-05 -1.14458e-05 -1.03175e-05 -9.2589e-06 -8.23043e-06 -7.26566e-06 -6.31676e-06 -5.43107e-06 -4.54229e-06 -3.71562e-06 -2.8615e-06 -2.07328e-06 -1.23394e-06 -4.8253e-07 0.000707703 0.000670358 0.000625907 0.000571257 0.000506545 0.000434261 0.000358185 0.000282418 0.000210581 0.000145326 8.81298e-05 3.93404e-05 -1.5236e-06 -3.5426e-05 -6.35241e-05 -8.69044e-05 -0.000106461 -0.000122922 -0.000136837 -0.000148612 -0.000158587 -0.000167028 -0.000174089 -0.000179909 -0.00018466 -0.000188522 -0.00019163 -0.000194054 -0.000195851 -0.000197128 -0.000197984 -0.000198468 -0.000198614 -0.000198448 -0.000197995 -0.00019732 -0.000196472 -0.000195424 -0.000194152 -0.000192696 -0.000191105 -0.000189361 -0.000187428 -0.000185289 -0.000182953 -0.000180441 -0.000177749 -0.000174827 -0.000171626 -0.000168151 -0.000164423 -0.000160408 -0.000156055 -0.000151366 -0.000146376 -0.000141091 -0.000135508 -0.000129656 -0.000123584 -0.000117339 -0.000110967 -0.000104536 -9.81204e-05 -9.17877e-05 -8.55929e-05 -7.95852e-05 -7.38025e-05 -6.82752e-05 -6.30248e-05 -5.80729e-05 -5.34316e-05 -4.91077e-05 -4.50929e-05 -4.13748e-05 -3.79283e-05 -3.47324e-05 -3.17597e-05 -2.89982e-05 -2.64321e-05 -2.40645e-05 -2.18864e-05 -1.99042e-05 -1.81007e-05 -1.64742e-05 -1.49908e-05 -1.36401e-05 -1.23774e-05 -1.12004e-05 -1.00693e-05 -9.00385e-06 -7.96981e-06 -7.00355e-06 -6.06078e-06 -5.18805e-06 -4.32098e-06 -3.5212e-06 -2.70195e-06 -1.95124e-06 -1.15807e-06 -4.52761e-07 0.000654784 0.000620505 0.000580737 0.000532597 0.000475959 0.000412712 0.000345851 0.000278694 0.000214244 0.000154776 0.000101693 5.55217e-05 1.60817e-05 -1.72446e-05 -4.53156e-05 -6.90203e-05 -8.90941e-05 -0.000106143 -0.000120672 -0.000133047 -0.000143578 -0.000152541 -0.00016011 -0.00016641 -0.000171602 -0.000175869 -0.000179358 -0.000182141 -0.000184268 -0.00018584 -0.00018696 -0.000187686 -0.000188064 -0.000188116 -0.000187852 -0.000187341 -0.000186653 -0.000185757 -0.000184618 -0.000183293 -0.000181823 -0.000180184 -0.00017836 -0.000176351 -0.000174128 -0.000171705 -0.000169129 -0.000166362 -0.000163303 -0.000159959 -0.000156398 -0.000152591 -0.000148452 -0.000143984 -0.000139251 -0.000134262 -0.000128994 -0.000123479 -0.000117777 -0.000111926 -0.000105957 -9.99292e-05 -9.39091e-05 -8.79547e-05 -8.21135e-05 -7.6434e-05 -7.09555e-05 -6.57092e-05 -6.07168e-05 -5.60003e-05 -5.15728e-05 -4.74421e-05 -4.36012e-05 -4.00394e-05 -3.67322e-05 -3.36595e-05 -3.07952e-05 -2.81296e-05 -2.56505e-05 -2.33644e-05 -2.12652e-05 -1.93595e-05 -1.76286e-05 -1.6067e-05 -1.46375e-05 -1.33269e-05 -1.20907e-05 -1.09276e-05 -9.80222e-06 -8.73749e-06 -7.70444e-06 -6.74131e-06 -5.80784e-06 -4.94949e-06 -4.10486e-06 -3.33174e-06 -2.5472e-06 -1.83323e-06 -1.0853e-06 -4.24065e-07 0.000604869 0.000573515 0.00053797 0.00049556 0.000445939 0.00039051 0.000331668 0.000272132 0.000214423 0.000160492 0.000111602 6.83527e-05 3.07559e-05 -1.56451e-06 -2.92007e-05 -5.28424e-05 -7.30969e-05 -9.04532e-05 -0.000105353 -0.00011814 -0.000129077 -0.000138426 -0.000146389 -0.000153077 -0.000158634 -0.000163249 -0.000167063 -0.00017015 -0.000172571 -0.000174415 -0.000175779 -0.000176726 -0.000177307 -0.000177558 -0.00017748 -0.00017713 -0.000176596 -0.000175853 -0.000174839 -0.000173628 -0.000172296 -0.000170782 -0.000169057 -0.000167166 -0.000165077 -0.000162761 -0.000160298 -0.000157687 -0.00015479 -0.000151586 -0.000148192 -0.000144602 -0.000140689 -0.000136448 -0.000131973 -0.000127282 -0.000122333 -0.000117155 -0.000111818 -0.000106356 -0.000100782 -9.5149e-05 -8.95182e-05 -8.39393e-05 -7.84521e-05 -7.31035e-05 -6.79338e-05 -6.29743e-05 -5.82464e-05 -5.37725e-05 -4.95666e-05 -4.56376e-05 -4.19798e-05 -3.85831e-05 -3.54242e-05 -3.24834e-05 -2.97359e-05 -2.71743e-05 -2.47898e-05 -2.2592e-05 -2.05772e-05 -1.87523e-05 -1.70976e-05 -1.56045e-05 -1.42332e-05 -1.29682e-05 -1.17652e-05 -1.06237e-05 -9.51227e-06 -8.45592e-06 -7.43059e-06 -6.47573e-06 -5.5553e-06 -4.71346e-06 -3.89253e-06 -3.14639e-06 -2.39659e-06 -1.7188e-06 -1.01516e-06 -3.96294e-07 0.000557386 0.000528862 0.000497223 0.00045996 0.000416511 0.00036787 0.000315997 0.000263184 0.000211578 0.000162866 0.00011815 7.80142e-05 4.25863e-05 1.16486e-05 -1.51892e-05 -3.84196e-05 -5.85415e-05 -7.59464e-05 -9.09814e-05 -0.000103973 -0.000115161 -0.000124767 -0.000133001 -0.000139975 -0.00014581 -0.000150698 -0.000154784 -0.000158128 -0.000160794 -0.000162872 -0.000164453 -0.000165605 -0.000166373 -0.00016679 -0.000166878 -0.000166687 -0.000166307 -0.000165718 -0.000164826 -0.000163709 -0.000162506 -0.000161151 -0.000159542 -0.000157739 -0.000155773 -0.000153601 -0.000151272 -0.000148805 -0.000146068 -0.000143024 -0.000139809 -0.000136434 -0.000132755 -0.000128751 -0.000124538 -0.000120146 -0.000115518 -0.000110678 -0.000105702 -0.00010062 -9.5437e-05 -9.01928e-05 -8.49462e-05 -7.97394e-05 -7.46063e-05 -6.9591e-05 -6.47343e-05 -6.00669e-05 -5.56099e-05 -5.13857e-05 -4.74093e-05 -4.36903e-05 -4.02241e-05 -3.70014e-05 -3.39994e-05 -3.1199e-05 -2.85768e-05 -2.61275e-05 -2.38454e-05 -2.17427e-05 -1.98182e-05 -1.80788e-05 -1.65044e-05 -1.50836e-05 -1.37749e-05 -1.25608e-05 -1.13976e-05 -1.02852e-05 -9.19562e-06 -8.15524e-06 -7.14451e-06 -6.20344e-06 -5.30026e-06 -4.47771e-06 -3.68226e-06 -2.96391e-06 -2.24917e-06 -1.60726e-06 -9.47148e-07 -3.69228e-07 0.000511694 0.000485948 0.000458112 0.000425639 0.000387694 0.000344971 0.000299151 0.000252251 0.000206143 0.000162289 0.000121641 8.47116e-05 5.16792e-05 2.24382e-05 -3.27475e-06 -2.5794e-05 -4.54977e-05 -6.26976e-05 -7.76458e-05 -9.06318e-05 -0.000101905 -0.000111638 -0.00012001 -0.000127162 -0.000133192 -0.000138264 -0.000142553 -0.000146116 -0.000148975 -0.000151226 -0.000152993 -0.000154335 -0.000155276 -0.000155842 -0.000156061 -0.000156006 -0.000155781 -0.000155355 -0.000154588 -0.000153549 -0.000152448 -0.000151265 -0.000149818 -0.0001481 -0.000146212 -0.000144193 -0.00014205 -0.000139732 -0.000137129 -0.000134256 -0.00013125 -0.000128094 -0.000124639 -0.00012088 -0.000116941 -0.000112847 -0.000108539 -0.000104038 -9.94214e-05 -9.47152e-05 -8.99153e-05 -8.50558e-05 -8.01892e-05 -7.53517e-05 -7.05722e-05 -6.58928e-05 -6.13533e-05 -5.69834e-05 -5.28035e-05 -4.88363e-05 -4.50972e-05 -4.15967e-05 -3.83308e-05 -3.52905e-05 -3.24538e-05 -2.98019e-05 -2.73133e-05 -2.49843e-05 -2.28125e-05 -2.08121e-05 -1.8984e-05 -1.73354e-05 -1.58457e-05 -1.45013e-05 -1.32599e-05 -1.2102e-05 -1.09849e-05 -9.90868e-06 -8.84851e-06 -7.83158e-06 -6.84238e-06 -5.9209e-06 -5.03967e-06 -4.23972e-06 -3.4721e-06 -2.78283e-06 -2.10388e-06 -1.49778e-06 -8.80819e-07 -3.42685e-07 0.000467069 0.000444139 0.000420247 0.000392374 0.000359401 0.000321883 0.000281361 0.000239684 0.00019853 0.000159168 0.000122409 8.86934e-05 5.81909e-05 3.08691e-05 6.5537e-06 -1.49923e-05 -3.40224e-05 -5.07675e-05 -6.54236e-05 -7.82162e-05 -8.93907e-05 -9.9111e-05 -0.000107499 -0.000114704 -0.000120836 -0.00012601 -0.000130413 -0.000134141 -0.000137149 -0.000139515 -0.000141425 -0.000142932 -0.000144015 -0.000144715 -0.000145054 -0.000145104 -0.000145018 -0.000144759 -0.000144123 -0.000143155 -0.000142133 -0.000141106 -0.000139858 -0.000138262 -0.00013642 -0.000134518 -0.000132598 -0.000130477 -0.000127991 -0.000125266 -0.000122491 -0.00011958 -0.000116346 -0.000112826 -0.000109172 -0.000105383 -0.000101389 -9.72243e-05 -9.29684e-05 -8.86349e-05 -8.42111e-05 -7.97305e-05 -7.52411e-05 -7.07714e-05 -6.63454e-05 -6.20039e-05 -5.77858e-05 -5.37189e-05 -4.98225e-05 -4.61193e-05 -4.26255e-05 -3.93518e-05 -3.62947e-05 -3.34454e-05 -3.07825e-05 -2.82877e-05 -2.59411e-05 -2.37407e-05 -2.1687e-05 -1.9796e-05 -1.80706e-05 -1.6518e-05 -1.51176e-05 -1.38541e-05 -1.26847e-05 -1.15882e-05 -1.05237e-05 -9.49064e-06 -8.46748e-06 -7.48139e-06 -6.52075e-06 -5.62481e-06 -4.77062e-06 -3.99692e-06 -3.26006e-06 -2.60145e-06 -1.95957e-06 -1.38933e-06 -8.15691e-07 -3.16442e-07 0.00041501 0.00039558 0.000376403 0.000353632 0.000326004 0.000294034 0.000259175 0.000223111 0.000187337 0.00015293 0.000120556 9.05794e-05 6.31441e-05 3.82574e-05 1.58346e-05 -4.28518e-06 -2.22513e-05 -3.81978e-05 -5.22809e-05 -6.46492e-05 -7.54929e-05 -8.50118e-05 -9.32929e-05 -0.000100418 -0.000106526 -0.000111724 -0.000116169 -0.000119997 -0.000123132 -0.000125582 -0.000127591 -0.000129245 -0.000130463 -0.000131286 -0.000131757 -0.000131915 -0.000131954 -0.000131883 -0.000131416 -0.000130533 -0.000129585 -0.000128715 -0.0001277 -0.0001263 -0.000124542 -0.000122728 -0.000121044 -0.000119218 -0.000116918 -0.000114332 -0.000111807 -0.000109226 -0.000106283 -0.000103035 -9.97109e-05 -9.6302e-05 -9.26902e-05 -8.89162e-05 -8.50829e-05 -8.1192e-05 -7.7211e-05 -7.31724e-05 -6.9127e-05 -6.50941e-05 -6.10887e-05 -5.71503e-05 -5.33181e-05 -4.96175e-05 -4.60654e-05 -4.26843e-05 -3.94913e-05 -3.6497e-05 -3.36981e-05 -3.10856e-05 -2.8639e-05 -2.63407e-05 -2.4173e-05 -2.21358e-05 -2.02325e-05 -1.84809e-05 -1.68858e-05 -1.54542e-05 -1.41658e-05 -1.30036e-05 -1.19251e-05 -1.09076e-05 -9.91254e-06 -8.93877e-06 -7.96851e-06 -7.02795e-06 -6.11009e-06 -5.25215e-06 -4.43694e-06 -3.6995e-06 -3.00343e-06 -2.38371e-06 -1.78797e-06 -1.26075e-06 -7.39094e-07 -2.85139e-07 0.000358104 0.000341728 0.000326386 0.00030827 0.000285958 0.000259765 0.000230925 0.000200887 0.000170913 0.00014191 0.000114409 8.86979e-05 6.49051e-05 4.30576e-05 2.3139e-05 5.06122e-06 -1.12774e-05 -2.59313e-05 -3.89864e-05 -5.05399e-05 -6.07063e-05 -6.96874e-05 -7.75977e-05 -8.44323e-05 -9.02994e-05 -9.53516e-05 -9.96945e-05 -0.000103457 -0.000106625 -0.000109118 -0.000111131 -0.000112851 -0.000114187 -0.000115104 -0.000115675 -0.00011593 -0.000116052 -0.00011615 -0.000115914 -0.000115173 -0.00011429 -0.000113547 -0.000112755 -0.000111619 -0.000110068 -0.000108362 -0.000106844 -0.000105359 -0.00010341 -0.000101028 -9.87185e-05 -9.65189e-05 -9.39972e-05 -9.10908e-05 -8.81225e-05 -8.51661e-05 -8.20377e-05 -7.87261e-05 -7.53734e-05 -7.20034e-05 -6.85505e-05 -6.50277e-05 -6.14976e-05 -5.79811e-05 -5.4478e-05 -5.10202e-05 -4.76501e-05 -4.43927e-05 -4.12605e-05 -3.82738e-05 -3.54508e-05 -3.28025e-05 -3.0325e-05 -2.80088e-05 -2.58343e-05 -2.37851e-05 -2.18455e-05 -2.00179e-05 -1.83084e-05 -1.67365e-05 -1.5309e-05 -1.40323e-05 -1.28871e-05 -1.18548e-05 -1.08941e-05 -9.98138e-06 -9.08063e-06 -8.19051e-06 -7.29666e-06 -6.42435e-06 -5.57046e-06 -4.77029e-06 -4.01172e-06 -3.32674e-06 -2.68557e-06 -2.11803e-06 -1.57986e-06 -1.10705e-06 -6.46859e-07 -2.47604e-07 0.000301772 0.000287901 0.000274936 0.000260136 0.000242283 0.000221426 0.000198388 0.00017425 0.00014999 0.00012634 0.000103739 8.24105e-05 6.24787e-05 4.39901e-05 2.69551e-05 1.13485e-05 -2.9014e-06 -1.58207e-05 -2.74145e-05 -3.7747e-05 -4.69077e-05 -5.50315e-05 -6.22343e-05 -6.85161e-05 -7.39366e-05 -7.86409e-05 -8.26921e-05 -8.61858e-05 -8.921e-05 -9.16725e-05 -9.36086e-05 -9.52508e-05 -9.66124e-05 -9.75906e-05 -9.82293e-05 -9.85666e-05 -9.87182e-05 -9.88723e-05 -9.88446e-05 -9.83306e-05 -9.75544e-05 -9.68917e-05 -9.62634e-05 -9.53879e-05 -9.4138e-05 -9.26328e-05 -9.12251e-05 -9.00069e-05 -8.85022e-05 -8.64562e-05 -8.43405e-05 -8.24671e-05 -8.04395e-05 -7.79724e-05 -7.53671e-05 -7.28569e-05 -7.02633e-05 -6.7467e-05 -6.4611e-05 -6.17799e-05 -5.88938e-05 -5.59213e-05 -5.29295e-05 -4.99578e-05 -4.69952e-05 -4.40565e-05 -4.1185e-05 -3.84099e-05 -3.57394e-05 -3.31884e-05 -3.07755e-05 -2.85125e-05 -2.63945e-05 -2.4411e-05 -2.25433e-05 -2.07765e-05 -1.90979e-05 -1.75113e-05 -1.60259e-05 -1.46616e-05 -1.34269e-05 -1.23277e-05 -1.13457e-05 -1.04614e-05 -9.63577e-06 -8.84537e-06 -8.05744e-06 -7.27068e-06 -6.47396e-06 -5.69112e-06 -4.92206e-06 -4.19953e-06 -3.51564e-06 -2.89921e-06 -2.32651e-06 -1.82282e-06 -1.35142e-06 -9.40942e-07 -5.48036e-07 -2.10561e-07 0.000244053 0.000232474 0.000221236 0.000208932 0.000194835 0.000178847 0.000161352 0.000142981 0.000124371 0.000106056 8.83905e-05 7.15624e-05 5.56909e-05 4.08437e-05 2.70409e-05 1.42953e-05 2.57683e-06 -8.14669e-06 -1.78577e-05 -2.65753e-05 -3.43545e-05 -4.1263e-05 -4.74145e-05 -5.28584e-05 -5.75855e-05 -6.16757e-05 -6.52227e-05 -6.82986e-05 -7.0989e-05 -7.32413e-05 -7.50006e-05 -7.64483e-05 -7.76995e-05 -7.86579e-05 -7.93177e-05 -7.97267e-05 -7.9913e-05 -8.00341e-05 -8.00927e-05 -7.98146e-05 -7.92155e-05 -7.86358e-05 -7.81375e-05 -7.75014e-05 -7.65764e-05 -7.53619e-05 -7.41057e-05 -7.30743e-05 -7.1996e-05 -7.04206e-05 -6.85825e-05 -6.69827e-05 -6.54412e-05 -6.35114e-05 -6.13293e-05 -5.92551e-05 -5.7218e-05 -5.50013e-05 -5.26801e-05 -5.04014e-05 -4.81144e-05 -4.57391e-05 -4.33224e-05 -4.09276e-05 -3.85463e-05 -3.61718e-05 -3.38405e-05 -3.15877e-05 -2.94212e-05 -2.73491e-05 -2.5388e-05 -2.35507e-05 -2.18325e-05 -2.02212e-05 -1.8699e-05 -1.72527e-05 -1.5872e-05 -1.45624e-05 -1.33349e-05 -1.22097e-05 -1.11963e-05 -1.03e-05 -9.50388e-06 -8.78869e-06 -8.11821e-06 -7.47014e-06 -6.81558e-06 -6.15358e-06 -5.47604e-06 -4.80506e-06 -4.14287e-06 -3.51926e-06 -2.92964e-06 -2.3997e-06 -1.91081e-06 -1.48465e-06 -1.09117e-06 -7.53329e-07 -4.34355e-07 -1.64827e-07 0.000182698 0.000173603 0.000164258 0.000154402 0.000143804 0.000132352 0.000120096 0.00010726 9.41679e-05 8.11368e-05 6.8426e-05 5.62031e-05 4.45733e-05 3.3611e-05 2.33625e-05 1.38502e-05 5.05395e-06 -3.05897e-06 -1.04727e-05 -1.71744e-05 -2.31828e-05 -2.85268e-05 -3.32986e-05 -3.75745e-05 -4.13163e-05 -4.45371e-05 -4.73497e-05 -4.98176e-05 -5.19682e-05 -5.37905e-05 -5.52415e-05 -5.64245e-05 -5.74707e-05 -5.83051e-05 -5.88586e-05 -5.92042e-05 -5.93984e-05 -5.95278e-05 -5.96426e-05 -5.95481e-05 -5.91301e-05 -5.86335e-05 -5.82382e-05 -5.78149e-05 -5.71978e-05 -5.63282e-05 -5.53343e-05 -5.44964e-05 -5.37601e-05 -5.26907e-05 -5.12673e-05 -4.9969e-05 -4.88598e-05 -4.75086e-05 -4.58536e-05 -4.42512e-05 -4.27681e-05 -4.11735e-05 -3.94471e-05 -3.77492e-05 -3.6083e-05 -3.43473e-05 -3.25528e-05 -3.07722e-05 -2.90119e-05 -2.72512e-05 -2.55117e-05 -2.38305e-05 -2.22171e-05 -2.06737e-05 -1.9212e-05 -1.78444e-05 -1.65668e-05 -1.53669e-05 -1.42283e-05 -1.31404e-05 -1.2096e-05 -1.11018e-05 -1.01693e-05 -9.31794e-06 -8.55689e-06 -7.89059e-06 -7.30407e-06 -6.77962e-06 -6.28566e-06 -5.80243e-06 -5.30603e-06 -4.79604e-06 -4.26719e-06 -3.73867e-06 -3.21411e-06 -2.71867e-06 -2.25042e-06 -1.83044e-06 -1.4454e-06 -1.11226e-06 -8.09274e-07 -5.53967e-07 -3.1866e-07 -1.15883e-07 0.000115295 0.000109288 0.000102769 9.60618e-05 8.92342e-05 8.22162e-05 7.49206e-05 6.73374e-05 5.95551e-05 5.17217e-05 4.39958e-05 3.64992e-05 2.93119e-05 2.25027e-05 1.61128e-05 1.01513e-05 4.61963e-06 -4.96272e-07 -5.20174e-06 -9.47501e-06 -1.33195e-05 -1.67766e-05 -1.98864e-05 -2.2655e-05 -2.50637e-05 -2.71515e-05 -2.90039e-05 -3.06427e-05 -3.20693e-05 -3.33008e-05 -3.4294e-05 -3.50529e-05 -3.57026e-05 -3.62849e-05 -3.67262e-05 -3.69998e-05 -3.71291e-05 -3.71943e-05 -3.72846e-05 -3.7293e-05 -3.70627e-05 -3.67198e-05 -3.64601e-05 -3.62242e-05 -3.586e-05 -3.53202e-05 -3.46797e-05 -3.41235e-05 -3.36839e-05 -3.30773e-05 -3.21794e-05 -3.12996e-05 -3.0601e-05 -2.98045e-05 -2.87647e-05 -2.77203e-05 -2.67983e-05 -2.58383e-05 -2.4769e-05 -2.37054e-05 -2.26821e-05 -2.16189e-05 -2.04998e-05 -1.93822e-05 -1.82829e-05 -1.7182e-05 -1.60874e-05 -1.50283e-05 -1.40156e-05 -1.30496e-05 -1.21374e-05 -1.12886e-05 -1.05e-05 -9.75993e-06 -9.05378e-06 -8.37244e-06 -7.71107e-06 -7.07595e-06 -6.47839e-06 -5.9351e-06 -5.45504e-06 -5.04195e-06 -4.6846e-06 -4.36834e-06 -4.06888e-06 -3.77037e-06 -3.45558e-06 -3.12427e-06 -2.77441e-06 -2.42062e-06 -2.06777e-06 -1.73424e-06 -1.4206e-06 -1.14135e-06 -8.88448e-07 -6.72378e-07 -4.78851e-07 -3.19994e-07 -1.85508e-07 -9.77944e-08 3.98796e-05 3.77406e-05 3.5342e-05 3.29001e-05 3.04902e-05 2.80949e-05 2.56619e-05 2.31525e-05 2.05675e-05 1.79438e-05 1.53344e-05 1.27859e-05 1.03333e-05 8.0019e-06 5.80607e-06 3.75521e-06 1.85027e-06 7.80615e-08 -1.55942e-06 -3.04403e-06 -4.37885e-06 -5.56919e-06 -6.62057e-06 -7.58437e-06 -8.49278e-06 -9.28657e-06 -9.91722e-06 -1.04344e-05 -1.09115e-05 -1.13585e-05 -1.17338e-05 -1.20238e-05 -1.22636e-05 -1.24685e-05 -1.26228e-05 -1.27226e-05 -1.2769e-05 -1.2785e-05 -1.28171e-05 -1.28358e-05 -1.27631e-05 -1.26348e-05 -1.25455e-05 -1.24807e-05 -1.2365e-05 -1.21758e-05 -1.19448e-05 -1.17388e-05 -1.15838e-05 -1.13879e-05 -1.1085e-05 -1.07729e-05 -1.05313e-05 -1.02683e-05 -9.91067e-06 -9.53982e-06 -9.22067e-06 -8.89899e-06 -8.53568e-06 -8.17038e-06 -7.82313e-06 -7.46352e-06 -7.07977e-06 -6.69357e-06 -6.31443e-06 -5.93471e-06 -5.55563e-06 -5.18872e-06 -4.83913e-06 -4.50694e-06 -4.19401e-06 -3.90391e-06 -3.63497e-06 -3.38245e-06 -3.14023e-06 -2.90531e-06 -2.67622e-06 -2.45666e-06 -2.25139e-06 -2.06782e-06 -1.90887e-06 -1.77609e-06 -1.66354e-06 -1.56531e-06 -1.46999e-06 -1.37174e-06 -1.26222e-06 -1.14275e-06 -1.01134e-06 -8.76145e-07 -7.37967e-07 -6.07061e-07 -4.82218e-07 -3.72386e-07 -2.72412e-07 -1.89623e-07 -1.15508e-07 -5.53092e-08 4.70984e-09 5.60053e-08 0.00114335 0.00113238 0.0012603 0.00142157 0.00167617 0.00197483 0.00236847 0.00113387 0.00113985 0.00125056 0.00141604 0.00163552 0.00190219 0.00213598 0.00112336 0.00114209 0.00123882 0.00139656 0.00158209 0.0017914 0.00192807 0.00111162 0.00113897 0.0012249 0.00136534 0.00152065 0.00167424 0.00175716 0.0010983 0.00113067 0.00120717 0.00132667 0.00145379 0.00156372 0.0016134 0.00108326 0.00111743 0.00118497 0.00128343 0.0013843 0.00146145 0.00148649 0.00106632 0.00109957 0.00115818 0.00123718 0.00131448 0.00136638 0.00137219 0.0010472 0.00107756 0.00112715 0.00118883 0.00124551 0.00127729 0.00126852 0.00102564 0.0010519 0.00109244 0.00113899 0.00117798 0.0011936 0.0011742 0.00100144 0.00102306 0.00105469 0.00108808 0.00111221 0.00111501 0.00108811 0.000974528 0.000991379 0.00101452 0.00103651 0.00104839 0.00104121 0.0010092 0.000944914 0.000957155 0.000972459 0.000984657 0.0009866 0.00097183 0.000936523 0.000912675 0.000920641 0.000928922 0.000932821 0.000926844 0.000906448 0.000869221 0.000877943 0.000882075 0.000884252 0.000881239 0.000869067 0.000844642 0.000806556 0.000840888 0.000841687 0.000838715 0.000830076 0.000813168 0.000786007 0.000747886 0.000801707 0.000799701 0.000792524 0.000779433 0.000759011 0.000730155 0.000692642 0.000760612 0.000756333 0.000745851 0.000729362 0.000706428 0.000676692 0.000640289 0.000717817 0.000711785 0.000698832 0.00067989 0.000655266 0.000625231 0.000590285 0.000673519 0.000666235 0.000651575 0.00063104 0.00060544 0.000575474 0.000542076 0.00062787 0.000619803 0.000604143 0.0005828 0.000556928 0.000527379 0.000495258 0.000572088 0.000563568 0.000547476 0.000525993 0.000500618 0.000472297 0.00044139 0.000503598 0.000495089 0.000479451 0.000458902 0.000435015 0.00040884 0.000381085 0.000428246 0.000420231 0.000405971 0.000387533 0.000366452 0.000343903 0.000320779 0.000345928 0.000338896 0.000326919 0.000311746 0.000294717 0.000276874 0.000258972 0.000256632 0.000251118 0.000242125 0.000230954 0.000218618 0.00020591 0.000193409 0.000160041 0.000156502 0.000150909 0.000144069 0.000136619 0.000129061 0.000121761 5.48952e-05 5.36641e-05 5.17581e-05 4.94512e-05 4.69614e-05 4.44584e-05 4.20605e-05 ) ; boundaryField { top { type fixedValue; value uniform 0; } inlet { type zeroGradient; } outlet { type fixedValue; value uniform 0; } plate { type zeroGradient; } symmBound { type zeroGradient; } frontAndBack { type empty; } } // ************************************************************************* //
c6739c3c6bd8b71c0983b29dda6db5fb9d885d53
34515f5927c07688979818cfcfa76c752c800ac5
/stixel_world.h
271db9b09b39ae3c0bf171772a0adffa3a9011af
[]
no_license
yonghoonkwon/stixel-world
481b4d852eae9c95848f2529854c395a36ea6aa1
408ba8510113588a5b9c8fb16bea78328ff2a9fe
refs/heads/master
2021-01-22T22:20:52.377821
2017-03-18T04:52:17
2017-03-18T04:52:17
85,534,200
1
0
null
2017-03-20T04:06:19
2017-03-20T04:06:19
null
UTF-8
C++
false
false
724
h
stixel_world.h
#ifndef __STIXEL_WORLD_H__ #define __STIXEL_WORLD_H__ #include <opencv2/opencv.hpp> struct Stixel { int u; int vT; int vB; int width; float disp; }; class StixelWorld { public: StixelWorld() = delete; StixelWorld( float focalLengthX, float focalLengthY, float principalPointX, float principalPointY, float baseline, float cameraHeight, float cameraTilt); void compute(const cv::Mat& disp, std::vector<Stixel>& stixels, int stixelWidth = 7); std::vector<int> lowerPath; std::vector<int> upperPath; private: float focalLengthX_; float focalLengthY_; float principalPointX_; float principalPointY_; float baseline_; float cameraHeight_; float cameraTilt_; }; #endif // !__STIXEL_WORLD_H__
2c251f6f4c76228643a4e0416d7e765c16eea737
73e89812a3e4f979641c7d8765b46ed0226e3dd9
/Urasandesu.Swathe/Urasandesu/Swathe/AutoGen/Profiling/ClassFacade/ModuleProfilerFacade.h
1b0d7f09b3aedb851d01f1169e7984e9ccea3e66
[]
no_license
urasandesu/Swathe
c601244e7339c2d6fe5686a0ee2ca44732007d89
e086ede891a64d991f1f738b00eb158b44537d06
refs/heads/master
2021-01-19T00:52:31.845284
2017-03-17T11:32:51
2017-03-17T11:32:51
6,515,991
3
1
null
null
null
null
UTF-8
C++
false
false
6,188
h
ModuleProfilerFacade.h
/* * File: ModuleProfilerFacade.h * * Author: Akira Sugiura (urasandesu@gmail.com) * * * Copyright (c) 2014 Akira Sugiura * * This software is MIT License. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * 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. */ #pragma once #ifndef URASANDESU_SWATHE_AUTOGEN_PROFILING_CLASSFACADE_MODULEPROFILERFACADE_H #define URASANDESU_SWATHE_AUTOGEN_PROFILING_CLASSFACADE_MODULEPROFILERFACADE_H #ifndef URASANDESU_SWATHE_AUTOGEN_PROFILING_CLASSAPIAT_MODULEPROFILERAPIAT_H #include <Urasandesu/Swathe/AutoGen/Profiling/ClassApiAt/ModuleProfilerApiAt.h> #endif #ifndef URASANDESU_SWATHE_PROFILING_MODULEPROFILERPIMPLFWD_H #include <Urasandesu/Swathe/Profiling/ModuleProfilerPimplFwd.h> #endif #ifndef URASANDESU_SWATHE_PROFILING_MODULEPROFILERFWD_H #include <Urasandesu/Swathe/Profiling/ModuleProfilerFwd.h> #endif #ifndef URASANDESU_SWATHE_AUTOGEN_PROFILING_CLASSLABEL_PROCESSPROFILERLABEL_H #include <Urasandesu/Swathe/AutoGen/Profiling/ClassLabel/ProcessProfilerLabel.h> #endif #ifndef URASANDESU_SWATHE_AUTOGEN_PROFILING_CLASSPIMPLLABEL_PROCESSPROFILERPIMPLLABEL_H #include <Urasandesu/Swathe/AutoGen/Profiling/ClassPimplLabel/ProcessProfilerPimplLabel.h> #endif #ifndef URASANDESU_SWATHE_PROFILING_ASSEMBLYPROFILERFWD_H #include <Urasandesu/Swathe/Profiling/AssemblyProfilerFwd.h> #endif namespace Urasandesu { namespace Swathe { namespace AutoGen { namespace Profiling { namespace ClassFacade { namespace ModuleProfilerFacadeDetail { namespace mpl = boost::mpl; using namespace Urasandesu::CppAnonym; using namespace Urasandesu::CppAnonym::Traits; using Urasandesu::Swathe::AutoGen::Profiling::ClassApiAt::ModuleProfilerApiAt; using Urasandesu::Swathe::Profiling::ModuleProfilerPimpl; using Urasandesu::Swathe::Profiling::ModuleProfiler; using Urasandesu::Swathe::AutoGen::Profiling::ClassLabel::ProcessProfilerLabel; using Urasandesu::Swathe::AutoGen::Profiling::ClassPimplLabel::ProcessProfilerPimplLabel; using Urasandesu::Swathe::Profiling::AssemblyProfiler; using mpl::vector; template< class ApiHolder > struct ModuleProfilerFacadeImpl { typedef ModuleProfiler class_type; typedef ModuleProfilerPimpl class_pimpl_type; typedef ModuleProfilerPimpl module_profiler_pimpl_label_type; typedef typename ModuleProfilerApiAt<ApiHolder, ProcessProfilerLabel>::type process_profiler_label_type; typedef typename ModuleProfilerApiAt<ApiHolder, ProcessProfilerPimplLabel>::type process_profiler_pimpl_label_type; typedef ModuleProfilerPimpl module_profiler_pimpl_label_type; typedef ModuleProfiler module_profiler_label_type; typedef AssemblyProfiler assembly_profiler_label_type; typedef Nil base_heap_provider_type; #define SWATHE_DECLARE_MODULE_PROFILER_EMPTY_HEAP_PROVIDER_TYPEDEF_ALIAS \ typedef typename facade::base_heap_provider_type base_heap_provider_type; \ friend typename base_heap_provider_type; \ }; } // namespace ModuleProfilerFacadeDetail { template< class ApiHolder > struct ModuleProfilerFacade : ModuleProfilerFacadeDetail::ModuleProfilerFacadeImpl<ApiHolder> { }; #define SWATHE_BEGIN_MODULE_PROFILER_FACADE_TYPEDEF_ALIAS \ typedef Urasandesu::Swathe::AutoGen::Profiling::ClassFacade::ModuleProfilerFacade<ApiHolder> facade; #define SWATHE_DECLARE_MODULE_PROFILER_FACADE_TYPEDEF_ALIAS \ SWATHE_DECLARE_MODULE_PROFILER_EMPTY_HEAP_PROVIDER_TYPEDEF_ALIAS \ typedef typename facade::class_type class_type; \ typedef typename facade::class_pimpl_type class_pimpl_type; \ friend typename class_pimpl_type; \ typedef typename facade::module_profiler_pimpl_label_type module_profiler_pimpl_label_type; \ friend typename module_profiler_pimpl_label_type; \ typedef typename facade::process_profiler_label_type process_profiler_label_type; \ typedef typename facade::process_profiler_pimpl_label_type process_profiler_pimpl_label_type; \ friend typename process_profiler_label_type; \ friend typename process_profiler_pimpl_label_type; \ typedef typename facade::module_profiler_pimpl_label_type module_profiler_pimpl_label_type; \ typedef typename facade::module_profiler_label_type module_profiler_label_type; \ typedef typename facade::assembly_profiler_label_type assembly_profiler_label_type; \ friend typename module_profiler_pimpl_label_type; \ friend typename module_profiler_label_type; \ friend typename assembly_profiler_label_type; \ #define SWATHE_END_MODULE_PROFILER_FACADE_TYPEDEF_ALIAS }}}}} // namespace Urasandesu { namespace Swathe { namespace AutoGen { namespace Profiling { namespace ClassFacade { #endif // URASANDESU_SWATHE_AUTOGEN_PROFILING_CLASSFACADE_MODULEPROFILERFACADE_H
7f3768d977fa812cde2e1ae239322a00c5a6a2ff
fa9ede38fa4d56e39bb89757ad60f0bf7fa7ac92
/include/components/Cursor.h
b36a3804c0746e51ffb789eb9843cf4598f8a89f
[]
no_license
Takashi-san/Yawara_Game
d27eb6613a8d54f02cd31a47bc5b0bab3ed8cb8c
d8ff2a84029131e9cd946d209024844daa99a970
refs/heads/master
2020-05-23T21:16:14.786938
2019-07-15T08:32:42
2019-07-15T08:32:42
186,946,234
1
0
null
2019-07-14T15:19:06
2019-05-16T03:43:23
C++
UTF-8
C++
false
false
341
h
Cursor.h
#pragma once // Alows to initializate the header just once #include "Component.h" #include "GameObject.h" #include "Vec2.h" #include <string> #include <iostream> #include <stdbool.h> #include <memory> class Cursor : public Component { private: public: Cursor(GameObject &); void Update(float); void Render(); bool Is(std::string); };
c67707b4d3c116e771dacdeffe9d1a1650c617d2
509801ad7b89cb4de92747e3361514153035f40a
/src/cwap/Location.hpp
1f7d59bcfd3aca4962708ee4589b480c81880c7e
[ "Apache-2.0" ]
permissive
SimplyKnownAsG/cwap
b48f0e8f332d78fe716365eef21a8954447e7495
2eaad6a2817017d5b04f465bd8f71e6fbbace5aa
refs/heads/master
2021-01-01T16:08:32.275442
2019-11-25T16:07:35
2019-11-25T16:07:35
97,777,259
4
0
null
null
null
null
UTF-8
C++
false
false
518
hpp
Location.hpp
#pragma once #include <clang-c/Index.h> #include <ostream> #include <string> namespace cwap { class Location { public: const std::string file_name; const unsigned line; const unsigned column; const unsigned offset; static Location Create(const CXCursor& cursor); friend std::ostream& operator<<(std::ostream& stream, const Location& self); private: Location(std::string file_name, unsigned line, unsigned column, unsigned offset); }; }
7618055cefad226d49a72528e3c7533a99d62a21
a53cd014871bad537d51b0c6498a1bafd652366d
/app/vachellia/ops/HorizonOps.h
952d46d077a87c1f67e162ae10b1f461edc85e67
[]
no_license
spinos/gorse
b3d9f39b12d091a7058ed686ce52c70bdf7927dc
65e81fcdbf6f747cbc43bf362a94f01f608ed4e1
refs/heads/master
2020-03-29T09:32:01.162127
2019-10-09T15:47:29
2019-10-15T20:07:46
149,762,698
0
0
null
null
null
null
UTF-8
C++
false
false
1,221
h
HorizonOps.h
/* * HorizonOps.h * vachellia * */ #ifndef VCHL_HORIZON_OPS_H #define VCHL_HORIZON_OPS_H #include "RenderableOps.h" namespace alo { class HorizonOps : public RenderableOps { Vector3F m_center; float m_planetRadius; public: enum { Type = 298999 }; HorizonOps(); virtual ~HorizonOps(); virtual std::string opsName() const override; virtual void addRenderableTo(RenderableScene *scene) override; virtual bool hasInstance() const override; virtual bool hasGeodesicSamples() const override; virtual bool hasSurfaceSamples() const override; virtual void update() override; virtual bool intersectRay(IntersectResult& result) const override; virtual void expandAabb(float *box) const override; virtual float mapDistance(const float *q) const override; virtual Vector3F mapNormal(const float *q) const override; virtual float mapLocalDistance(const float *q) const override; /// no samples generated virtual void genSamples(sds::SpaceFillingVector<grd::CellSample> &samples) const override; virtual QString getShortDescription() const override; protected: private: float radiusInMeters() const; }; } #endif
7633f762b2fc2ac8619822f08c291459d836faff
bc8daafdf886d9e3e0ce43baf74e8200c22eb809
/src/launcher.cpp
29cd884cb4c1eb2f93e30a3c813abf95bb152eca
[]
no_license
WJLiddy/DubstepZombiesC
dd8c3bff50bc194be9b311889249e3909442be9e
bed3f4c72f7b4ebeca31f20bf3559d8fb505fee6
refs/heads/master
2021-04-29T11:03:51.732181
2017-03-09T23:24:44
2017-03-09T23:24:44
77,858,903
2
0
null
null
null
null
UTF-8
C++
false
false
1,998
cpp
launcher.cpp
#include <stdio.h> #include <allegro5/allegro.h> #include "gamestate/gamestate.h" #include "gamestate/titlescreen.h" #include "drawutils/drawutils.h" #include "input/inputs.h" #include "input/controller.h" #include "input/keyboard.h" const float FPS = 60; int main(int argc, char **argv){ ALLEGRO_EVENT_QUEUE *event_queue = NULL; ALLEGRO_TIMER *timer = NULL; bool frame_drawn = false; //TODO: double check for memleaks, and if these initializers really every throw a false value if(!al_init()) { fprintf(stderr, "failed to initialize allegro!\n"); return -1; } timer = al_create_timer(1.0 / FPS); if(!timer) { fprintf(stderr, "failed to create timer!\n"); return -1; } event_queue = al_create_event_queue(); if(!event_queue) { fprintf(stderr, "failed to create event_queue!\n"); al_destroy_timer(timer); return -1; } al_start_timer(timer); // Load programatically from a file later, but for now, Inputs inputs; //Default keys inputs.setPlayerInput(0, new Keyboard()); DrawUtils drawUtils; GameState *gameState = new TitleScreen(&inputs); al_register_event_source(event_queue, al_get_display_event_source(drawUtils.display_)); al_register_event_source(event_queue, al_get_timer_event_source(timer)); while(1) { ALLEGRO_EVENT ev; al_wait_for_event(event_queue, &ev); if(ev.type == ALLEGRO_EVENT_TIMER) { GameState* next_state = gameState->update(); if(next_state) { delete(gameState); gameState = next_state; } frame_drawn = true; } else if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { //clean mem leaks! return 0; } if(frame_drawn && al_is_event_queue_empty(event_queue)) { gameState->draw(drawUtils); frame_drawn = false; } } al_destroy_timer(timer); al_destroy_event_queue(event_queue); return 0; }
2f068dfb5674762e00e75c5790b8d19e3e52a958
d76934f14ba26fe6fa374724cbd2f0f8416726c4
/lib/lda/real_audio_channel.cpp
9b0c57008a75edf0322f966c574fa5e29ccbb92c
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
TheMarlboroMan/libdansdl2
6e54681e51512b23d55713187e64a61e6e001a46
7692bcaa2bb7f412d88a01ead6f61c7ee0842c1c
refs/heads/master
2023-01-27T18:23:57.743163
2023-01-11T07:57:03
2023-01-11T08:00:13
39,908,671
0
1
null
null
null
null
UTF-8
C++
false
false
3,651
cpp
real_audio_channel.cpp
#include <lda/real_audio_channel.h> #include <lda/audio_controller.h> #include <cmath> using namespace lda; //!Default class constructor. //!It is private, so good luck creating it. real_audio_channel::real_audio_channel(int i, const int& main_vol) :index(i), repeat(0), volume(128), playing(false), monitoring(false), paused(false), main_sound_volume_ptr(&main_vol), sound_playing(nullptr) { } //!Copy constructor. //!Even if public, it is a very bad idea to use it. In fact, is only public so //!it can be thrown into a vector without doing custom allocators. real_audio_channel::real_audio_channel(const real_audio_channel& o) :index(o.index), repeat(o.repeat), volume(o.volume), playing(o.playing), monitoring(o.monitoring), paused(o.paused), main_sound_volume_ptr(o.main_sound_volume_ptr), sound_playing(o.sound_playing) { } //!Frees a channel after the playback is done. //!This is part of the SDL_Audio callback system, which needs a callback //!function to call after a sound has been played. Must be manually called on //!monitored channels. Nullifies repeat, sets monitoring to false and //!cleans pointer to played sound. The callback listener is also removed and //!the panning is cleared. void real_audio_channel::free() { sound_playing=nullptr; repeat=0; monitoring=false; callback_listener=nullptr; clear_panning(); } //!Forces sound stop. //!Forces sound stop. Internally calls Mix_HaltChannel, sets playing to false //!and calls "free" if the channel is unmonitored. void real_audio_channel::stop() { Mix_HaltChannel(index); playing=false; if(!monitoring) free(); } //!Clears the "playing" flag and calls free if not monitored. //!This is part of SDL_Audio callback system. void real_audio_channel::do_callback() { playing=false; if(callback_listener) callback_listener->do_callback(); if(!monitoring) free(); } //!Sets the volume for the channel. //!The volume for the channel is mixed with the overall master volume set on the //!controller. Maximum loudness is achieved when both are set at their maximum values. void real_audio_channel::set_volume(int v) { volume=v; Mix_Volume(index, calculate_real_volume()); } int real_audio_channel::calculate_real_volume() { // float res=(float) volume * ((float)volume / (float)*main_sound_volume_ptr); float res=(float) volume * ((float)*main_sound_volume_ptr / 128.f); return ceil(res); } //!Plays the sound_struct. //!A bug in the SDL Audio library (or in my code) prevents the panning from //!working on Windows builds. int real_audio_channel::play(const sound_struct& e) { sound_playing=e.sound_ptr; repeat=e.repeat; if(e.volume!=-1) volume=e.volume; Mix_Volume(index, calculate_real_volume()); playing=true; int res=!e.ms_fade ? Mix_PlayChannel(index, (*sound_playing).get_data(), repeat) : Mix_FadeInChannel(index, (*sound_playing).get_data(), repeat, e.ms_fade); //#ifndef WINCOMPIL if(e.panning.left!=-1 && e.panning.right!=-1) { set_stereo_volume(e.panning); } //#endif return res; } //!Sets the left and right channel volumes.. void real_audio_channel::set_stereo_volume(sound_panning sp) { Mix_SetPanning(index, sp.left, sp.right); } //!Removes panning from the channel. void real_audio_channel::clear_panning() { Mix_SetPanning(index, 255, 255); } //!Pauses the sound. //!Internally calls Mix_Pause for the channel and sets the paused flag to true. void real_audio_channel::pause() { Mix_Pause(index); paused=true; } //!Resumes playing after pausing. //!Internally calls Mix_Resume for the channel and unsets the pause flag. void real_audio_channel::resume() { Mix_Resume(index); paused=false; }
0d70e0a97a0c9357ac5b7198569dbfa503425e18
4603a7dd17c50b98d1da8b5c346c714361fd52f0
/base/utility/string_util.cpp
4d8732534b58ff6f9aa935881369777a2cc99115
[ "Apache-2.0" ]
permissive
openharmony-sig-ci/hiviewdfx_hiview
513f4b7fd0fb1273240467f9200334446d2959c6
32251dad5b7623631288a1947518e03494c1f7a4
refs/heads/master
2023-07-18T11:29:47.255518
2021-09-03T08:10:55
2021-09-03T08:10:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,842
cpp
string_util.cpp
/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "string_util.h" #include <climits> #include <iomanip> #include <iostream> #include <sstream> #include <string> #include <vector> namespace OHOS { namespace HiviewDFX { namespace StringUtil { using namespace std; const char INDICATE_VALUE_CHAR = ':'; const char KEY_VALUE_END_CHAR = ';'; constexpr int SKIP_NEXT_INDEX_LENGTH = 2; const std::string EMPTY_STRING = ""; std::string ConvertVectorToStr(const std::vector<std::string> &listStr, const std::string &split) { std::string str(""); for (auto &item : listStr) { if (str == "") { str = item; } else { str += split + item; } } return str; } string ReplaceStr(const string& str, const string& src, const string& dst) { if (src.empty()) { return str; } string::size_type pos = 0; string strTmp = str; while ((pos = strTmp.find(src, pos)) != string::npos) { strTmp.replace(pos, src.length(), dst); pos += dst.length(); } return strTmp; } string TrimStr(const string& str, const char cTrim) { string strTmp = str; strTmp.erase(0, strTmp.find_first_not_of(cTrim)); strTmp.erase(strTmp.find_last_not_of(cTrim) + sizeof(char)); return strTmp; } void SplitStr(const string& str, const string& sep, vector<string>& strs, bool canEmpty, bool needTrim) { strs.clear(); string strTmp = needTrim ? TrimStr(str) : str; string strPart; while (true) { string::size_type pos = strTmp.find(sep); if (string::npos == pos || sep.empty()) { strPart = needTrim ? TrimStr(strTmp) : strTmp; if (!strPart.empty() || canEmpty) { strs.push_back(strPart); } break; } else { strPart = needTrim ? TrimStr(strTmp.substr(0, pos)) : strTmp.substr(0, pos); if (!strPart.empty() || canEmpty) { strs.push_back(strPart); } strTmp = strTmp.substr(sep.size() + pos, strTmp.size() - sep.size() - pos); } } } bool StrToInt(const string& str, int& value) { if (str.empty() || (!isdigit(str.front()) && (str.front() != '-'))) { return false; } char* end = nullptr; const int base = 10; errno = 0; auto addr = str.c_str(); auto result = strtol(addr, &end, base); if (end == addr || end[0] != '\0' || errno == ERANGE) { return false; } value = static_cast<int>(result); return true; } int StrToInt(const string& str) { int id = -1; StrToInt(str, id); return id; } string DexToHexString(int value, bool upper) { stringstream ioss; string hexString; if (upper) { ioss << setiosflags(ios::uppercase) << hex << value; } else { ioss << hex << value; } ioss >> hexString; return hexString; } KeyValuePair GetKeyValueByString(int &start, const std::string &inputString) { std::string key; std::string value; int length = inputString.size(); while (start < length) { if (inputString[start] == INDICATE_VALUE_CHAR) { start++; break; } key.append(1, inputString[start]); start++; } while (start < length) { if (inputString[start] == KEY_VALUE_END_CHAR) { // replace ;; to ; in value; // one ';' means the end of a "key:value;" if (start + 1 < length && inputString[start + 1] == KEY_VALUE_END_CHAR) { value.append(1, inputString[start]); start = start + SKIP_NEXT_INDEX_LENGTH; continue; } else { start++; break; } } if (inputString[start] == INDICATE_VALUE_CHAR && start + 1 < length && inputString[start + 1] == INDICATE_VALUE_CHAR) { // replace :: to : value.append(1, inputString[start]); start = start + SKIP_NEXT_INDEX_LENGTH; continue; } value.append(1, inputString[start]); start++; } return make_pair(key, make_pair(value, 0)); } bool IsValidFloatNum(const std::string &value) { int len = value.size(); int pointNum = 0; for (int i = 0; i < len; i++) { if (isdigit(value[i])) { continue; } if (value[i] == '.') { pointNum++; } else { // the string contains not valid num; return false; } } // the string contains more than one character '.' if (pointNum > 1) { return false; } // the string format is .111/111. return isdigit(value[0]) && isdigit(value[len - 1]); } std::list<std::string> SplitStr(const std::string& str, char delimiter) { std::list<std::string> tokens; std::string token; std::istringstream tokenStream(str); while (std::getline(tokenStream, token, delimiter)) { tokens.push_back(token); } return tokens; } string GetLeftSubstr(const string& input, const string& split) { size_t pos = input.find(split, 0); if (pos == string::npos) { return input; } return input.substr(0, pos); } string GetRightSubstr(const string& input, const string& split) { size_t pos = input.find(split, 0); if (pos == string::npos) { return "none"; } return input.substr(pos + split.size(), input.size() - pos); } string GetRleftSubstr(const string& input, const string& split) { size_t pos = input.rfind(split, string::npos); if (pos == string::npos) { return input; } return input.substr(0, pos); } string GetRrightSubstr(const string& input, const string& split) { size_t pos = input.rfind(split, string::npos); if (pos == string::npos) { return "none"; } return input.substr(pos + 1, input.size() - pos); } string EraseString(const string& input, const string& toErase) { size_t pos = 0; string out = input; while ((pos = out.find(toErase, pos)) != string::npos) { out.erase(pos, toErase.size()); pos = (pos == 0) ? (0) : (pos - 1); } return out; } string GetMidSubstr(const string& input, const string& begin, const string& end) { string midstr = ""; size_t beginPos = input.find(begin, 0); if (beginPos == string::npos) { return midstr; } beginPos = beginPos + begin.size(); size_t endPos = input.find(end, beginPos); if (endPos == string::npos) { return midstr; } return input.substr(beginPos, endPos - beginPos); } string VectorToString(const vector<string>& src, bool reverse, const string& tag) { string str; for (auto elment : src) { if (elment.empty()) { continue; } if (reverse) { str = elment + tag + str; } else { str = str + elment + tag; } } return str; } uint64_t StringToUl(const string& flag, int base) { uint64_t ret = strtoul(flag.c_str(), NULL, base); if (ret == ULONG_MAX) { return 0; } return ret; } double StringToDouble(const string& input) { if (input.empty()) { return 0; } char *e = nullptr; errno = 0; double temp = std::strtod(input.c_str(), &e); if (errno != 0) { // error, overflow or underflow return 0; } return temp; } std::string FindMatchSubString(const std::string& target, const std::string& begin, int offset, const std::string& end) { auto matchPos = target.find_first_of(begin); if (matchPos == std::string::npos) { return ""; } auto beginPos = matchPos + offset; if (beginPos > target.length()) { return ""; } auto endPos = target.find_first_of(end, beginPos); if (endPos == std::string::npos) { return target.substr(beginPos); } return target.substr(beginPos, endPos); } std::string EscapeJsonStringValue(const std::string &value) { std::string escapeValue; for (auto it = value.begin(); it != value.end(); it++) { switch (*it) { case '\\': escapeValue.push_back('\\'); escapeValue.push_back('\\'); break; case '\"': escapeValue.push_back('\\'); escapeValue.push_back('"'); break; case '\b': escapeValue.push_back('\\'); escapeValue.push_back('b'); break; case '\f': escapeValue.push_back('\\'); escapeValue.push_back('f'); break; case '\n': escapeValue.push_back('\\'); escapeValue.push_back('n'); break; case '\r': escapeValue.push_back('\\'); escapeValue.push_back('r'); break; case '\t': escapeValue.push_back('\\'); escapeValue.push_back('t'); break; default: escapeValue.push_back(*it); break; } } return escapeValue; } } // namespace StringUtil } // namespace HiviewDFX } // namespace OHOS
9f9fd8b63a873dd2358a1a5a9a1d51cf17e178d2
48189c5e12266f7457d8501ad1c7d3da67ee44b7
/PhysicsProject/PhysicsProject/Joint.cpp
f468995a4e659961b5da1a75556f74ee22114d04
[]
no_license
CesarRocha/Engine
9d75dbb4878fce7b5bf35fb2c967eb57738617ad
de593a3878f66bcf11c608ccef4a42cf2e6d625c
refs/heads/master
2020-04-11T11:02:32.024231
2018-04-22T09:00:56
2018-04-22T09:00:56
50,062,432
0
0
null
null
null
null
UTF-8
C++
false
false
379
cpp
Joint.cpp
//================================================================ // Joint.cpp //================================================================ #include "Joint.hpp" //================================================================ Joint::Joint() : body1(0) , body2(0) , P(0.0f, 0.0f) , biasFactor(0.2f) , softness(0.0f) {}
aa5fadca230b9ec3366ee47ab9891c57c42c0b11
dab18ad37866e4ddc7f93ac548888751e543fe47
/modules/behavior/Formation.h
fe38f46f8ae45ad1950a78dd428b4ed465a11a6e
[]
no_license
samindaa/TopoFramework
1910cd9c0d7d3b51e6710df89c5dffc22d29d262
d0ff72500fc6d27656a96d2efad49e9bb81e9f5d
refs/heads/master
2021-01-23T11:50:53.187302
2013-10-06T03:09:23
2013-10-06T03:09:23
11,386,169
0
1
null
null
null
null
UTF-8
C++
false
false
1,576
h
Formation.h
#ifndef FORMATION_H #define FORMATION_H #include "kernel/Template.h" #include "representations/rcss/FieldDimensions.h" #include "representations/perception/FrameInfo.h" #include "representations/perception/Gamestate.h" #include "representations/perception/PlayerInfo.h" #include "representations/modeling/RobotPose.h" #include "representations/modeling/BallPos.h" #include "representations/modeling/OtherRobots.h" #include "representations/behavior/PlayerRole.h" #include "representations/behavior/BlockPosition.h" MODULE(Formation) REQUIRES(FrameInfo) REQUIRES(FieldDimensions) REQUIRES(Gamestate) REQUIRES(PlayerInfo) REQUIRES(RobotPose) REQUIRES(BallPos) REQUIRES(OtherRobots) REQUIRES(BlockPosition) PROVIDES(PlayerRole) END_MODULE class Formation : public FormationBase { public: void init(); void execute(); void update(PlayerRole& thePlayerRole); private: //which player is the striker bool closest_to_ball(int skip); float get_walk_cost(Vector2<double> robot, Vector2<double> dest); Vector2<double> get_intercept_pos(Vector2<double> robot, Vector2<double> point, Vector2<double> point_speed); //positioning of others Pose2D supporterAndDefendersSimple(); bool inPenaltyArea(const Vector2<double> &v); int ownPlayersCloserToPoint(Vector2<double> point); Vector2<double> getSupporterPosition(Vector2<double> ball_position); int nBlocker; int confNumBlocker; int confNumStrikerSupporter; int timeLastKickoff; }; #endif
f6edfc2792c668848ac9d79080c22d38cd362924
a92237bd9b14f588b9fdae06f60ddca998f504c3
/src/pieces/King.cpp
16967600a398a97be23c369e4a835c115276a852
[]
no_license
darrian12/Chess
2149c132fb962d8c486251d3f02c12135d8052f6
13ef6491d5832540132d1f310881a424c5287cbe
refs/heads/main
2023-02-24T23:19:25.336811
2021-01-31T22:10:27
2021-01-31T22:10:27
334,757,171
0
0
null
null
null
null
UTF-8
C++
false
false
564
cpp
King.cpp
#include "King.h" King::King(int tile, COLOR color) { m_tile = tile; m_type = Piece::TYPE::KING; m_color = color; SetupMoves(); } King::~King() { } void King::SetupMoves() { m_validMoves = { Move(Move::Direction::UP_LEFT, 1), Move(Move::Direction::UP, 1), Move(Move::Direction::UP_RIGHT, 1), Move(Move::Direction::LEFT, 1), Move(Move::Direction::RIGHT, 1), Move(Move::Direction::DOWN_LEFT, 1), Move(Move::Direction::DOWN, 1), Move(Move::Direction::DOWN_RIGHT, 1), }; }
1483a43594c10d37a48aadc5e9d407b17b296260
8bea9cde04655aad2563a7c1a0e0f26b9802b792
/DEFER2/def2.cxx
4e8324ace99a4faba416c4e82153b68327c7d9d1
[]
no_license
alex19999/upgraded-broccoli
db5d4bf266d25da0e0618e0789f6846a74c9485a
00d5a0fd65729390e5add59ceae1fcaf1f6a1e8b
refs/heads/master
2020-04-06T04:12:45.749619
2017-09-22T18:15:19
2017-09-22T18:15:19
83,016,460
0
0
null
2017-09-22T18:13:41
2017-02-24T07:56:54
C++
UTF-8
C++
false
false
6,302
cxx
def2.cxx
#include <cstdio> #include <cmath> #include <cstdlib> #include <cstring> #include"def2.hxx" #include<cassert> #include<cctype> #include <unistd.h> #define MAX_OP 10 Node::Node (Node* parent, double data, type t): data_ (data), type_ (t), left_ (NULL), right_ (NULL), parent_ (parent) {} Def2 :: Def2(): data(0), ptr(0) { FILE* f_in = fopen ("f_in.txt", "r"); fseek (f_in, 0, SEEK_END); long f_size = ftell (f_in); rewind (f_in); data = new char [f_size + 1]; size_t c = fread (data,sizeof(char), (size_t) f_size, f_in); assert (c == (size_t) f_size); data [f_size] = '\0'; PRINT ("file Size = %d\n", (int)f_size); int i; for (i = 0; i < f_size - 1; i++) { PRINT ("%c", data [i]); } PRINT ("\n"); fclose (f_in); } Def2 :: ~Def2() { delete[]data; } Node* Def2 :: GetN(Node* parent){ PRINT ("I am GetN \n"); int val = 0; while ('0' <= data[ptr] && data[ptr] <= '9'){ val = val*10 + data[ptr] - '0'; ptr++; } Node* newNode = new Node (parent, val, _const); PRINT ("I've found %d\n", val); return newNode; } Node* Def2 :: GetF (Node* parent) { PRINT ("I am GetF\n"); while (isalpha (data[ptr])){ char op_[MAX_OP] = {}; int i = 0; while (isalpha (data[ptr])){ op_[i] = data [ptr]; ptr++; i++; } PRINT ("%s\n", op_); if (!strcmp (op_, "ln")){ PRINT ("I've found ln\n"); Node* newNode = new Node (parent, _ln, _oper); Node* Ln_arg = GetP (parent); newNode->left_ = Ln_arg; Ln_arg->parent_ = newNode; return newNode; } else if (!strcmp (op_, "x")) { PRINT ("I've found X\n"); Node* newNode = new Node (parent, 0, _value); return newNode; } else { PRINT ("Unknown command!\n"); exit (0); } } return GetP (parent); } Node* Def2 :: GetP (Node* parent) { if (data[ptr] == '('){ PRINT ("I've found %c\n", data[ptr]); ptr++; Node* val = GetE (parent); PRINT ("I've found %c\n", data[ptr]); assert (data[ptr] == ')'); ptr++; return val; } else { return GetN (parent); } } Node* Def2 :: GetT (Node* parent) { PRINT ("I am GetT \n"); bool fl = false; double s = 0; Node* val = GetF (parent); Node* newNode = NULL; while (data[ptr] == '*' || data[ptr] == '/') { fl = true; int operat = data[ptr]; PRINT ("I've found mul or div\n"); ptr++; Node* val2 = GetF (parent); (operat == '*')? s = _mul: s = _div; newNode = new Node (parent, s, _oper); newNode->left_ = val; newNode->right_ = val2; val->parent_ = newNode; val2->parent_ = newNode; } if (fl == true) { return newNode; } else { return val; } } Node* Def2 :: GetE (Node* parent) { PRINT ("I am GetE \n"); bool fl = false; double s = 0; Node* val = GetT (parent); Node* newNode = NULL; while(data[ptr] == '+' || data[ptr] == '-') { fl = true; int operat = data[ptr]; PRINT ("I've found plus or minus\n"); ptr++; Node* val2 = GetT (parent); (operat == '+')? s = _add: s = _sub; newNode = new Node (parent, s, _oper); newNode->left_ = val; newNode->right_ = val2; val->parent_ = newNode; val2->parent_ = newNode; } if (fl == true) { return newNode; } else { return val; } } Node* Def2 :: GetG (Node* parent) { PRINT ("I am GetG \n"); Node* head = GetE (parent); PRINT ("!!!%s!!!\n", data); PRINT ("ptr = %d\n", ptr); PRINT ("(ptr - 1) = %c\n", (ptr - 1)); PRINT ("(ptr) = %c\n", ptr); PRINT ("(ptr + 1) = %c\n", (ptr + 1)); assert (data [ptr + 1] == '\0'); return head; } void texN (Node* node, FILE* stream) { assert (stream); if (!node) return; if (node->nodeCmp (node, _const)) { fprintf (stream, "{%lg}", node->data_); } else if (node->nodeCmp (node, _value)) { fprintf (stream, "{x}"); } else if (node->nodeCmp (node, _oper, _add)) { fprintf (stream, "{("); texN(node->left_ , stream); fprintf (stream, "}+{"); texN (node->right_, stream); fprintf (stream, ")}"); } else if (node->nodeCmp (node, _oper, _sub)) { fprintf (stream, "{("); texN (node->left_ , stream); fprintf (stream, "}-{"); texN (node->right_, stream); fprintf (stream, ")}"); } else if (node->nodeCmp (node, _oper, _mul)) { fprintf (stream, "{"); texN(node->left_ , stream); fprintf (stream, "}*{"); texN (node->right_, stream); fprintf (stream, "}"); } else if (node->nodeCmp (node, _oper, _div)) { fprintf (stream, "\\frac{"); texN (node->left_, stream); fprintf (stream, "}{"); texN (node->right_, stream); fprintf (stream, "}"); } else if (node->nodeCmp (node, _oper, _ln)) { fprintf (stream, "ln"); fprintf (stream, "\\left("); texN (node->left_, stream); texN (node->right_, stream); fprintf (stream, "\\right)"); } } void tex(Node* oldTree, Node* newTree) { assert (oldTree); assert (newTree); FILE* stream = fopen ("./TexDump/diff.tex", "w"); assert (stream); fprintf (stream,"\\documentclass{article}\n" "\\usepackage[a4paper, margin=6mm]{geometry}\n" "\\usepackage{amsmath}\n" "\\title{Differentiator}\n" "\\begin{document}\n" "\\maketitle\n" "\\begin{eqnarray}\n" "\\left( "); texN (oldTree, stream); fprintf (stream, "\\right) ' = \n"); texN (newTree, stream); fprintf (stream, "\\end{eqnarray}\n" "\\end{document}\n"); fclose (stream); chdir ("./TexDump"); system ("pdflatex diff.tex"); system ("evince diff.pdf"); system ("mv diff.pdf ./../"); }
2b230a37735040e8ebc15553bc371773c923de75
734ad0714537e082832fc8c5c9746edb991a5b14
/src/main.cpp
aa3113cd86e80526f4e5ddace794bec19a98dc6f
[ "MIT" ]
permissive
ipud2/KingEngine
d672cb9d4425bca0a9196d92e81973cda2312fd3
5c7e5ff89bfd7acc1031470660fc89b06d56101b
refs/heads/master
2020-06-29T13:23:31.332861
2016-07-22T03:22:10
2016-07-22T03:22:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,775
cpp
main.cpp
#include "ksApplication.h" #include "ksComplex.h" #include "ksPathFinder.h" #include "ksButton.h" #include "ksContainer.h" #include "ksTransition.h" #include "ksScene.h" #include "ksAudioTrack.h" #include "ksImageControl.h" #include <string> #include <vector> #include <iostream> int main() { ksApplication app("KingEngine", DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT); app.setEntityTilesheet("images/voltor_interior2.png"); //app.loadWorld(800, 400, 800, 4, 8, 8, "maps/exterior"); app.loadWorldDemo(); // World, Color, Location, size, num, velocity, and reach (time to live) // ksParticleEmitter emitter(app.getWorld(), sf::Color(0, 0, 255, 200), sf::Vector3f(0, 0, -192), 8, 20, 20, 60); ksParticleEmitter emitter(app.getWorld(), sf::Color(0, 0, 255, 200), sf::Vector3f(0, 0, -600), 8, 20, 20, 60); app.addParticleEmitter(&emitter); // Sunny day ksLightSystem lighting(app.getWorld(), sf::Color(0, 0, 0, 100), sf::Color(0, 0, 0, 255)); lighting.addLight(sf::Vector3f(128, 128, 0), 256, sf::Color(255, 200, 0, 255)); // Nightime // ksLightSystem lighting(app.getWorld(), sf::Color(0, 0, 255, 120), sf::Color(0, 0, 255, 60)); // //lighting.addLight(sf::Vector3f(128, 128, 800), 256, sf::Color(255, 255, 200, 255)); app.addLightSystem(&lighting); // Create a wrapper for a column of rows of buttons. ksContainer background(800, 400, ksAlign::CENTER, ksColor(255, 255, 255, 255), 0); app.addControl(&background); ksContainer container_foreground(800, 400, ksAlign::CENTER, ksColor(255, 255, 255, 0), 0); app.addControl(&container_foreground); ksImageControl title("images/KingEngineLogo.png", 14, 40, 771, 320); ksButton btn_fore(app.getFont(), "Something", 100, 35); container_foreground.addControl(&title); double container_opacity = 1.0; // Create the directions message. ksContainer container_message(480, 128, ksAlign::COLUMN, ksColor(0, 0, 0, 120), 300, 20); app.addControl(&container_message); ksLabel lbl_message(app.getFont(), "Welcome to this KingEngine demonstration!", 0, 0); ksLabel lbl_message2(app.getFont(), "These angry villagers are chasing after the player.", 0, 0); ksLabel lbl_message3(app.getFont(), "Move around using WASD.", 0, 0); ksButton btn_accept(app.getFont(), "Ok", 96, 32); container_message.addControl(&lbl_message); container_message.addControl(&lbl_message2); container_message.addControl(&lbl_message3); container_message.addControl(&btn_accept); container_message.setVisibility(false); container_message.setPosition(0, 0); double executive_diagram_opacity = 0.0; ksPathFinder path_finder(app.getWorld()); int emitter_x = 400; int emitter_z = 400; ksAudioTrack track("audio/a_theme_among_themes.ogg", 120, 100); bool transitioning = false; double title_opacity = 0.0; double sun_z_position = 0.0; ksScene<double> title_fade_in; title_fade_in.addTransition(ksTransition<double>(&title_opacity, 1.0, 120)); ksScene<double> title_pause; title_pause.addTransition(ksTransition<double>(&title_opacity, 1.0, 240)); ksScene<double> title_fade_out; title_fade_out.addTransition(ksTransition<double>(&title_opacity, 0.0, 120)); title_fade_out.addTransition(ksTransition<double>(&container_opacity, 0.0, 120)); title_fade_out.addTransition(ksTransition<double>(&sun_z_position, 801.0, 150)); app.addScene(&title_fade_in); app.addScene(&title_pause); app.addScene(&title_fade_out); bool sequence_paused = false; ksEntity tree(app.getWorld(), 600, 0, 800, 2, 4, 18); app.addEntity(&tree); // ksComplex ent(&path_finder, app.getWorld(), 400, 200, 32, 1, 2, 10); ksComplex ent(&path_finder, app.getWorld(), 400, 200, 32, 2, 2, 30); app.addEntity(&ent); ent.setAnimationLower(27); ent.setAnimationUpper(29); ent.setAnimationDelay(30); ent.toggleBehavior(); // Add angry villagers. std::vector<ksComplex *> entity_list; int entity_num = 0; for (int count = 0; count < 4; ++count) { entity_list.push_back(new ksComplex(&path_finder, app.getWorld(), emitter_x, 200, emitter_z, 2, 2, 66)); entity_list[entity_num]->setAnimationLower(66); entity_list[entity_num]->setAnimationUpper(71); entity_list[entity_num]->setAnimationDelay(5); app.addEntity(entity_list[entity_num++]); } for (int count = 0; count < entity_num; ++count) { for (int count2 = 0; count2 < entity_num; ++count2) { entity_list[count]->addToGroup(entity_list[count2]); entity_list[count]->arrive(ksVector2D(ent.X(), ent.Z())); } entity_list[count]->group(); entity_list[count]->avoidObstacles(); } // Flowers std::vector<ksEntity *> flower_list; int flower_num = 0; for (int col = 0; col < app.getWorld()->getMapCol(); ++col) { for (int depth = 0; depth < app.getWorld()->getMapDepth(); ++depth) { flower_list.push_back(new ksEntity(app.getWorld(), col * 100, 300, depth * 100, 1, 1, 31)); flower_list[flower_num]->setAnimationLower(31); flower_list[flower_num]->setAnimationUpper(32); flower_list[flower_num]->setAnimationDelay(30); app.addEntity(flower_list[flower_num++]); } } // Run the app without a main loop //app.run(); while (app.isOpen()) { if (app.getKeyDown(ksKey::Space)) { // Start or pause the sequence of scenes. if (sequence_paused) app.startSequence(); else app.pauseSequence(); // Toggle the sequence paused boolean. sequence_paused = !sequence_paused; } else if (app.getKeyDown(ksKey::Return)) container_message.setVisibility(false); else if (app.getKeyDown(ksKey::Left)) app.rotateWorldLeft(20); else if (app.getKeyDown(ksKey::Right)) app.rotateWorldRight(20); // Set default animation for player ent.setAnimationLower(27); ent.setAnimationUpper(29); ent.setAnimationDelay(30); if (app.getKeyDown(ksKey::W)) { if ((ent.Z() + 50) < app.getWorld()->getDepth()) ent.moveEntity(0, 0, 50); ent.setAnimationLower(37); ent.setAnimationUpper(42); ent.setAnimationDelay(5); } if (app.getKeyDown(ksKey::S)) { if ((ent.Z() - 50) > 0) ent.moveEntity(0, 0, -50); ent.setAnimationLower(30); ent.setAnimationUpper(35); ent.setAnimationDelay(5); } if (app.getKeyDown(ksKey::A)) { if ((ent.X() - 25) > 0) ent.moveEntity(-25, 0, 0); ent.setAnimationLower(55); ent.setAnimationUpper(60); ent.setAnimationDelay(5); } if (app.getKeyDown(ksKey::D)) { if ((ent.X() + 25) < app.getWorld()->getWidth()) ent.moveEntity(25, 0, 0); ent.setAnimationLower(46); ent.setAnimationUpper(51); ent.setAnimationDelay(5); } for (int count = 0; count < entity_num; ++count) { entity_list[count]->arrive(ksVector2D(ent.X(), ent.Z())); } if (title_fade_in.isDone() && !transitioning) { track.transitionTrack("audio/the_honeymoon.ogg"); transitioning = true; } track.update(); if (title_pause.isDone() && !title_fade_out.isDone()) { // Get the sun's position. ksVector3f temp = lighting.getLightPosition(0); // Update the sun's z coordinate. temp.z = sun_z_position; // Update the position of the light source. lighting.setLightPosition(0, temp.x, temp.y, temp.z); //lighting.addLight(sf::Vector3f(128, 128, sun_z_position), 256, sf::Color(255, 200, 0, 255)); } if (title_fade_out.isDone()) { container_message.setVisibility(true); //executive_diagram.setVisibility(true); } //app.setTextColor("subtitle", ksColor(0, 0, 0, title_alpha)); background.setOpacity(container_opacity); container_foreground.setOpacity(title_opacity); } return 0; }
71ff525765a8b2296360f6f58f4e971c14bfa6fc
c3a3a524a70873fa5a8dd01df3b1f90cbd75fb0a
/bug_one/src/bugrobot.h
9d44ff462e116a58a53c122c2fcae203dfc11f37
[]
no_license
Dearth/ROS_BugOne
4232fb97b8d968da4805f49e5016cf134ad0d7d5
7f81cd465f8eef626beb560d983bac32f70b3683
refs/heads/master
2021-05-28T05:14:03.380152
2015-02-24T03:32:22
2015-02-24T03:32:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,959
h
bugrobot.h
#ifndef _BUGROBOT_H_ #define _BUGROBOT_H_ #include <ros/ros.h> #include <std_msgs/String.h> #include <iostream> #include <ros/ros.h> #include <geometry_msgs/Twist.h> #include <sstream> #include <nav_msgs/Odometry.h> #include <sensor_msgs/LaserScan.h> #include <tf/transform_broadcaster.h> #include <cmath> #include "Location.h" #include <vector> #include <algorithm> //My robot and all that it does. class BugRobot { public: BugRobot(ros::NodeHandle&, double, double); void run(); protected: void poseCallBack(const nav_msgs::Odometry::ConstPtr&); void laserScanCallBack(const sensor_msgs::LaserScan::ConstPtr&); void moveBug(); private: //gereral useful calculations double calcBearing(position_s&, position_s&); void findNearWall(); bool isLeft(position_s&); bool isRight(position_s&); //takes in a bearing and gives the approximate index int calcRangeIndex(double); //calculate a bearing with respect to the robots frame. double calcRobotBearing(position_s&); //general movement void moveTowardDest(); bool isBlockedZero(); geometry_msgs::Twist followWall(); //bug algorithms void navigateWalls(); ros::Publisher cmd_vel_pub_; ros::Subscriber base_truth_sub_; ros::Subscriber laser_scan_sub_; position_s current_pos_; position_s destination_; position_s closest_wall_; std::vector<double> range_scan_; double range_incr_; double range_min_; bool following_wall_; bool in_corner_; }; //Figure out if we are blocked for bug Zero bool BugRobot::isBlockedZero() { double robotDest; int index, wallIndex; findNearWall(); wallIndex = calcRangeIndex(closest_wall_.bearing); robotDest = calcRobotBearing(destination_); index = calcRangeIndex(robotDest); if( !following_wall_ ) { //check wall index if( (wallIndex < 0) || (wallIndex > range_scan_.size()) ) { following_wall_ = false; return false; } //enter range looking for walls if ( range_scan_[wallIndex] < 0.8) { //If we can't see destination follow wall if ( (index > 1081) || (index < 0) ) { following_wall_ = true; return true; } if( range_scan_[index] < 5.0 ) { following_wall_ = true; return true; } } } else { //If we can't see destination follow wall if ( (index > 1081) || (index < 0) ) { following_wall_ = true; return true; } //Check if we have los if ( range_scan_[index] >= 2 ) { //check wall index if( (wallIndex < 0) || (wallIndex > range_scan_.size()) ) { following_wall_ = false; return false; } //check if we are at a corner on the same side as dest if ( range_scan_[wallIndex] < 1.3 && closest_wall_.bearing < 0 && robotDest < 0 ) { return true; } else if (range_scan_[wallIndex] < 1.3 && closest_wall_.bearing > 0 && robotDest > 0 ){ return true; } else { following_wall_ = false; return false; } } else { return true; } } } void BugRobot::navigateWalls() { geometry_msgs::Twist msg; /* INDEX 0F -PI/2 = 180 INDEX OF PI/2 = 899 INDEX OF 0 = 540 HARDCODED DUE TO SEGFAULT */ if ( !in_corner_ ) { //if CC left corner if (range_scan_[540] < 0.7 && range_scan_[180] < 1.3 ) { in_corner_ = true; msg.angular.z = -0.2; } //if CC right corner else if (range_scan_[540] < 0.7 && range_scan_[899] < 1.3 ) { in_corner_ = true; msg.angular.z = 0.2; } else { msg = followWall(); } } else { if ( range_scan_[540] < 4.0 ) { if ( range_scan_[180] < 1.3 ) { msg.angular.z = -0.2; } else { msg.angular.z = 0.2; } } else { in_corner_ = false; msg = followWall(); } } cmd_vel_pub_.publish(msg); } //movement tp follow the wall geometry_msgs::Twist BugRobot::followWall() { geometry_msgs::Twist msg; double min_wall_dist = 0.8; double max_wall_dist = 1.2; int wallIndex = calcRangeIndex(closest_wall_.bearing); //if wall is on left if ( closest_wall_.bearing > 0 ) { if ( !isLeft(closest_wall_)) { if (closest_wall_.bearing > M_PI_2) { msg.angular.z = 0.1; } else { msg.angular.z = -0.1; } } else { if ( range_scan_[wallIndex] < min_wall_dist ) { msg.angular.z = -0.1; msg.linear.x = 0.25; } else if ( range_scan_[wallIndex] > max_wall_dist ) { msg.angular.z = 0.1; msg.linear.x = 0.25; } else { msg.linear.x = 0.25; } } } //if wall is on right else if ( closest_wall_.bearing < 0 ) { if ( !isRight(closest_wall_)) { if (closest_wall_.bearing < -M_PI_2) { msg.angular.z = -0.1; } else { msg.angular.z = 0.1; } } else { if ( range_scan_[wallIndex] < min_wall_dist ) { msg.angular.z = 0.1; msg.linear.x = 0.25; } else if ( range_scan_[wallIndex] > max_wall_dist ) { msg.angular.z = -0.1; msg.linear.x = 0.25; } else { msg.linear.x = 0.25; } } } else { msg.linear.x = 0.25; } return msg; } //movement if we are not blocked void BugRobot::moveTowardDest() { geometry_msgs::Twist msg; in_corner_ = false; destination_.bearing = calcBearing(current_pos_, destination_); if ( !destination_.isEqualAproxLoc(current_pos_) ) { if( !destination_.isEqualAproxBearing(current_pos_) ) { if ( destination_.bearing > current_pos_.bearing ) { msg.angular.z = 0.1; } else { msg.angular.z = -0.1; } } else { msg.linear.x = 0.25; } } else { msg.linear.x = msg.linear.y = msg.linear.z = msg.angular.z = 0; } cmd_vel_pub_.publish(msg); } //Initialize all values of the robot, set up subscriber and publisher. BugRobot::BugRobot(ros::NodeHandle& nh, double goal_x, double goal_y) { // save my goal destination_.x = goal_x; destination_.y = goal_y; following_wall_ = false; in_corner_ = false; range_scan_.resize(1081); //Create publisher for cmd_vel cmd_vel_pub_ = nh.advertise<geometry_msgs::Twist>("/cmd_vel",1); //Create subscription to base_scan laser_scan_sub_ = nh.subscribe("/base_scan", 1, &BugRobot::laserScanCallBack, this); //Create a subscription to base_pose_ground_truth base_truth_sub_ = nh.subscribe("/base_pose_ground_truth", 1, &BugRobot::poseCallBack, this); } //base_pose_ground_truth call back void BugRobot::poseCallBack(const nav_msgs::Odometry::ConstPtr& msg) { tf::Pose pose; //Get x and y values current_pos_.x = msg->pose.pose.position.x; current_pos_.y = msg->pose.pose.position.y; //get bearing as angle tf::poseMsgToTF(msg->pose.pose, pose); current_pos_.bearing = tf::getYaw(pose.getRotation()); } //base_scan call back void BugRobot::laserScanCallBack(const sensor_msgs::LaserScan::ConstPtr& msg) { range_incr_ = msg->angle_increment; range_min_ = msg->angle_min; for( int i = 0; i < range_scan_.size(); ++i ) { range_scan_[i] = msg->ranges[i]; } } //calculate nearest wall void BugRobot::findNearWall() { position_s temp; int index = 0; double close_range = 31; for ( int i = 0; i < range_scan_.size(); ++i ) { if ( close_range > range_scan_[i] ) { close_range = range_scan_[i]; index = i; } } closest_wall_.x = (close_range * sin((index*range_incr_)+range_min_)) + current_pos_.x; closest_wall_.y = (close_range * cos((index*range_incr_)+range_min_)) + current_pos_.y; closest_wall_.bearing = (index*range_incr_) + range_min_; } //Calculat the angle of a bearing with respect to the robots frame. double BugRobot::calcRobotBearing(position_s& dest) { position_s roboDest; position_s origin(0,0,0); double x = dest.x - current_pos_.x; double y = dest.y - current_pos_.y; roboDest.x = x * cos(current_pos_.bearing) + y * sin(current_pos_.bearing); roboDest.y = -(x * sin(current_pos_.bearing)) + y * cos(current_pos_.bearing); roboDest.bearing = calcBearing(origin, roboDest); return roboDest.bearing; } //Calculate the approximate index of a value in range_scan_ given a bearing int BugRobot::calcRangeIndex(double bearing) { return (bearing - range_min_) / range_incr_; } //Calculate the bearing between two points. double BugRobot::calcBearing(position_s& current, position_s& dest) { return atan2(dest.y - current.y, dest.x - current.x); } //Calculate if a given position is on our left or on our right. bool BugRobot::isLeft(position_s& dest) { position_s left(0,0,M_PI_2); return dest.isEqualAproxBearing(left); } bool BugRobot::isRight(position_s& dest) { position_s right(0,0,-M_PI_2); return dest.isEqualAproxBearing(right); } //Move the robot a single step void BugRobot::moveBug() { if ( isBlockedZero() ) { navigateWalls(); } else { moveTowardDest(); } } void BugRobot::run() { ros::Rate rate(30); while(ros::ok()){ moveBug(); ros::spinOnce(); rate.sleep(); } } #endif
e0c4de91a6bb067b0e19aa14659268c9b45ede1d
eda03521b87da8bdbef6339b5b252472a5be8d23
/Tests/AK/TestCircularQueue.cpp
337164725d0d78f1e4db011439764a504a8542a2
[ "BSD-2-Clause" ]
permissive
SerenityOS/serenity
6ba3ffb242ed76c9f335bd2c3b9a928329cd7d98
ef9b6c25fafcf4ef0b44a562ee07f6412aeb8561
refs/heads/master
2023-09-01T13:04:30.262106
2023-09-01T08:06:28
2023-09-01T10:45:38
160,083,795
27,256
3,929
BSD-2-Clause
2023-09-14T21:00:04
2018-12-02T19:28:41
C++
UTF-8
C++
false
false
1,573
cpp
TestCircularQueue.cpp
/* * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ #include <LibTest/TestCase.h> #include <AK/CircularQueue.h> #include <AK/DeprecatedString.h> TEST_CASE(basic) { CircularQueue<int, 3> ints; EXPECT(ints.is_empty()); ints.enqueue(1); ints.enqueue(2); ints.enqueue(3); EXPECT_EQ(ints.size(), 3u); ints.enqueue(4); EXPECT_EQ(ints.size(), 3u); EXPECT_EQ(ints.dequeue(), 2); EXPECT_EQ(ints.dequeue(), 3); EXPECT_EQ(ints.dequeue(), 4); EXPECT_EQ(ints.size(), 0u); } TEST_CASE(complex_type) { CircularQueue<DeprecatedString, 2> strings; strings.enqueue("ABC"); strings.enqueue("DEF"); EXPECT_EQ(strings.size(), 2u); strings.enqueue("abc"); strings.enqueue("def"); EXPECT_EQ(strings.dequeue(), "abc"); EXPECT_EQ(strings.dequeue(), "def"); } TEST_CASE(complex_type_clear) { CircularQueue<DeprecatedString, 5> strings; strings.enqueue("xxx"); strings.enqueue("xxx"); strings.enqueue("xxx"); strings.enqueue("xxx"); strings.enqueue("xxx"); EXPECT_EQ(strings.size(), 5u); strings.clear(); EXPECT_EQ(strings.size(), 0u); } struct ConstructorCounter { static unsigned s_num_constructor_calls; ConstructorCounter() { ++s_num_constructor_calls; } }; unsigned ConstructorCounter::s_num_constructor_calls = 0; TEST_CASE(should_not_call_value_type_constructor_when_created) { CircularQueue<ConstructorCounter, 10> queue; EXPECT_EQ(0u, ConstructorCounter::s_num_constructor_calls); }
c66a9bbebae97002522e7950c1f35dd7adc55b51
e648a965eb5816817ecf829be0057cc9621d5080
/Animator/particleSystem.cpp
d89e6aecc6d4e66ce7dbefe459a0badad1d5173e
[]
no_license
siusiukim/COMP4411
cb558b747304462afe9e006fe5945c17c7bcde29
4a31b6a6912b0f284cd7bce7e1c309622e57fdbe
refs/heads/master
2020-05-18T19:50:33.451384
2018-05-05T15:39:07
2018-05-05T15:39:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,927
cpp
particleSystem.cpp
#pragma warning(disable : 4786) #include "particleSystem.h" #include "modelerview.h" #include "modelerapp.h" #include "modelerdraw.h" #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <math.h> #include <limits.h> using namespace std; /************* * Destructor *************/ ParticleSystem::~ParticleSystem() { // TODO } /****************** * Simulation fxns ******************/ /** Start the simulation */ void ParticleSystem::startSimulation(float t) { // TODO currParticles.clear(); bake_start_time = t; // These values are used by the UI ... // -ve bake_end_time indicates that simulation // is still progressing, and allows the // indicator window above the time slider // to correctly show the "baked" region // in grey. bake_end_time = -1; simulate = true; dirty = true; } /** Stop the simulation */ void ParticleSystem::stopSimulation(float t) { // TODO currParticles.clear(); bake_end_time = t; // These values are used by the UI simulate = false; dirty = true; } /** Reset the simulation */ void ParticleSystem::resetSimulation(float t) { // TODO currParticles.clear(); // These values are used by the UI simulate = false; dirty = true; } /** Compute forces and update particles **/ void ParticleSystem::computeForcesAndUpdateParticles(float t) { if (simulate) { bakeParticles(t); } } /** Render particles */ void ParticleSystem::drawParticles(float t) { int key = t * 100; map<int, vector<Particle>>::iterator iter = baked.lower_bound(key); if (iter != baked.end()) { //Have something in it if (key - iter->first <= 10) { vector<Particle> particles = iter->second; for (int i = 0; i < particles.size(); i++) { Particle p = particles[i]; setDiffuseColor(p.color[0], p.color[1], p.color[2]); glPushMatrix(); { glTranslated(p.pos[0], p.pos[1], p.pos[2]); drawBox(0.1, 0.1, 0.1); } glPopMatrix(); } } else { cout << "Time error" << endl; } } } void ParticleSystem::addParticle(Particle p) { currParticles.push_back(p); } void ParticleSystem::addForce(Vec3f force) { forces.push_back(force); } /** Adds the current configuration of particles to * your data structure for storing baked particles **/ void ParticleSystem::bakeParticles(float t) { int key = (t * 100); vector<Particle> particles; for (int i = 0; i < currParticles.size(); i++) { Particle p = currParticles[i]; if (!p.willDie(particleLife)) { particles.push_back(p); } } //Apply force and euler for (int j = 0; j < particles.size(); j++) { for (int i = 0; i < forces.size(); i++) { particles[j].fac += forces[i]; } particles[j].doEuler(); } //Put it into map currParticles.assign(particles.begin(), particles.end()); baked.insert(pair<int, vector<Particle>>(key, particles)); } /** Clears out your data structure of baked particles */ void ParticleSystem::clearBaked() { baked.clear(); }
ccafdfdc022fc7f77066e049f93588d60342be5b
2292df0f8b4670bb979b92b4e797fb31686be083
/SceneNodeManager/Node.cpp
e0c678027818735947582ee3d08a7d8268068e7b
[]
no_license
LiuYiZhou95/LeetCode
25877207a15283d9aa1885d3be6eb428aebedfca
2bcbdac2b5fed4f46fff30951cabc2ddbbc45ffe
refs/heads/master
2020-08-27T19:47:43.276752
2019-10-25T07:24:54
2019-10-25T07:24:54
217,474,743
0
0
null
null
null
null
UTF-8
C++
false
false
2,634
cpp
Node.cpp
// // Node.cpp // SharedPointer // // Created by action.zhou on 2019/8/12. // Copyright © 2019年 action.zhou. All rights reserved. // #include <stdio.h> #include "Node.h" #include "Scene.h" #include <iostream> using namespace std; Node::Node(int i) :i(i), scene_(nullptr), parent_(nullptr) { } Node::~Node(){ } int Node::getValue(){ return i; } void Node::SetScene(Scene* scene) { scene_ = scene; } void Node::addChild(Node* parent,Node* child) { if (!child || child == this || child->parent_ == this) return; shared_ptr<Node> nodeShared(child); Node* oldParent = child->parent_; if (oldParent) { // If old parent is in different scene, perform the full removal if(this->GetScene()){ child->SetScene(this->GetScene()); } else{ } }else{ } vector <shared_ptr<Node>>::iterator theIterator = children_.begin(); children_.insert(theIterator,nodeShared); if (scene_ && child->GetScene() != scene_) scene_->addNode(child); child->parent_ = this; } void Node::addChild(Scene* parent,Node* child) { if (!child || child == this || child->GetScene() == this) return; child->SetScene(parent); vector <shared_ptr<Node>>::iterator theIterator = children_.begin(); shared_ptr<Node> nodeShared(child); children_.insert(theIterator,nodeShared); if (scene_ && child->GetScene() != scene_) scene_->addNode(child); child->parent_ = this; for(int i=0;i<nodeShared->children_.size();++i){ nodeShared->children_[i].get()->SetScene(parent); addChild(parent,nodeShared->children_[i].get()); }; } //-------------- // remove的时候应该注意避免野指针 //-------------- void Node::removeChild(Node* parent,Node* child) { if (!child || parent==child) return; // vector <shared_ptr<Node>>::iterator theIterator = find(children_.begin(),children_.end(),child); // theIterator=children_.erase(theIterator); // theIterator--; //迭代出当前指向child的node for (vector <shared_ptr<Node>>::iterator theIterator=children_.begin();theIterator!=children_.end();++theIterator) { if(theIterator->get()==child){ removeChild(theIterator); } } } //通过迭代器下标remove Node void Node::removeChild(vector <shared_ptr<Node>>::iterator i){ shared_ptr<Node> child(*i); child->parent_=nullptr; //可以清空scene指向 // child->scene_=nullptr; i=children_.erase(i); i--; }
cf937bedc08e0df3854faba77a8f6b69a67e9024
504d304c87cff76f4a710d7b6a4bba4c8b08e0bb
/include/nasoq/common/Util.h
24334746bd2ddae8f3e6750a2bcfb12a6c15791b
[ "MIT" ]
permissive
sympiler/nasoq
880e144e3f51fb73eec2cb0d96f98f458df11cd6
b1fba68c0f8fc87526c0be7d838f9483452f8920
refs/heads/master
2023-03-02T10:09:39.505343
2023-01-16T03:51:50
2023-01-16T03:51:50
249,756,245
64
17
MIT
2023-01-06T16:54:48
2020-03-24T16:14:32
C++
UTF-8
C++
false
false
12,427
h
Util.h
// // Created by kazem on 7/25/17. // #ifndef CHOLOPENMP_UTIL_H #define CHOLOPENMP_UTIL_H #include <fstream> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <sstream> #include <vector> #include "nasoq/common/def.h" #include "nasoq/common/transpose_unsym.h" namespace nasoq { /* * reading a CSC matrix from a coordinate file, stored col-ordered */ bool readMatrix_old(std::string fName, int &n, int &NNZ, int *&col, int *&row, double *&val); /* * reading a CSC matrix from a coordinate file, stored col-ordered */ bool readMatrix(std::string fName, size_t &n, size_t &NNZ, int *&col,//FIXME change col type to size_t int *&row, double *&val); /* * reading a CSC matrix from a coordinate file, stored col-ordered */ bool readMatrix_rect(std::string fName, size_t &n_row, size_t &n_col, size_t &NNZ, int *&col,//FIXME change col type to size_t int *&row, double *&val); /* * */ void read_dense(std::string fname, int &n_row, int &n_col, double *&mat); /* * */ int write_dense(std::string fname, int n_row, int n_col, double *mat); /* * expand the empty columns by one zero * e.g., in indefinite matrices where empty columns exist * returns false if the matrix is not expanded. */ bool expandMatrix(size_t n, size_t NNZ, const int *col, const int *row, const double *val, size_t &newNNZ, int *&newCol,//FIXME change col type to size_t int *&newRow, double *&newVal, double insDiag = 0); /* * reading a ordering from PasTiX stored format. */ int read_vector(std::string fName, size_t n, double *perm); /* * writing a vector to a file. */ int write_vector(std::string fName, size_t n, double *vec_vals, std::string header = "", int prec = 30); /* * reading a ordering from PasTiX stored format. */ bool readOrdering(std::string fName, size_t n, size_t *perm); bool enableColdCache(int n, std::ifstream &f); /* * For linear solver using A and A' */ void rhsInit_linearSolver(int n, int *Ap, int *Ai, double *Ax, //A int *Bp, int *Bi, double *Bx, //AT double *b); /* * Assuming we have only lower part of a symmetric matrix * return false if rhs is zero */ bool rhsInit_linearSolver_onlylower(int n, int *Ap, int *Ai, double *Ax, //A double *b); /* * For triangular solve */ void rhsInit(int n, int *Ap, int *Ai, double *Ax, double *b); /* * RHS initilization for blocked */ void rhsInitBlocked(size_t n, size_t nBlocks, size_t *Ap, int *Ai, size_t *AiP, double *Ax, double *b); /* * RHS initilization for blocked L' */ void rhsInitBlockedLT(size_t n, size_t nBlocks, size_t *Ap, int *Ai, size_t *AiP, double *Ax, double *b); /* * Making full symmetric matrix from lower and upper */ void make_full(int ncol, int nnz, int *Ap, int *Ai, double *Ax, //A int *ATransp, int *ATransi, double *ATransx, int &nnzFull, int *&AFullp, int *&AFulli, double *&AFullx); /* * Testing lower triangular solve to make sure all x elements are ONE. * Warning: This works only for when RHS does not have zero */ int testTriangular(size_t n, const double *x, double epsilon = 1e-3); /* * converting CSC to CSR */ //TODO /* void csc2csr(int n, int *Ap, int *Ar, double *Ax, int *row_ptr, int *col_idx, double *Bx) { int *row_len = new int[n](); int *finger = new int[n](); for (int i = 0; i < Ap[i + 1]; ++i) { row_len[Ar[i]]++; } col_idx[0] = 0; for (int l = 1; l < n + 1; ++l) { col_idx[l] = col_idx[l - 1] + row_len[l]; } for (int k = 0; k < n; ++k) { for (int i = Ap[i]; i < Ap[i + 1]; ++i) { //Bx[col_idx[]] } } } */ /* * Converting BCSC to CSC */ int bcsc2csc( //in size_t n, size_t nBlocks, size_t *Ap, int *Ai, size_t *AiP, int *sup2col, double *Ax, //out int *Cp, int *Ci, double *Cx ); /* * Converting BCSC to CSC, removing all zeros, assuming * fill-ins are initially zero. * Warning: could be problematic in some exceptional cases where, * exact numerical cancellation happens. */ int bcsc2csc_aggressive( //in size_t n, size_t nBlocks, size_t *Ap, int *Ai, size_t *AiP, int *sup2col, double *Ax, //out //MKL_INT *Cp, MKL_INT *Ci, double *Cx size_t *Cp, int *Ci, double *Cx ); int check_row_idx_l( //in size_t n, size_t nBlocks, size_t *Ap, int *Ai, size_t *AiP, int *sup2col ); int bcsc2csc_aggressive_int( //in size_t n, size_t nBlocks, size_t *Ap, int *Ai, size_t *AiP, int *sup2col, double *Ax, //out //MKL_INT *Cp, MKL_INT *Ci, double *Cx int *Cp, int *Ci, double *Cx ); void swapWSet(std::vector<std::vector<int>> &List, int i, int j); /* * Check whether the matrix is stored in full * return the lower half if it is full * Makes sense only for symmetric matrices. */ CSC *computeLowerTriangular(CSC *A); void print_csc(std::string beg, size_t n, int *Ap, int *Ai, double *Ax); void print_csc_l(std::string beg, size_t n, long *Ap, int *Ai, double *Ax); template<class type> void print_vec(std::string header, int beg, int end, type *vec) { std::cout << header; for (int i = beg; i < end; ++i) { std::cout << std::setprecision(15) << vec[i] << ", "; } std::cout << "\n"; } /* * Print dense matrix, stored col-wise * */ template<class type> void print_mat(std::string header, int row_no, int col_no, type *mat) { std::cout << header; for (int i = 0; i < col_no; ++i) { for (int j = 0; j < row_no; ++j) { std::cout << std::setprecision(15) << mat[i * row_no + j] << ", "; } std::cout << "\n"; } std::cout << "\n"; } int *compute_inv_perm(int n, int *perm, int *pinv); void combine_perms(int n, int *perm1, int *perm2, int *result); int zero_diag_removal(size_t n, size_t NNZ, const int *col, const int *row, double *val, double threshold, double reg_diag); /* * return 0 if equal */ int is_vector_equal(int n, double *v1, double *v2, double eps = std::numeric_limits<double>::min()); /* * if all vector values are zero */ int is_vector_zero(int n, double *v, double threshold); /* * returns True:1 if equal */ int is_value_equal(double a, double b, double eps); /* * removes duplicates of a vector */ void make_unique(std::vector<int> &sn_arrays); /* * Gathering rows from a CSC matrix */ void gather_rows(std::vector<int> row_ids, size_t An, size_t Am, int *Ap, int *Ai, double *Ax, size_t &Bn, size_t &Bm, size_t &Bnz, int *&Bp, int *&Bi, double *&Bx); /* * Build super matrix from A and B, All are stored in CSC. */ int build_super_matrix_test(CSC *A, CSC *B, double reg_diag, size_t &SM_size, size_t &SM_nz, int *&SMp, int *&SMi, double *&SMx, double *&sm_rhs); int make_lower(size_t An, size_t Anz, int *Ap, int *Ai, double *Ax, size_t &Bn, size_t &Bnz, int *&Bp, int *&Bi, double *&Bx); void compressed_set_to_vector(int set_size, int *set_p, int *set_n, std::vector<std::vector<int>> &res_set); void max_min_spmat(size_t An, int *Ap, int *Ai, double *Ax, double &max_val, double &min_val); bool parse_args(int argc, const char *argv[], std::map<std::string, std::string> &qp_args); /* bool parse_args(int argc, char **argv, std::map<std::string, std::string> &qp_args) { const char *const short_opts = "m:o:l:a:b:c:d:n:p:r:e:t:h"; const option long_opts[] = { {"mode", required_argument, nullptr, 'm'}, {"objective", required_argument, nullptr, 'o'}, {"linear", required_argument, nullptr, 'l'}, {"eq", required_argument, nullptr, 'a'}, {"eqb", required_argument, nullptr, 'b'}, {"ineq", required_argument, nullptr, 'c'}, {"ineqb", required_argument, nullptr, 'd'}, {"nasoq", required_argument, nullptr, 'n'}, {"perturb", required_argument, nullptr, 'p'}, {"refinement", required_argument, nullptr, 'r'}, {"epsilon", required_argument, nullptr, 'e'}, {"toli", required_argument, nullptr, 't'}, {"help", no_argument, nullptr, 'h'}, {nullptr, no_argument, nullptr, 0} }; auto print_help = [](){std::cout<<"Input argument is wrong, you need at least an input QP file ";}; while (true) { const auto opt = getopt_long(argc, argv, short_opts, long_opts, nullptr); if (-1 == opt) break; switch (opt) { case 'm': qp_args.insert(std::pair<std::string, std::string>("mode", optarg)); break; case 'o': qp_args.insert(std::pair<std::string, std::string>("H", optarg)); break; case 'l': qp_args.insert(std::pair<std::string, std::string>("q", optarg)); break; case 'a': qp_args.insert(std::pair<std::string, std::string>("A", optarg)); break; case 'b': qp_args.insert(std::pair<std::string, std::string>("b", optarg)); break; case 'c': qp_args.insert(std::pair<std::string, std::string>("C", optarg)); break; case 'd': qp_args.insert(std::pair<std::string, std::string>("d", optarg)); break; case 'n': qp_args.insert(std::pair<std::string, std::string>("nasoq", optarg)); break; case 'p': qp_args.insert(std::pair<std::string, std::string>("perturbation", optarg)); break; case 'r': qp_args.insert(std::pair<std::string, std::string>("iterations", optarg)); break; case 'e': qp_args.insert(std::pair<std::string, std::string>("epsilon", optarg)); break; case 't': qp_args.insert(std::pair<std::string, std::string>("tolerance", optarg)); break; case 'h': // -h or --help case '?': // Unrecognized option default: print_help(); break; } } return true; } */ /* bool parse_nasoq_args(int argc, char **argv, std::map<std::string, std::string> &qp_args) { const char *const short_opts = "i:o:l:d:v:p:r:e:t:h"; const option long_opts[] = { {"input", required_argument, nullptr, 'i'}, {"output", required_argument, nullptr, 'o'}, {"log", required_argument, nullptr, 'l'}, {"header", required_argument, nullptr, 'd'}, {"variant", required_argument, nullptr, 'v'}, {"perturb", required_argument, nullptr, 'p'}, {"refinement", required_argument, nullptr, 'r'}, {"epsilon", required_argument, nullptr, 'e'}, {"toli", required_argument, nullptr, 't'}, {"help", no_argument, nullptr, 'h'}, {nullptr, no_argument, nullptr, 0} }; auto print_help = [](){std::cout<<"Input argument is wrong, you need at least an input QP file ";}; while (true) { const auto opt = getopt_long(argc, argv, short_opts, long_opts, nullptr); if (-1 == opt) break; switch (opt) { case 'i': qp_args.insert(std::pair<std::string, std::string>("input", optarg)); break; case 'o': qp_args.insert(std::pair<std::string, std::string>("output", optarg)); break; case 'l': qp_args.insert(std::pair<std::string, std::string>("log", optarg)); break; case 'd': qp_args.insert(std::pair<std::string, std::string>("header", optarg)); break; case 'v': qp_args.insert(std::pair<std::string, std::string>("variant", optarg)); break; case 'p': qp_args.insert(std::pair<std::string, std::string>("perturbation", optarg)); break; case 'r': qp_args.insert(std::pair<std::string, std::string>("iterations", optarg)); break; case 'e': qp_args.insert(std::pair<std::string, std::string>("epsilon", optarg)); break; case 't': qp_args.insert(std::pair<std::string, std::string>("tolerance", optarg)); break; case 'h': // -h or --help case '?': // Unrecognized option default: print_help(); break; } } if(qp_args.find("input") == qp_args.end()){ print_help(); return false; } return true; } */ } #endif //CHOLOPENMP_UTIL_H
151db279b56da4d6858ad1c674aaad0080de628b
ffd409ab7ff4bb316fa4d709188e3b17dc79e19a
/Arthur_model_1.cpp
12516f939bdd4c8c4ea31accbdf718f92f7cfc28
[]
no_license
snu-istick/Team
cb08738028a3e00d73e0b0d0691c87514ade3f6f
64b95ca54d51089d5db4b8eec1ed39dbc7ee5d75
refs/heads/master
2020-03-08T01:26:33.136450
2018-04-03T00:59:00
2018-04-03T00:59:00
127,830,310
0
0
null
2018-04-03T00:55:27
2018-04-03T00:55:27
null
UHC
C++
false
false
7,031
cpp
Arthur_model_1.cpp
// Arthur_model_1.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다. // #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { return 0; } #include <iostream> #include <fstream> #include <iomanip> #include <stdlib.h> #include <random> using namespace std; int a1 = 10, b1 = 5, c1=1, a2 = 1, b2 = 10, c2= 5, a3=5, b3=1, c3=10; //Natural preference double slope; //r value double ab1, ab2, ab3; // double sh_1 = 1/3, sh_2 = 1/3, sh_3= 1/3; //initial market share double p = 0.5; //probabiltiy drawing a R-agent int n1 = 5, n2 = 5, n3=5, d, n = 15; //initial marekt condition int tech, maxIter, x; double distribution[1000]; void genDistribution(int); void enterInputs(); void adoptionDynamics(); int constant(double); int decreasing(int, double, double, double); int increasing(int, double, double, double); int genBernoulli(); void writeResult(int); void writeDistribution(); ofstream outputFile; ofstream outputFile_dist; void main() { enterInputs(); adoptionDynamics(); for (int i = 0; i < 1000; i++) { genDistribution(i); } writeDistribution(); } void enterInputs() { maxIter = 1000; cout << "please enter the type of dynamics(1,2,3):"; cin >> tech; switch (tech) { case 1: slope = 0; //constant returns -> r=0 break; case 2: slope = -1; //decreasing returns -> r<0 break; case 3: slope = 1; //increasing returns -> r>0 break; } if (tech != 1) //ab1과 ab2 정의 { ab1 = (double)-1 * (a1 - (b1 + c1)) / slope; ab2 = (double)-1 * (a2 - (b2 + c2)) / slope; ab3 = (double)-1 * (a3 - (b3 + c3)) / slope; } //cout << "Please enter the maximum iterations:"; //cin >> maxIter; outputFile.open("Arthur_dynamics_1.txt", ios::out); if (!outputFile) { cerr << " File could not be opened" << endl; exit(1); } //outputFile << " Time R-agent S-agent Share of A Share of B" << endl; outputFile.close(); } void genDistribution(int i) { //initializing equation n1 = 5, n2 = 5, n = 10; n = n1 + n2; //시장 내 총 사용자 수 d = n1 - n2; //기술1과 기술2의 사용자수의 차이 if (tech != 1) //ab1과 ab2 정의 { ab1 = (double)-1 * (a1 - b1) / slope; ab2 = (double)-1 * (a2 - b2) / slope; } sh_1 = (double)n1 / n; //기술1의 점유율 sh_2 = 1 - sh_1; //기술2의 점유율 for (int t = 0; t <= maxIter; t++) { n = n1 + n2; //시장 내 총 사용자 수 d = n1 - n2; //기술1과 기술2의 사용자수의 차이 sh_1 = (double)n1 / n; //기술1의 점유율 sh_2 = 1 - sh_1; //기술2의 점유율 if (tech == 1) //처음에 constant 모형을 선택 { x = constant(p); //-->constant dyanmics } else if (tech == 2) //처음에 decreasing 모형을 선택 { x = decreasing(d, ab1, ab2, p);//-->decreasing dynamics } else { x = increasing(d, ab1, ab2, p); //-->increasing dyanamics } n1 = n1 + x; n2 = n2 + (1 - x); } distribution[i] = sh_1; } //Aopdtion dynamics void adoptionDynamics() { for (int t = 0; t <= maxIter; t++) { n = n1 + n2; //시장 내 총 사용자 수 d = n1 - n2; //기술1과 기술2의 사용자수의 차이 sh_1 = (double)n1 / n; //기술1의 점유율 sh_2 = 1 - sh_1; //기술2의 점유율 writeResult(t);//각기 t의 시장점유율 sh_1과 sh_2를 기록 if (tech == 1) //처음에 constant 모형을 선택 { x = constant(p); //-->constant dyanmics } else if (tech == 2) //처음에 decreasing 모형을 선택 { x = decreasing(d, ab1, ab2, p);//-->decreasing dynamics } else { x = increasing(d, ab1, ab2, p); //-->increasing dyanamics } n1 = n1 + x; n2 = n2 + (1 - x); } } //(1)Arthur's constant returns int constant(double pro) { int agent, choice; agent = genBernoulli(); //agent 형태는 1 또는 0 choice = agent; //agent는 r=0이므로 무조건 natural preference를 따른다. return choice; } //(2)Arthur's decreasing returns int decreasing(int diff, double prefer1, double prefer2, double pro) { int agent, choice; agent = genBernoulli(); //agent 1이 뽑혔을 경우 (tech 1선호) if ((agent == 1) && (diff <= prefer1)) //switching condition --> don't switch { choice = 1; } else if ((agent == 1) && (diff > prefer1)) //swithcing condition --> switch { choice = 0; } //agent 2가 뽑혔을 경우 (tech 2선호) else if ((agent == 0) && (diff >= prefer2)) //switching condition --> don't switch { choice = 0; } else { choice = 1; //switch } return choice; } //(3) Arthur's increasign returns int increasing(int diff, double prefer1, double prefer2, double pro) { int agent, choice; agent = genBernoulli(); if ((agent == 1) && (diff >= prefer1)) { choice = 1; } else if ((agent == 1) && (diff < prefer1)) { choice = 0; } else if ((agent == 0) && (diff <= prefer2)) { choice = 0; } else { choice = 1; } return choice; } //Random number function int genBernoulli() { random_device rd; mt19937 bernoulli(rd()); uniform_int_distribution<>dist(0, 1); return dist(bernoulli); } //Write Result to the disk void writeResult(int t) { outputFile.open("Arthur_dynamics_1.txt", ios::app); if (!outputFile){ cerr << "File could not be opened" << endl; exit(1); } /*outputFile << setw(5) << t << setw(10) << n1 << setw(10) << n2 << setiosflags(ios::fixed | ios::showpoint) << setw(13) << setprecision(2) << sh_1 << setiosflags(ios::fixed | ios::showpoint) << setw(13) << setprecision(2) << sh_2 << endl;*/ outputFile << sh_1 << endl; outputFile.close(); } //write distribution to the disk void writeDistribution() { int Freq[10] = { 0 }; for (int i = 0; i < 1000; i++) { if (distribution[i] <= 0.1) { Freq[0]++; } else if ((distribution[i] >0.1) && (distribution[i] <= 0.2)) { Freq[1]++; } else if ((distribution[i] >0.2) && (distribution[i] <= 0.3)) { Freq[2]++; } else if ((distribution[i] > 0.3) && (distribution[i] <= 0.4)) { Freq[3]++; } else if ((distribution[i] > 0.4) && (distribution[i] <= 0.5)) { Freq[4]++; } else if ((distribution[i] > 0.5) && (distribution[i] <= 0.6)) { Freq[5]++; } else if ((distribution[i] > 0.6) && (distribution[i] <= 0.7)) { Freq[6]++; } else if ((distribution[i] > 0.7) && (distribution[i] <= 0.8)) { Freq[7]++; } else if ((distribution[i] > 0.8) && (distribution[i] <= 0.9)) { Freq[8]++; } else if ((distribution[i] > 0.9) && (distribution[i] <= 1.0)) { Freq[9]++; } } outputFile_dist.open("Distribution.txt", ios::out); for (int j = 0; j < 10; j++) { outputFile_dist << Freq[j] << endl; } if (!outputFile_dist) { cerr << "File could not be opened" << endl; exit(1); } outputFile_dist.close(); }
89079fe03d2781deb12cd15c26a7fe3b6b51fef6
51a90b3e2291fd987655c1d36f9bb8991824ef1c
/student.h
80af1471df3fe3e64026ad950bb42f5b7d6b25f5
[]
no_license
OOP2019lab/lab11-180915hassanAli
2eb1b931a8f979219ddc2e7f35c24a5ef18cf90b
e72281fb06d5fc65d31daa4a5a804310d65bf1f5
refs/heads/master
2020-05-09T20:38:48.855286
2019-04-15T05:03:35
2019-04-15T05:03:35
181,415,219
0
0
null
null
null
null
UTF-8
C++
false
false
412
h
student.h
#pragma once #include "person.h" #include <string> class student: public person{ private: std::string fyp_name; float cgpa; public: student(std::string first_name,std::string last_name,std::string age, std::string fyp_name,float cgpa); ~student(); std::string getfyp_name(); float getcgpa(); void setfyp_name(std::string); void setcgpa(float); void student::printStudent(); };
c5809fbe2e19a2a6eb5f5a6e70db9caac294ca28
1d8700836cc244653cb6e20dfff62b3348eaa48c
/producer.cpp
6051547793afa268bc1d076d02f784ff1b22c3b4
[ "MIT" ]
permissive
Coder-0x7fffffff/ProducerAndConsumer
572a345aeafd2e8f613c0430cf0fa03981bfee07
833ff5e3f5e9e27a08162e6ab77a95e9d05ff02c
refs/heads/master
2022-04-19T00:50:49.788257
2020-04-17T07:44:03
2020-04-17T07:44:03
256,436,289
1
0
null
null
null
null
UTF-8
C++
false
false
1,157
cpp
producer.cpp
#include "producer.h" extern QMutex *mutex; extern QSemaphore *full,*empty; extern int producetCount; extern int consumerCount; extern int producerMs; extern int consumerMs; extern int producerTs; extern int consumerTs; extern int storeMax; extern int goodMax; extern int usedGood; extern int producedGood; extern int inStore; extern int running; producer::producer(QMainWindow *view,int id) { this->id = id; connect(this,SIGNAL(signal_produce(int)),view,SLOT(produce(int))); connect(this,SIGNAL(signal_produce_over(int)),view,SLOT(produceOver(int))); connect(this,SIGNAL(signal_produce_dispatch(int)),view,SLOT(dispatchProduct(int))); connect(this,SIGNAL(signam_produce_dispatch_over(int)),view,SLOT(dispatchProductOver(int))); } void producer::run(){ while(true){ emit signal_produce(id); sleep(producerMs); emit signal_produce_over(id); producedGood++; empty->acquire(); mutex->lock(); emit signal_produce_dispatch(id); sleep(producerTs); inStore++; emit signam_produce_dispatch_over(id); mutex->unlock(); full->release(); } }
91c7d8cf41fef66f71709903c945c9c2af97c743
d56d8c6a9dfad7898f7f874898a7736d172a0635
/ex2/common/GeneralUtility.cpp
81d78eee7d7ba2cbde38ffab6b68b89d4013f41c
[]
no_license
GrapeWang-zz325/StowagePlanning
7c97490381966fb00a357ef4a45f57f89c23e2fb
ebc5edd9abb572f1196bd0504d4aff0201dcdf8a
refs/heads/master
2022-10-31T20:00:30.118224
2020-06-18T22:35:54
2020-06-18T22:35:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
944
cpp
GeneralUtility.cpp
#include "GeneralUtility.h" // Split string by delimeter, stores outpit in result void GeneralUtility::split(std::vector<string>& result, const string &s, char delim) { std::stringstream ss(s); std::string item; while (getline(ss, item, delim)) { result.push_back(item); } } // Trim whitespaces from the left void ltrim(std::string& s, const string t = " \t\n\r\f\v") { s.erase(0, s.find_first_not_of(t)); } // Trim whitespaces from right void rtrim(std::string& s, const string t = " \t\n\r\f\v") { s.erase(s.find_last_not_of(t) + 1); } // Trim whitespaces from left & right void GeneralUtility::trim(std::string& s, const string t) { rtrim(s, t); ltrim(s, t); } // Trim all whitespaces from vector of strings void GeneralUtility::removeLeadingAndTrailingSpaces(std::vector<string> &split_line) { for (size_t i = 0; i < split_line.size(); i++) { trim(split_line[i]); } }
cd5457dfedd0e61abfc5db3080316aeaee3e0102
d7def7f68fa36f68d82fbe209dfa36d4f4df6f72
/DSA/DataStructuresAndAlgorithms/ak47/Regex.h
ae66dd6bcbb1efd89c3083f75cea79a9fd1cd63c
[]
no_license
terziev-viktor/FMI-Bachelor-Projects
d6a19203dea07a46c7afdd096d713c93fc6b632b
aaffbc22883fe2fb0ce03202123b8ab27b639271
refs/heads/master
2021-07-14T02:48:16.946848
2021-03-21T21:30:11
2021-03-21T21:30:11
123,151,640
0
0
null
null
null
null
UTF-8
C++
false
false
356
h
Regex.h
#pragma once #include "NAutomata.h" #include <memory> namespace ak47 { using std::string; class Regex { public: Regex(const std::string& regex); Regex(const std::string& regex, bool Init); bool IsMatch(const std::string& str); void Init(); protected: std::string regex; std::shared_ptr<ak47::NAutomata> automata; bool isInit; }; }
4ecb0325deea0b21b904872502cbb76ab49d02e3
6e8bf8af8f416a281b7b16607b9e6b124f7092a6
/Roteiro 6 Questao 1/Relogio.h
d4c5f50578b389faaf9c8c58a9cf6ab1d5546afb
[]
no_license
GiovanniBru/Roteiro6novo
d282e2370caf82e833528ab0249a6c4bc59017c2
255917a351ddd717b8b0db9bd680da763c741232
refs/heads/master
2021-05-16T08:27:40.444254
2017-09-26T13:58:56
2017-09-26T13:58:56
104,086,466
0
0
null
null
null
null
UTF-8
C++
false
false
511
h
Relogio.h
#ifndef RELOGIO_H #define RELOGIO_H using namespace std; class Relogio { public: Relogio(); virtual ~Relogio(); void setHorario(int, int, int); int getHora(int); int getMinuto(int); int getSegundo(int); void avancarHorario(int hora, int minuto, int segundo); bool chegarHorario(int hora, int minuto, int segundo); private: int hora; int minuto; int segundo; }; #endif // RELOGIO_H
5530d4a51e1bdc1d64b644bf2d9aa661d5e58d84
cd470ad61c4dbbd37ff004785fd6d75980987fe9
/Templates/Aho_Corasick_Automaton.cpp
0a041f90f39cd9d5d0a57aac2f44229ec7e58c1a
[]
no_license
AutumnKite/Codes
d67c3770687f3d68f17a06775c79285edc59a96d
31b7fc457bf8858424172bc3580389badab62269
refs/heads/master
2023-02-17T21:33:04.604104
2023-02-17T05:38:57
2023-02-17T05:38:57
202,944,952
3
1
null
null
null
null
UTF-8
C++
false
false
1,747
cpp
Aho_Corasick_Automaton.cpp
#include <cstdio> #include <cstring> using namespace std; const int N=11000; struct Aho_Corasick_Automaton{ int go[N][26],fail[N],cnt; // AC_Auto int h,t,Q[N]; // BFS_queue int edge,hd[N],pr[N],to[N],val[N],sum[N]; // Fail_Tree void addedge(int u,int v){ to[++edge]=v,pr[edge]=hd[u],hd[u]=edge; } void Insert(char *s){ for (register int i=0,u=0,len=strlen(s);i<len;u=go[u][s[i++]-97]) if (!go[u][s[i]-97]) go[u][s[i]-97]=++cnt; } void getfail(){ h=0,t=0; for (register int i=0;i<26;++i) if (go[0][i]) Q[++t]=go[0][i]; while (h<t){ int u=Q[++h]; addedge(fail[u],u); for (register int i=0,v,p;i<26;++i) if (go[u][i]) v=go[u][i],p=fail[u],fail[v]=go[p][i],Q[++t]=v; else go[u][i]=go[fail[u]][i]; } } void getval(char *s){ ++val[0]; for (register int i=0,u=0,len=strlen(s);i<len;++i) u=go[u][s[i]-97],++val[u]; } void getsum(int u){ sum[u]=val[u]; for (register int i=hd[u],v;i;i=pr[i]) v=to[i],getsum(v),sum[u]+=sum[v]; } int query(char *s){ for (register int i=0,u=0,len=strlen(s);i<len;++i) if ((u=go[u][s[i]-97])!=-1&&i==len-1) return sum[u]; } }AC; int n,ans[155],Ans; char a[155][75],s[1000005]; int main(){ while (1){ scanf("%d",&n); if (!n) return 0; memset(AC.go,0,sizeof AC.go); memset(AC.fail,0,sizeof AC.fail); memset(AC.val,0,sizeof AC.val); memset(AC.hd,0,sizeof AC.hd); AC.cnt=AC.edge=Ans=0; for (register int i=1;i<=n;++i) scanf("%s",a[i]),AC.Insert(a[i]); scanf("%s",s),AC.getfail(),AC.getval(s),AC.getsum(0); for (register int i=1;i<=n;++i) ans[i]=AC.query(a[i]),ans[i]>Ans?Ans=ans[i]:0; printf("%d\n",Ans); for (register int i=1;i<=n;++i) if (ans[i]==Ans) printf("%s\n",a[i]); } }
5d97338a156c05828c10292a9bc7bfbac3d6dd57
7df0ba90e096d987fe55e89bf64f92985cb03906
/Modules/Core/src/IO/mitkGeometry3DToXML.cpp
c611eac6c771885a06677ca1f2ef02c6e6906996
[ "BSD-3-Clause", "LicenseRef-scancode-free-unknown" ]
permissive
SVRTK/MITK
04eb6a54292a6da7c445cdf5a275b9b4addf6e21
52252d60e42702e292d188e30f6717fe50c23962
refs/heads/master
2022-06-04T20:47:10.398158
2020-04-27T10:29:27
2020-04-27T10:29:27
259,278,772
0
0
BSD-3-Clause
2020-04-27T10:19:57
2020-04-27T10:19:56
null
UTF-8
C++
false
false
8,327
cpp
mitkGeometry3DToXML.cpp
/*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "mitkGeometry3DToXML.h" #include <mitkLexicalCast.h> #include <tinyxml.h> TiXmlElement *mitk::Geometry3DToXML::ToXML(const Geometry3D *geom3D) { assert(geom3D); // really serialize const AffineTransform3D *transform = geom3D->GetIndexToWorldTransform(); // get transform parameters that would need to be serialized AffineTransform3D::MatrixType matrix = transform->GetMatrix(); AffineTransform3D::OffsetType offset = transform->GetOffset(); bool isImageGeometry = geom3D->GetImageGeometry(); BaseGeometry::BoundsArrayType bounds = geom3D->GetBounds(); // create XML file // construct XML tree describing the geometry auto *geomElem = new TiXmlElement("Geometry3D"); geomElem->SetAttribute("ImageGeometry", isImageGeometry ? "true" : "false"); geomElem->SetAttribute("FrameOfReferenceID", geom3D->GetFrameOfReferenceID()); // coefficients are matrix[row][column]! auto *matrixElem = new TiXmlElement("IndexToWorld"); matrixElem->SetAttribute("type", "Matrix3x3"); matrixElem->SetAttribute("m_0_0", boost::lexical_cast<std::string>(matrix[0][0])); matrixElem->SetAttribute("m_0_1", boost::lexical_cast<std::string>(matrix[0][1])); matrixElem->SetAttribute("m_0_2", boost::lexical_cast<std::string>(matrix[0][2])); matrixElem->SetAttribute("m_1_0", boost::lexical_cast<std::string>(matrix[1][0])); matrixElem->SetAttribute("m_1_1", boost::lexical_cast<std::string>(matrix[1][1])); matrixElem->SetAttribute("m_1_2", boost::lexical_cast<std::string>(matrix[1][2])); matrixElem->SetAttribute("m_2_0", boost::lexical_cast<std::string>(matrix[2][0])); matrixElem->SetAttribute("m_2_1", boost::lexical_cast<std::string>(matrix[2][1])); matrixElem->SetAttribute("m_2_2", boost::lexical_cast<std::string>(matrix[2][2])); geomElem->LinkEndChild(matrixElem); auto *offsetElem = new TiXmlElement("Offset"); offsetElem->SetAttribute("type", "Vector3D"); offsetElem->SetAttribute("x", boost::lexical_cast<std::string>(offset[0])); offsetElem->SetAttribute("y", boost::lexical_cast<std::string>(offset[1])); offsetElem->SetAttribute("z", boost::lexical_cast<std::string>(offset[2])); geomElem->LinkEndChild(offsetElem); auto *boundsElem = new TiXmlElement("Bounds"); auto *boundsMinElem = new TiXmlElement("Min"); boundsMinElem->SetAttribute("type", "Vector3D"); boundsMinElem->SetAttribute("x", boost::lexical_cast<std::string>(bounds[0])); boundsMinElem->SetAttribute("y", boost::lexical_cast<std::string>(bounds[2])); boundsMinElem->SetAttribute("z", boost::lexical_cast<std::string>(bounds[4])); boundsElem->LinkEndChild(boundsMinElem); auto *boundsMaxElem = new TiXmlElement("Max"); boundsMaxElem->SetAttribute("type", "Vector3D"); boundsMaxElem->SetAttribute("x", boost::lexical_cast<std::string>(bounds[1])); boundsMaxElem->SetAttribute("y", boost::lexical_cast<std::string>(bounds[3])); boundsMaxElem->SetAttribute("z", boost::lexical_cast<std::string>(bounds[5])); boundsElem->LinkEndChild(boundsMaxElem); geomElem->LinkEndChild(boundsElem); return geomElem; } mitk::Geometry3D::Pointer mitk::Geometry3DToXML::FromXML(TiXmlElement *geometryElement) { if (!geometryElement) { MITK_ERROR << "Cannot deserialize Geometry3D from nullptr."; return nullptr; } AffineTransform3D::MatrixType matrix; AffineTransform3D::OffsetType offset; bool isImageGeometry(false); unsigned int frameOfReferenceID(0); BaseGeometry::BoundsArrayType bounds; if (TIXML_SUCCESS != geometryElement->QueryUnsignedAttribute("FrameOfReferenceID", &frameOfReferenceID)) { MITK_WARN << "Missing FrameOfReference for Geometry3D."; } if (TIXML_SUCCESS != geometryElement->QueryBoolAttribute("ImageGeometry", &isImageGeometry)) { MITK_WARN << "Missing bool ImageGeometry for Geometry3D."; } // matrix if (TiXmlElement *matrixElem = geometryElement->FirstChildElement("IndexToWorld")->ToElement()) { bool matrixComplete = true; for (unsigned int r = 0; r < 3; ++r) { for (unsigned int c = 0; c < 3; ++c) { std::stringstream element_namer; element_namer << "m_" << r << "_" << c; std::string string_value; if (TIXML_SUCCESS == matrixElem->QueryStringAttribute(element_namer.str().c_str(), &string_value)) { try { matrix[r][c] = boost::lexical_cast<double>(string_value); } catch ( const boost::bad_lexical_cast &e ) { MITK_ERROR << "Could not parse '" << string_value << "' as number: " << e.what(); return nullptr; } } else { matrixComplete = false; } } } if (!matrixComplete) { MITK_ERROR << "Could not parse all Geometry3D matrix coefficients!"; return nullptr; } } else { MITK_ERROR << "Parse error: expected Matrix3x3 child below Geometry3D node"; return nullptr; } // offset if (TiXmlElement *offsetElem = geometryElement->FirstChildElement("Offset")->ToElement()) { bool vectorComplete = true; std::string offset_string[3]; vectorComplete &= TIXML_SUCCESS == offsetElem->QueryStringAttribute("x", &offset_string[0]); vectorComplete &= TIXML_SUCCESS == offsetElem->QueryStringAttribute("y", &offset_string[1]); vectorComplete &= TIXML_SUCCESS == offsetElem->QueryStringAttribute("z", &offset_string[2]); if (!vectorComplete) { MITK_ERROR << "Could not parse complete Geometry3D offset!"; return nullptr; } for (unsigned int d = 0; d < 3; ++d) try { offset[d] = boost::lexical_cast<double>(offset_string[d]); } catch ( const boost::bad_lexical_cast &e ) { MITK_ERROR << "Could not parse '" << offset_string[d] << "' as number: " << e.what(); return nullptr; } } else { MITK_ERROR << "Parse error: expected Offset3D child below Geometry3D node"; return nullptr; } // bounds if (TiXmlElement *boundsElem = geometryElement->FirstChildElement("Bounds")->ToElement()) { bool vectorsComplete(true); std::string bounds_string[6]; if (TiXmlElement *minElem = boundsElem->FirstChildElement("Min")->ToElement()) { vectorsComplete &= TIXML_SUCCESS == minElem->QueryStringAttribute("x", &bounds_string[0]); vectorsComplete &= TIXML_SUCCESS == minElem->QueryStringAttribute("y", &bounds_string[2]); vectorsComplete &= TIXML_SUCCESS == minElem->QueryStringAttribute("z", &bounds_string[4]); } else { vectorsComplete = false; } if (TiXmlElement *maxElem = boundsElem->FirstChildElement("Max")->ToElement()) { vectorsComplete &= TIXML_SUCCESS == maxElem->QueryStringAttribute("x", &bounds_string[1]); vectorsComplete &= TIXML_SUCCESS == maxElem->QueryStringAttribute("y", &bounds_string[3]); vectorsComplete &= TIXML_SUCCESS == maxElem->QueryStringAttribute("z", &bounds_string[5]); } else { vectorsComplete = false; } if (!vectorsComplete) { MITK_ERROR << "Could not parse complete Geometry3D bounds!"; return nullptr; } for (unsigned int d = 0; d < 6; ++d) try { bounds[d] = boost::lexical_cast<double>(bounds_string[d]); } catch ( const boost::bad_lexical_cast &e ) { MITK_ERROR << "Could not parse '" << bounds_string[d] << "' as number: " << e.what(); return nullptr; } } // build GeometryData from matrix/offset AffineTransform3D::Pointer newTransform = AffineTransform3D::New(); newTransform->SetMatrix(matrix); newTransform->SetOffset(offset); Geometry3D::Pointer newGeometry = Geometry3D::New(); newGeometry->SetFrameOfReferenceID(frameOfReferenceID); newGeometry->SetImageGeometry(isImageGeometry); newGeometry->SetIndexToWorldTransform(newTransform); newGeometry->SetBounds(bounds); return newGeometry; }
d24a3e592a016f9226e1a4a85c6963d87876586a
63ea92b95c82ca0558ec7312357c5079f92725b1
/SkinDetection/SkinDetection/Source.cpp
7a68b1142c8319c5f44de41f7c0945a1cc97620e
[]
no_license
razibdeb/SkinDetector
309c24abb2955fe5278da6626e62f3fc48eccb79
6d81d9a733a754fcaeac2eb93d2489f19c5be1cc
refs/heads/master
2020-06-15T06:12:10.113453
2015-02-04T14:26:49
2015-02-04T14:26:49
30,260,383
0
0
null
null
null
null
UTF-8
C++
false
false
801
cpp
Source.cpp
#include<opencv2\opencv.hpp> #include"SkinDetector.h" using namespace std; using namespace cv; int main() { VideoCapture capture; //open capture object at location zero (default location for webcam) capture.open(0); //set height and width of capture frame capture.set(CV_CAP_PROP_FRAME_WIDTH,320); capture.set(CV_CAP_PROP_FRAME_HEIGHT,480); Mat cameraFeed; SkinDetector mySkinDetector; Mat skinMat; //start an infinite loop where webcam feed is copied to cameraFeed matrix //all of our operations will be performed within this loop while(1){ //store image to matrix capture.read(cameraFeed); imshow("Original Image",cameraFeed); skinMat= mySkinDetector.getSkin(cameraFeed); imshow("Skin Image",skinMat); waitKey(30); } return 0; }
bb4264268072c1b5f963ea9de4c61dc90a0f3d8d
6ded2d148a50a4fb2afdda2cbd272595a0467540
/GenesisEngine/GenesisEngine/PhysicsComponent.cpp
c40479334962aa6f66e37f7a94cfbe95964b9ac5
[]
no_license
KingWapo/GenesisEngine
3d8f7954b57f92e6bf2bde04ae29ad224ad83324
5675473573c6e918c1f420b32285e00c11563a4c
refs/heads/master
2016-09-06T16:30:46.247272
2015-04-23T20:27:13
2015-04-23T20:27:13
30,262,891
0
1
null
null
null
null
UTF-8
C++
false
false
2,100
cpp
PhysicsComponent.cpp
#include "PhysicsComponent.h" #include "Actor.h" #include <math.h> const char *PhysicsComponent::g_Name = "PhysicsComponent"; PhysicsComponent::PhysicsComponent() { setPosition(Vector2(0.0, 0.0)); setVelocity(Vector2(0.0, 0.0)); setMass(1.0); setGrav(1.0); } PhysicsComponent::PhysicsComponent(Vector2 p_position, Vector2 p_velocity, float p_mass, float p_grav) { setPosition(p_position); setVelocity(p_velocity); setMass(p_mass); setGrav(p_grav); } PhysicsComponent::~PhysicsComponent() { } Vector2 PhysicsComponent::netForce() { Vector2 netForce = Vector2(); for (unsigned int i = 0; i < forceQueue.size(); i++) { netForce += forceQueue[i]; } return netForce; } void PhysicsComponent::move(Vector2 deltaPos) { Vector2 newPos = m_transform->GetTranslation() + deltaPos; newPos.x = max(0.0f, min(1.0f, newPos.x)); newPos.y = max(0.0f, min(.921f, newPos.y)); m_transform->SetTranslation(newPos); } void PhysicsComponent::accelerate(Vector2 deltaVel) { m_velocity += deltaVel; } void PhysicsComponent::addForce(Vector2 force) { forceQueue.push_back(force); } void PhysicsComponent::clearForces() { forceQueue.clear(); } float PhysicsComponent::kineticEnergy() { float speed = getVelocity().mag(); return (.5f * getMass() * pow(speed, 2)); } float PhysicsComponent::potentialEnergy() { return getMass() * getGrav() * getPosition().y; } void PhysicsComponent::euler(Vector2 netForce, float deltaTime) { move(getVelocity() * deltaTime); accelerate((netForce / getMass()) * deltaTime); } bool PhysicsComponent::vUpdate(int deltaMs) { GCC_ASSERT(m_transform.get() != NULL); Vector2 net = netForce(); float deltaTime = deltaMs / 1000.0f; //printf("DeltaTime: %f\n", deltaTime); fflush(stdout); euler(net, deltaTime); //m_transform->SetTranslation(m_position); return true; } bool PhysicsComponent::vInit() { GCC_ASSERT(m_pOwner.use_count() != 0); StrongActorPtr l_ownerPtr = m_pOwner.lock(); Actor* l_owner = static_cast<Actor*>(l_ownerPtr.get()); m_transform = l_owner->GetComponent<Transform2dComponent>("Transform2dComponent"); return true; }
aafe64285222dbf40c3585b071ac7554db1f1ee6
95c19710b2fd8949486a4aacbdefbda6927c6e81
/tetris.h
f655df5d7a5244be201be1b006bfba712281c8a1
[]
no_license
t0n1c/led_matrix_games
62cc1b3045cdeaac488fa287deea29267f66d34f
980b8d4ad3a0363dbbde20b210036f4f66675fd0
refs/heads/master
2021-01-18T11:19:56.982037
2015-03-28T17:15:01
2015-03-28T17:15:01
56,936,918
0
0
null
null
null
null
UTF-8
C++
false
false
1,416
h
tetris.h
#ifndef TETRIS_H_ #define TETRIS_H_ #include <StandardCplusplus.h> #include <set> #include "piece.h" typedef struct{ int x; int y; }PointStruct; /*typedef struct{ int x_right; int x_left; int y_top; int y_bottom; }BoundsStruct; */ using namespace std; void tetris_setup(); void tetris_loop(); void drawing_procedure(Piece * p,boolean clear_piece); void place_and_tetris(); void naive_tetris(); void sticky_tetris(); void level_up(); boolean check_tetris(int * number_of_scored_lines,int * scored_lines); void clear_tetris_lines(int * scored_lines,int number_of_scored_lines); void blink_lines(int * scored_lines,int number_of_scored_lines,int number_of_blinks,int ms); void draw_line(int line); set<set<int> > get_chunks(); set<set<int> > test_flood(); set<int> flood_finding(int current_point,set<int> chunk); void update_matrix_state(); boolean get_validated_pixels_piece(Piece * p); boolean check_unit_piece_pixel(int relocated_x,int relocated_y); void draw_piece(int color); int decrease_delay(char chosen_move,int init_delay,int decrease); //This prototypes are due to I included a port of uClibc++ for Arduino. //I had to use with a list of lists of different sizes adding and removing elements //so I didn't want to deal with memory management. set<set<int> > get_chunks(); set<int> flood_finding(int current_point,set<int> temp_chunk); set<set<int> > test_flood(); #endif
810a80ca7b7facadb5d70a8d60ac8bfce82d3352
42b4b82be54bb4c6bd38cc6f0fb7c78a131ccaea
/h_string.cpp
974c60fefe4b05ea7647a330986a47595f496670
[]
no_license
HevilH/HSearch
f01d8c578144f8b505c7af5279ac9c1ea0ef25ab
c5b8976f79632f0983975c482b3ebc0abff21a49
refs/heads/master
2023-05-02T20:47:29.585962
2021-05-26T11:10:55
2021-05-26T11:10:55
349,426,627
0
0
null
null
null
null
UTF-8
C++
false
false
3,255
cpp
h_string.cpp
#include "h_string.h" size_t wstrlen(const wchar_t* s) { const wchar_t* sc; for (sc = s; *sc != 0; sc++); return sc - s; } h_string::h_string() { w_str = L""; len = 0; } h_string::h_string(h_string &s) { len = s.len; w_str = new wchar_t[len + 1]; for (int i = 0; i < len; i++) w_str[i] = s.w_str[i]; w_str[len] = 0; } h_string::h_string(const wchar_t* s) { len = wstrlen(s); w_str = new wchar_t[len + 1]; for (int i = 0; i < len; i++) w_str[i] = s[i]; w_str[len] = 0; } h_string::~h_string() { if(w_str[0] != 0) delete[] w_str; } wchar_t* h_string::wc_str() { wchar_t* tmp = new wchar_t[len + 1]; for (int i = 0; i < len; i++) tmp[i] = w_str[i]; return tmp; } size_t h_string::length() { return len; } h_string& h_string::append(h_string& s) { wchar_t* tmp = w_str; w_str = new wchar_t[len + s.len + 1]; for (int i = 0; i < len; i++) { w_str[i] = tmp[i]; } for (int i = 0; i < s.len; i++) { w_str[len + i] = tmp[i]; } w_str[len + s.len] = 0; len += s.len; delete[] tmp; return *this; } h_string& h_string::assign(h_string& s) { wchar_t* tmp = w_str; w_str = new wchar_t[s.len + 1]; for (int i = 0; i < len; i++) { w_str[i] = tmp[i]; } len = s.len; w_str[s.len] = 0; if (tmp[0] != 0) delete[] tmp; return *this; } int h_string::find(h_string& s) { int length = s.length(); int check = 0; int i = 0; for (i = 0; i < len; i++){ if (check > 0){ if (w_str[i] != s[check]) check = 0; } if (w_str[i] == s[check]) check++; if (check == length) break; } if (check == length) return (i - check + 1); else return -1; } h_string h_string::substr(int begin, int len) { wchar_t* tmp = new wchar_t[len + 1]; for (int i = 0; i < len; i++) { tmp[i] = w_str[begin + i]; } tmp[len] = 0; h_string result(tmp); delete[] tmp; return result; } void h_string::clear() { if(w_str[0]) delete[] w_str; w_str = L""; len = 0; } h_string h_string::operator+(h_string& s) { wchar_t* tmp = new wchar_t[len + s.len + 1]; for (int i = 0;i < len; i++) { tmp[i] = w_str[i]; } for (int i = 0; i < s.len; i++) { tmp[len + i] = s[i]; } tmp[len + s.len] = 0; h_string result(tmp); delete[] tmp; return result; } h_string h_string::operator+(wchar_t s) { wchar_t* tmp = new wchar_t[len + 1 + 1]; for (int i = 0; i < len; i++) { tmp[i] = w_str[i]; } tmp[len] = s; tmp[len + 1] = 0; h_string result(tmp); delete[] tmp; return result; } h_string& h_string::operator=(h_string& s) { len = s.len; wchar_t* tmp = w_str; w_str = new wchar_t[s.len + 1]; for (int i = 0; i < len; i++) w_str[i] = s.w_str[i]; w_str[len] = 0; if(tmp[0]) delete[] tmp; return *this; } bool h_string::operator==(const h_string& s) { if (len == s.len) { for (int i = 0; i < len; i++) { if (w_str[i] != s.w_str[i]) return false; } return true; } return false; } bool h_string::operator>=(const h_string& s) { int m_len = len >= s.len ? s.len : len; for (int i = 0; i < m_len; i++) { if (w_str[i] > s.w_str[i]) return true; else if (w_str[i] < s.w_str[i]) return false; } if (len >= s.len) return true; else return false; } wchar_t h_string::operator[](int num) { const wchar_t result = w_str[num]; return result; }
703519d1df71ff296660dab6c58e80d07f24e49e
53dc9c8bf8a24c9157608af4f93a6c7575643210
/StardewLike/src/StateMachine/PlayerStateMachine.cpp
748d4ea7e5892924f307265989d740496f19639d
[]
no_license
JFLPardal/Stardewlike
b94291abde0e7f31ee0fe13a8878d99c91e91704
d810d784c7a22a65ae3cefcaf257bb19dd65875e
refs/heads/master
2021-06-12T20:57:50.535542
2020-06-17T15:16:35
2020-06-17T15:16:35
254,396,830
0
1
null
null
null
null
UTF-8
C++
false
false
857
cpp
PlayerStateMachine.cpp
#include "pch.h" #include "PlayerStateMachine.h" #include "Components/Orientation.h" #include "GameObject.h" std::vector<State> PlayerStateMachine::m_possibleStates = { State::walk, State::idle }; PlayerStateMachine::PlayerStateMachine() { m_currentState = State::idle; } void PlayerStateMachine::Start(GameObject* aOwner) { StateMachine::Start(aOwner); m_OrientationChangedIndex = m_owner->GetComponent<Orientation>()->OnOrientationChangedEvent->AddCallback(ORIENTATION_CHANGED(&PlayerStateMachine::OrientationChanged)); } void PlayerStateMachine::OrientationChanged(PossibleOrientation aNewOrientation) { OnStateChangeEvent->TriggerEvent(m_currentState); } PlayerStateMachine::~PlayerStateMachine() { if (m_owner->GetComponent<Orientation>() != nullptr) m_orientation->OnOrientationChangedEvent->RemoveCallback(m_OrientationChangedIndex); }
0226f1152ac1a9659696f67c2e079ddb3fb2757a
67f88d9de5d80d78de654de316cb6373229efb52
/kruskal_rebours.cpp
8a67cebb71ee7f32867872c8bad393627e68413e
[ "MIT" ]
permissive
sushithreddy75/DATA-STRUCTURES
0e99a7280da41eb0391e90fc9e8c2be58d54b1ad
ec948dbaadd0c675596ba1b6fd7c71ef14c9d656
refs/heads/main
2023-02-09T06:35:13.391029
2020-12-22T05:28:56
2020-12-22T05:28:56
309,661,157
1
0
null
null
null
null
UTF-8
C++
false
false
2,589
cpp
kruskal_rebours.cpp
#include<iostream> #include<stack> using namespace std; void swap(int **x,int i,int j) { int a=x[i][0],b=x[i][1],c=x[i][2]; x[i][0]=x[j][0];x[i][1]=x[j][1];x[i][2]=x[j][2]; x[j][0]=a;x[j][1]=b;x[j][2]=c; } void heapify(int **heap,int i) { if(i<=0) return; if(heap[i][0]>heap[(i-1)/2][0]||(heap[i][0]==heap[(i-1)/2][0]&&heap[i][1]>heap[(i-1)/2][1])) { swap(heap,i,(i-1)/2); heapify(heap,(i-1)/2); } } void del(int **heap,int i,int n) { if(2*i+1>=n) return; if(heap[i][0]<heap[2*i+1][0]||(heap[i][0]==heap[2*i+1][0]&&heap[i][1]>heap[2*i+1][1])) { swap(heap,i,2*i+1); del(heap,i,n); return del(heap,2*i+1,n); } if(2*i+2<n&&heap[i][0]<heap[2*i+2][0]||(2*i+2<n&&heap[i][0]==heap[2*i+2][0]&&heap[i][1]>heap[2*i+2][1])) { swap(heap,i,2*i+2); del(heap,2*i+2,n); } } bool path(int **G,int x,int y,int n) { G[x][y]=0; stack<int>s; s.push(x); int vis[n+1]={0}; while(!s.empty()) { int i=s.top(); s.pop(); vis[i]=1; if(i==y) return true; for(int j=1;j<=n;j++) { if(G[i][j]&&!vis[j]) s.push(j); } } G[x][y]=1; return false; } void kruskals(int **G,int vis[],int pre[],int &hc,int **heap,int n,int &s) { while(1) { int x=heap[0][0],y=heap[0][1],z=heap[0][2]; if(path(G,y,z,n)) { G[y][z]=G[z][y]=0; pre[y]--;pre[z]--; if(pre[y]==1) vis[y]=1; if(pre[z]==1) vis[z]=1; //cout<<z<<" "<<y<<endl; } else cout<<y<<" "<<z<<endl; hc--; if(hc==0) break; heap[0][0]=heap[hc][0]; heap[0][1]=heap[hc][1]; heap[0][2]=heap[hc][2]; del(heap,0,hc); } } int main() { int n=7,i; int **G=new int*[n+1]; int i1[]={1,1,1,2,2,3,3,4,4,4,5,6}; int i2[]={2,3,4,4,5,4,6,5,6,7,7,7}; int i3[]={2,4,1,3,10,2,5,7,8,4,6,1}; int **heap=new int*[12]; for(i=0;i<12;i++) heap[i]=new int[3]; for(i=0;i<=n;i++) G[i]=new int[n+1]; int hc=0; int pre[n+1]={0}; for(i=0;i<12;i++) { G[i1[i]][i2[i]]=G[i2[i]][i1[i]]=i3[i]; heap[hc][0]=i3[i];heap[hc][1]=i1[i];heap[hc][2]=i2[i]; heapify(heap,hc); hc++; pre[i1[i]]++;pre[i2[i]]++; } int vis[n+1]={0},s=0; for(i=1;i<=n;i++) { if(pre[i]==1) vis[i]=1; } kruskals(G,vis,pre,hc,heap,n,s); }
c204435c9fb1f865e42809d932d65d1dbab9aaee
ae03ab18cbd8ce785c0586755c95f66aea72427b
/Meso_STALite/Signal_API/SignalAPI_code/AgentLite/main_api.cpp
68d2a26d410fce7a2bf96c63b7251e737a54849e
[]
no_license
QLwin/Dynamic-Traffic-Simulation
474f5817900371e1a029abac723318cc2b6f268d
bce642dfc1813d4da289d9fadd76cdbb5263ee2e
refs/heads/master
2023-04-22T02:46:49.294967
2021-04-26T02:08:02
2021-04-26T02:08:02
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
59,374
cpp
main_api.cpp
// Portions Copyright 2019 // Xuesong (Simon) Zhou // If you help write or modify the code, please also list your names here. // The reason of having Copyright info here is to ensure all the modified version, as a whole, under the GPL // and further prevent a violation of the GPL. // More about "How to use GNU licenses for your own software" // http://www.gnu.org/licenses/gpl-howto.html #pragma warning( disable : 4305 4267 4018) #include <iostream> #include <fstream> #include <list> #include <omp.h> #include <algorithm> #include <time.h> #include <functional> #include <stdio.h> #include <math.h> #include <stack> #include <string> #include <vector> #include <map> #include <sstream> #include <iostream> #include <iomanip> using namespace std; using std::string; using std::ifstream; using std::vector; using std::map; using std::istringstream; using std::max; template <typename T> // some basic parameters setting #define sprintf_s sprintf FILE* g_pFileOutputLog = NULL; int g_debugging_flag = 2; string g_info_String = ""; void fopen_ss(FILE **file, const char *fileName, const char *mode) { *file = fopen(fileName, mode); } void g_ProgramStop(); //below shows where the functions used in Agentlite.cpp come from! //Utility.cpp #pragma warning(disable: 4244) // stop warning: "conversion from 'int' to 'float', possible loss of data" class CCSVParser { public: char Delimiter; bool IsFirstLineHeader; ifstream inFile; string mFileName; vector<string> LineFieldsValue; vector<string> Headers; map<string, int> FieldsIndices; vector<int> LineIntegerVector; public: void ConvertLineStringValueToIntegers() { LineIntegerVector.clear(); for (unsigned i = 0; i < LineFieldsValue.size(); i++) { std::string si = LineFieldsValue[i]; int value = atoi(si.c_str()); if (value >= 1) LineIntegerVector.push_back(value); } } vector<string> GetHeaderVector() { return Headers; } bool m_bDataHubSingleCSVFile; string m_DataHubSectionName; bool m_bLastSectionRead; bool m_bSkipFirstLine; // for DataHub CSV files CCSVParser(void) { Delimiter = ','; IsFirstLineHeader = true; m_bSkipFirstLine = false; m_bDataHubSingleCSVFile = false; m_bLastSectionRead = false; } ~CCSVParser(void) { if (inFile.is_open()) inFile.close(); } bool OpenCSVFile(string fileName, bool b_required) { mFileName = fileName; inFile.open(fileName.c_str()); if (inFile.is_open()) { if (IsFirstLineHeader) { string s; std::getline(inFile, s); vector<string> FieldNames = ParseLine(s); for (size_t i = 0;i < FieldNames.size();i++) { string tmp_str = FieldNames.at(i); size_t start = tmp_str.find_first_not_of(" "); string name; if (start == string::npos) { name = ""; } else { name = tmp_str.substr(start); // TRACE("%s,", name.c_str()); } FieldsIndices[name] = (int)i; } } return true; } else { if (b_required) { cout << "File " << fileName << " does not exist. Please check." << endl; //g_ProgramStop(); } return false; } } void CloseCSVFile(void) { inFile.close(); } bool ReadRecord() { LineFieldsValue.clear(); if (inFile.is_open()) { string s; std::getline(inFile, s); if (s.length() > 0) { LineFieldsValue = ParseLine(s); return true; } else { return false; } } else { return false; } } vector<string> ParseLine(string line) { vector<string> SeperatedStrings; string subStr; if (line.length() == 0) return SeperatedStrings; istringstream ss(line); if (line.find_first_of('"') == string::npos) { while (std::getline(ss, subStr, Delimiter)) { SeperatedStrings.push_back(subStr); } if (line.at(line.length() - 1) == ',') { SeperatedStrings.push_back(""); } } else { while (line.length() > 0) { size_t n1 = line.find_first_of(','); size_t n2 = line.find_first_of('"'); if (n1 == string::npos && n2 == string::npos) //last field without double quotes { subStr = line; SeperatedStrings.push_back(subStr); break; } if (n1 == string::npos && n2 != string::npos) //last field with double quotes { size_t n3 = line.find_first_of('"', n2 + 1); // second double quote //extract content from double quotes subStr = line.substr(n2 + 1, n3 - n2 - 1); SeperatedStrings.push_back(subStr); break; } if (n1 != string::npos && (n1 < n2 || n2 == string::npos)) { subStr = line.substr(0, n1); SeperatedStrings.push_back(subStr); if (n1 < line.length() - 1) { line = line.substr(n1 + 1); } else // comma is the last char in the line string, push an empty string to the back of vector { SeperatedStrings.push_back(""); break; } } if (n1 != string::npos && n2 != string::npos && n2 < n1) { size_t n3 = line.find_first_of('"', n2 + 1); // second double quote subStr = line.substr(n2 + 1, n3 - n2 - 1); SeperatedStrings.push_back(subStr); size_t idx = line.find_first_of(',', n3 + 1); if (idx != string::npos) { line = line.substr(idx + 1); } else { break; } } } } return SeperatedStrings; } template <class T> bool GetValueByFieldName(string field_name, T& value, bool NonnegativeFlag = true, bool required_field = true) { if (FieldsIndices.find(field_name) == FieldsIndices.end()) { if (required_field) { cout << "Field " << field_name << " in file " << mFileName << " does not exist. Please check the file." << endl; g_ProgramStop(); } return false; } else { if (LineFieldsValue.size() == 0) { return false; } int size = (int)(LineFieldsValue.size()); if (FieldsIndices[field_name] >= size) { return false; } string str_value = LineFieldsValue[FieldsIndices[field_name]]; if (str_value.length() <= 0) { return false; } istringstream ss(str_value); T converted_value; ss >> converted_value; if (/*!ss.eof() || */ ss.fail()) { return false; } if (NonnegativeFlag && converted_value < 0) converted_value = 0; value = converted_value; return true; } } bool GetValueByFieldName(string field_name, string& value) { if (FieldsIndices.find(field_name) == FieldsIndices.end()) { return false; } else { if (LineFieldsValue.size() == 0) { return false; } unsigned int index = FieldsIndices[field_name]; if (index >= LineFieldsValue.size()) { return false; } string str_value = LineFieldsValue[index]; if (str_value.length() <= 0) { return false; } value = str_value; return true; } } }; class CMainModual { public: CMainModual() { g_number_of_links = 0; g_number_of_service_arcs = 0; g_number_of_nodes = 0; b_debug_detail_flag = 1; g_pFileDebugLog = NULL; g_informationCount = 0; SYSTEMTIME st; GetLocalTime(&st); g_pFileDebugLog = fopen("log.txt", "at"); fprintf(g_pFileDebugLog, "Logging Time: %d/%d/%d_%d:%d:%d:%d---------------------------------------¡ý\n",st.wYear,st.wMonth,st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); fclose(g_pFileDebugLog); messageType_int_to_string[0] = "MSG";//message messageType_int_to_string[1] = "OUT";//output messageType_int_to_string[2] = "WAR";//Warning } int b_debug_detail_flag; std::map<int, int> g_internal_node_to_seq_no_map; // hash table, map external node number to internal node sequence no. std::map<string, int> g_road_link_id_map; int g_number_of_links; int g_number_of_service_arcs; int g_number_of_nodes; int g_number_of_zones; int g_LoadingStartTimeInMin; int g_LoadingEndTimeInMin; int g_informationCount; FILE* g_pFileDebugLog; std::map<int, char*> messageType_int_to_string; void WriteLog(int messageType, string info, int level) { string padding = ""; if (level > 1) { for (size_t l = 2; l <= level; l++) { padding.append("--"); } } if (level == -1) { padding = "++++++++++++++++++++++++++++++"; } if (level == -2) { padding = "++++++++++++++++++++++++++++++"; } g_pFileDebugLog = fopen("log.txt", "at"); fprintf(g_pFileDebugLog, "Info_ID: %d| Info_Type: %s \t| Info: %s%s\n", g_informationCount, messageType_int_to_string[messageType], padding.c_str(), info.c_str()); fclose(g_pFileDebugLog); cout << "Info_ID: " << g_informationCount << "| Info_Type: " << messageType_int_to_string[messageType] << " \t| Info: "<< padding.c_str() << info.c_str() << endl; //OutputDebugStringA(szLog); g_informationCount++; } string Output_Combine_Message_And_Value_Int(string info,int value) { string value_String = to_string(value); info.append(": "); info.append(value_String); return info; } string Output_Combine_Message_And_Value_Double(string info, double value) { string value_String = to_string(value); info.append(": "); info.append(value_String); return info; } }; CMainModual MainModual; class CLink { public: CLink() // construction { free_flow_travel_time_in_min = 1; } ~CLink() { //if (flow_volume_for_each_o != NULL) // delete flow_volume_for_each_o; } // 1. based on BPR. int zone_seq_no_for_outgoing_connector ; int m_RandomSeed; int link_seq_no; string link_id; int from_node_seq_no; int to_node_seq_no; int link_type; float fftt; float free_flow_travel_time_in_min; float lane_capacity; int number_of_lanes; int type; float length; }; class CServiceArc { public: CServiceArc() // construction { } int link_seq_no; int starting_time_no; int ending_time_no; int time_interval_no; float capacity; int travel_time_delta; }; class CNode { public: CNode() { node_seq_no = -1; //accessible_node_count = 0; } //int accessible_node_count; int node_seq_no; // sequence number int node_id; //external node number double x; double y; std::vector<int> m_outgoing_link_seq_no_vector; std::vector<int> m_incoming_link_seq_no_vector; std::vector<int> m_to_node_seq_no_vector; std::map<int, int> m_to_node_2_link_seq_no_map; }; struct SMovementData { //SMovementData() //{ //} bool Enable = false;//no value->false int LinkSeqNo; int PhaseNo; //enum stage StageNo; vector<enum stage> StageNo_in_Order; //https://blog.csdn.net/qq_32172673/article/details/85127176 int Volume; int Lanes; int SharedLanes; enum group GroupNo;//L->1;T/R->2 enum direction DirectionNo; //by Acquisition through processing int Assignment_Order;// not in use, Differentiate primary and secondary movements, then determine stages according to volumes enum left_Turn_Treatment Left_Turn_Treatment; }; #pragma region Method_Declarations #pragma endregion #pragma region Fields //enum enum movement_Index { EBL = 1, EBT = 2, EBR = 3, WBL = 4, WBT = 5, WBR = 6, NBL = 7, NBT = 8, NBR = 9, SBL = 10, SBT = 11, SBR = 12 }; enum stage { no_stage = -1, stage1 = 1, stage2 = 2, stage3 = 3, stage4 = 4 }; enum direction { E = 1, W = 2, N = 3, S = 4 }; enum group { L = 1, T_AND_R = 2 }; enum left_Turn_Treatment { perm = 0, prot = 1, no_business = -1 }; //array size, for constructing matirx or array const int laneColumnSize = 32; const int movementSize = 32; const int NEMA_PhaseSize = 32;//temp enable=false const int stageSize = 5; const int ringSize = 3; const int directionSize = 5; const int groupSize = 5; //index range, for indexing, from 1 to 0+range (including the 0+range th) //parameters double l = 12; double x_c_Input = 0.9; double PHF = 1; double f_1 = 1; double f_2 = 1; double t_L = 4; double t_Yellow = 4; double t_AR = 2; double minGreenTime = 5; #pragma endregion #pragma region Initialization_Methods class CSignalNode { public: CSignalNode()//Constructor { y_StageMax = 1; x_c_output = 0.9; c_Min = 60; movement_str_to_index_map["EBL"] = EBL; movement_str_to_index_map["EBT"] = EBT; movement_str_to_index_map["EBR"] = EBR; movement_str_to_index_map["WBL"] = WBL; movement_str_to_index_map["WBT"] = WBT; movement_str_to_index_map["WBR"] = WBR; movement_str_to_index_map["NBL"] = NBL; movement_str_to_index_map["NBT"] = NBT; movement_str_to_index_map["NBR"] = NBR; movement_str_to_index_map["SBL"] = SBL; movement_str_to_index_map["SBT"] = SBT; movement_str_to_index_map["SBR"] = SBR; movement_str_array[EBL] = "EBL"; movement_str_array[EBT] = "EBT"; movement_str_array[EBR] = "EBR"; movement_str_array[WBL] = "WBL"; movement_str_array[WBT] = "WBT"; movement_str_array[WBR] = "WBR"; movement_str_array[NBL] = "NBL"; movement_str_array[NBT] = "NBT"; movement_str_array[NBR] = "NBR"; movement_str_array[SBL] = "SBL"; movement_str_array[SBT] = "SBT"; movement_str_array[SBR] = "SBR"; movement_str_to_direction_map["EBL"] = E; movement_str_to_direction_map["EBT"] = E; movement_str_to_direction_map["EBR"] = E; movement_str_to_direction_map["WBL"] = W; movement_str_to_direction_map["WBT"] = W; movement_str_to_direction_map["WBR"] = W; movement_str_to_direction_map["NBL"] = N; movement_str_to_direction_map["NBT"] = N; movement_str_to_direction_map["NBR"] = N; movement_str_to_direction_map["SBL"] = S; movement_str_to_direction_map["SBT"] = S; movement_str_to_direction_map["SBR"] = S; left_Movement_Opposing_Index_Map[EBL] = WBT; left_Movement_Opposing_Index_Map[WBL] = EBT; left_Movement_Opposing_Index_Map[NBL] = SBT; left_Movement_Opposing_Index_Map[SBL] = NBT; left_Movement_Counterpart_Index_Map[EBL] = EBT; left_Movement_Counterpart_Index_Map[WBL] = WBT; left_Movement_Counterpart_Index_Map[NBL] = NBT; left_Movement_Counterpart_Index_Map[SBL] = SBT; left_Movement_Counterpart_Right_Trun_Index_Map[EBL] = EBR; left_Movement_Counterpart_Right_Trun_Index_Map[WBL] = WBR; left_Movement_Counterpart_Right_Trun_Index_Map[NBL] = NBR; left_Movement_Counterpart_Right_Trun_Index_Map[SBL] = SBR; movement_Index_to_Group_Map[EBL] = group(1); movement_Index_to_Group_Map[EBT] = group(2); movement_Index_to_Group_Map[EBR] = group(2); movement_Index_to_Group_Map[WBL] = group(1); movement_Index_to_Group_Map[WBT] = group(2); movement_Index_to_Group_Map[WBR] = group(2); movement_Index_to_Group_Map[NBL] = group(1); movement_Index_to_Group_Map[NBT] = group(2); movement_Index_to_Group_Map[NBR] = group(2); movement_Index_to_Group_Map[SBL] = group(1); movement_Index_to_Group_Map[SBT] = group(2); movement_Index_to_Group_Map[SBR] = group(2); direction_index_to_str_map[E] = "E"; direction_index_to_str_map[W] = "W"; direction_index_to_str_map[N] = "N"; direction_index_to_str_map[S] = "S"; intersection_Average_Delay = 0; intersection_Total_Delay = 0; intersection_Total_Volume = 0; left_Turn_Treatment_index_to_str_map[prot] = "Protected"; left_Turn_Treatment_index_to_str_map[perm] = "Permissive"; left_Turn_Treatment_index_to_str_map[no_business] = "Null"; for (int s = 0; s <= stageSize; s++) { y_Max_Stage_Array[s] = 0; for (int m = 0; m <= movementSize; m++) { saturation_Flow_Rate_Matrix[s][m] = 0; capacity_by_Stage_and_Movement_Matrix[s][m] = 0; } for (int d = 0; d <= directionSize; d++) { for (int g = 0; g <= groupSize; g++) { stage_Direction_Candidates_Matrix[s][d][g] = 0; } approach_Average_Delay_Array[d] = 0; approach_Total_Delay_Array[d] = 0; approach_Total_Volume_Array[d] = 0; } } for (int m = 0; m <= movementSize; m++) { movement_Array[m].Enable = false; movement_Array[m].Volume = 0; } } int movement_Range = 12; int direction_Range = 4; std::map<string, enum movement_Index> movement_str_to_index_map; std::map<enum direction, string > direction_index_to_str_map; std::map<enum left_Turn_Treatment, string > left_Turn_Treatment_index_to_str_map; string movement_str_array[movementSize + 1]; std::map<string, enum direction> movement_str_to_direction_map; std::map<enum movement_Index, enum movement_Index> left_Movement_Opposing_Index_Map; std::map<enum movement_Index, enum movement_Index> left_Movement_Counterpart_Index_Map;//L -> T std::map<enum movement_Index, enum movement_Index> left_Movement_Counterpart_Right_Trun_Index_Map;//L -> R std::map<enum movement_Index, enum group> movement_Index_to_Group_Map; //array SMovementData movement_Array[movementSize + 1]; //indexed by enum movement_Direction --Step 2 int green_Start_Stage_Array[stageSize + 1]; int green_End_Stage_Array[stageSize+1]; double y_Max_Stage_Array[stageSize+1]; double green_Time_Stage_Array[stageSize + 1]; double cumulative_Green_Start_Time_Stage_Array[stageSize + 1]; double cumulative_Green_End_Time_Stage_Array[stageSize + 1]; double effective_Green_Time_Stage_Array[stageSize + 1]; double cumulative_Effective_Green_Start_Time_Stage_Array[stageSize + 1]; double cumulative_Effective_Green_End_Time_Stage_Array[stageSize + 1]; double ratio_of_Effective_Green_Time_to_Cycle_Length_Array[stageSize + 1]; double approach_Average_Delay_Array[directionSize+1]; double approach_Total_Delay_Array[directionSize + 1]; double approach_Total_Volume_Array[directionSize + 1]; //matrix double saturation_Flow_Rate_Matrix[stageSize+1][movementSize + 1];//s double y_Stage_Movement_Matrix[stageSize + 1][movementSize + 1]; double stage_Direction_Candidates_Matrix[stageSize + 1][directionSize + 1][groupSize + 1]; double capacity_by_Stage_and_Movement_Matrix[stageSize + 1][movementSize + 1]; double v_over_C_by_Stage_and_Movement_Matrix[stageSize + 1][movementSize + 1]; double average_Uniform_Delay_Matrix[stageSize + 1][movementSize + 1]; int NEMA_Phase_Matrix[5][3] = { 0,0,0,0,1,5,0,2,6,0,3,7,0,4,8 };//row->NEMA_phases; col->rings int green_Start_NEMA_Phase[5][3]; SMovementData Stage_Ring_Movement_Matrix[ringSize + 1][stageSize + 1]; //variables int stage_Range; double y_StageMax; double x_c_output; double c_Min; double c_Optimal; double intersection_Average_Delay; double intersection_Total_Delay; double intersection_Total_Volume; string LOS; void PerformQEM(int nodeID) { MainModual.WriteLog(0, "Step 2: Perform QEM", 1); MainModual.WriteLog(0, "Step 2.1: Set Left Turn Treatments",2); Set_Left_Turn_Treatment(); MainModual.WriteLog(0, "Step 2.2: Set StageNos",2); Set_StageNo_for_Movements(); MainModual.WriteLog(0, "Step 2.3: Set Saturation Flow Rate Matrix",2); Set_Saturation_Flow_Rate_Matrix(); MainModual.WriteLog(0, "Step 2.4: Calculate Flow Ratio",2); Calculate_Flow_of_Ratio_Max(); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double("Max y Value", y_StageMax),3); MainModual.WriteLog(0, "Step 2.5: Calculate Total Cycle Lost Time", 2); Calculate_Total_Cycle_Lost_Time(); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double("Total Cycle Lost Time", l), 3); MainModual.WriteLog(0, "Step 2.6: Calculate the Minimum and Optimal Cycle Length",2); Calculate_the_Minimum_And_Optimal_Cycle_Length(); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double("Min Cycle Length", c_Min),3); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double("Optimal Cycle Length", c_Optimal), 3); MainModual.WriteLog(0, "Step 2.7: Recalculate xc",2); Calculate_the_x_c_Output(); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double("Recalculated xc", x_c_output),3); MainModual.WriteLog(0, "Step 2.8: Timing for Stages",2); Calculate_Green_Time_for_Stages(); Printing_Green_Time_for_Stages(); MainModual.WriteLog(0, "Step 2.9: Calculate capacity and ratio V/C", 2); Calculate_Capacity_And_Ratio_V_over_C(); MainModual.WriteLog(0, "Step 2.10: Calculate Signal Delay", 2); Calculate_Signal_Delay(nodeID); MainModual.WriteLog(0, "Step 2.11: Judge LOS", 2); Judge_Signal_LOS(nodeID); } void AddMovementVolume(int link_seq_no, string str, float volume, int lanes, int sharedLanes) { enum movement_Index mi = movement_str_to_index_map[str]; enum direction di = movement_str_to_direction_map[str]; movement_Array[mi].Enable = true; movement_Array[mi].LinkSeqNo = link_seq_no; movement_Array[mi].Volume = volume; //movement_Array[mi].StageNo = stage(movement_to_Stage_Array[mi]); movement_Array[mi].GroupNo = movement_Index_to_Group_Map[mi]; movement_Array[mi].DirectionNo = di; movement_Array[mi].Left_Turn_Treatment = no_business; movement_Array[mi].Lanes = lanes; movement_Array[mi].SharedLanes = sharedLanes; } void Set_Left_Turn_Treatment() { //20200808 Add a completeness check. Assign high privileges if only left. for (size_t m = 1; m <= movement_Range; m++) { int final_decision; if (movement_Array[m].GroupNo == 1) { final_decision = 0; //(1) Left-turn Lane Check if (movement_Array[m].Lanes > 1) { final_decision = 1; } //(2) Minimum Volume Check if (movement_Array[m].Volume >= 240) { final_decision = 1; } //(3) Opposing Through Lanes Check int op_Movement_Index = left_Movement_Opposing_Index_Map[movement_Index(m)]; if (movement_Array[op_Movement_Index].Lanes >= 4) { final_decision = 1; } //(4) Opposing Traffic Speed Check //(5) Minimum Cross-Product Check int co_Movement_Index = left_Movement_Opposing_Index_Map[movement_Index(m)]; if (movement_Array[co_Movement_Index].Lanes > 1) { if (movement_Array[co_Movement_Index].Volume * movement_Array[m].Volume >= 100000) { final_decision = 1; } } else { if (movement_Array[co_Movement_Index].Volume * movement_Array[m].Volume >= 50000) { final_decision = 1; } } //(6) if there is no T movement, then the left movement should be protected. if (movement_Array[left_Movement_Counterpart_Index_Map[movement_Index(m)]].Enable==false) { final_decision = 1; } } else { final_decision = -1; } movement_Array[m].Left_Turn_Treatment = left_Turn_Treatment(final_decision); if (final_decision != -1) { g_info_String = "Left Turn Treatment of Movement_"; g_info_String.append(movement_str_array[m]); g_info_String.append(": "); g_info_String.append(left_Turn_Treatment_index_to_str_map[left_Turn_Treatment(final_decision)]); MainModual.WriteLog(1, g_info_String, 3); } } } void Set_StageNo_for_Movements() { //Determining the main direction int east_And_West_Volume = movement_Array[EBL].Volume + movement_Array[EBT].Volume + movement_Array[EBR].Volume + movement_Array[WBL].Volume + movement_Array[WBT].Volume + movement_Array[WBR].Volume; int north_And_South_Volume = movement_Array[NBL].Volume + movement_Array[NBT].Volume + movement_Array[NBR].Volume + movement_Array[SBL].Volume + movement_Array[SBT].Volume + movement_Array[SBR].Volume; stage_Range = 2; bool east_And_West_Flag = false; bool north_And_South_Flag = false; if (movement_Array[EBL].Left_Turn_Treatment == prot) { stage_Range++; east_And_West_Flag = true; } else if (movement_Array[WBL].Left_Turn_Treatment == prot) { stage_Range++; east_And_West_Flag = true; } if (movement_Array[NBL].Left_Turn_Treatment == prot) { stage_Range++; north_And_South_Flag = true; } else if (movement_Array[SBL].Left_Turn_Treatment == prot) { stage_Range++; north_And_South_Flag = true; } enum movement_Index firstL; enum movement_Index firstT; enum movement_Index firstR; enum movement_Index secondL; enum movement_Index secondT; enum movement_Index secondR; enum movement_Index thridL; enum movement_Index thridT; enum movement_Index thridR; enum movement_Index fouthL; enum movement_Index fouthT; enum movement_Index fouthR; if (east_And_West_Volume >= north_And_South_Volume) { //east and west first firstL = EBL; firstT = EBT; firstR = EBR; secondL = WBL; secondT = WBT; secondR = WBR; thridL = NBL; thridT = NBT; thridR = NBR; fouthL = SBL; fouthT = SBT; fouthR = SBR; MainModual.WriteLog(0, "Main Approaches: E & W", 3); } else { firstL = NBL; firstT = NBT; firstR = NBR; secondL = SBL; secondT = SBT; secondR = SBR; thridL = EBL; thridT = EBT; thridR = EBR; fouthL = WBL; fouthT = WBT; fouthR = WBR; MainModual.WriteLog(0, "Main Approaches: N & S", 3); } if (east_And_West_Flag) { movement_Array[firstL].StageNo_in_Order.push_back(stage1); movement_Array[firstT].StageNo_in_Order.push_back(stage2); movement_Array[firstR].StageNo_in_Order.push_back(stage2); movement_Array[secondL].StageNo_in_Order.push_back(stage1); movement_Array[secondT].StageNo_in_Order.push_back(stage2); movement_Array[secondR].StageNo_in_Order.push_back(stage2); if (north_And_South_Flag) { movement_Array[thridL].StageNo_in_Order.push_back(stage3); movement_Array[thridT].StageNo_in_Order.push_back(stage4); movement_Array[thridR].StageNo_in_Order.push_back(stage4); movement_Array[fouthL].StageNo_in_Order.push_back(stage3); movement_Array[fouthT].StageNo_in_Order.push_back(stage4); movement_Array[fouthR].StageNo_in_Order.push_back(stage4); } else { movement_Array[thridL].StageNo_in_Order.push_back(stage3); movement_Array[thridT].StageNo_in_Order.push_back(stage3); movement_Array[thridR].StageNo_in_Order.push_back(stage3); movement_Array[fouthL].StageNo_in_Order.push_back(stage3); movement_Array[fouthT].StageNo_in_Order.push_back(stage3); movement_Array[fouthR].StageNo_in_Order.push_back(stage3); } } else { movement_Array[firstL].StageNo_in_Order.push_back(stage1); movement_Array[firstT].StageNo_in_Order.push_back(stage1); movement_Array[firstR].StageNo_in_Order.push_back(stage1); movement_Array[secondL].StageNo_in_Order.push_back(stage1); movement_Array[secondT].StageNo_in_Order.push_back(stage1); movement_Array[secondR].StageNo_in_Order.push_back(stage1); if (north_And_South_Flag) { movement_Array[thridL].StageNo_in_Order.push_back(stage2); movement_Array[thridT].StageNo_in_Order.push_back(stage3); movement_Array[thridR].StageNo_in_Order.push_back(stage3); movement_Array[fouthL].StageNo_in_Order.push_back(stage2); movement_Array[fouthT].StageNo_in_Order.push_back(stage3); movement_Array[fouthR].StageNo_in_Order.push_back(stage3); } else { movement_Array[thridL].StageNo_in_Order.push_back(stage2); movement_Array[thridT].StageNo_in_Order.push_back(stage2); movement_Array[thridR].StageNo_in_Order.push_back(stage2); movement_Array[fouthL].StageNo_in_Order.push_back(stage2); movement_Array[fouthT].StageNo_in_Order.push_back(stage2); movement_Array[fouthR].StageNo_in_Order.push_back(stage2); } } //20200808 check the enable property, delete stage from enable=false movement //20200812 modified this part by using vector StageNo_in_Order int initialStage_Range = stage_Range; int criticalStage = -1; for (size_t s = initialStage_Range; s >= 1; s--) { int checkNumber = 0; if (criticalStage != -1) { for (size_t m = 1; m <= movement_Range; m++) { for (size_t so = 0; so < movement_Array[m].StageNo_in_Order.size(); so++) { if (movement_Array[m].StageNo_in_Order[so] > criticalStage && movement_Array[m].Enable == true) { movement_Array[m].StageNo_in_Order[so] = stage(movement_Array[m].StageNo_in_Order[so] - 1); } } } } for (size_t m = 1; m <= movement_Range; m++) { for (size_t so = 0; so < movement_Array[m].StageNo_in_Order.size(); so++) { if (movement_Array[m].Enable == true && movement_Array[m].StageNo_in_Order[so] == s) { checkNumber++; } } } if (checkNumber == 0) { stage_Range--; criticalStage = s; } else { criticalStage = -1; } } for (size_t m = 1; m <= movement_Range; m++) { if (movement_Array[m].Enable == false) { movement_Array[m].StageNo_in_Order[0] = stage(- 1); } } //TODO: we can scan stages row-wise and mark the property of each stage, left-protected for example. //for (size_t s = 0; s < stage_Range; s++) //{ //} //20200812 add right-turn treatment for movements for (size_t m = 1; m <= movement_Range; m++) { if (movement_Array[m].Enable==true && movement_Array[m].GroupNo==1) { if (movement_Array[left_Movement_Counterpart_Right_Trun_Index_Map[movement_Index(m)]].Enable == true) { movement_Array[left_Movement_Counterpart_Right_Trun_Index_Map[movement_Index(m)]].StageNo_in_Order.insert(movement_Array[left_Movement_Counterpart_Right_Trun_Index_Map[movement_Index(m)]].StageNo_in_Order.begin(), movement_Array[m].StageNo_in_Order[0]); } } } //movement_Array[EBL].StageNo = stage1; //movement_Array[EBT].StageNo = stage2; //movement_Array[EBR].StageNo = stage2; //movement_Array[WBL].StageNo = stage1; //movement_Array[WBT].StageNo = stage2; //movement_Array[WBR].StageNo = stage2; //movement_Array[NBL].StageNo = stage3; //movement_Array[NBT].StageNo = stage3; //movement_Array[NBR].StageNo = stage3; //movement_Array[SBL].StageNo = stage3; //movement_Array[SBT].StageNo = stage3; //movement_Array[SBR].StageNo = stage3; g_info_String = "Number of Stages: "; g_info_String.append(to_string(stage_Range)); MainModual.WriteLog(1, g_info_String, 3); for (size_t m = 1; m <= movement_Range; m++) { if (movement_Array[m].Enable == true) { for (size_t so = 0; so < movement_Array[m].StageNo_in_Order.size(); so++) { g_info_String = "StageNo of Movement_"; g_info_String.append(movement_str_array[m]); g_info_String.append(": "); g_info_String.append("Stage_"); g_info_String.append(to_string(movement_Array[m].StageNo_in_Order[so])); MainModual.WriteLog(1, g_info_String, 4); } } } } void Set_Saturation_Flow_Rate_Matrix() { //movement_Array left turn movement // we need to use the saturation flow rate values based on protected and permitted for (size_t m = 1; m <= movement_Range; m++) { if (movement_Array[m].Enable == false) { continue; } for (size_t so = 0; so < movement_Array[m].StageNo_in_Order.size(); so++) { if (movement_Array[m].Left_Turn_Treatment == prot) { saturation_Flow_Rate_Matrix[movement_Array[m].StageNo_in_Order[so]][m] = 1530 * movement_Array[m].Lanes * PHF; } else if (movement_Array[m].Left_Turn_Treatment == perm) { int op_Movement_Index = left_Movement_Opposing_Index_Map[movement_Index(m)]; int op_volume = movement_Array[op_Movement_Index].Volume; saturation_Flow_Rate_Matrix[movement_Array[m].StageNo_in_Order[so]][m] = f_1 * f_2 * op_volume * (exp(-op_volume * 4.5 / 3600)) / (1 - exp(op_volume * 2.5 / 3600)); } else { saturation_Flow_Rate_Matrix[movement_Array[m].StageNo_in_Order[so]][m] = 1530 * movement_Array[m].Lanes;//temp!! } g_info_String = "Saturation Flow Rate of Movement_"; g_info_String.append(movement_str_array[m]); g_info_String.append(" and "); g_info_String.append("Stage_"); g_info_String.append(to_string(movement_Array[m].StageNo_in_Order[so])); g_info_String.append(": "); g_info_String.append(to_string(saturation_Flow_Rate_Matrix[movement_Array[m].StageNo_in_Order[so]][m])); MainModual.WriteLog(1, g_info_String, 3); } } //saturation_Flow_Rate_Matrix[1][EBL] = 1750; //saturation_Flow_Rate_Matrix[1][WBL] = 1750; //saturation_Flow_Rate_Matrix[2][EBT] = 3400; //saturation_Flow_Rate_Matrix[2][EBR] = 3400; //saturation_Flow_Rate_Matrix[2][WBT] = 3400; //saturation_Flow_Rate_Matrix[2][WBR] = 3400; //saturation_Flow_Rate_Matrix[3][NBL] = 475; //saturation_Flow_Rate_Matrix[3][NBT] = 1800; //saturation_Flow_Rate_Matrix[3][NBR] = 1800; //saturation_Flow_Rate_Matrix[3][SBL] = 450; //saturation_Flow_Rate_Matrix[3][SBT] = 1800; //saturation_Flow_Rate_Matrix[3][SBR] = 1800; } void Calculate_Flow_of_Ratio_Max() { //y_Stage_Movement_Matrix //y_StageMax for (size_t s = 1; s <= stage_Range; s++) { y_Max_Stage_Array[s] = 0; for (size_t m = 1; m <= movement_Range; m++) { for (size_t so = 0; so < movement_Array[m].StageNo_in_Order.size(); so++) { if (saturation_Flow_Rate_Matrix[s][m] != 0 && movement_Array[m].Enable && movement_Array[m].StageNo_in_Order[so] == s) { y_Stage_Movement_Matrix[s][m] = double(movement_Array[m].Volume) / double(saturation_Flow_Rate_Matrix[s][m]); //double stage_Direction_Candidates_Matrix[stageSize][directionSize][groupSize] stage_Direction_Candidates_Matrix[s][movement_Array[m].DirectionNo][movement_Array[m].GroupNo] += y_Stage_Movement_Matrix[s][m]; // we tally the movement matrix from this direction and this group number, so we can distingush movements belonging to different directions if (stage_Direction_Candidates_Matrix[s][movement_Array[m].DirectionNo][movement_Array[m].GroupNo] >= y_Max_Stage_Array[s]) { y_Max_Stage_Array[s] = stage_Direction_Candidates_Matrix[s][movement_Array[m].DirectionNo][movement_Array[m].GroupNo]; } } } } } y_StageMax = 0; for (size_t i = 1; i <= stage_Range; i++) { y_StageMax += y_Max_Stage_Array[i]; } } void Calculate_Total_Cycle_Lost_Time() { l = t_L * stage_Range; } void Calculate_the_Minimum_And_Optimal_Cycle_Length() { c_Min = min(150, max(60, (l - x_c_Input) / (x_c_Input - y_StageMax))); c_Optimal= min(150, max(60, (1.5*l +5) / (1 - y_StageMax))); } void Calculate_the_x_c_Output() { x_c_output = (y_StageMax * c_Min) / (c_Min - l); } void Calculate_Green_Time_for_Stages() { for (size_t s = 1; s <= stage_Range; s++) { // green_Time_Stage_Array[i] = y_Max_Stage_Array[i] * c_Min / x_c_output; green_Time_Stage_Array[s] = max(minGreenTime, y_Max_Stage_Array[s] * c_Min / y_StageMax); effective_Green_Time_Stage_Array[s] = green_Time_Stage_Array[s] - t_L + t_Yellow + t_AR; ratio_of_Effective_Green_Time_to_Cycle_Length_Array[s] = effective_Green_Time_Stage_Array[s] / c_Min; } } void Printing_Green_Time_for_Stages()//output Effective green time { cumulative_Green_Start_Time_Stage_Array[1] = 0; cumulative_Green_End_Time_Stage_Array[1] = green_Time_Stage_Array[1]; MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double("Green Time of Stage 1", green_Time_Stage_Array[1]),3); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double("Start Green Time of Stage 1", cumulative_Green_Start_Time_Stage_Array[1]), 4); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double("End Green Time of Stage 1", cumulative_Green_End_Time_Stage_Array[1]), 4); for (size_t i = 2; i <= stage_Range; i++) { g_info_String = "Green Time of Stage "; g_info_String.append(to_string(i)); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double(g_info_String, green_Time_Stage_Array[i]),3); cumulative_Green_Start_Time_Stage_Array[i] = cumulative_Green_End_Time_Stage_Array[i - 1]; cumulative_Green_End_Time_Stage_Array[i] = cumulative_Green_Start_Time_Stage_Array[i] + green_Time_Stage_Array[i]; g_info_String = "Start Green Time of Stage "; g_info_String.append(to_string(i)); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double(g_info_String, cumulative_Green_Start_Time_Stage_Array[i]), 4); g_info_String = "End Green Time of Stage "; g_info_String.append(to_string(i)); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double(g_info_String, cumulative_Green_End_Time_Stage_Array[i]), 4); } cumulative_Effective_Green_Start_Time_Stage_Array[1] = 0; cumulative_Effective_Green_End_Time_Stage_Array[1] = effective_Green_Time_Stage_Array[1]; MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double("Effective Green Time of Stage 1", effective_Green_Time_Stage_Array[1]), 3); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double("Start Effective Green Time of Stage 1", cumulative_Effective_Green_Start_Time_Stage_Array[1]), 4); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double("End Effective Green Time of Stage 1", cumulative_Effective_Green_End_Time_Stage_Array[1]), 4); for (size_t i = 2; i <= stage_Range; i++) { g_info_String = "Effective Green Time of Stage "; g_info_String.append(to_string(i)); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double(g_info_String, effective_Green_Time_Stage_Array[i]), 3); cumulative_Effective_Green_Start_Time_Stage_Array[i] = cumulative_Effective_Green_End_Time_Stage_Array[i - 1]; cumulative_Effective_Green_End_Time_Stage_Array[i] = cumulative_Effective_Green_Start_Time_Stage_Array[i] + effective_Green_Time_Stage_Array[i]; g_info_String = "Start Effective Green Time of Stage "; g_info_String.append(to_string(i)); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double(g_info_String, cumulative_Effective_Green_Start_Time_Stage_Array[i]), 4); g_info_String = "End Effective Green Time of Stage "; g_info_String.append(to_string(i)); MainModual.WriteLog(1, MainModual.Output_Combine_Message_And_Value_Double(g_info_String, cumulative_Effective_Green_End_Time_Stage_Array[i]), 4); } } void Calculate_Capacity_And_Ratio_V_over_C() { for (size_t s = 1; s <= stage_Range; s++) { for (size_t m = 1; m <= movement_Range; m++) { for (size_t so = 0; so < movement_Array[m].StageNo_in_Order.size(); so++) { if (saturation_Flow_Rate_Matrix[s][m] != 0 && movement_Array[m].Enable && movement_Array[m].StageNo_in_Order[so] == s) { capacity_by_Stage_and_Movement_Matrix[s][m] = saturation_Flow_Rate_Matrix[s][m] * ratio_of_Effective_Green_Time_to_Cycle_Length_Array[s]; g_info_String = "a. Capacity of Stage_"; g_info_String.append(to_string(s)); g_info_String.append(" and Movement_"); g_info_String.append(movement_str_array[m]); g_info_String.append(": "); g_info_String.append(to_string(capacity_by_Stage_and_Movement_Matrix[s][m])); MainModual.WriteLog(1, g_info_String, 3); v_over_C_by_Stage_and_Movement_Matrix[s][m] = movement_Array[m].Volume / capacity_by_Stage_and_Movement_Matrix[s][m]; g_info_String = "b. V/C of Stage_"; g_info_String.append(to_string(s)); g_info_String.append(" and Movement_"); g_info_String.append(movement_str_array[m]); g_info_String.append(": "); g_info_String.append(to_string(v_over_C_by_Stage_and_Movement_Matrix[s][m])); MainModual.WriteLog(1, g_info_String, 3); } } } } } void Calculate_Signal_Delay(int nodeID) { for (size_t s = 1; s <= stage_Range; s++) { for (size_t m = 1; m <= movement_Range; m++) { for (size_t so = 0; so < movement_Array[m].StageNo_in_Order.size(); so++) { if (saturation_Flow_Rate_Matrix[s][m] != 0 && movement_Array[m].Enable && movement_Array[m].StageNo_in_Order[so] == s) { average_Uniform_Delay_Matrix[s][m] = (0.5 * capacity_by_Stage_and_Movement_Matrix[s][m] * pow((1 - ratio_of_Effective_Green_Time_to_Cycle_Length_Array[s]), 2)) / (1 - v_over_C_by_Stage_and_Movement_Matrix[s][m] * ratio_of_Effective_Green_Time_to_Cycle_Length_Array[s]); //(2) Average Incremental Delay next time g_info_String = "Average Uniform Delay of Stage_"; g_info_String.append(to_string(s)); g_info_String.append(" and Movement_"); g_info_String.append(movement_str_array[m]); g_info_String.append(": "); g_info_String.append(to_string(average_Uniform_Delay_Matrix[s][m])); MainModual.WriteLog(1, g_info_String, 3); approach_Total_Delay_Array[movement_Array[m].DirectionNo] += movement_Array[m].Volume * average_Uniform_Delay_Matrix[s][m]; approach_Total_Volume_Array[movement_Array[m].DirectionNo] += movement_Array[m].Volume; } } } } for (size_t d = 1; d <= direction_Range; d++) { if (approach_Total_Volume_Array[d] == 0) { continue; } approach_Average_Delay_Array[d] = approach_Total_Delay_Array[d] / approach_Total_Volume_Array[d]; g_info_String = "Average Delay of Approach_"; g_info_String.append(direction_index_to_str_map[direction(d)]); g_info_String.append(": "); g_info_String.append(to_string(approach_Average_Delay_Array[d])); MainModual.WriteLog(1, g_info_String, 3); intersection_Total_Delay += approach_Average_Delay_Array[d] * approach_Total_Volume_Array[d]; intersection_Total_Volume += approach_Total_Volume_Array[d]; } intersection_Average_Delay = intersection_Total_Delay / intersection_Total_Volume; g_info_String = "Total Delay of Intersection_NodeID_"; g_info_String.append(to_string(nodeID)); g_info_String.append(": "); g_info_String.append(to_string(intersection_Total_Delay)); MainModual.WriteLog(1, g_info_String, 3); g_info_String = "Average Delay of Intersection_NodeID_"; g_info_String.append(to_string(nodeID)); g_info_String.append(": "); g_info_String.append(to_string(intersection_Average_Delay)); MainModual.WriteLog(1, g_info_String, 3); } void Judge_Signal_LOS(int nodeID) { if (intersection_Total_Delay <= 10) { LOS = "A"; } else if (intersection_Total_Delay <= 20) { LOS = "B"; } else if (intersection_Total_Delay <= 35) { LOS = "C"; } else if (intersection_Total_Delay <= 55) { LOS = "D"; } else if (intersection_Total_Delay <= 80) { LOS = "E"; } else { LOS = "F"; } g_info_String = "LOS of Intersection_NodeID_"; g_info_String.append(to_string(nodeID)); g_info_String.append(": "); g_info_String.append(LOS); MainModual.WriteLog(1, g_info_String, 3); } int signal_node_seq_no; // sequence number int main_node_id; //external node number std::vector<int> m_movement_link_seq_no_vector; //void Set_Movement_Array() //{ // //movement_Array // movement_Array[1].Enable = true; // movement_Array[1].Volume = 300; // movement_Array[1].StageNo = stage(movement_to_Stage_Array[1]); // movement_Array[1].GroupNo = group(1); // movement_Array[1].DirectionNo = E; // movement_Array[2].Enable = true; // movement_Array[2].Volume = 900; // movement_Array[2].StageNo = stage(movement_to_Stage_Array[2]); // movement_Array[2].GroupNo = group(2); // movement_Array[2].DirectionNo = E; // movement_Array[3].Enable = true; // movement_Array[3].Volume = 200; // movement_Array[3].StageNo = stage(movement_to_Stage_Array[3]); // movement_Array[3].GroupNo = group(2); // movement_Array[3].DirectionNo = E; // movement_Array[4].Enable = true; // movement_Array[4].Volume = 250; // movement_Array[4].StageNo = stage(movement_to_Stage_Array[4]); // movement_Array[4].GroupNo = group(1); // movement_Array[4].DirectionNo = W; // movement_Array[5].Enable = true; // movement_Array[5].Volume = 1000; // movement_Array[5].StageNo = stage(movement_to_Stage_Array[5]); // movement_Array[5].GroupNo = group(2); // movement_Array[5].DirectionNo = W; // movement_Array[6].Enable = true; // movement_Array[6].Volume = 150; // movement_Array[6].StageNo = stage(movement_to_Stage_Array[6]); // movement_Array[6].GroupNo = group(2); // movement_Array[6].DirectionNo = W; // movement_Array[7].Enable = true; // movement_Array[7].Volume = 70; // movement_Array[7].StageNo = stage(movement_to_Stage_Array[7]); // movement_Array[7].GroupNo = group(1); // movement_Array[7].DirectionNo = N; // movement_Array[8].Enable = true; // movement_Array[8].Volume = 310; // movement_Array[8].StageNo = stage(movement_to_Stage_Array[8]); // movement_Array[8].GroupNo = group(2); // movement_Array[8].DirectionNo = N; // movement_Array[9].Enable = true; // movement_Array[9].Volume = 60; // movement_Array[9].StageNo = stage(movement_to_Stage_Array[9]); // movement_Array[9].GroupNo = group(2); // movement_Array[9].DirectionNo = N; // movement_Array[10].Enable = true; // movement_Array[10].Volume = 90; // movement_Array[10].StageNo = stage(movement_to_Stage_Array[10]); // movement_Array[10].GroupNo = group(1); // movement_Array[10].DirectionNo = S; // movement_Array[11].Enable = true; // movement_Array[11].Volume = 340; // movement_Array[11].StageNo = stage(movement_to_Stage_Array[11]); // movement_Array[11].GroupNo = group(2); // movement_Array[11].DirectionNo = S; // movement_Array[12].Enable = true; // movement_Array[12].Volume = 50; // movement_Array[12].StageNo = stage(movement_to_Stage_Array[12]); // movement_Array[12].GroupNo = group(2); // movement_Array[12].DirectionNo = S; //} }; extern std::vector<CNode> g_node_vector; extern std::vector<CLink> g_link_vector; extern std::vector<CServiceArc> g_service_arc_vector; std::vector<CNode> g_node_vector; std::vector<CLink> g_link_vector; std::vector<CServiceArc> g_service_arc_vector; std::map<int, CSignalNode> g_signal_node_map; // first key is signal node id //split the string by "_" vector<string> split(const string &s, const string &seperator) { vector<string> result;typedef string::size_type string_size; string_size i = 0; while (i != s.size()) { int flag = 0; while (i != s.size() && flag == 0) { flag = 1; for (string_size x = 0; x < seperator.size(); ++x) if (s[i] == seperator[x]) { ++i; flag = 0; break; } } flag = 0; string_size j = i; while (j != s.size() && flag == 0) { for (string_size x = 0; x < seperator.size(); ++x) if (s[j] == seperator[x]) { flag = 1; break; } if (flag == 0) ++j; } if (i != j) { result.push_back(s.substr(i, j - i)); i = j; } } return result; } string test_str = "0300:30:120_0600:30:140"; vector<float> g_time_parser(vector<string>& inputstring) { vector<float> output_global_minute; for (int k = 0; k < inputstring.size(); k++) { vector<string> sub_string = split(inputstring[k], "_"); for (int i = 0; i < sub_string.size(); i++) { //HHMM //012345 char hh1 = sub_string[i].at(0); char hh2 = sub_string[i].at(1); char mm1 = sub_string[i].at(2); char mm2 = sub_string[i].at(3); float hhf1 = ((float)hh1 - 48); float hhf2 = ((float)hh2 - 48); float mmf1 = ((float)mm1 - 48); float mmf2 = ((float)mm2 - 48); float hh = hhf1 * 10 * 60 + hhf2 * 60; float mm = mmf1 * 10 + mmf2; float global_mm_temp = hh + mm; output_global_minute.push_back(global_mm_temp); } } return output_global_minute; } // transform hhmm to minutes inline string g_time_coding(float time_stamp) { int hour = time_stamp / 60; int minute = time_stamp - hour * 60; int second = (time_stamp - hour * 60 - minute)*60; ostringstream strm; strm.fill('0'); strm << setw(2) << hour << setw(2) << minute << ":" << setw(2) << second; return strm.str(); } // transform hhmm to minutes void g_ProgramStop() { MainModual.WriteLog(2, "Program stops. Press any key to terminate. Thanks!", 1); getchar(); exit(0); }; void g_ReadInputData(CMainModual& MainModual) { MainModual.g_LoadingStartTimeInMin = 99999; MainModual.g_LoadingEndTimeInMin = 0; //step 0:read demand period file CCSVParser parser_demand_period; MainModual.WriteLog(0, "Step 1: Reading file demand_period.csv...", 1); //g_LogFile << "Step 7.1: Reading file input_agent_type.csv..." << g_GetUsedMemoryDataInMB() << endl; if (!parser_demand_period.OpenCSVFile("demand_period.csv", true)) { MainModual.WriteLog(2, "demand_period.csv cannot be opened.", 1); g_ProgramStop(); } if (parser_demand_period.inFile.is_open() || parser_demand_period.OpenCSVFile("demand_period.csv", true)) { while (parser_demand_period.ReadRecord()) { int demand_period_id; if (parser_demand_period.GetValueByFieldName("demand_period_id", demand_period_id) == false) { MainModual.WriteLog(2, "Error: Field demand_period_id in file demand_period cannot be read.", 1); g_ProgramStop(); break; } vector<float> global_minute_vector; string time_period; if (parser_demand_period.GetValueByFieldName("time_period", time_period) == false) { MainModual.WriteLog(2, "Error: Field time_period in file demand_period cannot be read.", 1); g_ProgramStop(); break; } vector<string> input_string; input_string.push_back(time_period); //input_string includes the start and end time of a time period with hhmm format global_minute_vector = g_time_parser(input_string); //global_minute_vector incldue the starting and ending time if (global_minute_vector.size() == 2) { if (global_minute_vector[0] < MainModual.g_LoadingStartTimeInMin) MainModual.g_LoadingStartTimeInMin = global_minute_vector[0]; if (global_minute_vector[1] > MainModual.g_LoadingEndTimeInMin) MainModual.g_LoadingEndTimeInMin = global_minute_vector[1]; //cout << global_minute_vector[0] << endl; //cout << global_minute_vector[1] << endl; } } parser_demand_period.CloseCSVFile(); } MainModual.g_number_of_nodes = 0; MainModual.g_number_of_links = 0; // initialize the counter to 0 int internal_node_seq_no = 0; // step 3: read node file CCSVParser parser; if (parser.OpenCSVFile("node.csv", true)) { while (parser.ReadRecord()) // if this line contains [] mark, then we will also read field headers. { int node_id; if (parser.GetValueByFieldName("node_id", node_id) == false) continue; if (MainModual.g_internal_node_to_seq_no_map.find(node_id) != MainModual.g_internal_node_to_seq_no_map.end()) { continue; //has been defined } MainModual.g_internal_node_to_seq_no_map[node_id] = internal_node_seq_no; CNode node; // create a node object node.node_id = node_id; node.node_seq_no = internal_node_seq_no; internal_node_seq_no++; g_node_vector.push_back(node); // push it to the global node vector MainModual.g_number_of_nodes++; if (MainModual.g_number_of_nodes % 5000 == 0) { cout << "reading " << MainModual.g_number_of_nodes << " nodes.. " << endl; } } g_info_String = "Number of Nodes = "; g_info_String.append(to_string(MainModual.g_number_of_nodes)); MainModual.WriteLog(0, g_info_String, 2); // fprintf(g_pFileOutputLog, "number of nodes =,%d\n", MainModual.g_number_of_nodes); parser.CloseCSVFile(); } // step 4: read link file CCSVParser parser_link; if (parser_link.OpenCSVFile("road_link.csv", true)) { while (parser_link.ReadRecord()) // if this line contains [] mark, then we will also read field headers. { int from_node_id; int to_node_id; if (parser_link.GetValueByFieldName("from_node_id", from_node_id) == false) continue; if (parser_link.GetValueByFieldName("to_node_id", to_node_id) == false) continue; string linkID; parser_link.GetValueByFieldName("road_link_id", linkID); // add the to node id into the outbound (adjacent) node list if (MainModual.g_internal_node_to_seq_no_map.find(from_node_id) == MainModual.g_internal_node_to_seq_no_map.end()) { cout << "Error: from_node_id " << from_node_id << " in file road_link.csv is not defined in node.csv." << endl; continue; //has not been defined } if (MainModual.g_internal_node_to_seq_no_map.find(to_node_id) == MainModual.g_internal_node_to_seq_no_map.end()) { cout << "Error: to_node_id " << to_node_id << " in file road_link.csv is not defined in node.csv." << endl; continue; //has not been defined } if (MainModual.g_road_link_id_map.find(linkID) != MainModual.g_road_link_id_map.end()) { cout << "Error: road_link_id " << linkID.c_str() << " has been defined more than once. Please check road_link.csv." << endl; continue; //has not been defined } int internal_from_node_seq_no = MainModual.g_internal_node_to_seq_no_map[from_node_id]; // map external node number to internal node seq no. int internal_to_node_seq_no = MainModual.g_internal_node_to_seq_no_map[to_node_id]; CLink link; // create a link object link.from_node_seq_no = internal_from_node_seq_no; link.to_node_seq_no = internal_to_node_seq_no; link.link_seq_no = MainModual.g_number_of_links; link.to_node_seq_no = internal_to_node_seq_no; link.link_id = linkID; MainModual.g_road_link_id_map[link.link_id] = 1; parser_link.GetValueByFieldName("facility_type", link.type, true, false); parser_link.GetValueByFieldName("link_type", link.link_type); float length = 1.0; // km or mile float free_speed = 1.0; float lane_capacity = 1800; parser_link.GetValueByFieldName("length", length); parser_link.GetValueByFieldName("free_speed", free_speed); free_speed = max(0.1, free_speed); int number_of_lanes = 1; parser_link.GetValueByFieldName("lanes", number_of_lanes); parser_link.GetValueByFieldName("capacity", lane_capacity); float default_cap = 1000; float default_BaseTT = 1; link.number_of_lanes = number_of_lanes; link.lane_capacity = lane_capacity; link.length = length; link.free_flow_travel_time_in_min = length / free_speed * 60; g_node_vector[internal_from_node_seq_no].m_outgoing_link_seq_no_vector.push_back(link.link_seq_no); // add this link to the corresponding node as part of outgoing node/link g_node_vector[internal_to_node_seq_no].m_incoming_link_seq_no_vector.push_back(link.link_seq_no); // add this link to the corresponding node as part of outgoing node/link g_node_vector[internal_from_node_seq_no].m_to_node_seq_no_vector.push_back(link.to_node_seq_no); // add this link to the corresponding node as part of outgoing node/link g_node_vector[internal_from_node_seq_no].m_to_node_2_link_seq_no_map[link.to_node_seq_no] = link.link_seq_no; // add this link to the corresponding node as part of outgoing node/link g_link_vector.push_back(link); MainModual.g_number_of_links++; // map link data to signal node map. string movement_str; parser_link.GetValueByFieldName("movement_str", movement_str); if (movement_str.size() > 0) // and valid { int main_node_id = -1; parser_link.GetValueByFieldName("main_node_id", main_node_id, true, false); int NEMA_phase_number = 0; parser_link.GetValueByFieldName("NEMA_phase_number", NEMA_phase_number, true, false); int initial_volume = 200; parser_link.GetValueByFieldName("volume", initial_volume, true, false); int lanes = 0; parser_link.GetValueByFieldName("lanes", lanes); int sharedLanes = 0; parser_link.GetValueByFieldName("sharedLanes", sharedLanes); if (main_node_id >= 1) { g_signal_node_map[main_node_id].AddMovementVolume(link.link_seq_no, movement_str, initial_volume, lanes, sharedLanes); } } } } parser_link.CloseCSVFile(); // we now know the number of links g_info_String = "Number of Links = "; g_info_String.append(to_string(MainModual.g_number_of_links)); MainModual.WriteLog(0, g_info_String, 2); // fprintf(g_pFileOutputLog, "number of links =,%d\n", MainModual.g_number_of_links); }; double SignalAPI(int iteration_number, int MainModual_mode, int column_updating_iterations) { // step 1: read input data of network / demand tables / Toll g_ReadInputData(MainModual); for (std::map<int, CSignalNode>::iterator it = g_signal_node_map.begin(); it != g_signal_node_map.end(); ++it) { //cout << "Signal Node ID " << it->first << ":" << endl; g_info_String = "Start Signal Node ID "; g_info_String.append(to_string(it->first)); g_info_String.append(":"); MainModual.WriteLog(0, g_info_String, -1); it->second.PerformQEM(it->first); g_info_String = "End Signal Node ID "; g_info_String.append(to_string(it->first)); MainModual.WriteLog(0, g_info_String, -2); } //output service_arc.csv FILE* g_pFileServiceArc = NULL; fopen_ss(&g_pFileServiceArc, "service_arc.csv", "w"); if (g_pFileServiceArc == NULL) { cout << "File service_arc.csv cannot be opened." << endl; g_ProgramStop(); } else { fprintf(g_pFileServiceArc, "road_link_id,from_node_id,to_node_id,time_window,time_interval,travel_time_delta,capacity,cycle_no,cycle_length,green_time,red_time,main_node_id,stage,movement_str,\n"); for (std::map<int, CSignalNode>::iterator it = g_signal_node_map.begin(); it != g_signal_node_map.end(); ++it) { CSignalNode sn = it->second; int cycle_time_in_sec = max(10, sn.c_Min); int number_of_cycles = (MainModual.g_LoadingEndTimeInMin - MainModual.g_LoadingStartTimeInMin) * 60 / cycle_time_in_sec; // unit: seconds; int offset_in_sec = 0; int g_loading_start_time_in_sec = MainModual.g_LoadingStartTimeInMin * 60 + offset_in_sec; int ci = 0; //for (int ci = 0; ci <= number_of_cycles; ci++) { for (int m = 1; m < movementSize; m++) { if (sn.movement_Array[m].Enable) { for (size_t so = 0; so < sn.movement_Array[m].StageNo_in_Order.size(); so++) { int StageNo = sn.movement_Array[m].StageNo_in_Order[so]; // we should also consider offset. int global_start_time_in_sec = sn.cumulative_Green_Start_Time_Stage_Array[StageNo] + cycle_time_in_sec * ci + g_loading_start_time_in_sec; int global_end_time_in_sec = sn.cumulative_Green_End_Time_Stage_Array[StageNo] + cycle_time_in_sec * ci + g_loading_start_time_in_sec; //0300:30 int start_hour = global_start_time_in_sec / 3600; int start_min = global_start_time_in_sec / 60 - start_hour * 60; int start_sec = global_start_time_in_sec % 60; int end_hour = global_end_time_in_sec / 3600; int end_min = global_end_time_in_sec / 60 - end_hour * 60; int end_sec = global_end_time_in_sec % 60; int from_node_id = g_node_vector[g_link_vector[sn.movement_Array[m].LinkSeqNo].from_node_seq_no].node_id; int to_node_id = g_node_vector[g_link_vector[sn.movement_Array[m].LinkSeqNo].to_node_seq_no].node_id; // float capacity = sn.green_Time_Stage_Array[StageNo] * sn.saturation_Flow_Rate_Matrix[StageNo][m] / 3600.0; float capacity = sn.green_Time_Stage_Array[StageNo] * 1800.0 / 3600.0; //float capacity = sn.capacity_by_Stage_and_Movement_Matrix[StageNo][m]/60; float greenTime = sn.green_Time_Stage_Array[StageNo]; float redTime = cycle_time_in_sec - sn.green_Time_Stage_Array[StageNo]; fprintf(g_pFileServiceArc, "%s,%d,%d,%02d%02d:%02d_%02d%02d:%02d,-1,-1,%f,%d,%d,%f,%f,%d,%d,%s\n", g_link_vector[sn.movement_Array[m].LinkSeqNo].link_id.c_str(), from_node_id, to_node_id, start_hour, start_min, start_sec, end_hour, end_min, end_sec, capacity, ci, cycle_time_in_sec, greenTime, redTime, it->first, StageNo, sn.movement_str_array[m].c_str() ); } } // per movement } } // per cycle } // per signal node fclose(g_pFileServiceArc); } MainModual.WriteLog(0, "-----------------------Finished----------------------- ", 1); getchar(); return 1; }
b5b7da325fe409f8262d0316e2e5f6719abcad24
08a6e58321d7b7b7eaec5b6bc54019e26f639b0b
/src/include/fadeanimation.h
5989dc3ae68652cd16645c755d0f017ed4dab56f
[]
no_license
jeffersonfr/jclick
bd4decd96897e8f32daba4317d139dd69707250d
753f901f54d0e1026c1e3078d1450efc4ab709e9
refs/heads/master
2020-04-17T11:43:30.126392
2020-02-18T18:19:06
2020-02-18T18:19:06
166,552,803
1
0
null
null
null
null
UTF-8
C++
false
false
501
h
fadeanimation.h
#ifndef __FADEANIMATION_PHOTOBOOTH_H #define __FADEANIMATION_PHOTOBOOTH_H #include "animation.h" #include "jgui/jimage.h" #include "jgui/jcolor.h" #include <vector> class FadeAnimation : public Animation { private: std::vector<jgui::Image *> _frames; jgui::jcolor_t<float> _color; int _state; int _index; int _progress; public: FadeAnimation(std::vector<std::string> images); virtual ~FadeAnimation(); virtual bool Paint(jgui::Component *cmp, jgui::Graphics *g); }; #endif
3f50059740c6a85fa56e30c8fc77622a8f6d398b
a94a34cd7af1f45267e6eb0dfda627f1a9c7070c
/Practices/Training/Competition/MonthlyCompetition/20190531yz/source/JF02015_张扬/square.cpp
cfd00736cff3594df134573c30fa882691bd4180
[]
no_license
AI1379/OILearning
91f266b942d644e8567cda20c94126ee63e6dd4b
98a3bd303bc2be97e8ca86d955d85eb7c1920035
refs/heads/master
2021-10-16T16:37:39.161312
2021-10-09T11:50:32
2021-10-09T11:50:32
187,294,534
0
0
null
null
null
null
UTF-8
C++
false
false
528
cpp
square.cpp
#include <bits/stdc++.h> using namespace std; int main(){ freopen("square.in","r",stdin); freopen("square.out","w",stdout); double ans1=0,ans2=0,ans3=0; int a,b,c; int n; double k; double ba[2000]; scanf("%d%lf",&n,&k); ba[0]=n; for(int i=1;i<k;i++){ ba[i]=sqrt(ba[i-1]*ba[i-1])/sqrt(2); } for(int i=0;i<k;i++){ ans1+=ba[i]; ans2+=ba[i]; ans3+=ba[i]; if(i%3==0){ ans3+=ba[i]; }else if(i%3==1){ ans2+=ba[i]; }else{ ans1+=ba[i]; } } printf("%.3lf %.3lf %.3lf",ans3,ans2,ans1); return 0; }
3b26f5e4c54aee22a3f8615437dde68b6dadf46c
c7c0ece47912c77f919241537b2a7b3a9347b862
/Lab 9/GetOutput.cpp
b3977c1b1b7221ebe35aa0654ff4aa38d2fc079e
[]
no_license
KermiteO/CS1D
b06d27002b910307d797a6618e3cd17ab42b2be0
0335fcef3d2b3c9872125a890f059c2aea121475
refs/heads/master
2021-01-01T10:56:48.704473
2020-02-09T05:54:46
2020-02-09T05:54:46
239,248,153
0
0
null
null
null
null
UTF-8
C++
false
false
594
cpp
GetOutput.cpp
/********************************************************************** * AUTHOR : Kermite & Maclem * Lab #9 : Testing * CLASS : CS1B * SECTION : TTH 8:00a - 11:50a * DUE DATE : 2/19/15 *********************************************************************/ #include "HeaderFile.h" void GetOutput(int rem, int total) { if(total > MAX_CHOC) { cout << "\nINVALID - Each sheep can't have more than 4 chocolate bars.\n"; } else { cout << "\nEach sheep will get " << total << " chocolate bars and " << "there will be " << rem << " left over.\n"; } }
672cc827674782505148378ebf384c607753b4a7
9c6ee300a4890e463612a992e996433d7226e5b0
/src/core/Scene.h
e9d3f7bea3789565857e79cba588f3ae9399169a
[]
no_license
Zoophish/Lambda
aa353078640a12f507b91499fb20f425405942c9
3b9c7900df24c5314076e90183b7badd551c3150
refs/heads/master
2021-08-03T15:36:10.681899
2021-07-20T13:29:49
2021-07-20T13:29:49
190,223,245
28
0
null
null
null
null
UTF-8
C++
false
false
3,169
h
Scene.h
/*---- By Sam Warren 2019 ---- ---- Embree scene implmentation as an interface for scene construction and ray queries. ---- Scene flags improve results for certain tyes of scenes. If the scene flag is changed, the scene must be re-comitted to apply the changes. Uses one device per scene, hence the RTCDevice is kept here too. Scene constructor can take a config string which determines how Embree runs on the hardware. By default, this is NULL which leaves the device on default configuration. Specific device configurations can be found in the Embree manual. */ #pragma once #include <vector> #include "Object.h" #include <lighting/Light.h> #include <sampling/Piecewise.h> #include <shading/media/Media.h> #include <lighting/LightSampler.h> LAMBDA_BEGIN class EnvironmentLight; class Scene { protected: RTCScene scene; public: RTCDevice device; std::vector<Object*> objects; //Root(s) of object tree. std::vector<Light*> lights; EnvironmentLight* envLight; LightSampler *lightSampler; bool hasVolumes; Scene(const RTCSceneFlags _sceneFlags = RTC_SCENE_FLAG_NONE, const char *_deviceConfig = NULL); /* Sets Embree scene flags. */ void SetFlags(const RTCSceneFlags _flags = RTC_SCENE_FLAG_NONE); /* Builds scene's accelleration structure and lighting distribution. */ void Commit(const RTCBuildQuality _buildQuality = RTC_BUILD_QUALITY_HIGH); /* Queries _ray against scene geometry. - Returns true if intersection found. - Hit information passed to _hit. */ bool Intersect(const Ray &_ray, RayHit &_hit) const; /* Queries _ray against scene geometry, ignoring pure volumes and returning beam transmittance to _Tr. */ bool IntersectTr(Ray _r, RayHit &_hit, Sampler &_sampler, Medium *_med, Spectrum *_Tr) const; /* Version of IntersectTr that will not trace past _maxT (esssential for correct transmittance towards point lights etc). */ bool IntersectTr(Ray _r, RayHit &_hit, Sampler &_sampler, Medium *_med, Spectrum *_Tr, const Real _maxT) const; /* Returns true if points _p1 and _p2 are mutually visible against scene geometry. */ bool MutualVisibility(const Vec3 &_p1, const Vec3 &_p2, Vec3 *_w) const; bool MutualVisibility(const Vec3 &_p1, const Vec3 &_p2) const; /* Returns true if _ray intersects no geometry within the scene. */ bool RayEscapes(const Ray &_ray) const; /* Explicitly adds _light to the lighting distribution without adding intersectable geometry. */ void AddLight(Light *_light); /* Commits changes to _obj's geometry and adds to scene geometry. - _addLight will automatically add _obj's light (if any) to the lighting distribution. */ void AddObject(Object *_obj, const bool _addLight = true); /* Removes object by index. */ void RemoveObject(const unsigned _i); /* Removes object by value. */ void RemoveObject(Object *_obj); /* Returns bounding box of scene's geometry. */ inline Bounds GetBounds() const { RTCBounds b; rtcGetSceneBounds(scene, &b); return Bounds(Vec3(b.lower_x, b.lower_y, b.lower_z), Vec3(b.upper_x, b.upper_y, b.upper_z)); } }; LAMBDA_END
74c516f6dbcf7b4a3c5449eae165dad6ed91c8d9
93ab36c3a4545e817032f8bde2f85edd2b5552d4
/source/main.cpp
2df24020b70ecfd829bf49543053bf00199e3582
[]
no_license
uschmann/rex-runner
5571c349960b82737e7c2c5e3685e77b734b0233
49b5b1e7cd20a43b4e53809ef0ba06e297df6255
refs/heads/master
2020-03-30T06:33:28.957971
2018-09-30T08:57:57
2018-09-30T08:57:57
150,870,213
0
0
null
null
null
null
UTF-8
C++
false
false
3,067
cpp
main.cpp
#include <iostream> #include <SDL2/SDL.h> #include <SDL2/SDL_events.h> #include <SDL2/SDL_image.h> #include <SDL2/SDL_ttf.h> #include <curl/curl.h> #include <string> #include <switch.h> #include "Game.h" #define DEBUG SDL_Window* window = NULL; SDL_Renderer* renderer = NULL; SDL_Surface* screen = NULL; SDL_Texture* sprites = NULL; TTF_Font* font = NULL; int screenWidth = 0; int screenHeight = 0; /** * Init */ bool init() { SDL_Init(SDL_INIT_EVERYTHING); SDL_InitSubSystem(SDL_INIT_JOYSTICK); SDL_JoystickEventState(SDL_ENABLE); SDL_JoystickOpen(0); TTF_Init(); romfsInit(); #ifdef DEBUG socketInitializeDefault(); nxlinkStdio(); printf("printf output now goes to nxlink server\n"); #endif // DEBUG window = SDL_CreateWindow(nullptr, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 0, 0, SDL_WINDOW_FULLSCREEN_DESKTOP); if (!window) { printf("SDL_CreateWindow() failed!\n"); SDL_Quit(); return false; } renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE); if (!renderer) { printf("SDL_CreateRenderer() failed!\n"); SDL_Quit(); return false; } screen = SDL_GetWindowSurface(window); if (!screen) { printf("SDL_GetWindowSurface() failed!\n"); SDL_Quit(); return false; } sprites = IMG_LoadTexture(renderer ,"romfs:/sprites.png"); if (!sprites) { printf("IMG_LoadTexture() failed!\n"); SDL_Quit(); return false; } font = TTF_OpenFont("romfs:/font.ttf", 32); if(!font) { printf("TTF_OpenFont() failed!\n"); SDL_Quit(); return false; } SDL_GetWindowSize(window, &screenWidth, &screenHeight); printf("ScreenWidth: %d, ScreenHeight: %d\n", screenWidth, screenHeight); return true; } /** * Main entrypoint */ int main(int argc, char* argv[]) { if(!init()) { #ifdef DEBUG socketExit(); #endif // DEBUG return 0; } bool isRunning = true; int lastTick = SDL_GetTicks(); Game* game = new Game(renderer, sprites, font); SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF); SDL_RenderClear(renderer); SDL_RenderPresent(renderer); while (isRunning) { int currentTick = SDL_GetTicks(); int deltaTime = currentTick - lastTick; lastTick = currentTick; SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_JOYBUTTONDOWN: switch(event.jbutton.button) { case SDL_CONTROLLER_BUTTON_A: game->pressButton(); break; case SDL_CONTROLLER_BUTTON_X: isRunning = false; break; } break; case SDL_FINGERDOWN: game->pressButton(); break; } } game->update(deltaTime); SDL_RenderClear(renderer); game->draw(); SDL_RenderPresent(renderer); } SDL_FreeSurface(screen); SDL_DestroyRenderer(renderer); SDL_DestroyWindow(window); #ifdef DEBUG socketExit(); #endif // DEBUG SDL_Quit(); return 0; }
f8e07731310e6851f7be873cf765dfbe2ab88fc4
1352eac84ee81b864c302e64c238635221b4d307
/Design and analysis of algorithms/Graphs/Knights/Knights.cpp
ed571ad870df8e0a72bb5e8201667f91cbea53e7
[]
no_license
erikz99/Data-Structures-And-Algorithms
5f329136e5f8a0bde59b47f710701410a90dfc48
350e95e38b295131057d6af1a39b3642c231e8b7
refs/heads/main
2023-03-11T15:57:09.845087
2021-02-21T21:15:59
2021-02-21T21:15:59
336,898,809
0
0
null
null
null
null
UTF-8
C++
false
false
3,470
cpp
Knights.cpp
#include <iostream> #include <climits> #include <vector> #include <queue> #include <utility> using namespace std; struct knight { int x, y; }; struct cell { int first, second; }; knight arr[2020]; int mat[2020][2020]; int moves = 0; int cnt = 0; int n, m, k; int pX, pY; void bfs(int x, int y) { vector < vector <int> > used(n, vector <int>(n, false)); vector < vector <int> > dist(n, vector <int>(n, INT_MAX)); queue < cell > q; dist[x][y] = 0; q.push({ x,y }); while (!q.empty()) { cell p = q.front(); int x = p.first; int y = p.second; q.pop(); if ((!((x - 1 < 0 || x - 1 > n - 1) || (y - 2 < 0 || y - 2 > n - 1))) && (mat[x - 1][y - 2] != 1) && (!used[x - 1][y - 2])) { used[x - 1][y - 2] = true; dist[x - 1][y - 2] = dist[x][y] + 1; q.push({ x - 1 , y - 2 }); } if ((!((x - 2 < 0 || x - 2 > n - 1) || (y - 1 < 0 || y - 1 > n - 1))) && (mat[x - 2][y - 1] != 1) && (!used[x - 2][y - 1])) { used[x - 2][y - 1] = true; dist[x - 2][y - 1] = dist[x][y] + 1; q.push({ x - 2 , y - 1 }); } if ((!((x + 2 < 0 || x + 2 > n - 1) || (y - 1 < 0 || y - 1 > n - 1))) && (mat[x + 2][y - 1] != 1) && (!used[x + 2][y - 1])) { used[x + 2][y - 1] = true; dist[x + 2][y - 1] = dist[x][y] + 1; q.push({ x + 2 , y - 1 }); } if ((!((x + 1 < 0 || x + 1 > n - 1) || (y + 2 < 0 || y + 2 > n - 1))) && (mat[x + 1][y + 2] != 1) && (!used[x + 1][y + 2])) { used[x + 1][y + 2] = true; dist[x + 1][y + 2] = dist[x][y] + 1; q.push({ x + 1 , y + 2 }); } if ((!((x - 2 < 0 || x - 2 > n - 1) || (y + 1 < 0 || y + 1 > n - 1))) && (mat[x - 2][y + 1] != 1) && (!used[x - 2][y + 1])) { used[x - 2][y + 1] = true; dist[x - 2][y + 1] = dist[x][y] + 1; q.push({ x - 2 , y + 1 }); } if ((!((x - 1 < 0 || x - 1 > n - 1) || (y + 2 < 0 || y + 2 > n - 1))) && (mat[x - 1][y + 2] != 1) && (!used[x - 1][y + 2])) { used[x - 1][y + 2] = true; dist[x - 1][y + 2] = dist[x][y] + 1; q.push({ x - 1 , y + 2 }); } if ((!((x + 2 < 0 || x + 2 > n - 1) || (y + 1 < 0 || y + 1 > n - 1))) && (mat[x + 2][y + 1] != 1) && (!used[x + 2][y + 1])) { used[x + 2][y + 1] = true; dist[x + 2][y + 1] = dist[x][y] + 1; q.push({ x + 2 , y + 1 }); } if ((!((x + 1 < 0 || x + 1 > n - 1) || (y - 2 < 0 || y - 2 > n - 1))) && (mat[x + 1][y - 2] != 1) && (!used[x + 1][y - 2])) { used[x + 1][y - 2] = true; dist[x + 1][y - 2] = dist[x][y] + 1; q.push({ x + 1 , y - 2 }); } } for (int i = 0; i < k; i++) { int m = arr[i].x, l = arr[i].y; int distance = dist[m][l]; if (distance != INT_MAX) { cnt++; moves = distance > moves ? distance : moves; } } } void solve() { bfs(pX,pY); cout << cnt << " " << moves; } void input() { cin >> n >> m >> k; int x, y; for (int i = 0; i < m; i++) { cin >> x >> y; mat[x][y] = 1; } for (int i = 0; i < k; i++) { cin >> x >> y; arr[i] = { x,y }; } cin >> pX >> pY; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); input(); solve(); }
ca750f7a35c7d0c00183932db61a6dfc92bf9479
d5bfee386aef992bede5567d69895ac8fe90a0c6
/examples/mechanics/basics/pendulum_with_joints/system.cc
a549338015ea2ff58575fab6d3746d03370716d4
[]
no_license
yumianhuli2/mbsim
6905034b2698f3d6f8b4ff73e07658ce4fbd4a18
1093c03590f900d19278613e5f3cf195472d9127
refs/heads/master
2023-08-02T13:11:38.246585
2021-10-04T07:29:07
2021-10-04T07:29:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,469
cc
system.cc
#include "system.h" #include "mbsim/frames/fixed_relative_frame.h" #include "mbsim/objects/rigid_body.h" #include "mbsim/links/joint.h" #include "mbsim/constitutive_laws/constitutive_laws.h" #include "mbsim/environment.h" #include "mbsim/functions/kinematics/kinematics.h" #include "mbsim/functions/kinetics/kinetics.h" #include "mbsim/observers/mechanical_link_observer.h" #include <openmbvcppinterface/frustum.h> using namespace MBSim; using namespace fmatvec; using namespace std; System::System(const string &projectName) : DynamicSystemSolver(projectName) { Vec grav(3); grav(1)=-9.81; getMBSimEnvironment()->setAccelerationOfGravity(grav); double m1 = 0.5; double m2 = 0.5; double l1 = 1; double l2 = 1; double a1 = 0.2; double b1 = 0.45; double a2 = 0.2; double phi1 = -M_PI/2; double phi2 = -M_PI/4; RigidBody *body1 = new RigidBody("Stab1"); addObject(body1); body1->setMass(m1); SymMat Theta(3); Theta(2,2) = 1./12.*m1*l1*l1; body1->setInertiaTensor(Theta); SqrMat E = SqrMat(DiagMat(3,INIT,1)); Vec KrSP(3); KrSP(1) = a1; body1->addFrame(new FixedRelativeFrame("PunktO",KrSP,E)); body1->setTranslation(new TranslationAlongAxesXY<VecV>); body1->setRotation(new RotationAboutZAxis<VecV>); body1->setFrameOfReference(getFrame("I")); body1->setFrameForKinematics(body1->getFrame("C")); Vec q0(3); q0(0) = a1; q0(2) = -phi1; body1->setGeneralizedInitialPosition(q0); KrSP(1) = -b1; body1->addFrame(new FixedRelativeFrame("PunktU",KrSP,E)); RigidBody *body2 = new RigidBody("Stab2"); addObject(body2); body2->setMass(m2); Theta(2,2) = 1./12.*m2*l2*l2; body2->setInertiaTensor(Theta); KrSP(1) = a2; body2->addFrame(new FixedRelativeFrame("Punkt",KrSP,E)); body2->setTranslation(new TranslationAlongAxesXY<VecV>); body2->setRotation(new RotationAboutZAxis<VecV>); SqrMat A1(3); A1(0,0) = cos(phi1); A1(0,1) = sin(phi1); A1(1,0) = -sin(phi1); A1(1,1) = cos(phi1); A1(2,2) = 1; SqrMat A2(3); A2(0,0) = cos(phi2); A2(0,1) = sin(phi2); A2(1,0) = -sin(phi2); A2(1,1) = cos(phi2); A2(2,2) = 1; Vec rOP(3); rOP(1) = -a1-b1; q0 = A1*rOP + A2*(-KrSP); q0(2) = -phi2; body2->setGeneralizedInitialPosition(q0); addFrame(new FixedRelativeFrame("Os","[0;0;0.04]",E)); body2->setFrameOfReference(getFrame("Os")); body2->setFrameForKinematics(body2->getFrame("C")); Joint *joint1 = new Joint("Gelenk1"); addLink(joint1); joint1->setForceDirection(Mat("[1,0; 0,1; 0,0]")); joint1->connect(getFrame("I"),body1->getFrame("PunktO")); Joint *joint2 = new Joint("Gelenk2"); addLink(joint2); joint2->setForceDirection(Mat("[1,0; 0,1; 0,0]")); joint2->connect(body1->getFrame("PunktU"),body2->getFrame("Punkt")); joint1->setForceLaw(new BilateralConstraint); joint2->setForceLaw(new BilateralConstraint); std::shared_ptr<OpenMBV::Frustum> cylinder=OpenMBV::ObjectFactory::create<OpenMBV::Frustum>(); cylinder->setTopRadius(0.02); cylinder->setBaseRadius(0.02); cylinder->setHeight(l1); cylinder->setInitialTranslation(0,-0.5,0); cylinder->setInitialRotation(1.5708,0,0); body1->setOpenMBVRigidBody(cylinder); cylinder=OpenMBV::ObjectFactory::create<OpenMBV::Frustum>(); cylinder->setTopRadius(0.02); cylinder->setBaseRadius(0.02); cylinder->setHeight(l2); cylinder->setInitialTranslation(0,-0.5,0); cylinder->setInitialRotation(1.5708,0,0); body2->setOpenMBVRigidBody(cylinder); MechanicalLinkObserver *observer = new MechanicalLinkObserver("Observer1"); addObserver(observer); observer->setMechanicalLink(joint1); observer->enableOpenMBVForce(_colorRepresentation=OpenMBVArrow::absoluteValue,_scaleLength=0.02); observer = new MechanicalLinkObserver("Observer2"); addObserver(observer); observer->setMechanicalLink(joint2); observer->enableOpenMBVForce(_colorRepresentation=OpenMBVArrow::absoluteValue,_scaleLength=0.02); body1->setPlotFeature(generalizedPosition, true); body1->setPlotFeature(generalizedVelocity, true); body2->setPlotFeature(generalizedPosition, true); body2->setPlotFeature(generalizedVelocity, true); joint1->setPlotFeature(generalizedRelativePosition, true); joint1->setPlotFeature(generalizedRelativeVelocity, true); joint1->setPlotFeature(generalizedForce, true); joint2->setPlotFeature(generalizedRelativePosition, true); joint2->setPlotFeature(generalizedRelativeVelocity, true); joint2->setPlotFeature(generalizedForce, true); }
6bcf95dbe05db490fa0f56ae96634c6a5e8baebc
c0376f9eb4eb1adf2db5aff3d25abc3576d0241b
/src/util/gui/clearlineeditaddon.h
8f4dac559e2385fe4b1c23f791f760c46807852b
[ "BSL-1.0" ]
permissive
ROOAARR/leechcraft
0179e6f1e7c0b7afbfcce60cb810d61bd558b163
14bc859ca750598b77abdc8b2d5b9647c281d9b3
refs/heads/master
2021-01-17T22:08:16.273024
2013-08-05T12:28:45
2013-08-05T12:28:45
2,217,574
1
0
null
2013-01-19T15:32:47
2011-08-16T18:55:44
C++
UTF-8
C++
false
false
3,069
h
clearlineeditaddon.h
/********************************************************************** * LeechCraft - modular cross-platform feature rich internet client. * Copyright (C) 2006-2013 Georg Rudoy * * Boost Software License - Version 1.0 - August 17th, 2003 * * Permission is hereby granted, free of charge, to any person or organization * obtaining a copy of the software and accompanying documentation covered by * this license (the "Software") to use, reproduce, display, distribute, * execute, and transmit the Software, and to prepare derivative works of the * Software, and to permit third-parties to whom the Software is furnished to * do so, all subject to the following: * * The copyright notices in the Software and this entire statement, including * the above license grant, this restriction and the following disclaimer, * must be included in all copies of the Software, in whole or in part, and * all derivative works of the Software, unless such copies or derivative * works are solely in the form of machine-executable object code generated by * a source language processor. * * 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. **********************************************************************/ #pragma once #include <QObject> #include <interfaces/core/icoreproxy.h> #include <util/utilconfig.h> class QLineEdit; class QToolButton; namespace LeechCraft { namespace Util { /** @brief Provides a "clear text" action for line edits. * * Using this class is as simple as this: * \code * QLineEdit *edit = ...; // or some QLineEdit-derived class * new ClearLineEditAddon (proxy, edit); // proxy is the one passed to IInfo::Init() * \endcode * * The constructor takes a pointer to the proxy object that is passed * to IInfo::Init() method of the plugin instance object and the * pointer to the line edit where the addon should be installed. * * The line edit takes the ownership of the addon, so there is no * need to keep track of it or explicitly delete it. * * @sa IInfo::Init() */ class UTIL_API ClearLineEditAddon : public QObject { Q_OBJECT QToolButton *Button_; QLineEdit *Edit_; public: /** @brief Creates the addon and installs it on the given edit. * * @param[in] proxy The proxy passed to IInfo::Init() of the * plugin. * @param[in] edit The line edit to install this addon into. The * edit takes ownership of the addon. */ ClearLineEditAddon (ICoreProxy_ptr proxy, QLineEdit *edit); protected: bool eventFilter (QObject*, QEvent*); private: void UpdatePos (); private slots: void updateButton (const QString&); }; } }
4abdeb1f2759497ae1fcb43073f9a0a861efd3d0
e18f226be7ec8945273c903a31427eaebda112ce
/src/pr2_arm_move_ik/include/pr2_arm_move_ik/trajectory_unwrap.h
2f23edb285c642da11b9a177835abbfc15487f70
[]
no_license
gnoliyil/pr2_kinetic_packages
3cad819236de2a8c92b756eb8f49f76d4e4f1648
e43479ea6088062b63271c6b94417c266429d439
refs/heads/master
2020-06-25T01:06:37.872211
2017-08-25T21:19:33
2017-08-25T21:19:33
96,950,087
10
0
null
null
null
null
UTF-8
C++
false
false
4,144
h
trajectory_unwrap.h
/********************************************************************* * Software License Agreement (BSD License) * * Copyright (c) 2008, Willow Garage, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 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. * * Neither the name of Willow Garage nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "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 * COPYRIGHT OWNER OR CONTRIBUTORS 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. * * Author: Melonee Wise *********************************************************************/ #ifndef TRAJECTORY_UNWRAP_H_ #define TRAJECTORY_UNWRAP_H_ #include <angles/angles.h> #include <urdf/model.h> #include <urdf/joint.h> #include <trajectory_msgs/JointTrajectory.h> namespace trajectory_unwrap { void unwrap(urdf::Model &robot_model, const trajectory_msgs::JointTrajectory& traj_in, trajectory_msgs::JointTrajectory& traj_out) { //defualt result traj_out = traj_in; int num_jnts = traj_in.joint_names.size(); int traj_pnts = traj_in.points.size(); boost::shared_ptr<const urdf::Joint> joint; for(int i=0; i<num_jnts; i++) { joint = robot_model.getJoint(traj_in.joint_names[i]); if(joint->type == urdf::Joint::REVOLUTE) { for(int j=1; j<traj_pnts; j++) { double diff; angles::shortest_angular_distance_with_limits(traj_out.points[j-1].positions[i], traj_out.points[j].positions[i], joint->limits->lower, joint->limits->upper, diff); traj_out.points[j].positions[i] = traj_out.points[j-1].positions[i] + diff; } } if(joint->type == urdf::Joint::CONTINUOUS) { for(int j=1; j<traj_pnts; j++) { traj_out.points[j].positions[i] = traj_out.points[j-1].positions[i] + angles::shortest_angular_distance(traj_out.points[j-1].positions[i],traj_out.points[j].positions[i]); } } } } } #endif
dfb133c276a2e03630c929ecd1d4aeb555ad9a1e
95a0bb23a05a96b9ef01f88dcc35c2bdaa7f2f14
/1.9.1.12285/SDK/WBP_SelectableButtonWithText_functions.cpp
a3ac34c5e9c87d2c0c2d313103f94ec476427325
[]
no_license
MuhanjalaRE/Midair-Community-Edition-SDKs
38ccb53898cf22669d99724e7246eb543ae2d25d
8f459da568912b3d737d6494db003537af45bf85
refs/heads/main
2023-04-06T03:49:42.732247
2021-04-14T11:35:28
2021-04-14T11:35:28
334,685,504
1
0
null
null
null
null
UTF-8
C++
false
false
13,160
cpp
WBP_SelectableButtonWithText_functions.cpp
// Name: mace, Version: 1.9.1.12285 #include "../pch.h" /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace SDK { //--------------------------------------------------------------------------- // Functions //--------------------------------------------------------------------------- // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.UpdateSlotAnchor // (Public, BlueprintCallable, BlueprintEvent) // Parameters: // class UWidget* Item (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash) // struct FVector2D InPosition (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) // struct FVector2D InSize (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) void UWBP_SelectableButtonWithText_C::UpdateSlotAnchor(class UWidget* Item, const struct FVector2D& InPosition, const struct FVector2D& InSize) { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.UpdateSlotAnchor"); } UWBP_SelectableButtonWithText_C_UpdateSlotAnchor_Params params; params.Item = Item; params.InPosition = InPosition; params.InSize = InSize; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.Get_NewItemBadge_Visibility_1 // (Public, HasOutParms, BlueprintCallable, BlueprintEvent, BlueprintPure) // Parameters: // UMG_ESlateVisibility ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData, NoDestructor, HasGetValueTypeHash) UMG_ESlateVisibility UWBP_SelectableButtonWithText_C::Get_NewItemBadge_Visibility_1() { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.Get_NewItemBadge_Visibility_1"); } UWBP_SelectableButtonWithText_C_Get_NewItemBadge_Visibility_1_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.GetVisibility_1 // (Public, HasOutParms, BlueprintCallable, BlueprintEvent, BlueprintPure) // Parameters: // UMG_ESlateVisibility ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData, NoDestructor, HasGetValueTypeHash) UMG_ESlateVisibility UWBP_SelectableButtonWithText_C::GetVisibility_1() { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.GetVisibility_1"); } UWBP_SelectableButtonWithText_C_GetVisibility_1_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.Get_DefaultTextBlock_Text_1 // (Public, HasOutParms, BlueprintCallable, BlueprintEvent, BlueprintPure) // Parameters: // struct FText ReturnValue (Parm, OutParm, ReturnParm) struct FText UWBP_SelectableButtonWithText_C::Get_DefaultTextBlock_Text_1() { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.Get_DefaultTextBlock_Text_1"); } UWBP_SelectableButtonWithText_C_Get_DefaultTextBlock_Text_1_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.Get_DefaultTextBlock_ColorAndOpacity_1 // (Public, HasOutParms, HasDefaults, BlueprintCallable, BlueprintEvent, BlueprintPure) // Parameters: // struct FSlateColor ReturnValue (Parm, OutParm, ReturnParm) struct FSlateColor UWBP_SelectableButtonWithText_C::Get_DefaultTextBlock_ColorAndOpacity_1() { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.Get_DefaultTextBlock_ColorAndOpacity_1"); } UWBP_SelectableButtonWithText_C_Get_DefaultTextBlock_ColorAndOpacity_1_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.Get_DefaultBorder_BrushColor_0_1 // (Public, HasOutParms, BlueprintCallable, BlueprintEvent, BlueprintPure) // Parameters: // struct FLinearColor ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData, NoDestructor, HasGetValueTypeHash) struct FLinearColor UWBP_SelectableButtonWithText_C::Get_DefaultBorder_BrushColor_0_1() { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.Get_DefaultBorder_BrushColor_0_1"); } UWBP_SelectableButtonWithText_C_Get_DefaultBorder_BrushColor_0_1_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.OnSelected // (BlueprintCallable, BlueprintEvent) void UWBP_SelectableButtonWithText_C::OnSelected() { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.OnSelected"); } UWBP_SelectableButtonWithText_C_OnSelected_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.OnActive // (BlueprintCallable, BlueprintEvent) void UWBP_SelectableButtonWithText_C::OnActive() { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.OnActive"); } UWBP_SelectableButtonWithText_C_OnActive_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.OnPressed // (BlueprintCallable, BlueprintEvent) void UWBP_SelectableButtonWithText_C::OnPressed() { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.OnPressed"); } UWBP_SelectableButtonWithText_C_OnPressed_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.OnUpdateDisabled // (BlueprintCallable, BlueprintEvent) void UWBP_SelectableButtonWithText_C::OnUpdateDisabled() { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.OnUpdateDisabled"); } UWBP_SelectableButtonWithText_C_OnUpdateDisabled_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.BndEvt__DefaultButton_K2Node_ComponentBoundEvent_45_OnButtonClickedEvent__DelegateSignature // (BlueprintEvent) void UWBP_SelectableButtonWithText_C::BndEvt__DefaultButton_K2Node_ComponentBoundEvent_45_OnButtonClickedEvent__DelegateSignature() { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.BndEvt__DefaultButton_K2Node_ComponentBoundEvent_45_OnButtonClickedEvent__DelegateSignature"); } UWBP_SelectableButtonWithText_C_BndEvt__DefaultButton_K2Node_ComponentBoundEvent_45_OnButtonClickedEvent__DelegateSignature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.BndEvt__DefaultButton_K2Node_ComponentBoundEvent_58_OnButtonPressedEvent__DelegateSignature // (BlueprintEvent) void UWBP_SelectableButtonWithText_C::BndEvt__DefaultButton_K2Node_ComponentBoundEvent_58_OnButtonPressedEvent__DelegateSignature() { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.BndEvt__DefaultButton_K2Node_ComponentBoundEvent_58_OnButtonPressedEvent__DelegateSignature"); } UWBP_SelectableButtonWithText_C_BndEvt__DefaultButton_K2Node_ComponentBoundEvent_58_OnButtonPressedEvent__DelegateSignature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.BndEvt__DefaultButton_K2Node_ComponentBoundEvent_69_OnButtonReleasedEvent__DelegateSignature // (BlueprintEvent) void UWBP_SelectableButtonWithText_C::BndEvt__DefaultButton_K2Node_ComponentBoundEvent_69_OnButtonReleasedEvent__DelegateSignature() { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.BndEvt__DefaultButton_K2Node_ComponentBoundEvent_69_OnButtonReleasedEvent__DelegateSignature"); } UWBP_SelectableButtonWithText_C_BndEvt__DefaultButton_K2Node_ComponentBoundEvent_69_OnButtonReleasedEvent__DelegateSignature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.PreConstruct // (BlueprintCosmetic, Event, Public, BlueprintEvent) // Parameters: // bool IsDesignTime (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor) void UWBP_SelectableButtonWithText_C::PreConstruct(bool IsDesignTime) { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.PreConstruct"); } UWBP_SelectableButtonWithText_C_PreConstruct_Params params; params.IsDesignTime = IsDesignTime; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.Construct // (BlueprintCosmetic, Event, Public, BlueprintEvent) void UWBP_SelectableButtonWithText_C::Construct() { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.Construct"); } UWBP_SelectableButtonWithText_C_Construct_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.BndEvt__DefaultButton_K2Node_ComponentBoundEvent_2_OnButtonHoverEvent__DelegateSignature // (BlueprintEvent) void UWBP_SelectableButtonWithText_C::BndEvt__DefaultButton_K2Node_ComponentBoundEvent_2_OnButtonHoverEvent__DelegateSignature() { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.BndEvt__DefaultButton_K2Node_ComponentBoundEvent_2_OnButtonHoverEvent__DelegateSignature"); } UWBP_SelectableButtonWithText_C_BndEvt__DefaultButton_K2Node_ComponentBoundEvent_2_OnButtonHoverEvent__DelegateSignature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.ExecuteUbergraph_WBP_SelectableButtonWithText // (Final, HasDefaults) // Parameters: // int EntryPoint (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) void UWBP_SelectableButtonWithText_C::ExecuteUbergraph_WBP_SelectableButtonWithText(int EntryPoint) { static UFunction* fn = nullptr; if(!fn){ fn = UObject::FindObject<UFunction>("Function WBP_SelectableButtonWithText.WBP_SelectableButtonWithText_C.ExecuteUbergraph_WBP_SelectableButtonWithText"); } UWBP_SelectableButtonWithText_C_ExecuteUbergraph_WBP_SelectableButtonWithText_Params params; params.EntryPoint = EntryPoint; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } } #ifdef _MSC_VER #pragma pack(pop) #endif
6a6e5f469e66c768167a6b7d6438ffec9215b606
ea0ab164fe55cc105e889e5040da02ba13983b4a
/StringCalculator.hpp
aa21f1f62189a397b20c90145947a45015c38e41
[]
no_license
YaliWang2019/StringCalculator
acd1658c0e489051c02ed338d13f97724782f846
4a1da74cb7f3596ff8736cfd8ee4aa3f44327ea6
refs/heads/main
2023-02-28T08:14:41.884913
2021-02-04T17:11:26
2021-02-04T17:11:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
196
hpp
StringCalculator.hpp
#ifndef STRINGCALCULATOR_H #define STRINGCALCULATOR_H #include <string> class StringCalculator { public : StringCalculator(); int Add(std::string numbers); }; #endif // !STRINGCALCULATOR_H
d344351d0e4f16f0077c5f95d50532f2c5afe02b
905df54eb3c39d27046a9d6474e055ec2741f878
/src/vigenereautokeywidget.cpp
f51381880bb4f91c1588916822559466eb077206
[]
no_license
kevinfernaldy/simple-cryptography
51e73f97c6f96b61723b2574303058e4297a62e0
732f5d312e8b69012cb784d3c387f89f3bec1b78
refs/heads/master
2023-07-22T02:29:27.856363
2021-09-05T09:05:16
2021-09-05T09:05:16
403,307,648
0
0
null
null
null
null
UTF-8
C++
false
false
7,260
cpp
vigenereautokeywidget.cpp
#include <include/vigenereautokeywidget.h> #include "ui_vigenereautokeywidget.h" #include <QFileDialog> #include <QMessageBox> #include <fstream> #include <include/cipher/util.h> VigenereAutoKeyWidget::VigenereAutoKeyWidget(QWidget *parent) : QWidget(parent), ui(new Ui::VigenereAutoKeyWidget) { ui->setupUi(this); ui->sourceComboBox->addItem("keyboard"); ui->sourceComboBox->addItem("file"); ui->textTypeContainer_3->setVisible(false); ui->textTypeComboBox->addItem("plaintext"); ui->textTypeComboBox->addItem("ciphertext"); ui->fileHandlingContainer->setVisible(false); ui->plainTextWarningLabel->setVisible(false); cipher = nullptr; } VigenereAutoKeyWidget::~VigenereAutoKeyWidget() { delete ui; if (cipher != nullptr) delete cipher; } void VigenereAutoKeyWidget::encrypt(std::string key, std::string plainText) { if (cipher != nullptr) delete cipher; cipher = new VigenereAutoKeyCipher(key); cipher->setPlainText(plainText); cipher->encrypt(); } void VigenereAutoKeyWidget::decrypt(std::string key, std::string cipherText) { if (cipher != nullptr) delete cipher; cipher = new VigenereAutoKeyCipher(key); cipher->setCipherText(cipherText); cipher->decrypt(); } std::string VigenereAutoKeyWidget::readFile(std::string fileName) { std::ifstream fileInput(fileName.c_str()); std::ostringstream buffer; buffer << fileInput.rdbuf(); std::string content = buffer.str(); fileInput.close(); return content; } void VigenereAutoKeyWidget::handleFileOutput(std::string fileName, std::string content) { std::ofstream fileOutput(fileName); fileOutput << content; fileOutput.close(); } void VigenereAutoKeyWidget::on_encryptButton_clicked() { ui->plainTextWarningLabel->setVisible(false); try { std::string plainText = ui->plainTextBox->toPlainText().toLatin1().data(); std::string key = ui->keyTextBox->text().toLatin1().data(); CipherUtil::checkPlainText(plainText); CipherUtil::checkKey(key); if (!(CipherUtil::isPlainTextAlphanumeric(plainText))) { ui->plainTextWarningLabel->setVisible(true); plainText = CipherUtil::preparePlainText(plainText); } key = CipherUtil::prepareKey(key); ui->plainTextBox->setPlainText(QString(plainText.c_str())); encrypt(key, plainText); std::string convertedCipherText; if (ui->renderCipherTextBox->isChecked()) { convertedCipherText = cipher->getCipherText(false); } else { convertedCipherText = cipher->getCipherText(true); } ui->cipherTextBox->setPlainText(QString(convertedCipherText.c_str())); if (ui->sourceComboBox->currentIndex() == 1) { // Source and dest is file std::string fileOutputName = ui->fileOutputTextBox->text().toLatin1().data(); if (fileOutputName.empty()) { fileOutputName = ui->fileInputTextBox->text().toStdString() + "_ENCRYPTED"; } handleFileOutput(fileOutputName, convertedCipherText); } } catch (std::runtime_error message) { QMessageBox errorBox(QMessageBox::Icon::Critical, QString("Error"), QString(message.what()), QMessageBox::StandardButton::Ok); errorBox.exec(); } } void VigenereAutoKeyWidget::on_decryptButton_clicked() { ui->plainTextWarningLabel->setVisible(false); try { std::string cipherText = ui->cipherTextBox->toPlainText().toLatin1().data(); std::string key = ui->keyTextBox->text().toLatin1().data(); CipherUtil::checkCipherText(cipherText); CipherUtil::checkKey(key); cipherText = CipherUtil::prepareCipherText(cipherText); key = CipherUtil::prepareKey(key); decrypt(key, cipherText); std::string convertedPlainText = cipher->getPlainText(); ui->plainTextBox->setPlainText(QString(convertedPlainText.c_str())); if (ui->sourceComboBox->currentIndex() == 1) { // Source and dest is file std::string fileOutputName = ui->fileOutputTextBox->text().toLatin1().data(); if (fileOutputName.empty()) { fileOutputName = ui->fileInputTextBox->text().toStdString()+ "_DECRYPTED"; } handleFileOutput(fileOutputName, convertedPlainText); } } catch (std::runtime_error message) { QMessageBox errorBox(QMessageBox::Icon::Critical, QString("Error"), QString(message.what()), QMessageBox::StandardButton::Ok); errorBox.exec(); } } void VigenereAutoKeyWidget::on_renderCipherTextBox_stateChanged(int arg1) { switch(arg1) { case 2: { ui->cipherTextBox->setPlainText(QString(cipher->getCipherText(false).c_str())); break; } default: { ui->cipherTextBox->setPlainText(QString(cipher->getCipherText(true).c_str())); break; } } } void VigenereAutoKeyWidget::on_sourceComboBox_currentIndexChanged(int index) { switch(index) { case 0: { ui->textTypeContainer_3->setVisible(false); ui->fileHandlingContainer->setVisible(false); ui->cipherTextBox->setReadOnly(false); ui->plainTextBox->setReadOnly(false); break; } case 1: { ui->textTypeContainer_3->setVisible(true); ui->fileHandlingContainer->setVisible(true); ui->cipherTextBox->setReadOnly(true); ui->plainTextBox->setReadOnly(true); break; } } } void VigenereAutoKeyWidget::on_browseFileInputButton_clicked() { QFileDialog *dialog = new QFileDialog; QString fileName = dialog->getOpenFileName(); if (!fileName.isNull()) { std::string content = readFile(fileName.toLatin1().data()); int textType = ui->textTypeComboBox->currentIndex(); try { switch(textType) { case 0: { // Plaintext CipherUtil::checkPlainText(content); if (!(CipherUtil::isPlainTextAlphanumeric(content))) { ui->plainTextWarningLabel->setVisible(true); content = CipherUtil::preparePlainText(content); } ui->plainTextBox->setPlainText(QString(content.c_str())); break; } case 1: { // Ciphertext CipherUtil::checkCipherText(content); ui->cipherTextBox->setPlainText(QString(content.c_str())); break; } } ui->fileInputTextBox->setText(fileName); } catch (std::runtime_error message) { QMessageBox errorBox(QMessageBox::Icon::Critical, QString("Error"), QString(message.what()), QMessageBox::StandardButton::Ok); errorBox.exec(); } } delete dialog; } void VigenereAutoKeyWidget::on_browseFileOutputButton_clicked() { QFileDialog *dialog = new QFileDialog; QString fileName = dialog->getOpenFileName(); if (!fileName.isNull()) { ui->fileOutputTextBox->setText(fileName); } delete dialog; }
0e6cc6e135c1be802864dd5a44db34103b2eca4b
c10c875c7c7fa19a779e8da0579258675fed7b1a
/sim/midas/src/main/cc/simif_convey.h
3b264cd226469719a24a0bb15473ec86b50f0b43
[ "LicenseRef-scancode-bsd-3-clause-jtag" ]
permissive
davidmetz/firesim
b4a0b8587a9b40665070fd6e3d915f5269290ebd
251548023d52ab9d4e9bb9644974d9c9267c87a2
refs/heads/zynq-support-redux
2023-01-06T16:14:16.578992
2020-11-02T08:24:19
2020-11-02T08:24:19
278,298,296
0
0
NOASSERTION
2020-09-14T11:31:11
2020-07-09T07:46:38
null
UTF-8
C++
false
false
1,053
h
simif_convey.h
// See LICENSE for license details. #ifndef __SIMIF_CONVEY_H #define __SIMIF_CONVEY_H #include "simif.h" #include <stdint.h> #include <stdio.h> extern "C"{ #include <wdm_user.h> } class simif_convey_t: public virtual simif_t { public: simif_convey_t(int argc, char** argv); virtual ~simif_convey_t(); virtual int finish(); virtual void write(size_t addr, uint32_t data); virtual uint32_t read(size_t addr); virtual ssize_t pull(size_t addr, char* data, size_t size){ fprintf(stderr, "DMA not supported \n"); exit(-1); return 0; } virtual ssize_t push(size_t addr, char* data, size_t size){ fprintf(stderr, "DMA not supported \n"); exit(-1); return 0; } // virtual void write_mem_chunk(size_t addr, mpz_t& value, size_t bytes); private: wdm_coproc_t m_coproc; int fd; //allocate memmory uint64_t *cp_base; protected: void writeCSR(unsigned int regInd, uint64_t regValue); uint64_t readCSR(unsigned int regInd); }; #endif // __SIMIF_CONVEY_H
f6b8eb30a93ffb44e7dcd9c5ba845d47214b25a9
652eff8d86465c7dbda3ad8601d35318ce14d4a6
/DTDParser/Tokenizer.h
524bcdbdba9c79003af961b03467af7854a4f1a6
[ "MIT" ]
permissive
jezhiggins/bindotron
4cc08739df469c7c9c8fe0a5332d718c9c205792
db9089d9ba7662e48ba42e15e01420f31ab34c60
refs/heads/master
2021-01-20T09:33:01.480074
2017-05-04T13:11:54
2017-05-04T13:11:54
90,264,250
1
0
null
null
null
null
UTF-8
C++
false
false
9,691
h
Tokenizer.h
#ifndef ARABICA_DTDPARSER_TOKENIZER_H #define ARABICA_DTDPARSER_TOKENIZER_H // $Id: Tokenizer.h,v 1.11 2001/12/13 16:12:20 jez Exp $ #include <string> #include <XML/UnicodeCharacters.h> #include <XML/XMLCharacterClasses.h> namespace DTD { template<class stringT> class Token { public: enum Type { COMMA, PLUS, QUESTION_MARK, LEFT_PARENS, RIGHT_PARENS, PIPE, LT, GT, HASH_MARK, EQUALS, ASTERISK, START_CONDITIONAL, END_CONDITIONAL, START_DECL, COMMENT, START_PI, PERCENT, IDENTIFIER, QUOTED_STRING, NMTOKEN, CHARACTER, END }; Token() : skipped_(false) { } Token(const Token& rhs) : type_(rhs.type_), value_(rhs.value_), skipped_(rhs.skipped_) { } ~Token() { } Token& operator=(const Token& rhs) { type_ = rhs.type_; value_ = rhs.value_; skipped_ = rhs.skipped_; return *this; } // operator= bool operator==(Type type) const { return type_ == type; } bool operator!=(Type type) const { return !(operator==(type)); } Type type() const { return type_; } const stringT& value() const { return value_; } bool skippedWhitespace() const { return skipped_; } void set_type(Type type) { type_ = type; } void set_value(const stringT& value) { value_ = value; } void set_skipped(bool skipped) { skipped_ = skipped; } private: Type type_; stringT value_; bool skipped_; bool operator==(const Token&) const; // no impl }; // class Token /////////////////////////////////////////////////////////////////// // Tokenizer template<class stringT, class string_adaptorT> class Tokenizer { public: typedef Token<stringT> TokenT; typedef typename Token<stringT>::Type TokenTypeT; Tokenizer() : has_next_(false) { } void set_istream(std::wistream& istream) { stream_ = &istream; } TokenT token(); TokenT peek_token(); typedef typename stringT::value_type charT; stringT readUntil(charT delim); private: void readQuotedString(std::istreambuf_iterator<wchar_t>& is, wchar_t quot, std::wstring& tok) const; void readToken(std::istreambuf_iterator<wchar_t>& is, std::wstring& tok) const; TokenTypeT readStartOfSomething(std::istreambuf_iterator<wchar_t>& is, std::wstring& tok); void readEndOfConditional(std::istreambuf_iterator<wchar_t>& is); void reportError(const std::string& message) const; std::wistream* stream_; const std::istreambuf_iterator<wchar_t> end_stream_; TokenT next_token_; bool has_next_; string_adaptorT SA_; typedef Arabica::Unicode<typename stringT::value_type> UnicodeT; }; // class Tokenizer /////////////////////////////////////// // Tokenizer implementation template<class stringT, class string_adaptorT> typename Tokenizer<stringT, string_adaptorT>::TokenT Tokenizer<stringT, string_adaptorT>::token() { if(!has_next_) peek_token(); has_next_ = false; return next_token_; } // token template<class stringT, class string_adaptorT> typename Tokenizer<stringT, string_adaptorT>::TokenT Tokenizer<stringT, string_adaptorT>::peek_token() { if(has_next_) return next_token_; has_next_ = true; next_token_ = TokenT(); std::istreambuf_iterator<wchar_t> is(*stream_); if(is == end_stream_) { next_token_.set_type(TokenT::END); return next_token_; } // wchar_t c = *is++; next_token_.set_skipped(Arabica::XML::is_space(c)); while((Arabica::XML::is_space(c)) && (is != end_stream_)) c = *is++; if(is == end_stream_ && Arabica::XML::is_space(c)) { next_token_.set_type(TokenT::END); return next_token_; } // std::wstring tok; tok += c; if(c == UnicodeT::LESS_THAN_SIGN) next_token_.set_type(readStartOfSomething(is, tok)); else if(c == UnicodeT::RIGHT_SQUARE_BRACKET) readEndOfConditional(is); else if((c == UnicodeT::APOSTROPHE) || (c == UnicodeT::QUOTATION_MARK)) { readQuotedString(is, c, tok); next_token_.set_type(TokenT::QUOTED_STRING); } // if ... else if(Arabica::XML::is_letter(c)) { readToken(is, tok); next_token_.set_type(TokenT::IDENTIFIER); } else if(Arabica::XML::is_name_char(c)) { readToken(is, tok); next_token_.set_type(TokenT::NMTOKEN); } else if(c == UnicodeT::PERCENT_SIGN) { if(Arabica::XML::is_space(*is)) next_token_.set_type(TokenT::PERCENT); else throw std::runtime_error("can't handle parameter entity ref's yet"); } else if(c == UnicodeT::QUESTION_MARK) next_token_.set_type(TokenT::QUESTION_MARK); else if(c == UnicodeT::LEFT_PARENTHESIS) next_token_.set_type(TokenT::LEFT_PARENS); else if(c == UnicodeT::RIGHT_PARENTHESIS) next_token_.set_type(TokenT::RIGHT_PARENS); else if(c == UnicodeT::VERTICAL_BAR) next_token_.set_type(TokenT::PIPE); else if(c == UnicodeT::GREATER_THAN_SIGN) next_token_.set_type(TokenT::GT); else if(c == UnicodeT::EQUALS_SIGN) next_token_.set_type(TokenT::EQUALS); else if(c == UnicodeT::ASTERISK) next_token_.set_type(TokenT::ASTERISK); else if(c == UnicodeT::PLUS_SIGN) next_token_.set_type(TokenT::PLUS); else if(c == UnicodeT::COMMA) next_token_.set_type(TokenT::COMMA); else if(c == UnicodeT::NUMBER_SIGN) next_token_.set_type(TokenT::HASH_MARK); else next_token_.set_type(TokenT::CHARACTER); /* if((c == '&') || (c == '%')) { if((ch == '%') && XML::is_space(*is)) return new Token(PERCENT); boolean peRef = (ch == '%'); StringBuffer buff = new StringBuffer(); buff.append((char) ch); while (isIdentifierChar((char) peekChar())) { buff.append((char) read()); } if(read() != ';') { throw new DTDParseException(getUriId(), "Expected ';' after reference "+ buff.toString()+", found '"+ch+"'", getLineNumber(), getColumn()); } buff.append(';'); if (peRef && expandEntity(buff.toString())) { continue; } return new Token(IDENTIFIER, buff.toString()); } */ next_token_.set_value(SA_.makeStringT(tok.c_str())); return next_token_; } // peek_token template<class stringT, class string_adaptorT> stringT Tokenizer<stringT, string_adaptorT>::readUntil(charT delim) { has_next_ = false; wchar_t w_delim = SA_.makeValueT(delim); std::istreambuf_iterator<wchar_t> is(*stream_); std::wstring str; while((*is != w_delim) && (is != end_stream_)) str += *is++; return SA_.makeStringT(str.c_str()); } // readUntil template<class stringT, class string_adaptorT> void Tokenizer<stringT, string_adaptorT>::readQuotedString(std::istreambuf_iterator<wchar_t>& is, wchar_t quot, std::wstring& tok) const { tok.erase(); while((*is != quot) && (is != end_stream_)) tok += *is++; is++; if(is == end_stream_) throw std::runtime_error("unterminated string"); } // readQuotedString template<class stringT, class string_adaptorT> void Tokenizer<stringT, string_adaptorT>::readToken(std::istreambuf_iterator<wchar_t>& is, std::wstring& tok) const { while(Arabica::XML::is_name_char(*is)) tok += *is++; } // readToken template<class stringT, class string_adaptorT> typename Tokenizer<stringT, string_adaptorT>::TokenTypeT Tokenizer<stringT, string_adaptorT>::readStartOfSomething(std::istreambuf_iterator<wchar_t>& is, std::wstring& tok) { if(*is == UnicodeT::EXCLAMATION_MARK) { is++; if(*is == UnicodeT::LEFT_SQUARE_BRACKET) { is++; return TokenT::START_CONDITIONAL; } if(*is != UnicodeT::HYPHEN_MINUS) return TokenT::START_DECL; // possible start of comment is++; if(*is++ != UnicodeT::HYPHEN_MINUS) reportError("Invalid character sequence"); tok.erase(); while(true) { while((Arabica::XML::is_char(*is)) && (*is != UnicodeT::HYPHEN_MINUS) && (is != end_stream_)) tok += *is++; ++is; if(*is == UnicodeT::HYPHEN_MINUS) { ++is; if(*is == UnicodeT::GREATER_THAN_SIGN) { ++is; return TokenT::COMMENT; } // if(*is == UnicodeT::GREATER_THAN_SIGN) throw std::runtime_error("-- is illegal inside a comment"); } if(is == end_stream_) throw std::runtime_error("unterminated comment"); tok += UnicodeT::HYPHEN_MINUS; } } // if(*is == UnicodeT::EXCLAMATION_MARK if(*is == UnicodeT::QUESTION_MARK) { is++; return TokenT::START_PI; } // if(*is == UnicodeT::QUESTION_MARK) return TokenT::LT; } // readStartOfSomething template<class stringT, class string_adaptorT> void Tokenizer<stringT, string_adaptorT>::readEndOfConditional(std::istreambuf_iterator<wchar_t>& is) { is++; if((*is++ != UnicodeT::RIGHT_SQUARE_BRACKET) && (*is != UnicodeT::GREATER_THAN_SIGN)) { reportError("Invalid character " + *is); next_token_.set_type(TokenT::END); } next_token_.set_type(TokenT::END_CONDITIONAL); } // readEndOfConditional template<class stringT, class string_adaptorT> void Tokenizer<stringT, string_adaptorT>::reportError(const std::string& message) const { throw std::runtime_error(message); } // reportError } // namespace DTD #endif
09c11d8ff0d006671dfa2f34db212e658ff3baed
67a17f4a03abcfd7b1626c6c421e0fe03882f8f5
/9749008.cc
da0846f24e2e031db66f31fbd6b3409e58b6d993
[]
no_license
TinyBeing/study
fd41bc272ce1a65e26bd66796bdc4d2623cda4d9
ba84b56ae0e878470d7a9e3bc59a6c0da9215cb5
refs/heads/master
2020-03-22T21:26:53.757500
2018-10-19T17:39:12
2018-10-19T17:39:12
140,688,772
0
0
null
null
null
null
UTF-8
C++
false
false
1,476
cc
9749008.cc
#include <stdlib.h> #include <iostream> #include <stack> #include <utility> using namespace std; int** co; int re; stack<pair<int,int> > q; inline int make(int** c, int a, int b, int n) { int count=0; for (int i = 0; i < n; i++) { if (c[a][i] == 0) { q.push(pair<int, int>(a, i)); count++; c[a][i] = 1; } } for (int i = a; i < n; i++) { if (c[i][b] == 0) { q.push(pair<int, int>(i, b)); count++; c[i][b] = 1; } } int tmp, tmp2; tmp = a; tmp2 = b; while (tmp < n - 1 && tmp2 < n - 1) { if (c[++tmp][++tmp2] == 0) { q.push(pair<int, int>(tmp, tmp2)); count++; c[tmp][tmp2] = 1; } } while (a < n - 1 && b > 0) { if (c[++a][--b] == 0) { q.push(pair<int, int>(a, b)); count++; c[a][b] = 1; } } return count; } inline void make2(int** c,int n) { while(n-->0) { c[q.top().first][q.top().second] = 0; q.pop(); } } inline void track(int** c, int a, int b, int count, int n) { if (count == n){ re++; return; } int num = make(c, a, b, n); for (int i = 0; i < n; i++) if (c[a + 1][i] == 0) track(c, a + 1, i, count + 1, n); make2(c, num); } int main(void) { int n; cin >> n; co = (int**)malloc(sizeof(int*)*n); for (int i = 0; i < n; i++) co[i] = (int*)malloc(sizeof(int)*n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) co[i][j] = 0; re = 0; for (int i = 0; i < n; i++) track(co, 0, i, 1, n); cout << re << endl; return 0; }
f81055ef07f83987fa72fb36fc51242ff2179556
84c82b4e56f660aad04c6ff445a7a594e35c9870
/src/PreShower.cc
c470c9ea779189a509167910c1bc208edf3c8f85
[]
no_license
ginnocen/DelphesO2
cc1cfe7836eaf3345dac88db10be611bbc25fca8
ff47f74d437f2ca4d65302ad8caa5b79c544325b
refs/heads/master
2023-08-13T18:00:53.284453
2021-10-04T11:47:09
2021-10-04T11:47:09
276,666,301
0
0
null
2021-10-10T04:40:07
2020-07-02T14:21:35
C++
UTF-8
C++
false
false
1,970
cc
PreShower.cc
/// @author: Roberto Preghenella /// @email: preghenella@bo.infn.it /// @author: Antonio Uras /// @email: antonio.uras@cern.ch /// @author: Marco van Leeuwen /// @email: marco.van.leeuwen@cern.ch #include "PreShower.hh" #include "TDatabasePDG.h" #include "THnSparse.h" #include "TRandom.h" #include "TDatime.h" #include "TFile.h" #include "TVector3.h" #include "TMath.h" #include "TAxis.h" namespace o2 { namespace delphes { //========================================================================================================== bool PreShower::setup() { TDatime t; gRandom->SetSeed(t.GetDate()+t.GetYear()*t.GetHour()*t.GetMinute()*t.GetSecond()); // NB: gRandom is a global pointer ? for (Int_t iPart = 0; iPart < kNPart; iPart++) { mMomMin[iPart] = 0.1; mMomMax[iPart] = 20; } return kTRUE; } //========================================================================================================== bool PreShower::hasPreShower(const Track &track) { auto pdg = std::abs(track.PID); auto part = pidmap[pdg]; return ((TMath::Abs(track.Eta) < mEtaMax) && (track.P > mMomMin[part])); } //========================================================================================================== bool PreShower::isElectron(const Track &track, int multiplicity=1) { auto pdg = std::abs(track.PID); auto part = pidmap[pdg]; if (part == kElectron) { // Parametrisation of preshower detector studies without charge sharing float eff = 0.8*(1.-exp(-1.6*(track.P-0.05))); return (gRandom->Uniform() < eff); } else { const Float_t misTagProb = 0.001; return (gRandom->Uniform() < misTagProb); } } //========================================================================================================== } /** namespace delphes **/ } /** namespace o2 **/
9f4b292e687cf97508015899ed47cdfe93bf35ea
e39be34960c422082b4ef2906ea5f79c3fc0b9fd
/Algorithms_Assignment/Written:Programming_assignment_3/q3_quicksort.cpp
a4a7d5a65c4952fe0f70c8b97a9b4c82eb4da6d0
[]
no_license
kwanhiuhong/Algorithms-Cpp-C
3636eac3f747973f76b811fd98a63fe1363a0af5
f4c2e13023055641fbfb04fde0e942d56a6c7088
refs/heads/master
2023-03-13T15:08:07.446699
2021-03-12T06:03:08
2021-03-12T06:03:08
164,850,848
0
0
null
null
null
null
UTF-8
C++
false
false
1,795
cpp
q3_quicksort.cpp
// // main.cpp // quick_sort // // Created by Peter on 11/8/18. // Copyright © 2018 Peter. All rights reserved. // #include <iostream> using namespace std; int partition(int * arr, int p ,int r); void quicksort(int * arr, int p ,int r); void kthsmallest(int * arr, int p ,int r, int k); int main(int argc, const char * argv[]) { int array[7] = {1,10,3,9,8,4,5}; // {1,10,3,9,8,4,5}; // {1,3,4,5,8,9,10} cout << endl; //quicksort(array, 0, 6); kthsmallest(array, 0, 6, 1); // for(int j=0; j<7;j++){ // // cout << "j is " << array[j] << endl; // } // return 0; } int partition(int * arr, int p ,int r){ int x = arr[r]; int i = p - 1; // at the start i will be -1 for(int j = p; j<r; j++){ if(arr[j] <= x){ i++; int temp = arr[j]; arr[j] = arr[i]; arr[i] = temp; } } int temp2 = arr[i+1]; arr[i+1] = arr[r]; arr[r] = temp2; return i+1; } void kthsmallest(int * arr, int p ,int r, int k){ int x = arr[r]; int i = p - 1; // at the start i will be -1 for(int j = p; j<r; j++){ if(arr[j] <= x){ i++; int temp = arr[j]; arr[j] = arr[i]; arr[i] = temp; } } int temp2 = arr[i+1]; arr[i+1] = arr[r]; arr[r] = temp2; if(i == k-1){ cout << arr[i] << " is the kth smallest" << endl; }else if(i < k-1 ){ kthsmallest(arr, i+2, r , k); }else{ kthsmallest(arr, p, i , k); } } void quicksort(int * arr, int p ,int r){ cout << "p is " << p << endl; if(p<r){ int q = partition(arr, p , r); cout << "q is " << q << endl; quicksort(arr, p, q-1); quicksort(arr, q+1, r); } }
9964230cc1beddf786c2d95b6db8aec13c48cb2d
4b75484caaf240878f4768f689b5a4153a7a63a9
/BTREE/bnode.h
0a584ae3b7baa6f63dbb6eefac084d520e6ae8e1
[]
no_license
samueljrz/Advanced-Data-Structure
e4a86cc98b29edd81c2d7c6ad45729974d666317
dbf307296b0df11281722d12b4e2645fd9b7124d
refs/heads/master
2023-01-19T21:21:58.428631
2020-11-26T12:47:14
2020-11-26T12:47:14
247,602,953
1
0
null
null
null
null
UTF-8
C++
false
false
4,784
h
bnode.h
#ifndef BNODE_H #define BNODE_H #include <iostream> class Bnode { private: int *key; // vetor de chaves int d; // grau minimo Bnode **c; // vetor de ponteiros para filhos int n; // numero atual de chaves bool leaf; // true se o noh eh uma folha, false caso contrario public: // Construtor Bnode(int d, bool leaf); // Destrutor ~Bnode(); // Funcao que busca a chave k na subarvore // enraizada neste no. Se a chave existir, retorna // o ponteiro para o no e o valor do indice da chave // na variavel index. Caso contrario, retorna nullptr // e o valor de index eh indefinido. Bnode *search(int k, int& index); // Imprime todas as chaves do no em ordem crescente // Incompleto void printKeys(); // Funcao que divide o filho c[i] deste no. // O no apontado por c[i] deve estar cheio // quando esta funcao eh chamada. void splitChild(int i); // Funcao que insere uma nova chave na subarvore // enraizada neste no. Supomos que o no nao esta // cheio quando esta funcao eh chamada void insertNonFull(int k); // Faz Btree uma classe amiga desta, para que possamos acessar // os membros privados desta classe nas funções de Btree. friend class Btree; }; Bnode::Bnode(int d, bool leaf) { this->d = d; // grau minimo do noh this->leaf = leaf; // indica se noh eh folha n = 0; // no inicio o noh nao tem chaves key = new int[2*d - 1]; // o noh pode ter no maximo 2d-1 chaves c = new Bnode*[2*d]; // o noh pode ter no maximo 2d filhos } Bnode::~Bnode() { std::cout << "No removido com chaves: " << std::endl; for(int i = 0; i < n; i++) std::cout << key[i] << " "; std::cout << std::endl; delete[] key; delete[] c; } Bnode *Bnode::search(int k, int& index) { // Encontra a primeira chave maior ou igual a k int i = 0; while(i <= n-1 && k > key[i]) i++; // A chave foi encontrada neste no. if(i <= n-1 && k == key[i]) { index = i; return this; } // A chave nao foi encontrada neste no e ele eh folha. else if(leaf == true) return nullptr; // Desce para o filho apropriado else return c[i]->search(k, index); } void Bnode::printKeys() { int i; for(i=0; i<n; i++) { if(leaf == false) c[i]->printKeys(); std::cout << " " << key[i]; } if(leaf == false) c[i]->printKeys(); } void Bnode::splitChild(int i) { // y eh o filho deste no que sera dividido Bnode *y = this->c[i]; // Aloca memoria para um novo no que armazenara as // d-1 maiores chaves de y Bnode *z = new Bnode(d, y->leaf); z->n = d-1; // Copia as ultimas d-1 chaves de y para z for(int j = 0; j < d-1; j++) z->key[j] = y->key[j+d]; // Copia os ultimos d filhos de y para z if(y->leaf == false) { for(int j = 0; j < d; j++) z->c[j] = y->c[j+d]; } // Atualiza o numero de chaves de y y->n = d-1; // Como este no tera um novo filho, criamos // espaco para o ponteiro para o novo filho for(int j = n; j >= i+1; j--) c[j+1] = c[j]; // Faz c[i+1] apontar para z c[i+1] = z; // Move a chave mediana de y para este no. // Encontra a posicao da nova chave e move todas // as chaves maiores uma posicao para a frente for(int j = n-1; j >= i; j--) key[j+1] = key[j]; // Copia a chave mediana de y para este no. key[i] = y->key[d-1]; // Incrementa o numero de chaves deste no. n = n + 1; } void Bnode::insertNonFull(int k) { // Inicia i com o indice da chave mais a direita int i = n-1; // Se este no eh folha if(leaf == true) { // Este loop move as chaves uma posicao para // a direita ate achar a posicao correta da nova chave. while(i >= 0 && k < key[i]) { key[i+1] = key[i]; i--; } // Insere a nova chave na posicao correta key[i+1] = k; n = n+1; } // Se este no nao eh folha else { // Encontra o filho que tera a nova chave while(i >= 0 && k < key[i]) i--; i++; // Checa se o filho encontrado esta cheio if(c[i]->n == 2*d-1) { // Se o filho c[i] deste no estiver cheio, divida-o splitChild(i); // Depois de dividir, a chave do meio de c[i] sobe // para este no e c[i] eh dividido em dois. Agora, // devemos decidir qual das duas metades tera a // nova chave if(k > key[i]) i++; } c[i]->insertNonFull(k); } } #endif
57ad06aebdf0fd2132e48146d5e96c47cbeefd5a
1b74e77cd051d9db4e9f29c151b606980ea04a7f
/FILE_read Data/main.cpp
67660c633a0a644bdbd40a90e6d58136bdf7bad9
[]
no_license
Sudhan17/Cpp_Programming
45b020b68b9f792c83dab9442006c6bb9733eb60
dd04ea8d0e3e20415b5d2b2acaef40c5bdf19330
refs/heads/main
2023-07-04T19:17:18.600418
2021-08-12T11:50:17
2021-08-12T11:50:17
392,226,471
0
0
null
null
null
null
UTF-8
C++
false
false
625
cpp
main.cpp
#include <iostream> #include<fstream> using namespace std; int main() { ifstream fin; // create input stream char ch; // variable for storing GET pointer character fin.open("my.txt"); // load file into RAM fin >> ch; // storing 1st GET pointer vale into CH variable while (!fin.eof()) // iteration till End of File { cout << ch; // print the value at 1st Index(1st Character) fin >> ch; // move GET pointer forward } fin.close(); // close the file from RAM return 0; }
22dbbf1d8090411e67e9dbbfe8ded343adc8f6d6
82692cb6d80b9bda8930366f36f48eb6df073eba
/SteamAPIWrap/Services.hpp
066f5c7b9dfcc5c3d6baf82f908e772086e94206
[ "MIT" ]
permissive
HoggeL/Ludosity-s-Steamworks-Wrapper
897078de3bb5d6fa8b954aab05135c3084eb2b93
5cd8f5740829a20af23343865895ceb782f9b0b4
refs/heads/master
2021-01-01T04:50:04.904843
2016-05-09T21:31:05
2016-05-09T21:31:05
58,408,426
0
0
null
null
null
null
UTF-8
C++
false
false
1,781
hpp
Services.hpp
#ifndef Services_h_ #define Services_h_ #include "Services.h" #include "Singleton.hpp" #include "ErrorCodes.hpp" #include "LoadStatus.hpp" #include "CallbackID.hpp" #include "ResultID.hpp" namespace SteamAPIWrap { class CServices : public CSteamAPIContext, public CSingleton<CServices> { public: bool Startup(u32 interfaceVersion); void Shutdown(); u64 GetAppID() const { return appID; } void SetErrorCode(EErrorCodes::Enum error) { errorCode = error; } EErrorCodes::Enum GetErrorCode() const { return errorCode; } ELoadStatus::Enum GetSteamLoadStatus() const { return steamLoadStatus; } void CallManagedCallback(ECallbackID::Enum id, PConstantDataPointer data, s32 dataSize) { // Ignore the callback if no managed receiver is registered. if (managedCallback == nullptr) { return; } managedCallback(id, data, dataSize); } void CallManagedResultCallback(EResultID::Enum id, PConstantDataPointer data, s32 dataSize, bool ioFailure) { // Ignore the callback if no managed receiver is registered. if (managedResultCallback == nullptr) { return; } managedResultCallback(id, data, dataSize, ioFailure); } void RegisterManagedCallbacks(ManagedCallback callback, ManagedResultCallback resultCallback) { managedCallback = callback; managedResultCallback = resultCallback; } void RemoveManagedCallbacks() { managedCallback = nullptr; managedResultCallback = nullptr; } private: friend class CSingleton<CServices>; CServices(); ~CServices() {} DISALLOW_COPY_AND_ASSIGN(CServices); u64 appID; EErrorCodes::Enum errorCode; ELoadStatus::Enum steamLoadStatus; ManagedCallback managedCallback; ManagedResultCallback managedResultCallback; }; } #endif // Services_h_
4b165ce7f674f933de0af3c58fd4a03fc9cd02fe
7ace7f8411bf5cbacd650c0b3a173e88a8b22bd8
/Lesson 05 - Prefix Sums/MinAvgTwoSlice/solution.cpp
857b1bd16ee234efad22a0327ca748908459af2c
[]
no_license
bskim45/codility-lessons
f312ee1f23e927bc4b9d3787548c840e39f58be9
64bd6c64ea386206eae615fefe18e22fb24c57cf
refs/heads/master
2020-12-02T19:23:31.028338
2017-07-08T17:43:35
2017-07-08T17:43:35
96,334,042
0
0
null
null
null
null
UTF-8
C++
false
false
585
cpp
solution.cpp
// Task Score: 100% // Correctness: 100% // Performance: 100% // Time Complexity: O(N) // Space Complexity: O(1) #include <cfloat> int solution(vector<int> &A) { double min_avg = DBL_MAX; int idx = 0; for(size_t i = 0; i < A.size() - 2; i++) { double avg = std::min(double(A[i] + A[i + 1]) / 2, double(A[i] + A[i + 1] + A[i + 2]) / 3); if(avg < min_avg) { min_avg = avg; idx = i; } } if(double(*(A.cend() - 2) + *(A.cend() - 1)) / 2 < min_avg) { idx = A.size() - 2; } return idx; }
f1b656b39fffd158b498cbd2643d6d7e80d61b64
376c88f77e904986c2d81eb9ea8de851a8135b9a
/testy/test_grmath.cpp
e71c7a8d663716812b760131615f80ef7db66fe7
[ "MIT" ]
permissive
Wiladams/ndt
e01da0e7844c48c591031157cd0611fed08b6f0b
d93f6fd0e6de46e86dbe8e7dbb394f867fa799d4
refs/heads/master
2023-03-01T00:34:48.897819
2023-02-18T19:16:16
2023-02-18T19:16:16
252,350,143
14
0
null
null
null
null
UTF-8
C++
false
false
620
cpp
test_grmath.cpp
#include <cstdio> #include <DirectXMath.h> #include <DirectXPackedVector.h> #include <DirectXColors.h> #include <DirectXCollision.h> using namespace DirectX; using point3 = XMFLOAT3; // 3D point using rtcolor = XMFLOAT3; void main() { struct Ray { XMFLOAT3 pos; XMFLOAT3 dir; } struct ConstantBuffer { XMMATRIX transform; }; float angle = 30; const ConstantBuffer cb = { { XMMatrixRotationZ(angle) * XMMatrixScaling(3.0/4.0, 1.0, 1.0) } }; printf("hello\n"); XMVECTOR vFive = XMVectorReplicate( 5.f ); }
17226ceea8d34fb6e9eb1c04fbed149dd89a5254
ae4ade7352ad31c3f4892dcdf7307c169c055a4c
/Team.cpp
0560130a17c8c097ee81cbe95b851462f054406d
[]
no_license
adeemadil/CS201-Fundamental-Structures-Of-Computer-Science
e304f593a0fc44fadb2c666808f3263951509b20
b387d1e02aea9e431ea8e469ea36a5a79718a5da
refs/heads/master
2023-04-23T03:29:08.174206
2021-05-10T20:10:42
2021-05-10T20:10:42
255,088,378
0
0
null
null
null
null
UTF-8
C++
false
false
4,886
cpp
Team.cpp
#include "Team.h" #include <iostream> #include <algorithm> using namespace std; Team::Team(const string tname, const string tColor, const int tYear) { teamName = tname; teamColor = tColor; teamYear = tYear; head = NULL; } Team::~Team() { if (head != NULL) { PlayerNode* current = head; PlayerNode* next; while (current != NULL) { next = current->next; delete current; current = next; } } } Team::Team(const Team& teamToCopy) { teamName = teamToCopy.teamName; teamColor = teamToCopy.teamColor; teamYear = teamToCopy.teamYear; if (teamToCopy.head == NULL) { head = NULL; } else { head = new PlayerNode; head->p.setPlayerName(teamToCopy.head->p.getPlayerName()); head->p.setPlayerPosition(teamToCopy.head->p.getPlayerPosition()); PlayerNode* newPtr = head; for (PlayerNode* origPtr = teamToCopy.head->next; origPtr != NULL; origPtr = origPtr->next) { newPtr->next = new PlayerNode; newPtr = newPtr->next; newPtr->p.setPlayerName(origPtr->p.getPlayerName()); newPtr->p.setPlayerPosition(origPtr->p.getPlayerPosition()); } newPtr->next = NULL; } } void Team::operator=(const Team& right) { teamName = right.teamName; if (right.head == NULL) { head = NULL; } else { head = new PlayerNode; head->p.setPlayerName(right.head->p.getPlayerName()); head->p.setPlayerPosition(right.head->p.getPlayerPosition()); PlayerNode* newPtr = head; for (PlayerNode* origPtr = right.head->next; origPtr != NULL; origPtr = origPtr->next) { newPtr->next = new PlayerNode; newPtr = newPtr->next; newPtr->p.setPlayerName(origPtr->p.getPlayerName()); newPtr->p.setPlayerPosition(origPtr->p.getPlayerPosition()); } newPtr->next = NULL; } } string Team::getTeamName() const { return teamName; } int Team::getTeamYear() const { return teamYear; } string Team::getTeamColor() const { return teamColor; } void Team::setTeamName(const string tName) { teamName = tName; } void Team::setTeamColor(const string tColor) { teamColor = tColor; } void Team::setTeamYear(const int tYear) { teamYear = tYear; } bool Team::addPlayer(const string pName, const string pPosition) { if (findPlayer(pName) != NULL) { cout << "" << pName << " already exists." << endl; return false; } if (head == NULL) { head = new PlayerNode; head->p.setPlayerName(pName); head->p.setPlayerPosition(pPosition); head->next = NULL; return true; } else { PlayerNode* curr = head; while (curr->next != NULL) { curr = curr->next; } curr->next = new PlayerNode; curr = curr->next; curr->p.setPlayerName(pName); curr->p.setPlayerPosition(pPosition); curr->next = NULL; return true; } } bool Team::removePlayer(const string tName, const string pName) { PlayerNode* playerToRemove = findPlayer(pName); if (playerToRemove == NULL) { cout << "Player " << pName << " does not exist." << endl; return false; } PlayerNode* prev = head; if ((prev->next == NULL) && (prev == playerToRemove)) { delete prev; head = NULL; return true; } for (PlayerNode* curr = head->next; curr != NULL; curr = curr->next) { if (curr == playerToRemove) { prev->next = curr->next; delete curr; return true; } else if (prev == playerToRemove) { head = prev->next; delete prev; return true; } prev = prev->next; } } void Team::displayPlayers() const { if (head == NULL) { cout << "--EMPTY--" << endl; return; } for (PlayerNode* curr = head; curr != NULL; curr = curr->next) { cout << "\t" << curr->p.getPlayerName() << ", " << curr->p.getPlayerPosition() << endl; } } bool Team::playerInTeam(string pName, string &pPosition, string& teamName) { PlayerNode* ptrOfPlayer = findPlayer(pName); if (ptrOfPlayer == NULL) { return false; } else { pName = ptrOfPlayer->p.getPlayerName(); pPosition = ptrOfPlayer->p.getPlayerPosition(); teamName = this->getTeamName(); return true; } } void Team::printPlayer(const string playerName) { PlayerNode* tempNode = findPlayer(playerName); if (tempNode != NULL) { cout << tempNode->p.getPlayerPosition() << ", " << this->getTeamName() << ", " << this->getTeamColor() << ", " << this->getTeamYear() << endl; } } Team::PlayerNode* Team::findPlayer(const string pName) const { string playerToFind = pName; string currentPlayerName = ""; transform(playerToFind.begin(), playerToFind.end(), playerToFind.begin(), ::tolower); for (PlayerNode* curr = head; curr != NULL; curr = curr->next) { currentPlayerName = curr->p.getPlayerName(); transform(currentPlayerName.begin(), currentPlayerName.end(), currentPlayerName.begin(), ::tolower); if (currentPlayerName == playerToFind) { return curr; } } return NULL; }
9b24b3416d889396ba7d807a1c794b9a36d468be
04bce0202f77bc85cf3f64f6b3a0ced87d533ce3
/test/Jack_Test/view/title.h
3223f3ff0cda739af96a4cbe965797bc3d2d5d57
[]
no_license
jziesing/Interstellar
0ee97afd21b19eaedfbf073d067ab22c0dc51327
42f1fbee0358d3b17b82a54dbc21a7a7ec04ad83
refs/heads/master
2016-09-05T19:36:50.178095
2014-11-16T05:58:34
2014-11-16T05:58:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
365
h
title.h
#ifndef TITLE_H #define TITLE_H #include <SFML/Graphics.hpp> #include <string> using namespace sf; using namespace std; class title { protected: int center[2]; Font font; public: title(int center_x, int center_y); void initFont(string filePath); Text createTitle(string txt, int fontsz, int style); //RectangleShape createBorder(4); ~title() {}; }; #endif
fc38d9ded5327fddadfc180001a11cec11ab2a5e
3e814f0ed8f3563880228f837c851021fc561ba4
/Group_Project_Group48/main.cpp
cfc3b0cfb451ee45f849ba0d784de73cb0c2b266
[]
no_license
katrinechow/OSU-CS-162
a356ba8cdcc48b89d051283dd415b55eb186d0aa
082fba9bb4bfa1de742d6e9cdc1e1d74c546e1e0
refs/heads/master
2020-06-08T16:07:12.269212
2019-06-22T17:42:20
2019-06-22T17:42:20
193,259,431
0
0
null
null
null
null
UTF-8
C++
false
false
468
cpp
main.cpp
/********************************************************************* ** Program: Predator prey game ** Author: Group 48 ** Date: Feb 5, 2018 ** Description: Menu class implementation *********************************************************************/ #include <iostream> #include <cstdlib> #include "bugWorld.hpp" using std::cout; int main() { srand(time(NULL)); BugWorld bugWorld; bugWorld.play(); return 0; }
141750c3f219e45e419dad0c955ac986ac4b060e
1d1b972fe088c601eafdd0a9451f15a43fb40b4e
/QtGuiApplication1/QtGuiApplication1/Debug/moc/moc_QtGuiApplication1.cpp
fe2075f461e7be176181c54792e48a6ba43d427a
[]
no_license
sh963852741/SimpleFileTransfer
84edf9c4258c16332ffd5ee86549691e66aff6af
8d6ca2635173b0ed0867437b09abdaa18abbcc21
refs/heads/master
2021-04-20T17:12:13.039059
2020-05-10T14:18:15
2020-05-10T14:18:15
249,703,997
0
2
null
2020-05-10T14:18:16
2020-03-24T12:36:20
C++
UTF-8
C++
false
false
11,594
cpp
moc_QtGuiApplication1.cpp
/**************************************************************************** ** Meta object code from reading C++ file 'QtGuiApplication1.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.14.1) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include <memory> #include "../../QtGuiApplication1.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'QtGuiApplication1.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.14.1. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_QtGuiApplication1_t { QByteArrayData data[31]; char stringdata0[340]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_QtGuiApplication1_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_QtGuiApplication1_t qt_meta_stringdata_QtGuiApplication1 = { { QT_MOC_LITERAL(0, 0, 17), // "QtGuiApplication1" QT_MOC_LITERAL(1, 18, 12), // "BeginSending" QT_MOC_LITERAL(2, 31, 0), // "" QT_MOC_LITERAL(3, 32, 8), // "basepath" QT_MOC_LITERAL(4, 41, 8), // "filename" QT_MOC_LITERAL(5, 50, 9), // "IPaddress" QT_MOC_LITERAL(6, 60, 14), // "BeignListening" QT_MOC_LITERAL(7, 75, 16), // "updateRecvFloder" QT_MOC_LITERAL(8, 92, 6), // "floder" QT_MOC_LITERAL(9, 99, 10), // "ifcompress" QT_MOC_LITERAL(10, 110, 6), // "compre" QT_MOC_LITERAL(11, 117, 12), // "ifencryption" QT_MOC_LITERAL(12, 130, 6), // "encypt" QT_MOC_LITERAL(13, 137, 8), // "StopRecv" QT_MOC_LITERAL(14, 146, 9), // "BeginRecv" QT_MOC_LITERAL(15, 156, 15), // "ChangeRecvState" QT_MOC_LITERAL(16, 172, 12), // "showFileList" QT_MOC_LITERAL(17, 185, 14), // "ShowSendingMsg" QT_MOC_LITERAL(18, 200, 2), // "id" QT_MOC_LITERAL(19, 203, 3), // "msg" QT_MOC_LITERAL(20, 207, 14), // "ShowRecvingMsg" QT_MOC_LITERAL(21, 222, 8), // "filePath" QT_MOC_LITERAL(22, 231, 4), // "time" QT_MOC_LITERAL(23, 236, 9), // "SendFiles" QT_MOC_LITERAL(24, 246, 14), // "StartListening" QT_MOC_LITERAL(25, 261, 18), // "ShowRecvingMsgById" QT_MOC_LITERAL(26, 280, 16), // "selectRecvFloder" QT_MOC_LITERAL(27, 297, 14), // "clearRecvTable" QT_MOC_LITERAL(28, 312, 7), // "InputIP" QT_MOC_LITERAL(29, 320, 8), // "compress" QT_MOC_LITERAL(30, 329, 10) // "encryption" }, "QtGuiApplication1\0BeginSending\0\0" "basepath\0filename\0IPaddress\0BeignListening\0" "updateRecvFloder\0floder\0ifcompress\0" "compre\0ifencryption\0encypt\0StopRecv\0" "BeginRecv\0ChangeRecvState\0showFileList\0" "ShowSendingMsg\0id\0msg\0ShowRecvingMsg\0" "filePath\0time\0SendFiles\0StartListening\0" "ShowRecvingMsgById\0selectRecvFloder\0" "clearRecvTable\0InputIP\0compress\0" "encryption" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_QtGuiApplication1[] = { // content: 8, // revision 0, // classname 0, 0, // classinfo 19, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 7, // signalCount // signals: name, argc, parameters, tag, flags 1, 3, 109, 2, 0x06 /* Public */, 6, 1, 116, 2, 0x06 /* Public */, 7, 1, 119, 2, 0x06 /* Public */, 9, 1, 122, 2, 0x06 /* Public */, 11, 1, 125, 2, 0x06 /* Public */, 13, 0, 128, 2, 0x06 /* Public */, 14, 0, 129, 2, 0x06 /* Public */, // slots: name, argc, parameters, tag, flags 15, 0, 130, 2, 0x0a /* Public */, 16, 0, 131, 2, 0x0a /* Public */, 17, 2, 132, 2, 0x0a /* Public */, 20, 2, 137, 2, 0x0a /* Public */, 23, 0, 142, 2, 0x0a /* Public */, 24, 0, 143, 2, 0x0a /* Public */, 25, 3, 144, 2, 0x0a /* Public */, 26, 0, 151, 2, 0x0a /* Public */, 27, 0, 152, 2, 0x0a /* Public */, 28, 0, 153, 2, 0x0a /* Public */, 29, 0, 154, 2, 0x0a /* Public */, 30, 0, 155, 2, 0x0a /* Public */, // signals: parameters QMetaType::Void, QMetaType::QString, QMetaType::QStringList, QMetaType::QString, 3, 4, 5, QMetaType::Void, QMetaType::QString, 5, QMetaType::Void, QMetaType::QString, 8, QMetaType::Void, QMetaType::Bool, 10, QMetaType::Void, QMetaType::Bool, 12, QMetaType::Void, QMetaType::Void, // slots: parameters QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::UShort, QMetaType::QString, 18, 19, QMetaType::Void, QMetaType::QString, QMetaType::QTime, 21, 22, QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::UShort, QMetaType::QString, QMetaType::QTime, 18, 19, 22, QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, 0 // eod }; void QtGuiApplication1::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { auto *_t = static_cast<QtGuiApplication1 *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->BeginSending((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QStringList(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3]))); break; case 1: _t->BeignListening((*reinterpret_cast< QString(*)>(_a[1]))); break; case 2: _t->updateRecvFloder((*reinterpret_cast< QString(*)>(_a[1]))); break; case 3: _t->ifcompress((*reinterpret_cast< bool(*)>(_a[1]))); break; case 4: _t->ifencryption((*reinterpret_cast< bool(*)>(_a[1]))); break; case 5: _t->StopRecv(); break; case 6: _t->BeginRecv(); break; case 7: _t->ChangeRecvState(); break; case 8: _t->showFileList(); break; case 9: _t->ShowSendingMsg((*reinterpret_cast< unsigned short(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break; case 10: _t->ShowRecvingMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QTime(*)>(_a[2]))); break; case 11: _t->SendFiles(); break; case 12: _t->StartListening(); break; case 13: _t->ShowRecvingMsgById((*reinterpret_cast< unsigned short(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QTime(*)>(_a[3]))); break; case 14: _t->selectRecvFloder(); break; case 15: _t->clearRecvTable(); break; case 16: _t->InputIP(); break; case 17: _t->compress(); break; case 18: _t->encryption(); break; default: ; } } else if (_c == QMetaObject::IndexOfMethod) { int *result = reinterpret_cast<int *>(_a[0]); { using _t = void (QtGuiApplication1::*)(QString , QStringList , QString ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&QtGuiApplication1::BeginSending)) { *result = 0; return; } } { using _t = void (QtGuiApplication1::*)(QString ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&QtGuiApplication1::BeignListening)) { *result = 1; return; } } { using _t = void (QtGuiApplication1::*)(QString ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&QtGuiApplication1::updateRecvFloder)) { *result = 2; return; } } { using _t = void (QtGuiApplication1::*)(bool ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&QtGuiApplication1::ifcompress)) { *result = 3; return; } } { using _t = void (QtGuiApplication1::*)(bool ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&QtGuiApplication1::ifencryption)) { *result = 4; return; } } { using _t = void (QtGuiApplication1::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&QtGuiApplication1::StopRecv)) { *result = 5; return; } } { using _t = void (QtGuiApplication1::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&QtGuiApplication1::BeginRecv)) { *result = 6; return; } } } } QT_INIT_METAOBJECT const QMetaObject QtGuiApplication1::staticMetaObject = { { QMetaObject::SuperData::link<QMainWindow::staticMetaObject>(), qt_meta_stringdata_QtGuiApplication1.data, qt_meta_data_QtGuiApplication1, qt_static_metacall, nullptr, nullptr } }; const QMetaObject *QtGuiApplication1::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *QtGuiApplication1::qt_metacast(const char *_clname) { if (!_clname) return nullptr; if (!strcmp(_clname, qt_meta_stringdata_QtGuiApplication1.stringdata0)) return static_cast<void*>(this); return QMainWindow::qt_metacast(_clname); } int QtGuiApplication1::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 19) qt_static_metacall(this, _c, _id, _a); _id -= 19; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 19) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 19; } return _id; } // SIGNAL 0 void QtGuiApplication1::BeginSending(QString _t1, QStringList _t2, QString _t3) { void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))), const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t2))), const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t3))) }; QMetaObject::activate(this, &staticMetaObject, 0, _a); } // SIGNAL 1 void QtGuiApplication1::BeignListening(QString _t1) { void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) }; QMetaObject::activate(this, &staticMetaObject, 1, _a); } // SIGNAL 2 void QtGuiApplication1::updateRecvFloder(QString _t1) { void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) }; QMetaObject::activate(this, &staticMetaObject, 2, _a); } // SIGNAL 3 void QtGuiApplication1::ifcompress(bool _t1) { void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) }; QMetaObject::activate(this, &staticMetaObject, 3, _a); } // SIGNAL 4 void QtGuiApplication1::ifencryption(bool _t1) { void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) }; QMetaObject::activate(this, &staticMetaObject, 4, _a); } // SIGNAL 5 void QtGuiApplication1::StopRecv() { QMetaObject::activate(this, &staticMetaObject, 5, nullptr); } // SIGNAL 6 void QtGuiApplication1::BeginRecv() { QMetaObject::activate(this, &staticMetaObject, 6, nullptr); } QT_WARNING_POP QT_END_MOC_NAMESPACE
a67af7fe0dfc912a1eae47db1371c82bbefc3a69
e272d18a042e6b6808bc615917b1783d53607870
/done/1169.cpp
5d13c44ad1ba5acccaf545119963380409561bce
[]
no_license
chessdroid/morbidel-timus
58656c7a62132aaae71289a20ee77baeca4ba554
b079bf3ae716d4eeb54722037ac55066f9e9da7c
refs/heads/master
2020-07-10T02:20:08.032088
2013-04-11T20:48:39
2013-04-11T20:48:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,337
cpp
1169.cpp
/* * ACM Timus Online * Pairs - Problem 1169 * * solution: the problem can be reformulated as follows: find x1..xk which satisfies the first two Viete relations: * x1 + x2 + ... + xi = N * x1x2 + ... + xi-1xi = K * for some i * * for a value i for x1 a pair (n, k) turns in (n - i, k - i * (n - i)). * We can recurse now: at each step we check whether we have an integer solution of degree 2 for the current pair (n, k) * If so, a solution exists with all the values for x1... until now and the 2 solutions for current (n, k) */ #include <cstdio> #include <math.h> #include <vector> int N, K; std::vector<int> S; /* a (n, k) pair is valid if the equation x^2-n*x+k=0 has integer solutions */ bool Valid(int n, int k, int &x1, int &x2) { double d = n * n - 4 * k; double dx1, dx2; if (d < 0) return false; dx1 = (n - sqrtl(d)) / 2; dx2 = (n + sqrtl(d)) / 2; if (dx1 == (int) dx1 && dx2 == (int) dx2) { x1 = dx1; x2 = dx2; return true; } return false; } void print_sol() { int i, j, node = 1; /* for (i = 0; i < S.size(); i++) printf("%d ", S[i]); printf("\n------\n");*/ if (S.size() == 0) { printf("-1"); } else { int sum = 0; for (i = 0; i < S.size(); i++) for (j = i + 1; j < S.size(); j++) sum += S[i] * S[j]; if (sum != K) { printf("ERROR, %d != K!\n", sum); } for (i = 0; i < S.size(); i++) { /* generate a sub-graph from each group -> simple circle graph */ for (j = 0; j < S[i] - 1; j++) printf("%d %d\n", node + j, node + j + 1); if (j > 0) printf("%d %d\n", node + j, node); if (i != S.size() - 1) { /* tie with next group */ printf("%d %d\n", node, node + S[i]); node += S[i]; } } } } int back(int n, int k) { int i, x1, x2; if (k < 0) return 0; if (Valid(n, k, x1, x2)) { int sol = 0; if (x1 == 2 || x2 == 2) return 0; /* horray, we have a solution! */ if (x1 > 0) { sol = 1; S.push_back(x1); } if (x2 > 0) { sol = 1; S.push_back(x2); } return sol; } else /* how much we can have in the current group */ for (i = 1; i <= n; i++) { if (i == 2) continue; S.push_back(i); if (back(n - i, k - i * (n - i))) return 1; S.pop_back(); } return 0; } int main() { scanf("%d %d", &N, &K); back(N, K); print_sol(); return 0; }
4832dda856cf379a18bf30176fdeb5dfc83b10eb
e8a494cd4aa449ce95a01db6d61f8ec2ebba0257
/editlinedialog.cpp
dd15124e67d9220340141e2c23b007d081d094e4
[]
no_license
qianlanwyd/graphics-program
df5d0442f497fcc52463c8991f83540343649351
65ce5303266e21324fd3590d0c8e51f7dbac51c3
refs/heads/master
2020-04-08T06:56:17.893251
2019-01-07T08:12:08
2019-01-07T08:12:08
159,119,333
0
0
null
null
null
null
UTF-8
C++
false
false
2,669
cpp
editlinedialog.cpp
#include "editlinedialog.h" #include "ui_editlinedialog.h" #include "openglwidget.h" #include "myshape.h" #include"changelinedialog.h" #include"rotatelinedialog.h" #include"tranlinedialog.h" #include"scalelinedialog.h" #include"QMessageBox" editlineDialog::editlineDialog(QWidget *parent) : QDialog(parent), ui(new Ui::editlineDialog) { ui->setupUi(this); ui->textBrowser->clear(); this->display(); } editlineDialog::~editlineDialog() { delete ui; } void editlineDialog::display() { int cnt = 1; list<Line*> ll = my_line->getLineList(); list<Line*>::iterator it; for (it = ll.begin(); it != ll.end(); it++){ QString lineStr = ""; lineStr.append(QString::number(cnt)); lineStr.append(". 起点坐标: ("); lineStr.append(QString::number((*it)->getx1())); lineStr.append(", "); lineStr.append(QString::number((*it)->gety1())); lineStr.append(") 终点坐标: ("); lineStr.append(QString::number((*it)->getx2())); lineStr.append(", "); lineStr.append(QString::number((*it)->gety2())); lineStr.append(")"); cnt++; ui->textBrowser->append(lineStr); } } void editlineDialog::on_pushButton_clicked() { changelineDialog *dlg = new changelineDialog(); dlg->setAttribute(Qt::WA_DeleteOnClose);//设置对话框关闭后,自动销毁 dlg->exec(); ui->textBrowser->clear(); this->display(); } void editlineDialog::on_pushButton_2_clicked() { my_line->clearAll(); ui->textBrowser->clear(); this->display(); } void editlineDialog::on_pushButton_3_clicked() { int num=ui->spinBox->value(); if(num>my_line->getLineList().size()){ QMessageBox::about(NULL, "Error", " 不合法输入! "); return; } my_line->deleteLine(num); ui->textBrowser->clear(); this->display(); } void editlineDialog::on_pushButton_4_clicked() { rotatelineDialog *dlg = new rotatelineDialog(); dlg->setAttribute(Qt::WA_DeleteOnClose);//设置对话框关闭后,自动销毁 dlg->exec(); ui->textBrowser->clear(); this->display(); } void editlineDialog::on_pushButton_5_clicked() { tranlineDialog *dlg = new tranlineDialog(); dlg->setAttribute(Qt::WA_DeleteOnClose);//设置对话框关闭后,自动销毁 dlg->exec(); ui->textBrowser->clear(); this->display(); } void editlineDialog::on_pushButton_6_clicked() { scalelineDialog *dlg = new scalelineDialog(); dlg->setAttribute(Qt::WA_DeleteOnClose);//设置对话框关闭后,自动销毁 dlg->exec(); ui->textBrowser->clear(); this->display(); }
2c548e66310143a7efb4c111f5466c4240e015f1
ae8054dca7a277c363eef6bd0a4028fd982eb3d6
/sample/Test-cam/testDlg.h
893c42fc7a532c2927a396c7a672c7611f5b472c
[]
no_license
wwang13/FaceIdentifiSystem
7116a1b6fd11daf4ee57760170b579b45d46d827
ae5c6cc145b0dae5f77e973c107a4ed65f30b019
refs/heads/TheFirstVersion
2021-01-22T06:07:16.037641
2016-08-08T06:28:54
2016-08-08T06:28:54
65,707,015
0
0
null
2016-08-15T05:35:20
2016-08-15T05:35:20
null
UTF-8
C++
false
false
1,599
h
testDlg.h
// TestDlg.h : header file // #if !defined(AFX_TESTDLG_H__85E8D483_7487_48F6_A87B_C37F8760B0A8__INCLUDED_) #define AFX_TESTDLG_H__85E8D483_7487_48F6_A87B_C37F8760B0A8__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 ///////////////////////////////////////////////////////////////////////////// // CTestDlg dialog #include "TiCapture2.h" class CTestDlg : public CDialog { // Construction public: CTestDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(CTestDlg) enum { IDD = IDD_TEST_DIALOG }; BOOL m_bEnroll; BOOL m_bIdentify; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CTestDlg) public: virtual BOOL DestroyWindow(); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL public: CCapture* m_pCap; SCapParam m_capParam; int m_iFrame; long m_nFeatureSize; BYTE* m_pEnrollFeature; // Implementation protected: HICON m_hIcon; // Generated message map functions //{{AFX_MSG(CTestDlg) virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); afx_msg void OnTimer(UINT nIDEvent); afx_msg void OnTest(); afx_msg void OnStart(); afx_msg void OnMacauTest(); afx_msg void OnEnroll(); afx_msg void OnIdentify(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_TESTDLG_H__85E8D483_7487_48F6_A87B_C37F8760B0A8__INCLUDED_)
074cf982057779d185056bde3fc7874feab1f80f
4d4822b29e666cea6b2d99d5b9d9c41916b455a9
/Example/Pods/Headers/Private/GeoFeatures/boost/mpi/packed_oarchive.hpp
040aa9ba899bea52cee225209faad23f5355d317
[ "BSL-1.0", "Apache-2.0" ]
permissive
eswiss/geofeatures
7346210128358cca5001a04b0e380afc9d19663b
1ffd5fdc49d859b829bdb8a9147ba6543d8d46c4
refs/heads/master
2020-04-05T19:45:33.653377
2016-01-28T20:11:44
2016-01-28T20:11:44
50,859,811
0
0
null
2016-02-01T18:12:28
2016-02-01T18:12:28
null
UTF-8
C++
false
false
62
hpp
packed_oarchive.hpp
../../../../../../../GeoFeatures/boost/mpi/packed_oarchive.hpp
137fbd054425a064a9ca4fdeb65ec38cc6573922
f6c11d71f88eee3e7cb3486436e407b806e8df24
/LungSeparation/main.cxx
3a2632bbc15ff768bdbcdba682a34a3acb45dc54
[]
no_license
midmelody/ToolsITK
7778f459ddea4e113d5f3eb7eef4ff8d8ea73179
e627d6bde94e0a6e9f8b382261437ea00af6ea7d
refs/heads/master
2020-04-18T00:16:59.913186
2019-04-12T13:37:39
2019-04-12T13:37:39
167,070,815
3
0
null
null
null
null
UTF-8
C++
false
false
13,017
cxx
main.cxx
#include "itkImage.h" #include "itkImageFileReader.h" #include "itkBinaryBallStructuringElement.h" #include "itkBinaryDilateImageFilter.h" #include "itkBinaryErodeImageFilter.h" #include "itkNotImageFilter.h" #include "itkHessianToObjectnessMeasureImageFilter.h" #include "itkMultiScaleHessianBasedMeasureImageFilter.h" #include "itkRescaleIntensityImageFilter.h" #include "itkBinaryThresholdImageFilter.h" #include "itkAndImageFilter.h" #include "itkConnectedComponentImageFilter.h" #include "itkRelabelComponentImageFilter.h" #include "itkSignedMaurerDistanceMapImageFilter.h" #include "itkOrImageFilter.h" #include "itkImageFileWriter.h" #include <iostream> int main( int argc, char * argv[] ) { if( argc < 5 ) { std::cerr << "Usage: " << std::endl; std::cerr << argv[0] << " inputImageFile lungMaskFile airwayMaskFile outputImageFile [GapEnhanceImage]" << std::endl; return EXIT_FAILURE; } //ITK settings const unsigned int Dimension = 3; typedef float FloatPixelType; typedef int CharPixelType; typedef itk::Image< FloatPixelType, Dimension > FloatImageType; typedef itk::Image< CharPixelType, Dimension > CharImageType; typedef itk::ImageFileReader< FloatImageType > FloatReaderType; typedef itk::ImageFileReader< CharImageType > CharReaderType; typedef itk::BinaryBallStructuringElement< CharPixelType, Dimension > StructuringElementType; typedef itk::BinaryDilateImageFilter <CharImageType, CharImageType, StructuringElementType> BinaryDilateImageFilterType; typedef itk::BinaryErodeImageFilter <CharImageType, CharImageType, StructuringElementType> BinaryErodeImageFilterType; typedef itk::NotImageFilter< CharImageType, CharImageType > InvFilterType; typedef itk::NumericTraits< FloatPixelType >::RealType RealPixelType; typedef itk::SymmetricSecondRankTensor< RealPixelType, Dimension > HessianPixelType; typedef itk::Image< HessianPixelType, Dimension > HessianImageType; typedef itk::HessianToObjectnessMeasureImageFilter< HessianImageType,FloatImageType > ObjectnessFilterType; typedef itk::MultiScaleHessianBasedMeasureImageFilter< FloatImageType, HessianImageType, FloatImageType > MultiScaleEnhancementFilterType; typedef itk::RescaleIntensityImageFilter< FloatImageType, CharImageType > RescalerType; typedef itk::BinaryThresholdImageFilter< CharImageType, CharImageType > BinaryThresholdFilterType; typedef itk::AndImageFilter< CharImageType, CharImageType, CharImageType > AndFilterType; typedef itk::ConnectedComponentImageFilter< CharImageType, CharImageType > ConnectedComponentFilterType; typedef itk::RelabelComponentImageFilter< CharImageType, CharImageType > RelabelFilterType; typedef itk::SignedMaurerDistanceMapImageFilter < CharImageType, FloatImageType > DistanceTransformFilterType; typedef itk::OrImageFilter< CharImageType, CharImageType, CharImageType > OrFilterType; typedef itk::ImageFileWriter< CharImageType > WriterType; //Filters FloatReaderType::Pointer readerI = FloatReaderType::New(); CharReaderType::Pointer readerL = CharReaderType::New(); CharReaderType::Pointer readerA = CharReaderType::New(); BinaryDilateImageFilterType::Pointer dilateFilter = BinaryDilateImageFilterType::New(); BinaryErodeImageFilterType::Pointer erodeFilter = BinaryErodeImageFilterType::New(); InvFilterType::Pointer invFilter = InvFilterType::New(); ObjectnessFilterType::Pointer objectnessFilter = ObjectnessFilterType::New(); MultiScaleEnhancementFilterType::Pointer multiScaleEnhancementFilter = MultiScaleEnhancementFilterType::New(); RescalerType::Pointer rescaleFilter = RescalerType::New(); BinaryThresholdFilterType::Pointer thresholdFilter = BinaryThresholdFilterType::New(); AndFilterType::Pointer andFilter = AndFilterType::New(); ConnectedComponentFilterType::Pointer connectComponentFilter = ConnectedComponentFilterType::New(); RelabelFilterType::Pointer relabelFilter = RelabelFilterType::New(); DistanceTransformFilterType::Pointer DTFilter = DistanceTransformFilterType::New(); OrFilterType::Pointer orFilter = OrFilterType::New(); WriterType::Pointer writer = WriterType::New(); WriterType::Pointer writerTemp = WriterType::New(); //Parameters readerI->SetFileName( argv[1] ); readerL->SetFileName( argv[2] ); readerA->SetFileName( argv[3] ); writer->SetFileName( argv[4] ); if(argc == 6) writerTemp->SetFileName( argv[5] ); //Read images - original CT image, lung mask, airway mask readerI->Update(); readerL->Update(); readerA->Update(); //Subtract airway - dilate for ensurance int radius = 2; StructuringElementType structuringElement; structuringElement.SetRadius(radius); structuringElement.CreateStructuringElement(); dilateFilter->SetInput(readerA->GetOutput()); dilateFilter->SetKernel(structuringElement); dilateFilter->SetBackgroundValue(0); dilateFilter->SetForegroundValue(1); invFilter->SetInput(dilateFilter->GetOutput()); andFilter->SetInput1(invFilter->GetOutput()); andFilter->SetInput2(readerL->GetOutput()); andFilter->Update(); CharImageType::Pointer lungWOairway = andFilter->GetOutput(); lungWOairway->DisconnectPipeline(); //Calculate gap enhancement objectnessFilter->SetBrightObject(true); objectnessFilter->SetAlpha(0.5); objectnessFilter->SetBeta(0.5); objectnessFilter->SetGamma(5.0); objectnessFilter->SetObjectDimension(2); multiScaleEnhancementFilter->SetSigmaStepMethodToLogarithmic(); multiScaleEnhancementFilter->SetSigmaMinimum( 0.1 ); multiScaleEnhancementFilter->SetSigmaMaximum( 1 ); multiScaleEnhancementFilter->SetNumberOfSigmaSteps( 10 ); multiScaleEnhancementFilter->SetInput( readerI->GetOutput() ); multiScaleEnhancementFilter->SetHessianToMeasureFilter( objectnessFilter ); multiScaleEnhancementFilter->GenerateScalesOutputOn(); multiScaleEnhancementFilter->SetGenerateScalesOutput( true ); multiScaleEnhancementFilter->SetGenerateScalesOutput( false ); multiScaleEnhancementFilter->NonNegativeHessianBasedMeasureOff(); rescaleFilter->SetInput(multiScaleEnhancementFilter->GetOutput()); rescaleFilter->SetOutputMinimum( 0 ); rescaleFilter->SetOutputMaximum( 255 ); rescaleFilter->Update(); CharImageType::Pointer gapEnh = rescaleFilter->GetOutput(); if(argc == 6) { writerTemp->SetInput( gapEnh ); writerTemp->Update(); } gapEnh->DisconnectPipeline(); //Subtract gap until 2 groups int groupCt = 1; int thre = 20; int dilateSize = 1; CharImageType::Pointer lungGroup = CharImageType::New(); StructuringElementType gapSE; gapSE.SetRadius(dilateSize); gapSE.CreateStructuringElement(); std::cout<<"First"<<std::endl; while((groupCt==1)&&(thre>2)) { std::cout<<thre<<std::endl; thresholdFilter->SetInput(gapEnh); thresholdFilter->SetOutsideValue( 0 ); thresholdFilter->SetInsideValue( 1 ); thresholdFilter->SetLowerThreshold( thre ); thresholdFilter->SetUpperThreshold( 255 ); dilateFilter->SetKernel(gapSE); dilateFilter->SetBackgroundValue(0); dilateFilter->SetForegroundValue(1); dilateFilter->SetInput(thresholdFilter->GetOutput()); invFilter->SetInput(dilateFilter->GetOutput()); andFilter->SetInput1(invFilter->GetOutput()); andFilter->SetInput2(lungWOairway); connectComponentFilter->SetInput( andFilter->GetOutput() ); connectComponentFilter->SetFullyConnected(0); relabelFilter->SetInput( connectComponentFilter->GetOutput() ); relabelFilter->SetMinimumObjectSize(1000); relabelFilter->Update(); lungGroup = relabelFilter->GetOutput(); lungGroup->DisconnectPipeline(); typedef std::vector< itk::SizeValueType > SizesInPixelsType; const SizesInPixelsType & sizesInPixels = relabelFilter->GetSizeOfObjectsInPixels(); SizesInPixelsType::const_iterator sizeItr = sizesInPixels.begin(); SizesInPixelsType::const_iterator sizeBegin = sizesInPixels.begin(); SizesInPixelsType::const_iterator sizeEnd = sizesInPixels.end(); std::cout << "Number of pixels per class " << std::endl; unsigned int kclass = 1; while( sizeItr != sizeEnd ) { std::cout << "Class " << kclass << " = " << *sizeItr << std::endl; ++kclass; ++sizeItr; } groupCt = kclass-1; thre = thre-2; /* if(groupCt > 1) { float ratio; float i1, i2; i1 = *sizeBegin; i2 = *(++sizeBegin); ratio = i1/i2; if(ratio>5) groupCt = 1; } */ } std::cout<<"Second"<<std::endl; thre = 10; dilateSize = 2; gapSE.SetRadius(dilateSize); gapSE.CreateStructuringElement(); while((groupCt==1)&&(thre>2)) { std::cout<<thre<<std::endl; thresholdFilter->SetInput(gapEnh); thresholdFilter->SetOutsideValue( 0 ); thresholdFilter->SetInsideValue( 1 ); thresholdFilter->SetLowerThreshold( thre ); thresholdFilter->SetUpperThreshold( 255 ); dilateFilter->SetKernel(gapSE); dilateFilter->SetBackgroundValue(0); dilateFilter->SetForegroundValue(1); dilateFilter->SetInput(thresholdFilter->GetOutput()); invFilter->SetInput(dilateFilter->GetOutput()); andFilter->SetInput1(invFilter->GetOutput()); andFilter->SetInput2(lungWOairway); connectComponentFilter->SetInput( andFilter->GetOutput() ); connectComponentFilter->SetFullyConnected(0); relabelFilter->SetInput( connectComponentFilter->GetOutput() ); relabelFilter->SetMinimumObjectSize(1000); relabelFilter->Update(); lungGroup = relabelFilter->GetOutput(); lungGroup->DisconnectPipeline(); typedef std::vector< itk::SizeValueType > SizesInPixelsType; const SizesInPixelsType & sizesInPixels = relabelFilter->GetSizeOfObjectsInPixels(); SizesInPixelsType::const_iterator sizeItr = sizesInPixels.begin(); SizesInPixelsType::const_iterator sizeBegin = sizesInPixels.begin(); SizesInPixelsType::const_iterator sizeEnd = sizesInPixels.end(); std::cout << "Number of pixels per class " << std::endl; unsigned int kclass = 1; while( sizeItr != sizeEnd ) { std::cout << "Class " << kclass << " = " << *sizeItr << std::endl; ++kclass; ++sizeItr; } groupCt = kclass-1; thre--; if(groupCt >1 ) { float ratio; float i1, i2; i1 = *sizeBegin; i2 = *(++sizeBegin); ratio = i1/i2; if(ratio>5) groupCt = 1; } } std::cout<<"Third"<<std::endl; thre = 5; dilateSize = 3; gapSE.SetRadius(dilateSize); gapSE.CreateStructuringElement(); while((groupCt==1)&&(thre>2)) { std::cout<<thre<<std::endl; thresholdFilter->SetInput(gapEnh); thresholdFilter->SetOutsideValue( 0 ); thresholdFilter->SetInsideValue( 1 ); thresholdFilter->SetLowerThreshold( thre ); thresholdFilter->SetUpperThreshold( 255 ); dilateFilter->SetKernel(gapSE); dilateFilter->SetBackgroundValue(0); dilateFilter->SetForegroundValue(1); dilateFilter->SetInput(thresholdFilter->GetOutput()); invFilter->SetInput(dilateFilter->GetOutput()); andFilter->SetInput1(invFilter->GetOutput()); andFilter->SetInput2(lungWOairway); connectComponentFilter->SetInput( andFilter->GetOutput() ); connectComponentFilter->SetFullyConnected(0); relabelFilter->SetInput( connectComponentFilter->GetOutput() ); relabelFilter->SetMinimumObjectSize(1000); relabelFilter->Update(); lungGroup = relabelFilter->GetOutput(); lungGroup->DisconnectPipeline(); typedef std::vector< itk::SizeValueType > SizesInPixelsType; const SizesInPixelsType & sizesInPixels = relabelFilter->GetSizeOfObjectsInPixels(); SizesInPixelsType::const_iterator sizeItr = sizesInPixels.begin(); SizesInPixelsType::const_iterator sizeBegin = sizesInPixels.begin(); SizesInPixelsType::const_iterator sizeEnd = sizesInPixels.end(); std::cout << "Number of pixels per class " << std::endl; unsigned int kclass = 1; while( sizeItr != sizeEnd ) { std::cout << "Class " << kclass << " = " << *sizeItr << std::endl; ++kclass; ++sizeItr; } groupCt = kclass-1; thre--; if(groupCt >1) { float ratio; float i1, i2; i1 = *sizeBegin; i2 = *(++sizeBegin); ratio = i1/i2; if(ratio>5) groupCt = 1; } } CharImageType::Pointer lungL = CharImageType::New(); CharImageType::Pointer lungR = CharImageType::New(); FloatImageType::Pointer lungLDT = FloatImageType::New(); FloatImageType::Pointer lungRDT = FloatImageType::New(); if(groupCt!=1) { //Write output writer->SetInput( lungGroup ); try { writer->Update(); } catch( itk::ExceptionObject & err ) { std::cout<<"ExceptionObject caught !"<<std::endl; std::cout<< err <<std::endl; return EXIT_FAILURE; } } else { std::cerr << "Failed to separate " << std::endl; return EXIT_FAILURE; } return EXIT_SUCCESS; }
f8aeec2d05306596f2b8c4a2bf3abfea00fec302
9e1e09ea61632e80465f371a083625d03b1e5ab2
/src/CryptoNoteCore/CachedTransaction.h
38d7d8a533587b3dfb8d8354320a83f11021bccc
[ "MIT" ]
permissive
bitcoin-note/bitcoin-note
0f93c5a04dda2df6ff838187d894a0c4af633649
7be1e60f327b7ce1f995fee97f80131dcb934e70
refs/heads/master
2021-05-11T19:50:51.485229
2018-01-18T00:05:24
2018-01-18T00:05:24
117,895,059
3
2
null
null
null
null
UTF-8
C++
false
false
1,034
h
CachedTransaction.h
// Copyright (c) 2018, The Bitcoin Note Developers. // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #pragma once #include <boost/optional.hpp> #include <CryptoNote.h> namespace CryptoNote { class CachedTransaction { public: explicit CachedTransaction(Transaction&& transaction); explicit CachedTransaction(const Transaction& transaction); explicit CachedTransaction(const BinaryArray& transactionBinaryArray); const Transaction& getTransaction() const; const Crypto::Hash& getTransactionHash() const; const Crypto::Hash& getTransactionPrefixHash() const; const BinaryArray& getTransactionBinaryArray() const; uint64_t getTransactionFee() const; private: Transaction transaction; mutable boost::optional<BinaryArray> transactionBinaryArray; mutable boost::optional<Crypto::Hash> transactionHash; mutable boost::optional<Crypto::Hash> transactionPrefixHash; mutable boost::optional<uint64_t> transactionFee; }; }
d7f8539220c7ca9ac9f46c7ecc76c21ac63f0338
13f1ff12873c242e56e53feed402bd1fb6b7405c
/hw4-XiaoLeS-master/src/lib/sema/SymbolManager.cpp
d5a9f45e65cc586f13e946413fc31688133c691b
[ "MIT" ]
permissive
battlebrian/CompilerDesign
4460acfc29f25345077f4b717143c3f2df3bdb46
7bd9883d94d60655e26f403cb24af2ef67f9343a
refs/heads/main
2023-08-31T09:42:37.297351
2021-10-12T15:00:45
2021-10-12T15:00:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,752
cpp
SymbolManager.cpp
#include "sema/SymbolManager.hpp" //#include "visitor/AstNodeInclude.hpp" //#include "AST/PType.hpp" #include <cstring> // SymbolEntry SymbolEntry::SymbolEntry(const char* vn, const char* k, int lev, PTypeSharedPtr pt, const char* a) { this->var_name = vn; this->kind = k; this->level = lev; this->type = pt; this->attr = a; } // SymbolTable SymbolTable::SymbolTable() {} void SymbolTable::addSymbol(const char* vn, const char* k, int lev, PTypeSharedPtr pt, const char* a) { this->entries.push_back(SymbolEntry(vn, k, lev, pt, a)); } void dumpDemarcation(const char chr) { for (size_t i = 0; i < 110; ++i) { printf("%c", chr); } puts(""); } void SymbolTable::dumpSymbol(void) { dumpDemarcation('='); printf("%-33s%-11s%-11s%-17s%-11s\n", "Name", "Kind", "Level", "Type", "Attribute"); dumpDemarcation('-'); for (auto &entry : this->entries) { printf("%-33s", entry.getVariableName()); printf("%-11s", entry.getKind()); printf("%d%-10s", entry.getLevel(), entry.getLevel()?"(local)":"(global)"); printf("%-17s", entry.getTypeCString()); printf("%-11s", entry.getAttr()); puts(""); } dumpDemarcation('-'); } bool SymbolTable::findEntry(const char* sym_name) { for (auto& entry : entries) { if(strcmp(sym_name, entry.getVariableName()) == 0) { return true; } } return false; } bool SymbolTable::findLoopVarEntry(const char* sym_name) { for (auto& entry : entries) { if(strcmp(sym_name, entry.getVariableName()) == 0 && strcmp("loop_var", entry.getKind()) == 0) { return true; } } return false; } const char* SymbolTable::getEntryKind(const char* sym_name) { for (auto& entry: entries) { if(strcmp(sym_name, entry.getVariableName()) == 0) { return entry.getKind(); } } return NULL; } void SymbolTable::setEntryDirty(const char* sym_name, int idx) { for (auto& entry: entries) { if(strcmp(sym_name, entry.getVariableName()) == 0) { entry.setDirty(idx); return; } } } bool SymbolTable::isEntryDirty(const char*sym_name, int idx) { for (auto& entry: entries) { if(strcmp(sym_name, entry.getVariableName()) == 0) { return entry.isDirty(idx); } } } PTypeSharedPtr SymbolTable::getEntryType(const char* sym_name) { for(auto& entry: entries) { if(strcmp(sym_name, entry.getVariableName()) == 0) { return entry.getType(); } } } const char* SymbolTable::getEntryAttr(const char* sym_name) { for(auto& entry: entries) { if(strcmp(sym_name, entry.getVariableName()) == 0) { return entry.getAttr(); } } } int SymbolTable::getEntryLevel(const char* sym_name) { for(auto& entry: entries) { if(strcmp(sym_name, entry.getVariableName()) == 0) { return entry.getLevel(); } } } // SymbolManager SymbolManager::SymbolManager() {} void SymbolManager::pushScope(SymbolTable *new_scope) { tables.push_back(new_scope); } void SymbolManager::popScope() { // find loop_var int count = 0; for(auto loop_var: loop_vars) { if(tables.back()->findLoopVarEntry(loop_var.c_str())) { loop_vars.erase(loop_vars.begin()+count, loop_vars.end()); break; } count++; } tables.pop_back(); } SymbolTable* SymbolManager::getTop() { return tables.back(); } bool SymbolManager::findSymbol(const char* sym_name, bool isVariable) { if (isVariable) { // Variable Node if(tables.back()->findEntry(sym_name)) { return true; } for(auto& loop_var : loop_vars) { if(strcmp(loop_var.c_str(),sym_name)==0) return true; } return false; } else { // Function Node // check current scope if(tables.back()->findEntry(sym_name)) { return true; } return false; } } bool SymbolManager::findSymbol(const char*sym_name) { for (auto& table : tables) { if (table->findEntry(sym_name)) return true; } return false; } const char* SymbolManager::getSymbolKind(const char* sym_name) { for(auto it = tables.rbegin(); it!=tables.rend(); it++) { const char* res = (*it)->getEntryKind(sym_name); if(res != NULL) return res; } return NULL; } void SymbolManager::setEntryDirty(const char* sym_name, int idx) { for (auto it = tables.rbegin(); it!=tables.rend(); it++) { if((*it)->findEntry(sym_name)) { (*it)->setEntryDirty(sym_name, idx); return; } } } bool SymbolManager::isEntryDirty(const char* sym_name, int idx) { for (auto it = tables.rbegin(); it!=tables.rend(); it++) { if((*it)->findEntry(sym_name)) { return (*it)->isEntryDirty(sym_name, idx); } } // never return true; } PTypeSharedPtr SymbolManager::getEntryType(const char* sym_name) { for(auto it = tables.rbegin(); it != tables.rend(); it++) { if((*it)->findEntry(sym_name)) { return (*it)->getEntryType(sym_name); } } } int SymbolManager::getEntryArgNum(const char* sym_name) { const char* args; for(auto it = tables.rbegin(); it != tables.rend(); it++) { if((*it)->findEntry(sym_name)) { args = (*it)->getEntryAttr(sym_name); } } int count = 0; int len = strlen(args); if(len == 0) count = 0; else { count = 1; for(int i=0; i<strlen(args); i++) { if(args[i] == ',') count++; } } return count; } const char* SymbolManager::getEntryArgType(const char* sym_name) { for(auto it = tables.rbegin(); it != tables.rend(); it++) { if((*it)->findEntry(sym_name)) { return (*it)->getEntryAttr(sym_name); } } } int SymbolManager::getSymbolLevel(const char* sym_name) { for(auto it = tables.rbegin(); it != tables.rend(); it++) { if((*it)->findEntry(sym_name)) { return (*it)->getEntryLevel(sym_name); } } } int SymbolManager::getLoopInitVal(const char* sym_name) { for(auto it = tables.rbegin(); it != tables.rend(); it++) { if((*it)->findEntry(sym_name)) { return atoi((*it)->getEntryAttr(sym_name)); } } }
566a3e61af54b5af25b03282bb282a6bef44b1d5
47fca1e24037565433c96755370381e3a89b73ef
/dialog.cpp
c3d05cf7ac726918dff630fe7491b22e0f836df5
[]
no_license
winetx-winetx/Qt-axis
b18b21ecd21bc9938b60b3af956ca02643318c98
09e44d1ca13a665b4ff1df0a1b6982af96328864
refs/heads/master
2022-01-13T07:52:38.538568
2019-06-10T12:22:19
2019-06-10T12:22:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,509
cpp
dialog.cpp
#include "dialog.h" #include "ui_dialog.h" Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); MyUiInit(); } Dialog::~Dialog() { delete mAds; delete server; mAds = nullptr; server = nullptr; delete ui; } void Dialog::MyUiInit() { ui->btn_setModeMan->setChecked(true); ui->content->setCurrentIndex(0); ui->tabWidget->setCurrentIndex(0); ui->radioButton->setChecked(true); mAds = new Ads(); server = new TcpServer("192.168.43.99", 7777); // server = new TcpServer("10.66.11.110", 7777); // server = new TcpServer("172.20.10.2", 7777); connect(server, &TcpServer::newSocket, this, &Dialog::newSocketConnectToDialog); // 每个socket都与Dialog进行连接 connect(mAds->mOperation, &Operation::setValue, this, &Dialog::setUiValue); connect(mAds->mOperation, &Operation::setUiStatus, this, &Dialog::setUiStatus); // 示教模式,设置速度的轴索引 mCurrentIndexSpeed = 0; mAxisNumber = 0; // 要先读取寄存器内的数据,然后更新界面,进行界面的初始化 emit mAds->readSpeed(mSpeedMaxValue); ui->horizontalSlider->setValue(mSpeedMaxValue[0]); ui->horizontalSlider_2->setValue(mSpeedMaxValue[1]); ui->horizontalSlider_3->setValue(mSpeedMaxValue[2]); ui->horizontalSlider_4->setValue(mSpeedMaxValue[3]); ui->horizontalSlider_9->setValue(mSpeedMaxValue[4]); ui->horizontalSlider_10->setValue(mSpeedMaxValue[5]); // 失能"移动到A点"按钮 ui->pushButton_11->setDisabled(true); // 失能"反复"按钮 ui->btn_position->setDisabled(true); } void Dialog::AllButtonReset() { ui->btn_setModeMan->setChecked(false); ui->btn_setModeAuto->setChecked(false); ui->btn_paramSet->setChecked(false); } // 切换到手动模式界面 void Dialog::on_btn_setModeMan_clicked() { AllButtonReset(); ui->btn_setModeMan->setChecked(true); ui->content->setCurrentIndex(0); } // 切换到自动模式界面 void Dialog::on_btn_setModeAuto_clicked() { AllButtonReset(); ui->btn_setModeAuto->setChecked(true); ui->content->setCurrentIndex(1); } // 切换到参数设置界面 void Dialog::on_btn_paramSet_clicked() { AllButtonReset(); ui->btn_paramSet->setChecked(true); ui->content->setCurrentIndex(2); } // 切换到示教模式 void Dialog::on_btn_setModeShow_clicked() { if (ui->btn_setModeShow->isChecked()) ui->isToShowPage->setCurrentIndex(1); else ui->isToShowPage->setCurrentIndex(0); } /* 名称:回到标记零点 * 描述:机械臂回到标记零点 */ void Dialog::on_btn_reset_clicked() { emit mAds->setStatus(-1, 11); } /* 名称:更新Ui界面数据 * 描述:从底层获取数据,然后更新到Ui界面 */ void Dialog::setUiValue(vStruct* value) { ui->label_24->setText(QString::number(value[0].position)); ui->label_26->setText(QString::number(value[1].position)); ui->label_28->setText(QString::number(value[2].position)); ui->label_30->setText(QString::number(value[3].position)); ui->label_32->setText(QString::number(value[4].position)); ui->label_34->setText(QString::number(value[5].position)); ui->label_4->setText(QString::number(value[0].speed)); ui->label_5->setText(QString::number(value[1].speed)); ui->label_6->setText(QString::number(value[2].speed)); ui->label_10->setText(QString::number(value[3].speed)); ui->label_11->setText(QString::number(value[4].speed)); ui->label_12->setText(QString::number(value[5].speed)); } void Dialog::setUiStatus(QString value) { ui->lineEdit->setText(value); } // 设置速度的槽函数 => Begin void Dialog::on_horizontalSlider_valueChanged(int value) { mSpeedMaxValue[0] = value; if (mCurrentIndexSpeed == 0) ui->horizontalSlider_5->setValue(value); emit mAds->setSpeed("0", double(value)); } void Dialog::on_horizontalSlider_2_valueChanged(int value) { mSpeedMaxValue[1] = value; if (mCurrentIndexSpeed == 1) ui->horizontalSlider_5->setValue(value); emit mAds->setSpeed("1", double(value)); } void Dialog::on_horizontalSlider_3_valueChanged(int value) { mSpeedMaxValue[2] = value; if (mCurrentIndexSpeed == 2) ui->horizontalSlider_5->setValue(value); emit mAds->setSpeed("2", double(value)); } void Dialog::on_horizontalSlider_4_valueChanged(int value) { mSpeedMaxValue[3] = value; if (mCurrentIndexSpeed == 3) ui->horizontalSlider_5->setValue(value); emit mAds->setSpeed("3", double(value)); } void Dialog::on_horizontalSlider_9_valueChanged(int value) { mSpeedMaxValue[4] = value; if (mCurrentIndexSpeed == 4) ui->horizontalSlider_5->setValue(value); emit mAds->setSpeed("4", double(value)); } void Dialog::on_horizontalSlider_10_valueChanged(int value) { mSpeedMaxValue[5] = value; if (mCurrentIndexSpeed == 5) ui->horizontalSlider_5->setValue(value); emit mAds->setSpeed("5", double(value)); } // 设置速度的槽函数 => End // 更新选定轴索引 void Dialog::on_comboBox_activated(int index) { mCurrentIndexSpeed = index; ui->horizontalSlider_5->setValue(mSpeedMaxValue[index]); } // 设定对应轴的速度 void Dialog::on_horizontalSlider_5_valueChanged(int value) { switch (mCurrentIndexSpeed) { case 0: ui->horizontalSlider->setValue(value); break; case 1: ui->horizontalSlider_2->setValue(value); break; case 2: ui->horizontalSlider_3->setValue(value); break; case 3: ui->horizontalSlider_4->setValue(value); break; case 4: ui->horizontalSlider_9->setValue(value); break; case 5: ui->horizontalSlider_10->setValue(value); break; default: break; } } void Dialog::on_btn_switch_clicked() { emit mAds->setSwitch(ui->btn_switch->isChecked()); } // 设置选定轴 => Begin void Dialog::on_radioButton_clicked() { mAxisNumber = 0; } void Dialog::on_radioButton_2_clicked() { mAxisNumber = 1; } void Dialog::on_radioButton_3_clicked() { mAxisNumber = 2; } void Dialog::on_radioButton_4_clicked() { mAxisNumber = 3; } void Dialog::on_radioButton_5_clicked() { mAxisNumber = 4; } void Dialog::on_radioButton_6_clicked() { mAxisNumber = 5; } // 设置选定轴 => End /* 名称:Move to home * 描述:意义未知 */ void Dialog::on_pushButton_21_clicked() { emit mAds->setStatus(-1, 6); } /* 名称:复位 * 描述:将机械臂复位(软件复位,此时机械臂不会进行动作) */ void Dialog::on_pushButton_19_clicked() { emit mAds->setStatus(-1, 9); } /* 名称:标记零点 * 描述:将当前位置设定为零点位置 */ void Dialog::on_pushButton_29_clicked() { emit mAds->setStatus(-1, 1); } /* 名称:正转 * 描述:按钮按下不松开,执行此函数 * 设置伺服状态机为3,控制正向旋转 */ void Dialog::on_btn_zDo_pressed() { emit mAds->setStatus(mAxisNumber, 3); } /* 名称:正转 * 描述:按钮松开,还原为原来的状态机 * 原来的状态机为0,停止状态 */ void Dialog::on_btn_zDo_released() { emit mAds->setStatus(-1, 0); } /* 名称:反转 * 描述:按钮按下不松开,执行此函数 * 设置伺服状态机为4,控制反向旋转 */ void Dialog::on_btn_fDo_pressed() { emit mAds->setStatus(mAxisNumber, 4); } /* 名称:反转 * 描述:松开按钮,还原为原来的状态机 * 原来的状态机为0,停止状态 */ void Dialog::on_btn_fDo_released() { emit mAds->setStatus(-1, 0); } /* 名称:标记A点 * 描述:先获取当前机械臂的坐标位置, * 然后将坐标点设置到伺服驱动内 */ void Dialog::on_pushButton_10_clicked() { positionStore[0] = ui->label_24->text().toDouble(); positionStore[1] = ui->label_26->text().toDouble(); positionStore[2] = ui->label_28->text().toDouble(); positionStore[3] = ui->label_30->text().toDouble(); positionStore[4] = ui->label_32->text().toDouble(); positionStore[5] = ui->label_34->text().toDouble(); QString tmp; for (int i = 0; i < 5; ++i) { tmp += QString::number(positionStore[i]) + ","; } tmp += QString::number(positionStore[5]); ui->textEdit->setText(tmp); emit mAds->setAPosition(positionStore); // 标记A点,将"移动A点"按钮设定为使能状态 ui->pushButton_11->setEnabled(true); // 标记A点,将"反复"按钮设定为使能状态 ui->btn_position->setEnabled(true); } /* 名称:移动到A点 * 描述:已经设置过A点坐标之后,执行此函数,则会控制机械臂 * 单次到达A点坐标位置 */ void Dialog::on_pushButton_11_clicked() { if (ui->btn_setModeShow->isCheckable()&&ui->textEdit->toPlainText() != "") { emit mAds->setStatus(-1, 7); } } /* 名称:清除A点 * 描述:清除A点标记,用0来替代原来的坐标位置 */ void Dialog::on_btn_chooseGCode_clicked() { for (int i = 0; i < 6; i++) positionStore[i] = 0; ui->textEdit->clear(); emit mAds->setAPosition(positionStore); // 未标记A点,将"移动到A点"按钮设为失能状态 ui->pushButton_11->setDisabled(true); // 未标记A点,将"反复"按钮设定为失能状态 ui->btn_position->setDisabled(true); } /* 名称:反复 * 描述:在标记A点动作以后,可以执行反复动作 */ void Dialog::on_btn_position_clicked() { emit mAds->setStatus(-1, 8); } /* 名称:停止 * 描述:让机械臂处于停止状态 */ void Dialog::on_btn_goOn_clicked() { emit mAds->setStatus(-1, 5); } /* 名称:新的socket与ui线程通信 * 描述:新生成的socket与ui线程进行通信,里面是socket线程与ui线程之间信号与槽的连接 */ void Dialog::newSocketConnectToDialog(TcpSocket* socket) { // 控制回复位置信息 connect(mAds->mOperation, &Operation::setValue, socket, &TcpSocket::sendDataToClient); // 每个轴的点动控制 connect(socket, &TcpSocket::ctrlPotAction, mAds->mOperation, &Operation::setStatus); // 控制状态机 connect(socket, &TcpSocket::ctrlSaveOrClearPosInfo, this, &Dialog::ctrlSaveOrClearPosInfo); // 控制机械臂按照xyz坐标点移动 connect(socket, &TcpSocket::ctrlMoveByXYZ, mAds->mOperation, &Operation::setOutMovePos); } /* 名称:控制保存或者是清除位置信息 * 描述:用来控制机械臂清除或者标记位置信息 */ void Dialog::ctrlSaveOrClearPosInfo(int act) { switch (act) { case 1: // 标记0点 on_pushButton_29_clicked(); break; case 5: // 设置为停止状态 on_btn_goOn_clicked(); break; case 6: // Move To Home on_pushButton_21_clicked(); break; case 8: // 反复 on_btn_position_clicked(); break; case 11: // 回到0点 on_btn_reset_clicked(); break; case 12: // 标记A点 on_pushButton_10_clicked(); break; case 13: // 移到A点 on_pushButton_11_clicked(); break; case 14: // 清除A点 on_btn_chooseGCode_clicked(); break; default: break; } }
35f4e6f433c37c032928bcc7219b8f3900cae383
97cec4606c28e85af46f0a66bf38d46d373a1ea6
/Example/Example.h
aee323ccbbba27436347a9428fa2662026c1d76e
[ "Apache-2.0" ]
permissive
imclab/unity3d-to-gameplay3d-physics-exporter
03619885ffb8256a9ff671164eb768ea69f9b7fd
68677d0a0c05f0831d3c0b25e53d6ab4373d4b32
refs/heads/master
2021-01-22T01:55:17.488493
2013-12-23T19:16:33
2013-12-23T19:16:33
15,624,319
1
1
null
null
null
null
UTF-8
C++
false
false
605
h
Example.h
#ifndef Example_H_ #define Example_H_ #include "gameplay.h" using namespace gameplay; /** * Simple example of how you can reload the scenes that you generate using * the Unity3D exporter at runtime for rapid iteration. */ class Example: public Game { public: Example(); void keyEvent(Keyboard::KeyEvent evt, int key); protected: void initialize(); void finalize(); void update(float elapsedTime) override {} void render(float elapsedTime); private: void LoadScene(); Scene * scene; Font * font; int sceneIndex; std::vector<std::string> sceneList; }; #endif
4402ed8a7b06405b5d12996a2d1b68523f592549
464aa9d7d6c4906b083e6c3da12341504b626404
/src/lib/entitydef/property_change.hpp
9b52f3ed6b021e14bc08e4a8305d6f3348c0906f
[]
no_license
v2v3v4/BigWorld-Engine-2.0.1
3a6fdbb7e08a3e09bcf1fd82f06c1d3f29b84f7d
481e69a837a9f6d63f298a4f24d423b6329226c6
refs/heads/master
2023-01-13T03:49:54.244109
2022-12-25T14:21:30
2022-12-25T14:21:30
163,719,991
182
167
null
null
null
null
UTF-8
C++
false
false
4,099
hpp
property_change.hpp
/****************************************************************************** BigWorld Technology Copyright BigWorld Pty, Ltd. All Rights Reserved. Commercial in confidence. WARNING: This computer program is protected by copyright law and international treaties. Unauthorized use, reproduction or distribution of this program, or any portion of this program, may result in the imposition of civil and criminal penalties as provided by law. ******************************************************************************/ #ifndef PROPERTY_CHANGE_HPP #define PROPERTY_CHANGE_HPP #include <Python.h> #include "cstdmf/smartpointer.hpp" #include "cstdmf/stdmf.hpp" #include <vector> class BinaryOStream; class BitWriter; class DataType; class PropertyOwnerBase; typedef uint8 PropertyChangeType; typedef SmartPointer< PyObject > PyObjectPtr; const PropertyChangeType PROPERTY_CHANGE_TYPE_SINGLE = 0; const PropertyChangeType PROPERTY_CHANGE_TYPE_SLICE = 1; const int MAX_SIMPLE_PROPERTY_CHANGE_ID = 60; const int PROPERTY_CHANGE_ID_SINGLE = 61; const int PROPERTY_CHANGE_ID_SLICE = 62; // ----------------------------------------------------------------------------- // Section: PropertyChange // ----------------------------------------------------------------------------- /** * This class represents a change to a property of an entity. */ class PropertyChange { public: PropertyChange( const DataType & type ); virtual uint8 addToStream( BinaryOStream & stream, const PropertyOwnerBase * pOwner, int messageID ) const = 0; virtual PropertyChangeType type() const = 0; int rootIndex() const { return path_.empty() ? this->getRootIndex() : path_.back(); } void addToPath( int index ) { path_.push_back( index ); } protected: // A sequence of child indexes ordered from the leaf to the root // (i.e. entity). For example, 3,4,6 would be the 6th property of the // entity, the 4th "child" of that property and then the 3rd "child". // E.g. If the 6th property is a list of lists called myList, this refers // to entity.myList[4][3] typedef std::vector< int32 > ChangePath; uint8 addPathToStream( BinaryOStream & stream, const PropertyOwnerBase * pOwner, int messageID ) const; void writePathSimple( BinaryOStream & stream ) const; virtual void addExtraBits( BitWriter & writer, int leafSize ) const = 0; virtual void addExtraBits( BinaryOStream & stream ) const = 0; virtual int getRootIndex() const { return 0; } const DataType & type_; //< Type of the new value(s). ChangePath path_; //< Path to the owner being changed. }; /** * This class is a specialised PropertyChange. It represents a single value of * an entity changing. */ class SinglePropertyChange : public PropertyChange { public: SinglePropertyChange( int leafIndex, const DataType & type ); virtual uint8 addToStream( BinaryOStream & stream, const PropertyOwnerBase * pOwner, int messageID ) const; virtual PropertyChangeType type() const { return PROPERTY_CHANGE_TYPE_SINGLE; } void setValue( PyObjectPtr pValue ) { pValue_ = pValue; } private: virtual void addExtraBits( BitWriter & writer, int leafSize ) const; virtual void addExtraBits( BinaryOStream & stream ) const; virtual int getRootIndex() const { return leafIndex_; } int leafIndex_; PyObjectPtr pValue_; }; /** * This class is a specialised PropertyChange. It represents a change to an * array replacing a slice of values. */ class SlicePropertyChange : public PropertyChange { public: SlicePropertyChange( Py_ssize_t startIndex, Py_ssize_t endIndex, const std::vector< PyObjectPtr > & newValues, const DataType & type ); virtual uint8 addToStream( BinaryOStream & stream, const PropertyOwnerBase * pOwner, int messageID ) const; virtual PropertyChangeType type() const { return PROPERTY_CHANGE_TYPE_SLICE; } private: virtual void addExtraBits( BitWriter & writer, int leafSize ) const; virtual void addExtraBits( BinaryOStream & stream ) const; int32 startIndex_; int32 endIndex_; const std::vector< PyObjectPtr > & newValues_; }; #endif // PROPERTY_CHANGE_HPP
6ff8851f3dc3767b7a15bfa13acc6b2cf9290338
35a3a794c94fbe9a3d9b0bcb19eaeb60c7ca6a26
/cf1105d.cpp
0e623327cc395cb71ead61f95cf8d2f79fad59fe
[]
no_license
jshky/CODE
be7eae06f8478706495ea1886233165995ba6f69
e78b61572953167091796b51a2c152780cf8c661
refs/heads/master
2021-07-06T23:55:00.038980
2020-09-20T05:44:42
2020-09-20T05:44:42
183,609,334
0
0
null
null
null
null
UTF-8
C++
false
false
2,021
cpp
cf1105d.cpp
#include<cstdio> #include<queue> #include<vector> using namespace std; const int N=1005,tx[4]={0,0,-1,1},ty[4]={1,-1,0,0}; int n,m,p,s[10],cnt[10]; bool vis[N][N]; char str[N],a[N][N]; struct Map{ int x,y; }; bool check(int x,int y,int color){ if (x<1 || x>n || y<1 || y>m || (a[x][y]-'0'!=color && a[x][y]!='.') || vis[x][y]) return false; return true; } queue<Map> q[10]; vector<Map> v; int main(){ scanf("%d%d%d",&n,&m,&p); for (int i=1;i<=p;++i) scanf("%d",&s[i]); for (int i=1;i<=n;++i){ scanf("%s",str+1); for (int j=1;j<=m;++j){ a[i][j]=str[j]; if (str[j]>='0' && str[j]<='9') q[str[j]-'0'].push((Map){i,j}),vis[i][j]=1; } } for (int i=1;;){ v.clear(); for (int t=1;t<=s[i];++t){ bool flag=0; while (!q[i].empty()){ int x=q[i].front().x,y=q[i].front().y; q[i].pop(); // printf("%d %d %d\n",i,x,y); for (int k=0;k<4;++k){ int xx=x+tx[k],yy=y+ty[k]; if (check(xx,yy,i)){ a[xx][yy]=i+'0'; flag=1; vis[xx][yy]=1; v.push_back((Map){xx,yy}); } } } if (!flag) break; for (int j=0;j<v.size();++j) q[i].push(v[j]); } bool bol=0; for (int j=1;j<=p;++j) if (!q[j].empty()){bol=1; break;} if (!bol) break; i++; if (i>p) i=1; } // printf("\n"); // for (int i=1;i<=n;++i){ // for (int j=1;j<=m;++j) printf("%c",a[i][j]); // printf("\n"); // } for (int i=1;i<=n;++i) for (int j=1;j<=m;++j) if (a[i][j]>='0' && a[i][j]<='9') cnt[a[i][j]-'0']++; for (int i=1;i<=p;++i) printf("%d ",cnt[i]); return 0; } /* 戚里绸缪意转深 洋洋流水自天心 牛羊满地无人识 逼入西山一片阴 无人能识李将军 敌国风流属使君 啦客自怜天下士 戚洋牛逼无敌啦 */
a84ac34aa6535bb441d8c924df5bf4c0b7a0ad44
92e67b30497ffd29d3400e88aa553bbd12518fe9
/assignment2/part6/Re=110/51.3/p
ecad62f5ff101e7af6d59006177655eb58c6053f
[]
no_license
henryrossiter/OpenFOAM
8b89de8feb4d4c7f9ad4894b2ef550508792ce5c
c54b80dbf0548b34760b4fdc0dc4fb2facfdf657
refs/heads/master
2022-11-18T10:05:15.963117
2020-06-28T15:24:54
2020-06-28T15:24:54
241,991,470
0
0
null
null
null
null
UTF-8
C++
false
false
21,010
p
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 7 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "51.3"; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField nonuniform List<scalar> 2000 ( 0.0373214 0.0372438 0.0374799 0.0378145 0.0382193 0.0386795 0.0391876 0.0397415 0.0403339 0.0409965 0.0376474 0.0375966 0.0378818 0.0382783 0.0387455 0.0392577 0.0397968 0.0403511 0.0409023 0.0414674 0.0378715 0.0378802 0.0382226 0.038686 0.0392195 0.0397888 0.0403677 0.0409373 0.0414715 0.0419585 0.0379854 0.0380888 0.038494 0.0390245 0.0396216 0.0402454 0.0408647 0.041457 0.0419953 0.042428 0.037988 0.038221 0.0386912 0.039284 0.0399345 0.0406017 0.0412523 0.0418639 0.0424181 0.0428228 0.0378843 0.0382801 0.038814 0.0394585 0.0401464 0.0408371 0.0414993 0.0421138 0.0426784 0.0430761 0.0376866 0.0382738 0.038866 0.0395476 0.0402504 0.0409373 0.0415819 0.0421698 0.0427189 0.0431151 0.0374175 0.0382101 0.0388535 0.0395533 0.0402437 0.0408933 0.0414841 0.042008 0.0425018 0.0428831 0.0370986 0.0381024 0.0387842 0.0394791 0.0401254 0.0406988 0.0411926 0.0416101 0.0420107 0.0423665 0.0367565 0.037964 0.0386669 0.0393306 0.0398979 0.0403512 0.0406934 0.0409363 0.0411592 0.0414289 0.0430334 0.0472593 0.0518889 0.0567082 0.0611666 0.0655496 0.0689273 0.0726112 0.0739754 0.0759334 0.0432037 0.0468584 0.0509113 0.0553159 0.0594567 0.0635739 0.0667004 0.0701686 0.0715128 0.0732961 0.0433247 0.0465505 0.0499599 0.0539445 0.0577851 0.0616561 0.064561 0.0678482 0.0691209 0.0707921 0.0433473 0.0463336 0.0490385 0.0526046 0.0561558 0.0597915 0.0625053 0.0656272 0.0668203 0.0684192 0.0432303 0.0461681 0.0481534 0.0513092 0.0545764 0.0579892 0.0605384 0.0635118 0.0646405 0.0661814 0.0429478 0.0459686 0.047313 0.0500626 0.0530406 0.0562361 0.0586338 0.0614698 0.0625559 0.0640584 0.0424927 0.0456283 0.046525 0.0488747 0.0515699 0.0545614 0.0568255 0.0595379 0.0605912 0.0620511 0.0418649 0.0450623 0.0457771 0.0477146 0.0501178 0.0529008 0.0550394 0.0576359 0.0586783 0.0601252 0.0410744 0.0442047 0.045044 0.0466602 0.0488036 0.0513779 0.053401 0.0558714 0.0568902 0.0582912 0.0403523 0.0431588 0.0441376 0.0454631 0.0473519 0.0497194 0.0516536 0.0540136 0.0550824 0.0564841 0.0399017 0.0426766 0.044079 0.0447531 0.0456982 0.0471994 0.0487035 0.0504188 0.0513897 0.0523197 0.0327897 0.0355392 0.0376499 0.0392025 0.0404933 0.0418739 0.0431314 0.0443478 0.0450603 0.0456114 0.0251912 0.0278348 0.0301377 0.0321081 0.0337981 0.0354842 0.0369056 0.0380975 0.0387054 0.0390901 0.0174939 0.019956 0.0224046 0.0247054 0.0267515 0.028704 0.0302866 0.0315888 0.0323113 0.0327539 0.010299 0.0124295 0.014832 0.0172751 0.0196422 0.0219537 0.0237849 0.0251992 0.0259986 0.0265045 0.00424166 0.00598076 0.00817669 0.0105808 0.0130557 0.0155307 0.0175487 0.0191184 0.0200263 0.0205596 -0.000169681 0.00105499 0.00278487 0.00495924 0.00745982 0.00998339 0.0119878 0.0135293 0.014459 0.0150141 -0.00262909 -0.00188622 -0.000739283 0.000913046 0.00308979 0.00545026 0.00732162 0.00872101 0.00954019 0.0100389 -0.00324876 -0.00293407 -0.0022785 -0.00115117 0.000434802 0.00220338 0.0035952 0.00465262 0.00524377 0.00563586 -0.00194315 -0.00197967 -0.00185376 -0.00137608 -0.000578798 0.000316248 0.000939977 0.00143153 0.00164024 0.00183986 0.0365831 0.0298878 0.0228514 0.0157461 0.0091439 0.00358501 -0.000436402 -0.00263972 -0.00310094 -0.00180817 0.0349942 0.0282634 0.0213878 0.0145459 0.00827641 0.0030475 -0.000678064 -0.00267415 -0.00301823 -0.00175518 0.0333146 0.0268338 0.0201686 0.0135785 0.00759994 0.00264848 -0.000829738 -0.00265349 -0.0029007 -0.00170222 0.0317938 0.0256261 0.0191741 0.0128308 0.00712891 0.00242467 -0.000851172 -0.00255011 -0.002743 -0.00161257 0.0305168 0.0246414 0.0183962 0.0122803 0.00683103 0.00234291 -0.000761702 -0.00237384 -0.00254721 -0.00147486 0.0295334 0.0238885 0.0178385 0.0119266 0.00670144 0.00239619 -0.000573794 -0.00213064 -0.00231429 -0.00131994 0.0288576 0.0233682 0.0174944 0.0117645 0.00673174 0.00257595 -0.000293608 -0.00182531 -0.00204717 -0.00115283 0.0284776 0.0230714 0.017362 0.0117802 0.00690927 0.00287096 6.98234e-05 -0.00146423 -0.0017499 -0.000975618 0.028384 0.0229884 0.0174217 0.0119591 0.00721898 0.00326801 0.00050551 -0.00105528 -0.00142764 -0.000792384 0.0285378 0.0231028 0.017654 0.0122812 0.00764205 0.00375126 0.00100089 -0.000607506 -0.00108645 -0.000607676 0.0288805 0.0233732 0.0180232 0.0127156 0.00815324 0.00430147 0.00154173 -0.000130846 -0.000732884 -0.00042562 0.0293732 0.0237674 0.018502 0.0132401 0.00873262 0.00490275 0.00211515 0.00036497 -0.000373391 -0.000249686 0.0299944 0.0242693 0.0190745 0.0138416 0.00936619 0.00554266 0.00271012 0.000871108 -1.37082e-05 -8.24934e-05 0.0307199 0.0248617 0.0197221 0.0145056 0.0100398 0.00620908 0.00331668 0.00137991 0.000341584 7.44671e-05 0.0315291 0.0255323 0.0204277 0.0152196 0.0107413 0.00689133 0.00392651 0.00188517 0.000689254 0.000220699 0.032402 0.02627 0.0211742 0.0159711 0.0114598 0.00758007 0.00453295 0.00238215 0.00102734 0.000356524 0.0333047 0.0270556 0.0219417 0.0167461 0.012186 0.00826743 0.00513106 0.00286764 0.00135504 0.000482855 0.0342284 0.0279057 0.0227445 0.0175541 0.0129265 0.00895581 0.0057216 0.00334156 0.00167313 0.000601127 0.0352988 0.028956 0.0236713 0.018455 0.0137208 0.00966679 0.00631517 0.00380849 0.00198464 0.000712148 0.0362019 0.0300004 0.0245484 0.0193209 0.0144898 0.0103485 0.00688599 0.00425611 0.00228659 0.000811399 0.0353898 0.0306338 0.0254211 0.0204911 0.0157812 0.0116344 0.00807801 0.00523228 0.00295558 0.00102663 0.0346262 0.0300949 0.0252446 0.0207246 0.0163531 0.0124563 0.00900565 0.00612162 0.00363175 0.00131875 0.0350969 0.0305947 0.0258194 0.0214232 0.0171253 0.0132823 0.00981466 0.006847 0.00417799 0.00157569 0.0359072 0.0312956 0.0265194 0.0221607 0.0178785 0.0140299 0.0105064 0.00746373 0.00466843 0.00184029 0.0372185 0.0323307 0.0274312 0.0229906 0.0186413 0.0147282 0.0111305 0.00802795 0.00514538 0.00212234 0.0389559 0.0336947 0.0285713 0.0239329 0.0194528 0.0154267 0.0117437 0.00857498 0.00561155 0.00240161 0.0409706 0.0353036 0.0298606 0.0249464 0.0203068 0.0161446 0.0123699 0.00910044 0.00600353 0.0025681 0.043025 0.0367125 0.0310466 0.0259319 0.0211659 0.0168719 0.0129866 0.00953889 0.00620596 0.00253289 0.0444215 0.0381955 0.0322597 0.02684 0.0219017 0.0174815 0.0134752 0.00980446 0.00619026 0.00233724 0.0457539 0.0387177 0.0326061 0.0271739 0.0222627 0.0178291 0.0137599 0.00993824 0.00614343 0.00219684 0.0384558 0.0379092 0.0383631 0.0391426 0.0406253 0.0425471 0.0447223 0.0474584 0.048693 0.0507521 0.039209 0.0390997 0.0397269 0.0406369 0.0423026 0.0443731 0.0466896 0.0493917 0.0509066 0.0526727 0.0395986 0.0398881 0.0408379 0.0420993 0.0441007 0.04645 0.0490179 0.0516052 0.053448 0.0546519 0.0401702 0.0406937 0.0418706 0.0434682 0.0457752 0.048398 0.0512304 0.0538808 0.055945 0.0569222 0.0408845 0.0416684 0.0430283 0.0448899 0.0474257 0.0502614 0.0533154 0.0561447 0.0583676 0.0594215 0.0416249 0.0427369 0.0443293 0.0464409 0.049174 0.0521878 0.0554215 0.058443 0.0608038 0.0620378 0.0423795 0.0438347 0.0457164 0.0481015 0.0510456 0.054247 0.057651 0.0608414 0.0633287 0.0647163 0.0431764 0.0449605 0.0471607 0.0498346 0.0530132 0.0564297 0.0600203 0.063368 0.0659718 0.0674562 0.0440312 0.0461274 0.0486638 0.0516234 0.0550518 0.058705 0.0625046 0.0660164 0.0687322 0.0702755 0.0449461 0.0473333 0.0502297 0.0534623 0.057152 0.0610523 0.0650785 0.0687685 0.071599 0.073188 0.0459224 0.0485623 0.0518549 0.0553424 0.0593098 0.0634616 0.0677295 0.0716118 0.0745643 0.0761987 0.0469595 0.0497914 0.0535273 0.0572479 0.0615165 0.0659246 0.0704507 0.0745391 0.0776245 0.0793078 0.0480345 0.0510055 0.0552186 0.0591633 0.063757 0.0684396 0.0732417 0.07755 0.0807849 0.0825203 0.0491065 0.0522 0.05689 0.0610783 0.0660137 0.0710012 0.0760952 0.0806417 0.0840537 0.085849 0.0501225 0.0533789 0.0584962 0.0629755 0.0682917 0.0736143 0.0790143 0.0838185 0.0874198 0.0892847 0.0510231 0.0545399 0.0600247 0.0648751 0.0705399 0.0762244 0.0819629 0.0870564 0.0908683 0.092819 0.0517267 0.0557263 0.0614714 0.0667169 0.0727369 0.0788197 0.0849384 0.0903559 0.0944028 0.0964603 0.0522287 0.05684 0.0627719 0.068424 0.0748186 0.0813337 0.0878779 0.0936722 0.098002 0.100202 0.0525537 0.057856 0.063965 0.0700507 0.0768485 0.0838289 0.0908285 0.0970334 0.101682 0.104068 0.0524642 0.0584907 0.0647618 0.0712589 0.0784582 0.0859476 0.093497 0.100252 0.105357 0.108025 0.0541283 0.0618669 0.0685324 0.075847 0.0838288 0.0922774 0.100839 0.108641 0.114647 0.117923 0.0628497 0.070377 0.0775257 0.0861589 0.0955599 0.105604 0.115767 0.124997 0.132076 0.135874 0.0722517 0.0803383 0.0885233 0.0986709 0.109626 0.121438 0.133215 0.143758 0.151751 0.156052 0.0820123 0.0910934 0.100832 0.112721 0.125475 0.139299 0.152702 0.16451 0.173296 0.177884 0.0921234 0.102533 0.114094 0.12787 0.142631 0.158569 0.173542 0.186566 0.196013 0.201027 0.102885 0.11471 0.128261 0.14401 0.160894 0.178889 0.19534 0.209468 0.219253 0.224013 0.113751 0.12713 0.142583 0.160234 0.179198 0.198978 0.216805 0.231787 0.241566 0.2465 0.124482 0.139171 0.156375 0.175827 0.196745 0.218035 0.237355 0.253182 0.262482 0.265335 0.132315 0.148213 0.166743 0.187563 0.209945 0.232382 0.253114 0.269581 0.278291 0.282235 0.138041 0.154468 0.173918 0.195718 0.219145 0.242643 0.265142 0.284476 0.296172 0.283537 0.0518165 0.0598699 0.0681773 0.0772007 0.086389 0.0965682 0.106477 0.116837 0.1239 0.129552 0.0513676 0.0597674 0.0677956 0.0765569 0.0854122 0.0952781 0.104737 0.114731 0.121124 0.126584 0.0514548 0.060349 0.0683244 0.0770067 0.0856956 0.0952685 0.104298 0.113692 0.119266 0.124266 0.0513425 0.0604192 0.0683181 0.0769659 0.0855257 0.0948748 0.103546 0.112465 0.117527 0.12208 0.0511519 0.0601902 0.0679877 0.0765128 0.0848876 0.0939887 0.102317 0.110884 0.115685 0.119919 0.0509631 0.059893 0.0677004 0.0760348 0.084201 0.0930155 0.100996 0.109246 0.11387 0.117884 0.050761 0.0596262 0.0674532 0.0756564 0.083659 0.0922036 0.0998716 0.107813 0.112271 0.116101 0.0505415 0.0593821 0.0672256 0.0753342 0.083262 0.0915809 0.0990305 0.106656 0.110997 0.114635 0.0503233 0.0591624 0.0670301 0.0750766 0.0829538 0.0911027 0.0984627 0.105726 0.110078 0.113485 0.0501318 0.0589848 0.0668884 0.0749049 0.0827365 0.0907751 0.0980731 0.105065 0.109446 0.112635 0.0499908 0.0588646 0.0668178 0.0748325 0.0826346 0.0906078 0.0978457 0.104677 0.109057 0.112089 0.0498923 0.0587896 0.0668141 0.0748557 0.0826565 0.0906044 0.097802 0.104547 0.10891 0.111843 0.0498063 0.0587325 0.066862 0.0749621 0.0827973 0.0907649 0.0979597 0.104665 0.10902 0.11189 0.0497166 0.0586878 0.0669561 0.0751441 0.0830519 0.0910854 0.0983182 0.105026 0.109387 0.112221 0.0496079 0.0586603 0.0670933 0.0753978 0.0834199 0.0915633 0.0988773 0.105631 0.110016 0.112831 0.0494498 0.0586458 0.0672581 0.0757101 0.0838889 0.092181 0.09962 0.106463 0.110887 0.113711 0.0492053 0.0586407 0.0674374 0.0760751 0.0844581 0.0929434 0.10056 0.107526 0.11201 0.114863 0.048801 0.0585972 0.0675773 0.0764394 0.0850672 0.0937849 0.101636 0.108768 0.113342 0.11628 0.0482769 0.0585773 0.0677346 0.0768577 0.0857758 0.0947676 0.102904 0.110229 0.114924 0.117971 0.0472035 0.0581702 0.0675533 0.0769708 0.0862125 0.0955308 0.104059 0.1117 0.116626 0.119926 0.0480479 0.0596451 0.0693037 0.0792159 0.0891143 0.0990007 0.10825 0.116378 0.121846 0.125392 0.0570727 0.0676772 0.0770115 0.0875949 0.098395 0.109409 0.119925 0.129089 0.135361 0.138926 0.066497 0.0772433 0.0872541 0.0990132 0.11105 0.123671 0.135794 0.146365 0.153567 0.157338 0.0756578 0.087132 0.0986218 0.112132 0.12607 0.141063 0.155417 0.16809 0.176901 0.181342 0.0845518 0.0972498 0.110686 0.126286 0.142722 0.160761 0.178086 0.193937 0.205539 0.211602 0.0934381 0.107634 0.123359 0.141299 0.160799 0.1824 0.203562 0.224024 0.240465 0.250566 0.101776 0.117743 0.135646 0.15613 0.17903 0.20437 0.230447 0.257427 0.281799 0.300907 0.109866 0.127344 0.147386 0.170515 0.19679 0.226149 0.258487 0.294216 0.331501 0.369677 0.114296 0.132977 0.15463 0.179741 0.208959 0.242708 0.282445 0.329791 0.388287 0.460547 0.117808 0.13854 0.161871 0.189136 0.221661 0.260654 0.308867 0.37115 0.459858 0.579611 0.0447936 0.0530808 0.0609611 0.0692825 0.0771662 0.0855977 0.0925597 0.100317 0.104236 0.106112 0.0439225 0.0522206 0.0599635 0.067871 0.0753107 0.0834177 0.0898004 0.097329 0.100784 0.103133 0.0436505 0.0520849 0.0598448 0.0674871 0.074591 0.0822542 0.0881399 0.0951867 0.0980756 0.101633 0.0433324 0.0516165 0.0591925 0.0666138 0.0734256 0.0806743 0.0861458 0.0927055 0.0951506 0.0993358 0.0430468 0.0509318 0.0581181 0.0653217 0.0717576 0.0785715 0.0836397 0.0897554 0.0918304 0.0959587 0.0428535 0.0502342 0.0570262 0.0638651 0.069961 0.0762912 0.0809479 0.0866275 0.0883549 0.0920677 0.0427415 0.0495627 0.0559888 0.0623966 0.0681876 0.0740512 0.0783369 0.0835793 0.0849979 0.0882459 0.0427064 0.0489148 0.054959 0.06096 0.066422 0.071853 0.0758864 0.0806854 0.0818998 0.0847651 0.0427513 0.048302 0.053922 0.0595363 0.0646598 0.0696923 0.0735394 0.0778892 0.0790816 0.0816233 0.0428682 0.0477441 0.0528935 0.0581165 0.062905 0.0675877 0.0712173 0.0751845 0.0764821 0.0787015 0.0364215 0.0378098 0.0385133 0.0391182 0.0395735 0.0398673 0.0400063 0.0399908 0.0398264 0.0393703 0.036131 0.0376599 0.0383398 0.0388604 0.0391787 0.0392919 0.0392168 0.0389619 0.0385541 0.0379594 0.0359184 0.0375341 0.0381676 0.0385839 0.038751 0.038678 0.0383962 0.0379299 0.0373324 0.0366133 0.0358193 0.0374577 0.038025 0.0383243 0.0383364 0.0380838 0.0376121 0.0369598 0.0361958 0.0353288 0.0358695 0.0374603 0.0379461 0.038123 0.037985 0.0375678 0.036929 0.0361185 0.0352106 0.0341979 0.0361018 0.0375732 0.0379669 0.0380216 0.0377436 0.0371806 0.0363992 0.0354565 0.0344256 0.033283 0.0365433 0.0378268 0.0381212 0.0380563 0.0376497 0.036959 0.0360568 0.0350045 0.033869 0.0326195 0.0372128 0.0382466 0.0384355 0.038253 0.0377269 0.0369232 0.0359179 0.0347738 0.0335505 0.0322191 0.0381159 0.0388485 0.0389243 0.0386237 0.0379836 0.0370771 0.0359817 0.0347596 0.0334625 0.0320649 0.0392294 0.039629 0.0395859 0.0391644 0.0384123 0.0374098 0.0362339 0.0349453 0.0335872 0.0321391 0.0404948 0.0405617 0.0404015 0.0398561 0.0389937 0.0378995 0.0366503 0.0353039 0.0338975 0.0324195 0.0419499 0.0416531 0.0413551 0.0406753 0.0396991 0.0385159 0.0371994 0.0358033 0.0343614 0.0328683 0.0435295 0.0428554 0.0424056 0.0415836 0.0404926 0.0392242 0.037847 0.0364097 0.0349447 0.0334496 0.0451661 0.0441163 0.0435059 0.0425377 0.0413338 0.0399861 0.0385563 0.0370876 0.0356124 0.0341288 0.0467925 0.04538 0.0446052 0.0434918 0.0421812 0.0407632 0.0392909 0.0378018 0.0363306 0.0348744 0.0483381 0.046587 0.0456513 0.0444006 0.0429945 0.0415184 0.0400162 0.0385194 0.037067 0.0356563 0.0497329 0.0476782 0.0465943 0.0452222 0.043737 0.0422188 0.0407017 0.0392105 0.0377906 0.0364411 0.050911 0.0485985 0.0473896 0.0459203 0.0443784 0.0428379 0.0413229 0.0398501 0.0384694 0.0371886 0.051815 0.0493003 0.0480001 0.0464667 0.0448962 0.0433564 0.0418617 0.0404138 0.0390624 0.0378639 0.0523981 0.0497457 0.0483973 0.0468415 0.0452783 0.0437686 0.0423154 0.0408974 0.0395644 0.0384752 0.0526263 0.049907 0.0485608 0.0470319 0.0455207 0.0440865 0.0427332 0.0414382 0.0402655 0.039492 0.0524753 0.0497654 0.0484762 0.0470248 0.0456077 0.0442809 0.0430486 0.0418878 0.040841 0.0401291 0.0519379 0.0493165 0.0481395 0.0468144 0.0455295 0.044337 0.043241 0.0422208 0.0412966 0.0406124 0.0510261 0.0485695 0.0475569 0.0464046 0.0452888 0.0442595 0.0433221 0.0424605 0.0416829 0.0410892 0.0497683 0.0475457 0.0467453 0.0458092 0.044898 0.0440608 0.0433065 0.0426231 0.0420117 0.0415494 0.0482072 0.0462779 0.0457305 0.0450498 0.0443761 0.0437584 0.04321 0.0427235 0.0422948 0.0419838 0.0463968 0.0448072 0.0445456 0.0441535 0.0437463 0.0433726 0.0430505 0.0427782 0.0425493 0.0424077 0.0443976 0.0431804 0.0432276 0.0431504 0.0430338 0.0429248 0.0428465 0.0428034 0.0427901 0.0428374 0.0422745 0.041446 0.0418151 0.0420709 0.0422635 0.0424356 0.042615 0.0428129 0.0430276 0.0432818 0.0401068 0.0396571 0.0403473 0.040945 0.0414584 0.0419227 0.0423698 0.0428173 0.0432691 0.0437442 0.0380005 0.037881 0.0388698 0.0398043 0.0406414 0.0414032 0.0421232 0.0428248 0.0435183 0.0442249 0.0359036 0.0361189 0.0373988 0.0386652 0.0398254 0.0408859 0.0418806 0.0428374 0.0437729 0.0447171 0.033881 0.0344142 0.0359645 0.0375479 0.039024 0.040379 0.0416454 0.0428541 0.0440256 0.0452054 0.0319825 0.0328055 0.0345922 0.0364692 0.0382466 0.0398867 0.0414173 0.0428701 0.0442653 0.0456675 0.0302417 0.0313195 0.0332967 0.035441 0.0374996 0.0394099 0.0411931 0.042879 0.0444807 0.0460777 0.0286783 0.0299722 0.032097 0.0344709 0.0367864 0.0389482 0.0409688 0.0428746 0.0446656 0.046412 0.0273045 0.0287726 0.0310064 0.0335688 0.0361076 0.0384999 0.0407406 0.0428529 0.0448247 0.0466612 0.0261269 0.0277293 0.0300299 0.0327365 0.0354654 0.0380632 0.040506 0.0428097 0.0449447 0.0468838 0.0251465 0.0268458 0.0291716 0.0319763 0.0348585 0.0376351 0.0402635 0.0427549 0.0450623 0.0471119 0.0243602 0.026122 0.0284333 0.0312895 0.0342841 0.0372084 0.0399993 0.0426669 0.0451836 0.0474179 0.023758 0.0255526 0.0278136 0.0306752 0.0337385 0.0367772 0.0397096 0.0425545 0.0454113 0.0482196 0.0233077 0.0251225 0.0273073 0.0301319 0.0332167 0.0363216 0.0393389 0.042252 0.0451428 0.0479509 0.023017 0.0248319 0.0269151 0.0296615 0.0327199 0.0358407 0.0388908 0.0418194 0.0446731 0.0474121 0.0228789 0.0246741 0.0266351 0.0292683 0.0322591 0.0353566 0.0384112 0.0413535 0.0442078 0.0469219 0.0228785 0.0246379 0.0264636 0.0289565 0.0318464 0.0348907 0.0379296 0.0408802 0.0437484 0.0464656 0.0230007 0.0247118 0.0263955 0.0287288 0.0314908 0.0344559 0.0374588 0.0404037 0.0432784 0.0460089 0.0232307 0.0248838 0.0264242 0.0285854 0.0311984 0.0340613 0.0370091 0.039934 0.0428057 0.0455503 0.0235534 0.0251414 0.0265416 0.0285247 0.0309732 0.0337148 0.0365902 0.0394824 0.0423431 0.0450995 0.0239548 0.0254714 0.0267379 0.0285426 0.0308168 0.033422 0.03621 0.0390577 0.0419003 0.0446663 0.0244282 0.0258664 0.0270059 0.0286348 0.0307291 0.033186 0.0358731 0.0386656 0.0414833 0.0442582 0.0249779 0.0263308 0.0273489 0.0288054 0.0307157 0.0330136 0.0355865 0.0383119 0.0410971 0.0438793 0.0255506 0.0268225 0.0277336 0.0290308 0.0307624 0.0328978 0.0353476 0.0379961 0.04074 0.0435236 0.0261479 0.0273415 0.0281568 0.0293068 0.0308661 0.0328371 0.0351555 0.0377163 0.0404079 0.0431805 0.0267675 0.0278839 0.0286129 0.0296272 0.0310217 0.0328281 0.0350077 0.0374697 0.040096 0.0428413 0.0274029 0.0284429 0.0290941 0.0299846 0.0312234 0.0328672 0.0349023 0.0372544 0.0398005 0.0424979 0.0280487 0.0290128 0.0295937 0.0303721 0.0314656 0.032951 0.034838 0.0370699 0.0395185 0.0421405 0.028701 0.0295894 0.0301067 0.0307843 0.0317437 0.0330769 0.0348146 0.036918 0.0392518 0.0417627 0.0293571 0.0301696 0.0306291 0.0312165 0.0320535 0.0332427 0.0348326 0.0368036 0.03901 0.0413661 0.0300153 0.0307515 0.0311582 0.0316655 0.0323921 0.0334469 0.0348939 0.0367358 0.0388209 0.040993 0.0306748 0.0313338 0.0316923 0.0321289 0.0327571 0.0336882 0.0349967 0.0367103 0.038706 0.0407173 0.0313355 0.0319156 0.0322298 0.0326044 0.033146 0.0339665 0.0351497 0.0367604 0.0388463 0.0411987 0.031998 0.0324954 0.0327692 0.0330907 0.0335569 0.0342746 0.0353262 0.0367712 0.0386756 0.0408711 0.0326614 0.0330737 0.0333114 0.0335884 0.0339895 0.0346115 0.0355307 0.0367966 0.0384645 0.0404249 0.0333239 0.0336495 0.0338561 0.0340977 0.0344462 0.0349859 0.0357864 0.0368965 0.0383666 0.0401107 0.0339818 0.0342207 0.0344023 0.0346189 0.0349288 0.0354029 0.0361032 0.0370777 0.0383736 0.0399222 0.0346294 0.034784 0.0349479 0.0351509 0.0354373 0.0358636 0.0364824 0.0373378 0.0384723 0.0398416 0.0352586 0.0353342 0.0354897 0.0356916 0.0359702 0.0363671 0.0369237 0.037678 0.0386657 0.0398681 0.0358578 0.0358648 0.0360221 0.0362365 0.0365235 0.0369097 0.0374246 0.0380974 0.0389554 0.0400035 0.0364129 0.0363669 0.0365374 0.0367785 0.0370901 0.0374842 0.0379777 0.03859 0.0393377 0.040244 0.0369072 0.0368302 0.0370266 0.037308 0.0376596 0.0380791 0.038571 0.0391438 0.0398025 0.0405799 ) ; boundaryField { inlet { type zeroGradient; } outlet { type fixedValue; value uniform 0; } cylinder { type zeroGradient; } top { type symmetryPlane; } bottom { type symmetryPlane; } defaultFaces { type empty; } } // ************************************************************************* //