blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c1824a6383eaa5a7459ba96416e472f09571b378 | 4f05236606d5dbd483e5d0ae9e99d82f7eb94636 | /EclipseStudio/Sources/Editors/Terrain2Editor.h | bd5ff00fdadf330413b9a9acb4261c6d9f7d71ab | [] | no_license | Mateuus/newundead | bd59de0b81607c03cd220dced3dac5c6d5d2365f | c0506f26fa7f896ba3b94bb2ae2878517bd0063a | refs/heads/master | 2020-06-03T14:20:00.375106 | 2014-09-23T03:58:13 | 2014-09-23T03:58:13 | 22,456,183 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,394 | h | #pragma once
#include "../UndoHistory/UndoHistory.h"
#if !defined(FINAL_BUILD) && !defined(WO_SERVER)
class Terrain2Editor
{
public:
friend class CHeightChanged2;
friend class CLayerMaskPaint2;
friend class CLayerColorPaint2;
friend class CLayerMaskEraseAll2;
typedef r3dTL::TArray< float > Floats;
typedef r3dTL::TArray< PxI16 > Shorts;
typedef r3dTL::TArray< r3dTexture* > PaintMasks;
typedef r3dTL::TArray< uint32_t > UInts;
typedef r3dTL::TArray< r3dPoint3D > Vectors;
struct NoiseParams
{
r3dPerlinNoise noise;
float maxHeight;
float minHeight;
float heightApplySpeed;
int heightRelative;
bool painting_;
struct cell_s
{
float org; // original terrain height
float trg; // calculated noisy terrain
float mc; // current morph coef
};
cell_s* noiseData;
int Width;
int Height;
NoiseParams();
~NoiseParams();
void DrawNoiseParams( float& SliderX, float& SliderY );
void ResetCache();
float GetNoise( int x, int y );
void Apply( const r3dPoint3D& pos, float radius, float hardiness );
} noiseParams;
public:
Terrain2Editor();
~Terrain2Editor();
public:
void LoadHeightsFromTerrain();
void SaveHeightsToTerrain();
void FinalizeHeightEditing();
void LoadColorsFromTerrain();
int AreHeightsLoaded() const;
void ApplyHeightBrush(const r3dPoint3D &pnt, const float strength, const float radius, const float hardness);
void ApplyHeightLevel(const r3dPoint3D &pnt, const float H, const float strength, const float radius, const float hardness);
void ApplyHeightSmooth(const r3dPoint3D &pnt, const float radius);
void ApplyHeightErosion(const r3dPoint3D &pnt, const float strength, const float radius, const float hardness);
void ApplyHeightNoise(const r3dPoint3D &pnt, const float radius, const float hardness);
void ApplyHeightRamp(const r3dPoint3D& rampStart, const r3dPoint3D& rampEnd, const float rampWidthOuter, const float rampWidthInner);
void StartLayerBrush( int layerIdx );
void ApplyLayerBrush(const r3dTerrainPaintBoundControl& boundCtrl, const r3dPoint3D &pnt, int opType, int layerIdx, float val, const float radius, const float hardness );
void EndLayerBrush();
void StartEraseAllBrush();
void ApplyEraseAllBrush(const r3dTerrainPaintBoundControl& boundCtrl, const r3dPoint3D &pnt, const float val, const float radius, const float hardness );
void EndEraseAllBrush();
void StartColorBrush();
void ApplyColorBrush( const r3dTerrainPaintBoundControl& boundCtrl, const r3dPoint3D &pnt, const r3dColor &dwColor, const float strength, const float radius, const float hardness );
void EndColorBrush();
int ImportHeight( const char* path, float scale, float offset );
int ExportHeight( const char* path );
void UpdateHeightRect( const RECT& rc );
void UpdateTerrainHeightRect( const RECT& rc );
r3dTexture* GetPaintMask( int idx );
void BeginUndoRecord ( const char * title, UndoAction_e eAction );
void EndUndoRecord ();
bool IsUndoRecord () const { return m_UndoItem != NULL; }
IUndoItem* GetUndoRecord () const { return m_UndoItem; }
int IsHeightDirty() const;
int GetMaskCount() const;
private:
int m_PaintLayerIdx;
PaintMasks m_PaintLayerMasks;
r3dTexture* m_ColorTex;
Floats m_FloatHeights;
Floats m_TempFloatHeights;
Vectors m_TempVectors0;
Vectors m_TempVectors1;
Shorts m_ShortHeights;
IUndoItem* m_UndoItem;
int m_HeightDirty;
} extern * g_pTerrain2Editor;
//------------------------------------------------------------------------
class CHeightChanged2 : public IUndoItem
{
public:
struct UndoHeight_t
{
int nIndex;
float fPrevHeight;
float fCurrHeight;
};
private:
static const UndoAction_e ms_eActionID = UA_TERRAIN2_HEIGHT;
r3dTL::TArray< UndoHeight_t > m_pData;
RECT m_rc;
public:
void Release ();
UndoAction_e GetActionID ();
void Undo ();
void Redo ();
void AddData ( const UndoHeight_t & data );
void AddRectUpdate ( const RECT &rc );
CHeightChanged2 ();
static IUndoItem* CreateUndoItem ();
static void Register();
};
//------------------------------------------------------------------------
class CLayerMaskPaint2 : public IUndoItem
{
public:
struct PaintData_t
{
PaintData_t();
uint16_t * pData; // old data + new data
RECT rc;
int LayerIdx;
};
private:
static const UndoAction_e ms_eActionID = UA_TERRAIN2_MASK_PAINT;
r3dTL::TArray< PaintData_t > m_pData;
RECT m_rc;
public:
void Release ();
UndoAction_e GetActionID ();
void UndoRedo ( bool redo );
void Undo ();
void Redo ();
void AddData ( const PaintData_t & data );
void AddRectUpdate ( const RECT &rc );
CLayerMaskPaint2();
static IUndoItem * CreateUndoItem ();
static void Register();
};
//------------------------------------------------------------------------
class CLayerMaskEraseAll2 : public IUndoItem
{
public:
struct PaintData_t
{
PaintData_t();
r3dTL::TArray< r3dTL::TArray< uint16_t > > masks; // old data + new data
RECT rc;
};
private:
static const UndoAction_e ms_eActionID = UA_TERRAIN2_MASK_ERASEALL;
r3dTL::TArray< PaintData_t > m_pData;
int m_MaskCount;
RECT m_rc;
public:
void Release ();
UndoAction_e GetActionID ();
void UndoRedo ( bool redo );
void Undo ();
void Redo ();
void AddData ( const PaintData_t & data );
void AddRectUpdate ( const RECT &rc );
CLayerMaskEraseAll2();
static IUndoItem * CreateUndoItem ();
static void Register();
};
//------------------------------------------------------------------------
class CLayerColorPaint2 : public IUndoItem
{
public:
struct UndoColor_t
{
int nIndex;
uint32_t dwPrevColor;
uint32_t dwCurrColor;
};
private:
static const UndoAction_e ms_eActionID = UA_TERRAIN2_COLOR_PAINT;
r3dTL::TArray< UndoColor_t > m_pData;
RECT m_rc;
int m_CellCount;
public:
void Release ();
UndoAction_e GetActionID ();
void UndoRedo ( bool redo );
void Undo ();
void Redo ();
void AddData ( const UndoColor_t & data );
void AddRectUpdate ( const RECT &rc );
CLayerColorPaint2 ();
static IUndoItem * CreateUndoItem ();
static void Register();
};
//------------------------------------------------------------------------
class CTerrain2DestroyLayer : public IUndoItem
{
public:
typedef r3dTL::TArray< float > Floats;
public:
CTerrain2DestroyLayer();
public:
void Release ();
UndoAction_e GetActionID ();
void Undo ();
void Redo ();
void SetData ( int layerIdx );
static IUndoItem * CreateUndoItem ();
static void Register();
private:
static const UndoAction_e ms_eActionID = UA_TERRAIN2_DESTROY_LAYER;
r3dTerrainLayer m_TerrainLayer;
Floats m_TerrainLayerData;
int m_TerrainLayerIdx;
};
//------------------------------------------------------------------------
class CTerrain2InsertLayer : public IUndoItem
{
public:
typedef r3dTL::TArray< float > Floats;
public:
CTerrain2InsertLayer();
public:
void Release ();
UndoAction_e GetActionID ();
void Undo ();
void Redo ();
void SetData ( int layerIdx );
static IUndoItem * CreateUndoItem ();
static void Register();
private:
static const UndoAction_e ms_eActionID = UA_TERRAIN2_INSERT_LAYER;
int m_TerrainLayerIdx;
};
#endif | [
"muvucasbars@outlook.com"
] | muvucasbars@outlook.com |
cf8f920501b1325838eaa3803a5c803ebc5e429a | d77728922f20f5ec6e69e462c9ddb35e4872945c | /chap05/plotter/main.cpp | 36cf8fad48ec3179f4404c98c6bfd23a9afae5db | [] | no_license | JackHuang21/qtbookcode | c51ae2def6fa243ad9cfe649c6c7230749450904 | 7bb315b74e925042de02c9f0cdf63b61ed9f817b | refs/heads/main | 2023-04-09T23:46:55.428674 | 2021-04-26T02:13:47 | 2021-04-26T02:13:47 | 325,927,771 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 737 | cpp | #include <QApplication>
#include "plotter.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Plotter plotter;
plotter.setWindowTitle(QObject::tr("Jambi Plotter"));
int numPoints = 100;
QVector<QPointF> points0;
QVector<QPointF> points1;
for (int i = 0; i < numPoints; ++ i)
{
points0.append(QPointF(i, uint(qrand()) % 100));
points1.append(QPointF(i, uint(qrand()) % 100));
}
plotter.setCurveData(0, points0);
plotter.setCurveData(1, points1);
PlotSettings settings;
settings.minX = 0.0;
settings.maxX = 100.0;
settings.minY = 0.0;
settings.maxY = 100.0;
plotter.setPlotSettings(settings);
plotter.show();
return a.exec();
}
| [
"q994702390@gmail.com"
] | q994702390@gmail.com |
6d73916f1af12c6c86a68ac21d627bfec77b7cd0 | 333cb2c948944caabfd7a03453f69777aed1138b | /input.cpp | f3858c9e4db49e5d5696b5f2094002b60f3be70e | [] | no_license | gloriohenry/OOP2021 | 956bcf4fcfcad081a89fb5e50db0de9d54169f24 | 11ed8d9f1d1c688c76c8adfed4427e3193a77446 | refs/heads/main | 2023-04-29T08:06:43.835949 | 2021-05-15T14:29:49 | 2021-05-15T14:29:49 | 338,977,821 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 313 | cpp | #include <iostream>
using namespace std;
int main()
{
string nama;
int umur;
cout << "Nama Anda: ";
getline(cin, nama);
cout << "Umur Anda: ";
cin >> umur;
cout << "Nama Anda adalah: " << nama << endl;
cout << "Anda berumur: " << umur << " tahun." << endl;
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
50316c93e28164a477124d426356df40566b6bc5 | ce4fed088cf6c631ae5b3b2cfb0a6fdeb8cfff11 | /Project1/PlayerObject.cpp | 989ccaef0ccfa580d3aa076d07b15fe10828ea3b | [] | no_license | superoirNathan/Duel | bed8ebaafbaeaa7187e8ed8103aa2dc4458b6015 | f287add5db1a5e8aeafadebc2ed8463b627b92ab | refs/heads/master | 2021-05-04T22:18:53.587024 | 2020-06-05T20:27:11 | 2020-06-05T20:27:11 | 120,023,648 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,734 | cpp | #include "PlayerObject.h"
#include <iostream>
PlayerObject::PlayerObject()
{
numbOfBullets = 5;
bulletCDLength = 1.0;
for (int i = 0; i < numbOfBullets; i++)
BulletBounceNum.push_back(0.f);
for (int i = 0; i < numbOfBullets;i++)
BulletMoveVal.push_back(glm::vec3(0.0f));
for (int i = 0; i < numbOfBullets;i++) {
bulletHitSheild.push_back(false);
bulletHitPillar2.push_back(false);
bulletAlive.push_back(false);
}
}
PlayerObject::~PlayerObject()
{
}
void PlayerObject::Shoot(GameObject* Player, std::vector<GameObject*> Bullets, Input::Stick rStick)
{
if (this->once == false || this->CD == true)
return;
Bullets[BulletNum]->translate = glm::translate(Bullets[BulletNum]->translate, Player->position); // This moves the Bullet to the Players Position
Bullets[BulletNum]->position = glm::vec3(Bullets[BulletNum]->translate * glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));//set position of object
this->BulletBounceNum[BulletNum] = 0;
Bullets[BulletNum]->rotate = glm::rotate(Bullets[BulletNum]->rotate, Player->localRotation, glm::vec3(0.f, 1.f, 0.f)); // This rotates the Bullet to the same rotation as the player
this->bulletHitSheild[BulletNum] = false;
this->bulletHitPillar2[BulletNum] = false;
bulletAlive[BulletNum] = true;
BulletMove = true; // This bool makes bullet still move after RT is done being pressed
if (shouldBulletMove && sqrt(rStick.yAxis*rStick.yAxis + rStick.xAxis*rStick.xAxis) != 0.f) // Shoots Bullet in Direction the player is facing w/ the right stick
{
BulletMoveVal[BulletNum].x = 1.0 * glm::cos(((glm::atan(rStick.yAxis, rStick.xAxis)) * (180.f / glm::pi<float>()) * float(0.0174533))) * +0.5; // This moves the bullet based on the X angle of RS
BulletMoveVal[BulletNum].y = 1.0 * glm::sin(((glm::atan(rStick.yAxis, rStick.xAxis)) * (180.f / glm::pi<float>()) * float(0.0174533))) * -0.5; // This moves the bullet based on the Y angle of RS
//shouldBulletMove = false;
}
if (sqrt(rStick.yAxis*rStick.yAxis + rStick.xAxis*rStick.xAxis) == 0.f) // Shoots Bullet if player chooses Direction inside the deadzone
{
BulletMoveVal[BulletNum].x = 1.0 * glm::cos(((glm::atan(PrevStickY, PrevStickX)) * (180.f / glm::pi<float>()) * float(0.0174533))) * +0.5;
BulletMoveVal[BulletNum].y = 1.0 * glm::sin(((glm::atan(PrevStickY, PrevStickX)) * (180.f / glm::pi<float>()) * float(0.0174533))) * -0.5;
}
}
void PlayerObject::IterateBulletNum() {
if (this->once == true && this->CD == false) // If once1 is true, bulletNum changes to the next num in line
{
if (this->BulletNum < this->BulletBounceNum.size() - 1)
this->BulletNum += 1;
else // If past the max bullet pool, player will take control of the first bullet
this->BulletNum = 0;
this->once = false;
this->CD = true;
this->shouldBulletPlaySound = true;
}
}
void PlayerObject::BulletPillarCollision(std::vector<GameObject*> Bullets, GameObject& pillar1, GameObject& pillar2, GameObject& pillar3) {
CheckBulletBounceLimit(Bullets, 3);
for (int i = 0; i < Bullets.size(); i++) // change Bullets into function call variable
{
if (BulletBounceNum[i] <= 3 && (glm::length(BulletMoveVal[i]) != 0)) {
if (glm::distance(Bullets[i]->position, pillar1.position) < pillar1.Radius)
{
float delta_x = Bullets[i]->position.x - pillar1.position.x;
float delta_z = Bullets[i]->position.z - pillar1.position.z;
float theta_radians = glm::atan(delta_z, delta_x);
glm::vec2 temp = BulletMoveVal[i];
float tempLength = glm::length(temp);
BulletMoveVal[i].x = glm::cos(theta_radians) * 0.5;
BulletMoveVal[i].y = glm::sin(theta_radians) * 0.5;
float tempLengthNew = glm::length(BulletMoveVal[i]);
BulletBounceNum[i]++;
bulletHitSheild[i] = false;
bulletHitPillar2[i] = false;
shouldBulletBouncePlaySound = true;
}
if (bulletHitPillar2[i] == false) {
if (glm::distance(Bullets[i]->position, pillar2.position) < pillar2.Radius)
{
float delta_x = Bullets[i]->position.x - pillar2.position.x;
float delta_z = Bullets[i]->position.z - pillar2.position.z;
float theta_radians = glm::atan(delta_z, delta_x);
BulletMoveVal[i].x = glm::cos(theta_radians) * 0.5;
BulletMoveVal[i].y = glm::sin(theta_radians) * 0.5;
BulletBounceNum[i]++;
bulletHitSheild[i] = false;
bulletHitPillar2[i] = true;
shouldBulletBouncePlaySound = true;
}
}
if (glm::distance(Bullets[i]->position, pillar3.position) < pillar3.Radius)
{
float delta_x = Bullets[i]->position.x - pillar3.position.x;
float delta_z = Bullets[i]->position.z - pillar3.position.z;
float theta_radians = glm::atan(delta_z, delta_x);
BulletMoveVal[i].x = glm::cos(theta_radians) * 0.5;
BulletMoveVal[i].y = glm::sin(theta_radians) * 0.5;
BulletBounceNum[i]++;
bulletHitSheild[i] = false;
bulletHitPillar2[i] = false;
shouldBulletBouncePlaySound = true;
}
}
}
}
void PlayerObject::BulletOuterWallsCollision(std::vector<GameObject*> Bullets) {
for (int i = 0; i < Bullets.size(); i++) // change Bullets into function call variable
{
if (glm::length(BulletMoveVal[i]) > 0) {
if (Bullets[i]->position.x < -13.5 || Bullets[i]->position.x > 13.2) {
BulletMoveVal[i].x *= -1, BulletBounceNum[i]++, bulletHitSheild[i] = false;bulletHitPillar2[i] = false;
if (bulletAlive[i] = true)
shouldBulletBouncePlaySound = true;
}
if (Bullets[i]->position.z < -7.35 || Bullets[i]->position.z > 7.55) {
BulletMoveVal[i].y *= -1, BulletBounceNum[i]++, bulletHitSheild[i] = false;bulletHitPillar2[i] = false;
if (bulletAlive[i] = true)
shouldBulletBouncePlaySound = true;
}
}
}
}
void PlayerObject::CheckBulletBounceLimit(std::vector<GameObject*> Bullets, int bounceLimit) {
for (int i = 0; i < Bullets.size(); i++) // change p1Bullets into function call variable
{
if (BulletBounceNum[i] > bounceLimit)
{
BulletMoveVal[i].x = 0, BulletMoveVal[i].y = 0;
Bullets[i]->translate = glm::translate(glm::mat4(), glm::vec3(-1000.0f, -100.0f, -1000.0f)); //set position of object
Bullets[i]->position = glm::vec3(-1000.0f, -100.0f, -1000.0f); //set position of object
BulletBounceNum[i] = 0;
bulletHitSheild[i] = false;
bulletHitPillar2[i] = false;
bulletAlive[i] = false;
shouldBulletBouncePlaySound = false;
}
}
}
void PlayerObject::ShieldCollision(PlayerObject& other, GameObject* Player, std::vector<GameObject*> otherBullets) {
for (int i = 0; i < otherBullets.size(); i++)
{
if (other.bulletHitSheild[i] == false) {
if (glm::distance(otherBullets[i]->position, Shield.position) < Shield.Radius)
{
// std::cout << "P1Shield was Hit" << std::endl;
other.BulletMoveVal[i] = glm::reflect(other.BulletMoveVal[i], glm::vec2(-glm::cos(Player->OppAngle), glm::sin(Player->OppAngle)));
// other.BulletMoveVal[i].y = glm::reflect(other.BulletMoveVal[i], glm::vec2(glm::cos(Player->OppAngle), glm::sin(Player->OppAngle))).y;
other.BulletBounceNum[i]++;
other.bulletHitSheild[i] = true; //if you hit the shield the bullet is garunteed to hit something else
other.bulletHitPillar2[i] = false;
}
}
}
}
void PlayerObject::Death(GameObject* Player1, GameObject* Player2, std::vector<GameObject*> p1Bullets, std::vector<GameObject*> p2Bullets, int& RoundWins, PlayerObject* Winner)
{
// NOTE:: FIX SHIELD REINITIALIZTION
// Player Round Win Point
RoundWins++;
// Reset All Bullets
for (int i = 0; i < BulletBounceNum.size(); i++)
{
BulletBounceNum[i] = 0.0f;
Winner->BulletBounceNum[i] = 0.0f;
}
for (int i = 0; i < BulletMoveVal.size(); i++)
{
BulletMoveVal[i].x = 0, BulletMoveVal[i].y = 0;
Winner->BulletMoveVal[i].x = 0, Winner->BulletMoveVal[i].y = 0;
p1Bullets[i]->position.x = 1000;
p1Bullets[i]->position.z = 1000;
p2Bullets[i]->position.x = 1000;
p2Bullets[i]->position.z = 1000;
p1Bullets[i]->translate = glm::translate(glm::mat4(), p1Bullets[i]->position); //set position of object
p2Bullets[i]->translate = glm::translate(glm::mat4(), p2Bullets[i]->position);
}
// Reinitalize Player2
Player2->position = glm::vec3(8.f, 0.0f, 0.0f);
Player2->translate = glm::translate(glm::mat4(), Player2->position); //set position of object
Player2->rotate = glm::rotate(glm::mat4(), 1.5708f, glm::vec3(0.f, 1.f, 0.f));
// Reinitalize Player1
Player1->position = glm::vec3(-8.f, 0.0f, 0.0f);
Player1->translate = glm::translate(glm::mat4(), Player1->position); //set position of object
Player1->rotate = glm::rotate(glm::mat4(), 1.5708f, glm::vec3(0.f, 1.f, 0.f));
}
void PlayerObject::GetRightStick(GameObject* player, Input::Stick rStick, Input::Stick lStick) {
// -------------------------------------------- RIGHT THUMB STICK --------------------------------------------
// Get Opposite angle Player 2 is facing
if (player->currAngle >= 0)
player->OppAngle = (player->currAngle - glm::pi<float>());
else
player->OppAngle = (player->currAngle + glm::pi<float>());
this->Shield.position.x = player->position.x + glm::cos(player->OppAngle) * 0.4f;
this->Shield.position.z = player->position.z + glm::sin(player->OppAngle) * -0.4f;
this->rStickAngle = (glm::atan(rStick.yAxis, rStick.xAxis) * (180.f / glm::pi<float>()) * float(0.0174533)); //Update rStickAngle value
// Dead Zone Check
if (sqrt(rStick.yAxis*rStick.yAxis + rStick.xAxis*rStick.xAxis) > 0.1f) // DeadZone 10%
{
if (player->currAngle > glm::pi<float>())
player->currAngle -= 2 * glm::pi<float>();
else if (player->currAngle < -glm::pi<float>())
player->currAngle += 2 * glm::pi<float>();
if (abs(player->currAngle - this->rStickAngle) >= 0.4f) // if difference between current angle and rStick angle is greater than 0.1f then...
{
if (player->currAngle < this->rStickAngle) // if current angle LESS than rStickAngle...
{
if (abs(player->currAngle - this->rStickAngle) < glm::pi<float>()) // if angle difference less than pi...
{
player->rotate = glm::rotate(player->rotate, +0.4f, glm::vec3(0.f, 1.f, 0.f));
player->currAngle += 0.4f;
}
else // if angle difference greater than pi...
{
player->rotate = glm::rotate(player->rotate, -0.4f, glm::vec3(0.f, 1.f, 0.f));
player->currAngle -= 0.4f;
}
}
else // if current angle GREATER than rStickAngle...
{
if (abs(player->currAngle - this->rStickAngle) < glm::pi<float>())
{
player->rotate = glm::rotate(player->rotate, -0.4f, glm::vec3(0.f, 1.f, 0.f));
player->currAngle -= 0.4f;
}
else
{
player->rotate = glm::rotate(player->rotate, +0.4f, glm::vec3(0.f, 1.f, 0.f));
player->currAngle += 0.4f;
}
}
}
else if (abs(player->currAngle - this->rStickAngle) >= 0.1f)
{
if (player->currAngle < this->rStickAngle) // if current angle LESS than rStickAngle...
{
if (abs(player->currAngle - this->rStickAngle) < glm::pi<float>()) // if angle difference less than pi...
{
player->rotate = glm::rotate(player->rotate, +0.05f, glm::vec3(0.f, 1.f, 0.f));
player->currAngle += 0.05f;
}
else // if angle difference greater than pi...
{
player->rotate = glm::rotate(player->rotate, -0.05f, glm::vec3(0.f, 1.f, 0.f));
player->currAngle -= 0.05f;
}
}
else // if current angle GREATER than rStickAngle...
{
if (abs(player->currAngle - this->rStickAngle) < glm::pi<float>())
{
player->rotate = glm::rotate(player->rotate, -0.05f, glm::vec3(0.f, 1.f, 0.f));
player->currAngle -= 0.05f;
}
else
{
player->rotate = glm::rotate(player->rotate, +0.05f, glm::vec3(0.f, 1.f, 0.f));
player->currAngle += 0.05f;
}
}
}
}
}
void PlayerObject::BulletCooldown(float deltaTime) {
if (this->CD) // Bullet Cool Down
{
this->BulletCD += deltaTime;
if (this->BulletCD > this->bulletCDLength)
{
this->BulletCD = 0;
this->CD = false;
}
}
}
void PlayerObject::UpdatePrevStick(Input::Stick rStick)
{
if (sqrt(rStick.yAxis*rStick.yAxis + rStick.xAxis*rStick.xAxis) > 0.1f) // If magnitude of rStick is greater than 10%, update prevStick
{
this->PrevStickX = rStick.xAxis;
this->PrevStickY = rStick.yAxis;
}
}
| [
"juthun@hotmail.com"
] | juthun@hotmail.com |
bc503dfffbb190222474da049f62362472b287a7 | 9bb46496ad26f167027babeba10ed027d4cbec75 | /Task.h | 41bb278b88fa0094b232f5d74de7dbd1b62a3d64 | [
"Apache-2.0"
] | permissive | dmaliuk/mem-pool | 9540e0edeafc79c67a1163b3b36aaf64d4445ff6 | 0d700d9a00fd6ccc9f56b62d5863900faba4a1e3 | refs/heads/master | 2020-04-15T01:10:22.421704 | 2019-01-06T04:16:34 | 2019-01-06T04:16:34 | 164,266,106 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 378 | h | #include <cstddef>
class Task
{
public:
virtual void Run() = 0;
virtual ~Task(){};
};
class TaskA : public Task
{
public:
TaskA(std::size_t sleepT)
: sleepT(sleepT)
{}
~TaskA() = default;
void Run() override;
private:
std::size_t sleepT;
};
class TaskB : public Task
{
public:
TaskB(std::size_t){}
~TaskB() = default;
void Run() override {}
};
| [
"dzmitry.maliuk@gmail.com"
] | dzmitry.maliuk@gmail.com |
e8273eabd43ba5c056e8922096f8576d7f760bbd | 3bdbc5b4a14284ca6a9206a17454f79826b7de27 | /client/forgetdialog.h | 39b73ad3030e0f431929119310adaa84ae6a5702 | [] | no_license | darkicerain/dnfLogin | 6ea713b2a16e881985ea3ec8ccb9da438726d82c | 77d0b71d40a2243c5feddd2c0540033fa9f15350 | refs/heads/master | 2021-12-15T00:33:20.949730 | 2017-05-08T10:48:46 | 2017-05-08T10:48:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 449 | h | #ifndef FORGETDIALOG_H
#define FORGETDIALOG_H
#include <QDialog>
#include <QNetworkReply>
namespace Ui {
class forgetDialog;
}
class forgetDialog : public QDialog
{
Q_OBJECT
public:
explicit forgetDialog(QWidget *parent = 0);
~forgetDialog();
private slots:
void on_pushButton_clicked();
void requestFinished(QNetworkReply *reply);
private:
Ui::forgetDialog *ui;
};
#endif // FORGETDIALOG_H
| [
"zuopucun@meituan.com"
] | zuopucun@meituan.com |
6e91e7a9120466f0e6fb7b73ee63aadf6890bee9 | 6b8fff0eeb75ad266af0ec2b9e9aaf28462c2a73 | /Sapi_Dataset/Data/user11/labor6/feladat1/main.cpp | f3d752f8ed199095bcd049644831d8baaf7e590c | [] | no_license | kotunde/SourceFileAnalyzer_featureSearch_and_classification | 030ab8e39dd79bcc029b38d68760c6366d425df5 | 9a3467e6aae5455142bc7a5805787f9b17112d17 | refs/heads/master | 2020-09-22T04:04:41.722623 | 2019-12-07T11:59:06 | 2019-12-07T11:59:06 | 225,040,703 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,227 | cpp | #include <cstdlib>
#include "Matrix.h"
#include<utility>
#include<stdexcept>
using namespace std;
Matrix createSquareMatrix(int size) {
Matrix m(size, size);
m.fillMatrix(1);
return m;
}
int main(int argc, char** argv) {
/*Matrix m4(1, 2);
cout << "Please type in two real numbers for m4[0][0] and m4[0][1]: " << endl;
//Extractor operator
cin>>m4;
//Inserter operator
cout << "m4: " << endl << m4 << endl;
cout << endl << "m4[0][0]: " << m4[0][0] << endl;
Matrix m1(2, 3);
m1.randomMatrix(1, 5);
cout<<m1[1][1]<<endl;
m1[1][1]=20;
cout<<m1[1][1];*/
cout<<"******************************************************************"<<endl;
cout<<"Constructor "<<endl;
cout<<"******************************************************************"<<endl;
Matrix m1(2, 3);
m1.randomMatrix(1, 5);
cout << "m1: " << endl << m1 << endl;
cout<<"******************************************************************"<<endl;
cout<<"+ operator - equal sizes "<<endl;
cout<<"******************************************************************"<<endl;
Matrix m2(2, 3);
m2.fillMatrix(2);
cout << "m2: " << endl << m2 << endl;
try {
cout << "Matrix m3 = m1 + m2: " << endl;
Matrix m3 = (m1 + m2);
cout << "m3: " << endl << m3 << endl;
} catch (out_of_range& e) {
cout << e.what() << endl;
}
cout<<"******************************************************************"<<endl;
cout<<"+ operator - different sizes "<<endl;
cout<<"******************************************************************"<<endl;
Matrix m3(5, 5);
m3.fillMatrix(1);
cout << "m3: " << endl << m3 << endl;
try {
cout<<"m1+m3:"<<endl;
cout << "m1+m3: " << endl << m1 + m3 << endl;
} catch (out_of_range& e) {
cout << e.what() << endl;
}
cout<<"******************************************************************"<<endl;
cout<<"copy assignment - different sizes "<<endl;
cout<<"******************************************************************"<<endl;
try {
//copy assignment
cout<<"m3 = m1"<<endl;
m3 = m1;
} catch (out_of_range& e) {
cout << e.what() << endl;
}
cout<<"m3: "<<endl;
cout<<m3<<endl;
/*try {
//copy assignment
cout<<"m2 = m1"<<endl;
m2 = m1;
} catch (out_of_range& e) {
cout << e.what() << endl;
}
cout<<"m2: "<<endl;
cout<<m2<<endl;*/
cout<<"******************************************************************"<<endl;
cout<<"Extractor operator "<<endl;
cout<<"******************************************************************"<<endl;
Matrix m4(1, 2);
cout << "Please type in two real numbers for m4[0][0] and m4[0][1]: " << endl;
//Extractor operator
cin>>m4;
//Inserter operator
cout << "m4: " << endl << m4 << endl;
cout<<"******************************************************************"<<endl;
cout<<"Index operator "<<endl;
cout<<"******************************************************************"<<endl;
//Index operator
cout << endl << "m4[0][0]: " << m4[0][0] << endl;
cout<<"******************************************************************"<<endl;
cout<<"* operator "<<endl;
cout<<"******************************************************************"<<endl;
Matrix m5(2, 1);
m5.fillMatrix(1);
cout << "M4: " << endl << m4 << endl;
cout << "M5: " << endl << m5 << endl;
cout << "Multiplication: ";
try {
cout << "M4 x M5: " << endl << m4 * m5 << endl;
} catch (out_of_range& e) {
cout << e.what() << endl;
}
cout<<"******************************************************************"<<endl;
cout<<" = operator -- copy assignment "<<endl;
cout<<"******************************************************************"<<endl;
Matrix m6(m4);
cout << "m6 created as a copy of m4 using copy constructor: " <<endl<< m6 << endl;
try {
cout<<"m1 = m6 = m6"<<endl;
m1 = m6 = m6;
} catch (out_of_range& e) {
cout<< e.what() << endl;
}
cout<<"******************************************************************"<<endl;
cout<<"MOVE constructor "<<endl;
cout<<"******************************************************************"<<endl;
Matrix mx(3, 2), my(2, 3);
mx.fillMatrix(1);
my.fillMatrix(2);
cout << "mx: " << endl << mx << endl;
cout << "my: " << endl << my << endl;
Matrix mx2;
mx2=(mx*my);
cout << "my: " << endl << mx2 << endl;*/
//Move constructor
cout << "Matrix mz1 = std::move(mx * my);\n ";
Matrix mz1 = std::move(mx * my);
mz1.printMatrix(cout);
Matrix mz2 = std::move(createSquareMatrix(3));
cout << "Matrix mz2 = std::move(createSquareMatrix(3))\n ";
mz2.printMatrix(cout);
cout<<"******************************************************************"<<endl;
cout<<"MOVE assignment "<<endl;
cout<<"******************************************************************"<<endl;
try {
cout<<"mx: "<<mx.getRows()<<" x "<<mx.getCols()<<endl;
cout<<mx<<endl;
cout<<"my: "<<my.getRows()<<" x "<<my.getCols()<<endl;
cout<<my<<endl;
cout << "m6 = mx * my: " << endl;
m6 = mx * my;
cout<<"m6: "<<m6.getRows()<<" x "<<m6.getCols()<<endl;
cout<<m6<<endl;
} catch (out_of_range& e) {
cout << e.what() << endl;
}
return (EXIT_SUCCESS);
}
| [
"tundekoncsard3566@gmail.com"
] | tundekoncsard3566@gmail.com |
eee6cb0f4c221d83d5fbd13f15f390d10669ff98 | 5a6398e0b197dc76eb9d79e8c9a70940c826b00e | /src/include/izenelib/include/3rdparty/msgpack/msgpack/type.hpp | 69c9b23e210d8ad099cd86fdd1705a86b080892e | [
"Apache-2.0",
"PostgreSQL"
] | permissive | RMoraffah/hippo-postgresql | 38b07cd802e179c3fce00097f49c843b238c3e91 | 002702bab3a820bbc8cf99e6fcf3bb1eface96c1 | refs/heads/master | 2021-01-12T00:48:53.735686 | 2016-12-02T01:01:15 | 2016-12-02T01:13:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 437 | hpp | #include "type/bool.hpp"
#include "type/deque.hpp"
#include "type/fixint.hpp"
#include "type/float.hpp"
#include "type/int.hpp"
#include "type/int128.hpp"
#include "type/list.hpp"
#include "type/map.hpp"
#include "type/nil.hpp"
#include "type/pair.hpp"
#include "type/raw.hpp"
#include "type/set.hpp"
#include "type/string.hpp"
#include "type/UString.hpp"
#include "type/vector.hpp"
#include "type/tuple.hpp"
#include "type/define.hpp"
| [
"jiayu198910@gmail.com"
] | jiayu198910@gmail.com |
8172c865493a225c6d2e231c7c72e4c8f832f333 | 08d2d675218cd2d398d379b29e18a4f3eea2ff5b | /039_Combination_Sum.cpp | 1be77091f75c3baf077aa041b23c3bf094adcc9c | [] | no_license | liguanyu/leetcode_solutions | d48e0ea5595bb0fcd2b846303fe60133af54986b | 9fd35d669577393402b50fb9b95861baae48b086 | refs/heads/master | 2021-01-22T21:00:35.356513 | 2019-03-06T12:36:38 | 2019-03-06T12:36:38 | 100,683,112 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 919 | cpp | class Solution {
public:
vector<vector<int>> combinationSum(vector<int>& candidates, int target) {
vector<int> can = candidates;
sort(can.begin(), can.end());
vector<vector<int> > result;
vector<int> base;
cal(can, target, base, result);
return result;
}
void cal(vector<int>& candidates, int target, vector<int> base,vector<vector<int> >& result)
{
for(int a : candidates){
if(!base.empty() && a < base.back()){
continue;
}
if(a > target)
return;
else if(a == target){
base.push_back(a);
result.push_back(base);
return;
}
else{
base.push_back(a);
cal(candidates, target - a, base, result);
base.pop_back();
}
}
}
}; | [
"guanyu.li@outlook.com"
] | guanyu.li@outlook.com |
ac5782e6937c4da25953926474dc54aea3045b0d | 9402379373dceaacddbd68911410df582f763246 | /src/tlocGraphics/media/tlocFontSize.cpp | 69c4bdaff6519bf9acec8351659943af9cf9d688 | [] | no_license | samaursa/tlocEngine | 45c08cf4c63e618f0df30adc91b39f58c7978608 | 5fab63a31af9c4e266d7805a24a3d6611af71fa7 | refs/heads/master | 2022-12-30T20:10:38.841709 | 2014-09-12T07:36:27 | 2014-09-12T07:36:27 | 305,503,446 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,388 | cpp | #include "tlocFontSize.h"
#include <tlocMath/tlocRange.h>
#include <tlocMath/utilities/tlocScale.h>
namespace tloc { namespace graphics { namespace media {
FontSize::
FontSize(em a_size, dpi a_dpi)
{
// using the formula: pixel_size = point_size * resolution / 72
size_type dpiY =
core_utils::CastNumber<size_type>(a_dpi.m_value->operator [](1));
m_heightInPixels = a_size * dpiY / 72;
}
FontSize::
FontSize(fraction a_0to100, resolution a_resolution)
{
TLOC_ASSERT(a_0to100 >= 0 && a_0to100 <= 100, "Fraction (a_0to1) out of range");
real_type resY =
core_utils::CastNumber<real_type>(a_resolution.m_value->operator [](1));
real_type heightInPixels =
core_utils::CastNumber<real_type>(resY) * a_0to100 / 100.0f;
m_heightInPixels = (size_type)heightInPixels;
}
FontSize::
FontSize(pixels a_heightInPixels)
{
m_heightInPixels = a_heightInPixels;
}
};};};
using namespace tloc::gfx_med;
#include <tlocCore/types/tlocStrongType.inl.h>
TLOC_EXPLICITLY_INSTANTIATE_STRONG_TYPE(FontSize::dim_type, 0);
TLOC_EXPLICITLY_INSTANTIATE_STRONG_TYPE(FontSize::dim_type, 1);
TLOC_EXPLICITLY_INSTANTIATE_STRONG_TYPE(FontSize::real_type, 0);
TLOC_EXPLICITLY_INSTANTIATE_STRONG_TYPE(FontSize::size_type, 0);
TLOC_EXPLICITLY_INSTANTIATE_STRONG_TYPE(FontSize::size_type, 1); | [
"saadrustam@gmail.com"
] | saadrustam@gmail.com |
7a2c01597b2fcfb3f09d49f3baf3d61161483fbb | 5b2cf0a26a477caa23e68798c6378d964dad8618 | /Plugins/HttpLibrary/Source/HttpLibraryBlueprintSupport/Private/K2Node_HttpLibraryRequest.cpp | 3b503dc04b0a834537e2545a9178e20ff963b35a | [] | no_license | q1192487554/myTest | e0703c7fb120b48fc71a4c9f3f0905eaaebb8728 | 3fe6eeb93a338a963300989313a2141a68cae74d | refs/heads/master | 2023-01-30T18:34:15.735843 | 2020-12-16T11:09:20 | 2020-12-16T11:09:20 | 289,756,687 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,256 | cpp | // Copyright 2019 Tracer Interactive, LLC. All Rights Reserved.
#include "K2Node_HttpLibraryRequest.h"
#include "HttpLibraryRequestCallbackProxy.h"
#include "EdGraph/EdGraphPin.h"
#define LOCTEXT_NAMESPACE "K2Node"
UK2Node_HttpLibraryRequest::UK2Node_HttpLibraryRequest( const FObjectInitializer& ObjectInitializer )
: Super( ObjectInitializer )
{
ProxyFactoryFunctionName = GET_FUNCTION_NAME_CHECKED( UHttpLibraryRequestCallbackProxy, CreateProxyObjectForRequest );
ProxyFactoryClass = UHttpLibraryRequestCallbackProxy::StaticClass();
ProxyClass = UHttpLibraryRequestCallbackProxy::StaticClass();
}
FText UK2Node_HttpLibraryRequest::GetTooltipText() const
{
return LOCTEXT( "K2Node_HttpLibraryRequest_Tooltip", "Send an HTTP request" );
}
FText UK2Node_HttpLibraryRequest::GetNodeTitle( ENodeTitleType::Type TitleType ) const
{
return LOCTEXT( "HttpLibraryRequest", "HTTP Request" );
}
void UK2Node_HttpLibraryRequest::GetPinHoverText( const UEdGraphPin& Pin, FString& HoverTextOut ) const
{
Super::GetPinHoverText( Pin, HoverTextOut );
static FName NAME_OnSuccess = FName( TEXT( "OnSuccess" ) );
static FName NAME_OnProgress = FName( TEXT( "OnProgress" ) );
static FName NAME_OnFailure = FName( TEXT( "OnFailure" ) );
if ( Pin.PinName == NAME_OnSuccess )
{
FText ToolTipText = LOCTEXT( "K2Node_HttpLibraryRequest_OnSuccess_Tooltip", "Event called when the HTTP request has successfully completed." );
HoverTextOut = FString::Printf( TEXT( "%s\n%s" ), *ToolTipText.ToString(), *HoverTextOut );
}
else if ( Pin.PinName == NAME_OnProgress )
{
FText ToolTipText = LOCTEXT( "K2Node_HttpLibraryRequest_OnProgress_Tooltip", "Event called when the HTTP request has a progress update." );
HoverTextOut = FString::Printf( TEXT( "%s\n%s" ), *ToolTipText.ToString(), *HoverTextOut );
}
else if ( Pin.PinName == NAME_OnFailure )
{
FText ToolTipText = LOCTEXT( "K2Node_HttpLibraryRequest_OnFailure_Tooltip", "Event called when the HTTP request has failed with an error code." );
HoverTextOut = FString::Printf( TEXT( "%s\n%s" ), *ToolTipText.ToString(), *HoverTextOut );
}
}
FText UK2Node_HttpLibraryRequest::GetMenuCategory() const
{
return LOCTEXT( "HttpLibraryRequestCategory", "HTTP Library" );
}
#undef LOCTEXT_NAMESPACE
| [
"1192487554@qq.com"
] | 1192487554@qq.com |
f3ec9fdba5e231dfbcc405a7c74328822e8a9200 | 96737e6f65b7daed6aa02d7d98662ce2888cff29 | /Purchase/PurchaseReceiptManager.cpp | dbf8b6e1ec81abd8d2e62ab240e15f21492203d6 | [] | no_license | mkawick/ChatResearch | 405ae7313218b1cf8898ea34694ce63d559b3c64 | 852a25198f942770cf6425b55ba080c3475d589f | refs/heads/master | 2021-01-10T19:25:58.731316 | 2015-01-10T02:33:56 | 2015-01-10T02:33:56 | 10,066,899 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,858 | cpp | // PurchaseReceiptManager.cpp
#include <time.h>
#include <iostream>
#include <string>
#include <set>
using namespace std;
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
#include "../NetworkCommon/Utils/CommandLineParser.h"
#include "../NetworkCommon/Utils/StringUtils.h"
#include "PurchaseReceiptManager.h"
#include "../NetworkCommon/Database/StringLookup.h"
#include "../NetworkCommon/Packets/PurchasePacket.h"
struct ReceiptTempData: public PacketPurchase_ValidatePurchaseReceipt
{
ReceiptTempData& operator = ( const PacketPurchase_ValidatePurchaseReceipt* receipt )
{
purchaseItemId = receipt->purchaseItemId;
quantity = receipt->quantity;
transactionId = receipt->transactionId;
//receipt; // do not copy
platformId = receipt->platformId;
return *this;
}
};
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
PurchaseReceiptManager::PurchaseReceiptManager( U32 id, ParentQueryerPtr parent, string& query, bool runQueryImmediately ) : ParentType( id, 20, parent, runQueryImmediately ),
m_isServicingReceipts( false ),
m_isInitializing( true ),
m_salesManager( NULL )
/*,
m_hasSendProductRequest( false )*/
{
SetQuery( query );
}
/////////////////////////////////////////////////////////////////////////////////////////
void PurchaseReceiptManager::Update( time_t currentTime )
{
if( m_isInitializing )
{
/* if( m_hasSendProductRequest == false )
{
m_hasSendProductRequest = true;
RequestAllProducts();
}*/
m_isInitializing = false;
}
else
{
// request strings first for all of the sales.
ParentType::Update( currentTime, m_isServicingReceipts );
if( m_isServicingReceipts )
ValidateReceipts();
}
}
/////////////////////////////////////////////////////////////////////////////////////////
void PurchaseReceiptManager::ValidateReceipts()
{
if( m_receiptsToValidate.size() != 0 )
{
while( m_receiptsToValidate.size() )
{
const PurchaseReceiptTracking& prt = m_receiptsToValidate.front();
// todo, send http request
m_receiptsToValidate.pop_front();
}
return;
}
else
{
m_isServicingReceipts = false;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
bool PurchaseReceiptManager::HandleResult( const PacketDbQueryResult* dbResult )
{
//DiplodocusPurchase::QueryType_ReceiptInsert,
//DiplodocusPurchase::QueryType_ReceiptLookup,
int lookupType = dbResult->lookup;
if( lookupType == static_cast<int>( m_queryType ) )
{
//SetValueOnExit< bool > setter( m_isServicingReceipts, false );// due to multiple exit points...
if( m_endpointValidation.size() != 0 )
{
PurchaseReceiptParser enigma( dbResult->bucket );
PurchaseReceiptParser::iterator it = enigma.begin();
if( enigma.m_bucket.size() > 0 )
{
/* cout << "PurchaseReceiptManager:" << endl;
cout << " Successful query = " << m_queryString << endl;
cout << "No receipts to service " << endl;*/
}
while( it != enigma.end() )
{
PurchaseReceiptTracking prt;
prt = *it++;
// send HTTP requests to apple for each of these.
m_receiptsToValidate.push_back( prt );
}
}
return true;
}
if( lookupType == DiplodocusPurchase::QueryType_ReceiptInsert )
{
ReceiptTempData* data = static_cast< ReceiptTempData* >( dbResult->customData );
if( dbResult->successfulQuery == true )
{
LogMessage( LOG_PRIO_INFO, "successful receipt additions" );
}
else
{
LogMessage( LOG_PRIO_ERR, "receipt additions failed Time: %s", GetDateInUTC().c_str() );
}
delete data;
return true;
}
// m_salesManager
return false;
}
/*void RequestAllProducts()
{
string query = "SELECT * FROM procuct";
}*/
/////////////////////////////////////////////////////////////////////////////////////////
bool PurchaseReceiptManager::WriteReceipt( const PacketPurchase_ValidatePurchaseReceipt* receipt, U32 userId, const string& userUuid )
{
LogMessage( LOG_PRIO_INFO, "PurchaseReceiptManager::WriteReceipt" );
/*
INSERT INTO playdek.purchase_receipts (user_id, user_uuid, transaction_id, receipt, receipt_hash, platform_id, product_purchased, product_purchased_count )
VALUES( 1, "38cabbad2461e678", "AABBCCDDEEFFGGHH", "a long receipt which is filled with garbage", 12234456, 1, "fe78c73d96db90cf", 1 );
*/
if( userId == 0 )
return false;
if( userUuid.size() < 2 )
return false;
string productUuid = receipt->purchaseItemId;
stringhash lookupHash = GenerateUniqueHash( receipt->receipt );
string insertQuery = "INSERT INTO playdek.purchase_receipts (user_id, user_uuid, transaction_id, receipt, receipt_hash, platform_id, product_purchased_uuid, product_purchased_count ) VALUES( ";
insertQuery += boost::lexical_cast< string >( userId );
insertQuery += ", '%s', '%s', '%s', ";
insertQuery += boost::lexical_cast< string >( lookupHash );
insertQuery += ", ";
insertQuery += boost::lexical_cast< string >( receipt->platformId );
insertQuery += ", '%s', "; // product id
insertQuery += boost::lexical_cast< string >( receipt->quantity );
insertQuery += ");";
//1, "38cabbad2461e678", "AABBCCDDEEFFGGHH", "a long receipt which is filled with garbage", 12234456, 1, "fe78c73d96db90cf", 1
PacketDbQuery* dbQuery = new PacketDbQuery;
dbQuery->id = 0;
dbQuery->lookup = DiplodocusPurchase::QueryType_ReceiptInsert;
ReceiptTempData* data = new ReceiptTempData;
(*data) = ( receipt );
dbQuery->customData = data;
//dbQuery->isFireAndForget = true;
dbQuery->escapedStrings.insert( userUuid );
dbQuery->escapedStrings.insert( receipt->transactionId );
dbQuery->escapedStrings.insert( receipt->receipt );
dbQuery->escapedStrings.insert( receipt->purchaseItemId );
dbQuery->query = insertQuery;
m_parent->AddQueryToOutput( dbQuery );
if( m_salesManager )
{
m_salesManager->PerformSimpleInventoryAddition( userUuid, productUuid, receipt->quantity, true );
}
return true;
}
/////////////////////////////////////////////////////////////////////////////////////////
void PurchaseReceiptManager::AddProductToUserInventory( const string& productUuid, int quantity, const string& userUuid )
{
}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
PurchaseReceiptTracking::PurchaseReceiptTracking()
{
}
/////////////////////////////////////////////////////////////////////////////////////////
PurchaseReceiptTracking& PurchaseReceiptTracking::operator = ( PurchaseReceiptParser::row row )
{
index = boost::lexical_cast< int > ( row[ TablePurchaseReceipts::Column_index ] );
user_id = boost::lexical_cast< int > ( row[ TablePurchaseReceipts::Column_user_id ] );
user_uuid = row[ TablePurchaseReceipts::Column_user_uuid ];
transaction_id = row[ TablePurchaseReceipts::Column_transaction_id ];
date_received = row[ TablePurchaseReceipts::Column_date_received ];
receipt = row[ TablePurchaseReceipts::Column_receipt ];
receipt_hash = boost::lexical_cast< U64 > ( row[ TablePurchaseReceipts::Column_receipt_hash ] );
platform_id = boost::lexical_cast< int > ( row[ TablePurchaseReceipts::Column_platform_id ] );
product_purchased = row[ TablePurchaseReceipts::Column_product_purchased ];
product_purchased_count = boost::lexical_cast< int > ( row[ TablePurchaseReceipts::Column_product_purchased_count ] );
num_attempts_to_validate = boost::lexical_cast< int > ( row[ TablePurchaseReceipts::Column_num_attempts_to_validate ] );
date_last_validation_attempt = row[ TablePurchaseReceipts::Column_date_last_validation_attempt ];
validated_result = boost::lexical_cast< int > ( row[ TablePurchaseReceipts::Column_validated_result ] );
return *this;
}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
| [
"mickey@playdekgames.com"
] | mickey@playdekgames.com |
f66e3958cb4f2aa41ba5abbdeb923f9d4e9bf06f | a400691d30c4442f8ff5ea495c6ec6fc0a3bdf4c | /LaserscannerDLL_Leuze_RSL400/LaserscannerDLL_Leuze_RSL400/RotoScan.cpp | e3ec8b5060f6b6a211869b036d458c8bf3f73b5e | [] | no_license | S0543830/Kalibrierung | a54a1e71c0b305b34285dc9b949f1d96a806e844 | a11c36ffeaf8800aa402487840eb872edc7c093c | refs/heads/master | 2021-08-24T07:26:02.473585 | 2017-12-08T15:16:43 | 2017-12-08T15:16:43 | 113,586,214 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,881 | cpp | #include "RSL430Scan.h"
#include "RotoScan.h"
#include "TimeStamp.h"
#include <vector>
std::vector<CRSL430Scan*> vecObjLeSc;
ROTOSCAN_API int initRotoScan (unsigned int* iHandle, const char* szHostName, unsigned int uiPortNumber)
{
int iRetVal = ERR_LASCANLIB_UNKOWN_ERROR;
CRSL430Scan* objScan = new CRSL430Scan();
if (nullptr != objScan)
{
*iHandle = static_cast<int>(vecObjLeSc.size());
vecObjLeSc.push_back(objScan);
iRetVal = vecObjLeSc.back()->initRSL430UDP(szHostName, uiPortNumber);
if (RSL430_RETURN_OK != iRetVal)
{
if (RSL430_RETURN_INVALIDSOCKET == iRetVal)
{
iRetVal = MY_SOCKET_ERROR;
}
else if (RSL430_RETURN_BINDFAIL == iRetVal)
{
iRetVal = MY_SOCKET_ERROR_CREATE;
}
else if (RSL430_RETURN_ERROR == iRetVal)
{
iRetVal = ERR_LASCANLIB_UNKOWN_ERROR;
}
}
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_NULL;
}
return iRetVal;
}
ROTOSCAN_API int exitRotoScan (unsigned int iHandle)
{
int iRetVal = ERR_LASCANLIB_UNKOWN_ERROR;
if (vecObjLeSc.size() > iHandle)
{
CRSL430Scan * pScanner = vecObjLeSc.at(iHandle);
if (nullptr != pScanner)
{
iRetVal = pScanner->exitRSL430();
if (0 == iRetVal)
{
delete pScanner;
vecObjLeSc.at(iHandle) = nullptr;
iRetVal = LASCANLIB_OK;
}
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_NULL;
}
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_ID;
}
return iRetVal;
}
ROTOSCAN_API int setAngleFilterLimits (unsigned int iHandle, double dMinAngle, double dMaxAngle)
{
int iRetVal = LASCANLIB_OK;
if (vecObjLeSc.size() > iHandle)
{
CRSL430Scan * pScanner = vecObjLeSc.at(iHandle);
if (nullptr != pScanner )
{
pScanner->setAngleFilterLimits(dMinAngle, dMaxAngle);
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_NULL;
}
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_ID;
}
return iRetVal;
}
ROTOSCAN_API int setDistanceFilterLimits (unsigned int iHandle, double dMinDist, double dMaxDist)
{
int iRetVal = LASCANLIB_OK;
if (vecObjLeSc.size() > iHandle)
{
CRSL430Scan * pScanner = vecObjLeSc.at(iHandle);
if (nullptr != pScanner )
{
pScanner->setDistanceFilterLimits(dMinDist, dMaxDist);
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_NULL;
}
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_ID;
}
return iRetVal;
}
ROTOSCAN_API int getRotoScanStatus (unsigned int iHandle)
{
int iRetVal = LASCANLIB_OK;
if (vecObjLeSc.size() > iHandle)
{
CRSL430Scan * pScanner = vecObjLeSc.at(iHandle);
if (nullptr != pScanner)
{
iRetVal = pScanner->getRSL430Status();
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_NULL;
}
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_ID;
}
return iRetVal;
}
ROTOSCAN_API int getSingleScan (unsigned int iHandle,std::list <SPunkt>& rlstclPoints, std::list <double>& rlstdTimeStamps)
{
int iRetVal = LASCANLIB_OK;
if (vecObjLeSc.size() > iHandle)
{
CRSL430Scan * pScanner = vecObjLeSc.at(iHandle);
if (nullptr != pScanner )
{
iRetVal = pScanner->getSingleScan(rlstclPoints, rlstdTimeStamps);
if (iRetVal != 0)
{
iRetVal = ERR_LASCANLIB_UNKOWN_ERROR;
}
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_NULL;
}
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_ID;
}
return iRetVal;
}
ROTOSCAN_API int startScanRecording (unsigned int iHandle)
{
int iRetVal = LASCANLIB_OK;
if (vecObjLeSc.size() > iHandle)
{
CRSL430Scan * pScanner = vecObjLeSc.at(iHandle);
if (nullptr != pScanner)
{
iRetVal = pScanner->startScanRecording();
if (iRetVal != 0)
{
iRetVal = ERR_LASCANLIB_UNKOWN_ERROR;
}
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_NULL;
}
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_ID;
}
return iRetVal;
}
ROTOSCAN_API int stopScanRecording (unsigned int iHandle)
{
int iRetVal = LASCANLIB_OK;
if (vecObjLeSc.size() > iHandle)
{
CRSL430Scan * pScanner = vecObjLeSc.at(iHandle);
if (nullptr != pScanner )
{
iRetVal = pScanner->stopScanRecording();
if (iRetVal != 0)
{
iRetVal = ERR_LASCANLIB_UNKOWN_ERROR;
}
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_NULL;
}
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_ID;
}
return iRetVal;
}
ROTOSCAN_API int getRecordedScanPoints (unsigned int iHandle, std::list <SPunkt>& rlstclPoints,
std::list <double>& rlstdTimeStamps,
bool bInterpoleateTimeStamps/*Wird nicht verwendet*/)
{
int iRetVal = LASCANLIB_OK;
if (vecObjLeSc.size() > iHandle)
{
CRSL430Scan * pScanner = vecObjLeSc.at(iHandle);
if (nullptr != pScanner )
{
iRetVal = pScanner->getRecordedScanPoints(rlstclPoints, rlstdTimeStamps );
if (iRetVal != 0)
{
iRetVal = ERR_LASCANLIB_UNKOWN_ERROR;
}
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_NULL;
}
}
else
{
iRetVal = ERR_LASCANLIB_SCANNER_ID;
}
return iRetVal;
}
ROTOSCAN_API double getTimeStamp ( )
{
return CTimeStamp::getTimeStamp();
}
| [
"elbardan@gfaiev.de"
] | elbardan@gfaiev.de |
d8c9633635a5e51c6b444b3b9ea5f859ae96f3ad | 1071581be2ce5a990baf679d51e06adf280df258 | /Linked List/Odd even ll.cpp | 2d7ab478024cca45cdac9552f4ff1f4560e469e8 | [] | no_license | himanshu-802/CP1_CIPHERSCHOOLS | 87e1062d8a9d4fcd7366430e1583fa6026b73a26 | 20846e5b8a5df7b261eaab19898e9eade99c9f51 | refs/heads/master | 2022-12-13T00:41:38.480716 | 2020-09-03T12:19:59 | 2020-09-03T12:19:59 | 287,461,423 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,296 | cpp | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* };
*/
class Solution {
public:
ListNode* oddEvenList(ListNode* head) {
if(head==NULL || head->next==NULL){
return head;
}
ListNode* ptr=head;
ListNode* qtr=head->next;
ListNode* rtr=qtr;
while(1)
{
cout<<ptr->val<<" "<<qtr->val<<endl;
if(ptr->next!=NULL && ptr->next->next!=NULL)
{
ptr->next=qtr->next;
ptr=ptr->next;
}
if(ptr->next==NULL){
qtr->next=NULL;
break;
}
if(ptr->next->next==NULL)
{
qtr->next=ptr->next;
qtr=qtr->next;
qtr->next=NULL;
break;
}
if(qtr->next!=NULL && qtr->next->next!=NULL)
{
qtr->next=ptr->next;
qtr=qtr->next;
}
}
ptr->next=rtr;
return head;
}
};
| [
"36191619+himanshu-802@users.noreply.github.com"
] | 36191619+himanshu-802@users.noreply.github.com |
8ec815a73188712e4e11ddbbb685609b36d85a85 | f1bc129debaca67dd206d20bddf3cbac2aff235a | /USACO/frameup.cpp | 3192234f57cdff944a311aed7aac12b456ba6eb3 | [] | no_license | ovis96/coding-practice | a848b0b869b8001a69770464c46e4cfe1ba69164 | 7214383be1e3a2030aa05ff99666b9ee038ae207 | refs/heads/master | 2022-05-28T14:13:17.517562 | 2022-05-21T14:16:04 | 2022-05-21T14:16:04 | 70,779,713 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 4,191 | cpp | /*
ID: ovishek1
LANG: C++11
PROB: frameup
*/
#include <bits/stdc++.h>
using namespace std;
char grid[35][35];
char tmp[35][35];
int n, m;
int getMinX(char ch)
{
for(int i = 0; i<n; i++)
{
for(int j = 0; j<m; j++)
{
if(grid[i][j] == ch) return i;
}
}
return -1;
}
int getMaxX(char ch)
{
for(int i = n-1; i>=0; i--)
{
for(int j = 0; j<m; j++)
{
if(grid[i][j] == ch) return i;
}
}
}
int getMinY(char ch)
{
for(int j = 0; j<m; j++)
{
for(int i = 0; i<n; i++)
{
if(grid[i][j] == ch) return j;
}
}
}
int getMaxY(char ch)
{
for(int j = m-1; j>=0; j--)
{
for(int i = 0; i<n; i++)
{
if(grid[i][j] == ch) return j;
}
}
}
struct data{
int x1, y1, x2, y2;
data(int a, int b, int c, int d){
x1 = a, y1 = b, x2 = c, y2 = d;
}
data(){}
};
vector<char> st;
data vt[200];
vector<char> now;
int vis[26];
void rec(int pos, int sig)
{
if(pos==st.size()){
// for(int i = 0; i<n; i++)
// for(int j = 0; j<m; j++)
// tmp[i][j] = '.';
//// string sst = "";
// for(int i = 0; i<now.size(); i++)
// {
// data x = vt[now[i]];
//// sst += now[i];
// for(int j = x.x1; j <= x.x2; j++)
// tmp[j][x.y1] = tmp[j][x.y2] = now[i];
// for(int k = x.y1; k <= x.y2; k++)
// tmp[x.x1][k] = tmp[x.x2][k] = now[i];
// }
// if(sst == "EDABC"){
// for(int i = 0; i<n; i++)
// for(int j = 0; j<m; j++, (j==m?printf("\n"):1))
// printf("%c", tmp[i][j]);
// }
// int f = 0;
// for(int i = 0; i<n; i++)
// for(int j = 0; j<m; j++)
// if(grid[i][j] != tmp[i][j]) f = 1;
// if(!f){
for(char ch : now)
printf("%c", ch);
printf("\n");
// }
return;
}
for(int i = 0; i<st.size(); i++)
{
if(vis[i] == 0){
vis[i] = 1;
now.push_back(st[i]);
rec(pos+1);
now.pop_back();
vis[i] = 0;
}
}
}
int in[200];
vector<char> edge[200];
void top_order()
{
vector<char> order;
int f = 0;
while(1){
f = 0;
for(int i = 0; i<st.size(); i++)
{
if(in[st[i]] == 0) {
f = 1;
for(char ch : edge[st[i]])
{
in[ch] --;
}
in[st[i]] = -1;
order.push_back(st[i]);
break;
}
}
if(f==0) break;
}
st = order;
// for(char ch : st) cout << ch << endl;
}
/*input
6 9
AAABBBCCC
AQAQQQCQC
AAABBBCCC
XQXYYYZQZ
XQQYQYQQZ
XXXYYYZZZ
*/
int main()
{
// freopen("frameup.in", "r", stdin);
// freopen("frameup.out", "w", stdout);
scanf("%d %d", &n, &m);
for(int i = 0; i<n; i++)
scanf("%s", grid[i]);
for(char ch = 'A'; ch <= 'Z'; ch++)
{
if(getMinX(ch) == -1) continue;
st.push_back(ch);
vt[ch] = data(getMinX(ch), getMinY(ch), getMaxX(ch), getMaxY(ch));
// printf("%d %d %d %d\n", vt[ch].x1, vt[ch].y1, vt[ch].x2, vt[ch].y2);
}
for(int i = 0; i<st.size(); i++)
{
data x = vt[st[i]];
for(int j = x.x1; j <= x.x2; j++){
if(grid[j][x.y1] != st[i]) {
edge[st[i]].push_back(grid[j][x.y1]);
in[grid[j][x.y1]]++;
}
if(grid[j][x.y2] != st[i]){
edge[st[i]].push_back(grid[j][x.y2]);
in[grid[j][x.y2]]++;
}
}
for(int j = x.y1; j <= x.y2; j++){
if(grid[x.x1][j] != st[i]) {
edge[st[i]].push_back(grid[x.x1][j]);
in[grid[x.x1][j]]++;
}
if(grid[x.x2][j] != st[i]) {
edge[st[i]].push_back(grid[x.x2][j]);
in[grid[x.x2][j]]++;
}
}
}
top_order();
// for(char ch : st)
// cout << ch;
rec(0);
return 0;
}
| [
"ovishek.private@gmail.com"
] | ovishek.private@gmail.com |
dba8a0e3bdc7eb17e77e49b5499aa40fbd4fb708 | 35e28d7705773eed54345af4440700522c9d1863 | /deps/libgeos/geos/src/planargraph/Node_planargraph.cpp | 125c3c545054f775de704d3786c604d9dfc40c39 | [
"Apache-2.0",
"LGPL-2.1-only"
] | permissive | naturalatlas/node-gdal | 0ee3447861bf2d1abc48d4fbdbcf15aba5473a27 | c83e7858a9ec566cc91d65db74fd07b99789c0f0 | refs/heads/master | 2023-09-03T00:11:41.576937 | 2022-03-12T20:41:59 | 2022-03-12T20:41:59 | 19,504,824 | 522 | 122 | Apache-2.0 | 2022-06-04T20:03:43 | 2014-05-06T18:02:34 | C++ | UTF-8 | C++ | false | false | 1,610 | cpp | /**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2001-2002 Vivid Solutions Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/
#include <geos/planargraph/Node.h>
#include <geos/planargraph/DirectedEdge.h>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
namespace geos {
namespace planargraph {
/* static public */
/* UNUSED */
vector<Edge*>*
Node::getEdgesBetween(Node *node0, Node *node1)
{
std::vector<Edge*> edges0;
DirectedEdge::toEdges(node0->getOutEdges()->getEdges(), edges0);
std::vector<Edge*> edges1;
DirectedEdge::toEdges(node1->getOutEdges()->getEdges(), edges1);
// Sort edge lists (needed for set_intersection below
std::sort( edges0.begin(), edges0.end() );
std::sort( edges1.begin(), edges1.end() );
std::vector<Edge*>* commonEdges = new std::vector<Edge*>();
// Intersect the two sets
std::set_intersection(
edges0.begin(), edges0.end(),
edges1.begin(), edges1.end(),
commonEdges->end()
);
return commonEdges;
}
std::ostream& operator<<(std::ostream& os, const Node& n) {
os << "Node " << n.pt << " with degree " << n.getDegree();
if ( n.isMarked() ) os << " Marked ";
if ( n.isVisited() ) os << " Visited ";
return os;
}
} // namespace planargraph
} // namespace geos
| [
"brian@thirdroute.com"
] | brian@thirdroute.com |
50c6dfeefda5df0c8a6235e5bdd9407d8ff6a684 | f81e0bb7c5c3ea6ed4939be630b8bd4b1080b63d | /OTDR/IniUtil.cpp | 8da7fdb022f339469ec730c8e1b943011a97a25f | [] | no_license | iloveghq/Otdr_v1 | 16148863547f9998c35d8b2e3bd7947bd46e1892 | a5a088c206c70b942cb0e0a3fcc617d585edb247 | refs/heads/master | 2021-01-01T03:31:44.645669 | 2016-05-21T06:54:43 | 2016-05-21T06:54:43 | 59,346,193 | 5 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,579 | cpp | #include "StdAfx.h"
#include "IniUtil.h"
#include "atlbase.h"
LANG g_currentLang;
//可执行文件路径
CString s_strExePath = IniUtil::GetExePath();
IniUtil::IniUtil(void)
{
}
IniUtil::~IniUtil(void)
{
}
CString IniUtil::GetExePath()//获取文件运行路径
{
CString sPath;
GetModuleFileName(NULL,sPath.GetBufferSetLength(MAX_PATH+1),MAX_PATH);
sPath.ReleaseBuffer();
int nPos;
nPos=sPath.ReverseFind('\\');
sPath=sPath.Left(nPos);
return sPath;
}
/******************************************************************************/
/* 0:chinese config file, 1:english config file , 2:portugal config file */
/****************************************************************************/
CString IniUtil::GetLangFilePath()
{
CString strFilePath;
int nCurLang = (int)g_currentLang;
if (nCurLang == 0)
strFilePath.Format(_T("%s%s"),s_strExePath, CHS_FILE);
else if (nCurLang == 1)
strFilePath.Format(_T("%s%s"),s_strExePath, ENG_FILE);
else if(nCurLang == 2) //lzy 2014.06.06 葡萄牙语
strFilePath.Format(_T("%s%s"),s_strExePath, PORT_FILE);
return strFilePath;
}
CString IniUtil::GetConfigFilePath()
{
CString strFilePath;
strFilePath.Format(_T("%s%s"),s_strExePath, CONFIG_FILE);
return strFilePath;
}
void IniUtil::ReadLangSetting()
{
CString strLang = ReadSingleConfigInfo(_T("Language"), _T("LanguageOpt"));
if(strLang.CompareNoCase(_T("0")) == 0) //设为中文
g_currentLang = LANG::CHS;
else if (strLang.CompareNoCase(_T("1")) == 0) //设为英语
g_currentLang = LANG::ENG;
else if (strLang.CompareNoCase(_T("2")) == 0) //设为葡萄牙语
g_currentLang = LANG::PORT;
}
bool IniUtil::SaveLangSetting()
{
CString strLang;
strLang.Format(_T("%d"), (int)g_currentLang);
return WritePrivateProfileString (_T("Language"), _T("LanguageOpt"), strLang, GetConfigFilePath());
}
CString IniUtil::ReadSingleConfigInfo(const CString& strSection, const CString strKey)
{
CString strVal;
GetPrivateProfileString(strSection, strKey, _T(""), strVal.GetBuffer(MAX_PATH), MAX_PATH, GetConfigFilePath());
strVal.ReleaseBuffer();
return strVal;
}
bool IniUtil::WriteSingleConfigInfo(const CString& strSection, const CString& strKey, const CString& strVal)
{
return WritePrivateProfileString (strSection, strKey, strVal, GetConfigFilePath());
}
CString IniUtil::ReadResString(const CString strKey)
{
CString strConfigFile = GetLangFilePath();
CString strVal;
GetPrivateProfileString(_T("String"), strKey, _T(""), strVal.GetBuffer(MAX_PATH), MAX_PATH, strConfigFile);
strVal.ReleaseBuffer();
return strVal;
}
| [
"iloveghq@sina.com"
] | iloveghq@sina.com |
5661709c12858e0d2c2e1b8ea3fda2c60d64a7bd | bf61e58c6afa4545d3800de2c354e4a53041a91b | /Plugins/win32/arunity/Controller.h | 04dea028aa47e32ebd0a006cf80f823fbe5d6ee3 | [
"Apache-2.0"
] | permissive | ly774508966/ARUnity | 0828dd232746fed6adc9590d376d5397aacc0389 | a29d8a34d03d272c86d26b9a3026ae1b55dff69c | refs/heads/master | 2021-01-18T20:19:09.235486 | 2016-09-01T06:10:03 | 2016-09-01T06:10:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,022 | h | #ifndef __CONTROLLER_H__
#define __CONTROLLER_H__
#include <memory>
#include <unordered_map>
#include "opencv2/opencv.hpp"
#include "Common.h"
#include "Marker.h"
class ICamera;
class Controller{
public:
/**********************************************************************************************//**
* @enum Mode
*
* @brief Values that represent modes.
**************************************************************************************************/
enum Mode
{
MODE_IDLE,
MODE_AR,
MODE_CALIBRATE
};
Controller();
~Controller();
/**********************************************************************************************//**
* @fn bool Controller::init();
*
* @brief Init the controller.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @return true if it succeeds, false if it fails.
**************************************************************************************************/
bool init();
/**********************************************************************************************//**
* @fn bool Controller::release();
*
* @brief Releases this object.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @return true if it succeeds, false if it fails.
**************************************************************************************************/
bool release();
/**********************************************************************************************//**
* @fn bool Controller::start_camera();
*
* @brief Starts a camera.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @return true if it succeeds, false if it fails.
**************************************************************************************************/
bool start_camera();
/**********************************************************************************************//**
* @fn bool Controller::stop_camera();
*
* @brief Stops a camera.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @return true if it succeeds, false if it fails.
**************************************************************************************************/
bool stop_camera();
/**********************************************************************************************//**
* @fn void Controller::start_algo();
*
* @brief Starts the algorithm.
*
* @author liu-wenwu
* @date 2016/8/29
**************************************************************************************************/
void start_algorithm();
/**********************************************************************************************//**
* @fn void Controller::stop_algorithm();
*
* @brief Stops the algorithm.
*
* @author liu-wenwu
* @date 2016/8/29
**************************************************************************************************/
void stop_algorithm();
/**********************************************************************************************//**
* @fn void Controller::set_camera_selector(CAMERA_SELECTOR selector);
*
* @brief Set the callback of camera selector.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param selector the callback of camera selector.
**************************************************************************************************/
void set_camera_selector(CAMERA_SELECTOR selector);
/**********************************************************************************************//**
* @fn void Controller::set_data_dir(const char *dir);
*
* @brief Set data dir.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param dir The data dir.
**************************************************************************************************/
void set_data_dir(const char *dir);
/**********************************************************************************************//**
* @fn void Controller::set_camera_para(float *m, float *d);
*
* @brief Sets camera parameter.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param [in] m Camera internal parameters,3x3 matrix.
* @param [in] d Camera distortion parameters,length is 5.
**************************************************************************************************/
void set_camera_para(float *m, float *d);
/**********************************************************************************************//**
* @fn void Controller::set_calibrate_chessboard(int rows, int cols, float size);
*
* @brief Sets calibrate chessboard.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param rows The rows of chessboard.
* @param cols The cols of chessboard.
* @param size The size of chessboard(m).
**************************************************************************************************/
void set_calibrate_chessboard(int rows, int cols, float size);
/**********************************************************************************************//**
* @fn void Controller::set_auto_calibrate(bool auto_cali);
*
* @brief Sets automatic calibrate.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param auto_cali true to automatically cali.
**************************************************************************************************/
void set_auto_calibrate(bool auto_cali);
/**********************************************************************************************//**
* @fn int Controller::get_camera_count();
*
* @brief Gets camera count.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @return The camera count.
**************************************************************************************************/
int get_camera_count();
/**********************************************************************************************//**
* @fn bool Controller::get_camera_name(int idx, char *buffer, int buff_len);
*
* @brief Gets camera name.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param idx The index of camera.
* @param [in,out] buffer If non-null, the buffer.
* @param buff_len Length of the buffer.
*
* @return true if it succeeds, false if it fails.
**************************************************************************************************/
bool get_camera_name(int idx, char *buffer, int buff_len);
/**********************************************************************************************//**
* @fn bool Controller::get_camera_size(int *width, int *height);
*
* @brief Gets camera size.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param [in,out] width If non-null, the width.
* @param [in,out] height If non-null, the height.
*
* @return true if it succeeds, false if it fails.
**************************************************************************************************/
bool get_camera_size(int *width, int *height);
/**********************************************************************************************//**
* @fn void Controller::update_frame(unsigned int *buffer);
*
* @brief Updates the frame described by buffer.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param [in,out] buffer If non-null, the buffer.
**************************************************************************************************/
void update_frame(unsigned int *buffer);//RGBA
/**********************************************************************************************//**
* @fn int Controller::get_markers_count();
*
* @brief Gets markers count.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @return The markers count.
**************************************************************************************************/
int get_markers_count();
/**********************************************************************************************//**
* @fn void Controller::get_markers_ids(int *ids);
*
* @brief Gets markers identifiers.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param [in,out] ids If non-null, the identifiers.
**************************************************************************************************/
void get_markers_ids(int *ids);
/**********************************************************************************************//**
* @fn bool Controller::get_marker_tracked(int id);
*
* @brief Gets marker tracked.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param id The identifier.
*
* @return true if it succeeds, false if it fails.
**************************************************************************************************/
bool get_marker_tracked(int id);
/**********************************************************************************************//**
* @fn bool Controller::get_marker_pose(int id, float *mat);
*
* @brief Gets marker pose.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param id The identifier of marker.
* @param [out] 4x4 mat, the matrix of marker pose.
*
* @return true if it succeeds, false if it fails.
**************************************************************************************************/
bool get_marker_pose(int id, float *mat);
/**********************************************************************************************//**
* @fn void Controller::add_marker(int id, float length);
*
* @brief Adds a marker to 'length'.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param id The identifier.
* @param length The length.
**************************************************************************************************/
void add_marker(int id, float length);
/**********************************************************************************************//**
* @fn bool Controller::exist_marker(int id);
*
* @brief Query whether the marker has been added.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param id The identifier.
*
* @return true if it succeeds, false if it fails.
**************************************************************************************************/
bool exist_marker(int id);
/**********************************************************************************************//**
* @fn bool Controller::get_projection(float *m,float width, float height, float near_plane, float far_plane);
*
* @brief Gets a projection.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param [out] m If non-null, the projection matrix(4x4).
* @param width The width.
* @param height The height.
* @param near_plane The near plane.
* @param far_plane The far plane.
*
* @return true if it succeeds, false if it fails.
**************************************************************************************************/
bool get_projection(float *m,float width, float height, float near_plane, float far_plane);
/**********************************************************************************************//**
* @fn bool Controller::get_marker_texture(int id, int size, unsigned int *buffer);
*
* @brief Get the marker texture.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param id The identifier of marker.
* @param size The size of marker image.
* @param [in,out] buffer If non-null, the buffer.
*
* @return true if it succeeds, false if it fails.
**************************************************************************************************/
bool get_marker_texture(int id, int size, char *filepath);
int get_dictionary_words();
int get_dictionary();
void set_dictionary(int dict);
void draw_result(cv::Mat &img);
private:
/** @brief The camera instance. */
std::shared_ptr<ICamera> camera;
/** @brief The data dir. */
std::string data_dir;
/** @brief The camera selector. */
CAMERA_SELECTOR camera_selector;
/** @brief Identifier for the camera. */
int camera_id;
int dict_id;
/** @brief The dictionary. */
cv::Ptr<cv::aruco::Dictionary> dictionary;
/** @brief The markers. */
std::unordered_map<int, Marker> markers;
/**********************************************************************************************//**
* @fn bool Controller::run_calibrate(const cv::Mat &in);
*
* @brief Executes the calibrate operation.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param in The in.
*
* @return true if it succeeds, false if it fails.
**************************************************************************************************/
bool run_calibrate(const cv::Mat &in);
/**********************************************************************************************//**
* @fn void Controller::run_algo(cv::Mat &in);
*
* @brief Executes the algo operation.
*
* @author liu-wenwu
* @date 2016/8/29
*
* @param [in,out] in The in.
**************************************************************************************************/
void run_algorithm(cv::Mat &in);
/**********************************************************************************************//**
* @fn void Controller::estimate_pose(const std::vector< cv::Point2f > &corners, float markerLength, cv::Vec3d &rvec, cv::Vec3d &tvec);
*
* @brief Estimate pose of marker.
*
* @author liu-wenwu
* @date 2016/8/30
*
* @param corners The corners.
* @param markerLength Length of the marker.
* @param [out] rvec The rotation vector.
* @param [out] tvec The translation vector.
**************************************************************************************************/
void estimate_pose(const std::vector< cv::Point2f > &corners, float markerLength, cv::Vec3d &rvec, cv::Vec3d &tvec);
void calc_projection(cv::Mat& camera_matrix, float width, float height, float near_plane, float far_plane, float* projection_matrix);
void calc_modelview(cv::Mat& rotation, cv::Mat& translation, float* model_view_matrix);
bool auto_calibrate;
Mode mode;
bool algo_enabled;
float projection[16];
};
#endif
| [
"liu-wenwu@foxmail.com"
] | liu-wenwu@foxmail.com |
cb1400546965851e5a3923105ea84fcb94872ee5 | 5e6386cb102b4734c5944a090b0777e9795b30f7 | /src/opt/tail_call.cpp | 5775156a4aef14f03dccf79ae74bd7305cf5e0f8 | [
"BSD-3-Clause"
] | permissive | buresm11/zr | 47e0dfdc23057ea4cac868b856acb2ab5710a9b5 | 92cd1ad620c0493f95d8132da8315c80356e789c | refs/heads/master | 2021-04-06T08:54:56.574474 | 2018-05-10T15:55:18 | 2018-05-10T15:55:18 | 124,690,959 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 85 | cpp |
#include "opt/tail_call.h"
char tail_call::ID = 0;
char tail_call_analysis::ID = 0; | [
"buresm11@fit.cvut.cz"
] | buresm11@fit.cvut.cz |
712135c0a829e16bcaa5e9e16e1849382c6d6be0 | a26575054e41cc73f9eb2603ba0008694a038126 | /vts/vm/src/test/vm/jvmti/funcs/GetClassMethods/GetClassMethods0105/GetClassMethods0105.cpp | 90cf152ac731c38d5368f3dbe849e902de6b1ae0 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] | permissive | FLORG1/drlvm-vts-bundle | e269ede0e2c41b402315100d7bb830f6c3d8a097 | 61f0d5a91d2e703d95e669298a84fc18ae9f050d | refs/heads/master | 2021-01-17T20:34:24.999958 | 2015-04-23T18:54:38 | 2015-04-23T18:54:38 | 45,146,096 | 2 | 0 | null | 2015-10-28T22:39:44 | 2015-10-28T22:39:43 | null | UTF-8 | C++ | false | false | 2,799 | cpp | /*
Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
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.
*/
/**
* @author Valentin Al. Sitnick
* @version $Revision: 1.1 $
*
*/
/* *********************************************************************** */
#include "events.h"
#include "utils.h"
#include "fake.h"
static bool test = false;
static bool util = false;
static bool flag = false;
const char test_case_name[] = "GetClassMethods0105";
/* *********************************************************************** */
JNIEXPORT jint JNICALL Agent_OnLoad(prms_AGENT_ONLOAD)
{
Callbacks CB;
check_AGENT_ONLOAD;
jvmtiEvent events[] = { JVMTI_EVENT_CLASS_PREPARE, JVMTI_EVENT_VM_DEATH };
cb_clprep;
cb_death;
return func_for_Agent_OnLoad(vm, options, reserved, &CB, events,
sizeof(events)/4, test_case_name, DEBUG_OUT);
}
/* *********************************************************************** */
void JNICALL callbackClassPrepare(prms_CLS_PRPR)
{
check_CLS_PRPR;
if (flag) return;
char* signature;
char* generic;
jint met_num;
jvmtiError result;
result = jvmti_env->GetClassSignature(klass, &signature,&generic);
if (strcmp(signature, "Lorg/apache/harmony/vts/test/vm/jvmti/GetClassMethods0105;")) return;
fprintf(stderr, "\tnative: GetClassSignature result = %d (must be zero) \n", result);
fprintf(stderr, "\tnative: klass ptr is %p \n", klass);
fprintf(stderr, "\tnative: signature is %s \n", signature);
fprintf(stderr, "\tnative: generic is %s \n", generic);
fflush(stderr);
if (result != JVMTI_ERROR_NONE) return;
flag = true;
util = true;
result = jvmti_env->GetClassMethods(klass, &met_num, NULL);
fprintf(stderr, "\tnative: GetClassMethods result = %d (must be JVMTI_ERROR_NULL_POINTER (100)) \n", result);
fflush(stderr);
if ( result != JVMTI_ERROR_NULL_POINTER ) return;
test = true;
}
void JNICALL callbackVMDeath(prms_VMDEATH)
{
check_VMDEATH;
func_for_callback_VMDeath(jni_env, jvmti_env, test_case_name, test, util);
}
/* *********************************************************************** */
| [
"niklas@therning.org"
] | niklas@therning.org |
f13e3a47393dcdffa78a9584ae3df76c0a2ca94a | d6442b20db93f35b2342bc12555d6a3e632da95e | /friend.cpp | bd2605852e35c97558808a1d51e86fa6182c11fe | [
"MIT"
] | permissive | avinal/C_ode | 3e5d1a9f29e3c9a1f76613a8b7fd807b72610cb6 | f056da37c8c56a4a62a06351c2ea3773d16d1b11 | refs/heads/master | 2021-09-29T06:06:01.392351 | 2021-09-18T07:36:25 | 2021-09-18T07:36:25 | 238,019,525 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,197 | cpp | #include<iostream>
class GrandFather;
class GrandPaFrd{
public:
void dance(GrandFather&);
};
class GrandFather{
int age = 75;
// constructor
GrandFather(){
std::cout << "in the grandFather Class\n";
}
void grannyAge(void);
public:
friend class GrandMother;
// when a specific function of other class is allowed to acess private members
friend void GrandPaFrd::dance(GrandFather&);
};
class GrandMother{
public:
char* name;
// int testdata;
GrandMother(){
std::cout << "in the GrandMother Class\n";
}
// function to access private member of private class GrandPa
void showGrandPaAge(GrandFather&);
};
// Member function declarations
void GrandFather::grannyAge(){
std::cout << "Granny is old and fragile\n";
}
void GrandPaFrd::dance(GrandFather &abc){
// accesing private member age in frd class
// CREATING AN OBJECT IS NECCESSARY
int dage;
std::cout << "Grand Father's friend dances";
}
void GrandMother::showGrandPaAge(GrandFather &abc){
std::cout << "Grandma thinks Granpa age is :"<< abc.age <<"\n";
}
int main(){
return 0;
} | [
"avinal.xlvii@gmail.com"
] | avinal.xlvii@gmail.com |
9b96706513af1a394efc610fd087cc90f8f0cabd | 443d188c1162c4a1135ced15aeaf61f11b7e4fa6 | /ldap/xpcom/src/nsLDAPOperation.cpp | eaeecb7fa44aca8effe2b685398b46c81bc68fcb | [] | no_license | rivy/FossaMail | 6525e747f3025ab7e37955487cf5ddc301064902 | 94f054b4dba816a7fbef3b90427443cb2bdf541f | refs/heads/master | 2021-01-12T11:34:24.212019 | 2016-10-25T19:30:06 | 2016-10-25T19:30:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 28,961 | cpp | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsLDAPInternal.h"
#include "nsLDAPOperation.h"
#include "nsLDAPBERValue.h"
#include "nsILDAPMessage.h"
#include "nsILDAPModification.h"
#include "nsIComponentManager.h"
#include "nspr.h"
#include "nsISimpleEnumerator.h"
#include "nsLDAPControl.h"
#include "nsILDAPErrors.h"
#include "nsIClassInfoImpl.h"
#include "nsIAuthModule.h"
#include "nsArrayUtils.h"
#include "nsMemory.h"
// Helper function
static nsresult TranslateLDAPErrorToNSError(const int ldapError)
{
switch (ldapError) {
case LDAP_SUCCESS:
return NS_OK;
case LDAP_ENCODING_ERROR:
return NS_ERROR_LDAP_ENCODING_ERROR;
case LDAP_CONNECT_ERROR:
return NS_ERROR_LDAP_CONNECT_ERROR;
case LDAP_SERVER_DOWN:
return NS_ERROR_LDAP_SERVER_DOWN;
case LDAP_NO_MEMORY:
return NS_ERROR_OUT_OF_MEMORY;
case LDAP_NOT_SUPPORTED:
return NS_ERROR_LDAP_NOT_SUPPORTED;
case LDAP_PARAM_ERROR:
return NS_ERROR_INVALID_ARG;
case LDAP_FILTER_ERROR:
return NS_ERROR_LDAP_FILTER_ERROR;
default:
PR_LOG(gLDAPLogModule, PR_LOG_ERROR,
("TranslateLDAPErrorToNSError: "
"Do not know how to translate LDAP error: 0x%x", ldapError));
return NS_ERROR_UNEXPECTED;
}
}
// constructor
nsLDAPOperation::nsLDAPOperation()
{
}
// destructor
nsLDAPOperation::~nsLDAPOperation()
{
}
NS_IMPL_CLASSINFO(nsLDAPOperation, NULL, nsIClassInfo::THREADSAFE,
NS_LDAPOPERATION_CID)
NS_IMPL_THREADSAFE_ADDREF(nsLDAPOperation)
NS_IMPL_THREADSAFE_RELEASE(nsLDAPOperation)
NS_INTERFACE_MAP_BEGIN(nsLDAPOperation)
NS_INTERFACE_MAP_ENTRY(nsILDAPOperation)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsILDAPOperation)
NS_IMPL_QUERY_CLASSINFO(nsLDAPOperation)
NS_INTERFACE_MAP_END_THREADSAFE
NS_IMPL_CI_INTERFACE_GETTER1(nsLDAPOperation, nsILDAPOperation)
/**
* Initializes this operation. Must be called prior to use.
*
* @param aConnection connection this operation should use
* @param aMessageListener where are the results are called back to.
*/
NS_IMETHODIMP
nsLDAPOperation::Init(nsILDAPConnection *aConnection,
nsILDAPMessageListener *aMessageListener,
nsISupports *aClosure)
{
if (!aConnection) {
return NS_ERROR_ILLEGAL_VALUE;
}
// so we know that the operation is not yet running (and therefore don't
// try and call ldap_abandon_ext() on it) or remove it from the queue.
//
mMsgID = 0;
// set the member vars
//
mConnection = static_cast<nsLDAPConnection*>(aConnection);
mMessageListener = aMessageListener;
mClosure = aClosure;
// cache the connection handle
//
mConnectionHandle =
mConnection->mConnectionHandle;
return NS_OK;
}
NS_IMETHODIMP
nsLDAPOperation::GetClosure(nsISupports **_retval)
{
if (!_retval) {
return NS_ERROR_ILLEGAL_VALUE;
}
NS_IF_ADDREF(*_retval = mClosure);
return NS_OK;
}
NS_IMETHODIMP
nsLDAPOperation::SetClosure(nsISupports *aClosure)
{
mClosure = aClosure;
return NS_OK;
}
NS_IMETHODIMP
nsLDAPOperation::GetConnection(nsILDAPConnection* *aConnection)
{
if (!aConnection) {
return NS_ERROR_ILLEGAL_VALUE;
}
*aConnection = mConnection;
NS_IF_ADDREF(*aConnection);
return NS_OK;
}
void
nsLDAPOperation::Clear()
{
mMessageListener = nullptr;
mClosure = nullptr;
mConnection = nullptr;
}
NS_IMETHODIMP
nsLDAPOperation::GetMessageListener(nsILDAPMessageListener **aMessageListener)
{
if (!aMessageListener) {
return NS_ERROR_ILLEGAL_VALUE;
}
*aMessageListener = mMessageListener;
NS_IF_ADDREF(*aMessageListener);
return NS_OK;
}
NS_IMETHODIMP
nsLDAPOperation::SaslBind(const nsACString &service,
const nsACString &mechanism,
nsIAuthModule *authModule)
{
nsresult rv;
nsAutoCString bindName;
struct berval creds;
unsigned int credlen;
mAuthModule = authModule;
mMechanism.Assign(mechanism);
rv = mConnection->GetBindName(bindName);
NS_ENSURE_SUCCESS(rv, rv);
creds.bv_val = NULL;
mAuthModule->Init(PromiseFlatCString(service).get(),
nsIAuthModule::REQ_DEFAULT, nullptr,
NS_ConvertUTF8toUTF16(bindName).get(), nullptr);
rv = mAuthModule->GetNextToken(nullptr, 0, (void **)&creds.bv_val,
&credlen);
if (NS_FAILED(rv) || !creds.bv_val)
return rv;
creds.bv_len = credlen;
const int lderrno = ldap_sasl_bind(mConnectionHandle, bindName.get(),
mMechanism.get(), &creds, NULL, NULL,
&mMsgID);
nsMemory::Free(creds.bv_val);
if (lderrno != LDAP_SUCCESS)
return TranslateLDAPErrorToNSError(lderrno);
// make sure the connection knows where to call back once the messages
// for this operation start coming in
rv = mConnection->AddPendingOperation(mMsgID, this);
if (NS_FAILED(rv))
(void)ldap_abandon_ext(mConnectionHandle, mMsgID, 0, 0);
return rv;
}
NS_IMETHODIMP
nsLDAPOperation::SaslStep(const char *token, uint32_t tokenLen)
{
nsresult rv;
nsAutoCString bindName;
struct berval clientCreds;
struct berval serverCreds;
unsigned int credlen;
rv = mConnection->RemovePendingOperation(mMsgID);
NS_ENSURE_SUCCESS(rv, rv);
serverCreds.bv_val = (char *) token;
serverCreds.bv_len = tokenLen;
rv = mConnection->GetBindName(bindName);
NS_ENSURE_SUCCESS(rv, rv);
rv = mAuthModule->GetNextToken(serverCreds.bv_val, serverCreds.bv_len,
(void **) &clientCreds.bv_val, &credlen);
NS_ENSURE_SUCCESS(rv, rv);
clientCreds.bv_len = credlen;
const int lderrno = ldap_sasl_bind(mConnectionHandle, bindName.get(),
mMechanism.get(), &clientCreds, NULL,
NULL, &mMsgID);
nsMemory::Free(clientCreds.bv_val);
if (lderrno != LDAP_SUCCESS)
return TranslateLDAPErrorToNSError(lderrno);
// make sure the connection knows where to call back once the messages
// for this operation start coming in
rv = mConnection->AddPendingOperation(mMsgID, this);
if (NS_FAILED(rv))
(void)ldap_abandon_ext(mConnectionHandle, mMsgID, 0, 0);
return rv;
}
// wrapper for ldap_simple_bind()
//
NS_IMETHODIMP
nsLDAPOperation::SimpleBind(const nsACString& passwd)
{
nsRefPtr<nsLDAPConnection> connection = mConnection;
// There is a possibilty that mConnection can be cleared by another
// thread. Grabbing a local reference to mConnection may avoid this.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=557928#c1
nsresult rv;
nsAutoCString bindName;
int32_t originalMsgID = mMsgID;
// Ugly hack alert:
// the first time we get called with a passwd, remember it.
// Then, if we get called again w/o a password, use the
// saved one. Getting called again means we're trying to
// fall back to VERSION2.
// Since LDAP operations are thrown away when done, it won't stay
// around in memory.
if (!passwd.IsEmpty())
mSavePassword = passwd;
NS_PRECONDITION(mMessageListener != 0, "MessageListener not set");
rv = connection->GetBindName(bindName);
if (NS_FAILED(rv))
return rv;
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
("nsLDAPOperation::SimpleBind(): called; bindName = '%s'; ",
bindName.get()));
// If this is a second try at binding, remove the operation from pending ops
// because msg id has changed...
if (originalMsgID)
connection->RemovePendingOperation(originalMsgID);
mMsgID = ldap_simple_bind(mConnectionHandle, bindName.get(),
mSavePassword.get());
if (mMsgID == -1) {
// XXX Should NS_ERROR_LDAP_SERVER_DOWN cause a rebind here?
return TranslateLDAPErrorToNSError(ldap_get_lderrno(mConnectionHandle,
0, 0));
}
// make sure the connection knows where to call back once the messages
// for this operation start coming in
rv = connection->AddPendingOperation(mMsgID, this);
switch (rv) {
case NS_OK:
break;
// note that the return value of ldap_abandon_ext() is ignored, as
// there's nothing useful to do with it
case NS_ERROR_OUT_OF_MEMORY:
(void)ldap_abandon_ext(mConnectionHandle, mMsgID, 0, 0);
return NS_ERROR_OUT_OF_MEMORY;
break;
case NS_ERROR_UNEXPECTED:
case NS_ERROR_ILLEGAL_VALUE:
default:
(void)ldap_abandon_ext(mConnectionHandle, mMsgID, 0, 0);
return NS_ERROR_UNEXPECTED;
}
return NS_OK;
}
/**
* Given an nsIArray of nsILDAPControls, return the appropriate
* zero-terminated array of LDAPControls ready to pass in to the C SDK.
*/
static nsresult
convertControlArray(nsIArray *aXpcomArray, LDAPControl ***aArray)
{
// get the size of the original array
uint32_t length;
nsresult rv = aXpcomArray->GetLength(&length);
NS_ENSURE_SUCCESS(rv, rv);
// don't allocate an array if someone passed us in an empty one
if (!length) {
*aArray = 0;
return NS_OK;
}
// allocate a local array of the form understood by the C-SDK;
// +1 is to account for the final null terminator. PR_Calloc is
// is used so that ldap_controls_free will work anywhere during the
// iteration
LDAPControl **controls =
static_cast<LDAPControl **>
(PR_Calloc(length+1, sizeof(LDAPControl)));
// prepare to enumerate the array
nsCOMPtr<nsISimpleEnumerator> enumerator;
rv = aXpcomArray->Enumerate(getter_AddRefs(enumerator));
NS_ENSURE_SUCCESS(rv, rv);
bool moreElements;
rv = enumerator->HasMoreElements(&moreElements);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t i = 0;
while (moreElements) {
// get the next array element
nsCOMPtr<nsISupports> isupports;
rv = enumerator->GetNext(getter_AddRefs(isupports));
if (NS_FAILED(rv)) {
ldap_controls_free(controls);
return rv;
}
nsCOMPtr<nsILDAPControl> control = do_QueryInterface(isupports, &rv);
if (NS_FAILED(rv)) {
ldap_controls_free(controls);
return NS_ERROR_INVALID_ARG; // bogus element in the array
}
nsLDAPControl *ctl = static_cast<nsLDAPControl *>
(static_cast<nsILDAPControl *>
(control.get()));
// convert it to an LDAPControl structure placed in the new array
rv = ctl->ToLDAPControl(&controls[i]);
if (NS_FAILED(rv)) {
ldap_controls_free(controls);
return rv;
}
// on to the next element
rv = enumerator->HasMoreElements(&moreElements);
if (NS_FAILED(rv)) {
ldap_controls_free(controls);
return NS_ERROR_UNEXPECTED;
}
++i;
}
*aArray = controls;
return NS_OK;
}
NS_IMETHODIMP
nsLDAPOperation::SearchExt(const nsACString& aBaseDn, int32_t aScope,
const nsACString& aFilter,
const nsACString &aAttributes,
PRIntervalTime aTimeOut, int32_t aSizeLimit)
{
if (!mMessageListener) {
NS_ERROR("nsLDAPOperation::SearchExt(): mMessageListener not set");
return NS_ERROR_NOT_INITIALIZED;
}
// XXX add control logging
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
("nsLDAPOperation::SearchExt(): called with aBaseDn = '%s'; "
"aFilter = '%s'; aAttributes = %s; aSizeLimit = %d",
PromiseFlatCString(aBaseDn).get(),
PromiseFlatCString(aFilter).get(),
PromiseFlatCString(aAttributes).get(), aSizeLimit));
LDAPControl **serverctls = 0;
nsresult rv;
if (mServerControls) {
rv = convertControlArray(mServerControls, &serverctls);
if (NS_FAILED(rv)) {
PR_LOG(gLDAPLogModule, PR_LOG_ERROR,
("nsLDAPOperation::SearchExt(): error converting server "
"control array: %x", rv));
return rv;
}
}
LDAPControl **clientctls = 0;
if (mClientControls) {
rv = convertControlArray(mClientControls, &clientctls);
if (NS_FAILED(rv)) {
PR_LOG(gLDAPLogModule, PR_LOG_ERROR,
("nsLDAPOperation::SearchExt(): error converting client "
"control array: %x", rv));
ldap_controls_free(serverctls);
return rv;
}
}
// Convert our comma separated string to one that the C-SDK will like, i.e.
// convert to a char array and add a last NULL element.
nsTArray<nsCString> attrArray;
ParseString(aAttributes, ',', attrArray);
char **attrs = nullptr;
uint32_t origLength = attrArray.Length();
if (origLength)
{
attrs = static_cast<char **> (NS_Alloc((origLength + 1) * sizeof(char *)));
if (!attrs)
return NS_ERROR_OUT_OF_MEMORY;
for (uint32_t i = 0; i < origLength; ++i)
attrs[i] = ToNewCString(attrArray[i]);
attrs[origLength] = 0;
}
// XXX deal with timeout here
int retVal = ldap_search_ext(mConnectionHandle,
PromiseFlatCString(aBaseDn).get(),
aScope, PromiseFlatCString(aFilter).get(),
attrs, 0, serverctls, clientctls, 0,
aSizeLimit, &mMsgID);
// clean up
ldap_controls_free(serverctls);
ldap_controls_free(clientctls);
// The last entry is null, so no need to free that.
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(origLength, attrs);
rv = TranslateLDAPErrorToNSError(retVal);
NS_ENSURE_SUCCESS(rv, rv);
// make sure the connection knows where to call back once the messages
// for this operation start coming in
//
rv = mConnection->AddPendingOperation(mMsgID, this);
if (NS_FAILED(rv)) {
switch (rv) {
case NS_ERROR_OUT_OF_MEMORY:
(void)ldap_abandon_ext(mConnectionHandle, mMsgID, 0, 0);
return NS_ERROR_OUT_OF_MEMORY;
default:
(void)ldap_abandon_ext(mConnectionHandle, mMsgID, 0, 0);
NS_ERROR("nsLDAPOperation::SearchExt(): unexpected error in "
"mConnection->AddPendingOperation");
return NS_ERROR_UNEXPECTED;
}
}
return NS_OK;
}
NS_IMETHODIMP
nsLDAPOperation::GetMessageID(int32_t *aMsgID)
{
if (!aMsgID) {
return NS_ERROR_ILLEGAL_VALUE;
}
*aMsgID = mMsgID;
return NS_OK;
}
// as far as I can tell from reading the LDAP C SDK code, abandoning something
// that has already been abandoned does not return an error
//
NS_IMETHODIMP
nsLDAPOperation::AbandonExt()
{
nsresult rv;
nsresult retStatus = NS_OK;
if ( mMessageListener == 0 || mMsgID == 0 ) {
NS_ERROR("nsLDAPOperation::AbandonExt(): mMessageListener or "
"mMsgId not initialized");
return NS_ERROR_NOT_INITIALIZED;
}
// XXX handle controls here
if (mServerControls || mClientControls) {
return NS_ERROR_NOT_IMPLEMENTED;
}
rv = TranslateLDAPErrorToNSError(ldap_abandon_ext(mConnectionHandle,
mMsgID, 0, 0));
NS_ENSURE_SUCCESS(rv, rv);
// try to remove it from the pendingOperations queue, if it's there.
// even if something goes wrong here, the abandon() has already succeeded
// succeeded (and there's nothing else the caller can reasonably do),
// so we only pay attention to this in debug builds.
//
// check mConnection in case we're getting bit by
// http://bugzilla.mozilla.org/show_bug.cgi?id=239729, wherein we
// theorize that ::Clearing the operation is nulling out the mConnection
// from another thread.
if (mConnection)
{
rv = mConnection->RemovePendingOperation(mMsgID);
if (NS_FAILED(rv)) {
// XXXdmose should we keep AbandonExt from happening on multiple
// threads at the same time? that's when this condition is most
// likely to occur. i _think_ the LDAP C SDK is ok with this; need
// to verify.
//
NS_WARNING("nsLDAPOperation::AbandonExt: "
"mConnection->RemovePendingOperation(this) failed.");
}
}
return retStatus;
}
NS_IMETHODIMP
nsLDAPOperation::GetClientControls(nsIMutableArray **aControls)
{
NS_IF_ADDREF(*aControls = mClientControls);
return NS_OK;
}
NS_IMETHODIMP
nsLDAPOperation::SetClientControls(nsIMutableArray *aControls)
{
mClientControls = aControls;
return NS_OK;
}
NS_IMETHODIMP nsLDAPOperation::GetServerControls(nsIMutableArray **aControls)
{
NS_IF_ADDREF(*aControls = mServerControls);
return NS_OK;
}
NS_IMETHODIMP nsLDAPOperation::SetServerControls(nsIMutableArray *aControls)
{
mServerControls = aControls;
return NS_OK;
}
// wrappers for ldap_add_ext
//
nsresult
nsLDAPOperation::AddExt(const char *base,
nsIArray *mods,
LDAPControl **serverctrls,
LDAPControl **clientctrls)
{
if (mMessageListener == 0) {
NS_ERROR("nsLDAPOperation::AddExt(): mMessageListener not set");
return NS_ERROR_NOT_INITIALIZED;
}
LDAPMod **attrs = 0;
int retVal = LDAP_SUCCESS;
uint32_t modCount = 0;
nsresult rv = mods->GetLength(&modCount);
NS_ENSURE_SUCCESS(rv, rv);
if (mods && modCount) {
attrs = static_cast<LDAPMod **>(nsMemory::Alloc((modCount + 1) *
sizeof(LDAPMod *)));
if (!attrs) {
NS_ERROR("nsLDAPOperation::AddExt: out of memory ");
return NS_ERROR_OUT_OF_MEMORY;
}
nsAutoCString type;
uint32_t index;
for (index = 0; index < modCount && NS_SUCCEEDED(rv); ++index) {
attrs[index] = new LDAPMod();
if (!attrs[index])
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsILDAPModification> modif(do_QueryElementAt(mods, index, &rv));
if (NS_FAILED(rv))
break;
#ifdef NS_DEBUG
int32_t operation;
NS_ASSERTION(NS_SUCCEEDED(modif->GetOperation(&operation)) &&
((operation & ~LDAP_MOD_BVALUES) == LDAP_MOD_ADD),
"AddExt can only add.");
#endif
attrs[index]->mod_op = LDAP_MOD_ADD | LDAP_MOD_BVALUES;
nsresult rv = modif->GetType(type);
if (NS_FAILED(rv))
break;
attrs[index]->mod_type = ToNewCString(type);
rv = CopyValues(modif, &attrs[index]->mod_bvalues);
if (NS_FAILED(rv))
break;
}
if (NS_SUCCEEDED(rv)) {
attrs[modCount] = 0;
retVal = ldap_add_ext(mConnectionHandle, base, attrs,
serverctrls, clientctrls, &mMsgID);
}
else
// reset the modCount so we correctly free the array.
modCount = index;
}
for (uint32_t counter = 0; counter < modCount; ++counter)
delete attrs[counter];
nsMemory::Free(attrs);
return NS_FAILED(rv) ? rv : TranslateLDAPErrorToNSError(retVal);
}
/**
* wrapper for ldap_add_ext(): kicks off an async add request.
*
* @param aBaseDn Base DN to search
* @param aModCount Number of modifications
* @param aMods Array of modifications
*
* XXX doesn't currently handle LDAPControl params
*
* void addExt (in AUTF8String aBaseDn, in unsigned long aModCount,
* [array, size_is (aModCount)] in nsILDAPModification aMods);
*/
NS_IMETHODIMP
nsLDAPOperation::AddExt(const nsACString& aBaseDn,
nsIArray *aMods)
{
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
("nsLDAPOperation::AddExt(): called with aBaseDn = '%s'",
PromiseFlatCString(aBaseDn).get()));
nsresult rv = AddExt(PromiseFlatCString(aBaseDn).get(), aMods, 0, 0);
if (NS_FAILED(rv))
return rv;
// make sure the connection knows where to call back once the messages
// for this operation start coming in
rv = mConnection->AddPendingOperation(mMsgID, this);
if (NS_FAILED(rv)) {
(void)ldap_abandon_ext(mConnectionHandle, mMsgID, 0, 0);
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
("nsLDAPOperation::AddExt(): abandoned due to rv %x",
rv));
}
return rv;
}
// wrappers for ldap_delete_ext
//
nsresult
nsLDAPOperation::DeleteExt(const char *base,
LDAPControl **serverctrls,
LDAPControl **clientctrls)
{
if (mMessageListener == 0) {
NS_ERROR("nsLDAPOperation::DeleteExt(): mMessageListener not set");
return NS_ERROR_NOT_INITIALIZED;
}
return TranslateLDAPErrorToNSError(ldap_delete_ext(mConnectionHandle, base,
serverctrls, clientctrls,
&mMsgID));
}
/**
* wrapper for ldap_delete_ext(): kicks off an async delete request.
*
* @param aBaseDn Base DN to delete
*
* XXX doesn't currently handle LDAPControl params
*
* void deleteExt(in AUTF8String aBaseDn);
*/
NS_IMETHODIMP
nsLDAPOperation::DeleteExt(const nsACString& aBaseDn)
{
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
("nsLDAPOperation::DeleteExt(): called with aBaseDn = '%s'",
PromiseFlatCString(aBaseDn).get()));
nsresult rv = DeleteExt(PromiseFlatCString(aBaseDn).get(), 0, 0);
if (NS_FAILED(rv))
return rv;
// make sure the connection knows where to call back once the messages
// for this operation start coming in
rv = mConnection->AddPendingOperation(mMsgID, this);
if (NS_FAILED(rv)) {
(void)ldap_abandon_ext(mConnectionHandle, mMsgID, 0, 0);
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
("nsLDAPOperation::AddExt(): abandoned due to rv %x",
rv));
}
return rv;
}
// wrappers for ldap_modify_ext
//
nsresult
nsLDAPOperation::ModifyExt(const char *base,
nsIArray *mods,
LDAPControl **serverctrls,
LDAPControl **clientctrls)
{
if (mMessageListener == 0) {
NS_ERROR("nsLDAPOperation::ModifyExt(): mMessageListener not set");
return NS_ERROR_NOT_INITIALIZED;
}
LDAPMod **attrs = 0;
int retVal = 0;
uint32_t modCount = 0;
nsresult rv = mods->GetLength(&modCount);
NS_ENSURE_SUCCESS(rv, rv);
if (modCount && mods) {
attrs = static_cast<LDAPMod **>(nsMemory::Alloc((modCount + 1) *
sizeof(LDAPMod *)));
if (!attrs) {
NS_ERROR("nsLDAPOperation::ModifyExt: out of memory ");
return NS_ERROR_OUT_OF_MEMORY;
}
nsAutoCString type;
uint32_t index;
for (index = 0; index < modCount && NS_SUCCEEDED(rv); ++index) {
attrs[index] = new LDAPMod();
if (!attrs[index])
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsILDAPModification> modif(do_QueryElementAt(mods, index, &rv));
if (NS_FAILED(rv))
break;
int32_t operation;
nsresult rv = modif->GetOperation(&operation);
if (NS_FAILED(rv))
break;
attrs[index]->mod_op = operation | LDAP_MOD_BVALUES;
rv = modif->GetType(type);
if (NS_FAILED(rv))
break;
attrs[index]->mod_type = ToNewCString(type);
rv = CopyValues(modif, &attrs[index]->mod_bvalues);
if (NS_FAILED(rv))
break;
}
if (NS_SUCCEEDED(rv)) {
attrs[modCount] = 0;
retVal = ldap_modify_ext(mConnectionHandle, base, attrs,
serverctrls, clientctrls, &mMsgID);
}
else
// reset the modCount so we correctly free the array.
modCount = index;
}
for (uint32_t counter = 0; counter < modCount; ++counter)
delete attrs[counter];
nsMemory::Free(attrs);
return NS_FAILED(rv) ? rv : TranslateLDAPErrorToNSError(retVal);
}
/**
* wrapper for ldap_modify_ext(): kicks off an async modify request.
*
* @param aBaseDn Base DN to modify
* @param aModCount Number of modifications
* @param aMods Array of modifications
*
* XXX doesn't currently handle LDAPControl params
*
* void modifyExt (in AUTF8String aBaseDn, in unsigned long aModCount,
* [array, size_is (aModCount)] in nsILDAPModification aMods);
*/
NS_IMETHODIMP
nsLDAPOperation::ModifyExt(const nsACString& aBaseDn,
nsIArray *aMods)
{
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
("nsLDAPOperation::ModifyExt(): called with aBaseDn = '%s'",
PromiseFlatCString(aBaseDn).get()));
nsresult rv = ModifyExt(PromiseFlatCString(aBaseDn).get(),
aMods, 0, 0);
if (NS_FAILED(rv))
return rv;
// make sure the connection knows where to call back once the messages
// for this operation start coming in
rv = mConnection->AddPendingOperation(mMsgID, this);
if (NS_FAILED(rv)) {
(void)ldap_abandon_ext(mConnectionHandle, mMsgID, 0, 0);
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
("nsLDAPOperation::AddExt(): abandoned due to rv %x",
rv));
}
return rv;
}
// wrappers for ldap_rename
//
nsresult
nsLDAPOperation::Rename(const char *base,
const char *newRDn,
const char *newParent,
bool deleteOldRDn,
LDAPControl **serverctrls,
LDAPControl **clientctrls)
{
if (mMessageListener == 0) {
NS_ERROR("nsLDAPOperation::Rename(): mMessageListener not set");
return NS_ERROR_NOT_INITIALIZED;
}
return TranslateLDAPErrorToNSError(ldap_rename(mConnectionHandle, base,
newRDn, newParent,
deleteOldRDn, serverctrls,
clientctrls, &mMsgID));
}
/**
* wrapper for ldap_rename(): kicks off an async rename request.
*
* @param aBaseDn Base DN to rename
* @param aNewRDn New relative DN
* @param aNewParent DN of the new parent under which to move the
*
* XXX doesn't currently handle LDAPControl params
*
* void rename(in AUTF8String aBaseDn, in AUTF8String aNewRDn,
* in AUTF8String aNewParent, in boolean aDeleteOldRDn);
*/
NS_IMETHODIMP
nsLDAPOperation::Rename(const nsACString& aBaseDn,
const nsACString& aNewRDn,
const nsACString& aNewParent,
bool aDeleteOldRDn)
{
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
("nsLDAPOperation::Rename(): called with aBaseDn = '%s'",
PromiseFlatCString(aBaseDn).get()));
nsresult rv = Rename(PromiseFlatCString(aBaseDn).get(),
PromiseFlatCString(aNewRDn).get(),
PromiseFlatCString(aNewParent).get(),
aDeleteOldRDn, 0, 0);
if (NS_FAILED(rv))
return rv;
// make sure the connection knows where to call back once the messages
// for this operation start coming in
rv = mConnection->AddPendingOperation(mMsgID, this);
if (NS_FAILED(rv)) {
(void)ldap_abandon_ext(mConnectionHandle, mMsgID, 0, 0);
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
("nsLDAPOperation::AddExt(): abandoned due to rv %x",
rv));
}
return rv;
}
// wrappers for ldap_search_ext
//
/* static */
nsresult
nsLDAPOperation::CopyValues(nsILDAPModification* aMod, berval*** aBValues)
{
nsCOMPtr<nsIArray> values;
nsresult rv = aMod->GetValues(getter_AddRefs(values));
NS_ENSURE_SUCCESS(rv, rv);
uint32_t valuesCount;
rv = values->GetLength(&valuesCount);
NS_ENSURE_SUCCESS(rv, rv);
*aBValues = static_cast<berval **>
(nsMemory::Alloc((valuesCount + 1) *
sizeof(berval *)));
if (!*aBValues)
return NS_ERROR_OUT_OF_MEMORY;
uint32_t valueIndex;
for (valueIndex = 0; valueIndex < valuesCount; ++valueIndex) {
nsCOMPtr<nsILDAPBERValue> value(do_QueryElementAt(values, valueIndex, &rv));
berval* bval = new berval;
if (NS_FAILED(rv) || !bval) {
for (uint32_t counter = 0;
counter < valueIndex && counter < valuesCount;
++counter)
delete (*aBValues)[valueIndex];
nsMemory::Free(*aBValues);
delete bval;
return NS_ERROR_OUT_OF_MEMORY;
}
value->Get((uint32_t*)&bval->bv_len,
(uint8_t**)&bval->bv_val);
(*aBValues)[valueIndex] = bval;
}
(*aBValues)[valuesCount] = 0;
return NS_OK;
}
| [
"email@mattatobin.com"
] | email@mattatobin.com |
c2f3ebb180b730066104ffc291f695cc5c5468b3 | 2609137765a5fb9a7646361e47d1c5f68440faa3 | /inc/VEmissionHeightCalculator.h | 342e79485f1ed2df1c5305a564964c120367142e | [
"BSD-3-Clause"
] | permissive | Eventdisplay/Eventdisplay | 6133a1fcac44efb37baf25f6d91d337c1965fcd2 | 50e297561ddac0ca2db39e0391a672f2f275994b | refs/heads/main | 2023-06-24T03:58:48.287734 | 2023-06-14T06:29:25 | 2023-06-14T06:29:25 | 221,222,023 | 15 | 3 | BSD-3-Clause | 2023-08-23T15:17:56 | 2019-11-12T13:17:01 | C++ | UTF-8 | C++ | false | false | 1,782 | h | //! VEmissionHeightCalculator calculate emission height (and possibly get systematic error in energy reconstruction)
#ifndef VEmissionHeightCalculator_H
#define VEmissionHeightCalculator_H
#include "TFile.h"
#include "TF1.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TMath.h"
#include "TProfile.h"
#include <cmath>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include "VUtilities.h"
using namespace std;
class VEmissionHeightCalculator
{
private:
bool fDebug;
unsigned int fNTelPairs;
double fEmissionHeight;
double fEmissionHeightChi2;
vector< double > fEmissionHeightT;
unsigned int fNTel;
vector< double > fTelX;
vector< double > fTelY;
vector< double > fTelZ;
double getTelescopeDistanceSC( unsigned int iTel1, unsigned int iTel2, double az, double z );
double imageDistance( double c1x, double c2x, double c1y, double c2y );
public:
VEmissionHeightCalculator();
~VEmissionHeightCalculator();
double getEmissionHeight( double* cen_x, double* cen_y, double* size, double az, double el );
double getMeanEmissionHeight()
{
return fEmissionHeight;
}
double getMeanEmissionHeightChi2()
{
return fEmissionHeightChi2;
}
vector< double >& getEmissionHeights()
{
return fEmissionHeightT;
}
unsigned int getNTelPairs()
{
return fNTelPairs;
}
void setTelescopePositions( vector< float > x, vector< float > y, vector< float > z );
void setTelescopePositions( unsigned int ntel, double* x, double* y, double* z );
};
#endif
| [
"noauthor@noauthor"
] | noauthor@noauthor |
e5b2bc6283a67f6da2ea1f50bb0c6ad27243ed2d | 92365dad5ab950192e086d2dec3da4f9123a2a90 | /sword_offer/37. 两个链表的第一个公共结点.cpp | 03485cb7b1d2603f048ba65e0bf73ad22f05d2d6 | [] | no_license | roachsinai/Coding_Interviews | e2fec89c57e53fdccb55d103486685cc0d5a4a21 | bf39ee91f6b7b241067a7be79bf0023000d8c7a7 | refs/heads/master | 2020-12-26T16:48:24.749461 | 2019-01-12T09:07:39 | 2019-01-12T09:18:59 | 63,310,037 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,410 | cpp | #include <iostream>
#include <vector>
using namespace std;
struct ListNode {
int val;
struct ListNode *next;
ListNode(int x) :
val(x), next(NULL) {
}
};
class Solution {
public:
ListNode* FindFirstCommonNode( ListNode *pHead1, ListNode *pHead2) {
unsigned int length1 = GetListLength(pHead1);
unsigned int length2 = GetListLength(pHead2);
int lengthDif = length1 - length2;
ListNode* pListLong = pHead1;
ListNode* pListShort = pHead2;
if (lengthDif < 0)
{
pListLong = pHead2;
pListShort = pHead1;
lengthDif = length2 - length1;
}
// 长链后移几步
for (int i = 0; i < lengthDif; ++ i)
pListLong = pListLong->next;
while (pListLong != NULL && pListShort != NULL && pListLong != pListShort)
{
pListLong = pListLong->next;
pListShort = pListShort->next;
}
// 如果两个链表没有相交的节点,则此时两个指针都指向 NULL
return pListShort;
}
unsigned int GetListLength(ListNode *pHead)
{
unsigned int length = 0;
ListNode* pNode = pHead;
while (pNode != NULL)
{
++ length;
pNode = pNode->next;
}
return length;
}
};
int main(int argc, char const *argv[])
{
Solution s;
return 0;
}
| [
"710347541@qq.com"
] | 710347541@qq.com |
bdd409d9249a7c23df885da5c1ab0ece7ed098a8 | 2bd80beb5dc0db6833fe477dac7f36ffc1e4d97e | /src/model/temperature_sensor.h | 8275c2d73a3dec59e97172c32ff647fbcb75cb62 | [
"MIT"
] | permissive | acc-cosc-1337-fall-2018/acc-cosc-1337-oo-weather-station-allenman23 | 56d0b7ac73065c7b25a9cf5d6d86a0969909c46a | 7d4df1b2588a101ce4069243f2b8cb0016bd844f | refs/heads/master | 2020-03-29T07:48:21.544341 | 2018-09-27T23:30:35 | 2018-09-27T23:30:35 | 149,679,702 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 382 | h | #ifndef TEMPERATURE_SENSOR_H
#define TEMPERATURE_SENSOR_H
#include "temperature_observation.h"
#include <vector>
class TemperatureSensor
{
public:
void get_temperature_keyboard();
void get_temperature_file();
void get_temperature_web();
private:
std::vector<TemperatureObservation> observations;
//Reading interval in seconds
int interval;
};
#endif //TEMPERATUR_SENSOR_H
| [
"allenman23@yahoo.com"
] | allenman23@yahoo.com |
427c856542bce5a422c68224e4d59fc5eb43a943 | d67045bb4dd69667cf379d88d39429003da02719 | /lib/gbbs-counting_sort_no_transpose.h | b27662313354210720aa0a3e5bedf2bcb2b9cea2 | [
"MIT"
] | permissive | jeshi96/parbutterfly | f882ad327c9f1a25d619aedaab9b32baba6a4b76 | 06af1f082736c446c740dcd8c1d0ce2b44442ee9 | refs/heads/master | 2020-07-05T08:16:59.909161 | 2019-11-26T04:06:46 | 2019-11-26T04:06:46 | 202,586,252 | 7 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,832 | h | // This code is part of the Problem Based Benchmark Suite (PBBS)
// Copyright (c) 2010-2016 Guy Blelloch and the PBBS team
//
// 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
#include <stdio.h>
#include "sequence_ops.h"
#include "utilities.h"
namespace pbbsa {
namespace gbbs {
// the following parameters can be tuned
constexpr const size_t _cs_seq_threshold = 2048;
constexpr const size_t _cs_max_blocks = 512;
// Sequential base case for the no-transpose count sort.
template <typename b_size_t, typename s_size_t, typename E, typename I,
typename F>
inline void _seq_count_sort(I& In, E* Out, F& get_key, s_size_t start,
s_size_t end, s_size_t* counts,
s_size_t num_buckets,
s_size_t* offsets=nullptr,
b_size_t* tmp=nullptr) {
s_size_t n = end - start;
bool alloc_offsets = false;
bool alloc_tmp = false;
if (offsets == nullptr) {
new_array_no_init<s_size_t>(num_buckets);
alloc_offsets = true;
}
if (tmp == nullptr) {
new_array_no_init<b_size_t>(n);
alloc_tmp = true;
}
for (s_size_t i = 0; i < num_buckets; i++) {
offsets[i] = 0;
}
for (s_size_t j = 0; j < n; j++) {
s_size_t k = tmp[j] = get_key(j + start);
offsets[k]++;
}
size_t s = 0;
for (s_size_t i = 0; i < num_buckets; i++) {
counts[i] = s;
s += offsets[i];
offsets[i] = s;
}
for (long j = ((long)n) - 1; j >= 0; j--) {
s_size_t k = --offsets[tmp[j]];
// needed for types with self defined assignment or initialization
// otherwise equivalent to: Out[k+start] = In[j+start];
move_uninitialized(Out[k + start], In[j + start]);
}
if (alloc_offsets) {
free(offsets);
}
if (alloc_tmp) {
free(tmp);
}
}
// Parallel internal version that returns the un-transposed result
// This means that the output consists of a set of blocks, where each block is
// internally sorted into num_buckets buckets.
template <typename b_size_t, typename s_size_t, typename E, typename I,
typename F>
inline tuple<E*, s_size_t*, s_size_t> _count_sort(I& A, F& get_key, s_size_t n,
s_size_t num_buckets) {
// pad to 16 buckets to avoid false sharing (does not affect results)
size_t sqrt = (size_t)ceil(pow(n, 0.5));
size_t num_blocks = (size_t)(n < 20000000) ? (sqrt / 10) : sqrt / 4;
num_blocks = min(num_blocks, _cs_max_blocks);
num_blocks = 1 << log2_up(num_blocks);
// if insufficient parallelism, sort sequentially
if (n < _cs_seq_threshold || num_blocks == 1) {
s_size_t* counts = new_array_no_init<s_size_t>(num_buckets + 1);
E* B = new_array_no_init<E>(n);
_seq_count_sort<b_size_t>(A, B, get_key, (s_size_t)0, n, counts,
num_buckets);
return make_tuple(B, counts, (s_size_t)1);
}
s_size_t block_size = ((n - 1) / num_blocks) + 1;
s_size_t m = num_blocks * num_buckets;
// need new_array<E>(n) if E is not trivially constructable
E* B = new_array_no_init<E>(n);
s_size_t* counts = new_array_no_init<s_size_t>(m, 1);
// sort each block
s_size_t* offsets = newA(s_size_t, num_blocks*num_buckets);
b_size_t* tmp = newA(b_size_t, num_blocks*block_size);
parallel_for_bc(i, 0, num_blocks, (num_blocks > 1), {
s_size_t start = std::min(i * block_size, n);
s_size_t end = std::min(start + block_size, n);
auto our_offsets = offsets + (i*num_buckets);
auto our_tmp = tmp + (i*block_size);
_seq_count_sort<b_size_t>(A, B, get_key, start, end,
counts + i * num_buckets, num_buckets, our_offsets, our_tmp);
});
free(offsets); free(tmp);
return make_tuple(B, counts, num_blocks);
}
} // namespace gbbs
} // namespace pbbs
| [
"jeshi@scooby-snacks.csail.mit.edu"
] | jeshi@scooby-snacks.csail.mit.edu |
1843526bc93c1fe9d3148fe5bbba5ae0974531ed | 4335e39b1d955a987e43c734357e6f19debec0c4 | /compress.cpp | 58ca63fe89537c8abfefa0836face9288b286f91 | [
"MIT"
] | permissive | amichai-H/it-cp-a | aaa27a0f2c7ad6d661c057cf5e67c6e6173d81fa | 7dd6fc503ae436c1a3a95e48217ce70562a21ab8 | refs/heads/master | 2022-10-06T00:47:13.162945 | 2020-06-10T16:03:37 | 2020-06-10T16:03:37 | 271,322,187 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 74 | cpp | //
// Created by amichai hadad on 08/06/2020.
//
#include "compress.hpp"
| [
"noreply@github.com"
] | noreply@github.com |
210207850f83eb96840ec988e514d6eec0008ffe | 8dd39b654dde37c6cbde38a7e3a5c9838a237b51 | /dfs corman/main.cpp | 2520dfec34365257cfd8e345a4a2a15e6dc1b43e | [] | no_license | Taohid0/C-and-C-Plus-Plus | 43726bdaa0dc74860c4170b729e34cea268008fd | d38fd51851cc489302ad4ef6725f1d19f7e72ec2 | refs/heads/master | 2021-07-19T17:30:26.875749 | 2017-10-28T09:49:51 | 2017-10-28T09:49:51 | 108,636,340 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,058 | cpp | #include <bits/stdc++.h>
using namespace std;
#define white 0
#define gray 1
#define black 2
int t=0 ;
struct node
{
int color,parent,value,st,et;
bool operator < (const node & p)const
{
return et<p.et;
}
};
vector<node>g[100];
void dfs(node u)
{
t++;
u.st = t;
u.color = gray;
node v;
for(int i= 0;i<(int)g[u.value].size();i++)
{
v = g[u.value][i];
if(v.color==white)
{
v.parent=u.value;
}
dfs(v);
u.color = black;
t++;
u.et = t;
}
}
int main()
{
int n,e,src,des;
node u,v;
cout<<"enter the number of nodes and their edges ";
cin>>n>>e;
cout<<"enter the edges ";
for(int i = 0;i<e;i++)
{
cin>>u.value>>v.value;
u.color = white;
v.color = white;
u.parent = 0;
v.parent = 0;
g[u.value].push_back(v);
g[v.value].push_back(u);
}
sort(g.begin(),g.end());
for(int i = 0;i<4;i++)
{
cout<<v[i].et<<" ";
}
return 0;
}
| [
"taohidulii@gmail.com"
] | taohidulii@gmail.com |
71d8ec99ce975d4e131192d445e9c2f71a8504d4 | 407dfab69e940665fe0618d1143c7dfbd3cfda84 | /QT/QtScene/mysquare.cpp | 3921dda334df012577f95dd1d1a93ef2e58dd88f | [] | no_license | Ivanchik/Cpp | f8f36c715ecccfaa945997d1b82b1654cf187f8d | 2fafbc8d51d031e72d40c04dba12139b4e0b1664 | refs/heads/master | 2020-05-18T05:02:09.030126 | 2014-04-29T17:07:55 | 2014-04-29T17:07:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 48 | cpp | #include "mysquare.h"
MySquare::MySquare()
{
}
| [
"bikeev-ivan@yandex.ru"
] | bikeev-ivan@yandex.ru |
1f32d7e4adb4a89cdd85769e0cc2b868facbeba9 | 3fea771b276b5d501c0fe3cf4108614fd7ce52ee | /Projects/Breakout/Breakout/LearnOpenGL_1/src/CoordinatesTest.cpp | d5e08fc37a803f4b3bf28e58c420038a8dc90a1d | [] | no_license | diegomacario/Learning-OpenGL | 91a4a47f61d52771a5a37176aa2b2a6e9cbf2516 | cf4903387186b7d09e75ef1315c54309804c4642 | refs/heads/master | 2021-06-05T19:04:03.355725 | 2020-01-04T16:15:06 | 2020-01-04T16:15:06 | 139,003,351 | 8 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 34,356 | cpp | #include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <iostream>
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void processInput(GLFWwindow* window);
const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;
// gl_Position is a pre-defined output
const char* vertexShaderSource = "#version 330 core \n"
"layout (location = 0) in vec3 aPos; \n"
"layout (location = 1) in vec3 aCol; \n"
"uniform mat4 projection; \n"
"out vec3 ourColor; \n"
"void main() \n"
"{ \n"
" gl_Position = projection * vec4(aPos.x, aPos.y, aPos.z, 1.0); \n"
" ourColor = aCol; \n"
"} \0";
// The fragment shader only needs one output: the final color of the fragment
const char* fragmentShaderSource = "#version 330 core \n"
"in vec3 ourColor; \n"
"out vec4 FragColor; \n"
"void main() \n"
"{ \n"
" FragColor = vec4(ourColor, 1.0); \n"
"} \0";
int main()
{
// Initialize GLFW before calling any GLFW functions
// ****************************************************************************************************
glfwInit();
// Tell GLFW we want to use OpenGL version 3.3
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
// Tell GLFW we want to use the OpenGL Core Profile
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
// Create a window
// ****************************************************************************************************
GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
// Destroy all remaining windows, free any allocated resources and set GLFW to an uninitialized state
glfwTerminate();
return -1;
}
// Make the context of the specified window current on the calling thread
// A context can only be made current on a single thread at a time, and each thread can only have a single current context at a time
glfwMakeContextCurrent(window);
// Specify the function that is called when the window is resized (the resize callback)
// When the window is first displayed, this function is also called
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
// Initialize GLAD before calling any OpenGL functions
// ****************************************************************************************************
// GLAD manages function pointers for OpenGL
// We pass it the function used to load the addresses of the OpenGL function pointers, which is OS-specific
// glfwGetProcAddress defines the correct function based on the OS we are compiling for
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
std::cout << "Failed to initialize GLAD" << std::endl;
return -1;
}
glEnable(GL_DEPTH_TEST);
// Vertex shader
// ****************************************************************************************************
int vertexShader = glCreateShader(GL_VERTEX_SHADER); // glCreateShader returns 0 if an error occurs during the creation the shader object
glShaderSource(vertexShader, 1, &vertexShaderSource, NULL); // Replace the source code of a given shader
glCompileShader(vertexShader);
int success;
char infoLog[512];
// glGetShaderiv allows us to query a shader for information (GL_SHADER_TYPE, GL_DELETE_STATUS, GL_COMPILE_STATUS, GL_INFO_LOG_LENGTH, GL_SHADER_SOURCE_LENGTH)
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success);
if (!success)
{
// glGetShaderInfoLog allows us to print compilation errors
glGetShaderInfoLog(vertexShader, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl;
}
// Fragment shader
// ****************************************************************************************************
int fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
glCompileShader(fragmentShader);
glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success);
if (!success)
{
glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl;
}
// Shader program
// ****************************************************************************************************
int shaderProgram = glCreateProgram(); // A shader program is the result of linking multiple shaders together. glCreateProgram returns 0 if an error occurs during the creation the shader program
glAttachShader(shaderProgram, vertexShader);
glAttachShader(shaderProgram, fragmentShader);
glLinkProgram(shaderProgram); // When two shaders are linked, the outputs of the first one are connected with the inputs of the second one
// glGetProgramiv allows us to query a program for information
glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success);
if (!success)
{
// glGetProgramInfoLog allows us to print link errors
glGetProgramInfoLog(shaderProgram, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl;
}
// Shaders can be deleted, since they have already been attached and linked to the shader program
glDeleteShader(vertexShader);
glDeleteShader(fragmentShader);
// Initialize the relevant buffers with the data that we wish to render
// ****************************************************************************************************
// Positions Colors
// <----------------> <-------------->
float vertices[] = { 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, // Right
-0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, // Left
0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f }; // Top
unsigned int VAO, VBO;
// Create a VAO and a VBO
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
// Bind the VAO
// From this point onward, the VAO will store the vertex attribute configuration
glBindVertexArray(VAO);
// Bind the VBO and store the vertex data inside of it
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
// Connect the vertex positions that are inside VBO with attribute 0 of the vertex shader
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);
// Connect the vertex colors that are inside VBO with attribute 1 of the vertex shader
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*) (3 * sizeof(GL_FLOAT)));
glEnableVertexAttribArray(1);
// The call to glVertexAttribPointer registered VBO as the vertex attribute's bound VBO, so we can safely unbind it now.
glBindBuffer(GL_ARRAY_BUFFER, 0);
// We can also unbind VAO so that other VAO calls won't accidentally modify it
glBindVertexArray(0);
// Uncomment this call to draw in wireframe polygons.
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// The opposite is:
//glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
// Render loop
// ****************************************************************************************************
while(!glfwWindowShouldClose(window))
{
// Process keyboard input
processInput(window);
// Set the color that OpenGL uses to reset the colorbuffer
//glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
// Clear the entire buffer of the current framebuffer
// Some of the available options are:
// GL_COLOR_BUFFER_BIT (color buffer)
// GL_DEPTH_BUFFER_BIT (depth buffer)
// GL_STENCIL_BUFFER_BIT (stencil buffer)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// glUseProgram specifies the shader program that is to be used in all subsequent drawing commands
glUseProgram(shaderProgram);
glm::mat4 projection = glm::ortho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);
unsigned int projectionLoc = glGetUniformLocation(shaderProgram, "projection");
glUniformMatrix4fv(projectionLoc, 1, GL_FALSE, glm::value_ptr(projection));
// There is no need to bind the VAO in every iteration of the render loop, since there is only 1, but we will do it anyway in this example
glBindVertexArray(VAO);
// Draw
glDrawArrays(GL_TRIANGLES, 0, 3);
// There is no need to unbind the VAO in every iteration of the render loop in this example
// glBindVertexArray(0);
// Swap the front/back buffers
// The front buffer contains the final image that is displayed on the screen,
// while all the rendering commands draw to the back buffer
// When all the rendering commands are finished, the two buffers are swapped
glfwSwapBuffers(window);
// Process the events that have been received
// This will cause the window and input callbacks associated with those events to be called
glfwPollEvents();
}
glDeleteVertexArrays(1, &VAO);
glDeleteBuffers(1, &VBO);
// Destroy all remaining windows, free any allocated resources and set GLFW to an uninitialized state
glfwTerminate();
return 0;
}
// When the window is resized, the rendering window must also be resized
// For this reason, we call glViewport in the resize callback with the new dimensions of the window
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
// glViewPort specifies the size of the rendering window
// The first two parameters (x, y) set the location of the lower left corner of the rendering window
// The third and fourth parameters set the width and the height of the rendering window
// The specified coordinates tell OpenGL how it should map its Normalized Device Coordinates (NDC),
// which range from -1 to 1, to window coordinates (whose range is defined here)
// We could make the rendering window smaller than GLFW's window, and use the extra space to display a menu
// In this case, glViewport maps 2D coordinates as illustrated below:
// Horizontally: (-1, 1) -> (0, 800)
// Vertically: (-1, 1) -> (0, 600)
glViewport(0, 0, width, height);
}
// This function is used to exit the rendering the loop when the escape key is pressed
// It is called in every iteration of the render loop
void processInput(GLFWwindow* window)
{
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
{
glfwSetWindowShouldClose(window, true);
}
}
// Additional information:
// The process of transforming 3D coordinates to 2D pixels is managed by OpenGL's graphics pipeline
// The graphics pipeline can be divided into two large parts:
// 1) 3D coordinates -> 2D coordinates
// 2) 2D coordinates -> Colored pixels
// A 2D coordinate is a precise representation of where a point is in 2D space
// A 2D pixel is an approximation of a 2D point that is limited by the resolution of the window
// The steps that compose the graphics pipeline can be executed in parallel by running small programs on the GPU
// These small programs are called shaders
// Stages of the graphics pipeline:
// Vertex Shader -> Shape Assembly -> Geometry Shader -> Rasterization -> Fragment Shader -> Tests and Blending
// A vertex is a collection of data for a 3D coordinate (e.g. position, color, normal...)
// A vertex's data is represented using vertex attributes
// In order for OpenGL to know what to make of a set of vertices, you must hint what kind of render type you want to form with the data
// Do we want the data to be rendered as a collection of points, a collection of triangles or a line?
// The hints that tell OpenGL what to make of a set of vertices are called primitives.
// Examples: GL_POINTS, GL_TRIANGLES and GL_LINE_STRIP
// A fragment is all the data required by OpenGL to render a single pixel.
// Steps:
// 1) Vertex Shader: Takes as input a single vertex and transforms its position (3D -> 3D). Also allows us to do some basic processing on the vertex's attributes.
// 2) Shape Assembly: Takes as input all the vertices that form a primitive and assembles them in the primitive shape we specified.
// 3) Geometry Shader: Takes as input a collection of vertices that form a primitive and has the ability to generate other shapes by emitting new vertices to form other primitives.
// 4) Rasterization: Takes as input a primitive and maps it to its corresponding pixels on the screen, resulting in fragments for the fragment shader to use. Note that before the fragment shader runs, clipping is performed. Clipping discards all the fragments that are outside of view.
// 5) Fragment shader: Takes as input a fragment. Its main purpose is to calculate the final color of a pixel. This is where all the advanced OpenGL effects occur. The fragment shader usually contains data about the 3D scene that it can use to perform lighting calculations.
// 6) Alpha Test and Blending: Checks the depth and stencil values of a fragment to determine if it is in front or behind other objects. Additionally, it checks the alpha value and blends objects accordingly.
// We can play with the vertex, fragment and geometry shaders.
// OpenGL transforms the 3D coordinates that are in the range [-1.0, 1.0] on all 3 axes (x, y and z) to 2D pixels on the screen
// This range is called the Normalized Device Coordinates (NDC) range
// After vertex coordinates have been processed by the vertex shader, they should be in the NDC range
// Any coordinates outside of this range are clipped
// Normalized Deviced Coordinates are transformed to screen-space coordinates by the viewport transform (glViewport takes care of this)
// The resulting screen-space coordinates are transformed into fragments and given to the fragment shader
// So, how do we send vertex data to the vertex shader? Steps:
// 1) Create memory on the GPU where we can store the vertex data
// 2) Configure how OpenGL should interpret the memory
// 3) Specify how to send the data to the graphics card
// Let's break each step down:
// 1) Create memory on the GPU where we can store the vertex data
// - We manage this memory through Vertex Buffer Objects (VBO). A VBO can store a large number of vertices in the GPU's memory.
// - Using VBOs is advantageous because they allow us to send large batches of data to the graphics card all at once. Sending data from the CPU to the graphics card is slow, so we must try to send as much data as possible at once.
// float vertices[] = {...}; // Array containing the coordinates of 3 vertices
// unsigned int VBO; // Will contain unique ID (GLuint) corresponding to a buffer object
// glGenBuffers(1, &VBO); // Generate one buffer object and store its unique ID in VBO
// glBindBuffer(GL_ARRAY_BUFFER, VBO); // To change the state of a buffer object, it must first be bound to a buffer binding target
// Only a single buffer object can be bound to a given buffer binding target at a time, but different buffer objects can be bound to different buffer binding targets simultaneously
// Once a buffer object has been bound, any calls made on its buffer binding target affect its state
// Calling glBindBuffer with 0 unbinds the current buffer object
// Common buffer binding targets are: GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER and GL_TEXTURE_BUFFER
// glBufferData(GL_ARRAY_BUFFER, // Copy the vertex data into VBO's memory by calling glBufferData with the buffer binding target that VBO is bound to
// sizeof(vertices),
// vertices,
// GL_STATIC_DRAW); // This fourth parameter specifies how the graphics card should manage the given data. It can be set to 3 different values:
// GL_STATIC_DRAW: The data is not likely to change, or it will rarely change.
// GL_DYNAMIC_DRAW: The data is likely to change often.
// GL_STREAM_DRAW: The data will change every time it is drawn.
// 2) Configure how OpenGL should interpret the memory
// - How should OpenGL interpret the vertex data in memory?
// - How should it connect the vertex data to the vertex shader's attributes?
// The vertex shader allows us to specify any input we want in the form of vertex attributes
// We have to tell OpenGL how to connect our input data with the vertex attributes
// In our case, the data in VBO is organized as follows:
// | Vertex1 | Vertex2 | Vertex3 |
// | X Y Z | X Y Z | X Y Z |
// | | | | | | | | | |
// Byte: 0 4 8 12 16 20 24 28 32 36
// Offset: 0
// Pos: ------------>
// Stride: 12
// Each coordinate is a 32-bit (4 byte) floating point value
// Each position is composed of 3 coordinates (12 bytes)
// There is no space between each set of 3 values, that is, the values are tightly packed
// The first value is at the beginning of the buffer
// Knowing this, we can tell OpenGL how to interpret the vertex data for each attribute
// glVertexAttribPointer tells OpenGL how to connect the vertex data with a specific attribute when a drawing call is made.
// Each vertex attribute takes its data from the VBO that is bound to GL_ARRAY_BUFFER when the call to glVertexAttribPointer is made.
// glVertexAttribPointer(0, // Index: Specifies which vertex attribute we want to configure.
// In the vertex shader we declared the following:
// layout (location = 0) in vec3 aPos;
// So index 0 corresponds to the position vertex attribute.
// 3, // Size: Specifies the number of elements that make up the vertex attribute.
// Since the position is a vec3, we select 3.
// GL_FLOAT, // Type: Specifies the type of the elements that make up the vertex attribute.
// GL_FALSE, // Normalized: Specifies if the data should be normalized.
// 3 * sizeof(float), // Stride: Specifies the space between consecutive vertex attribute sets.
// Since the next set of position data is located exactly 3 times the size of a float away,
// we specify that value as the stride.
// (void*) 0); // Offset: Specifies the offset of where the position data begins in the buffer.
// glEnableVertexAttribArray(0); // Enables a generic vertex attribute. A vertex attribute can be disabled by calling glDisableVertexAttribArray.
// Another example of the vertex data is connected with the vertex attributes:
// Position Color TexCoords
// <--------> <--------------> <-------->
// GLfloat data[] = {1.0f, 0.0f, 0.5f, 0.5f, 0.5f, 0.0f, 0.5f,
// 0.0f, 1.0f, 0.2f, 0.8f, 0.0f, 0.0f, 1.0f};
// Position
// glEnableVertexAttribArray(0);
// glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 7 * sizeof(GL_FLOAT), (void*) 0);
//
// Color
// glEnableVertexAttribArray(1);
// glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 7 * sizeof(GL_FLOAT), (void*) (2 * sizeof(GL_FLOAT)));
//
// TexCoords
// glEnableVertexAttribArray(2);
// glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 7 * sizeof(GL_FLOAT), (void*) (5 * sizeof(GL_FLOAT)));
// So far we have the following:
// - We initialized the vertex data in a buffer using a vertex buffer object.
// - We set up vertex and fragment shaders and told OpenGL how to link the vertex data to the vertex attributes of the vertex shader.
// So drawing in OpenGL looks like this:
// A) Copy our vertices array into a buffer for OpenGL to use.
//
// glBindBuffer(GL_ARRAY_BUFFER, VBO);
// glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
//
// B) Set the vertex attributes pointers.
//
// glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*) 0);
// glEnableVertexAttribArray(0);
//
// C) Use our shader program when we want to render an object.
//
// glUseProgram(shaderProgram);
//
// D) Draw the object.
//
// ...
// If you have many objects, you need to do this for each one:
// - Bind the appropriate buffer object
// - Configure all the vertex attributes
// This is a long process. Is there a way to make it faster? Yes! Use Vertex Array Objects (VAO).
// A VAO can be bound just like a VBO, and once it is bound, it stores any vertex attribute calls.
// So we no longer need to configure all of the vertex attribute pointers multiple times.
// Instead, when we want to draw an object, we can simply load the VAO that was bound when we made the vertex attributes calls for said object.
// VAOs make it easy to switch between different vertex data and attribute configurations.
// A VAO stores the following:
// - Calls to glEnableVertexAttribArray or glDisableVertexAttribArray.
// - Vertex attribute configurations (these configurations are established using glVertexAttribPointer).
// - VBOs that are associated with vertex attributes (these associations are established when glVertexAttribPointer is called).
// When a VAO has been bound, any subsequent VBO, EBO, glVertexAttribPointer and glEnableVertexAttribArray calls are stored inside of it.
// So a VAO stores a vertex attribute configuration and which VBO to use.
// Creating a VAO is similar to creating a VBO:
// unsigned int VAO;
// glGenVertexArrays(1, &VAO);
// Using a VAO looks like this:
// A) Bind the VAO
//
// glBindVertexArray(VAO);
//
// B) Copy the vertices array into a buffer for OpenGL to use.
//
// glBindBuffer(GL_ARRAY_BUFFER, VBO);
// glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
//
// C) Set the vertex attribute pointers.
//
// glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*) 0);
// glEnableVertexAttribArray(0);
//
// D) Inside the render loop, bind the VAO and draw the object.
//
// glUseProgram(shaderProgram);
// glBindVertexArray(VAO);
// ...
// 3) Specify how to send the data to the graphics card
// To draw, OpenGL provides glDrawArrays, which draws primitives using:
// - The currently active shader program.
// - The previously defined vertex attribute configuration.
// - The vertex data in the currently bound VBO, or the vertex data that can be accessed indirectly through the currently bound VAO
// glUseProgram(shaderProgram);
// glBindVertexArray(VAO);
// glDrawArrays(GL_TRIANGLES, // Mode: Specifies the kind of primitive to render. The options are:
// GL_POINT, GL_LINE, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLE, GL_TRIANGLE_STRIP and GL_TRIANGLE_FAN.
// 0, // First: Specifies the starting index in the enabled arrays.
// 3); // Count: Specifies the number of vertices to draw.
// The vertices are obtained directly from the currently bound VBO,
// or indirectly through the currently bound VAO.
// Element Buffer Objects (EBO)
// Take a look at how we specify this rectangle:
// float vertices[] = { // First triangle
// 0.5f, 0.5f, 0.0f, // Top right
// 0.5f, -0.5f, 0.0f, // Bottom right
// -0.5f, 0.5f, 0.0f, // Top left
// // Second triangle
// 0.5f, -0.5f, 0.0f, // Bottom right
// -0.5f, -0.5f, 0.0f, // Bottom left
// -0.5f, 0.5f, 0.0f }; // Top left
// Bottom right and top left are specified twice. Is there a way to avoid this overhead? Yes! With EBOs.
// An EBO is a buffer, just like a VBO, that stores indices that OpenGL uses to decide what vertices to draw.
// This is called indexed drawing.
// Using EBOs we can draw our rectangle like this (now we only need 4 vertices!):
//
// float vertices[] = { 0.5f, 0.5f, 0.0f, // Top right
// 0.5f, -0.5f, 0.0f, // Bottom right
// -0.5f, -0.5f, 0.0f, // Bottom left
// -0.5f, 0.5f, 0.0f }; // Top left
//
// unsigned int indices[] = { 0, 1, 3, // First triangle
// 1, 2, 3 }; // Second triangle
//
// unsigned int EBO;
// glGenBuffers(1, &EBO);
//
// We use GL_ELEMENT_ARRAY_BUFFER as the buffer binding target
// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
// glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
//
// We use glDrawElements instead of glDrawArrays to indicate that we want to render triangles from an index buffer
// glDrawElements(GL_TRIANGLES, // Mode: Specifies the mode we want to draw in.
// 6, // Count: Specifies the number of elements we want to draw.
// GL_UNSIGNED_INT, // Type: Specifies the type of the indices.
// 0); // Indices: Specifies an offset in a buffer or a pointer to the location where the indices are stored (if an EBO is not used).
// glDrawElements takes its indices from the EBO that is currently bound to the GL_ELEMENT_ARRAY_BUFFER target.
// So we have to bind the corresponding EBO each time we want to render an object with indices.
// This is cumbersome. Is there a way to avoid it? Yes! Use VAOs.
// When a EBO is bound after a VAO has been bound, the VAO stores the EBO.
// In other words, a VAO stores the glBindBuffer calls when the target is GL_ELEMENT_ARRAY_BUFFER.
// This also means it stores the calls that unbind an EBO from the target GL_ELEMENT_ARRAY_BUFFER.
// So make sure you don't unbind the EBO before unbinding the VAO.
// The initialization code now looks like this:
// Initialization:
//
// A) Bind the VAO
//
// glBindVertexArray(VAO);
//
// B) Copy the vertices array into a vertex buffer for OpenGL to use
//
// glBindBuffer(GL_ARRAY_BUFFER, VBO);
// glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
//
// B) Copy the indices array into an element buffer for OpenGL to use
//
// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
// glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
//
// D) Set the vertex attribute pointers
//
// glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
// glEnableVertexAttribArray(0);
//
// ...
//
// Render loop:
//
// glUseProgram(shaderProgram);
// glBindVertexArray(VAO);
// glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0)
// glBindVertexArray(0);
// Shader structure:
// - Version declaration
// - List of input, output and uniform variables
// - Main function
// When we're talking about the vertex shader, each input variable is also known as a vertex attribute.
// The hardware determines the maximum number of vertex attributes we are allowed to declare.
// OpenGL guarantees there are always at least 16 4-component vertex attributes available.
// To know the maximum number of vertex attributes supported by your hardware, query GL_MAX_VERTEX_ATTRIBS:
// int numVertexAttributes;
// glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttributes);
// GLSL basic types: int, float, double, uint and bool.
// GLSL container types: vectors and matrices.
// A vector in GLSL is a 1,2,3 or 4 component container for any of the basic types mentioned above.
// They can take the following form (n represents the number of components):
// vecn: the default vector of n floats.
// bvecn: a vector of n booleans.
// ivecn: a vector of n integers.
// uvecn: a vector of n unsigned integers.
// dvecn: a vector of n double components.
// The components of vectors can be accessed with xyzw, rgba and stpw.
// Swizzling is also supported.
// Inputs and outputs:
// Each shader can specify inputs and outputs using the in and out keywords.
// When an output variable matches an input variable of the next shader stage, the output values are passed along.
// Note that vertex shaders and fragment shaders differ in terms of their inputs.
// A vertex shader receives its input straight from the vertex data, since it is the first stage of the rendering pipeline.
// To define how the vertex data is organized, we specify the input variables of the vertex shader with location metadata (e.g. layout (location = 0)).
// By doing this, we are allowed to configure the vertex attributes on the CPU.
// The vertex shader thus requires an extra layout specification for its inputs so that we can link them with the vertex data.
// Note that it is possible to omit the layout (location = 0) specifier and query for the attribute locations in your code using glGetAttribLocation.
// Another difference is that fragment shaders require a vec4 color output variable, since fragment shaders need to generate a final output color.
// If you do not to specify an output color in your fragment shader, OpenGL will render your object black (or white).
// If we want to send data from one shader to another, we have to declare an output in the sending shader and a similar input in the receiving shader.
// When the output of the sending shader and the input of the receiving shader have the same names and types, OpenGL links them together.
// Once this is done, it is possible to send data between the two shaders.
// This connection between input and outputs is established when we link a program object.
// Uniforms:
// Uniforms are another way to pass data from our application on the CPU to the shaders on the GPU.
// Uniforms differ from vertex attributes in two ways:
// - Uniforms are global.
// Global, meaning that a uniform variable is unique per shader program object, and can be accessed from any shader at any stage in the shader program.
// - When you set the value of a uniform variable, it keeps its value until it is either reset or updated.
// If you declare a uniform that is not used anywhere in your GLSL code, the compiler will silently
// remove the variable from the compiled versiom. This can lead to frustrating errors!
// Here is an example where we use a uniform variable in the fragment shader:
// #version 330 core
// out vec4 FragColor;
//
// uniform vec4 ourColor;
//
// void main()
// {
// FragColor = ourColor;
// }
// Time in seconds since GLFW was initialized
// float timeValue = glfwGetTime();
// greenValue ranges from 0.0 to 1.0
// float greenValue = (sin(timeValue) / 2.0f) + 0.5f;
// Retrieve the location of the uniform ourColor from the given shader program
// If the location of the uniform is not found, the function returns -1
// int vertexColorLocation = glGetUniformLocation(shaderProgram, "ourColor");
// To retrieve the location of a uniform variable from a shader program, we do not have to call glUseProgram before
// But to update the value of a uniform variable, we do need to call glUseProgram first,
// because the function used to we set the value of a uniform variable acts on the currently active shader program
// glUseProgram(shaderProgram);
// Set the value of the uniform in the currently active shader program
// The postfix of the glUniform call specifies the type of the uniform we want to set
// A few of the possible postfixes are:
// f: float
// i: int
// ui: unsigned int
// 3f: 3 floats
// fv: vector/array of floats -> Syntax: glUniform(location, count, array[count] or vec[count])
// glUniform4f(vertexColorLocation, // Location of uniform variable
// 0.0f, // R
// greenValue, // G
// 0.0f, // B
// 1.0f); // A
// Up to this point we know how to:
// - Fill a VBO
// - Configure vertex attribute pointers
// - Store the configuration in a VAO
// Let's add color to the vertex data now
// When we supply 1 color for each vertex of a triangle, why do we end up with a gradient?
// The gradient you see is the result of something called fragment interpolation, which is done in the fragment shader
// The rasterization stage usually results in a number of fragment that is much larger than the number of vertices we provided
// The rasterizer determines the positions of the fragments based on where they reside on the triangle shape
// It then interpolates all the input variables of the fragment shader based on these positions
| [
"diego.macario5@gmail.com"
] | diego.macario5@gmail.com |
14a129dbad22df6fde9bb725ea4b5e573fc36aec | dd2fa7da3ee1d1f976a7315b7cf924dc401000f6 | /uart.cpp | 40acaf3006863ac85209d18c181d371a77110f36 | [] | no_license | jterweeme/avruino | d596a31b06db67b77ad7dc9ebc212fa4b018b601 | 0d175e82f625922515589f7f4ff144352a9e3d3f | refs/heads/master | 2022-11-26T16:41:44.310743 | 2022-11-23T16:07:09 | 2022-11-23T16:07:09 | 110,882,116 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 603 | cpp | #include "uart.h"
#include "board.h"
UartBase::UartBase(volatile uint16_t *brr, volatile uint8_t *udr,
volatile uint8_t *ucsra, volatile uint8_t *ucsrb)
:
_brr(brr),
udr(udr),
ucsra(ucsra),
ucsrb(ucsrb)
{
}
int16_t UartBase::get(uint32_t timeout)
{
for (uint32_t i = 0; i <= timeout; i++)
if (*ucsra & 1<<rxc9)
return *udr;
return -1;
}
Uart::Uart() : UartBase(p_ubrr9, p_udr9, p_ucsr9a, p_ucsr9b)
{
instance = this;
}
Uart *Uart::instance;
DefaultUart::DefaultUart()
{
*_brr = 16;
*p_ucsr9a |= 1<<u2x9;
*p_ucsr9b = 1<<txen9;
}
| [
"jasper@yogalinux.terweeme.eu"
] | jasper@yogalinux.terweeme.eu |
04457ca782efabe9b4f7059ac2683b25ee863477 | 4f5f4361ae1494f92cf107c22b5719088d06aef7 | /src/gd_sqlite.cpp | a6f49a0b54748f9f6e1d52a51b64a380a69b81a0 | [
"MIT"
] | permissive | marceluphd/gd-sqlite | c7894716aa90047eb258664687bacce9c7871c06 | bbf7bf8466ea8f6b3c5b7899e5b361b701b09941 | refs/heads/master | 2020-11-25T00:54:41.106773 | 2017-10-23T00:40:59 | 2017-10-23T00:40:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,775 | cpp | /* MIT License
*
* Copyright (c) 2017 maxmurder
*
* 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.
*/
#include "gd_sqlite.h"
#include "sqlite/sqlite3.h"
#include <OS.hpp>
int STEP_PAGES = 8;
int SLEEP_MS = 250;
int GDSqlite::open(Variant filename, bool _bInMemory)
{
int ret = -1;
bInMemory = _bInMemory;
path = OS::get_data_dir() + String("/") + filename;
if(bInMemory)
{
//Open a link to the on-disk data base
sqlite3 *fileDb;
if ( sqlite3_open(path.c_string(), &fileDb) == SQLITE_OK )
{
//Open the in-memory database
if ( sqlite3_open("file:memory:", &db) == SQLITE_OK )
{
// copy database to in memory db
sqlite3_backup* backup = sqlite3_backup_init(db, "main", fileDb, "main");
if( backup )
{
sqlite3_backup_step(backup, -1);
sqlite3_backup_finish(backup);
}
}
// close the link to our file db
sqlite3_close(fileDb);
}
} else
{
sqlite3_open(path.c_string(), &db);
}
ret = sqlite3_errcode(db);
if(ret != SQLITE_OK)
{
printf("[GDSqlite] Error opening database: %s\n", sqlite3_errmsg(db));
}
return ret;
}
int GDSqlite::close()
{
return sqlite3_close(db);
}
int GDSqlite::backup(Variant _filename)
{
int ret = -1;
String filename = _filename;
sqlite3* fileDb;
sqlite3_backup* backup;
// open the output database file
if( sqlite3_open(filename.c_string(), &fileDb) == SQLITE_OK)
{
// create the backup object
backup = sqlite3_backup_init(fileDb, "main", db, "main");
if(backup)
{
// copy database pages until backup is complete
do {
ret = sqlite3_backup_step(backup, STEP_PAGES);
if( ret == SQLITE_OK || ret == SQLITE_BUSY || ret == SQLITE_LOCKED )
{
sqlite3_sleep(SLEEP_MS);
}
}while ( ret == SQLITE_OK || ret == SQLITE_BUSY || ret == SQLITE_LOCKED );
sqlite3_backup_finish(backup);
}
ret = sqlite3_errcode(fileDb);
}
// close the output database
sqlite3_close(fileDb);
return ret;
}
int GDSqlite::save()
{
int ret = -1;
if(bInMemory)
{
ret = backup(path);
}
return ret;
}
int GDSqlite::create_table(Variant name, Variant columns)
{
String _name = name;
Array _columns = columns;
// generate query
char _query[128];
sprintf(_query, "CREATE TABLE %s (", _name.c_string());
for(int itr=0; itr<_columns.size(); itr++)
{
String column = _columns[itr];
sprintf(_query, "%s%s%s", _query, (itr != 0 ? ", " : ""), column.c_string());
}
sprintf(_query, "%s);", _query);
return query(_query);
}
int GDSqlite::query(Variant _query)
{
int ret = -1;
String query = _query;
if( prepare(query.c_string()) == SQLITE_OK )
{
ret = step();
finalize();
}
return ret;
}
Array GDSqlite::query_array( Variant _query )
{
Array out;
String query = _query;
// construct output array from the query
if( prepare(query.c_string()) == SQLITE_OK)
{
int ret = step();
while (ret == SQLITE_ROW) {
Dictionary row;
// add all columns to each row
for(int col = 0; col < sqlite3_column_count(stmt); col++)
{
// handle diffrent column types
switch(sqlite3_column_type(stmt, col))
{
case SQLITE_INTEGER:
row[sqlite3_column_name(stmt, col)] = sqlite3_column_int(stmt, col);
break;
case SQLITE_FLOAT:
row[sqlite3_column_name(stmt, col)] = sqlite3_column_double(stmt, col);
break;
case SQLITE_TEXT:
row[sqlite3_column_name(stmt, col)] = String((char *)sqlite3_column_text(stmt, col));
break;
}
}
// store result and iterate
out.push_back(row);
ret = step();
}
}
finalize();
return out;
}
String GDSqlite::get_path()
{
return path;
}
String GDSqlite::get_error()
{
return String(sqlite3_errmsg(db));
}
bool GDSqlite::is_in_memory()
{
return bInMemory;
}
int GDSqlite::prepare(const char* query)
{
return sqlite3_prepare_v2(db, query, -1, &stmt, NULL);
}
int GDSqlite::step()
{
return sqlite3_step(stmt);
}
int GDSqlite::finalize()
{
return sqlite3_finalize(stmt);
}
| [
"rusty657@shaw.ca"
] | rusty657@shaw.ca |
7529541a399fcc3904d2c21c242443f26e061d76 | 187b9278a8122bd7ac0a26932e476b2cf7171492 | /TFMEngine/src/defaultimpl/loggers/ConsoleLogger.cpp | c2cdd2bb2faf7b81daa0bcc5e80499ddd6a508ea | [] | no_license | Graphics-Physics-Libraries/RenderLibrary | b0b7a1fe23b7d1553886d1a8783f49a2d83ed593 | 83cb99f269853f8311111c011face5c101eb6cd3 | refs/heads/master | 2020-07-14T16:53:18.939002 | 2019-01-31T09:12:23 | 2019-01-31T09:12:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 622 | cpp | #include "defaultimpl/loggers/ConsoleLogger.h"
#include <iostream>
#ifdef _WIN32
#define PRINTF fprintf_s
#else
#define PRINTF fprintf
#endif
namespace RenderLib
{
namespace DefaultImpl
{
void
ConsoleLogger::logInfo(const std::string & message)
{
PRINTF(stdout, "%s\n", message.c_str());
}
void
ConsoleLogger::logWarning(const std::string & warning)
{
PRINTF(stdout, "%s\n", warning.c_str());
}
void
ConsoleLogger::logError(const std::string & error)
{
PRINTF(stderr, "%s\n", error.c_str());
}
} // namespace DefaultImpl
} // namespace RenderLib | [
"NadirRoGue@users.noreply.github.com"
] | NadirRoGue@users.noreply.github.com |
a46d6cce27e7fcc1e6aa54e217e996622fd8393c | b8f67d61d62799db00542b7b3069da6fcdf10f85 | /chrome/browser/ui/views/media_router/cast_dialog_view.h | a2dfa4588c4c3c8518d556d65c4724c2dc08aa9b | [
"BSD-3-Clause"
] | permissive | fujunwei/chromium-src | 535e4cc01dc2c96aac50671222a77de50d2616dc | 57c7d5bbf24af7b342b330fb8775fc76c343ff69 | refs/heads/webml | 2022-12-30T07:55:11.938223 | 2018-08-28T07:07:52 | 2018-08-28T07:07:52 | 138,548,904 | 0 | 0 | NOASSERTION | 2019-03-22T01:51:37 | 2018-06-25T05:47:59 | null | UTF-8 | C++ | false | false | 7,192 | 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 CHROME_BROWSER_UI_VIEWS_MEDIA_ROUTER_CAST_DIALOG_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_MEDIA_ROUTER_CAST_DIALOG_VIEW_H_
#include <memory>
#include <vector>
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/media_router/cast_dialog_controller.h"
#include "chrome/browser/ui/views/media_router/cast_dialog_metrics.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/bubble/bubble_dialog_delegate.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/menu/menu_runner.h"
class Browser;
namespace gfx {
class Canvas;
} // namespace gfx
namespace media_router {
class CastDialogSinkButton;
struct UIMediaSink;
// View component of the Cast dialog that allows users to start and stop Casting
// to devices. The list of devices used to populate the dialog is supplied by
// CastDialogModel.
class CastDialogView : public views::BubbleDialogDelegateView,
public views::ButtonListener,
public CastDialogController::Observer,
public ui::SimpleMenuModel::Delegate {
public:
// Shows the singleton dialog anchored to the Cast toolbar icon. Requires that
// BrowserActionsContainer exists for |browser|.
static void ShowDialogWithToolbarAction(CastDialogController* controller,
Browser* browser,
const base::Time& start_time);
// Shows the singleton dialog anchored to the top-center of the browser
// window.
static void ShowDialogTopCentered(CastDialogController* controller,
Browser* browser,
const base::Time& start_time);
// No-op if the dialog is currently not shown.
static void HideDialog();
static bool IsShowing();
// Returns nullptr if the dialog is currently not shown.
static views::Widget* GetCurrentDialogWidget();
// views::WidgetDelegateView:
bool ShouldShowCloseButton() const override;
// views::WidgetDelegate:
base::string16 GetWindowTitle() const override;
// ui::DialogModel:
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
int GetDialogButtons() const override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override;
// views::DialogDelegate:
views::View* CreateExtraView() override;
bool Accept() override;
bool Close() override;
// CastDialogController::Observer:
void OnModelUpdated(const CastDialogModel& model) override;
void OnControllerInvalidated() override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// views::View:
gfx::Size CalculatePreferredSize() const override;
void OnPaint(gfx::Canvas* canvas) override;
// ui::SimpleMenuModel::Delegate:
bool IsCommandIdChecked(int command_id) const override;
bool IsCommandIdEnabled(int command_id) const override;
void ExecuteCommand(int command_id, int event_flags) override;
// Called by tests.
size_t selected_sink_index_for_test() const { return selected_sink_index_; }
const std::vector<CastDialogSinkButton*>& sink_buttons_for_test() const {
return sink_buttons_;
}
views::ScrollView* scroll_view_for_test() { return scroll_view_; }
views::View* no_sinks_view_for_test() { return no_sinks_view_; }
views::Button* sources_button_for_test() { return sources_button_; }
ui::SimpleMenuModel* sources_menu_model_for_test() {
return sources_menu_model_.get();
}
views::MenuRunner* sources_menu_runner_for_test() {
return sources_menu_runner_.get();
}
private:
friend class CastDialogViewTest;
FRIEND_TEST_ALL_PREFIXES(CastDialogViewTest, ShowAndHideDialog);
// Instantiates and shows the singleton dialog. The dialog must not be
// currently shown.
static void ShowDialog(views::View* anchor_view,
views::BubbleBorder::Arrow anchor_position,
CastDialogController* controller,
Browser* browser,
const base::Time& start_time);
CastDialogView(views::View* anchor_view,
views::BubbleBorder::Arrow anchor_position,
CastDialogController* controller,
Browser* browser,
const base::Time& start_time);
~CastDialogView() override;
// views::BubbleDialogDelegateView:
void Init() override;
void WindowClosing() override;
void ShowNoSinksView();
void ShowScrollView();
// Applies the stored sink selection and scroll state.
void RestoreSinkListState();
// Populates the scroll view containing sinks using the data in |model|.
void PopulateScrollView(const std::vector<UIMediaSink>& sinks);
// Shows the sources menu that allows the user to choose a source to cast.
void ShowSourcesMenu();
// Populates the sources menu with the sources supported by |sink|.
void UpdateSourcesMenu(const UIMediaSink& sink);
void SelectSinkAtIndex(size_t index);
const UIMediaSink& GetSelectedSink() const;
void MaybeSizeToContents();
// Posts a delayed task to record the number of sinks shown with the metrics
// recorder.
void RecordSinkCountWithDelay();
// Records the number of sinks shown with the metrics recorder.
void RecordSinkCount();
// The singleton dialog instance. This is a nullptr when a dialog is not
// shown.
static CastDialogView* instance_;
// Title shown at the top of the dialog.
base::string16 dialog_title_;
// The index of the selected item on the sink list.
size_t selected_sink_index_ = 0;
// The source selected in the sources menu. This defaults to "tab"
// (presentation or tab mirroring) under the assumption that all sinks support
// at least one of them. "Tab" is represented by a single item in the sources
// menu.
int selected_source_;
// Contains references to sink buttons in the order they appear.
std::vector<CastDialogSinkButton*> sink_buttons_;
CastDialogController* controller_;
// ScrollView containing the list of sink buttons.
views::ScrollView* scroll_view_ = nullptr;
// View shown while there are no sinks.
views::View* no_sinks_view_ = nullptr;
Browser* const browser_;
// How much |scroll_view_| is scrolled downwards in pixels. Whenever the sink
// list is updated the scroll position gets reset, so we must manually restore
// it to this value.
int scroll_position_ = 0;
// The sources menu allows the user to choose a source to cast.
views::Button* sources_button_ = nullptr;
std::unique_ptr<ui::SimpleMenuModel> sources_menu_model_;
std::unique_ptr<views::MenuRunner> sources_menu_runner_;
// Records UMA metrics for the dialog's behavior.
CastDialogMetrics metrics_;
base::WeakPtrFactory<CastDialogView> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(CastDialogView);
};
} // namespace media_router
#endif // CHROME_BROWSER_UI_VIEWS_MEDIA_ROUTER_CAST_DIALOG_VIEW_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
2fbcec95cd33cbd9207700e465ffeb95ee4704d5 | 3956bae02d5733c8103c677566ac9dfacb07cc08 | /src/robot_voice/src/iat_publish.cpp | 7e93c7447393ba528c8dbaa0156b4df1355f714e | [] | no_license | suljaxm/mobile-robot-sim | d50433f9260a6d97338e52005d74b5345cf63796 | 2acdf8a46b8ccc43b93b8d8fd6c7f86f7269d4e2 | refs/heads/master | 2020-07-11T22:27:43.456914 | 2019-09-17T03:33:11 | 2019-09-17T03:33:11 | 204,657,066 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 7,683 | cpp | /*
* 语音听写(iFly Auto Transform)技术能够实时地将语音转换成对应的文字。
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "robot_voice/qisr.h"
#include "robot_voice/msp_cmn.h"
#include "robot_voice/msp_errors.h"
#include "robot_voice/speech_recognizer.h"
#include "ros/ros.h"
#include "std_msgs/String.h"
#define FRAME_LEN 640
#define BUFFER_SIZE 4096
int wakeupFlag = 0 ;
int resultFlag = 0 ;
/* Upload User words */
static int upload_userwords()
{
char* userwords = NULL;
size_t len = 0;
size_t read_len = 0;
FILE* fp = NULL;
int ret = -1;
fp = fopen("userwords.txt", "rb");
if (NULL == fp)
{
printf("\nopen [userwords.txt] failed! \n");
goto upload_exit;
}
fseek(fp, 0, SEEK_END);
len = ftell(fp);
fseek(fp, 0, SEEK_SET);
userwords = (char*)malloc(len + 1);
if (NULL == userwords)
{
printf("\nout of memory! \n");
goto upload_exit;
}
read_len = fread((void*)userwords, 1, len, fp);
if (read_len != len)
{
printf("\nread [userwords.txt] failed!\n");
goto upload_exit;
}
userwords[len] = '\0';
MSPUploadData("userwords", userwords, len, "sub = uup, dtt = userword", &ret); //ÉÏ´«Óû§´Ê±í
if (MSP_SUCCESS != ret)
{
printf("\nMSPUploadData failed ! errorCode: %d \n", ret);
goto upload_exit;
}
upload_exit:
if (NULL != fp)
{
fclose(fp);
fp = NULL;
}
if (NULL != userwords)
{
free(userwords);
userwords = NULL;
}
return ret;
}
static void show_result(char *string, char is_over)
{
resultFlag = 1;
printf("\rResult: [ %s ]", string);
if(is_over)
putchar('\n');
}
static char *g_result = NULL;
static unsigned int g_buffersize = BUFFER_SIZE;
void on_result(const char *result, char is_last)
{
if (result) {
size_t left = g_buffersize - 1 - strlen(g_result);
size_t size = strlen(result);
if (left < size) {
g_result = (char*)realloc(g_result, g_buffersize + BUFFER_SIZE);
if (g_result)
g_buffersize += BUFFER_SIZE;
else {
printf("mem alloc failed\n");
return;
}
}
strncat(g_result, result, size);
show_result(g_result, is_last);
}
}
void on_speech_begin()
{
if (g_result)
{
free(g_result);
}
g_result = (char*)malloc(BUFFER_SIZE);
g_buffersize = BUFFER_SIZE;
memset(g_result, 0, g_buffersize);
printf("Start Listening...\n");
}
void on_speech_end(int reason)
{
if (reason == END_REASON_VAD_DETECT)
printf("\nSpeaking done \n");
else
printf("\nRecognizer error %d\n", reason);
}
/* demo send audio data from a file */
static void demo_file(const char* audio_file, const char* session_begin_params)
{
int errcode = 0;
FILE* f_pcm = NULL;
char* p_pcm = NULL;
unsigned long pcm_count = 0;
unsigned long pcm_size = 0;
unsigned long read_size = 0;
struct speech_rec iat;
struct speech_rec_notifier recnotifier = {
on_result,
on_speech_begin,
on_speech_end
};
if (NULL == audio_file)
goto iat_exit;
f_pcm = fopen(audio_file, "rb");
if (NULL == f_pcm)
{
printf("\nopen [%s] failed! \n", audio_file);
goto iat_exit;
}
fseek(f_pcm, 0, SEEK_END);
pcm_size = ftell(f_pcm);
fseek(f_pcm, 0, SEEK_SET);
p_pcm = (char *)malloc(pcm_size);
if (NULL == p_pcm)
{
printf("\nout of memory! \n");
goto iat_exit;
}
read_size = fread((void *)p_pcm, 1, pcm_size, f_pcm);
if (read_size != pcm_size)
{
printf("\nread [%s] error!\n", audio_file);
goto iat_exit;
}
errcode = sr_init(&iat, session_begin_params, SR_USER, &recnotifier);
if (errcode) {
printf("speech recognizer init failed : %d\n", errcode);
goto iat_exit;
}
errcode = sr_start_listening(&iat);
if (errcode) {
printf("\nsr_start_listening failed! error code:%d\n", errcode);
goto iat_exit;
}
while (1)
{
unsigned int len = 10 * FRAME_LEN; /* 200ms audio */
int ret = 0;
if (pcm_size < 2 * len)
len = pcm_size;
if (len <= 0)
break;
ret = sr_write_audio_data(&iat, &p_pcm[pcm_count], len);
if (0 != ret)
{
printf("\nwrite audio data failed! error code:%d\n", ret);
goto iat_exit;
}
pcm_count += (long)len;
pcm_size -= (long)len;
}
errcode = sr_stop_listening(&iat);
if (errcode) {
printf("\nsr_stop_listening failed! error code:%d \n", errcode);
goto iat_exit;
}
iat_exit:
if (NULL != f_pcm)
{
fclose(f_pcm);
f_pcm = NULL;
}
if (NULL != p_pcm)
{
free(p_pcm);
p_pcm = NULL;
}
sr_stop_listening(&iat);
sr_uninit(&iat);
}
/* demo recognize the audio from microphone */
static void demo_mic(const char* session_begin_params)
{
int errcode;
int i = 0;
struct speech_rec iat;
struct speech_rec_notifier recnotifier = {
on_result,
on_speech_begin,
on_speech_end
};
errcode = sr_init(&iat, session_begin_params, SR_MIC, &recnotifier);
if (errcode) {
printf("speech recognizer init failed\n");
return;
}
errcode = sr_start_listening(&iat);
if (errcode) {
printf("start listen failed %d\n", errcode);
}
/* demo 8 seconds recording */
while(i++ < 8)
sleep(1);
errcode = sr_stop_listening(&iat);
if (errcode) {
printf("stop listening failed %d\n", errcode);
}
sr_uninit(&iat);
}
void WakeUp(const std_msgs::String::ConstPtr& msg)
{
printf("waking up\r\n");
usleep(700*1000);
wakeupFlag=1;
}
/* main thread: start/stop record ; query the result of recgonization.
* record thread: record callback(data write)
* helper thread: ui(keystroke detection)
*/
int main(int argc, char* argv[])
{
// 初始化ROS
ros::init(argc, argv, "voiceRecognition");
ros::NodeHandle n;
ros::Rate loop_rate(10);
// 声明Publisher和Subscriber
// 订阅唤醒语音识别的信号
ros::Subscriber wakeUpSub = n.subscribe("voiceWakeup", 1000, WakeUp);
// 订阅唤醒语音识别的信号
ros::Publisher voiceWordsPub = n.advertise<std_msgs::String>("voiceWords", 1000);
ROS_INFO("Sleeping...");
int count=0;
int ret = MSP_SUCCESS;
int upload_on = 1; /* whether upload the user word */
/* login params, please do keep the appid correct */
const char* login_params = "appid = 5d60d836, work_dir = .";
int aud_src = 0; /* from mic or file */
/*
* See "iFlytek MSC Reference Manual"
*/
const char* session_begin_params =
"sub = iat, domain = iat, language = zh_cn, "
"accent = mandarin, sample_rate = 16000, "
"result_type = plain, result_encoding = utf8";
/* Login first. the 1st arg is username, the 2nd arg is password
* just set them as NULL. the 3rd arg is login paramertes
* */
ret = MSPLogin(NULL, NULL, login_params);
if (MSP_SUCCESS != ret) {
printf("MSPLogin failed , Error code %d.\n",ret);
goto exit; // login fail, exit the program
}
while(ros::ok()){
// 语音识别唤醒
if(wakeupFlag)
{
ROS_INFO("Wakeup...");
printf("Demo recognizing the speech from microphone\n");
printf("Speak in 8 seconds\n");
demo_mic(session_begin_params);
printf("8 sec passed\n");
wakeupFlag=0;
}
// 语音识别完成
if(resultFlag){
resultFlag=0;
std_msgs::String msg;
msg.data = g_result;
voiceWordsPub.publish(msg);
}
ros::spinOnce();
loop_rate.sleep();
count++;
}
exit:
MSPLogout(); // Logout...
return 0;
}
| [
"ujxhz@outlook.com"
] | ujxhz@outlook.com |
513d37ca54d44125907a35ec1aaabd943126410a | 74675f8354e377f2b2dd1574549b1b4b9b612c38 | /src/mainvis/CRenderPass.cpp | cfba19c15395dd3ec15e1184292b849dc943b121 | [
"Apache-2.0"
] | permissive | schreiberx/lbm_free_surface_opencl | a822441b2f897c4787423c11dc1032b946f77eef | 1149b68dc6bc5f3d7e4f3c646c4c9a72dcf4914e | refs/heads/main | 2023-01-28T14:51:01.952290 | 2020-12-07T23:28:26 | 2020-12-07T23:28:26 | 317,255,771 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 90,437 | cpp | /*
* Copyright 2010 Martin Schreiber
*
* 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.
*/
/*
* CRenderPass.hpp
*
* Created on: Mar 22, 2010
* Author: martin
*/
#include "CRenderPass.hpp"
#include "libgl/core/CGlBuffer.hpp"
#include "libgl/core/CGlTexture.hpp"
#include "libgl/core/CGlViewport.hpp"
#include "libgl/core/CGlState.hpp"
#include "libgl/CGlCubeMap.hpp"
#include "libgl/peeling/CGlDepthPeeling.hpp"
#include "libgl/draw/CGlDrawRectangle.hpp"
#include "libgl/draw/CGlDrawTexturedQuad.hpp"
#include "libgl/draw/CGlDrawTexturedArrayQuad.hpp"
#include "libgl/draw/CGlDrawIntTexturedQuad.hpp"
#include "libgl/draw/CGlDrawFlatCubeMap.hpp"
#include "libgl/draw/CGlDrawVolumeBox.hpp"
#include "libgl/draw/CGlDrawSkyBox.hpp"
#include "libgl/draw/CGlDrawWireframeBox.hpp"
#include "libgl/CGlLights.hpp"
#include "libgl/CGlMaterial.hpp"
// define GL_INTEROP to load OpenGL INTEROP support (usually set up via preprocessor variable)
#include "lbm/CLbmOpenClInterface.hpp"
#include "libgl/opencl/CGlVolumeTextureToFlat.hpp"
#include "libgl/opencl/CGlRawVolumeTextureToFlat.hpp"
#include "lib/CFlatTextureLayout.hpp"
#include "lib/CEyeBall.hpp"
#include "mainvis/CConfig.hpp"
#include "mainvis/CMarchingCubesRenderers.hpp"
#include "mainvis/CObjectRenderers.hpp"
#include "mainvis/CShaders.hpp"
#include "mainvis/CSwitches.hpp"
#include "mainvis/CTextures.hpp"
#include "mainvis/CVolumeTexturesAndRenderers.hpp"
#include "mainvis/CMatrices.hpp"
#include "libgl/CGlProjectionMatrix.hpp"
#include "libgl/CGlExpandableViewBox.hpp"
#define DEBUG_CHECKSUM_VELOCITY 0
#include "libgl/CGlRenderCallbackTypes.hpp"
#include "libgl/viewspace_refractions/CGlViewspaceRefractionsFrontBack.hpp"
#include "libgl/viewspace_refractions/CGlViewspaceRefractionsFrontBackDepthVoxels.hpp"
#include "libgl/viewspace_refractions/CGlViewspaceRefractionsFrontBackTotalReflections.hpp"
#include "libgl/viewspace_refractions/CGlViewspaceRefractionsMultiLayered.hpp"
#include "libgl/photon_mapping/CGlPhotonMappingFrontBack.hpp"
#include "libgl/photon_mapping/CGlPhotonsRenderer.hpp"
#include "libgl/photon_mapping/CGlPhotonMappingCausticMapFrontBack.hpp"
#include "libgl/photon_mapping/CGlPhotonsCreateCausticMap.hpp"
#include "CMainVisualization.hpp"
template <typename T>
class CRenderPass_Private
{
public:
CRenderPass_Private(bool verbose) :
cVolumeTexturesAndRenderers(verbose)
{
}
CGlCubeMap cGlCubeMap;
CGlDrawFlatCubeMap cGlDrawFlatCubeMap;
CGlDrawTexturedQuad cGlDrawTexturedQuad;
CGlDrawTexturedArrayQuad cGlDrawTexturedArrayQuad;
CGlDrawIntTexturedQuad cGlDrawIntTexturedQuad;
CGlDrawVolumeBox cGlDrawVolumeBox;
CGlTexture fbo_texture;
CGlFbo test_fbo;
CGlDrawRectangle draw_rectangle;
// temporary texture to store the raw memory buffer
CGlTexture fluid_fraction_raw_texture;
// final fluid fraction texture with the standard flat texture layout
CGlTexture fluid_fraction_flat_texture;
/**
* simulation parts
*/
T *fluid_fraction_buffer;
CGlRawVolumeTextureToFlat cGlRawVolumeTextureToFlat;
CGlVolumeTextureToFlat cGlVolumeTextureToFlat;
/**
* flat texture
*/
CFlatTextureLayout cFlatTextureLayout;
/**
* depth peeling for current view
*/
CGlDepthPeeling cGlDepthPeeling;
/**
* depth peeling for refractions
*/
CGlViewspaceRefractionsFrontBack cGlViewspaceRefractionsFrontBack;
CGlViewspaceRefractionsFrontBackDepthVoxels cGlViewspaceRefractionsFrontBackDepthVoxels;
CGlViewspaceRefractionsFrontBackTotalReflections cGlViewspaceRefractionsFrontBackTotalReflections;
CGlViewspaceRefractionsMultiLayered cGlViewspaceRefractionsMultiLayered;
/**
* Light Space Photon Mapping
*/
CGlPhotonMappingFrontBack cGlPhotonMappingFrontBack;
CGlPhotonsRenderer cGlPhotonsRenderer;
CGlPhotonMappingCausticMapFrontBack cGlPhotonMappingCausticMapFrontBack;
CGlPhotonsCreateCausticMap cGlPhotonsCreateCausticMap;
/**
* stopwatch
*/
CStopwatch stopwatch;
/**
* other stuff
*/
CGlDrawSkyBox cGlDrawSkyBox;
CGlWireframeBox cGlWireframeBox;
CGlViewport viewport;
GLsizei depth_peeling_width; ///< width of depth peeling texture
GLsizei depth_peeling_height; ///< height of depth peeling texture
int depth_peeling_layers; ///< layers for depthpeeling
CGlLights lights_non_transparent_water;
class CVolumeTexturesAndRenderers cVolumeTexturesAndRenderers;
};
// use typename for renderpass which has to be of the same type as CMainVisualization<T>
template <typename T>
CRenderPass<T>::CRenderPass(
CRenderWindow &p_cRenderWindow,
class CMainVisualization<T> &p_cMain,
CConfig &p_cConfig,
CLbmOpenClInterface<T> *p_cLbmOpenCl_ptr,
bool p_verbose
):
verbose(p_verbose),
cRenderWindow(p_cRenderWindow),
cMain(p_cMain),
cConfig(p_cConfig),
cLbmOpenCl_ptr(p_cLbmOpenCl_ptr),
cMarchingCubesRenderers(verbose),
cObjectRenderers(verbose),
cTextures(verbose),
cShaders(verbose),
// initialize fluid_fraction_volume_texture here because rebinding a texture to a different target
// creates an error
fluid_fraction_volume_texture(GL_TEXTURE_3D, GL_R32F, GL_RED, GL_FLOAT)
{
private_class = new CRenderPass_Private<T>(verbose);
}
template <typename T>
void CRenderPass<T>::createCubeMapCallback(GLSL::mat4 &projection_matrix, GLSL::mat4 &view_matrix, void *user_data)
{
CRenderPass *cRenderPass = (CRenderPass*)user_data;
cRenderPass->render_scene_objects(projection_matrix, view_matrix);
if (cRenderPass->cConfig.render_table)
cRenderPass->render_table(projection_matrix, view_matrix);
}
/**
* this function is called from CMain when the viewport has to be resized
*/
template <typename T>
void CRenderPass<T>::viewport_resize(GLsizei width, GLsizei height)
{
private_class->cGlViewspaceRefractionsFrontBack.resize(width, height);
private_class->cGlViewspaceRefractionsFrontBackDepthVoxels.resize(width, height);
private_class->cGlViewspaceRefractionsFrontBackTotalReflections.resize(width, height);
private_class->cGlViewspaceRefractionsMultiLayered.resizeViewport(width, height);
private_class->cGlPhotonsRenderer.resizeViewport(width, height);
private_class->cGlViewspaceRefractionsMultiLayered.cGlDepthPeelingVoxels.resize(width, height, width, height);
}
/**
* this callback function is called, when the peeling texture for photon mapping should be resized
*/
template <typename T>
void CRenderPass<T>::callback_photon_mapping_peeling_texture_resized(void *user_ptr)
{
CRenderPass &r = *(CRenderPass*)user_ptr;
r.private_class->cGlPhotonMappingFrontBack.resizePeelingTexture(r.cConfig.photon_mapping_peeling_texture_width, r.cConfig.photon_mapping_peeling_texture_height);
r.private_class->cGlPhotonMappingCausticMapFrontBack.resizePeelingTexture(r.cConfig.photon_mapping_peeling_texture_width, r.cConfig.photon_mapping_peeling_texture_height);
}
/**
* this callback function is called, when the photon texture for photon mapping should be resized
*/
template <typename T>
void CRenderPass<T>::callback_photon_mapping_photon_texture_resized(void *user_ptr)
{
CRenderPass &r = *(CRenderPass*)user_ptr;
r.private_class->cGlPhotonMappingFrontBack.resizePhotonTexture(r.cConfig.photon_mapping_photon_texture_width, r.cConfig.photon_mapping_photon_texture_height);
r.private_class->cGlPhotonsRenderer.resizeIndexBuffer(r.cConfig.photon_mapping_photon_texture_width*r.cConfig.photon_mapping_photon_texture_height);
r.private_class->cGlPhotonMappingCausticMapFrontBack.resizePhotonTexture(r.cConfig.photon_mapping_photon_texture_width, r.cConfig.photon_mapping_photon_texture_height);
r.private_class->cGlPhotonsCreateCausticMap.resizeIndexBuffer(r.cConfig.photon_mapping_photon_texture_width*r.cConfig.photon_mapping_photon_texture_height);
r.private_class->cGlPhotonsCreateCausticMap.resizeCausticMap(r.cConfig.photon_mapping_photon_texture_width, r.cConfig.photon_mapping_photon_texture_height);
}
/**
* initialize everything
*/
template <typename T>
void CRenderPass<T>::init()
{
private_class->fluid_fraction_buffer = NULL;
central_object_scale_matrix = GLSL::scale(1.4, 1.4, 1.4);
// central_object_scale_matrix = GLSL::scale(2, 2, 2);
/**
* OTHER STUFF
*/
if (verbose) std::cout << "RL: cube map, draw flat cube map, draw textured quad, draw int textured quad, draw volume box" << std::endl;
// cGlCubeMap.resize(512, 512, 512);
private_class->cGlCubeMap.resize(1024, 1024, 1024);
CError_AppendReturn(private_class->cGlCubeMap);
CError_AppendReturn(private_class->cGlDrawFlatCubeMap);
CError_AppendReturn(private_class->cGlDrawTexturedQuad);
CError_AppendReturn(private_class->cGlDrawIntTexturedQuad);
CError_AppendReturn(private_class->cGlDrawVolumeBox);
if (verbose) std::cout << "RL: fbo_texture, test_fbo, draw_rectangle" << std::endl;
private_class->fbo_texture.setTextureParameters(GL_TEXTURE_2D);
private_class->fbo_texture.bind();
private_class->fbo_texture.resize(512,512);
private_class->fbo_texture.unbind();
CError_AppendReturn(private_class->fbo_texture);
private_class->test_fbo.bind();
private_class->test_fbo.bindTexture(private_class->fbo_texture);
private_class->test_fbo.unbind();
CError_AppendReturn(private_class->test_fbo);
CError_AppendReturn(private_class->draw_rectangle);
/**
* OBJECT RENDERERS
*/
if (verbose) std::cout << "Object Renderers..." << std::endl;
cObjectRenderers.setup();
CError_AppendReturn(cObjectRenderers);
/**
* TEXTURES
*/
if (verbose) std::cout << "Textures..." << std::endl;
cTextures.setup();
CError_AppendReturn(cTextures);
/**
* SHADERS
*/
if (verbose) std::cout << "Shader..." << std::endl;
CError_AppendReturn(cShaders);
/**
* WATER MATERIAL AND LIGHTS
*/
private_class->lights_non_transparent_water.light0_enabled = true;
private_class->lights_non_transparent_water.light0_ambient_color3 = cConfig.light0_ambient_color3;
private_class->lights_non_transparent_water.light0_diffuse_color3 = cConfig.light0_diffuse_color3;
private_class->lights_non_transparent_water.light0_specular_color3 = cConfig.light0_specular_color3;
/**
* VOLUME TEXTURES AND RENDERERS
*/
if (verbose) std::cout << "Volume Textures..." << std::endl;
if (cMain.domain_cells.max() <= 64)
{
private_class->cVolumeTexturesAndRenderers.setup(true, cMain.domain_cells);
}
else
{
std::cout << "INFO: disabling test volume: 'domain_cells.max() > 64' to save memory" << std::endl;
private_class->cVolumeTexturesAndRenderers.setup(cMain.cLbmOpenCl_ptr == NULL, cMain.domain_cells);
}
CError_AppendReturn(private_class->cVolumeTexturesAndRenderers);
/**
* SKYBOX
*/
if (verbose) std::cout << "SkyBox..." << std::endl;
#if 0
private_class->CGlDrawSkyBox.initWithTextures(
"data/textures/skybox/img_7888.jpg",
"data/textures/skybox/img_8093.jpg",
"data/textures/skybox/img_6295.jpg",
"data/textures/skybox/dsc00087.jpg",
"data/textures/skybox/img_5264.jpg",
"data/textures/skybox/dsc00040.jpg"
);
#else
private_class->cGlDrawSkyBox.initWithTextures(
"data/textures/weilheimer_huette/left.jpg",
"data/textures/weilheimer_huette/right.jpg",
"data/textures/weilheimer_huette/top.jpg",
"data/textures/weilheimer_huette/bottom.jpg",
"data/textures/weilheimer_huette/back.jpg",
"data/textures/weilheimer_huette/front.jpg"
);
#endif
CError_AppendReturn(private_class->cGlDrawSkyBox);
/**
* setup fixed matrices
*/
cMatrices.ortho_matrix = GLSL::ortho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);
/**
* MARCHING CUBES EXTRACTION
*/
if (verbose) std::cout << "RL: MC Renderers" << std::endl;
cMarchingCubesRenderers.reset(cMain.domain_cells);
CError_AppendReturn(cMarchingCubesRenderers);
/**
* 3D volume and 2D flat texture conversions
*/
// temporary texture to store the raw memory buffer
private_class->fluid_fraction_raw_texture.setTextureParameters(GL_TEXTURE_2D, GL_RGBA32F, GL_RGBA, GL_FLOAT);
// final fluid fraction texture with the standard flat texture layout
private_class->fluid_fraction_flat_texture.setTextureParameters(GL_TEXTURE_2D, GL_RGBA32F, GL_RGBA, GL_FLOAT);
/**
* OPENCL STUFF
*/
#if LBM_OPENCL_FS_DEBUG_CHECKSUM_VELOCITY
int lbm_sim_count = 0;
#endif
if (cLbmOpenCl_ptr != NULL)
{
private_class->fluid_fraction_buffer = new T[cLbmOpenCl_ptr->params.domain_cells.elements()];
/*
* we have to use GL_RGBA for initialization cz. opencl does not support GL_RED memory objects!
*/
fluid_fraction_volume_texture.bind();
fluid_fraction_volume_texture.resize( cLbmOpenCl_ptr->params.domain_cells[0],
cLbmOpenCl_ptr->params.domain_cells[1],
cLbmOpenCl_ptr->params.domain_cells[2]
);
fluid_fraction_volume_texture.unbind();
}
/*
* prepare conversion to flat texture layout for speedup using marching cubes and vertex arrays
*/
private_class->cFlatTextureLayout.init(cMain.domain_cells);
if ( (private_class->cFlatTextureLayout.ft_z_width & 1) != 0 ||
(private_class->cFlatTextureLayout.ft_z_height & 1) != 0
)
{
std::cerr << "width and height of flat texture for fluid fraction has to be a multiple of 2 to use GL INTEROPS!!!" << std::endl;
exit(1);
}
private_class->fluid_fraction_flat_texture.bind();
private_class->fluid_fraction_flat_texture.setNearestNeighborInterpolation();
private_class->fluid_fraction_flat_texture.resize(
private_class->cFlatTextureLayout.ft_z_width >> 1,
private_class->cFlatTextureLayout.ft_z_height >> 1 );
private_class->fluid_fraction_flat_texture.unbind();
CGlErrorCheck();
if (cLbmOpenCl_ptr != NULL)
{
private_class->fluid_fraction_raw_texture.bind();
private_class->fluid_fraction_raw_texture.setNearestNeighborInterpolation();
private_class->fluid_fraction_raw_texture.resize(
private_class->cFlatTextureLayout.ft_z_width >> 1,
private_class->cFlatTextureLayout.ft_z_height >> 1 );
private_class->fluid_fraction_raw_texture.unbind();
#ifdef LBM_OPENCL_GL_INTEROP
cLbmOpenCl_ptr->initFluidFractionMemObject2D(private_class->fluid_fraction_raw_texture);
#endif
CGlErrorCheck();
}
std::ostringstream raw_to_flat_program_defines;
raw_to_flat_program_defines << "#version 150" << std::endl;
raw_to_flat_program_defines << "#define TEXTURE_WIDTH (" << (private_class->cFlatTextureLayout.ft_z_width >> 1) << ")" << std::endl;
raw_to_flat_program_defines << "#define TEXTURE_HEIGHT (" << (private_class->cFlatTextureLayout.ft_z_height >> 1) << ")" << std::endl;
raw_to_flat_program_defines << "#define DOMAIN_CELLS_X (" << cMain.domain_cells[0] << ")" << std::endl;
raw_to_flat_program_defines << "#define DOMAIN_CELLS_Y (" << cMain.domain_cells[1] << ")" << std::endl;
raw_to_flat_program_defines << "#define DOMAIN_CELLS_Z (" << cMain.domain_cells[2] << ")" << std::endl;
raw_to_flat_program_defines << "#define FT_Z_MOD (" << private_class->cFlatTextureLayout.ft_z_mod << ")" << std::endl;
/*
* GL PROGRAM: RAW TO FLAT
*/
private_class->cGlRawVolumeTextureToFlat.setup(private_class->fluid_fraction_flat_texture, private_class->cFlatTextureLayout);
CError_AppendReturn(private_class->cGlRawVolumeTextureToFlat);
private_class->cGlVolumeTextureToFlat.setup(private_class->fluid_fraction_flat_texture, private_class->cFlatTextureLayout);
CError_AppendReturn(private_class->cGlVolumeTextureToFlat);
/**
* DEPTH PEELING PARAMETERS
*/
private_class->depth_peeling_width = 64;
private_class->depth_peeling_height = 64;
private_class->depth_peeling_width = 256;
private_class->depth_peeling_height = 256;
private_class->depth_peeling_layers = 4;
/**
* DEPTH PEELING OF MESH
*/
private_class->cGlDepthPeeling.setup(private_class->depth_peeling_width, private_class->depth_peeling_height, private_class->depth_peeling_layers);
CError_AppendReturn(private_class->cGlDepthPeeling);
/**
* DEPTH PEELING IN VIEWSPACE FOR REFRACTIONS
*/
CError_AppendReturn(private_class->cGlViewspaceRefractionsFrontBack);
CError_AppendReturn(private_class->cGlViewspaceRefractionsFrontBackDepthVoxels);
CError_AppendReturn(private_class->cGlViewspaceRefractionsFrontBackTotalReflections);
private_class->cGlViewspaceRefractionsMultiLayered.setup(private_class->depth_peeling_layers);
CError_AppendReturn(private_class->cGlViewspaceRefractionsMultiLayered);
/**
* Light Space Photon Mapping
*/
private_class->cGlPhotonMappingFrontBack.setup();
CError_AppendReturn(private_class->cGlPhotonMappingFrontBack);
private_class->cGlPhotonsRenderer.setup(private_class->cGlPhotonMappingFrontBack.photon_position_texture);
CError_AppendReturn(private_class->cGlPhotonsRenderer);
private_class->cGlPhotonMappingCausticMapFrontBack.setup();
CError_AppendReturn(private_class->cGlPhotonMappingCausticMapFrontBack);
private_class->cGlPhotonsCreateCausticMap.setup(private_class->cGlPhotonMappingCausticMapFrontBack.photon_position_texture);
CError_AppendReturn(private_class->cGlPhotonsCreateCausticMap);
cConfig.set_callback(&cConfig.photon_mapping_peeling_texture_width, &callback_photon_mapping_peeling_texture_resized, this);
cConfig.set_callback(&cConfig.photon_mapping_peeling_texture_height, &callback_photon_mapping_peeling_texture_resized, this);
callback_photon_mapping_peeling_texture_resized(this);
cConfig.set_callback(&cConfig.photon_mapping_photon_texture_width, &callback_photon_mapping_photon_texture_resized, this);
cConfig.set_callback(&cConfig.photon_mapping_photon_texture_height, &callback_photon_mapping_photon_texture_resized, this);
callback_photon_mapping_photon_texture_resized(this);
private_class->stopwatch.start();
viewport_resize(cRenderWindow.window_width, cRenderWindow.window_height);
}
/**
* render some textured quads
*/
template <typename T>
void CRenderPass<T>::render_animated_quads( GLSL::mat4 &projection_matrix,
GLSL::mat4 &view_matrix
)
{
CGlStateDisable state_cull_face(GL_CULL_FACE);
GLSL::mat4 p_model_matrix;
GLSL::mat4 p_normal_matrix;
GLSL::mat4 p_pvm_matrix;
cShaders.cTexturize.use();
// front
p_model_matrix = GLSL::rotate((float)cMain.ticks*30.0f+0.0f, 0.0f, 1.0f, 0.0f);
p_model_matrix *= GLSL::translate(0.0f, 0.0f, -13.0f);
p_pvm_matrix = projection_matrix * view_matrix * p_model_matrix;
cShaders.cTexturize.pvm_matrix_uniform.set(p_pvm_matrix);
cTextures.texture1.bind();
cObjectRenderers.cGlDrawQuad.render();
cTextures.texture1.unbind();
// left
p_model_matrix = GLSL::rotate((float)cMain.ticks*30.0f+90.0f, 0.0f, 1.0f, 0.0f);
p_model_matrix *= GLSL::translate(0.0f, 0.0f, -12.5f);
p_pvm_matrix = projection_matrix * view_matrix * p_model_matrix;
cShaders.cTexturize.pvm_matrix_uniform.set(p_pvm_matrix);
cTextures.texture2.bind();
cObjectRenderers.cGlDrawQuad.render();
cTextures.texture2.unbind();
// back
p_model_matrix = GLSL::rotate((float)cMain.ticks*30.0f+180.0f, 0.0f, 1.0f, 0.0f);
p_model_matrix *= GLSL::translate(0.0f, 0.0f, -13.0f);
p_pvm_matrix = projection_matrix * view_matrix * p_model_matrix;
cShaders.cTexturize.pvm_matrix_uniform.set(p_pvm_matrix);
cTextures.texture3.bind();
cObjectRenderers.cGlDrawQuad.render();
cTextures.texture3.unbind();
// right
p_model_matrix = GLSL::rotate((float)cMain.ticks*30.0f+270.0f, 0.0f, 1.0f, 0.0f);
p_model_matrix *= GLSL::translate(0.0f, 0.0f, -12.5f);
p_pvm_matrix = projection_matrix * view_matrix * p_model_matrix;
cShaders.cTexturize.pvm_matrix_uniform.set(p_pvm_matrix);
cTextures.texture4.bind();
cObjectRenderers.cGlDrawQuad.render();
cTextures.texture4.unbind();
// top
p_model_matrix = GLSL::rotate((float)cMain.ticks*30.0f+180.0f, 1.0f, 0.0f, 0.0f);
p_model_matrix *= GLSL::translate(0.0f, 0.0f, -11.0f);
p_pvm_matrix = projection_matrix * view_matrix * p_model_matrix;
cShaders.cTexturize.pvm_matrix_uniform.set(p_pvm_matrix);
cTextures.texture3.bind();
cObjectRenderers.cGlDrawQuad.render();
cTextures.texture3.unbind();
// bottom
p_model_matrix = GLSL::rotate((float)cMain.ticks*30.0f, 1.0f, 0.0f, 0.0f);
p_model_matrix *= GLSL::translate(0.0f, 0.0f, -10.0f);
p_pvm_matrix = projection_matrix * view_matrix * p_model_matrix;
cShaders.cTexturize.pvm_matrix_uniform.set(p_pvm_matrix);
cTextures.texture4.bind();
cObjectRenderers.cGlDrawQuad.render();
cTextures.texture4.unbind();
cShaders.cTexturize.disable();
CGlErrorCheck();
}
/**
* render fancy rotating balls
*/
template <typename T>
void CRenderPass<T>::render_animated_balls( GLSL::mat4 &projection_matrix,
GLSL::mat4 &view_matrix
)
{
CGlProgramUse program(cShaders.cBlinn);
cShaders.cBlinn.texture0_enabled.set1b(false);
static CGlMaterial m;
m.ambient_color3 = GLSL::vec3(0.1);
m.diffuse_color3 = GLSL::vec3(0.1, 0.1, 1.0);
m.specular_color3 = GLSL::vec3(1);
m.specular_exponent = 20;
cShaders.cBlinn.setupUniforms(m, cGlLights, view_matrix*cGlLights.light0_world_pos4);
GLSL::mat4 p_model_matrix;
GLSL::mat4 p_view_model_matrix;
GLSL::mat4 p_pvm_matrix;
GLSL::mat3 p_normal_matrix3;
#define MINIMUM_DISTANCE 6.5f
// BALL 0
p_model_matrix = GLSL::rotate((float)cMain.ticks*30.0f+50.0f, 1.0f, 1.0f, 0.0f);
p_model_matrix *= GLSL::translate(-0.1f-MINIMUM_DISTANCE, 0.2f+MINIMUM_DISTANCE, 0.1f+MINIMUM_DISTANCE);
p_view_model_matrix = view_matrix * p_model_matrix;
p_pvm_matrix = projection_matrix * view_matrix * p_model_matrix;
p_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(p_view_model_matrix));
cShaders.cBlinn.light0_diffuse_color3_uniform.set(GLSL::vec3(1,0,0));
cShaders.cBlinn.setupUniformsMatrices(p_pvm_matrix, p_view_model_matrix, p_normal_matrix3);
cObjectRenderers.cGlDrawSphere.renderWithoutProgram();
// BALL 1
p_model_matrix = GLSL::rotate((float)cMain.ticks*50.0f-50.0f, 0.4f, 1.0f, 0.4f);
p_model_matrix *= GLSL::translate(-0.1f-MINIMUM_DISTANCE, -0.1f-MINIMUM_DISTANCE, 0.2f+MINIMUM_DISTANCE);
p_view_model_matrix = view_matrix * p_model_matrix;
p_pvm_matrix = projection_matrix * view_matrix * p_model_matrix;
p_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(p_view_model_matrix));
cShaders.cBlinn.light0_diffuse_color3_uniform.set(GLSL::vec3(0,1,0));
cShaders.cBlinn.setupUniformsMatrices(p_pvm_matrix, p_view_model_matrix, p_normal_matrix3);
cObjectRenderers.cGlDrawSphere.renderWithoutProgram();
// BALL 2
p_model_matrix = GLSL::rotate((float)cMain.ticks*70.0f+50.0f, 1.1f, 0.4f, -1.0f);
p_model_matrix *= GLSL::translate(-0.2f-MINIMUM_DISTANCE, 0.3f+MINIMUM_DISTANCE, -0.1f-MINIMUM_DISTANCE);
p_view_model_matrix = view_matrix * p_model_matrix;
p_pvm_matrix = projection_matrix * view_matrix * p_model_matrix;
p_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(p_view_model_matrix));
cShaders.cBlinn.light0_diffuse_color3_uniform.set(GLSL::vec3(0,0,1));
cShaders.cBlinn.vertex_color.set(GLSL::vec4(0,0,1,0));
cShaders.cBlinn.setupUniformsMatrices(p_pvm_matrix, p_view_model_matrix, p_normal_matrix3);
cObjectRenderers.cGlDrawSphere.renderWithoutProgram();
}
/**
* render fancy rotating meshes
*/
template <typename T>
void CRenderPass<T>::render_animated_meshes( GLSL::mat4 &projection_matrix,
GLSL::mat4 &view_matrix
)
{
CGlProgramUse program(cShaders.cBlinn);
cShaders.cBlinn.texture0_enabled.set1b(false);
GLSL::mat4 p_model_matrix;
GLSL::mat4 p_view_model_matrix;
GLSL::mat4 p_pvm_matrix;
GLSL::mat3 p_normal_matrix3;
// BUNNY 0
p_model_matrix = GLSL::rotate((float)cMain.ticks*30.0f+70.0f, 1.1f, 0.4f, -1.0f);
p_model_matrix *= GLSL::translate(-0.1f-MINIMUM_DISTANCE, 0.1f+MINIMUM_DISTANCE, 0.2f+MINIMUM_DISTANCE);
p_model_matrix *= GLSL::scale(1.5f, 1.5f, 1.5f);
p_view_model_matrix = view_matrix * p_model_matrix;
p_pvm_matrix = projection_matrix * view_matrix * p_model_matrix;
p_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(p_view_model_matrix));
cShaders.cBlinn.light0_diffuse_color3_uniform.set(GLSL::vec3(1,1,0));
cShaders.cBlinn.setupUniformsMatrices(p_pvm_matrix, p_view_model_matrix, p_normal_matrix3);
cObjectRenderers.cGlRenderObjFileBunny.renderWithoutProgram();
// BUNNY 1
p_model_matrix = GLSL::rotate((float)cMain.ticks*20.0f+170.0f, 1.1f, 3.4f, -1.0f);
p_model_matrix *= GLSL::translate(-0.3f-MINIMUM_DISTANCE, 0.1f+MINIMUM_DISTANCE, 0.2f+MINIMUM_DISTANCE);
p_model_matrix *= GLSL::scale(1.8f, 1.8f, 1.8f);
p_view_model_matrix = view_matrix * p_model_matrix;
p_pvm_matrix = projection_matrix * view_matrix * p_model_matrix;
p_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(p_view_model_matrix));
cShaders.cBlinn.light0_diffuse_color3_uniform.set(GLSL::vec3(1,0,1));
cShaders.cBlinn.setupUniformsMatrices(p_pvm_matrix, p_view_model_matrix, p_normal_matrix3);
cObjectRenderers.cGlRenderObjFileBunny.renderWithoutProgram();
// BUNNY 2
p_model_matrix = GLSL::rotate((float)cMain.ticks*60.0f+70.0f, 1.1f, -0.4f, -1.1f);
p_model_matrix *= GLSL::translate(0.1f+MINIMUM_DISTANCE, 0.0f+MINIMUM_DISTANCE, -0.2f-MINIMUM_DISTANCE);
p_model_matrix *= GLSL::scale(1.7f, 1.7f, 1.7f);
p_view_model_matrix = view_matrix * p_model_matrix;
p_pvm_matrix = projection_matrix * view_matrix * p_model_matrix;
p_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(p_view_model_matrix));
cShaders.cBlinn.light0_diffuse_color3_uniform.set(GLSL::vec3(0,1,1));
cShaders.cBlinn.setupUniformsMatrices(p_pvm_matrix, p_view_model_matrix, p_normal_matrix3);
cObjectRenderers.cGlRenderObjFileBunny.renderWithoutProgram();
}
template <typename T>
void CRenderPass<T>::render_table( GLSL::mat4 &projection_matrix,
GLSL::mat4 &view_matrix
)
{
if (cConfig.photon_mapping_shadows)
{
if (cConfig.photon_mapping_front_back)
{
render_table_shadow_mapping( projection_matrix, view_matrix,
private_class->cGlPhotonMappingFrontBack.cGlPeelingFrontBackFaces.front_depth_texture,
cGlExpandableViewBox.lsb_view_matrix,
cGlExpandableViewBox.lsb_projection_matrix
);
}
else
{
render_table_shadow_and_caustic_mapping(
projection_matrix, view_matrix,
(cConfig.photon_mapping_front_back_faces_from_polygons ? private_class->cGlPhotonMappingCausticMapFrontBack.cGlPeelingFrontBackFaces.front_depth_texture : private_class->cGlPhotonMappingCausticMapFrontBack.cGlVolumeRendererInterpolatedFrontBackFaces.front_depth_texture),
private_class->cGlPhotonsCreateCausticMap.photon_caustic_map_texture,
private_class->cGlPhotonMappingCausticMapFrontBack.cGlPeelingFrontDiffuseFaces.front_depth_texture,
cGlExpandableViewBox.lsb_view_matrix,
cGlExpandableViewBox.lsb_projection_matrix
);
}
}
else
{
render_table_no_lighting(projection_matrix, view_matrix);
}
}
/**
* render table without lighting
*/
template <typename T>
void CRenderPass<T>::render_table_no_lighting( GLSL::mat4 &projection_matrix,
GLSL::mat4 &view_matrix
)
{
GLSL::mat4 p_view_model_matrix = view_matrix * diffuse_receivers_model_matrix;
GLSL::mat4 p_pvm_matrix = projection_matrix * view_matrix * diffuse_receivers_model_matrix;
GLSL::mat3 p_view_model_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(p_view_model_matrix));
// GLSL::mat3 p_view_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(view_matrix));
cObjectRenderers.cGlRenderObjFileTable.render(cGlLights, p_pvm_matrix, p_view_model_matrix, p_view_model_normal_matrix3);
}
/**
* render table with shadow mapping
*/
template <typename T>
void CRenderPass<T>::render_table_shadow_mapping(
GLSL::mat4 &projection_matrix,
GLSL::mat4 &view_matrix,
CGlTexture &depth_texture,
GLSL::mat4 &lsb_view_matrix,
GLSL::mat4 &lsb_projection_matrix
)
{
GLSL::mat4 p_view_model_matrix = view_matrix * diffuse_receivers_model_matrix;
GLSL::mat4 p_pvm_matrix = projection_matrix * p_view_model_matrix;
GLSL::mat3 p_view_model_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(p_view_model_matrix));
// GLSL::mat3 p_view_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(view_matrix));
GLSL::mat4 shadow_map_matrix = lsb_projection_matrix * GLSL::inverse(view_matrix) * GLSL::scale((float)cRenderWindow.window_width, (float)cRenderWindow.window_height, 1.0);
shadow_map_matrix = GLSL::scale(0.5, 0.5, 0.5)*GLSL::translate(1, 1, 1)*lsb_projection_matrix*lsb_view_matrix*GLSL::inverse(view_matrix);
cObjectRenderers.cGlRenderObjFileTable.renderWithShadowMap(
cGlLights, p_pvm_matrix, p_view_model_matrix, p_view_model_normal_matrix3, view_matrix,
depth_texture, shadow_map_matrix
);
}
/**
* render table with shadow and caustic mapping
*/
template <typename T>
void CRenderPass<T>::render_table_shadow_and_caustic_mapping(
GLSL::mat4 &projection_matrix,
GLSL::mat4 &view_matrix,
CGlTexture &depth_texture,
CGlTexture &caustic_map_texture,
CGlTexture &caustic_map_depth_texture,
GLSL::mat4 &lsb_view_matrix,
GLSL::mat4 &lsb_projection_matrix
)
{
GLSL::mat4 p_view_model_matrix = view_matrix * diffuse_receivers_model_matrix;
GLSL::mat4 p_pvm_matrix = projection_matrix * p_view_model_matrix;
GLSL::mat3 p_view_model_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(p_view_model_matrix));
GLSL::mat4 shadow_map_matrix = lsb_projection_matrix *
GLSL::inverse(view_matrix) *
GLSL::scale((float)cRenderWindow.window_width, (float)cRenderWindow.window_height, 1.0);
shadow_map_matrix = GLSL::scale(0.5, 0.5, 0.5)*GLSL::translate(1, 1, 1)*lsb_projection_matrix*lsb_view_matrix*GLSL::inverse(view_matrix);
cObjectRenderers.cGlRenderObjFileTable.renderWithShadowAndCausticMap(
cGlLights, p_pvm_matrix, p_view_model_matrix, p_view_model_normal_matrix3, view_matrix,
depth_texture,
caustic_map_texture,
caustic_map_depth_texture,
shadow_map_matrix
);
}
template <typename T>
void CRenderPass<T>::render_scene_objects(GLSL::mat4 &projection_matrix, GLSL::mat4 &view_matrix)
{
/**
* initialize lighting for standard cShaders
*/
if (cConfig.render_scene)
{
GLSL::mat4 p_view_model_matrix = view_matrix;
GLSL::mat3 p_view_model_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(p_view_model_matrix));
GLSL::mat4 p_pvm_matrix = projection_matrix * p_view_model_matrix;
if (!cConfig.photon_mapping_shadows)
{
cObjectRenderers.cGlRenderScene.render( cGlLights,
p_pvm_matrix,
p_view_model_matrix,
p_view_model_normal_matrix3
);
}
else
{
GLSL::mat4 shadow_map_matrix = GLSL::scale(0.5, 0.5, 0.5)*GLSL::translate(1, 1, 1)*cGlExpandableViewBox.lsb_projection_matrix*cGlExpandableViewBox.lsb_view_matrix*GLSL::inverse(view_matrix);
cObjectRenderers.cGlRenderScene.renderWithShadowMap(
cGlLights,
p_pvm_matrix,
p_view_model_matrix,
p_view_model_normal_matrix3,
view_matrix,
private_class->cGlPhotonMappingCausticMapFrontBack.cGlPeelingFrontDiffuseFaces.front_depth_texture,
shadow_map_matrix
);
}
}
if (cConfig.render_skybox)
{
// skip model matrix because we don't move the environment!
GLSL::mat4 p_pvm_matrix = projection_matrix * GLSL::mat4(GLSL::mat3(view_matrix));
private_class->cGlDrawSkyBox.renderWithProgram(p_pvm_matrix);
}
if (cConfig.render_animated_balls)
render_animated_balls(projection_matrix, view_matrix);
if (cConfig.render_animated_meshes)
render_animated_meshes(projection_matrix, view_matrix);
if (cConfig.render_animated_quads)
render_animated_quads(projection_matrix, view_matrix);
}
template <typename T>
void CRenderPass<T>::render_fbo_test()
{
cMatrices.p_model_matrix = cMatrices.model_matrix*GLSL::scale(2.0f, 2.0f, 2.0f);;
cMatrices.p_pvm_matrix = cMatrices.projection_matrix * cMatrices.view_matrix * cMatrices.p_model_matrix;
// render box to fbo
private_class->test_fbo.bind();
private_class->viewport.saveState();
glViewport(0, 0, private_class->fbo_texture.width, private_class->fbo_texture.height);
// clear background
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
// draw box
glCullFace(GL_FRONT);
private_class->cGlDrawVolumeBox.render(cMatrices.p_pvm_matrix);
glCullFace(GL_BACK);
private_class->viewport.restoreState();
private_class->test_fbo.unbind();
cMatrices.p_view_matrix = GLSL::translate(0.6f, 0.6f, 0.6f);
cMatrices.p_model_matrix = GLSL::scale(0.25f, 0.25f, 0.25f);
cMatrices.p_pvm_matrix = cMatrices.ortho_matrix * cMatrices.p_view_matrix * cMatrices.p_model_matrix;
private_class->cGlDrawTexturedQuad.render(cMatrices.p_pvm_matrix, private_class->fbo_texture);
}
template <typename T>
void CRenderPass<T>::render_marching_cubes_with_refractions()
{
cMatrices.p_model_matrix = cMatrices.model_matrix;
cMatrices.p_model_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(cMatrices.p_model_matrix));
cMatrices.p_view_model_matrix = cMatrices.view_matrix*cMatrices.p_model_matrix;
cMatrices.p_view_model_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(cMatrices.p_view_model_matrix));
cMatrices.p_view_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(cMatrices.view_matrix));
cMatrices.p_pvm_matrix = cMatrices.projection_matrix * cMatrices.p_view_model_matrix;
cMatrices.p_transposed_view_matrix3 = GLSL::mat3(GLSL::transpose(cMatrices.view_matrix));
static CGlMaterial m;
m.ambient_color3 = cConfig.water_ambient_color3;
m.diffuse_color3 = cConfig.water_diffuse_color3;
m.specular_color3 = cConfig.water_specular_color3;
m.specular_exponent = cConfig.water_specular_exponent;
if (cConfig.render_marching_cubes_vertex_array_front_back_refractions)
{
/**
* render MCs using vertex arrays with refractions using only front and back textures
*/
private_class->cGlViewspaceRefractionsFrontBack.create(
cMatrices.projection_matrix,
cMatrices.view_matrix,
&callback_render_refractive_objects,
this);
private_class->cGlViewspaceRefractionsFrontBack.cGlProgram.use();
private_class->cGlViewspaceRefractionsFrontBack.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
private_class->cGlViewspaceRefractionsFrontBack.cGlProgram.disable();
private_class->cGlViewspaceRefractionsFrontBack.render(
private_class->cGlCubeMap.texture_cube_map,
GLSL::inverse(GLSL::mat3(cMatrices.view_matrix)),
cMatrices.projection_matrix,
cConfig.refraction_index,
cConfig.water_reflectance_at_normal_incidence,
cConfig.render_marching_cubes_vertex_array_front_back_step_size
);
if (cConfig.render_view_space_refractions_peeling_textures)
{
CGlViewport viewport;
viewport.saveState();
CGlStateDisable asdf(GL_DEPTH_TEST);
int size_div = 4;
int width = private_class->cGlViewspaceRefractionsFrontBack.cGlPeelingFrontBackFaces.width / size_div;
int height = private_class->cGlViewspaceRefractionsFrontBack.cGlPeelingFrontBackFaces.height / size_div;
viewport.set(0, 0, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBack.cGlPeelingFrontBackFaces.front_depth_texture);
viewport.set(0, (height+1), width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBack.cGlPeelingFrontBackFaces.front_normal_texture);
viewport.set(0, (height+1)*2, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBack.cGlPeelingFrontBackFaces.front_texture);
int x = width+1;
viewport.set(x, 0, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBack.cGlPeelingFrontBackFaces.back_depth_texture);
viewport.set(x, (height+1), width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBack.cGlPeelingFrontBackFaces.back_normal_texture);
viewport.set(x, (height+1)*2, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBack.cGlPeelingFrontBackFaces.back_texture);
viewport.restoreState();
}
}
/**
* render MCs using vertex arrays with refractions using only front and back textures
*/
if (cConfig.render_marching_cubes_vertex_array_front_back_depth_voxels_refractions)
{
private_class->cGlViewspaceRefractionsFrontBackDepthVoxels.create(
cMatrices.projection_matrix,
cMatrices.view_matrix,
&callback_render_refractive_objects,
this);
private_class->cGlViewspaceRefractionsFrontBackDepthVoxels.cGlProgram.use();
private_class->cGlViewspaceRefractionsFrontBackDepthVoxels.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
private_class->cGlViewspaceRefractionsFrontBackDepthVoxels.cGlProgram.disable();
private_class->cGlViewspaceRefractionsFrontBackDepthVoxels.render( private_class->cGlCubeMap.texture_cube_map,
GLSL::inverse(GLSL::mat3(cMatrices.view_matrix)),
//GLSL::inverseTranspose(projection_matrix),
cMatrices.projection_matrix,
cConfig.refraction_index
);
if (cConfig.render_view_space_refractions_peeling_textures)
{
CGlViewport viewport;
viewport.saveState();
CGlStateDisable asdf(GL_DEPTH_TEST);
int size_div = 4;
int width = private_class->cGlViewspaceRefractionsFrontBackDepthVoxels.cGlPeelingFrontBackFaces.width / size_div;
int height = private_class->cGlViewspaceRefractionsFrontBackDepthVoxels.cGlPeelingFrontBackFaces.height / size_div;
viewport.set(0, 0, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBackDepthVoxels.cGlPeelingFrontBackFaces.front_depth_texture);
viewport.set(0, (height+1), width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBackDepthVoxels.cGlPeelingFrontBackFaces.front_normal_texture);
viewport.set(0, (height+1)*2, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBackDepthVoxels.cGlPeelingFrontBackFaces.front_texture);
int x = width+1;
viewport.set(x, 0, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBackDepthVoxels.cGlPeelingFrontBackFaces.back_depth_texture);
viewport.set(x, (height+1), width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBackDepthVoxels.cGlPeelingFrontBackFaces.back_normal_texture);
viewport.set(x, (height+1)*2, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBackDepthVoxels.cGlPeelingFrontBackFaces.back_texture);
viewport.restoreState();
}
}
/**
* render MCs using vertex arrays with refractions using only front and back textures and total reflections
*/
if (cConfig.render_marching_cubes_vertex_array_front_back_total_reflections)
{
private_class->cGlViewspaceRefractionsFrontBackTotalReflections.create(
cMatrices.projection_matrix,
cMatrices.view_matrix,
&callback_render_refractive_objects,
this);
private_class->cGlViewspaceRefractionsFrontBackTotalReflections.cGlProgram.use();
private_class->cGlViewspaceRefractionsFrontBackTotalReflections.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
private_class->cGlViewspaceRefractionsFrontBackTotalReflections.cGlProgram.disable();
private_class->cGlViewspaceRefractionsFrontBackTotalReflections.render(
private_class->cGlCubeMap.texture_cube_map,
GLSL::inverse(GLSL::mat3(cMatrices.view_matrix)),
//GLSL::inverseTranspose(projection_matrix),
cMatrices.projection_matrix,
cConfig.refraction_index
);
if (cConfig.render_view_space_refractions_peeling_textures)
{
CGlViewport viewport;
viewport.saveState();
CGlStateDisable asdf(GL_DEPTH_TEST);
int size_div = 4;
int width = private_class->cGlViewspaceRefractionsFrontBackTotalReflections.cGlPeelingFrontBackFaces.width / size_div;
int height = private_class->cGlViewspaceRefractionsFrontBackTotalReflections.cGlPeelingFrontBackFaces.height / size_div;
viewport.set(0, 0, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBackTotalReflections.cGlPeelingFrontBackFaces.front_depth_texture);
viewport.set(0, (height+1), width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBackTotalReflections.cGlPeelingFrontBackFaces.front_normal_texture);
viewport.set(0, (height+1)*2, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBackTotalReflections.cGlPeelingFrontBackFaces.front_texture);
int x = width+1;
viewport.set(x, 0, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBackTotalReflections.cGlPeelingFrontBackFaces.back_depth_texture);
viewport.set(x, (height+1), width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBackTotalReflections.cGlPeelingFrontBackFaces.back_normal_texture);
viewport.set(x, (height+1)*2, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsFrontBackTotalReflections.cGlPeelingFrontBackFaces.back_texture);
viewport.restoreState();
}
}
/**
* render MCs using vertex arrays with refractions using multiple layers
*/
if (cConfig.render_marching_cubes_vertex_array_multi_layered_refractions)
{
/**
* create depth peeling voxelization textures
*/
private_class->cGlViewspaceRefractionsMultiLayered.create(
cMatrices.projection_matrix,
cMatrices.view_matrix,
&callback_render_refractive_objects,
this);
private_class->cGlViewspaceRefractionsMultiLayered.cGlProgram.use();
private_class->cGlViewspaceRefractionsMultiLayered.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
private_class->cGlViewspaceRefractionsMultiLayered.cGlProgram.disable();
private_class->cGlViewspaceRefractionsMultiLayered.render(
private_class->cGlCubeMap.texture_cube_map,
GLSL::inverse(GLSL::mat3(cMatrices.view_matrix)),
//GLSL::inverseTranspose(projection_matrix),
cMatrices.projection_matrix,
cConfig.refraction_index
);
if (cConfig.render_view_space_refractions_peeling_textures)
{
CGlViewport viewport;
viewport.saveState();
CGlStateDisable asdf(GL_DEPTH_TEST);
int size_div = 4;
int width = private_class->cGlViewspaceRefractionsMultiLayered.cGlDepthPeelingVoxels.peeling_pass_width / size_div;
int height = private_class->cGlViewspaceRefractionsMultiLayered.cGlDepthPeelingVoxels.peeling_pass_height / size_div;
int x = 0;
for (int i = 0; i < 4; i++)
{
viewport.set(x, 0, width, height);
private_class->cGlDrawTexturedArrayQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsMultiLayered.cGlDepthPeelingVoxels.peeling_depth_texture, i);
viewport.set(x, (height+1), width, height);
private_class->cGlDrawTexturedArrayQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsMultiLayered.cGlDepthPeelingVoxels.peeling_normal_texture, i);
viewport.set(x, (height+1)*2, width, height);
private_class->cGlDrawTexturedArrayQuad.render(cMatrices.ortho_matrix, private_class->cGlViewspaceRefractionsMultiLayered.cGlDepthPeelingVoxels.peeling_voxel_texture, i);
x += width+1;
}
viewport.restoreState();
}
}
}
template <typename T>
void CRenderPass<T>::render_volume_casting(CGlTexture *volume_texture)
{
float max = CMath::max((float)volume_texture->width, (float)volume_texture->height);
max = CMath::max(max, (float)volume_texture->depth);
cMatrices.p_model_matrix = cMatrices.model_matrix*central_object_scale_matrix*GLSL::scale((float)volume_texture->width/max, (float)volume_texture->height/max, (float)volume_texture->depth/max);
cMatrices.p_model_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(cMatrices.p_model_matrix));
cMatrices.p_view_model_matrix = cMatrices.view_matrix*cMatrices.p_model_matrix;
cMatrices.p_view_model_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(cMatrices.p_view_model_matrix));
cMatrices.p_view_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(cMatrices.view_matrix));
cMatrices.p_pvm_matrix = cMatrices.projection_matrix * cMatrices.p_view_model_matrix;
cMatrices.p_transposed_view_matrix3 = GLSL::mat3(GLSL::transpose(cMatrices.view_matrix));
volume_texture->setLinearInterpolation();
volume_texture->unbind();
if (!cConfig.refraction_active)
{
static CGlMaterial m;
m.ambient_color3 = GLSL::vec3(0.1);
m.diffuse_color3 = GLSL::vec3(0.1, 0.1, 1.0);
m.specular_color3 = GLSL::vec3(1);
m.specular_exponent = 20;
if (cConfig.volume_simple)
{
private_class->cVolumeTexturesAndRenderers.volume_renderer_simple.cGlProgram.use();
private_class->cVolumeTexturesAndRenderers.volume_renderer_simple.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
private_class->cVolumeTexturesAndRenderers.volume_renderer_simple.cGlProgram.disable();
private_class->cVolumeTexturesAndRenderers.volume_renderer_simple.render(
cMatrices.p_pvm_matrix,
cMatrices.view_matrix,
cMatrices.p_model_matrix,
cMatrices.p_view_model_matrix,
cMatrices.p_view_model_normal_matrix3,
*volume_texture,
cConfig.volume_gradient_distance,
cConfig.volume_step_size
);
}
if (cConfig.volume_interpolated)
{
private_class->cVolumeTexturesAndRenderers.volume_renderer_interpolated.cGlProgram.use();
private_class->cVolumeTexturesAndRenderers.volume_renderer_interpolated.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
private_class->cVolumeTexturesAndRenderers.volume_renderer_interpolated.cGlProgram.disable();
private_class->cVolumeTexturesAndRenderers.volume_renderer_interpolated.render(
cMatrices.p_pvm_matrix,
cMatrices.view_matrix,
cMatrices.p_model_matrix,
cMatrices.p_view_model_matrix,
cMatrices.p_view_model_normal_matrix3,
*volume_texture,
cConfig.volume_gradient_distance,
cConfig.volume_step_size
);
}
if (cConfig.volume_cube_steps)
{
private_class->cVolumeTexturesAndRenderers.volume_renderer_cube_steps.cGlProgram.use();
private_class->cVolumeTexturesAndRenderers.volume_renderer_cube_steps.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
private_class->cVolumeTexturesAndRenderers.volume_renderer_cube_steps.cGlProgram.disable();
private_class->cVolumeTexturesAndRenderers.volume_renderer_cube_steps.render(
cMatrices.p_pvm_matrix,
cMatrices.view_matrix,
cMatrices.p_model_matrix,
cMatrices.p_view_model_matrix,
cMatrices.p_view_model_normal_matrix3,
*volume_texture,
cConfig.volume_gradient_distance,
cConfig.volume_step_size
);
}
if (cConfig.volume_marching_cubes)
{
// prepare the marching cube indices and normal data using another class
CGlMarchingCubesPreprocessing &preprocessing = cMarchingCubesRenderers.cGlMarchingCubesGeometryShader;
preprocessing.prepare(*volume_texture);
private_class->cVolumeTexturesAndRenderers.volume_renderer_marching_cubes.cGlProgram.use();
private_class->cVolumeTexturesAndRenderers.volume_renderer_marching_cubes.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
private_class->cVolumeTexturesAndRenderers.volume_renderer_marching_cubes.cGlProgram.disable();
private_class->cVolumeTexturesAndRenderers.volume_renderer_marching_cubes.render(
cMatrices.p_pvm_matrix,
cMatrices.view_matrix,
cMatrices.p_model_matrix,
cMatrices.p_view_model_matrix,
cMatrices.p_view_model_normal_matrix3,
preprocessing,
cConfig.volume_gradient_distance,
cConfig.volume_step_size
);
}
}
else
{
CGlMaterial m;
m.ambient_color3 = cConfig.water_ambient_color3;
m.diffuse_color3 = cConfig.water_diffuse_color3;
m.specular_color3 = cConfig.water_specular_color3;
m.specular_exponent = cConfig.water_specular_exponent;
if (cConfig.volume_simple)
{
private_class->cVolumeTexturesAndRenderers.volume_renderer_simple_refraction.cGlProgram.use();
private_class->cVolumeTexturesAndRenderers.volume_renderer_simple_refraction.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
private_class->cVolumeTexturesAndRenderers.volume_renderer_simple_refraction.cGlProgram.disable();
private_class->cVolumeTexturesAndRenderers.volume_renderer_simple_refraction.render(
cMatrices.p_pvm_matrix,
cMatrices.view_matrix,
cMatrices.p_model_matrix,
cMatrices.p_model_normal_matrix3,
cMatrices.p_view_model_matrix,
cMatrices.p_view_model_normal_matrix3,
*volume_texture,
private_class->cGlCubeMap.texture_cube_map,
cConfig.volume_gradient_distance,
cConfig.refraction_index,
cConfig.volume_step_size,
cConfig.water_reflectance_at_normal_incidence
);
}
if (cConfig.volume_interpolated)
{
private_class->cVolumeTexturesAndRenderers.volume_renderer_interpolated_refraction.cGlProgram.use();
private_class->cVolumeTexturesAndRenderers.volume_renderer_interpolated_refraction.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
private_class->cVolumeTexturesAndRenderers.volume_renderer_interpolated_refraction.cGlProgram.disable();
private_class->cVolumeTexturesAndRenderers.volume_renderer_interpolated_refraction.render(
cMatrices.p_pvm_matrix,
cMatrices.view_matrix,
cMatrices.p_model_matrix,
cMatrices.p_model_normal_matrix3,
cMatrices.p_view_model_matrix,
cMatrices.p_view_model_normal_matrix3,
*volume_texture,
private_class->cGlCubeMap.texture_cube_map,
cConfig.volume_gradient_distance,
cConfig.refraction_index,
cConfig.volume_step_size,
cConfig.water_reflectance_at_normal_incidence
);
}
if (cConfig.volume_cube_steps)
{
private_class->cVolumeTexturesAndRenderers.volume_renderer_cube_steps_refraction.cGlProgram.use();
private_class->cVolumeTexturesAndRenderers.volume_renderer_cube_steps_refraction.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
private_class->cVolumeTexturesAndRenderers.volume_renderer_cube_steps_refraction.cGlProgram.disable();
private_class->cVolumeTexturesAndRenderers.volume_renderer_cube_steps_refraction.render(
cMatrices.p_pvm_matrix,
cMatrices.view_matrix,
cMatrices.p_model_matrix,
cMatrices.p_model_normal_matrix3,
cMatrices.p_view_model_matrix,
cMatrices.p_view_model_normal_matrix3,
*volume_texture,
private_class->cGlCubeMap.texture_cube_map,
cConfig.volume_gradient_distance,
cConfig.refraction_index,
cConfig.volume_step_size,
cConfig.water_reflectance_at_normal_incidence
);
}
if (cConfig.volume_marching_cubes)
{
CGlMarchingCubesPreprocessing &preprocessing = cMarchingCubesRenderers.cGlMarchingCubesGeometryShader;
preprocessing.prepare(*volume_texture);
private_class->cVolumeTexturesAndRenderers.volume_renderer_marching_cubes_refraction.cGlProgram.use();
private_class->cVolumeTexturesAndRenderers.volume_renderer_marching_cubes_refraction.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
private_class->cVolumeTexturesAndRenderers.volume_renderer_marching_cubes_refraction.cGlProgram.disable();
private_class->cVolumeTexturesAndRenderers.volume_renderer_marching_cubes_refraction.render(
cMatrices.p_pvm_matrix,
cMatrices.view_matrix,
cMatrices.p_model_matrix,
cMatrices.p_model_normal_matrix3,
cMatrices.p_view_model_matrix,
cMatrices.p_view_model_normal_matrix3,
preprocessing,
private_class->cGlCubeMap.texture_cube_map,
cConfig.volume_gradient_distance,
cConfig.refraction_index,
cConfig.volume_step_size,
cConfig.water_reflectance_at_normal_incidence
);
}
}
}
/**
* convert a flat texture created by copying from opencl to a flat texture with adjacent slices
*
* then, extract the marching cubes
*
* this function is usually called by every function which relies on the extracted marching cubes vertices
*/
template <typename T>
void CRenderPass<T>::render_flat_volume_texture_to_flat_texture_and_extract(CGlTexture *volume_texture)
{
if (cConfig.render_marching_cubes_vertex_array_disable_mc_generation)
return;
if (cLbmOpenCl_ptr != NULL && !cConfig.lbm_simulation_disable_visualization)
private_class->cGlRawVolumeTextureToFlat.convert(private_class->fluid_fraction_raw_texture, private_class->fluid_fraction_flat_texture);
else
private_class->cGlVolumeTextureToFlat.convert(*volume_texture, private_class->fluid_fraction_flat_texture);
/*
* the flat texture is now prepared and we can start with computing the marching cubes indices
*/
cMarchingCubesRenderers.cGlMarchingCubesVertexArrayRGBA.prepare(private_class->fluid_fraction_flat_texture);
}
template <typename T>
void CRenderPass<T>::render_marching_cubes_solid(CGlTexture *volume_texture)
{
static CGlMaterial m;
m.ambient_color3 = GLSL::vec3(0.1);
m.diffuse_color3 = GLSL::vec3(0.1, 0.1, 1.0);
m.specular_color3 = GLSL::vec3(1);
m.specular_exponent = 20;
if (cConfig.render_marching_cubes_geometry_shader)
{
// VERSION USING GEOMETRY SHADER
cMarchingCubesRenderers.cGlMarchingCubesGeometryShader.prepare(*volume_texture);
cMatrices.p_model_matrix = cMatrices.model_matrix*central_object_scale_matrix;
float max = CMath::max((float)volume_texture->width, (float)volume_texture->height);
max = CMath::max(max, (float)volume_texture->depth);
cMatrices.p_model_matrix *= GLSL::scale(2.0f/max, 2.0f/max, 2.0f/max);
cMatrices.p_model_matrix *= GLSL::translate( 0.5f - (float)volume_texture->width*0.5f,
0.5f - (float)volume_texture->height*0.5f,
0.5f - (float)volume_texture->depth*0.5f);
cMatrices.p_view_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(cMatrices.view_matrix));
cMatrices.p_view_model_matrix = cMatrices.view_matrix * cMatrices.p_model_matrix;
cMatrices.p_view_model_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(cMatrices.p_view_model_matrix));
cMatrices.p_pvm_matrix = cMatrices.projection_matrix * cMatrices.p_view_model_matrix;
cMarchingCubesRenderers.cGlMarchingCubesGeometryShader.cGlProgramRender.use();
cMarchingCubesRenderers.cGlMarchingCubesGeometryShader.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
cMarchingCubesRenderers.cGlMarchingCubesGeometryShader.cGlProgramRender.disable();
cMarchingCubesRenderers.cGlMarchingCubesGeometryShader.render( cMatrices.p_pvm_matrix, GLSL::mat3(GLSL::inverseTranspose(cMatrices.p_pvm_matrix)),
cMatrices.p_view_model_matrix, GLSL::mat3(GLSL::inverseTranspose(cMatrices.p_view_model_matrix))
);
}
/**
* render MC using vertex array
*/
if (cConfig.render_marching_cubes_vertex_array)
{
if (!cMarchingCubesRenderers.cGlMarchingCubesVertexArray.valid)
return;
cMarchingCubesRenderers.cGlMarchingCubesVertexArray.prepare(*volume_texture);
cMatrices.p_model_matrix = cMatrices.model_matrix*central_object_scale_matrix;
float max = CMath::max((float)volume_texture->width, (float)volume_texture->height);
max = CMath::max(max, (float)volume_texture->depth);
cMatrices.p_model_matrix *= GLSL::scale(2.0f/max, 2.0f/max, 2.0f/max);
cMatrices.p_model_matrix *= GLSL::translate( 0.5f - (float)volume_texture->width*0.5f,
0.5f - (float)volume_texture->height*0.5f,
0.5f - (float)volume_texture->depth*0.5f);
cMatrices.p_view_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(cMatrices.view_matrix));
cMatrices.p_view_model_matrix = cMatrices.view_matrix * cMatrices.p_model_matrix;
cMatrices.p_view_model_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(cMatrices.p_view_model_matrix));
cMatrices.p_pvm_matrix = cMatrices.projection_matrix * cMatrices.p_view_model_matrix;
cMarchingCubesRenderers.cGlMarchingCubesVertexArray.cGlProgramRender.use();
cMarchingCubesRenderers.cGlMarchingCubesVertexArray.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
cMarchingCubesRenderers.cGlMarchingCubesVertexArray.cGlProgramRender.disable();
cMarchingCubesRenderers.cGlMarchingCubesVertexArray.render(
cMatrices.p_pvm_matrix, GLSL::mat3(GLSL::inverseTranspose(cMatrices.p_pvm_matrix)),
cMatrices.p_view_model_matrix, GLSL::mat3(GLSL::inverseTranspose(cMatrices.p_view_model_matrix))
);
}
/**
* render MCs using flat texture and vertex array
*/
if (cConfig.render_marching_cubes_vertex_array_rgba)
{
cMatrices.p_model_matrix = cMatrices.model_matrix*central_object_scale_matrix;
cMatrices.p_view_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(cMatrices.view_matrix));
cMatrices.p_view_model_matrix = cMatrices.view_matrix * cMatrices.p_model_matrix;
cMatrices.p_view_model_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(cMatrices.p_view_model_matrix));
cMatrices.p_pvm_matrix = cMatrices.projection_matrix * cMatrices.p_view_model_matrix;
cMarchingCubesRenderers.cGlMarchingCubesVertexArrayRGBA.cGlProgramRender.use();
cMarchingCubesRenderers.cGlMarchingCubesVertexArrayRGBA.setupUniforms(m, cGlLights, cMatrices.view_matrix*cGlLights.light0_world_pos4);
cMarchingCubesRenderers.cGlMarchingCubesVertexArrayRGBA.cGlProgramRender.disable();
cMarchingCubesRenderers.cGlMarchingCubesVertexArrayRGBA.render(
cMatrices.p_pvm_matrix, GLSL::mat3(GLSL::inverseTranspose(cMatrices.p_pvm_matrix)),
cMatrices.p_view_model_matrix, GLSL::mat3(GLSL::inverseTranspose(cMatrices.p_view_model_matrix))
);
}
}
template <typename T>
void CRenderPass<T>::render_photonmapping_front_back_volume_callback(
CGlVolumeRendererInterpolatedFrontBackFaces &renderer,
void* user_data,
const GLSL::mat4 &projection_matrix,
const GLSL::mat4 &view_matrix
)
{
CRenderPass &r = *(CRenderPass*)user_data;
float max = CMath::max((float)r.volume_texture->width, (float)r.volume_texture->height);
max = CMath::max(max, (float)r.volume_texture->depth);
r.cMatrices.p_model_matrix = r.cMatrices.model_matrix*r.central_object_scale_matrix*GLSL::scale((float)r.volume_texture->width/max, (float)r.volume_texture->height/max, (float)r.volume_texture->depth/max);
r.cMatrices.p_model_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(r.cMatrices.p_model_matrix));
r.cMatrices.p_view_model_matrix = view_matrix*r.cMatrices.p_model_matrix;
r.cMatrices.p_view_model_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(r.cMatrices.p_view_model_matrix));
r.cMatrices.p_view_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(view_matrix));
r.cMatrices.p_pvm_matrix = projection_matrix * r.cMatrices.p_view_model_matrix;
r.cMatrices.p_transposed_view_matrix3 = GLSL::mat3(GLSL::transpose(view_matrix));
renderer.render(
r.cMatrices.p_pvm_matrix,
view_matrix,
r.cMatrices.p_model_matrix,
r.cMatrices.p_view_model_matrix,
r.cMatrices.p_view_model_normal_matrix3,
*r.volume_texture,
r.cConfig.volume_gradient_distance,
r.cConfig.volume_step_size
);
}
/**
* PHOTON MAPPING preparation
*/
template <typename T>
void CRenderPass<T>::render_photonmapping_front_back_faces_prepare(CGlExpandableViewBox &cGlExpandableViewBox)
{
if (cConfig.photon_mapping_front_back)
{
private_class->cGlPhotonMappingFrontBack.create( cGlExpandableViewBox.lsb_projection_matrix,
cGlExpandableViewBox.lsb_view_matrix,
cConfig.refraction_index,
&callback_render_refractive_objects,
this,
&callback_render_diffuse_objects,
this
);
}
if (cConfig.photon_mapping_front_back_caustic_map)
{
private_class->cGlPhotonMappingCausticMapFrontBack.create( cGlExpandableViewBox.lsb_projection_matrix,
cGlExpandableViewBox.lsb_view_matrix,
cConfig.refraction_index,
&callback_render_refractive_objects,
this,
&callback_render_diffuse_objects,
this,
cConfig.photon_mapping_front_back_caustic_map_step_size,
cConfig.photon_mapping_front_back_faces_from_polygons,
render_photonmapping_front_back_volume_callback,
this
);
// area of light space
float light_space_near_plane_area = (cGlExpandableViewBox.lsb_frustum_right - cGlExpandableViewBox.lsb_frustum_left)
* (cGlExpandableViewBox.lsb_frustum_top - cGlExpandableViewBox.lsb_frustum_bottom);
float splat_size = cConfig.photon_mapping_light0_splat_size *
CMath::sqrt(
((float)(private_class->cGlPhotonMappingCausticMapFrontBack.photon_position_texture.width*private_class->cGlPhotonMappingCausticMapFrontBack.photon_position_texture.height)) /
((cGlExpandableViewBox.lsb_frustum_right-cGlExpandableViewBox.lsb_frustum_left)*(cGlExpandableViewBox.lsb_frustum_top-cGlExpandableViewBox.lsb_frustum_bottom))
);
// std::cout << splat_size << std::endl;
private_class->cGlPhotonsCreateCausticMap.setupSplatEnergyAndSize(
cConfig.photon_mapping_light0_energy,
light_space_near_plane_area,
private_class->cGlPhotonMappingCausticMapFrontBack.photon_position_texture.width,
private_class->cGlPhotonMappingCausticMapFrontBack.photon_position_texture.height,
splat_size,
1.0/(cConfig.photon_mapping_light0_splat_size*cConfig.photon_mapping_light0_splat_size)
);
private_class->cGlPhotonsCreateCausticMap.renderCausticMap(
cMatrices.projection_matrix,
cMatrices.view_matrix,
GLSL::inverseTranspose(GLSL::mat3(cMatrices.view_matrix)),
GLSL::vec3(cConfig.water_ambient_color3),
private_class->cGlPhotonMappingCausticMapFrontBack.photon_position_texture
);
if (cConfig.render_photon_mapping_peeling_textures)
{
CGlViewport viewport;
viewport.saveState();
int size_div = 8;
int width = private_class->cGlPhotonMappingCausticMapFrontBack.cGlPeelingFrontBackFaces.width / size_div;
int height = private_class->cGlPhotonMappingCausticMapFrontBack.cGlPeelingFrontBackFaces.height / size_div;
bool c = cConfig.photon_mapping_front_back_faces_from_polygons;
/*
CGlVolumeRendererInterpolatedFrontBackFaces &a = cGlPhotonMappingCausticMapFrontBack.cGlVolumeRendererInterpolatedFrontBackFaces;
CGlTexture asdftex;
asdftex.bind();
asdftex.resize(1024, 1024);
asdftex.unbind();
a.front_back_fbo.bind();
a.front_back_fbo.bindTexture(asdftex, 0, 0);
a.front_back_fbo.unbind();
a.front_back_fbo.bind();
viewport.setSize(1024, 1024);
glClearColor(1, 0.5, 1, 0.5);
glClear(GL_COLOR_BUFFER_BIT);
a.front_back_fbo.unbind();
viewport.set(0, 0, width, height);
cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, asdftex);
*/
#if 1
int x = 0;
viewport.set(x, 0, width, height);
if (c) private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlPeelingFrontBackFaces.front_depth_texture);
else private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlVolumeRendererInterpolatedFrontBackFaces.front_depth_texture);
viewport.set(x, (height+1), width, height);
if (c) private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlPeelingFrontBackFaces.front_normal_texture);
else private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlVolumeRendererInterpolatedFrontBackFaces.front_normal_texture);
viewport.set(x, (height+1)*2, width, height);
if (c) private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlPeelingFrontBackFaces.front_texture);
else private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlVolumeRendererInterpolatedFrontBackFaces.front_texture);
x += width+1;
viewport.set(x, 0, width, height);
if (c) private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlPeelingFrontBackFaces.back_depth_texture);
else private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlVolumeRendererInterpolatedFrontBackFaces.back_depth_texture);
viewport.set(x, (height+1), width, height);
if (c) private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlPeelingFrontBackFaces.back_normal_texture);
else private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlVolumeRendererInterpolatedFrontBackFaces.back_normal_texture);
viewport.set(x, (height+1)*2, width, height);
if (c) private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlPeelingFrontBackFaces.back_texture);
else private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlVolumeRendererInterpolatedFrontBackFaces.back_texture);
x += width+1;
viewport.set(x, 0, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlPeelingFrontDiffuseFaces.front_depth_texture);
viewport.set(x, (height+1), width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlPeelingFrontDiffuseFaces.front_normal_texture);
viewport.set(x, (height+1)*2, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.cGlPeelingFrontDiffuseFaces.front_texture);
x += width+1;
size_div = 8;
width = private_class->cGlPhotonMappingCausticMapFrontBack.photon_position_texture.width / size_div;
height = private_class->cGlPhotonMappingCausticMapFrontBack.photon_position_texture.height / size_div;
viewport.set(x, 0, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingCausticMapFrontBack.photon_position_texture);
x += width+1;
size_div = 4;
width = private_class->cGlPhotonsCreateCausticMap.photon_caustic_map_texture.width / size_div;
height = private_class->cGlPhotonsCreateCausticMap.photon_caustic_map_texture.height / size_div;
viewport.set(x, 0, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonsCreateCausticMap.photon_caustic_map_texture);
#endif
viewport.restoreState();
}
}
}
/*
* PHOTON MAPPING using only front and back faces
*/
template <typename T>
void CRenderPass<T>::render_photonmapping_front_back_faces(CGlExpandableViewBox &cGlExpandableViewBox)
{
CGlProjectionMatrix p;
p.setup(cMatrices.projection_matrix);
p.unproject();
if (cConfig.photon_mapping_front_back)
{
// area of light spaces near plane
float light_space_near_plane_area = (cGlExpandableViewBox.lsb_frustum_right - cGlExpandableViewBox.lsb_frustum_left)
* (cGlExpandableViewBox.lsb_frustum_top - cGlExpandableViewBox.lsb_frustum_bottom);
float splat_size = cConfig.photon_mapping_light0_splat_size *
((float)cRenderWindow.window_width)/(p.frustum_right-p.frustum_left);
private_class->cGlPhotonsRenderer.setupSplatEnergyAndSplatSize(
cConfig.photon_mapping_light0_energy,
light_space_near_plane_area,
private_class->cGlPhotonMappingFrontBack.photon_position_texture.width,
private_class->cGlPhotonMappingFrontBack.photon_position_texture.height,
splat_size,
4.0/(cConfig.photon_mapping_light0_splat_size*cConfig.photon_mapping_light0_splat_size)
);
private_class->cGlPhotonsRenderer.render( cMatrices.projection_matrix,
cMatrices.view_matrix,
GLSL::inverseTranspose(GLSL::mat3(cMatrices.view_matrix)),
GLSL::inverse(cGlExpandableViewBox.lsb_view_matrix),
GLSL::mat3(GLSL::transpose(cGlExpandableViewBox.lsb_view_matrix)),
private_class->cGlPhotonMappingFrontBack.photon_position_texture,
private_class->cGlPhotonMappingFrontBack.photon_normal_attenuation_texture
);
if (cConfig.render_photon_mapping_peeling_textures)
{
CGlViewport viewport;
viewport.saveState();
int size_div = 8;
int width = private_class->cGlPhotonMappingFrontBack.cGlPeelingFrontBackFaces.width / size_div;
int height = private_class->cGlPhotonMappingFrontBack.cGlPeelingFrontBackFaces.height / size_div;
int x = 0;
viewport.set(x, 0, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingFrontBack.cGlPeelingFrontBackFaces.front_depth_texture);
viewport.set(x, (height+1), width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingFrontBack.cGlPeelingFrontBackFaces.front_normal_texture);
viewport.set(x, (height+1)*2, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingFrontBack.cGlPeelingFrontBackFaces.front_texture);
x += width+1;
viewport.set(x, 0, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingFrontBack.cGlPeelingFrontBackFaces.back_depth_texture);
viewport.set(x, (height+1), width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingFrontBack.cGlPeelingFrontBackFaces.back_normal_texture);
viewport.set(x, (height+1)*2, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingFrontBack.cGlPeelingFrontBackFaces.back_texture);
x += width+1;
viewport.set(x, 0, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingFrontBack.cGlPeelingFrontDiffuseFaces.front_depth_texture);
viewport.set(x, (height+1), width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingFrontBack.cGlPeelingFrontDiffuseFaces.front_normal_texture);
viewport.set(x, (height+1)*2, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingFrontBack.cGlPeelingFrontDiffuseFaces.front_texture);
x += width+1;
size_div = 8;
width = private_class->cGlPhotonMappingFrontBack.photon_position_texture.width / size_div;
height = private_class->cGlPhotonMappingFrontBack.photon_position_texture.height / size_div;
viewport.set(x, 0, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingFrontBack.photon_position_texture);
viewport.set(x, (height+1), width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonMappingFrontBack.photon_normal_attenuation_texture);
x += width+1;
size_div = 4;
width = private_class->cGlPhotonsRenderer.photon_blend_texture.width / size_div;
height = private_class->cGlPhotonsRenderer.photon_blend_texture.height / size_div;
viewport.set(x, 0, width, height);
private_class->cGlDrawTexturedQuad.render(cMatrices.ortho_matrix, private_class->cGlPhotonsRenderer.photon_blend_texture);
viewport.restoreState();
}
}
}
/**
* render refractive objects only (for photon mapping, caustics, refractions, etc.)
*/
template <typename T>
void CRenderPass<T>::callback_render_refractive_objects(
const GLSL::mat4 &projection_matrix, ///< projection matrix
const GLSL::mat4 &view_matrix, ///< view matrix
typename CGlRenderCallbackTypes::setup_view_model_matrix *callback, ///< callback
void *callback_param, ///< parameter for callback
void *user_data ///< user data (pointer to cMainVisualization, because this is a static function)
)
{
class CRenderPass &c = *(class CRenderPass*)user_data;
if (c.cConfig.render_mesh_bunny || c.cConfig.render_mesh_sphere)
{
GLSL::mat4 view_model_matrix = view_matrix*c.cMatrices.model_matrix;
GLSL::mat3 view_model_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(view_model_matrix));
GLSL::mat4 pvm_matrix = projection_matrix*view_model_matrix;
callback(callback_param, pvm_matrix, view_model_matrix, view_model_normal_matrix3);
if (c.cConfig.render_mesh_bunny)
c.cObjectRenderers.cGlRenderObjFileBunny.renderWithoutProgram();
else if (c.cConfig.render_mesh_sphere)
c.cObjectRenderers.cGlRenderObjFileSphere.renderWithoutProgram();
}
else
{
GLSL::mat4 view_model_matrix = view_matrix*c.cMatrices.model_matrix*c.central_object_scale_matrix;
GLSL::mat3 view_model_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(view_model_matrix));
GLSL::mat4 pvm_matrix = projection_matrix*view_model_matrix;
callback(callback_param, pvm_matrix, view_model_matrix, view_model_normal_matrix3);
c.cMarchingCubesRenderers.cGlMarchingCubesVertexArrayRGBA.renderWithoutProgram();
}
}
/**
* render diffuse objects where photons are catched
*/
template <typename T>
void CRenderPass<T>::callback_render_diffuse_objects(
const GLSL::mat4 &projection_matrix, ///< projection matrix
const GLSL::mat4 &view_matrix, ///< view matrix
typename CGlRenderCallbackTypes::setup_view_model_matrix *callback, ///< callback
void *callback_param, ///< parameter for callback
void *user_data ///< user data (pointer to cMainVisualization, because this is a static function)
)
{
class CRenderPass &c = *(class CRenderPass*)user_data;
GLSL::mat4 view_model_matrix = view_matrix*c.diffuse_receivers_model_matrix;
GLSL::mat3 view_model_normal_matrix3 = GLSL::inverseTranspose(GLSL::mat3(view_model_matrix));
GLSL::mat4 pvm_matrix = projection_matrix*view_model_matrix;
callback(callback_param, pvm_matrix, view_model_matrix, view_model_normal_matrix3);
// render table without shaders
c.cObjectRenderers.cGlRenderObjFileTable.renderWithoutProgram();
}
template <typename T>
void CRenderPass<T>::prepare_expandable_viewbox()
{
// compute projection and view matrix from light source to center (0,0,0)
GLSL::mat4 lsb_view_matrix;
if (GLSL::length2(GLSL::abs(GLSL::normalize(GLSL::vec3(cGlLights.light0_world_pos4)))-GLSL::vec3(0,1,0)) > 0.01)
{
lsb_view_matrix = GLSL::lookAt(
GLSL::vec3(cGlLights.light0_world_pos4),
GLSL::vec3(0,0,0),
GLSL::vec3(0,1,0)
);
}
else
{
lsb_view_matrix = GLSL::lookAt(
GLSL::vec3(cGlLights.light0_world_pos4),
GLSL::vec3(0,0,0),
GLSL::vec3(1,0,0)
);
}
GLSL::mat4 lsb_projection_matrix = GLSL::frustum(-0.1,0.1,-0.1,0.1,0.5,20);
cGlExpandableViewBox.setup(lsb_projection_matrix, lsb_view_matrix);
GLSL::mat4 pm = cMatrices.model_matrix*central_object_scale_matrix;
// expand obstacle
cGlExpandableViewBox.expandWithPoint(pm*GLSL::vec3(-1,-1,-1));
cGlExpandableViewBox.expandWithPoint(pm*GLSL::vec3(1,-1,-1));
cGlExpandableViewBox.expandWithPoint(pm*GLSL::vec3(1,1,-1));
cGlExpandableViewBox.expandWithPoint(pm*GLSL::vec3(-1,1,-1));
cGlExpandableViewBox.expandWithPoint(pm*GLSL::vec3(-1,-1,1));
cGlExpandableViewBox.expandWithPoint(pm*GLSL::vec3(1,-1,1));
cGlExpandableViewBox.expandWithPoint(pm*GLSL::vec3(1,1,1));
cGlExpandableViewBox.expandWithPoint(pm*GLSL::vec3(-1,1,1));
// expand with diffuse receivers (table)
cGlExpandableViewBox.expandWithPoint(diffuse_receivers_model_matrix*GLSL::vec3(-1,-1,-1));
cGlExpandableViewBox.expandWithPoint(diffuse_receivers_model_matrix*GLSL::vec3(1,-1,-1));
cGlExpandableViewBox.expandWithPoint(diffuse_receivers_model_matrix*GLSL::vec3(1,1,-1));
cGlExpandableViewBox.expandWithPoint(diffuse_receivers_model_matrix*GLSL::vec3(-1,1,-1));
cGlExpandableViewBox.expandWithPoint(diffuse_receivers_model_matrix*GLSL::vec3(-1,-1,1));
cGlExpandableViewBox.expandWithPoint(diffuse_receivers_model_matrix*GLSL::vec3(1,-1,1));
cGlExpandableViewBox.expandWithPoint(diffuse_receivers_model_matrix*GLSL::vec3(1,1,1));
cGlExpandableViewBox.expandWithPoint(diffuse_receivers_model_matrix*GLSL::vec3(-1,1,1));
cGlExpandableViewBox.computeMatrices();
}
/**
* this function actually renders the objects and is also calling the simulation runtime
*/
template <typename T>
void CRenderPass<T>::render()
{
/********************************************************
* COMMUNICATION (ONLY HERE AND NOWHERE ELSE!) PART WITH OPENCL
********************************************************/
volume_texture = &(private_class->cVolumeTexturesAndRenderers.test_volume_texture);
if (!cConfig.lbm_simulation_disable_visualization)
{
if ( cConfig.volume_simple ||
cConfig.volume_interpolated ||
cConfig.volume_cube_steps ||
cConfig.volume_marching_cubes ||
cConfig.render_marching_cubes_geometry_shader ||
cConfig.render_marching_cubes_vertex_array ||
cConfig.volume_dummy
)
{
if (cLbmOpenCl_ptr != NULL)
{
if (cConfig.lbm_simulation_copy_fluid_fraction_to_visualization)
{
cLbmOpenCl_ptr->storeFraction(private_class->fluid_fraction_buffer);
fluid_fraction_volume_texture.bind();
fluid_fraction_volume_texture.setData(private_class->fluid_fraction_buffer);
fluid_fraction_volume_texture.unbind();
CGlErrorCheck();
}
CGlErrorCheck();
volume_texture = &fluid_fraction_volume_texture;
}
}
else
{
if (cLbmOpenCl_ptr != NULL)
volume_texture = &fluid_fraction_volume_texture;
}
if ( cConfig.render_marching_cubes_vertex_array_rgba ||
cConfig.render_marching_cubes_vertex_array_front_back_refractions ||
cConfig.render_marching_cubes_vertex_array_front_back_depth_voxels_refractions ||
cConfig.render_marching_cubes_vertex_array_multi_layered_refractions ||
cConfig.render_marching_cubes_vertex_array_front_back_total_reflections ||
cConfig.photon_mapping_front_back ||
(cConfig.photon_mapping_front_back_caustic_map && cConfig.photon_mapping_front_back_faces_from_polygons) ||
cConfig.render_marching_cubes_dummy
)
{
if ( cConfig.lbm_simulation_copy_fluid_fraction_to_visualization &&
!cConfig.render_marching_cubes_vertex_array_disable_mc_generation)
{
// load raw fluid fraction
if (cLbmOpenCl_ptr != NULL)
{
#ifdef LBM_OPENCL_GL_INTEROP
cLbmOpenCl_ptr->loadFluidFractionToRawFlatTexture();
#else
cLbmOpenCl_ptr->storeFraction(private_class->fluid_fraction_buffer);
private_class->fluid_fraction_raw_texture.bind();
private_class->fluid_fraction_raw_texture.setData(private_class->fluid_fraction_buffer);
private_class->fluid_fraction_raw_texture.unbind();
#endif
}
}
}
}
/********************************************************
* setup matrices for refractive objects and diffuse receiver objects
********************************************************/
refraction_object_model_matrix = cMatrices.model_matrix;
/********************************************************
* SETUP LIGHT SPACE BOX
********************************************************/
if (cConfig.photon_mapping_front_back || cConfig.photon_mapping_front_back_caustic_map || cConfig.render_light_space_box)
{
prepare_expandable_viewbox();
}
/**
* SPECIAL GL_INTEROPS VERSION FOR MARCHING CUBES
*
* the fluid fraction memory object is copied to a 2d texture
* (writing to a 3d texture is still not supported with current OpenCL drivers)
*
* because this is not an equivilant to the usual flat texture, we convert it
*/
if ( cConfig.render_marching_cubes_vertex_array_rgba ||
cConfig.render_marching_cubes_vertex_array_front_back_refractions ||
cConfig.render_marching_cubes_vertex_array_front_back_depth_voxels_refractions ||
cConfig.render_marching_cubes_vertex_array_multi_layered_refractions ||
cConfig.render_marching_cubes_vertex_array_front_back_total_reflections ||
cConfig.photon_mapping_front_back ||
(cConfig.photon_mapping_front_back_caustic_map && cConfig.photon_mapping_front_back_faces_from_polygons) ||
cConfig.render_marching_cubes_dummy
)
{
render_flat_volume_texture_to_flat_texture_and_extract(volume_texture);
}
/********************************************************
* prepare photonmap
********************************************************/
if (cConfig.photon_mapping_front_back || cConfig.photon_mapping_front_back_caustic_map)
{
render_photonmapping_front_back_faces_prepare(cGlExpandableViewBox);
}
/********************************************************
* render diffuse receiver (table)
********************************************************/
if (cConfig.render_table)
{
render_table(cMatrices.projection_matrix, cMatrices.view_matrix);
}
/********************************************************
* render photons
********************************************************/
if (cConfig.photon_mapping_front_back || cConfig.photon_mapping_front_back_caustic_map)
{
render_photonmapping_front_back_faces(cGlExpandableViewBox);
}
/********************************************************
* create cubemap
********************************************************/
if (cConfig.create_cube_map)
{
GLSL::vec3 translation(cMatrices.model_matrix[3][0], cMatrices.model_matrix[3][1], cMatrices.model_matrix[3][2]);
private_class->cGlCubeMap.create(createCubeMapCallback, -translation, this, 1, 40);
}
/********************************************************
* render scene
********************************************************/
render_scene_objects(cMatrices.projection_matrix, cMatrices.view_matrix);
/**
* RENDER VOLUME WITH VOLUME CASTING
*/
if ( cConfig.volume_simple ||
cConfig.volume_interpolated ||
cConfig.volume_cube_steps ||
cConfig.volume_marching_cubes
)
{
render_volume_casting(volume_texture);
}
/**
* MC renderers without refractions
*/
if ( cConfig.render_marching_cubes_geometry_shader ||
cConfig.render_marching_cubes_vertex_array ||
cConfig.render_marching_cubes_vertex_array_rgba
)
{
render_marching_cubes_solid(volume_texture);
}
/**
* MC renderers with refractions
*/
if ( cConfig.render_marching_cubes_vertex_array_rgba ||
cConfig.render_marching_cubes_vertex_array_front_back_refractions ||
cConfig.render_marching_cubes_vertex_array_front_back_depth_voxels_refractions ||
cConfig.render_marching_cubes_vertex_array_multi_layered_refractions ||
cConfig.render_marching_cubes_vertex_array_front_back_total_reflections
)
{
render_marching_cubes_with_refractions();
}
/**************************
* RENDER LIGHT SPACE BOX
**************************/
if (cConfig.render_light_space_box)
{
cMatrices.p_pvm_matrix = cMatrices.projection_matrix * cMatrices.view_matrix;
CGlProgramUse program(cShaders.cColor);
cShaders.cColor.pvm_matrix.set(cMatrices.p_pvm_matrix);
cShaders.cColor.frag_color.set(GLSL::vec4(0,1,0,0));
cGlExpandableViewBox.emitBoxVertices();
}
/**************************
* draw bounding box
**************************/
if (cConfig.render_bounding_box)
{
float max = CMath::max((float)volume_texture->width, (float)volume_texture->height);
max = CMath::max(max, (float)volume_texture->depth);
cMatrices.p_model_matrix = cMatrices.model_matrix*central_object_scale_matrix*GLSL::scale((float)volume_texture->width/max, (float)volume_texture->height/max, (float)volume_texture->depth/max);
cMatrices.p_view_model_matrix = cMatrices.view_matrix*cMatrices.p_model_matrix;
cMatrices.p_pvm_matrix = cMatrices.projection_matrix * cMatrices.p_view_model_matrix;
cObjectRenderers.cGlRenderFluidBorder.render( cGlLights,
cMatrices.p_pvm_matrix,
cMatrices.p_view_model_matrix,
cMatrices.p_view_model_normal_matrix3
);
}
/**************************
* RENDER STANDARD SCENE
**************************/
if (cConfig.render_scene)
{
cMatrices.p_view_model_matrix = cMatrices.view_matrix;
cMatrices.p_view_model_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(cMatrices.p_view_model_matrix));
cMatrices.p_pvm_matrix = cMatrices.projection_matrix * cMatrices.p_view_model_matrix;
cObjectRenderers.cGlRenderScene.render( cGlLights,
cMatrices.p_pvm_matrix,
cMatrices.p_view_model_matrix,
cMatrices.p_view_model_normal_matrix3
);
}
if (cConfig.render_mesh_bunny || cConfig.render_mesh_sphere)
{
cMatrices.p_view_model_matrix = cMatrices.view_matrix * cMatrices.model_matrix;
cMatrices.p_view_model_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(cMatrices.p_view_model_matrix));
cMatrices.p_pvm_matrix = cMatrices.projection_matrix * cMatrices.p_view_model_matrix;
CGlProgramUse program(cShaders.cBlinn);
cShaders.cBlinn.setupUniforms(cObjectRenderers.cGlRenderObjFileBunny.cGlMaterial,
cGlLights,
cMatrices.view_matrix*cGlLights.light0_world_pos4);
cShaders.cBlinn.setupUniformsMatrices(cMatrices.p_pvm_matrix, cMatrices.p_view_model_normal_matrix3, cMatrices.p_view_model_matrix);
cTextures.texture1.bind();
if (cConfig.render_mesh_bunny
&& !( cConfig.render_marching_cubes_vertex_array_front_back_refractions ||
cConfig.render_marching_cubes_vertex_array_front_back_depth_voxels_refractions ||
cConfig.render_marching_cubes_vertex_array_front_back_total_reflections ||
cConfig.render_marching_cubes_vertex_array_multi_layered_refractions
))
{
if (cObjectRenderers.cGlRenderObjFileBunny.cGlMaterial.texture0)
cObjectRenderers.cGlRenderObjFileBunny.cGlMaterial.texture0->bind();
cObjectRenderers.cGlRenderObjFileBunny.renderWithoutProgram();
if (cObjectRenderers.cGlRenderObjFileBunny.cGlMaterial.texture0)
cObjectRenderers.cGlRenderObjFileBunny.cGlMaterial.texture0->unbind();
}
if (cConfig.render_mesh_sphere
&& !( cConfig.render_marching_cubes_vertex_array_front_back_refractions ||
cConfig.render_marching_cubes_vertex_array_front_back_depth_voxels_refractions ||
cConfig.render_marching_cubes_vertex_array_front_back_total_reflections ||
cConfig.render_marching_cubes_vertex_array_multi_layered_refractions
))
{
if (cObjectRenderers.cGlRenderObjFileSphere.texture_valid)
cShaders.cBlinn.texture0_enabled.set1b(true);
else
cShaders.cBlinn.texture0_enabled.set1b(false);
cObjectRenderers.cGlRenderObjFileSphere.renderWithoutProgram();
}
cTextures.texture1.unbind();
}
/********************************************************************
* render obstacles with reflections using cube map
********************************************************************/
if (cConfig.render_mesh_bunny_reflected || cConfig.render_mesh_sphere_reflected)// || switches.sphere_reflected)
{
private_class->cGlCubeMap.texture_cube_map.bind();
cMatrices.p_view_model_matrix = cMatrices.view_matrix*cMatrices.model_matrix;
cMatrices.p_view_model_normal_matrix3 = GLSL::mat3(GLSL::inverseTranspose(cMatrices.p_view_model_matrix));
cMatrices.p_pvm_matrix = cMatrices.projection_matrix * cMatrices.p_view_model_matrix;
cMatrices.p_view_normal_matrix3 = GLSL::mat3(cMatrices.view_matrix);
GLSL::mat3 p_transposed_view_matrix = GLSL::mat3(GLSL::transpose(cMatrices.view_matrix));
CGlProgramUse program_use(cShaders.cCubeMapMirror);
cShaders.cCubeMapMirror.pvm_matrix.set(cMatrices.p_pvm_matrix);
cShaders.cCubeMapMirror.view_model_normal_matrix3.set(cMatrices.p_view_model_normal_matrix3);
cShaders.cCubeMapMirror.view_model_matrix.set(cMatrices.p_view_model_matrix);
cShaders.cCubeMapMirror.light0_view_pos3.set(GLSL::vec3(cMatrices.view_matrix*cGlLights.light0_world_pos4));
// we use the transpose cz. we invert the normal which is invert(transp(invert(M))) = transp(M)
cShaders.cCubeMapMirror.transposed_view_matrix3.set(p_transposed_view_matrix);
if (cConfig.render_mesh_bunny_reflected)
cObjectRenderers.cGlRenderObjFileBunny.renderWithoutProgram();
if (cConfig.render_mesh_sphere_reflected)
cObjectRenderers.cGlRenderObjFileSphere.renderWithoutProgram();
cShaders.cCubeMapMirror.disable();
private_class->cGlCubeMap.texture_cube_map.unbind();
}
/**********************************
* render flattened cube map
**********************************/
if (cConfig.display_flat_cube_map)
{
private_class->cGlDrawFlatCubeMap.render(private_class->cGlCubeMap, 0.5f);
}
}
template <typename T>
void CRenderPass<T>::cleanup()
{
if (private_class->fluid_fraction_buffer != NULL)
{
delete [] private_class->fluid_fraction_buffer;
private_class->fluid_fraction_buffer = NULL;
}
}
template <typename T>
CRenderPass<T>::~CRenderPass()
{
cleanup();
delete private_class;
}
template class CRenderPass<float>;
| [
"martin.schreiber@tum.de"
] | martin.schreiber@tum.de |
7ad2ddecd880f636ae80fa85cd4dbdc7f4800b17 | a223f028f0ba1d041909e4f609441d7bae4ea2f6 | /convert_occ_totext.cpp | f39681f08022d0bbbe26339a881d123c9639be52 | [] | no_license | foreverunfree/Read_Write_File_from_text_file_from_Occupancy_grid | eb7587e9d6db3e28c8d337f0b1270de44f65800b | b0093d6eb12c9eb28e8f72a281e3910892ba8e8a | refs/heads/master | 2020-08-28T23:20:53.390119 | 2019-08-31T04:08:21 | 2019-08-31T04:08:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,375 | cpp | #include <math.h>
#include <std_msgs/Float32.h>
#include <std_msgs/Float64MultiArray.h>
#include <tf/tf.h>
#include <tf/transform_listener.h>
#include <geometry_msgs/PoseStamped.h>
#include <nav_msgs/Path.h>
#include <nav_msgs/OccupancyGrid.h>
#include <visualization_msgs/MarkerArray.h>
#include <std_msgs/Bool.h>
#include <iostream>
#include <fstream>
using namespace std;
const vector<int8_t> *_occGrid;
double _gridOrigin[2];
/*
* controlLoop
*
* Function Description
*
* @critical Major Multi-Point
*
* @param
* @return
*
* @ureq
* -#
*/
// Get occupancy grid and write to a .txt file
void getNavPack( const nav_msgs::OccupancyGrid::ConstPtr &msg )
{
_occGrid = &( msg->data );
_gridOrigin[0] = msg->info.origin.position.x;
_gridOrigin[1] = msg->info.origin.position.y;
ofstream OccGridfile;
OccGridfile.open ("/home/sthapa/getOccGrid.txt", ios::app);
if (OccGridfile.is_open())
{
// OccGridfile << _gridOrigin[0] << "\n";
// OccGridfile << "\n";
// OccGridfile << _gridOrigin[1] << " \n ";
// OccGridfile << "\n";
for ( int xIndex = 0; xIndex < 200; xIndex++ ) //The grid size is 200 X 200
{
for (int yIndex = 0; yIndex < 200; yIndex++)
{
int occVal = _occGrid->at( yIndex * 200 + xIndex );
// printf("%d", occVal ); //Un comment this to test if it's printing the right info
OccGridfile << occVal << " ";
}
OccGridfile << "\n";
}
OccGridfile << "end_of_params \n" ;
OccGridfile.close();
}
else
{
cout << "Unable to open file";
}
ofstream OccGridOriginfile;
OccGridOriginfile.open ("/home/sthapa/getOccGridOrigin.txt", ios::app);
if (OccGridOriginfile.is_open())
{
OccGridOriginfile << _gridOrigin[0] << " " << _gridOrigin[1] << "\n ";
// OccGridOriginfile << "\n";
OccGridOriginfile << "end_of_params \n" ;
OccGridOriginfile.close();
}
else
{
cout << "Unable to open file";
}
}
int main( int argc, char * *argv )
{
ros::init( argc, argv, "convert_toOcc" );
ros::NodeHandle n;
//Subscribe to the occupancy grid nav_msgs
ros::Subscriber _occGridSub = n.subscribe( "/global_freespace/occupancy_grid",1, getNavPack );
while ( ros::ok() )
{
ros::spinOnce();
}
} | [
"noreply@github.com"
] | noreply@github.com |
3110f32c88692d3bed44dc99901b8bb25349f28e | 54f4933d321aedc8250680dbcdfeea4ae6c25c09 | /ScribbleVania/Header/GameObject/Boss/SnailBoss.h | aae78ffd710ed94637f75276512dffa2467883aa | [] | no_license | mahart/ScribbleVania | 2e0f5fd63efee4146ab13aceb0882a5cd8ebe2f3 | fd9f00fe76c8ba6ce1283d42a3cba4d6d182ea80 | refs/heads/master | 2021-01-19T22:10:55.810858 | 2013-12-21T21:40:31 | 2013-12-21T21:40:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,325 | h | #pragma once
#define WIN32_LEAN_AND_MEAN
#include "../Boss.h"
#include "../Player/Player.h"
class SnailBoss : public Boss
{
public:
SnailBoss();
SnailBoss(unsigned int ID, Player* p, D3DXVECTOR3 position);
~SnailBoss();
bool Initialize(ObjectManager* om);
bool Initialize(ObjectManager* om, D3DXVECTOR3 position);
void Draw(COLOR_ARGB color = graphicsNS::WHITE);
void Draw(SpriteData sd, COLOR_ARGB color = graphicsNS::WHITE);
void Update(float elapsedTime);
void ProcessCollision(GameObject* obj);
D3DXVECTOR3 GetDirection();
void AI();
bool IsDead(){return _state == SnailBossState::Dead;}
protected:
private:
int _hitPoints;
int _hitThreshold;
int _hitCount;
int _bounceCount;
float _bounceTimer;
float _startBounceTime;
float _attackTimer;
float _bounceCountStop;
Player* _player;
SnailBossState _state;
float _fallAccel;
float _accel;
Direction _dir;
void UpdateFalling(float elapsedTime);
void UpdateBouncing(float elapsedTime);
void UpdateAttacking(float elapsedTime);
void EnvironmentCollision(EnvironmentObject* obj);
void FloorCollision(EnvironmentObject* obj);
void WallCollision(EnvironmentObject* obj);
void PlayerCollision(Player* obj);
void SwitchBouncing();
void SwitchStanding();
};
| [
"mshart@k-state.edu"
] | mshart@k-state.edu |
a513652b69c1f8e760d45f52359f3ebc84aeeabf | b325034ca11a9fe156ad51f8306f5e20e13511e8 | /ConsolEngine/PlayField.h | 5c6e8d644f7713eb63a742bf3dd663fddf4763bf | [] | no_license | teraGL/Console_Tetris | 3dc0e10c51a7fda5493ed33fae3c7143024e0007 | 4a74b71d5f31ea8bb6c2fd887c956d390549e8b3 | refs/heads/master | 2020-03-25T03:17:00.568854 | 2018-08-02T19:04:40 | 2018-08-02T19:04:40 | 143,323,769 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,191 | h | // Copyright 2009-2014 Blam Games, Inc. All Rights Reserved.
#pragma once
#include "BaseApp.h"
#include "Tetromino.h"
const int kPlayFieldWidth = 15;
const int kPlayFieldHeight = 20;
const int START_X = 7;
const int START_Y = 1;
const float kStep = 1.0f;
const float kQuickStep = 0.8f;
enum KeyCode {
SPACE = 32,
ENTER = 13,
ARROW_LEFT = 75,
ARROW_RIGHT = 77,
ARROW_DOWN = 80
};
class PlayField : public BaseApp
{
public:
PlayField();
virtual void KeyPressed(int btnCode) override;
virtual void UpdateF(float deltaTime) override;
void drawBorders();
bool createTetromino();
void drawCurrentTetromino(const Tetromino* tetromino);
void drawNextTetromino();
void clearOldStuff();
void fixTetroOnTheDeck();
bool emptyLeft();
bool emptyRight();
bool emptyDown();
bool canRotate();
bool removeRows();
void displayStatistics();
void gameOver();
private:
Tetromino* tetromino_;
Tetromino* tetromino_old_;
float current_time_;
int next_tetromino_;
bool next_flip_;
int score_;
float step_;
};
| [
"noreply@github.com"
] | noreply@github.com |
daa0f795ec808a6cd852c4d7c50e4aa0b08828de | e8f584b4467b0679b54b762c5cc45766a77c1a2a | /Graph (GFG)/13_detect_cycle_in_directed_graph_part_2.cpp | f4f480bf2a053bc5318cd607c66c0d841d560e20 | [] | no_license | ravi956/dsa-in-cpp | 84c0fc42e1a8d212c9f60fab9b1cad6bfb1e1475 | 461c4e11f3ba08ce9c2b1d600451e7ef9302a1c6 | refs/heads/master | 2023-06-07T08:58:24.996908 | 2021-06-30T06:21:59 | 2021-06-30T06:21:59 | 294,481,199 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,038 | cpp | // Based on Kahn's Algorithm
#include <bits/stdc++.h>
using namespace std;
void topologicalSort(vector<int> adj[], int V)
{
vector<int> in_degree(V, 0);
for (int u = 0; u < V; u++)
{
for (int x : adj[u])
in_degree[x]++;
}
queue<int> q;
for (int i = 0; i < V; i++)
if (in_degree[i] == 0)
q.push(i);
int count = 0;
while (!q.empty())
{
int u = q.front();
q.pop();
for (int x : adj[u])
if (--in_degree[x] == 0)
q.push(x);
count++;
}
if (count != V)
{
cout << "There exists a cycle in the graph\n";
}
else
{
cout << "There exists no cycle in the graph\n";
}
}
void addEdge(vector<int> adj[], int u, int v)
{
adj[u].push_back(v);
}
int main()
{
int V = 5;
vector<int> adj[V];
addEdge(adj, 0, 1);
addEdge(adj, 4, 1);
addEdge(adj, 1, 2);
addEdge(adj, 2, 3);
addEdge(adj, 3, 1);
topologicalSort(adj, V);
return 0;
}
| [
"ravikumar956078@gmail.com"
] | ravikumar956078@gmail.com |
03f131be2f00b71c57ef18271605306b8a7c5746 | e22a59aaeef2e31bc1c46d4f5f2aa57bd1e6f7c1 | /SDK/SoT_BP_tls_shovel_elb_01_a_v02_ItemInfo_classes.hpp | 3c6719a4ae0e1c9273553be736cb5ee4e72aa31b | [] | no_license | ktim30/SoT-SDK | dbbeb603ebe3c3ac9ca0cd049f86ca72158407ea | e8e401d4fc7982673fc5932e683844fc5eef8210 | refs/heads/master | 2020-04-22T07:20:04.667385 | 2019-02-06T19:08:10 | 2019-02-06T19:08:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,014 | hpp | #pragma once
// Sea of Thieves (1.4) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "SoT_BP_tls_shovel_elb_01_a_v02_ItemInfo_structs.hpp"
namespace SDK
{
//---------------------------------------------------------------------------
//Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass BP_tls_shovel_elb_01_a_v02_ItemInfo.BP_tls_shovel_elb_01_a_v02_ItemInfo_C
// 0x0008 (0x0520 - 0x0518)
class ABP_tls_shovel_elb_01_a_v02_ItemInfo_C : public AItemInfo
{
public:
class USceneComponent* DefaultSceneRoot; // 0x0518(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData)
static UClass* StaticClass()
{
static auto ptr = UObject::FindObject<UClass>(_xor_("BlueprintGeneratedClass BP_tls_shovel_elb_01_a_v02_ItemInfo.BP_tls_shovel_elb_01_a_v02_ItemInfo_C"));
return ptr;
}
void UserConstructionScript();
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"igromanru@yahoo.de"
] | igromanru@yahoo.de |
637675100c3cc367cf693f8bda857efdd4aae13a | 52abd2ccd1435421f756514a23c73843ea301a35 | /bubble/tests/test_Architectures.cpp | 7c0e3b6edaa431bd8dbabbdeaf05500bece34dde | [
"Apache-2.0"
] | permissive | qfizik/tket | 51e684db0f56128a71a18a27d6c660908af391cd | f31cbec63be1a0e08f83494ef7dedb8b7c1dafc8 | refs/heads/main | 2023-08-13T01:20:01.937544 | 2021-09-24T08:09:30 | 2021-09-24T08:09:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,667 | cpp | // Copyright 2019-2021 Cambridge Quantum Computing
//
// 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 <algorithm>
#include <boost/graph/adjacency_list.hpp>
#include <catch2/catch.hpp>
#include <cmath>
#include <iostream>
#include <vector>
#include "Architecture/Architectures.hpp"
#include "Graphs/ArticulationPoints.hpp"
using namespace tket;
using namespace tket::graph;
SCENARIO("Testing FullyConnected") {
using Arch = FullyConnected;
unsigned n_nodes = 10;
node_vector_t nodes_vec = Arch::get_nodes_canonical_order(n_nodes);
node_set_t nodes(nodes_vec.begin(), nodes_vec.end());
Arch arch(n_nodes);
REQUIRE(arch.n_uids() == nodes.size());
for (const UnitID &uid : arch.get_all_uids()) {
REQUIRE(nodes.count(Node(uid)));
}
for (auto [n1, n2] : arch.get_connections_vec()) {
REQUIRE(nodes.count(n1));
REQUIRE(nodes.count(n2));
}
for (unsigned i = 0; i < n_nodes; i++) {
for (unsigned j = 0; j < n_nodes; j++) {
if (i != j) {
Node n1("fcNode", i);
Node n2("fcNode", j);
REQUIRE(arch.connection_exists(n1, n2));
}
}
}
}
SCENARIO("Testing RingArch") {
using Arch = RingArch;
unsigned n_nodes = 10;
node_vector_t nodes_vec = Arch::get_nodes_canonical_order(n_nodes);
node_set_t nodes(nodes_vec.begin(), nodes_vec.end());
Arch arch(n_nodes);
REQUIRE(arch.n_uids() == nodes.size());
for (const UnitID &uid : arch.get_all_uids()) {
REQUIRE(nodes.count(Node(uid)));
}
for (auto [n1, n2] : arch.get_connections_vec()) {
REQUIRE(nodes.count(n1));
REQUIRE(nodes.count(n2));
}
for (unsigned i = 0; i < n_nodes; i++) {
Node n1("ringNode", i);
Node n2("ringNode", (i + 1) % n_nodes);
REQUIRE(arch.connection_exists(n1, n2));
}
}
SCENARIO("Testing SquareGrid") {
using Arch = SquareGrid;
unsigned ver = 5;
unsigned hor = 5;
unsigned layer = 2;
node_vector_t nodes_vec = Arch::get_nodes_canonical_order(ver, hor, layer);
node_set_t nodes(nodes_vec.begin(), nodes_vec.end());
Arch arch(ver, hor, layer);
REQUIRE(nodes.size() == arch.n_uids());
for (const UnitID &uid : arch.get_all_uids()) {
REQUIRE(nodes.count(Node(uid)));
}
for (auto [n1, n2] : arch.get_connections_vec()) {
REQUIRE(nodes.count(n1));
REQUIRE(nodes.count(n2));
}
for (const Node &n : nodes) {
int row = n.index()[0], col = n.index()[1], l = n.index()[2];
for (const Node &neigh : arch.get_neighbour_uids(n)) {
int row_neigh = neigh.index()[0], col_neigh = neigh.index()[1],
l_neigh = neigh.index()[2];
REQUIRE(
abs(row - row_neigh) + abs(col - col_neigh) + abs(l - l_neigh) == 1);
}
}
}
SCENARIO("Diameters") {
GIVEN("an empty architecture") {
Architecture arc;
CHECK_THROWS(arc.get_diameter());
}
GIVEN("a singleton architecture") {
Architecture arc;
arc.add_uid(Node(0));
CHECK(arc.get_diameter() == 0);
}
GIVEN("a connected architecture") {
Architecture arc({{0, 1}, {1, 2}, {2, 3}, {3, 0}});
CHECK(arc.get_diameter() == 2);
}
GIVEN("a disconnected architecture") {
// TKET-1425
Architecture arc({{0, 1}, {1, 2}, {2, 0}, {3, 4}});
CHECK_THROWS(arc.get_diameter());
}
}
SCENARIO("connectivity") {
GIVEN("simple architecture") {
const Architecture archi(
{{Node(0), Node(1)},
{Node(0), Node(2)},
{Node(1), Node(2)},
{Node(2), Node(3)}});
MatrixXb connectivity(4, 4);
connectivity << 0, 1, 1, 0, // 0
1, 0, 1, 0, // 1
1, 1, 0, 1, // 2
0, 0, 1, 0; // 3
REQUIRE(archi.get_connectivity() == connectivity);
}
GIVEN("connected architecture") {
const Architecture archi(
{{Node(0), Node(1)},
{Node(0), Node(2)},
{Node(0), Node(3)},
{Node(1), Node(2)},
{Node(1), Node(3)},
{Node(2), Node(3)}});
MatrixXb connectivity(4, 4);
connectivity << 0, 1, 1, 1, // 0
1, 0, 1, 1, // 1
1, 1, 0, 1, // 2
1, 1, 1, 0; // 3
REQUIRE(archi.get_connectivity() == connectivity);
}
}
| [
"alec.edgington@cambridgequantum.com"
] | alec.edgington@cambridgequantum.com |
6976492351b3cc4bfb8e5d4b932e5537c3d1932b | 43dcbba9c3f06574d362898412196950a715ecb0 | /cmake_tut/src/greeting_en.cpp | e1e6b971fc0b34d041db1311172c87c190a8612d | [] | no_license | QuangNamVu/DocCommand | 79babbb77a285b7598fee678a5581f09beb1d420 | 41b7d6c1058827a3c2d33556a9c24b6a024147d1 | refs/heads/master | 2022-03-29T04:33:27.614007 | 2020-01-23T07:53:41 | 2020-01-23T07:53:41 | 106,441,999 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 76 | cpp | #include <greeting_en.h>
void greeting_en() {
printf("Hello cmake\n");
}
| [
"vqnam97@gmail.com"
] | vqnam97@gmail.com |
c4b2883566e74ea3d9cf41cb2a1fbe0ce94bd81c | 5464d8f847aecb3cbab7629485a1fdff707f0a3d | /s32v234_sdk/libs/arm/apexcv_base/image_filters/build-v234ce-gnu-linux-d/CONVOLVE_SCALE_5X5_16S.hpp | 1c77daefe2d36ec636d5a4b6fa7d4e69c6f675eb | [] | no_license | kernal88/VisionSDK | 73e0d1280ac1574a43f129e0ab8940e8be86000e | 63dfbbb8800c647ac9d23dae08de946e7c1ab6f3 | refs/heads/master | 2021-06-02T14:26:44.838058 | 2016-03-22T00:34:08 | 2016-03-22T00:34:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 82,546 | hpp | #ifndef _ACF_PROCESS_APU_CONVOLVE_SCALE_5X5_16S
#define _ACF_PROCESS_APU_CONVOLVE_SCALE_5X5_16S
#include <acf_process_apu.h>
#include <CONVOLVE_SCALE_5X5_16S_APU_LOAD.h> //APU load associated with this process
#include <stdint.h>
//SCENARIO LIST*************************************************
static acf_scenario_buffer_data gScenarioBufferData0_CONVOLVE_SCALE_5X5_16S[] = {{2, 1, 7, 0, 0x2222}, {2, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData1_CONVOLVE_SCALE_5X5_16S[] = {{4, 1, 7, 0, 0x2222}, {4, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData2_CONVOLVE_SCALE_5X5_16S[] = {{6, 1, 7, 0, 0x2222}, {6, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData3_CONVOLVE_SCALE_5X5_16S[] = {{8, 1, 7, 0, 0x2222}, {8, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData4_CONVOLVE_SCALE_5X5_16S[] = {{10, 1, 7, 0, 0x2222}, {10, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData5_CONVOLVE_SCALE_5X5_16S[] = {{12, 1, 7, 0, 0x2222}, {12, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData6_CONVOLVE_SCALE_5X5_16S[] = {{14, 1, 7, 0, 0x2222}, {14, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData7_CONVOLVE_SCALE_5X5_16S[] = {{16, 1, 7, 0, 0x2222}, {16, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData8_CONVOLVE_SCALE_5X5_16S[] = {{18, 1, 7, 0, 0x2222}, {18, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData9_CONVOLVE_SCALE_5X5_16S[] = {{20, 1, 7, 0, 0x2222}, {20, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData10_CONVOLVE_SCALE_5X5_16S[] = {{22, 1, 7, 0, 0x2222}, {22, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData11_CONVOLVE_SCALE_5X5_16S[] = {{24, 1, 7, 0, 0x2222}, {24, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData12_CONVOLVE_SCALE_5X5_16S[] = {{26, 1, 7, 0, 0x2222}, {26, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData13_CONVOLVE_SCALE_5X5_16S[] = {{28, 1, 7, 0, 0x2222}, {28, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData14_CONVOLVE_SCALE_5X5_16S[] = {{30, 1, 7, 0, 0x2222}, {30, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData15_CONVOLVE_SCALE_5X5_16S[] = {{32, 1, 7, 0, 0x2222}, {32, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData16_CONVOLVE_SCALE_5X5_16S[] = {{48, 1, 7, 0, 0x2222}, {48, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData17_CONVOLVE_SCALE_5X5_16S[] = {{64, 1, 7, 0, 0x2222}, {64, 1, 2, 2, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData18_CONVOLVE_SCALE_5X5_16S[] = {{2, 2, 4, 0, 0x2222}, {2, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData19_CONVOLVE_SCALE_5X5_16S[] = {{4, 2, 4, 0, 0x2222}, {4, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData20_CONVOLVE_SCALE_5X5_16S[] = {{6, 2, 4, 0, 0x2222}, {6, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData21_CONVOLVE_SCALE_5X5_16S[] = {{8, 2, 4, 0, 0x2222}, {8, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData22_CONVOLVE_SCALE_5X5_16S[] = {{10, 2, 4, 0, 0x2222}, {10, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData23_CONVOLVE_SCALE_5X5_16S[] = {{12, 2, 4, 0, 0x2222}, {12, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData24_CONVOLVE_SCALE_5X5_16S[] = {{14, 2, 4, 0, 0x2222}, {14, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData25_CONVOLVE_SCALE_5X5_16S[] = {{16, 2, 4, 0, 0x2222}, {16, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData26_CONVOLVE_SCALE_5X5_16S[] = {{18, 2, 4, 0, 0x2222}, {18, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData27_CONVOLVE_SCALE_5X5_16S[] = {{20, 2, 4, 0, 0x2222}, {20, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData28_CONVOLVE_SCALE_5X5_16S[] = {{22, 2, 4, 0, 0x2222}, {22, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData29_CONVOLVE_SCALE_5X5_16S[] = {{24, 2, 4, 0, 0x2222}, {24, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData30_CONVOLVE_SCALE_5X5_16S[] = {{26, 2, 4, 0, 0x2222}, {26, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData31_CONVOLVE_SCALE_5X5_16S[] = {{28, 2, 4, 0, 0x2222}, {28, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData32_CONVOLVE_SCALE_5X5_16S[] = {{30, 2, 4, 0, 0x2222}, {30, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData33_CONVOLVE_SCALE_5X5_16S[] = {{32, 2, 4, 0, 0x2222}, {32, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData34_CONVOLVE_SCALE_5X5_16S[] = {{48, 2, 4, 0, 0x2222}, {48, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData35_CONVOLVE_SCALE_5X5_16S[] = {{64, 2, 4, 0, 0x2222}, {64, 2, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData36_CONVOLVE_SCALE_5X5_16S[] = {{2, 4, 4, 0, 0x2222}, {2, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData37_CONVOLVE_SCALE_5X5_16S[] = {{4, 4, 4, 0, 0x2222}, {4, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData38_CONVOLVE_SCALE_5X5_16S[] = {{6, 4, 4, 0, 0x2222}, {6, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData39_CONVOLVE_SCALE_5X5_16S[] = {{8, 4, 4, 0, 0x2222}, {8, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData40_CONVOLVE_SCALE_5X5_16S[] = {{10, 4, 4, 0, 0x2222}, {10, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData41_CONVOLVE_SCALE_5X5_16S[] = {{12, 4, 4, 0, 0x2222}, {12, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData42_CONVOLVE_SCALE_5X5_16S[] = {{14, 4, 4, 0, 0x2222}, {14, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData43_CONVOLVE_SCALE_5X5_16S[] = {{16, 4, 4, 0, 0x2222}, {16, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData44_CONVOLVE_SCALE_5X5_16S[] = {{18, 4, 4, 0, 0x2222}, {18, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData45_CONVOLVE_SCALE_5X5_16S[] = {{20, 4, 4, 0, 0x2222}, {20, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData46_CONVOLVE_SCALE_5X5_16S[] = {{22, 4, 4, 0, 0x2222}, {22, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData47_CONVOLVE_SCALE_5X5_16S[] = {{24, 4, 4, 0, 0x2222}, {24, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData48_CONVOLVE_SCALE_5X5_16S[] = {{26, 4, 4, 0, 0x2222}, {26, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData49_CONVOLVE_SCALE_5X5_16S[] = {{28, 4, 4, 0, 0x2222}, {28, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData50_CONVOLVE_SCALE_5X5_16S[] = {{30, 4, 4, 0, 0x2222}, {30, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData51_CONVOLVE_SCALE_5X5_16S[] = {{32, 4, 4, 0, 0x2222}, {32, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData52_CONVOLVE_SCALE_5X5_16S[] = {{48, 4, 4, 0, 0x2222}, {48, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData53_CONVOLVE_SCALE_5X5_16S[] = {{64, 4, 4, 0, 0x2222}, {64, 4, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData54_CONVOLVE_SCALE_5X5_16S[] = {{2, 6, 4, 0, 0x2222}, {2, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData55_CONVOLVE_SCALE_5X5_16S[] = {{4, 6, 4, 0, 0x2222}, {4, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData56_CONVOLVE_SCALE_5X5_16S[] = {{6, 6, 4, 0, 0x2222}, {6, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData57_CONVOLVE_SCALE_5X5_16S[] = {{8, 6, 4, 0, 0x2222}, {8, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData58_CONVOLVE_SCALE_5X5_16S[] = {{10, 6, 4, 0, 0x2222}, {10, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData59_CONVOLVE_SCALE_5X5_16S[] = {{12, 6, 4, 0, 0x2222}, {12, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData60_CONVOLVE_SCALE_5X5_16S[] = {{14, 6, 4, 0, 0x2222}, {14, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData61_CONVOLVE_SCALE_5X5_16S[] = {{16, 6, 4, 0, 0x2222}, {16, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData62_CONVOLVE_SCALE_5X5_16S[] = {{18, 6, 4, 0, 0x2222}, {18, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData63_CONVOLVE_SCALE_5X5_16S[] = {{20, 6, 4, 0, 0x2222}, {20, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData64_CONVOLVE_SCALE_5X5_16S[] = {{22, 6, 4, 0, 0x2222}, {22, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData65_CONVOLVE_SCALE_5X5_16S[] = {{24, 6, 4, 0, 0x2222}, {24, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData66_CONVOLVE_SCALE_5X5_16S[] = {{26, 6, 4, 0, 0x2222}, {26, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData67_CONVOLVE_SCALE_5X5_16S[] = {{28, 6, 4, 0, 0x2222}, {28, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData68_CONVOLVE_SCALE_5X5_16S[] = {{30, 6, 4, 0, 0x2222}, {30, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData69_CONVOLVE_SCALE_5X5_16S[] = {{32, 6, 4, 0, 0x2222}, {32, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData70_CONVOLVE_SCALE_5X5_16S[] = {{48, 6, 4, 0, 0x2222}, {48, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData71_CONVOLVE_SCALE_5X5_16S[] = {{64, 6, 4, 0, 0x2222}, {64, 6, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData72_CONVOLVE_SCALE_5X5_16S[] = {{2, 8, 4, 0, 0x2222}, {2, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData73_CONVOLVE_SCALE_5X5_16S[] = {{4, 8, 4, 0, 0x2222}, {4, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData74_CONVOLVE_SCALE_5X5_16S[] = {{6, 8, 4, 0, 0x2222}, {6, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData75_CONVOLVE_SCALE_5X5_16S[] = {{8, 8, 4, 0, 0x2222}, {8, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData76_CONVOLVE_SCALE_5X5_16S[] = {{10, 8, 4, 0, 0x2222}, {10, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData77_CONVOLVE_SCALE_5X5_16S[] = {{12, 8, 4, 0, 0x2222}, {12, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData78_CONVOLVE_SCALE_5X5_16S[] = {{14, 8, 4, 0, 0x2222}, {14, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData79_CONVOLVE_SCALE_5X5_16S[] = {{16, 8, 4, 0, 0x2222}, {16, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData80_CONVOLVE_SCALE_5X5_16S[] = {{18, 8, 4, 0, 0x2222}, {18, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData81_CONVOLVE_SCALE_5X5_16S[] = {{20, 8, 4, 0, 0x2222}, {20, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData82_CONVOLVE_SCALE_5X5_16S[] = {{22, 8, 4, 0, 0x2222}, {22, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData83_CONVOLVE_SCALE_5X5_16S[] = {{24, 8, 4, 0, 0x2222}, {24, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData84_CONVOLVE_SCALE_5X5_16S[] = {{26, 8, 4, 0, 0x2222}, {26, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData85_CONVOLVE_SCALE_5X5_16S[] = {{28, 8, 4, 0, 0x2222}, {28, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData86_CONVOLVE_SCALE_5X5_16S[] = {{30, 8, 4, 0, 0x2222}, {30, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData87_CONVOLVE_SCALE_5X5_16S[] = {{32, 8, 4, 0, 0x2222}, {32, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData88_CONVOLVE_SCALE_5X5_16S[] = {{48, 8, 4, 0, 0x2222}, {48, 8, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData89_CONVOLVE_SCALE_5X5_16S[] = {{2, 10, 4, 0, 0x2222}, {2, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData90_CONVOLVE_SCALE_5X5_16S[] = {{4, 10, 4, 0, 0x2222}, {4, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData91_CONVOLVE_SCALE_5X5_16S[] = {{6, 10, 4, 0, 0x2222}, {6, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData92_CONVOLVE_SCALE_5X5_16S[] = {{8, 10, 4, 0, 0x2222}, {8, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData93_CONVOLVE_SCALE_5X5_16S[] = {{10, 10, 4, 0, 0x2222}, {10, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData94_CONVOLVE_SCALE_5X5_16S[] = {{12, 10, 4, 0, 0x2222}, {12, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData95_CONVOLVE_SCALE_5X5_16S[] = {{14, 10, 4, 0, 0x2222}, {14, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData96_CONVOLVE_SCALE_5X5_16S[] = {{16, 10, 4, 0, 0x2222}, {16, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData97_CONVOLVE_SCALE_5X5_16S[] = {{18, 10, 4, 0, 0x2222}, {18, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData98_CONVOLVE_SCALE_5X5_16S[] = {{20, 10, 4, 0, 0x2222}, {20, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData99_CONVOLVE_SCALE_5X5_16S[] = {{22, 10, 4, 0, 0x2222}, {22, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData100_CONVOLVE_SCALE_5X5_16S[] = {{24, 10, 4, 0, 0x2222}, {24, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData101_CONVOLVE_SCALE_5X5_16S[] = {{26, 10, 4, 0, 0x2222}, {26, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData102_CONVOLVE_SCALE_5X5_16S[] = {{28, 10, 4, 0, 0x2222}, {28, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData103_CONVOLVE_SCALE_5X5_16S[] = {{30, 10, 4, 0, 0x2222}, {30, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData104_CONVOLVE_SCALE_5X5_16S[] = {{32, 10, 4, 0, 0x2222}, {32, 10, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData105_CONVOLVE_SCALE_5X5_16S[] = {{2, 12, 4, 0, 0x2222}, {2, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData106_CONVOLVE_SCALE_5X5_16S[] = {{4, 12, 4, 0, 0x2222}, {4, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData107_CONVOLVE_SCALE_5X5_16S[] = {{6, 12, 4, 0, 0x2222}, {6, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData108_CONVOLVE_SCALE_5X5_16S[] = {{8, 12, 4, 0, 0x2222}, {8, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData109_CONVOLVE_SCALE_5X5_16S[] = {{10, 12, 4, 0, 0x2222}, {10, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData110_CONVOLVE_SCALE_5X5_16S[] = {{12, 12, 4, 0, 0x2222}, {12, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData111_CONVOLVE_SCALE_5X5_16S[] = {{14, 12, 4, 0, 0x2222}, {14, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData112_CONVOLVE_SCALE_5X5_16S[] = {{16, 12, 4, 0, 0x2222}, {16, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData113_CONVOLVE_SCALE_5X5_16S[] = {{18, 12, 4, 0, 0x2222}, {18, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData114_CONVOLVE_SCALE_5X5_16S[] = {{20, 12, 4, 0, 0x2222}, {20, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData115_CONVOLVE_SCALE_5X5_16S[] = {{22, 12, 4, 0, 0x2222}, {22, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData116_CONVOLVE_SCALE_5X5_16S[] = {{24, 12, 4, 0, 0x2222}, {24, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData117_CONVOLVE_SCALE_5X5_16S[] = {{26, 12, 4, 0, 0x2222}, {26, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData118_CONVOLVE_SCALE_5X5_16S[] = {{28, 12, 4, 0, 0x2222}, {28, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData119_CONVOLVE_SCALE_5X5_16S[] = {{30, 12, 4, 0, 0x2222}, {30, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData120_CONVOLVE_SCALE_5X5_16S[] = {{32, 12, 4, 0, 0x2222}, {32, 12, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData121_CONVOLVE_SCALE_5X5_16S[] = {{2, 14, 4, 0, 0x2222}, {2, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData122_CONVOLVE_SCALE_5X5_16S[] = {{4, 14, 4, 0, 0x2222}, {4, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData123_CONVOLVE_SCALE_5X5_16S[] = {{6, 14, 4, 0, 0x2222}, {6, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData124_CONVOLVE_SCALE_5X5_16S[] = {{8, 14, 4, 0, 0x2222}, {8, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData125_CONVOLVE_SCALE_5X5_16S[] = {{10, 14, 4, 0, 0x2222}, {10, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData126_CONVOLVE_SCALE_5X5_16S[] = {{12, 14, 4, 0, 0x2222}, {12, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData127_CONVOLVE_SCALE_5X5_16S[] = {{14, 14, 4, 0, 0x2222}, {14, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData128_CONVOLVE_SCALE_5X5_16S[] = {{16, 14, 4, 0, 0x2222}, {16, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData129_CONVOLVE_SCALE_5X5_16S[] = {{18, 14, 4, 0, 0x2222}, {18, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData130_CONVOLVE_SCALE_5X5_16S[] = {{20, 14, 4, 0, 0x2222}, {20, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData131_CONVOLVE_SCALE_5X5_16S[] = {{22, 14, 4, 0, 0x2222}, {22, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData132_CONVOLVE_SCALE_5X5_16S[] = {{24, 14, 4, 0, 0x2222}, {24, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData133_CONVOLVE_SCALE_5X5_16S[] = {{26, 14, 4, 0, 0x2222}, {26, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData134_CONVOLVE_SCALE_5X5_16S[] = {{28, 14, 4, 0, 0x2222}, {28, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData135_CONVOLVE_SCALE_5X5_16S[] = {{30, 14, 4, 0, 0x2222}, {30, 14, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData136_CONVOLVE_SCALE_5X5_16S[] = {{2, 16, 4, 0, 0x2222}, {2, 16, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData137_CONVOLVE_SCALE_5X5_16S[] = {{4, 16, 4, 0, 0x2222}, {4, 16, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData138_CONVOLVE_SCALE_5X5_16S[] = {{6, 16, 4, 0, 0x2222}, {6, 16, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData139_CONVOLVE_SCALE_5X5_16S[] = {{8, 16, 4, 0, 0x2222}, {8, 16, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData140_CONVOLVE_SCALE_5X5_16S[] = {{10, 16, 4, 0, 0x2222}, {10, 16, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData141_CONVOLVE_SCALE_5X5_16S[] = {{12, 16, 4, 0, 0x2222}, {12, 16, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData142_CONVOLVE_SCALE_5X5_16S[] = {{14, 16, 4, 0, 0x2222}, {14, 16, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData143_CONVOLVE_SCALE_5X5_16S[] = {{16, 16, 4, 0, 0x2222}, {16, 16, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData144_CONVOLVE_SCALE_5X5_16S[] = {{18, 16, 4, 0, 0x2222}, {18, 16, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData145_CONVOLVE_SCALE_5X5_16S[] = {{20, 16, 4, 0, 0x2222}, {20, 16, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData146_CONVOLVE_SCALE_5X5_16S[] = {{22, 16, 4, 0, 0x2222}, {22, 16, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData147_CONVOLVE_SCALE_5X5_16S[] = {{24, 16, 4, 0, 0x2222}, {24, 16, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData148_CONVOLVE_SCALE_5X5_16S[] = {{26, 16, 4, 0, 0x2222}, {26, 16, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData149_CONVOLVE_SCALE_5X5_16S[] = {{2, 18, 4, 0, 0x2222}, {2, 18, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData150_CONVOLVE_SCALE_5X5_16S[] = {{4, 18, 4, 0, 0x2222}, {4, 18, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData151_CONVOLVE_SCALE_5X5_16S[] = {{6, 18, 4, 0, 0x2222}, {6, 18, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData152_CONVOLVE_SCALE_5X5_16S[] = {{8, 18, 4, 0, 0x2222}, {8, 18, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData153_CONVOLVE_SCALE_5X5_16S[] = {{10, 18, 4, 0, 0x2222}, {10, 18, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData154_CONVOLVE_SCALE_5X5_16S[] = {{12, 18, 4, 0, 0x2222}, {12, 18, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData155_CONVOLVE_SCALE_5X5_16S[] = {{14, 18, 4, 0, 0x2222}, {14, 18, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData156_CONVOLVE_SCALE_5X5_16S[] = {{16, 18, 4, 0, 0x2222}, {16, 18, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData157_CONVOLVE_SCALE_5X5_16S[] = {{18, 18, 4, 0, 0x2222}, {18, 18, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData158_CONVOLVE_SCALE_5X5_16S[] = {{20, 18, 4, 0, 0x2222}, {20, 18, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData159_CONVOLVE_SCALE_5X5_16S[] = {{22, 18, 4, 0, 0x2222}, {22, 18, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData160_CONVOLVE_SCALE_5X5_16S[] = {{2, 20, 4, 0, 0x2222}, {2, 20, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData161_CONVOLVE_SCALE_5X5_16S[] = {{4, 20, 4, 0, 0x2222}, {4, 20, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData162_CONVOLVE_SCALE_5X5_16S[] = {{6, 20, 4, 0, 0x2222}, {6, 20, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData163_CONVOLVE_SCALE_5X5_16S[] = {{8, 20, 4, 0, 0x2222}, {8, 20, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData164_CONVOLVE_SCALE_5X5_16S[] = {{10, 20, 4, 0, 0x2222}, {10, 20, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData165_CONVOLVE_SCALE_5X5_16S[] = {{12, 20, 4, 0, 0x2222}, {12, 20, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData166_CONVOLVE_SCALE_5X5_16S[] = {{14, 20, 4, 0, 0x2222}, {14, 20, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData167_CONVOLVE_SCALE_5X5_16S[] = {{16, 20, 4, 0, 0x2222}, {16, 20, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData168_CONVOLVE_SCALE_5X5_16S[] = {{18, 20, 4, 0, 0x2222}, {18, 20, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData169_CONVOLVE_SCALE_5X5_16S[] = {{20, 20, 4, 0, 0x2222}, {20, 20, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData170_CONVOLVE_SCALE_5X5_16S[] = {{2, 22, 4, 0, 0x2222}, {2, 22, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData171_CONVOLVE_SCALE_5X5_16S[] = {{4, 22, 4, 0, 0x2222}, {4, 22, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData172_CONVOLVE_SCALE_5X5_16S[] = {{6, 22, 4, 0, 0x2222}, {6, 22, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData173_CONVOLVE_SCALE_5X5_16S[] = {{8, 22, 4, 0, 0x2222}, {8, 22, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData174_CONVOLVE_SCALE_5X5_16S[] = {{10, 22, 4, 0, 0x2222}, {10, 22, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData175_CONVOLVE_SCALE_5X5_16S[] = {{12, 22, 4, 0, 0x2222}, {12, 22, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData176_CONVOLVE_SCALE_5X5_16S[] = {{14, 22, 4, 0, 0x2222}, {14, 22, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData177_CONVOLVE_SCALE_5X5_16S[] = {{16, 22, 4, 0, 0x2222}, {16, 22, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData178_CONVOLVE_SCALE_5X5_16S[] = {{18, 22, 4, 0, 0x2222}, {18, 22, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData179_CONVOLVE_SCALE_5X5_16S[] = {{2, 24, 4, 0, 0x2222}, {2, 24, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData180_CONVOLVE_SCALE_5X5_16S[] = {{4, 24, 4, 0, 0x2222}, {4, 24, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData181_CONVOLVE_SCALE_5X5_16S[] = {{6, 24, 4, 0, 0x2222}, {6, 24, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData182_CONVOLVE_SCALE_5X5_16S[] = {{8, 24, 4, 0, 0x2222}, {8, 24, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData183_CONVOLVE_SCALE_5X5_16S[] = {{10, 24, 4, 0, 0x2222}, {10, 24, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData184_CONVOLVE_SCALE_5X5_16S[] = {{12, 24, 4, 0, 0x2222}, {12, 24, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData185_CONVOLVE_SCALE_5X5_16S[] = {{14, 24, 4, 0, 0x2222}, {14, 24, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData186_CONVOLVE_SCALE_5X5_16S[] = {{16, 24, 4, 0, 0x2222}, {16, 24, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData187_CONVOLVE_SCALE_5X5_16S[] = {{2, 26, 4, 0, 0x2222}, {2, 26, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData188_CONVOLVE_SCALE_5X5_16S[] = {{4, 26, 4, 0, 0x2222}, {4, 26, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData189_CONVOLVE_SCALE_5X5_16S[] = {{6, 26, 4, 0, 0x2222}, {6, 26, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData190_CONVOLVE_SCALE_5X5_16S[] = {{8, 26, 4, 0, 0x2222}, {8, 26, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData191_CONVOLVE_SCALE_5X5_16S[] = {{10, 26, 4, 0, 0x2222}, {10, 26, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData192_CONVOLVE_SCALE_5X5_16S[] = {{12, 26, 4, 0, 0x2222}, {12, 26, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData193_CONVOLVE_SCALE_5X5_16S[] = {{14, 26, 4, 0, 0x2222}, {14, 26, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData194_CONVOLVE_SCALE_5X5_16S[] = {{16, 26, 4, 0, 0x2222}, {16, 26, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData195_CONVOLVE_SCALE_5X5_16S[] = {{2, 28, 4, 0, 0x2222}, {2, 28, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData196_CONVOLVE_SCALE_5X5_16S[] = {{4, 28, 4, 0, 0x2222}, {4, 28, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData197_CONVOLVE_SCALE_5X5_16S[] = {{6, 28, 4, 0, 0x2222}, {6, 28, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData198_CONVOLVE_SCALE_5X5_16S[] = {{8, 28, 4, 0, 0x2222}, {8, 28, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData199_CONVOLVE_SCALE_5X5_16S[] = {{10, 28, 4, 0, 0x2222}, {10, 28, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData200_CONVOLVE_SCALE_5X5_16S[] = {{12, 28, 4, 0, 0x2222}, {12, 28, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData201_CONVOLVE_SCALE_5X5_16S[] = {{14, 28, 4, 0, 0x2222}, {14, 28, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData202_CONVOLVE_SCALE_5X5_16S[] = {{2, 30, 4, 0, 0x2222}, {2, 30, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData203_CONVOLVE_SCALE_5X5_16S[] = {{4, 30, 4, 0, 0x2222}, {4, 30, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData204_CONVOLVE_SCALE_5X5_16S[] = {{6, 30, 4, 0, 0x2222}, {6, 30, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData205_CONVOLVE_SCALE_5X5_16S[] = {{8, 30, 4, 0, 0x2222}, {8, 30, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData206_CONVOLVE_SCALE_5X5_16S[] = {{10, 30, 4, 0, 0x2222}, {10, 30, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData207_CONVOLVE_SCALE_5X5_16S[] = {{12, 30, 4, 0, 0x2222}, {12, 30, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData208_CONVOLVE_SCALE_5X5_16S[] = {{2, 32, 4, 0, 0x2222}, {2, 32, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData209_CONVOLVE_SCALE_5X5_16S[] = {{4, 32, 4, 0, 0x2222}, {4, 32, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData210_CONVOLVE_SCALE_5X5_16S[] = {{6, 32, 4, 0, 0x2222}, {6, 32, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData211_CONVOLVE_SCALE_5X5_16S[] = {{8, 32, 4, 0, 0x2222}, {8, 32, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData212_CONVOLVE_SCALE_5X5_16S[] = {{10, 32, 4, 0, 0x2222}, {10, 32, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_buffer_data gScenarioBufferData213_CONVOLVE_SCALE_5X5_16S[] = {{12, 32, 4, 0, 0x2222}, {12, 32, 2, 1, 0x0}, {25, 1, 1, 0, 0x0}, {1, 1, 1, 0, 0x0}};
static acf_scenario_kernel_data gScenarioKernelData0_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData1_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData2_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData3_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData4_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData5_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData6_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData7_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData8_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData9_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData10_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData11_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData12_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData13_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData14_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData15_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData16_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData17_CONVOLVE_SCALE_5X5_16S[] = {{2}};
static acf_scenario_kernel_data gScenarioKernelData18_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData19_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData20_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData21_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData22_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData23_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData24_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData25_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData26_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData27_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData28_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData29_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData30_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData31_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData32_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData33_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData34_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData35_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData36_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData37_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData38_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData39_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData40_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData41_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData42_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData43_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData44_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData45_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData46_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData47_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData48_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData49_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData50_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData51_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData52_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData53_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData54_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData55_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData56_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData57_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData58_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData59_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData60_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData61_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData62_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData63_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData64_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData65_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData66_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData67_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData68_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData69_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData70_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData71_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData72_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData73_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData74_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData75_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData76_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData77_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData78_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData79_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData80_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData81_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData82_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData83_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData84_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData85_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData86_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData87_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData88_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData89_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData90_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData91_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData92_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData93_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData94_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData95_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData96_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData97_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData98_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData99_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData100_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData101_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData102_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData103_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData104_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData105_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData106_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData107_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData108_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData109_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData110_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData111_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData112_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData113_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData114_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData115_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData116_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData117_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData118_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData119_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData120_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData121_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData122_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData123_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData124_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData125_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData126_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData127_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData128_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData129_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData130_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData131_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData132_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData133_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData134_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData135_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData136_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData137_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData138_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData139_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData140_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData141_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData142_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData143_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData144_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData145_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData146_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData147_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData148_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData149_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData150_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData151_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData152_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData153_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData154_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData155_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData156_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData157_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData158_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData159_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData160_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData161_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData162_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData163_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData164_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData165_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData166_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData167_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData168_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData169_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData170_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData171_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData172_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData173_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData174_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData175_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData176_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData177_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData178_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData179_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData180_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData181_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData182_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData183_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData184_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData185_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData186_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData187_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData188_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData189_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData190_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData191_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData192_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData193_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData194_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData195_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData196_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData197_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData198_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData199_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData200_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData201_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData202_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData203_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData204_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData205_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData206_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData207_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData208_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData209_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData210_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData211_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData212_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario_kernel_data gScenarioKernelData213_CONVOLVE_SCALE_5X5_16S[] = {{1}};
static acf_scenario gScenarioArray_CONVOLVE_SCALE_5X5_16S[] = {
{2, 1, 76, 40, 2, gScenarioBufferData0_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData0_CONVOLVE_SCALE_5X5_16S, 2},
{4, 1, 104, 40, 2, gScenarioBufferData1_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData1_CONVOLVE_SCALE_5X5_16S, 2},
{6, 1, 136, 40, 2, gScenarioBufferData2_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData2_CONVOLVE_SCALE_5X5_16S, 2},
{8, 1, 164, 40, 2, gScenarioBufferData3_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData3_CONVOLVE_SCALE_5X5_16S, 2},
{10, 1, 196, 40, 2, gScenarioBufferData4_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData4_CONVOLVE_SCALE_5X5_16S, 2},
{12, 1, 224, 40, 2, gScenarioBufferData5_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData5_CONVOLVE_SCALE_5X5_16S, 2},
{14, 1, 256, 40, 2, gScenarioBufferData6_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData6_CONVOLVE_SCALE_5X5_16S, 2},
{16, 1, 284, 40, 2, gScenarioBufferData7_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData7_CONVOLVE_SCALE_5X5_16S, 2},
{18, 1, 316, 40, 2, gScenarioBufferData8_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData8_CONVOLVE_SCALE_5X5_16S, 2},
{20, 1, 344, 40, 2, gScenarioBufferData9_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData9_CONVOLVE_SCALE_5X5_16S, 2},
{22, 1, 376, 40, 2, gScenarioBufferData10_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData10_CONVOLVE_SCALE_5X5_16S, 2},
{24, 1, 404, 40, 2, gScenarioBufferData11_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData11_CONVOLVE_SCALE_5X5_16S, 2},
{26, 1, 436, 40, 2, gScenarioBufferData12_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData12_CONVOLVE_SCALE_5X5_16S, 2},
{28, 1, 464, 40, 2, gScenarioBufferData13_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData13_CONVOLVE_SCALE_5X5_16S, 2},
{30, 1, 496, 40, 2, gScenarioBufferData14_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData14_CONVOLVE_SCALE_5X5_16S, 2},
{32, 1, 524, 40, 2, gScenarioBufferData15_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData15_CONVOLVE_SCALE_5X5_16S, 2},
{48, 1, 764, 40, 2, gScenarioBufferData16_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData16_CONVOLVE_SCALE_5X5_16S, 2},
{64, 1, 1004, 40, 2, gScenarioBufferData17_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData17_CONVOLVE_SCALE_5X5_16S, 2},
{2, 2, 88, 40, 1, gScenarioBufferData18_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData18_CONVOLVE_SCALE_5X5_16S, 2},
{4, 2, 128, 40, 1, gScenarioBufferData19_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData19_CONVOLVE_SCALE_5X5_16S, 2},
{6, 2, 168, 40, 1, gScenarioBufferData20_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData20_CONVOLVE_SCALE_5X5_16S, 2},
{8, 2, 208, 40, 1, gScenarioBufferData21_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData21_CONVOLVE_SCALE_5X5_16S, 2},
{10, 2, 248, 40, 1, gScenarioBufferData22_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData22_CONVOLVE_SCALE_5X5_16S, 2},
{12, 2, 288, 40, 1, gScenarioBufferData23_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData23_CONVOLVE_SCALE_5X5_16S, 2},
{14, 2, 328, 40, 1, gScenarioBufferData24_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData24_CONVOLVE_SCALE_5X5_16S, 2},
{16, 2, 368, 40, 1, gScenarioBufferData25_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData25_CONVOLVE_SCALE_5X5_16S, 2},
{18, 2, 408, 40, 1, gScenarioBufferData26_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData26_CONVOLVE_SCALE_5X5_16S, 2},
{20, 2, 448, 40, 1, gScenarioBufferData27_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData27_CONVOLVE_SCALE_5X5_16S, 2},
{22, 2, 488, 40, 1, gScenarioBufferData28_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData28_CONVOLVE_SCALE_5X5_16S, 2},
{24, 2, 528, 40, 1, gScenarioBufferData29_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData29_CONVOLVE_SCALE_5X5_16S, 2},
{26, 2, 568, 40, 1, gScenarioBufferData30_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData30_CONVOLVE_SCALE_5X5_16S, 2},
{28, 2, 608, 40, 1, gScenarioBufferData31_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData31_CONVOLVE_SCALE_5X5_16S, 2},
{30, 2, 648, 40, 1, gScenarioBufferData32_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData32_CONVOLVE_SCALE_5X5_16S, 2},
{32, 2, 688, 40, 1, gScenarioBufferData33_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData33_CONVOLVE_SCALE_5X5_16S, 2},
{48, 2, 1008, 40, 1, gScenarioBufferData34_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData34_CONVOLVE_SCALE_5X5_16S, 2},
{64, 2, 1328, 40, 1, gScenarioBufferData35_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData35_CONVOLVE_SCALE_5X5_16S, 2},
{2, 4, 152, 40, 1, gScenarioBufferData36_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData36_CONVOLVE_SCALE_5X5_16S, 2},
{4, 4, 224, 40, 1, gScenarioBufferData37_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData37_CONVOLVE_SCALE_5X5_16S, 2},
{6, 4, 296, 40, 1, gScenarioBufferData38_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData38_CONVOLVE_SCALE_5X5_16S, 2},
{8, 4, 368, 40, 1, gScenarioBufferData39_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData39_CONVOLVE_SCALE_5X5_16S, 2},
{10, 4, 440, 40, 1, gScenarioBufferData40_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData40_CONVOLVE_SCALE_5X5_16S, 2},
{12, 4, 512, 40, 1, gScenarioBufferData41_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData41_CONVOLVE_SCALE_5X5_16S, 2},
{14, 4, 584, 40, 1, gScenarioBufferData42_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData42_CONVOLVE_SCALE_5X5_16S, 2},
{16, 4, 656, 40, 1, gScenarioBufferData43_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData43_CONVOLVE_SCALE_5X5_16S, 2},
{18, 4, 728, 40, 1, gScenarioBufferData44_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData44_CONVOLVE_SCALE_5X5_16S, 2},
{20, 4, 800, 40, 1, gScenarioBufferData45_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData45_CONVOLVE_SCALE_5X5_16S, 2},
{22, 4, 872, 40, 1, gScenarioBufferData46_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData46_CONVOLVE_SCALE_5X5_16S, 2},
{24, 4, 944, 40, 1, gScenarioBufferData47_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData47_CONVOLVE_SCALE_5X5_16S, 2},
{26, 4, 1016, 40, 1, gScenarioBufferData48_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData48_CONVOLVE_SCALE_5X5_16S, 2},
{28, 4, 1088, 40, 1, gScenarioBufferData49_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData49_CONVOLVE_SCALE_5X5_16S, 2},
{30, 4, 1160, 40, 1, gScenarioBufferData50_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData50_CONVOLVE_SCALE_5X5_16S, 2},
{32, 4, 1232, 40, 1, gScenarioBufferData51_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData51_CONVOLVE_SCALE_5X5_16S, 2},
{48, 4, 1808, 40, 1, gScenarioBufferData52_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData52_CONVOLVE_SCALE_5X5_16S, 2},
{64, 4, 2384, 40, 1, gScenarioBufferData53_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData53_CONVOLVE_SCALE_5X5_16S, 2},
{2, 6, 216, 40, 1, gScenarioBufferData54_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData54_CONVOLVE_SCALE_5X5_16S, 2},
{4, 6, 320, 40, 1, gScenarioBufferData55_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData55_CONVOLVE_SCALE_5X5_16S, 2},
{6, 6, 424, 40, 1, gScenarioBufferData56_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData56_CONVOLVE_SCALE_5X5_16S, 2},
{8, 6, 528, 40, 1, gScenarioBufferData57_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData57_CONVOLVE_SCALE_5X5_16S, 2},
{10, 6, 632, 40, 1, gScenarioBufferData58_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData58_CONVOLVE_SCALE_5X5_16S, 2},
{12, 6, 736, 40, 1, gScenarioBufferData59_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData59_CONVOLVE_SCALE_5X5_16S, 2},
{14, 6, 840, 40, 1, gScenarioBufferData60_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData60_CONVOLVE_SCALE_5X5_16S, 2},
{16, 6, 944, 40, 1, gScenarioBufferData61_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData61_CONVOLVE_SCALE_5X5_16S, 2},
{18, 6, 1048, 40, 1, gScenarioBufferData62_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData62_CONVOLVE_SCALE_5X5_16S, 2},
{20, 6, 1152, 40, 1, gScenarioBufferData63_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData63_CONVOLVE_SCALE_5X5_16S, 2},
{22, 6, 1256, 40, 1, gScenarioBufferData64_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData64_CONVOLVE_SCALE_5X5_16S, 2},
{24, 6, 1360, 40, 1, gScenarioBufferData65_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData65_CONVOLVE_SCALE_5X5_16S, 2},
{26, 6, 1464, 40, 1, gScenarioBufferData66_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData66_CONVOLVE_SCALE_5X5_16S, 2},
{28, 6, 1568, 40, 1, gScenarioBufferData67_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData67_CONVOLVE_SCALE_5X5_16S, 2},
{30, 6, 1672, 40, 1, gScenarioBufferData68_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData68_CONVOLVE_SCALE_5X5_16S, 2},
{32, 6, 1776, 40, 1, gScenarioBufferData69_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData69_CONVOLVE_SCALE_5X5_16S, 2},
{48, 6, 2608, 40, 1, gScenarioBufferData70_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData70_CONVOLVE_SCALE_5X5_16S, 2},
{64, 6, 3440, 40, 1, gScenarioBufferData71_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData71_CONVOLVE_SCALE_5X5_16S, 2},
{2, 8, 280, 40, 1, gScenarioBufferData72_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData72_CONVOLVE_SCALE_5X5_16S, 2},
{4, 8, 416, 40, 1, gScenarioBufferData73_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData73_CONVOLVE_SCALE_5X5_16S, 2},
{6, 8, 552, 40, 1, gScenarioBufferData74_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData74_CONVOLVE_SCALE_5X5_16S, 2},
{8, 8, 688, 40, 1, gScenarioBufferData75_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData75_CONVOLVE_SCALE_5X5_16S, 2},
{10, 8, 824, 40, 1, gScenarioBufferData76_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData76_CONVOLVE_SCALE_5X5_16S, 2},
{12, 8, 960, 40, 1, gScenarioBufferData77_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData77_CONVOLVE_SCALE_5X5_16S, 2},
{14, 8, 1096, 40, 1, gScenarioBufferData78_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData78_CONVOLVE_SCALE_5X5_16S, 2},
{16, 8, 1232, 40, 1, gScenarioBufferData79_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData79_CONVOLVE_SCALE_5X5_16S, 2},
{18, 8, 1368, 40, 1, gScenarioBufferData80_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData80_CONVOLVE_SCALE_5X5_16S, 2},
{20, 8, 1504, 40, 1, gScenarioBufferData81_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData81_CONVOLVE_SCALE_5X5_16S, 2},
{22, 8, 1640, 40, 1, gScenarioBufferData82_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData82_CONVOLVE_SCALE_5X5_16S, 2},
{24, 8, 1776, 40, 1, gScenarioBufferData83_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData83_CONVOLVE_SCALE_5X5_16S, 2},
{26, 8, 1912, 40, 1, gScenarioBufferData84_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData84_CONVOLVE_SCALE_5X5_16S, 2},
{28, 8, 2048, 40, 1, gScenarioBufferData85_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData85_CONVOLVE_SCALE_5X5_16S, 2},
{30, 8, 2184, 40, 1, gScenarioBufferData86_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData86_CONVOLVE_SCALE_5X5_16S, 2},
{32, 8, 2320, 40, 1, gScenarioBufferData87_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData87_CONVOLVE_SCALE_5X5_16S, 2},
{48, 8, 3408, 40, 1, gScenarioBufferData88_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData88_CONVOLVE_SCALE_5X5_16S, 2},
{2, 10, 344, 40, 1, gScenarioBufferData89_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData89_CONVOLVE_SCALE_5X5_16S, 2},
{4, 10, 512, 40, 1, gScenarioBufferData90_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData90_CONVOLVE_SCALE_5X5_16S, 2},
{6, 10, 680, 40, 1, gScenarioBufferData91_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData91_CONVOLVE_SCALE_5X5_16S, 2},
{8, 10, 848, 40, 1, gScenarioBufferData92_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData92_CONVOLVE_SCALE_5X5_16S, 2},
{10, 10, 1016, 40, 1, gScenarioBufferData93_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData93_CONVOLVE_SCALE_5X5_16S, 2},
{12, 10, 1184, 40, 1, gScenarioBufferData94_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData94_CONVOLVE_SCALE_5X5_16S, 2},
{14, 10, 1352, 40, 1, gScenarioBufferData95_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData95_CONVOLVE_SCALE_5X5_16S, 2},
{16, 10, 1520, 40, 1, gScenarioBufferData96_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData96_CONVOLVE_SCALE_5X5_16S, 2},
{18, 10, 1688, 40, 1, gScenarioBufferData97_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData97_CONVOLVE_SCALE_5X5_16S, 2},
{20, 10, 1856, 40, 1, gScenarioBufferData98_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData98_CONVOLVE_SCALE_5X5_16S, 2},
{22, 10, 2024, 40, 1, gScenarioBufferData99_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData99_CONVOLVE_SCALE_5X5_16S, 2},
{24, 10, 2192, 40, 1, gScenarioBufferData100_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData100_CONVOLVE_SCALE_5X5_16S, 2},
{26, 10, 2360, 40, 1, gScenarioBufferData101_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData101_CONVOLVE_SCALE_5X5_16S, 2},
{28, 10, 2528, 40, 1, gScenarioBufferData102_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData102_CONVOLVE_SCALE_5X5_16S, 2},
{30, 10, 2696, 40, 1, gScenarioBufferData103_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData103_CONVOLVE_SCALE_5X5_16S, 2},
{32, 10, 2864, 40, 1, gScenarioBufferData104_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData104_CONVOLVE_SCALE_5X5_16S, 2},
{2, 12, 408, 40, 1, gScenarioBufferData105_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData105_CONVOLVE_SCALE_5X5_16S, 2},
{4, 12, 608, 40, 1, gScenarioBufferData106_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData106_CONVOLVE_SCALE_5X5_16S, 2},
{6, 12, 808, 40, 1, gScenarioBufferData107_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData107_CONVOLVE_SCALE_5X5_16S, 2},
{8, 12, 1008, 40, 1, gScenarioBufferData108_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData108_CONVOLVE_SCALE_5X5_16S, 2},
{10, 12, 1208, 40, 1, gScenarioBufferData109_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData109_CONVOLVE_SCALE_5X5_16S, 2},
{12, 12, 1408, 40, 1, gScenarioBufferData110_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData110_CONVOLVE_SCALE_5X5_16S, 2},
{14, 12, 1608, 40, 1, gScenarioBufferData111_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData111_CONVOLVE_SCALE_5X5_16S, 2},
{16, 12, 1808, 40, 1, gScenarioBufferData112_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData112_CONVOLVE_SCALE_5X5_16S, 2},
{18, 12, 2008, 40, 1, gScenarioBufferData113_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData113_CONVOLVE_SCALE_5X5_16S, 2},
{20, 12, 2208, 40, 1, gScenarioBufferData114_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData114_CONVOLVE_SCALE_5X5_16S, 2},
{22, 12, 2408, 40, 1, gScenarioBufferData115_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData115_CONVOLVE_SCALE_5X5_16S, 2},
{24, 12, 2608, 40, 1, gScenarioBufferData116_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData116_CONVOLVE_SCALE_5X5_16S, 2},
{26, 12, 2808, 40, 1, gScenarioBufferData117_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData117_CONVOLVE_SCALE_5X5_16S, 2},
{28, 12, 3008, 40, 1, gScenarioBufferData118_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData118_CONVOLVE_SCALE_5X5_16S, 2},
{30, 12, 3208, 40, 1, gScenarioBufferData119_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData119_CONVOLVE_SCALE_5X5_16S, 2},
{32, 12, 3408, 40, 1, gScenarioBufferData120_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData120_CONVOLVE_SCALE_5X5_16S, 2},
{2, 14, 472, 40, 1, gScenarioBufferData121_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData121_CONVOLVE_SCALE_5X5_16S, 2},
{4, 14, 704, 40, 1, gScenarioBufferData122_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData122_CONVOLVE_SCALE_5X5_16S, 2},
{6, 14, 936, 40, 1, gScenarioBufferData123_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData123_CONVOLVE_SCALE_5X5_16S, 2},
{8, 14, 1168, 40, 1, gScenarioBufferData124_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData124_CONVOLVE_SCALE_5X5_16S, 2},
{10, 14, 1400, 40, 1, gScenarioBufferData125_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData125_CONVOLVE_SCALE_5X5_16S, 2},
{12, 14, 1632, 40, 1, gScenarioBufferData126_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData126_CONVOLVE_SCALE_5X5_16S, 2},
{14, 14, 1864, 40, 1, gScenarioBufferData127_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData127_CONVOLVE_SCALE_5X5_16S, 2},
{16, 14, 2096, 40, 1, gScenarioBufferData128_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData128_CONVOLVE_SCALE_5X5_16S, 2},
{18, 14, 2328, 40, 1, gScenarioBufferData129_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData129_CONVOLVE_SCALE_5X5_16S, 2},
{20, 14, 2560, 40, 1, gScenarioBufferData130_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData130_CONVOLVE_SCALE_5X5_16S, 2},
{22, 14, 2792, 40, 1, gScenarioBufferData131_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData131_CONVOLVE_SCALE_5X5_16S, 2},
{24, 14, 3024, 40, 1, gScenarioBufferData132_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData132_CONVOLVE_SCALE_5X5_16S, 2},
{26, 14, 3256, 40, 1, gScenarioBufferData133_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData133_CONVOLVE_SCALE_5X5_16S, 2},
{28, 14, 3488, 40, 1, gScenarioBufferData134_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData134_CONVOLVE_SCALE_5X5_16S, 2},
{30, 14, 3720, 40, 1, gScenarioBufferData135_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData135_CONVOLVE_SCALE_5X5_16S, 2},
{2, 16, 536, 40, 1, gScenarioBufferData136_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData136_CONVOLVE_SCALE_5X5_16S, 2},
{4, 16, 800, 40, 1, gScenarioBufferData137_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData137_CONVOLVE_SCALE_5X5_16S, 2},
{6, 16, 1064, 40, 1, gScenarioBufferData138_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData138_CONVOLVE_SCALE_5X5_16S, 2},
{8, 16, 1328, 40, 1, gScenarioBufferData139_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData139_CONVOLVE_SCALE_5X5_16S, 2},
{10, 16, 1592, 40, 1, gScenarioBufferData140_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData140_CONVOLVE_SCALE_5X5_16S, 2},
{12, 16, 1856, 40, 1, gScenarioBufferData141_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData141_CONVOLVE_SCALE_5X5_16S, 2},
{14, 16, 2120, 40, 1, gScenarioBufferData142_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData142_CONVOLVE_SCALE_5X5_16S, 2},
{16, 16, 2384, 40, 1, gScenarioBufferData143_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData143_CONVOLVE_SCALE_5X5_16S, 2},
{18, 16, 2648, 40, 1, gScenarioBufferData144_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData144_CONVOLVE_SCALE_5X5_16S, 2},
{20, 16, 2912, 40, 1, gScenarioBufferData145_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData145_CONVOLVE_SCALE_5X5_16S, 2},
{22, 16, 3176, 40, 1, gScenarioBufferData146_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData146_CONVOLVE_SCALE_5X5_16S, 2},
{24, 16, 3440, 40, 1, gScenarioBufferData147_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData147_CONVOLVE_SCALE_5X5_16S, 2},
{26, 16, 3704, 40, 1, gScenarioBufferData148_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData148_CONVOLVE_SCALE_5X5_16S, 2},
{2, 18, 600, 40, 1, gScenarioBufferData149_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData149_CONVOLVE_SCALE_5X5_16S, 2},
{4, 18, 896, 40, 1, gScenarioBufferData150_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData150_CONVOLVE_SCALE_5X5_16S, 2},
{6, 18, 1192, 40, 1, gScenarioBufferData151_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData151_CONVOLVE_SCALE_5X5_16S, 2},
{8, 18, 1488, 40, 1, gScenarioBufferData152_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData152_CONVOLVE_SCALE_5X5_16S, 2},
{10, 18, 1784, 40, 1, gScenarioBufferData153_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData153_CONVOLVE_SCALE_5X5_16S, 2},
{12, 18, 2080, 40, 1, gScenarioBufferData154_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData154_CONVOLVE_SCALE_5X5_16S, 2},
{14, 18, 2376, 40, 1, gScenarioBufferData155_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData155_CONVOLVE_SCALE_5X5_16S, 2},
{16, 18, 2672, 40, 1, gScenarioBufferData156_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData156_CONVOLVE_SCALE_5X5_16S, 2},
{18, 18, 2968, 40, 1, gScenarioBufferData157_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData157_CONVOLVE_SCALE_5X5_16S, 2},
{20, 18, 3264, 40, 1, gScenarioBufferData158_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData158_CONVOLVE_SCALE_5X5_16S, 2},
{22, 18, 3560, 40, 1, gScenarioBufferData159_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData159_CONVOLVE_SCALE_5X5_16S, 2},
{2, 20, 664, 40, 1, gScenarioBufferData160_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData160_CONVOLVE_SCALE_5X5_16S, 2},
{4, 20, 992, 40, 1, gScenarioBufferData161_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData161_CONVOLVE_SCALE_5X5_16S, 2},
{6, 20, 1320, 40, 1, gScenarioBufferData162_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData162_CONVOLVE_SCALE_5X5_16S, 2},
{8, 20, 1648, 40, 1, gScenarioBufferData163_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData163_CONVOLVE_SCALE_5X5_16S, 2},
{10, 20, 1976, 40, 1, gScenarioBufferData164_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData164_CONVOLVE_SCALE_5X5_16S, 2},
{12, 20, 2304, 40, 1, gScenarioBufferData165_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData165_CONVOLVE_SCALE_5X5_16S, 2},
{14, 20, 2632, 40, 1, gScenarioBufferData166_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData166_CONVOLVE_SCALE_5X5_16S, 2},
{16, 20, 2960, 40, 1, gScenarioBufferData167_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData167_CONVOLVE_SCALE_5X5_16S, 2},
{18, 20, 3288, 40, 1, gScenarioBufferData168_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData168_CONVOLVE_SCALE_5X5_16S, 2},
{20, 20, 3616, 40, 1, gScenarioBufferData169_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData169_CONVOLVE_SCALE_5X5_16S, 2},
{2, 22, 728, 40, 1, gScenarioBufferData170_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData170_CONVOLVE_SCALE_5X5_16S, 2},
{4, 22, 1088, 40, 1, gScenarioBufferData171_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData171_CONVOLVE_SCALE_5X5_16S, 2},
{6, 22, 1448, 40, 1, gScenarioBufferData172_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData172_CONVOLVE_SCALE_5X5_16S, 2},
{8, 22, 1808, 40, 1, gScenarioBufferData173_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData173_CONVOLVE_SCALE_5X5_16S, 2},
{10, 22, 2168, 40, 1, gScenarioBufferData174_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData174_CONVOLVE_SCALE_5X5_16S, 2},
{12, 22, 2528, 40, 1, gScenarioBufferData175_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData175_CONVOLVE_SCALE_5X5_16S, 2},
{14, 22, 2888, 40, 1, gScenarioBufferData176_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData176_CONVOLVE_SCALE_5X5_16S, 2},
{16, 22, 3248, 40, 1, gScenarioBufferData177_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData177_CONVOLVE_SCALE_5X5_16S, 2},
{18, 22, 3608, 40, 1, gScenarioBufferData178_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData178_CONVOLVE_SCALE_5X5_16S, 2},
{2, 24, 792, 40, 1, gScenarioBufferData179_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData179_CONVOLVE_SCALE_5X5_16S, 2},
{4, 24, 1184, 40, 1, gScenarioBufferData180_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData180_CONVOLVE_SCALE_5X5_16S, 2},
{6, 24, 1576, 40, 1, gScenarioBufferData181_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData181_CONVOLVE_SCALE_5X5_16S, 2},
{8, 24, 1968, 40, 1, gScenarioBufferData182_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData182_CONVOLVE_SCALE_5X5_16S, 2},
{10, 24, 2360, 40, 1, gScenarioBufferData183_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData183_CONVOLVE_SCALE_5X5_16S, 2},
{12, 24, 2752, 40, 1, gScenarioBufferData184_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData184_CONVOLVE_SCALE_5X5_16S, 2},
{14, 24, 3144, 40, 1, gScenarioBufferData185_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData185_CONVOLVE_SCALE_5X5_16S, 2},
{16, 24, 3536, 40, 1, gScenarioBufferData186_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData186_CONVOLVE_SCALE_5X5_16S, 2},
{2, 26, 856, 40, 1, gScenarioBufferData187_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData187_CONVOLVE_SCALE_5X5_16S, 2},
{4, 26, 1280, 40, 1, gScenarioBufferData188_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData188_CONVOLVE_SCALE_5X5_16S, 2},
{6, 26, 1704, 40, 1, gScenarioBufferData189_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData189_CONVOLVE_SCALE_5X5_16S, 2},
{8, 26, 2128, 40, 1, gScenarioBufferData190_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData190_CONVOLVE_SCALE_5X5_16S, 2},
{10, 26, 2552, 40, 1, gScenarioBufferData191_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData191_CONVOLVE_SCALE_5X5_16S, 2},
{12, 26, 2976, 40, 1, gScenarioBufferData192_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData192_CONVOLVE_SCALE_5X5_16S, 2},
{14, 26, 3400, 40, 1, gScenarioBufferData193_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData193_CONVOLVE_SCALE_5X5_16S, 2},
{16, 26, 3824, 40, 1, gScenarioBufferData194_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData194_CONVOLVE_SCALE_5X5_16S, 2},
{2, 28, 920, 40, 1, gScenarioBufferData195_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData195_CONVOLVE_SCALE_5X5_16S, 2},
{4, 28, 1376, 40, 1, gScenarioBufferData196_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData196_CONVOLVE_SCALE_5X5_16S, 2},
{6, 28, 1832, 40, 1, gScenarioBufferData197_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData197_CONVOLVE_SCALE_5X5_16S, 2},
{8, 28, 2288, 40, 1, gScenarioBufferData198_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData198_CONVOLVE_SCALE_5X5_16S, 2},
{10, 28, 2744, 40, 1, gScenarioBufferData199_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData199_CONVOLVE_SCALE_5X5_16S, 2},
{12, 28, 3200, 40, 1, gScenarioBufferData200_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData200_CONVOLVE_SCALE_5X5_16S, 2},
{14, 28, 3656, 40, 1, gScenarioBufferData201_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData201_CONVOLVE_SCALE_5X5_16S, 2},
{2, 30, 984, 40, 1, gScenarioBufferData202_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData202_CONVOLVE_SCALE_5X5_16S, 2},
{4, 30, 1472, 40, 1, gScenarioBufferData203_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData203_CONVOLVE_SCALE_5X5_16S, 2},
{6, 30, 1960, 40, 1, gScenarioBufferData204_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData204_CONVOLVE_SCALE_5X5_16S, 2},
{8, 30, 2448, 40, 1, gScenarioBufferData205_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData205_CONVOLVE_SCALE_5X5_16S, 2},
{10, 30, 2936, 40, 1, gScenarioBufferData206_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData206_CONVOLVE_SCALE_5X5_16S, 2},
{12, 30, 3424, 40, 1, gScenarioBufferData207_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData207_CONVOLVE_SCALE_5X5_16S, 2},
{2, 32, 1048, 40, 1, gScenarioBufferData208_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData208_CONVOLVE_SCALE_5X5_16S, 2},
{4, 32, 1568, 40, 1, gScenarioBufferData209_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData209_CONVOLVE_SCALE_5X5_16S, 2},
{6, 32, 2088, 40, 1, gScenarioBufferData210_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData210_CONVOLVE_SCALE_5X5_16S, 2},
{8, 32, 2608, 40, 1, gScenarioBufferData211_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData211_CONVOLVE_SCALE_5X5_16S, 2},
{10, 32, 3128, 40, 1, gScenarioBufferData212_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData212_CONVOLVE_SCALE_5X5_16S, 2},
{12, 32, 3648, 40, 1, gScenarioBufferData213_CONVOLVE_SCALE_5X5_16S, 40, gScenarioKernelData213_CONVOLVE_SCALE_5X5_16S, 2}
};
static acf_scenario_list gScenarioList_CONVOLVE_SCALE_5X5_16S = {
214, //number of scenarios
gScenarioArray_CONVOLVE_SCALE_5X5_16S};
//**************************************************************
class CONVOLVE_SCALE_5X5_16S : public ACF_Process_APU
{
public:
CONVOLVE_SCALE_5X5_16S(int32_t apex_id = 0) : ACF_Process_APU(apex_id)
{}
int32_t Initialize()
{
int32_t lRetVal = 0;
if (!Initialized()) //initialization steps that only need to occur once
{
SetProcessIdentifier("CONVOLVE_SCALE_5X5_16S");
SetApuLoadInfo(CONVOLVE_SCALE_5X5_16S_LOAD_SEGMENTS,
CONVOLVE_SCALE_5X5_16S_LOAD_PMEM, CONVOLVE_SCALE_5X5_16S_LOAD_PMEM_SIZE,
CONVOLVE_SCALE_5X5_16S_LOAD_DMEM, CONVOLVE_SCALE_5X5_16S_LOAD_DMEM_SIZE,
0, 0); //assuming _LOAD_CMEM does not exist
FlagSpatialDep();
//***NOTE: the order in which the following ports are added is meaningful; do not change!
AddPort("INPUT_0", ICP_DATATYPE_08U, 1, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0x2020202);
AddPort("F_COEFF", ICP_DATATYPE_08S, 1, 1, 25, 1, 0, 1, 1, 0, 1, 0, 2);
AddPort("F_SCALE", ICP_DATATYPE_32S, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 3);
AddPort("OUTPUT_0", ICP_DATATYPE_16S, 1, 1, 2, 1, 1, 0, 0, 0, 0, 0, 1);
CfgScenarios(&gScenarioList_CONVOLVE_SCALE_5X5_16S);
FlagAsInitialized();
}
lRetVal = SelectApuConfiguration(mApuCfg, mApexId); //by default mApuCfg = ACF_APU_CFG__APEX0_DEFAULT and mApexId = 0
return lRetVal;
}
};
#endif //_ACF_PROCESS_APU_CONVOLVE_SCALE_5X5_16S
| [
"uw.infotainment@gmail.com"
] | uw.infotainment@gmail.com |
8fdfcd27e9d1ada75ea227ff8030b3f97b647a20 | 6aeccfb60568a360d2d143e0271f0def40747d73 | /sandbox/synchro/boost/synchro/lockable/try_lock_upgrade_until.hpp | 48decce8dc9e1792035a775266e529a3196a5ad5 | [] | no_license | ttyang/sandbox | 1066b324a13813cb1113beca75cdaf518e952276 | e1d6fde18ced644bb63e231829b2fe0664e51fac | refs/heads/trunk | 2021-01-19T17:17:47.452557 | 2013-06-07T14:19:55 | 2013-06-07T14:19:55 | 13,488,698 | 1 | 3 | null | 2023-03-20T11:52:19 | 2013-10-11T03:08:51 | C++ | UTF-8 | C++ | false | false | 1,772 | hpp | //////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Vicente J. Botet Escriba 2008-2009.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/synchro for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_SYNCHRO_LOCKABLE_TRY_LOCK_SHARED_UNTIL__HPP
#define BOOST_SYNCHRO_LOCKABLE_TRY_LOCK_SHARED_UNTIL__HPP
#include <boost/chrono/chrono.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost { namespace synchro { namespace lockable {
namespace result_of {
template <typename Lockable, class Clock, class Duration >
struct try_lock_shared_until {
typedef bool type;
};
}
namespace partial_specialization_workaround {
template <typename Lockable, class Clock, class Duration >
struct try_lock_shared_until {
static typename result_of::template try_lock_shared_until<Lockable,Clock,Duration>::type
apply( Lockable& lockable, const chrono::time_point<Clock, Duration>& abs_time ) {
return lockable.try_lock_shared_until(abs_time);
}
};
}
template <typename Lockable, class Clock, class Duration >
typename result_of::template try_lock_shared_until<Lockable,Clock,Duration>::type
try_lock_shared_until(Lockable& lockable, const chrono::time_point<Clock, Duration>& abs_time) {
return partial_specialization_workaround::try_lock_shared_until<Lockable,Clock,Duration>::apply(lockable, abs_time);
}
}}} // namespace boost
#include <boost/config/abi_suffix.hpp>
#endif
| [
"vicente.botet@wanadoo.fr"
] | vicente.botet@wanadoo.fr |
6be6f8566e9cb4063eda95d877094d43e225d07f | 2e2af6a66011ef4daa3156476c55db16c5aaedb8 | /PR3_EX4.3/PR3_EX4.3.ino | 7c19ea2f53939aaeea8feba97fb9d2be03cea482 | [] | no_license | quimmoreno/Practica3ANALOGIC | afec616c5fbd4a4d0ba0771bd9c2cc1e1bc96366 | becc98821f9a3bd0e8dc27169ad6508c65b883ec | refs/heads/master | 2021-01-10T04:50:16.159556 | 2015-05-22T10:55:40 | 2015-05-22T10:55:40 | 36,066,423 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 691 | ino | const int PITU = 3; // PIN 3
const int entrada = A0; // ENTRADA A0 DURADA XIULET
const int entrada1 = A0; // ENTRADA A1 DURADA TEMPS D'ESPERA
int POT; // VALOR POTENCIOMETRE
int F; //FREQUENCIA
int T= 5000; //TEMPS D'ESPERA
void setup()
{
pinMode(PITU, OUTPUT); // PIN 3 SORTIDA ALTAVEU
}
void loop()
{
POT = analogRead(entrada); // LECTURA POTENCIOMETRE
F = analogRead(entrada1); // LECTURA POTENCIOMETRE
POT= map(POT,0,1023,0,1000);
F = map(F,0,1023,20,10000);
tone(PITU, F, POT); // FUNCIO PER FER SONAR EL ALTAVEU
delay(POT + T); // TEMPS D'ESPERA
}
//QUIM MORENO
| [
"moreno_kim_95@hotmail.com"
] | moreno_kim_95@hotmail.com |
a5899514a7b3a9eda186a024288d157ad4741977 | 56a4cb943d085a672f8b0d08a8c047f772e6a45e | /code/Johnson_Engine/Runtime/render_a/src/sys/d3d/rendermodelpiecelist.cpp | a207f036ffbee6bd2d756cc963494d0db0d7d532 | [] | no_license | robertveloso/suddenattack_legacy | 2016fa21640d9a97227337ac8b2513af7b0ce00b | 05ff49cced2ba651c25c18379fed156c58a577d7 | refs/heads/master | 2022-06-20T05:00:10.375695 | 2020-05-08T01:46:02 | 2020-05-08T01:46:02 | 262,199,345 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 17,603 | cpp | #include "precompile.h"
#include "setupmodel.h"
#include "d3dmeshrendobj_rigid.h"
#include "d3dmeshrendobj_skel.h"
#include "d3dmeshrendobj_vertanim.h"
#include "d3d_renderstatemgr.h"
#include "iltdrawprim.h"
#include "d3d_texture.h"
#include "rendermodelpiecelist.h"
#include "devicelightlist.h"
#include "renderstylemap.h"
#include "rendererframestats.h"
#include <algorithm>
//---------------------------------------------------------------------------------
// Utility functions
//---------------------------------------------------------------------------------
//given a renderable model piece, this will look at the type and determine the appropriate
//means of starting its rendering block
static void BeginRenderableModelPiece(CDIModelDrawable* pRPiece, CD3DRenderStyle* pRenderStyle, uint32 nCurrPass)
{
//we shouldn't ever have a NULL piece in here
assert(pRPiece);
//see what type it is
switch (pRPiece->GetType())
{
case CRenderObject::eSkelMesh :
((CD3DSkelMesh*)pRPiece)->BeginRender(pRenderStyle, nCurrPass);
break;
case CRenderObject::eRigidMesh :
((CD3DRigidMesh*)pRPiece)->BeginRender(pRenderStyle, nCurrPass);
break;
case CRenderObject::eVAMesh :
break;
}
}
//given a renderable model piece, this will render it. This assumes that the begin has already
//been called for this piece and any other pieces prior have been ended
static void RenderModelPiece( CDIModelDrawable* pRPiece,
ModelInstance* pInstance,
DDMatrix* pTransforms,
CD3DRenderStyle* pRenderStyle,
uint32 nCurrPass )
{
//all parameters should be valid
assert(pRPiece);
assert(pInstance);
assert(pRenderStyle);
//see what type it is
switch (pRPiece->GetType())
{
case CRenderObject::eSkelMesh :
{
((CD3DSkelMesh*)pRPiece)->Render(pInstance, pTransforms, pRenderStyle, nCurrPass);
IncFrameStat(eFS_ModelRender_NumSkeletalPieces, 1);
}
break;
case CRenderObject::eRigidMesh :
{
((CD3DRigidMesh*)pRPiece)->Render(pInstance, pTransforms[((CD3DRigidMesh*)pRPiece)->GetBoneEffector()], pRenderStyle, nCurrPass);
IncFrameStat(eFS_ModelRender_NumRigidPieces, 1);
}
break;
case CRenderObject::eVAMesh :
{
((CD3DVAMesh*)pRPiece)->UpdateVA(pInstance->GetModelDB(), &pInstance->m_AnimTracker.m_TimeRef);
// needs global pos.
LTMatrix mTrans;
if(pInstance->GetCachedTransform(((CD3DVAMesh*)pRPiece)->GetBoneEffector(), mTrans))
{
DDMatrix mD3DTrans;
Convert_DItoDD(mTrans, mD3DTrans);
((CD3DVAMesh*)pRPiece)->Render(pInstance, mD3DTrans, pRenderStyle, nCurrPass);
IncFrameStat(eFS_ModelRender_NumVertexAnimatedPieces, 1);
}
}
break;
}
//update our model polygon counts for information reporting
IncFrameStat(eFS_ModelTriangles, pRPiece->GetPolyCount());
}
//given a renderable model piece, this will look at the type and determine the appropriate
//means of ending its rendering block
static void EndRenderableModelPiece(CDIModelDrawable* pRPiece)
{
//bail if it is a null piece, this is actually valid in the end call
if(!pRPiece)
return;
//see what type it is
switch (pRPiece->GetType())
{
case CRenderObject::eSkelMesh :
((CD3DSkelMesh*)pRPiece)->EndRender();
break;
case CRenderObject::eRigidMesh :
((CD3DRigidMesh*)pRPiece)->EndRender();
break;
case CRenderObject::eVAMesh :
break;
}
}
//handles checking the to be installed render style and determining if it should be updated to accomodate
//for environment map panning. Note that I am fully aware that this is probably the worst way possible
//to handle this, but I just pulled this from the original model rendering pipeline. Returns if it was
//modified or not
static bool HandleReallyCloseEnvMapPanning(ModelInstance* pInstance, CD3DRenderStyle* pRenderStyle, uint32 nRenderPass, bool bPrevWasSet)
{
// Modify the texture transform based on the viewer position
// for player view models.
// check to see that the r/s has a second stage that's an env map.
// if so, change the texture matrix based on the current view x-form.
if(pRenderStyle->GetRenderPassCount() > 0 )
{
RenderPassOp RenderPass;
if(pRenderStyle->GetRenderPass(nRenderPass, &RenderPass))
{
// set uv transform.
if(RenderPass.TextureStages[1].UVTransform_Enable == true)
{
if( (pInstance->m_Flags & FLAG_REALLYCLOSE) != 0 )
{
//early out if it is already set
if(bPrevWasSet)
return true;
LTMatrix mat;
mat.Identity();
const LTMatrix & view = g_ViewParams.m_mInvView;
// remember somethings.
static LTVector vLastPos(view.m[0][3], view.m[1][3], view.m[2][3]);
static bool bInitCamOfs = true;
static LTMatrix mCamOfs;
if (bInitCamOfs)
{
mCamOfs.Identity();
bInitCamOfs = false;
}
// transform based camera pos and orientation (forwardvec);
// set x/z UV-rotation based on forward vector of camera.
LTVector v1,v2,v3;
view.GetBasisVectors(&v1,&v2,&v3);
// change in pos
LTVector vOffset(view.m[0][3] - vLastPos.x, view.m[1][3] - vLastPos.y, view.m[2][3] - vLastPos.z);
vOffset /= g_CV_PVModelEnvmapVelocity.m_Val;
LTVector vCamRelOfs(vOffset.Dot(v1), vOffset.Dot(v2), vOffset.Dot(v3));
LTMatrix mRotateAboutY;
mRotateAboutY.SetupRot(LTVector(0.0f, 1.0f, 0.0f), vCamRelOfs.x);
mCamOfs = mRotateAboutY * mCamOfs;
LTMatrix mRotateAboutX;
mRotateAboutX.SetupRot(LTVector(1.0f, 0.0f, 0.0f), -(vCamRelOfs.y + vCamRelOfs.z));
mCamOfs = mRotateAboutX * mCamOfs;
mCamOfs.Normalize();
mat = mCamOfs * g_ViewParams.m_mView;
vLastPos.x = view.m[0][3];
vLastPos.y = view.m[1][3];
vLastPos.z = view.m[2][3];
// set the matrix.
g_RenderStateMgr.SetTransform(D3DTS_TEXTURE1, (D3DMATRIX*)&mat);
return true;
}
else if(bPrevWasSet)
{
g_RenderStateMgr.SetTransform(D3DTS_TEXTURE1, (D3DXMATRIX*)&RenderPass.TextureStages[1].UVTransform_Matrix);
}
}
}
}
return false;
}
//---------------------------------------------------------------------------------
// SQueuedPiece
//---------------------------------------------------------------------------------
CRenderModelPieceList::SQueuedPiece::SQueuedPiece()
{
//nothing really needs to be initialized...so don't for performance
}
CRenderModelPieceList::SQueuedPiece::SQueuedPiece(const SQueuedPiece& rhs)
{
//copy everything over
*this = rhs;
}
CRenderModelPieceList::SQueuedPiece::~SQueuedPiece()
{
//nothing to clean up
}
//singleton access
CRenderModelPieceList& CRenderModelPieceList::GetSingleton()
{
static CRenderModelPieceList sSingleton;
return sSingleton;
}
CRenderModelPieceList::SQueuedPiece& CRenderModelPieceList::SQueuedPiece::operator=(const SQueuedPiece& rhs)
{
//just copy
memcpy(this, &rhs, sizeof(rhs));
return *this;
}
bool CRenderModelPieceList::SQueuedPiece::operator==(const SQueuedPiece& rhs) const
{
return memcmp(this, &rhs, sizeof(rhs)) == 0;
}
bool CRenderModelPieceList::SQueuedPiece::operator<(const SQueuedPiece& rhs) const
{
//here is where it gets tricky, we need to sort based upon the following criteria:
//1 - Really Close
//2 - Render Priority
//3 - Render Style
//4 - Textures
//5 - Render object
//6 - Lights
//really close needs to come last
if(m_bReallyClose != rhs.m_bReallyClose)
return rhs.m_bReallyClose;
//now we need to render lowest priority first, then higher, and so on
if(m_nRenderPriority != rhs.m_nRenderPriority)
return m_nRenderPriority < rhs.m_nRenderPriority;
//now the render style, just sort based upon address
if(m_pRenderStyle != rhs.m_pRenderStyle)
return m_pRenderStyle < rhs.m_pRenderStyle;
//now sort based upon the textures
int nTexDiff = memcmp(m_TextureList, rhs.m_TextureList, sizeof(m_TextureList));
if(nTexDiff)
return nTexDiff < 0;
//now upon the render object
if(m_pRenderPiece != rhs.m_pRenderPiece)
return m_pRenderPiece < rhs.m_pRenderPiece;
//now upon the lights
if(!m_pLightList->IsSameAs(rhs.m_pLightList))
return m_pLightList < rhs.m_pLightList;
//they are equal
return false;
}
//---------------------------------------------------------------------------------
// CRenderModelPieceList
//---------------------------------------------------------------------------------
CRenderModelPieceList::CRenderModelPieceList()
{
}
CRenderModelPieceList::CRenderModelPieceList(const CRenderModelPieceList&)
{
}
//adds a piece to be rendered
void CRenderModelPieceList::QueuePiece(ModelInstance* pInstance, ModelPiece* pPiece, CDIModelDrawable* pLOD, DDMatrix* pTransforms, CDeviceLightList* pLightList, bool bTexture, const ModelHookData* pHookData)
{
//make sure that the items they passed are valid
assert(pInstance);
assert(pPiece);
assert(pLOD);
assert(pLightList);
//we need to extract all the relevant information, fill out a piece structure, and add it
//to the list to be rendered
SQueuedPiece Info;
Info.m_bReallyClose = (pInstance->m_Flags & FLAG_REALLYCLOSE) != 0;
Info.m_nRenderPriority = pPiece->m_nRenderPriority;
Info.m_pLightList = pLightList;
Info.m_pRenderPiece = pLOD;
Info.m_pInstance = pInstance;
Info.m_pTransforms = pTransforms;
Info.m_pHookData = pHookData;
//get the appropriate render style (or the backup one if none exists)
Info.m_pRenderStyle = NULL;
if (!pInstance->GetRenderStyle(pPiece->m_iRenderStyle,(CRenderStyle**)(&Info.m_pRenderStyle)) || !Info.m_pRenderStyle)
{
//failed to get the associated render style, get the default
Info.m_pRenderStyle = g_RenderStateMgr.GetBackupRenderStyle();
}
uint32 nCurrTexture = 0;
if(bTexture)
{
for(; nCurrTexture < pPiece->m_nNumTextures; nCurrTexture++)
{
if (pInstance->m_pSkins[pPiece->m_iTextures[nCurrTexture]] &&
pInstance->m_pSkins[pPiece->m_iTextures[nCurrTexture]]->m_pRenderData)
{
Info.m_TextureList[nCurrTexture] = pInstance->m_pSkins[pPiece->m_iTextures[nCurrTexture]];
}
else
{
Info.m_TextureList[nCurrTexture] = NULL;
}
}
}
//fill up any leftover slots with NULL pointers
for (; nCurrTexture < MAX_PIECE_TEXTURES; ++nCurrTexture)
{
Info.m_TextureList[nCurrTexture] = NULL;
}
//alright, the info is complete, put it on the list
LT_MEM_TRACK_ALLOC(m_cPieceList.push_back(Info), LT_MEM_TYPE_RENDERER);
}
//Renders all the queued pieces and flushes the list
void CRenderModelPieceList::RenderPieceList(float fAlpha)
{
// Oh my god! STL-Port let us down! We have to use stable_sort, because
// sort appears to have a problem sorting this list sometimes.
//we need to sort the list first
//std::sort(m_cPieceList.begin(), m_cPieceList.end());
stable_sort(m_cPieceList.begin(), m_cPieceList.end());
//make sure some stuff is setup
StateSet ssLightEnable(D3DRS_LIGHTING, TRUE);
PD3DDEVICE->SetRenderState(D3DRS_NORMALIZENORMALS, FALSE);
//now that the list is sorted, we can run through and render
//flag to keep track of when we are in really close and not
bool bInReallyClose = false;
CReallyCloseData ReallyCloseData;
//the previous object's settings
CDIModelDrawable* pPrevRPiece = NULL;
CDeviceLightList* pPrevLightList = NULL;
bool bPrevPieceScaled = false;
LPDIRECT3DBASETEXTURE8 PrevTextureList[MAX_PIECE_TEXTURES];
//save the Z bias so we can restore it later
DWORD nOldZBias;
PD3DDEVICE->GetRenderState(D3DRS_ZBIAS, &nOldZBias);
//clear out the texture list
memset(PrevTextureList, 0, sizeof(PrevTextureList));
for(uint32 nCurrPiece = 0; nCurrPiece < m_cPieceList.size();)
{
//we now have our starting, we now need to expand out and see where this render style ends
//(being careful to observe the really close switch)
uint32 nStartPiece = nCurrPiece;
CD3DRenderStyle* pCurrRenderStyle = m_cPieceList[nStartPiece].m_pRenderStyle;
for(; nCurrPiece < m_cPieceList.size(); nCurrPiece++)
{
//see if we need to bail
if( (m_cPieceList[nCurrPiece].m_pRenderStyle != pCurrRenderStyle) ||
(m_cPieceList[nCurrPiece].m_bReallyClose != m_cPieceList[nStartPiece].m_bReallyClose))
{
break;
}
}
//we may need to modify the render style to apply the alpha of the piece
LightingMaterial OriginalLightMaterial;
// Over-ride the color if the model requests it...
if (fAlpha < 0.99f)
{
if (pCurrRenderStyle->GetLightingMaterial(&OriginalLightMaterial))
{
LightingMaterial OverrideLightMaterial = OriginalLightMaterial;
OverrideLightMaterial = OriginalLightMaterial;
OverrideLightMaterial.Ambient.a = fAlpha * OriginalLightMaterial.Ambient.a;
OverrideLightMaterial.Diffuse.a = fAlpha * OriginalLightMaterial.Diffuse.a;
OverrideLightMaterial.Specular.a = fAlpha * OriginalLightMaterial.Specular.a;
pCurrRenderStyle->SetLightingMaterial(OverrideLightMaterial);
}
}
//run through each pass of the current render style
for(uint32 nCurrPass = 0; nCurrPass < pCurrRenderStyle->GetRenderPassCount(); nCurrPass++)
{
if(g_CV_ZBiasModelRSPasses.m_Val)
{
PD3DDEVICE->SetRenderState(D3DRS_ZBIAS, nCurrPass);
}
bool bModifiedReallyCloseEnvMap = false;
//setup all the texture and render style information
g_RenderStateMgr.SetRenderStyleStates(pCurrRenderStyle, nCurrPass);
g_RenderStateMgr.SetRenderStyleTextures(pCurrRenderStyle, nCurrPass, m_cPieceList[nStartPiece].m_TextureList);
//keep track of stats
IncFrameStat(eFS_ModelRender_RenderStyleSets, 1);
IncFrameStat(eFS_ModelRender_TextureSets, 1);
//update our texture list information since the render style set them
memcpy(PrevTextureList, m_cPieceList[nStartPiece].m_TextureList, sizeof(PrevTextureList));
//now we need to render each piece of this pass
for(uint32 nRSPiece = nStartPiece; nRSPiece < nCurrPiece; nRSPiece++)
{
//cache the current piece
SQueuedPiece& Piece = m_cPieceList[nRSPiece];
//handle environment mapping on the PV
bModifiedReallyCloseEnvMap = HandleReallyCloseEnvMapPanning(Piece.m_pInstance, pCurrRenderStyle, nCurrPass, bModifiedReallyCloseEnvMap);
//see if we have crossed any boundaries. If we have we need to change the appropriate part
if(memcmp(PrevTextureList, Piece.m_TextureList, sizeof(PrevTextureList)))
{
//need to swap textures
g_RenderStateMgr.SetRenderStyleTextures(pCurrRenderStyle, nCurrPass, Piece.m_TextureList);
memcpy(PrevTextureList, Piece.m_TextureList, sizeof(PrevTextureList));
IncFrameStat(eFS_ModelRender_TextureSets, 1);
}
if(!pPrevLightList || !pPrevLightList->IsSameAs(Piece.m_pLightList))
{
Piece.m_pLightList->InstallLightList();
pPrevLightList = Piece.m_pLightList;
IncFrameStat(eFS_ModelRender_LightingSets, 1);
}
if(bInReallyClose != Piece.m_bReallyClose)
{
d3d_SetReallyClose(&ReallyCloseData);
bInReallyClose = Piece.m_bReallyClose;
IncFrameStat(eFS_ModelRender_ReallyCloseSets, 1);
}
if(pPrevRPiece != Piece.m_pRenderPiece)
{
//end the old one
EndRenderableModelPiece(pPrevRPiece);
//begin the new one
BeginRenderableModelPiece(Piece.m_pRenderPiece, pCurrRenderStyle, nCurrPass);
//save the new one
pPrevRPiece = Piece.m_pRenderPiece;
}
//we also need to determine whether or not we need to scale the normals of this piece
bool bPieceScaled = Piece.m_pInstance->IsScaled();
if(bPieceScaled != bPrevPieceScaled)
{
PD3DDEVICE->SetRenderState(D3DRS_NORMALIZENORMALS, bPieceScaled ? TRUE : FALSE);
bPrevPieceScaled = bPieceScaled;
IncFrameStat(eFS_ModelRender_ScaleSets, 1);
}
//ok, we can finally render our piece
RenderModelPiece(Piece.m_pRenderPiece, Piece.m_pInstance, Piece.m_pTransforms, pCurrRenderStyle, nCurrPass);
}
//we should end any outstanding pieces being rendered so the changing of the pass won't mess them up
EndRenderableModelPiece(pPrevRPiece);
pPrevRPiece = NULL;
}
//cleanup any changes we made to the render style
if (fAlpha < 0.99f)
{
pCurrRenderStyle->SetLightingMaterial(OriginalLightMaterial);
}
}
//we need to unset really close if we entered it
if(bInReallyClose)
d3d_UnsetReallyClose(&ReallyCloseData);
//restore our transform to be the identity matrix
const D3DMATRIX mIdentity = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
g_RenderStateMgr.SetTransform(D3DTS_WORLDMATRIX(0),&mIdentity);
//restore our Z bias
PD3DDEVICE->SetRenderState(D3DRS_ZBIAS, nOldZBias);
// Need to reset every time till the render state mgr handles things...
g_Device.SetDefaultRenderStates();
//we are done, clear out the lists
m_cPieceList.clear();
}
//call this to free all memory associated with the piece list. This will require it to grow
//again, but is a good chance to clean up after some level that used a lot of models
//and caused it to grow too large
void CRenderModelPieceList::FreeListMemory()
{
//standard STL trick to force vector to give up memory
TPieceList cEmptyPiece;
cEmptyPiece.swap(m_cPieceList);
}
//remaps all the render styles using the specified map
void CRenderModelPieceList::RemapRenderStyles(const CRenderStyleMap& Map)
{
for(TPieceList::iterator it = m_cPieceList.begin(); it != m_cPieceList.end(); it++)
{
//see what this pieces render style maps to
CD3DRenderStyle* pMapTo;
if(it->m_pHookData->m_HookFlags & MHF_NOGLOW)
{
pMapTo = (CD3DRenderStyle*)Map.GetNoGlowRenderStyle();
}
else
{
pMapTo = (CD3DRenderStyle*)Map.MapRenderStyle(it->m_pRenderStyle);
}
//see if we overrode it
if(pMapTo)
{
it->m_pRenderStyle = pMapTo;
}
}
} | [
"robert@velosodigital.com"
] | robert@velosodigital.com |
7851cead4d360b9022d8790090acfa5ceafc18c2 | bd29e9bea797b0560579f651e8fff6d893d4a3dd | /src/chippe8.cpp | 22e17fa8f903843a2259158f38ea97f3576c6f8e | [] | no_license | renaultfernandes/chippe8 | 0f392b98eb6e78f55d54981bf54236378de26c1a | bb20622be3f139216f3fc80b9397209cccb0e1e6 | refs/heads/master | 2021-03-27T12:55:04.086381 | 2019-08-11T16:07:40 | 2019-08-11T16:07:40 | 123,957,654 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,548 | cpp | #include "chippe8.hpp"
#include <fstream>
#include <iostream>
#include <chrono>
#include <thread>
void Chippe8::run()
{
auto msPerFrame = std::chrono::milliseconds(MS_PER_FRAME);
SDL_Event event;
while (running) {
auto startTime = std::chrono::steady_clock::now();
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
running = false;
}
else if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP) {
input.handleInput(event, event.type == SDL_KEYDOWN);
}
}
cpu.runStep();
timer.tick();
graphics.render();
auto endTime = std::chrono::steady_clock::now();
auto sleepTime = startTime + msPerFrame - endTime;
// std::cout << "Sleeping for " << std::chrono::duration_cast<std::chrono::milliseconds>(sleepTime).count() << " ms." << std::endl;
std::this_thread::sleep_for(sleepTime);
}
}
void Chippe8::reset()
{
memory.reset();
timer.reset();
}
void Chippe8::loadGame(const std::string& path)
{
std::ifstream gameFile(path.c_str(), std::ios::binary);
// Get the filesize of the game
gameFile.seekg(0, gameFile.end);
int fileSize = gameFile.tellg();
gameFile.seekg(0, gameFile.beg);
// Read the game file
char* buffer = new char[fileSize];
gameFile.read(buffer, fileSize);
memory.reset();
// Load the game file to the memory
for (uint16_t i = 0; i < fileSize; i++) {
memory.set(i + PROGRAM_START_ADDRESS, buffer[i]);
}
}
void Chippe8::dumpState()
{
std::cout << "Chippe8 State" << std::endl;
memory.dump();
}
| [
"renault.j.ferns@gmail.com"
] | renault.j.ferns@gmail.com |
26f45ff65917c47f12a09a23578bf5c239a62090 | fb1cd763904071cabef7d15e9a3e1bdf8425e630 | /57.6174问题/6174问题.cpp | 8533eb4fa75bd689f770760e65e3d86f82c0da59 | [] | no_license | liuye1996/ACM_Works | cc1f65310c5ad374eff8c63956ac2b47ae79c5bd | 6eef944041a3b7181053518ac1cd502073926bbd | refs/heads/master | 2020-04-10T03:58:44.236149 | 2018-07-13T05:17:14 | 2018-07-13T05:17:14 | 124,260,699 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,399 | cpp | /*
2018/3/18
题目57
6174问题
时间限制:1000 ms | 内存限制:65535 KB
难度:2
描述
假设你有一个各位数字互不相同的四位数,把所有的数字从大到小排序后得到a,从小到大后得到b,然后用a-b替换原来这个数,并且继续操作。例如,从1234出发,依次可以得到4321-1234=3087、8730-378=8352、8532-2358=6174,又回到了它自己!现在要你写一个程序来判断一个四位数经过多少次这样的操作能出现循环,并且求出操作的次数
比如输入1234执行顺序是1234->3087->8352->6174->6174,输出是4
输入
第一行输入n,代表有n组测试数据。
接下来n行每行都写一个各位数字互不相同的四位数
输出
经过多少次上面描述的操作才能出现循环
样例输入
1
1234
样例输出
4
*/
#include<iostream>
#include <algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
int num, a, b, c, i, x[4];
while (n--)
{
cin >> num;
for (i=1; ; i++)
{
x[3] = num / 1000;
x[2] = num / 100 % 10;
x[1] = num % 100 / 10;
x[0] = num % 10;
sort(x, x + 4);
a = x[3] * 1000 + x[2] * 100 + x[1] * 10 + x[0];
b = x[0] * 1000 + x[1] * 100 + x[2] * 10 + x[3];
if (num == a - b) break;
else num = a - b;
//cout << a;
}
cout << i<< endl;
}
//return 0;
system("pause");
} | [
"noreply@github.com"
] | noreply@github.com |
0b5fbf6bd57187fd9be00c23858654806eaad6bb | e8d3c90dfb0902286be260cb307559e4a27cfdb0 | /Find_Bank_Card_Number/Find_Bank_Card_Number/FindNumber.cpp | b895175dd129f83ff7fa9e6be038ff2cd8b360dd | [] | no_license | HatsuneMona/BankCardOCR | a0d08cd55789ac05bb2011ce86151a8bf99af1d8 | 9e1bbe58fb1c8db892ae32756a8da578606fd78c | refs/heads/master | 2023-03-31T10:45:06.733578 | 2019-05-28T09:17:21 | 2019-05-28T09:17:21 | 183,617,786 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 7,792 | cpp | #include "FindNumber.h"
#include<vector>
#include<cmath>
using std::abs;
using namespace std;
FindNumber::FindNumber() { }
FindNumber::FindNumber(Mat img) {
colorfulImg = img;
LoadDeal();
盲猜缩小范围();
//Myimwrite("分割用原图", roughlyNumImg);
UseKmeans();
GetEachColor();
FindRowPeak();
FindRow();
CutRow();
//找数字();
//Myimwrite("粗略卡号图像 ", 粗略的卡号图像);
////Myimwrite("卡号Kmeans图像 ", kmeansImg);
//Myimwrite("卡号形态学梯度图像 ", kmeansErodeImg);
//for (int i = 0; i < eachColorP.size(); i++) {
// Myimwrite("第" + to_string(i) + "张图片的原图", eachColorP[i].srcImg);
// Myimwrite("第" + to_string(i) + "张图片的row投影", eachColorP[i].rowPImgWithAverage);
// Myimwrite("第" + to_string(i) + "张图片的col投影", eachColorP[i].colPImgWithAverage);
//}
//vector<Projection> test;
//for (auto i : eachColorP) {
// test.push_back(Projection(i.srcImg(preciseRowRect)));
//}
//for (int i = 0; i < test.size(); i++) {
// Myimwrite("第" + to_string(i) + "张图片的原图", test[i].srcImg);
// //Myimwrite("第" + to_string(i) + "张图片的row投影", test[i].rowPImgWithAverage);
// Myimwrite("第" + to_string(i) + "张图片的col投影", test[i].colPImgWithAverage);
//}
Myimwrite("精确卡号图像", preciseRowImg);
}
void FindNumber::LoadDeal() {
resize(colorfulImg, colorfulImg, NUM_SIZE);//修改图像大小
cvtColor(colorfulImg, grayImg, COLOR_RGB2GRAY);//创建灰度图
//width = colorfulImg.cols;
//height = colorfulImg.rows;
//Myimwrite("标准大小的银行卡", colorfulImg);
}
void FindNumber::UseKmeans() {
const int MAX_CLUSTERS = 5;
Mat data, labels;
BCmodify(roughlyNumImg, kmeansImg, 1.27, 0);
medianBlur(kmeansImg, kmeansImg, 3);
for (int i = 0; i < kmeansImg.rows; i++)
for (int j = 0; j < kmeansImg.cols; j++) {
Vec3b point = kmeansImg.at<Vec3b>(i, j);
Mat tmp = (Mat_<float>(1, 3) << point[0], point[1], point[2]);
data.push_back(tmp);
}
//根据浏览图片,确定k=3
kmeans(data, 4, labels, TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 10, 1.0),
1, KMEANS_PP_CENTERS);
int n = 0;
//显示聚类结果,不同的类别用不同的颜色显示
for (int i = 0; i < kmeansImg.rows; i++)
for (int j = 0; j < kmeansImg.cols; j++) {
int clusterIdx = labels.at<int>(n);
kmeansImg.at<Vec3b>(i, j) = kmeansColorTab[clusterIdx];
n++;
}
morphologyEx(kmeansImg, kmeansErodeImg, MORPH_GRADIENT,
getStructuringElement(MORPH_RECT, Size(3, 3)));//原来是4,4
}
void FindNumber::盲猜缩小范围() {
int y1 = colorfulImg.rows * 0.4;
int y2 = colorfulImg.rows * 0.7;
roughlyNumRect = Rect(0, y1, colorfulImg.cols, y2 - y1);
roughlyNumImg = Mat(colorfulImg, roughlyNumRect).clone();
//Myimwrite("粗略的卡号位置", 粗略的卡号图像);
}
void FindNumber::找数字() {
struct NumY {
int weight;
int y;
int height;
int area;
};
int minArea = 10000;
vector<NumY> EachY;
}
Mat FindNumber::UseSobel(Mat srcImg, int xy) {
#pragma region Sobel算子使用方法
/*
1-2:输入输出Mat
3:输出图像深度,应该是CV_16S,取CV_8U
4:dx,x方向上的差分阶数
5:dy,y方向上的差分阶数
6:ksize,Sobel内核的大小,必须取1,3,5,7,
7:scale,默认取 1
8:可选的delta值,默认取 0
9:borderType,边界模式,默认取BORDER_DEFAULT
*/
//在经过处理后,需要用convertScaleAbs()函数将其转回原来的uint8形式,否则将无法显示图像,而只是一副灰色的窗口
#pragma endregion
Mat sobel_x, sobel_y;
Mat sobelAbsX;
Mat sobelAbsY;
Mat sobelAbsXY;
switch (xy) {
case(0):
Sobel(srcImg, sobel_x, CV_16S, 0, 1);
convertScaleAbs(sobel_x, sobelAbsX);
threshold(sobelAbsX, sobelAbsX, 80, 255, THRESH_BINARY);
return sobelAbsX;
case(1):
Sobel(srcImg, sobel_y, CV_16S, 1, 0);
convertScaleAbs(sobel_y, sobelAbsY);
threshold(sobelAbsY, sobelAbsY, 80, 255, THRESH_BINARY);
return sobelAbsY;
case(2):
Sobel(srcImg, sobel_x, CV_16S, 0, 1);
convertScaleAbs(sobel_x, sobelAbsX);
Sobel(srcImg, sobel_y, CV_16S, 1, 0);
convertScaleAbs(sobel_y, sobelAbsY);
addWeighted(sobelAbsX, 0.5, sobelAbsY, 0.5, 0, sobelAbsXY);
threshold(sobelAbsXY, sobelAbsXY, 80, 255, THRESH_BINARY);
return sobelAbsXY;
default:
cout << "xy Wrong!" << endl;
return Mat();
}
//Myimwrite("sobelAbsX ", sobelAbsX);
//Myimwrite("sobelAbsY ", sobelAbsY);
//Myimwrite("sobelAbsXY ", sobelAbsXY);
}
void FindNumber::GetEachColor() {
//初始化
Mat EachColor[8];
for (int i = 0; i < 8; i++)
EachColor[i] = Mat(kmeansErodeImg.size(), CV_8UC3, Scalar(0, 0, 0));
//进行筛选
int colorStat[8] = { 0 };
for(int row = 0; row<kmeansErodeImg.cols; row++)
for (int col = 0; col < kmeansErodeImg.rows; col++) {
int choose = 0;
while (kmeansErodeImg.at<Vec3b>(col, row) != gradientColorTab[choose]
&& choose < 8)choose++;
if (choose > 7) {
cout << "Choose Color Wrong! " << endl;
continue;
}
else {
EachColor[choose].at<Vec3b>(col, row) = gradientColorTab[choose];
colorStat[choose]++;
}
}
for (int i = 1; i < 8; i++) {
cvtColor(EachColor[i], EachColor[i], COLOR_RGB2GRAY);
//排除微小干扰
morphologyEx(EachColor[i], EachColor[i], MORPH_GRADIENT,
getStructuringElement(MORPH_RECT, Size(3, 3)));
if (colorStat[i] > COLORSTAT_MIN) {
threshold(EachColor[i], EachColor[i], 30, 255, THRESH_BINARY);
auto temp = Projection(EachColor[i]);
if (temp.statAll > COLORSTAT_MIN) {
eachColorP.push_back(temp);
}
}
}
}
FindNumber::~FindNumber() {
}
void FindNumber::FindRowPeak() {
for (auto i : eachColorP) {
vector<pt> rowPeakTemp = i.rowTanPeak(20, 3, 4);//5,3,15
rowPeak.push_back(rowPeakTemp);
}
}
void FindNumber::FindRow() {
int fuzzyValue = 2;
vector<Rect> foundRects;
Rect realRect = Rect(0, 0, 1, 1);
for (int PNo = 0; PNo < eachColorP.size(); PNo++) {
auto pr = eachColorP[PNo];
//Myimwrite("原始投影", pr.rowPImgWithAverage);
auto tempRects = UseFindContours(pr.rowProjectionImg
(Rect(0, 0, pr.width - pr.rowStatAverage + 3, pr.height)));
//Myimwrite("原图 ", pr.srcImg);
for (auto i : tempRects) {
//double weight = 0.2 * pr.height / 2 - abs((i.y + i.height) / 2 - pr.height / 2);
if (i.height >= 10 && i.height <= 30
&& i.area() > realRect.area()){
realRect = i;
}
}
}
y1 = realRect.y - 4;
y2 = realRect.y + realRect.height + 8;
if (y1 < 0)y1 = 0;
if (y2 > roughlyNumImg.rows)y2 = roughlyNumImg.rows - 1;
}
vector<Rect> FindNumber::UseFindContours(Mat srcImg) {
Mat img = srcImg.clone();
Mat test;
//消除细尖的影
morphologyEx(img, test, MORPH_DILATE,
getStructuringElement(MORPH_RECT, Size(5,5)));
//Myimwrite("效果图", test);
bitwise_not(img, img);
vector<vector<Point>> contours = vector<vector<Point>>();//定义轮廓
vector<Vec4i> hierarchy = vector<Vec4i>();//定义层次结构
findContours(img, contours, hierarchy, RETR_CCOMP, CHAIN_APPROX_SIMPLE);// 寻找轮廓
cvtColor(img, img, COLOR_GRAY2RGB);//如果需要可视化绘制轮廓则需要RGB
Scalar color(255, 255, 255);
vector<Rect> rects;//定义轮廓框
if(contours.size()!=0)
for (int index = 0; index >= 0; index = hierarchy[index][0]) {//遍历轮廓
//drawContours(img, contours, index, color, FILLED, 8, hierarchy);
Rect tempRect = boundingRect(contours[index]);
if (tempRect.height >= 10 && tempRect.area() > 100) {//检测外轮廓
rectangle(img, tempRect, Scalar(0, 0, 255), 3);//对所有轮廓加矩形框
rects.push_back(tempRect);
}
}
//Myimwrite("轮廓图 ", img);
return rects;
}
void FindNumber::CutRow() {
preciseRowRect = Rect(0, y1, roughlyNumImg.cols, y2 - y1);
preciseRowImg = roughlyNumImg(preciseRowRect).clone();
}
| [
"songmiao39@foxmail.com"
] | songmiao39@foxmail.com |
53dc549d5b11489a156a83ff4669716f1b62f419 | 53758d03b112554ce9afbae9ea4f85acf9f5bb64 | /2_Arrays/20_sortByFrequency.cpp | fd6b1a27ece53957516d8c7e53c59671f936b278 | [] | no_license | skalva404/geeksCoding | 47f3795cce9bbaa761b89a97667ed9231a3a783e | 58ae1d4a1b65bf849456209295fa0e696b51ed8c | refs/heads/master | 2020-04-26T17:25:14.069994 | 2015-06-22T06:39:59 | 2015-06-22T06:39:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,278 | cpp | //given an arraym sort its elements by frequency
//using map
//O(n*n) time
//O(n) space
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<map>
using namespace std;
int max(map<int,int>m1)
{
int ans=0;
map<int,int>::iterator i;
for(i=m1.begin();i!=m1.end();i++)
{
if((*i).second > ans)
ans=(*i).second;
}
return ans;
}
void sortByFreq(int a[], int n)
{
map<int, int> m1;
map<int, int>::iterator i;
int j;
for(j=0;j<n;j++)
{
i=m1.find(a[j]);
if(i==m1.end()) //insert into map
{
m1.insert(pair<int,int>(a[j],1));
}
else //increment frequency
{
(*i).second++;
}
}
int maxValue,k;
//map has elements and frequencies
while(m1.size()!=0) //until map is not empty
{
maxValue=max(m1); //max value in the map
for(j=0;j<n;j++) //iterate over the array nd chec if the element is in map nd has the maxValue frequency
{
i=m1.find(a[j]);
if(i!=m1.end() && (*i).second==maxValue)
{
for(k=0;k<maxValue;k++) //print the element maxValue times nd delete it from map
printf("%d ",(*i).first);
m1.erase(i);
}
}
}
printf("\n");
}
int main()
{
int n;
scanf("%d",&n);
int a[n];
int i;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("array sorted by freq: \n");
sortByFreq(a,n);
return 0;
}
| [
"subash.k3110@outlook.com"
] | subash.k3110@outlook.com |
249745249aa70c40e8dcc47c5b9d7586e99dedf6 | 037c6452dfdcbfb0ee4be18375df0b9af7ef3b27 | /gm/LogRun.cc | 948219b06fbafee14dfb143e040bac4bd1b1bd0b | [
"MIT"
] | permissive | granolamatt/SoundProcessor | f9d622cfd602dee83514fbad1256036dc9212f33 | 6c903a20b2da268e054d5e9189d746e36ac38ce1 | refs/heads/master | 2020-12-02T08:44:44.530249 | 2019-12-30T16:43:26 | 2019-12-30T16:43:26 | 230,947,771 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 230 | cc | #include <unistd.h>
#include <iostream>
#include "gm/Thread.h"
#include "gm/process/LogProcessor.h"
int main() {
gm::process::LogProcessor processor;
processor.start();
while(true) {
usleep(1000000);
}
return 0;
}
| [
"granolamatt@gmail.com"
] | granolamatt@gmail.com |
74f60514df0478d7d214694985dd062c99d0147d | 6f37f529bae8bbcc99244468477f14e9f96ff95c | /wxWidgets-2.8.12/src/dfb/brush.cpp | 36580b0334a81e96fabff80a8c807dc358e49a0e | [] | no_license | darknebuli/darknebuli-RM-graph | 13326ddbc9a210605926f7ad4b70672a48b1b2f2 | bf169c01f787fdd144e19fae6732a5b58fdbdafd | refs/heads/master | 2020-05-16T23:40:56.853727 | 2012-04-30T22:14:24 | 2012-04-30T22:14:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,530 | cpp | U2FsdGVkX19fTms3OENxUoetnOKy1AyJ49jWWmkNc76HrZzistQMiePY1lppDXO+
h62c4rLUDInj2NZaaQ1zvoetnOKy1AyJ49jWWmkNc758g4KpHaB8LwCS1iqVEAa/
3WR6GO//whonn01yC3Yog8R8Xp7o2Aqgbul8yQ+ft9U5JnIbhY1XjjZVcrW9yvoS
J4dfZ0Vh6A82eDiFOcZWDgr8wlHiUzrj+YvipANm3C7030KA9dv2IqL0qByHB4Ai
Q0QMkIOpZzWb18c6ywgH/LADYY9ZmC7Fph37OdlNBKvWcv84n9fMjixYQU0lMhIH
lclCCOHnHF66vB5dJuVvPBAL49raxPwuZGBz9ntBP2HQd5hc7okT2g6pTFswHcUB
McJN7lUlvCByGtYG4LChEl+K8Vp/fuy/nPfLiUANKdknxN1JPj0muHMw37BjdmV+
iGMvW3XCztFzyKO4zdJ0QW/JWG/PRUqGnjkvZS7VaszuGGdChovlJvzp/k62TZaW
h62c4rLUDInj2NZaaQ1zvoetnOKy1AyJ49jWWmkNc76HrZzistQMiePY1lppDXO+
h62c4rLUDInj2NZaaQ1zvhYH9es8OdGVuc/FN8Z8fOB5SMlAclJTkR4dSh7XR0IX
dZLLQ5liQYKM+0tIsHPOaYD+9dWuA+Ou/AgzsYhP3sCtvlH2IhYm11FR6HVk2a9+
o1ymgRrAl4b9wZpJ7TwqyXSnPI+JO9eNmDTZyVMQoGesV7jpuJcu7g4zvwmmg5BV
7yM8nNdL8vPfPzo6cke4RbCH1Y722zuHf012ctT+Hvdzczx1PCsGqNMNlj4V3GQZ
wD382L/wp/cTWboGESiriEx0Qcvt937k8vtpDfwS2iFGG36V6PtNaidZsT1yF3u+
JH1ExAUESuGPuZWTQI0rPyR9RMQFBErhj7mVk0CNKz8kfUTEBQRK4Y+5lZNAjSs/
JH1ExAUESuGPuZWTQI0rP+9B1rZ8/3CnaD6Q8krGIPO2GPDD/xteOIOFcZIJFqKp
JH1ExAUESuGPuZWTQI0rPyR9RMQFBErhj7mVk0CNKz8kfUTEBQRK4Y+5lZNAjSs/
JH1ExAUESuGPuZWTQI0rP0bxI1yGT4LVQgN5Ubr06it3+YDUSFZlY2VV2Mw8VMPI
HSwWN6Z2xK3KIDUtpmk9Lz1k0yEiGIqHb8l6dNm5VhyrbeIXXNFgw0Y7Rp8xDoLy
1kqoSD5aqtdd0q6DJ8FSToFv2unv69fgFOrb2g/BI9471F9wNae1/zbc3Ew4U3uM
megT7io8W/fv3I4AQ26V8jYBRSlAGHdsFKW262KsxPOQt4RsD1s6yw4nQ/NdTP32
TJKOQNcQMGRKdja2X8co9mBpBSmgbkr7QwGffVjXsIU2P5CPTjSvy7XLw2QzKkd+
YqYKjZzC1N6k4A3NAbLO3ue+VfJHC79b0UCWoVJID9VcX0WjO0nftSp2QZWzsLrq
YAhJYtekjKgsGwgCqeDD+FBj1X9AhbP+6szK+iE6RHWGYuGWiadXhCMUPFOnDcJ3
5cjIbLsqN0Ca9IdUJ0Jp2UH/dxUUhTG4vw9aG47ZTnpWbTntcI1ssBgM2ssztHkt
AnPsGpbfLh2j6WQqV/kF+8HfjQ0FTdnlLQeGzRqU5d+oe1p1wg1BWBodyzRHhLaJ
eJzPlikRkvit4IeVw4oMO4JLhe2bltaGzkXpLbXAQKzDudUtRRzg+JFJdK21xvCB
FqIOdCa+3OjjS2dCCBejNdKhEqfVq4vdCN8y3Wsp+luzIPpQQoVlSyhu2SfnuxZ/
Hbh90XzMmutQl+8WlIz0kyJ+pUNSRCfLCvghl2edCeOvtQC7FgfcfudFwo6BGD5g
fySEjtS6LFYRZfYvHhMdFca/xpCGDmzF4D1dArYpEKCi4lwkFHVC9fFcpoBP8P6a
Qpt/X496Kbu7af+gcPtEj2tt/b25PacZP6uraJ4Bc8YssDbp/7jc2SIhqAuUXuOC
JH1ExAUESuGPuZWTQI0rPyR9RMQFBErhj7mVk0CNKz8kfUTEBQRK4Y+5lZNAjSs/
JH1ExAUESuGPuZWTQI0rP4sjyWjyUjUAQ25fO5dQUpUSqPmCMbo+V0wrr5EtBIyl
IR0F4YduIwrG6UfCnWAC6L4jsCq0E/ubHF5kkGK1Mpm4h6E0Y9Q01ayoMQwOnH3j
72BftDAkQqAyEUToEmqJ+PNXBf9G+gG26lVFrKssSfDYPQnVaoiwbsCA009ouk5Q
cY4C8lKoJV00MJ8GrwapqB2YxqBTQdZe69df69IxCEyix4AvrH3TQqfIuftylicZ
rVY6otOGb6AURO+MaKi6Eug7MmH9sb1Z69/yiObld1SLzAOS/ZkNyTT21bh32jly
3NyWC34d8LKRG8w6HweXpTy0kbXxTKswDsWsd7NaKZfiLHH5tF2WcpuavKG9AgLu
2T8tMen5erjcm5yOzIkDq1gfkOilZyGYwNeaRIXg1ffhfJK7h+IdgUnO4j857gO6
BootgsGS2fZbJ2z4qSxFzDgly3SJnjcs4s0DF4eSd7IHNcf10yxjJEHDINhrL7fl
q23nrJ9Zz9tvvoDkwo5f63m0B5fdYtajT6X+O3MZONZVAmHVbAuJ+4dHRvaWwRFd
l/q+t0QkEtE4RYDEjyiXKFSkwNRSQbU9lgJC8f6s26bmktJoXu2vwr2EDpzzAiDw
Wck1Dxa2fet32RsbvCpFv8Zha9PCgORW2CkPW9UdbIRHV4sDkU2AjQnmWzkptwDB
Uey4Gm6MOl6mvTrJPUnXjjPkAXLdmfbkVk6CW9xjok4QYTWI4s4AY71SurPW2qKI
SZr9iWWSDWKg0LK3BbpgtEUWS6qyPgrW/vEmTHDclFx2kyXf5JBl6RlweatrbNhl
H5kpFYsNYalE5Y+Qu669c5wiKuWlDfwNuy80Ii+3UWbIE4zLmc0+MRMjSlZBpBPn
QOoviVFIeAPx0aZ+6rxCkcpn3nq073lry6ssSgSqig4RY1AGtiSRpQcJp5yg6Bt7
r0j79yghjVsOVGH+zDN0yVlZkElo2jgxfYBS+LUdSeY1qMtzwniKtl4BP9ib3es/
vx8Hw2/SUGI2P4kOKhrXiQYviN+4q6FMa0MtvWeXtfRTNxKjgT2CRbOLH5HkSgbk
MXHdHMGr9l19u8YiJ1ixUpmYV38R3BXOW59EmHB1ysyf4U3tbIs01iZj6s+35h9x
PjADHQaFk/PSYkJirSNBQkB6OEXf5CAc5tr+YyzSRfpAFhlbfxsMZLXTeMMaO6+0
39DZ1wNNRwe1TQZkc+SLDukmos0A7IcGj8gjWSDiByqn0TqBu+lkENWXQB2ZzPTb
hxcaLxS4VzC2x2CeCVkBWriBFUFRVcrZi2sLy5pk3cb20OOWxrjiTz6pcuYNNRZo
bOgZQzM+xjKyHgqFxnH5AVpzILVAGG67lghTN56W0AEEozBtzkG4+BWpMAWatCYL
T35KxW8GmU8PEmRbuAKHEgIi0L61cGHOfEgwCHPBK26L8f9Fp8elmqVc9lpAaHRv
dq2BuvVCpZUtzjDg8u6OoV/Tb4sBTwPH2Mx06tK6a4kNAJajIICc+GIZhe8NJof5
ZCMyWuw1aPV7WBhJC26MeePS++l6Nbxt4jmQ+ny25Ql5VX+pA+Mirupt8BQGEDlH
fuv1Zl+AlZIg8wehUPjF7Cxuk/auXWS6M0R2LEWy2dWvUjnlZBpq27JVUrx7dO4t
HucobpwsZ+9B++xdY1xAfy1fPuaUmwI/TrOYXd5ICwC3nxtkv3e83Wrpe+gqbxZg
HnG+rYsZkD5VULWxa9SbooxFq44CKPJeGfvleHRl0KQKDOI/jlULvs5XkkYvQ09k
5YDsta0GZEpBORiOxKcA8xzqlvGhxIFPDjde2zHTZnevUR6qsTuiStNmBHK31zZB
AKaJ5niRMDfV3/VaZE5zzgWXWlsZaxTMLvZQwZwQ8StvxKM680+ZUugRaxohAVvS
vP8/oVQMcovnOMctyY2/i/C/sckBoXTusnVytpAk0/aPOeMwCUA3xVIbHyTRhVr0
UrfHoelNwVD3oTkUGvOSQtOc9M1OUDS10ZO32/FC1fOaEzhfLkZf3Tpvsi2ObbRR
VLgzp6cHLZ5SamvYd3gxPxf7LsLOsIK4HzSteK/YzKK8+1hXh+pila0OzEFNVH7u
orGKwKOrUO+YIl2sdj/Dc56MtQJ1nEQwKawy3C6x+mMUObipOGiDhdpAFrtbtiUq
2GLVlZeEtfx78pG/ywf1cA8Dq9psjGbvCBMzb+mjNhZc9A6j9/4gIglrnwsLMU+o
PgD9oXvtedZ4LPfZ6jdSawaPrjktZ2FjFqbzZLRlB3HaMnB1J+O5t4cgHVqRl8yi
PAHfzeQFj96/yhMnGve/23edAXzXuaeuKJ/9cgnh5aatVjqi04ZvoBRE74xoqLoS
HKFabBdMxWQg/ZvD+iDVSP+KVYewVyIiVZokcbc/UYA=
| [
"charles@rhizometric.com"
] | charles@rhizometric.com |
0b36d5f1d1e38c8445236fe39a67522e7fa4d647 | 9cb42d00153b1154a6efd915ab3fb731167c5894 | /zonecommand.h | 2c709edb5256281bd32f0320a4fdc215fac9a25a | [] | no_license | corra72/mudeditor | 45f9bfeb8b80e20cc00e5f1d694973d0cc27a701 | 7cca359cc1b8c32ad678d0dd5717e629011919fc | refs/heads/master | 2020-05-20T04:07:28.076528 | 2019-06-17T10:18:04 | 2019-06-17T10:18:04 | 185,375,884 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,665 | h |
#ifndef TS_ZONECOMMAND_H
#define TS_ZONECOMMAND_H
#include <QString>
#include <QTextStream>
#include <stdio.h>
#include "types.h"
namespace ts
{
class ZoneCommand
{
public:
enum Argument { Argument0 = 0, Argument1, Argument2, Argument3, Argument4,
LastArgument };
void initArguments();
void init();
void validate();
ZoneCommand();
ZoneCommand( const ZoneCommand& );
virtual ~ZoneCommand();
virtual ZoneCommand& operator=( const ZoneCommand& );
// Useful only in DoorInits
virtual bool operator<( const ZoneCommand& zc ) const { return priority() < zc.priority(); }
virtual bool operator>( const ZoneCommand& zc ) const { return priority() > zc.priority(); }
QChar type() const { return m_type; }
long argument( Argument arg ) const { return mp_args[ arg ]; }
bool hasArgument( Argument arg ) const { return mp_args[ arg ] >= 0; }
VNumber id() const { return m_id; }
QString comment() const { return m_comment; }
QString commentSeparator() const { return m_commentSeparator; }
void setType( QChar new_type ) { m_type = new_type.toUpper(); initArguments(); }
void setArgument( Argument arg, long new_value ) { mp_args[ arg ] = new_value; }
void setId( VNumber new_value ) { m_id = new_value; }
void setComment( const QString& txt ) { m_comment = txt.simplified(); }
void setCommentSeparator( const QString& sep ) { m_commentSeparator = sep.trimmed(); }
bool isMobLoad() const { return m_type == 'M'; }
bool isMobFollower() const { return m_type == 'C'; }
bool isMobFear() const { return m_type == 'F'; }
bool isMobHate() const { return m_type == 'H'; }
bool isMobEquip() const { return m_type == 'E'; }
bool isMobGive() const { return m_type == 'G'; }
bool isItemLoad() const { return m_type == 'O'; }
bool isItemPut() const { return m_type == 'P'; }
bool isDoorInit() const { return m_type == 'D'; }
bool isOnlyComment() const { return m_type == '*' || m_type == ';'; }
bool isZoneEnd() const { return m_type == 'S'; }
bool isValidType() const { return isMobLoad() || isMobFollower() ||
isMobFear() || isMobHate() || isItemPut() || isMobEquip() ||
isMobGive() || isItemLoad() || isDoorInit() ||
isOnlyComment(); }
bool isMobCommand() const { return isMobLoad() || isMobFollower() ||
isMobFear() || isMobHate() || isMobEquip() || isMobGive(); }
bool isItemCommand() const { return isItemPut() || isItemLoad(); }
bool isEmptyCommand() const { return isOnlyComment() && m_comment.trimmed().isEmpty(); }
bool hasParent() const { return isMobFear() || isMobHate() || isItemPut() ||
isMobEquip() || isMobGive(); }
bool hasMaxField() const { return isMobLoad() || isMobFollower() || isItemPut() ||
isMobEquip() || isMobGive() || isItemLoad(); }
bool hasMobField() const { return isMobLoad() || isMobFollower(); }
bool hasItemField() const { return isItemPut() || isMobEquip() || isMobGive() ||
isItemLoad(); }
QString dumpObject() const;
void load( FILE* );
void save( QTextStream& ) const;
void loadComment( const QString& );
QString toString( bool append_comment ) const;
int priority() const;
protected:
QChar m_type;
long mp_args[ LastArgument ];
int m_numArgs;
VNumber m_id;
QString m_comment;
QString m_commentSeparator;
};
} // namespace ts
#endif // TS_ZONECOMMAND_H
| [
"corra@Corra.lan"
] | corra@Corra.lan |
01260b1d18524ffe970b43848262af1b9a765828 | 5f2cf3da47b5cb6102540b1f7917ab7f0db9b308 | /AI_TicTacToe/AI.cpp | 446d560c5d028ea12913fb46c46656632fa42f1a | [] | no_license | AntonVeselskyi/AI_TicTacToe | a4e3fb73f3161d9fbed25cb36c67ede240cf91e7 | be7d03a9e1755ac2c1950fa8ad1bf78e0248cc11 | refs/heads/master | 2022-12-14T02:36:43.955098 | 2020-09-13T07:32:46 | 2020-09-13T07:32:46 | 110,130,649 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,436 | cpp | #include "AI.h"
using namespace AI_TicTacToe;
bool AI_Helper::IsCellInbound(int x, int y)
{
if ((x <= 2) && (x >= 0) && (y <= 2) && (y >= 0))
{
return true;
}
return false;
}
AI::AI(Field &field) : _field(field){}
bool AI::TryToPutMark(int x, int y)
{
//if cell inbound and == 0, we can mark it
if (AI_Helper::IsCellInbound(x,y) && _field[x][y] == 0)
{
_field[x][y] = AI_MARK;
_last_mark_x = x;
_last_mark_y = y;
return true;
}
return false;
}
bool AI::TryToWin()
{
for (int i = 0; i < FIELD_SIDE; ++i)
{
for (int j = 0; j < FIELD_SIDE; ++j)
{
if (_field[i][j] == AI_MARK)
{
//here we check all cells (around)near current
//(cell_near_x == 0 && cell_near_y == 0) -->it`s current cell
for (int cell_near_x = -1; cell_near_x <= 1; ++cell_near_x)
for (int cell_near_y = -1; cell_near_y <= 1; ++cell_near_y)
{
if (!cell_near_x && !cell_near_y) //if it`s current cell
continue;
//here we specify the position of sell near [i][j] cell
int second_cell_x = i + cell_near_x;
int second_cell_y = j + cell_near_y;
//next I check is cell I`m looking at out of bounds
if (AI_Helper::IsCellInbound(second_cell_x, second_cell_y))
{
if (_field[second_cell_x][second_cell_y] == AI_MARK)
{
//if it`s true, we have to
//check next cell in a row after them
//first we find a offset
int offset_x = second_cell_x - i;
int offset_y = second_cell_y - j;
if (AI_Helper::IsCellInbound(second_cell_x + offset_x, second_cell_y + offset_y) &&
TryToPutMark(second_cell_x + offset_x, second_cell_y + offset_y))
{
return true;
}
}
else if (_field[second_cell_x][second_cell_y] != PLAYER_MARK)
{
//if the cell near current exist,
//but it`s empty and not filled by player,
//there can be situation like this:
//first we have to find an offset
int offset_x = second_cell_x - i;
int offset_y = second_cell_y - j;
if (AI_Helper::IsCellInbound(second_cell_x + offset_x, second_cell_y + offset_y) &&
_field[second_cell_x + offset_x][second_cell_y + offset_y] == AI_MARK)
{
//if we have |x||_||x| situation
TryToPutMark(second_cell_x, second_cell_y);
return true;
}
}
}
}
}
}
}
return false;
}
bool AI::TryToObstructOpponent()
{
for (int i = 0; i < FIELD_SIDE; ++i)
{
for (int j = 0; j < FIELD_SIDE; ++j)
if (_field[i][j] == PLAYER_MARK)
{
//here we check all cells (around)near current
for (int cell_near_x = -1; cell_near_x <= 1; ++cell_near_x)
for (int cell_near_y = -1; cell_near_y <= 1; ++cell_near_y)
{
if (!cell_near_x && !cell_near_y) //if it`s current cell
continue;
//here we specify the position of sell near [i][j] cell
int second_cell_x = i + cell_near_x;
int second_cell_y = j + cell_near_y;
//next I check is cell I`m looking at out of bounds
if (AI_Helper::IsCellInbound(second_cell_x, second_cell_y))
if (_field[second_cell_x][second_cell_y] == PLAYER_MARK)
{
//if it`s true, we have too
//check next cell in a row after them
//first we find a offset vector
int offset_x = second_cell_x - i;
int offset_y = second_cell_y - j;
//check is cell after second_cell is free, if free --> put our mark there
//possible future opponent game winning mark
if (AI_Helper::IsCellInbound(second_cell_x + offset_x, second_cell_y + offset_y) &&
TryToPutMark(second_cell_x + offset_x, second_cell_y + offset_y))
return true;
}
else if (_field[second_cell_x][second_cell_y] != AI_MARK)
{
//if the cell near current exist,
//but it`s empty and not filled by AI,
//there can be situation like this:
//first we find a offset vector
int offset_x = second_cell_x - i;
int offset_y = second_cell_y - j;
//possible future opponent game winning mark
if (AI_Helper::IsCellInbound(second_cell_x + offset_x, second_cell_y + offset_y) &&
_field[second_cell_x + offset_x][second_cell_y + offset_y] == PLAYER_MARK)
{
TryToPutMark(second_cell_x, second_cell_y);
return true;
}
}
}
}
}
return false;
}
| [
"anton.veselskyi@gmail.com"
] | anton.veselskyi@gmail.com |
27924ed49cfb11a4c79be69808fd515977ae90ba | 30f8f1d9beb54bb449f4c7458bfd6f4c1f39226e | /linklist/cc_impl/test_linked_list.cc | e87061aa1fa607cbeb3a9fbcd48d3b11407ae41b | [] | no_license | kakukosaku/DSA | d3ab695764ad8afb6e60c35354eb27b3d074e358 | 9d8eef6f0bebf9d797f2d284e53789ee3f835f82 | refs/heads/master | 2023-08-24T14:55:26.359798 | 2021-09-25T01:41:16 | 2021-09-25T01:41:16 | 103,033,043 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 551 | cc | //
// Created by kaku on 2019/10/21.
//
#include "linked_list.h"
#include <iostream>
using namespace std;
int main() {
ElemType arr[] = {1, 2, 3, 4, 5};
LinkedList l = head_insert_linked_list(arr, 5);
show_linked_list(l);
l = tail_insert_linked_list(arr, 5);
show_linked_list(l);
LNode *n = get_elem(l, 3);
show_node(n);
LNode *n1 = new LNode {9, nullptr};
insert_elem(l, n1, 3);
show_linked_list(l);
delete_elem(l, 3);
show_linked_list(l);
reverse_linked_list(l);
show_linked_list(l);
} | [
"scugjs@gmail.com"
] | scugjs@gmail.com |
0a1df21b911e68d6d7a3992324689bc3d4e40e56 | 93396398ced93f13f65909edc35ef6ed660bf891 | /examples/toy/Ch2/toyc.cpp | 984676452fb41a5a19a20e94a5a829e251838900 | [
"Apache-2.0"
] | permissive | cesarriat/mlir | 0affb769fe1ed16f6f9ae23312dd086e1682c4e1 | 78caf457ce48e04f7767fbae240bd93db541e18d | refs/heads/master | 2020-05-09T11:28:09.545193 | 2019-04-16T00:18:32 | 2019-04-16T00:18:32 | 181,080,954 | 0 | 0 | Apache-2.0 | 2019-04-12T20:43:57 | 2019-04-12T20:43:57 | null | UTF-8 | C++ | false | false | 4,420 | cpp | //===- toyc.cpp - The Toy Compiler ----------------------------------------===//
//
// Copyright 2019 The MLIR Authors.
//
// 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.
// =============================================================================
//
// This file implements the entry point for the Toy compiler.
//
//===----------------------------------------------------------------------===//
#include "toy/MLIRGen.h"
#include "toy/Parser.h"
#include <memory>
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Module.h"
#include "mlir/Parser.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
using namespace toy;
namespace cl = llvm::cl;
static cl::opt<std::string> inputFilename(cl::Positional,
cl::desc("<input toy file>"),
cl::init("-"),
cl::value_desc("filename"));
namespace {
enum InputType { Toy, MLIR };
}
static cl::opt<enum InputType> inputType(
"x", cl::init(Toy), cl::desc("Decided the kind of output desired"),
cl::values(clEnumValN(Toy, "toy", "load the input file as a Toy source.")),
cl::values(clEnumValN(MLIR, "mlir",
"load the input file as an MLIR file")));
namespace {
enum Action { None, DumpAST, DumpMLIR };
}
static cl::opt<enum Action> emitAction(
"emit", cl::desc("Select the kind of output desired"),
cl::values(clEnumValN(DumpAST, "ast", "output the AST dump")),
cl::values(clEnumValN(DumpMLIR, "mlir", "output the MLIR dump")));
/// Returns a Toy AST resulting from parsing the file or a nullptr on error.
std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileOrErr =
llvm::MemoryBuffer::getFileOrSTDIN(filename);
if (std::error_code EC = FileOrErr.getError()) {
llvm::errs() << "Could not open input file: " << EC.message() << "\n";
return nullptr;
}
auto buffer = FileOrErr.get()->getBuffer();
LexerBuffer lexer(buffer.begin(), buffer.end(), filename);
Parser parser(lexer);
return parser.ParseModule();
}
int dumpMLIR() {
mlir::MLIRContext context;
std::unique_ptr<mlir::Module> module;
if (inputType == InputType::MLIR ||
llvm::StringRef(inputFilename).endswith(".mlir")) {
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> fileOrErr =
llvm::MemoryBuffer::getFileOrSTDIN(inputFilename);
if (std::error_code EC = fileOrErr.getError()) {
llvm::errs() << "Could not open input file: " << EC.message() << "\n";
return -1;
}
llvm::SourceMgr sourceMgr;
sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), llvm::SMLoc());
module.reset(mlir::parseSourceFile(sourceMgr, &context));
if (!module) {
llvm::errs() << "Error can't load file " << inputFilename << "\n";
return 3;
}
if (failed(module->verify())) {
llvm::errs() << "Error verifying MLIR module\n";
return 4;
}
} else {
auto moduleAST = parseInputFile(inputFilename);
module = mlirGen(context, *moduleAST);
}
if (!module)
return 1;
module->dump();
return 0;
}
int dumpAST() {
if (inputType == InputType::MLIR) {
llvm::errs() << "Can't dump a Toy AST when the input is MLIR\n";
return 5;
}
auto moduleAST = parseInputFile(inputFilename);
if (!moduleAST)
return 1;
dump(*moduleAST);
return 0;
}
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, "toy compiler\n");
switch (emitAction) {
case Action::DumpAST:
return dumpAST();
case Action::DumpMLIR:
return dumpMLIR();
default:
llvm::errs() << "No action specified (parsing only?), use -emit=<action>\n";
}
return 0;
}
| [
"joker.eph@gmail.com"
] | joker.eph@gmail.com |
ddcaa226eef15b1328ceede290808a65c32660fd | d465a2b37454648afcddf761ec8fdd2b393569e4 | /src/Scene.cpp | 258300799a35c8a1181425c5060a9da4c3b3438e | [] | no_license | doyin2986/naijagame_opengl_cpp | 093e5ef70319357f6a6fef800ed1d51e2f872ecb | eb6774368dc88ca96b8fc78ad0ce55e63f42b91d | refs/heads/master | 2021-06-20T06:50:54.872684 | 2017-07-25T13:09:05 | 2017-07-25T13:09:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 25,196 | cpp | /** Naijagame
* Created by Olusegun Ojewale 20-03-2017.
*
**/
#include "Scene.h"
#include "GameEngine.h"
#include <iostream>
#include <time.h>
#include <fstream>
// constructor sets window width and height
// I will make window size fixed so as not to worry about impact of resising on game display
char file_name [] = "user.kw";
char *_file = file_name;
void getPositionMatrix (int positions[], int size_ , const GLfloat source_ [], GLfloat dest_ []) ;
// array stores cards postions on the board
// there are possible positions 0-8 ( i.e 1-9)
// start position is 0,1,2 - 6,7,8
int pos [] = {0,1,2,6,7,8};
// OpenGL Shaders
const GLchar* gl_Position = "#version 330 core\n"
"layout (location = 0) in vec3 position;\n"
"void main()\n"
"{\n"
"gl_Position = vec4(position.x, position.y, position.z, 1.0);\n"
"}\0";
const GLchar* lineColor = {"#version 330 core\n"
"out vec4 color;\n"
"void main()\n"
"{\n"
"color = vec4(1.0f, 0.5f, 0.2f, 1.0f);\n"
"}\n\0",
};
const GLchar* yellowshade = "#version 330 core\n"
"out vec4 color;\n"
"void main()\n"
"{\n"
"color = vec4(1.0f, 1.0f, 0.0f, 1.0f); // The color yellow \n"
"}\n\0";
const GLchar* fgreenShade = "#version 330 core\n"
"out vec4 color;\n"
"void main()\n"
"{\n"
"color = vec4(0.0f, 1.0f, 0.0f, 1.0f); // The color green \n"
"}\n\0";
const GLchar* fwinshade = "#version 330 core\n"
"out vec4 color;\n"
"void main()\n"
"{\n"
"color = vec4(1.0f, 0.0f, 1.0f, 0.0f); // The color \n"
"}\n\0";
double xloc, yloc; // stores mouse x,y locations
// markers for moving cards from a source to a destination. The two values must be greater than -1 before a move can happen
int destinationPosition = -1;
int sourcePosition = -1;
// matrix for possible 9 points on the board
GLfloat cardsMatrix[] = {
// top left 1
-0.8f, 0.8f, 0.0f,
-0.8f, 0.6f, 0.0f,
-0.6f, 0.6f, 0.0f,
-0.8f, 0.8f, 0.0f,
-0.6f, 0.8f, 0.0f,
-0.6f, 0.6f, 0.0f,
// top middle 2
-0.1f, 0.8f, 0.0f,
0.1f, 0.8f, 0.0f,
0.1f, 0.6f, 0.0f,
-0.1f, 0.8f, 0.0f,
-0.1f, 0.6f, 0.0f,
0.1f, 0.6f, 0.0f,
// top right 3
0.8f, 0.8f, 0.0f,
0.6f, 0.8f, 0.0f,
0.6f, 0.6f, 0.0f,
0.8f, 0.8f, 0.0f,
0.8f, 0.6f, 0.0f,
0.6f, 0.6f, 0.0f,
// mddile left 4
-0.8f, 0.1f, 0.0f,
-0.6f, 0.1f, 0.0f,
-0.6f, -0.1f, 0.0f,
-0.8f, 0.1f, 0.0f,
-0.8f, -0.1f, 0.0f,
-0.6f, -0.1f, 0.0f,
// middle 5
-0.1f, 0.1f, 0.0f,
0.1f, 0.1f, 0.0f,
0.1f, -0.1f, 0.0f,
-0.1f, 0.1f, 0.0f,
-0.1f, -0.1f, 0.0f,
0.1f, -0.1f, 0.0f,
// middle right 6
0.8f, 0.1f, 0.0f,
0.6f, 0.1f, 0.0f,
0.6f, -0.1f, 0.0f,
0.8f, 0.1f, 0.0f,
0.8f, -0.1f, 0.0f,
0.6f, -0.1f, 0.0f,
// bottom left 7
-0.8f, -0.8f, 0.0f,
-0.8f, -0.6f, 0.0f,
-0.6f, -0.6f, 0.0f,
-0.8f, -0.8f, 0.0f,
-0.6f, -0.8f, 0.0f,
-0.6f, -0.6f, 0.0f,
// middle bottom 8
-0.1f, -0.8f, 0.0f,
0.1f, -0.8f, 0.0f,
0.1f, -0.6f, 0.0f,
-0.1f, -0.8f, 0.0f,
-0.1f, -0.6f, 0.0f,
0.1f, -0.6f, 0.0f,
// bottom right 9
0.8f, -0.6f, 0.0f,
0.6f, -0.6f, 0.0f,
0.6f, -0.8f, 0.0f,
0.8f, -0.6f, 0.0f,
0.8f, -0.8f, 0.0f,
0.6f, -0.8f, 0.0f,
};
GLfloat scoreMatrix [] = {
// bottom score counter
// first
-0.08f, -0.93f, 0.0f,
-0.06f, -0.9f, 0.0f,
-0.04f, -0.93f, 0.0f,
// second
0.00f, -0.93f, 0.0f,
0.02f, -0.9f, 0.0f,
0.04f, -0.93f, 0.0f,
// third
0.08f, -0.93f, 0.0f,
0.10f, -0.9f, 0.0f,
0.12f, -0.93f, 0.0f,
// top score counter
-0.08f, 0.9f, 0.0f,
-0.06f, 0.93f, 0.0f,
-0.04f, 0.9f, 0.0f,
// second
0.00f, 0.9f, 0.0f,
0.02f, 0.93f, 0.0f,
0.04f, 0.9f, 0.0f,
// third
0.08f, 0.9f, 0.0f,
0.10f, 0.93f, 0.0f,
0.12f, 0.9f, 0.0f,
};
GLfloat indicatorMatrix [] = {
0.90, 0.00f, 0.0f,
0.96f,0.06f, 0.0f,
0.96f, -0.06f, 0.0f,
};
GLfloat boardMatrix[] = {
// diagonal 1 left to right
-0.7f, -0.7f, 0.0f,
0.7f, 0.7f, 0.0f,
// diagonal 2 right to left
-0.7f, 0.7f, 0.0f,
0.7f, -0.7f, 0.0f,
// middle horizontal line
0.7f, 0.0f, 0.0f,
-0.7f,-0.0f, 0.0f,
// vertical middle line
0.0f, 0.7f, 0.0f,
0.0f, -0.7f, 0.0f,
// veritcal left line
-0.7f, 0.7f, 0.0f,
-0.7f, -0.7f, 0.0f,
// horizontal top line
-0.7f, 0.7f, 0.0f,
0.7f, 0.7f, 0.0f,
// veritcal right line
0.7f, -0.7f, 0.0f,
0.7f, 0.7f, 0.0f,
// horizontal bottom line
-0.7f, -0.7f, 0.0f,
0.7f, -0.7f, 0.0f,
};
GLfloat cardsPositions [6*18]; // this is used to manage how cards are rendered. It uses 6 spots from possible 9 postions
bool UPDATE_NOW = false;
bool IN_PLAY = true; //flag to control game interraction
int awinner = 0; // variable to decide of there is a winner . 0 for no winner, 1 if player 1 wins and 2 if its player 2
// shaders
enum { LINE_POSITION, PLAYER1_POSITION, PLAYER2_POSITION, WIN_POSITION, TOGGLE_SHADER };
GLuint gameShaders [5];//Program, gameShaders [PLAYER1_POSITION], gameShaders [PLAYER2_POSITION],gameShaders [WIN_POSITION], gameShaders [TOGGLE_SHADER];
GLuint fragmentsShaders [4];
// couple sof functions definition
/**
*getPositionMatrix is used to
*/
void getPositionMatrix (int positions[], int size_ , const GLfloat source_ [], GLfloat dest_ []) ;
/**
*areamatch function check if mouse x,y location is an 'action' point
* for instance, is there a card in the location? Is location a 'vertex' etc?
*/
int areamatch (double xaxis, double yaxis );
/**
*Update card position. Card has moved from postion A to B. There are 9 possible postions, numbered 0..8
**/
void update (int positions[] , int a, int b);
int getArrayIndexForAvalue (const int _array [], int _value );
/**
*areYouOnYourCard function is to ensure Player 1cannot move layerr 2 cards.
*/
bool areYouOnYourCard (int player, int _position);
/**
*Flowmanager controls game flow..
* */
void flowmanager ( double x, double y);
// sleepcp is platform independent way of implementing a 'sleep'
void sleepcp(int milliseconds);
void initiateAImove ();
// initalise Game
GameEngine game;
Scene::Scene (int WindowWidth, int WindowHeigth, char * title) {
this -> wWidth = WindowWidth;
this -> wHeight = WindowHeigth;
this -> title = title;
}
// perform Opengl intialization functions here
//
GLFWwindow* Scene::initWindow(const int resX, const int resY, const char * title) {
// Init GLFW
glfwInit();
// Set all the required options for GLFW
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
// Create a GLFWwindow object that we can use for GLFW's functions
GLFWwindow* window = glfwCreateWindow(resX, resY, title, nullptr, nullptr);
glfwMakeContextCurrent(window);
// Set the required callback functions
glfwSetKeyCallback(window, key_callback);
glfwSetMouseButtonCallback(window, mouse_callback);
// Set this to true so GLEW knows to use a modern approach to retrieving function pointers and extensions
glewExperimental = GL_TRUE;
// Initialize GLEW to setup the OpenGL Function pointers
glewInit();
// Define the viewport dimensions
int width, height;
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
return window;
}
void Scene::init () {
// Build and compile our shader program
// // Vertex shader
this -> appWindow = initWindow (wWidth, wHeight, title);
GLuint fragment_Gl_Position = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(fragment_Gl_Position, 1, &gl_Position, NULL);
glCompileShader(fragment_Gl_Position);
// Check for compile time errors
GLint success;
GLchar infoLog[512];
glGetShaderiv(fragment_Gl_Position, GL_COMPILE_STATUS, &success);
fragmentsShaders [LINE_POSITION] = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentsShaders [LINE_POSITION], 1, &lineColor, NULL);
glCompileShader(fragmentsShaders [LINE_POSITION]);
// Check for compile time errors
glGetShaderiv(fragmentsShaders [LINE_POSITION], GL_COMPILE_STATUS, &success);
// Fragment2 shader
fragmentsShaders [PLAYER1_POSITION] = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentsShaders [PLAYER1_POSITION], 1, &fgreenShade, NULL);
glCompileShader(fragmentsShaders [PLAYER1_POSITION]);
// Check for compile time errors
glGetShaderiv(fragmentsShaders [PLAYER1_POSITION], GL_COMPILE_STATUS, &success);
// Fragment2 shader
fragmentsShaders [PLAYER2_POSITION] = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentsShaders [PLAYER2_POSITION], 1, &yellowshade, NULL);
glCompileShader(fragmentsShaders [PLAYER2_POSITION]);
// Check for compile time errors
glGetShaderiv(fragmentsShaders [PLAYER2_POSITION], GL_COMPILE_STATUS, &success);
// win shader
fragmentsShaders [WIN_POSITION] = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentsShaders [WIN_POSITION], 1, &fwinshade, NULL);
glCompileShader(fragmentsShaders [WIN_POSITION]);
// Check for compile time errors
glGetShaderiv(fragmentsShaders [WIN_POSITION], GL_COMPILE_STATUS, &success);
// Link shaders
gameShaders [LINE_POSITION] = glCreateProgram();
glAttachShader(gameShaders [LINE_POSITION], fragment_Gl_Position);
glAttachShader(gameShaders [LINE_POSITION], fragmentsShaders [LINE_POSITION]);
glLinkProgram(gameShaders [LINE_POSITION]);
gameShaders [PLAYER1_POSITION] = glCreateProgram();
glAttachShader(gameShaders [PLAYER1_POSITION], fragment_Gl_Position);
glAttachShader(gameShaders [PLAYER1_POSITION], fragmentsShaders [PLAYER1_POSITION]);
glLinkProgram(gameShaders [PLAYER1_POSITION]);
gameShaders [PLAYER2_POSITION] = glCreateProgram();
glAttachShader(gameShaders [PLAYER2_POSITION], fragment_Gl_Position);
glAttachShader(gameShaders [PLAYER2_POSITION], fragmentsShaders [PLAYER2_POSITION]);
glLinkProgram(gameShaders [PLAYER2_POSITION]);
gameShaders [WIN_POSITION] = glCreateProgram();
glAttachShader(gameShaders [WIN_POSITION], fragment_Gl_Position);
glAttachShader(gameShaders [WIN_POSITION], fragmentsShaders [WIN_POSITION]);
glLinkProgram(gameShaders [WIN_POSITION]);
glDeleteShader(fragment_Gl_Position);
glDeleteShader(fragmentsShaders [LINE_POSITION]);
glDeleteShader(fragmentsShaders [PLAYER1_POSITION]);
glDeleteShader(fragmentsShaders [PLAYER2_POSITION]);
glDeleteShader(fragmentsShaders [WIN_POSITION]);
return;
}
void Scene::aWin(int i) {
IN_PLAY = false;
}
void Scene::start() {
int workcounter = 0; // this is used to animate a win
const int INDICATOR_INDEX = 3; // used as VBO VAO index value for 'indicator' arrow- who's playing next
GLuint VBO[4], VAO[4];
const int POINTS = 16;
//pointer to store score count...
int * playscore;
glGenVertexArrays(4, VAO);
glGenBuffers(4, VBO);
// Bind the Vertex Array Object first, then bind and set vertex buffer(s) and attribute pointer(s).
glBindVertexArray(VAO [LINE_POSITION]);
getPositionMatrix (pos, 2 , cardsMatrix, cardsPositions);
glBindBuffer(GL_ARRAY_BUFFER, VBO[0]);
glBufferData(GL_ARRAY_BUFFER, sizeof(boardMatrix), boardMatrix, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); // Note that this is allowed, the call to glVertexAttribPointer registered VBO as the currently bound vertex buffer object so afterwards we can safely unbind
glBindVertexArray(0); // Unbind VAO (it's always a good thing to unbind any buffer/array to prevent strange bugs)
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // wireframes only
// triangle
glBindVertexArray(VAO [PLAYER1_POSITION]);
glBindBuffer(GL_ARRAY_BUFFER, VBO[1]);
glBufferData(GL_ARRAY_BUFFER,6*72, cardsPositions, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); // Note that this is allowed, the call to glVertexAttribPointer registered VBO as the currently bound vertex buffer object so afterwards we can safely unbind
glBindVertexArray(1); // Unbind VAO (it's always a good thing to unbind any buffer/array to prevent strange bugs)
// score
glBindVertexArray(VAO [PLAYER2_POSITION]);
glBindBuffer(GL_ARRAY_BUFFER, VBO[2]);
glBufferData(GL_ARRAY_BUFFER, sizeof(scoreMatrix), scoreMatrix, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); // Note that this is allowed, the call to glVertexAttribPointer registered VBO as the currently bound vertex buffer object so afterwards we can safely unbind
glBindVertexArray(2); // Unbind VAO (it's always a good thing to unbind any buffer/array to prevent strange bugs)
// indicator
glBindVertexArray(VAO[3]);
glBindBuffer(GL_ARRAY_BUFFER, VBO[3]);
glBufferData(GL_ARRAY_BUFFER, sizeof(indicatorMatrix), indicatorMatrix, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); // Note that this is allowed, the call to glVertexAttribPointer registered VBO as the currently bound vertex buffer object so afterwards we can safely unbind
glBindVertexArray(2); // Unbind VAO (it's always a good thing to unbind any buffer/array to prevent strange bugs)
// Game loop
gameShaders [TOGGLE_SHADER] = gameShaders [PLAYER2_POSITION];
while (!glfwWindowShouldClose(appWindow))
{
// Check if any events have been activiated (key pressed, mouse moved etc.) and call corresponding response functions
workcounter ++;
if ( workcounter > 2) workcounter = 0; // reset
//if (IN_PLAY) glfwPollEvents(); // only allow user event when play is on
glfwPollEvents(); // capture user events ... mouse move, keypress etc
if (IN_PLAY || UPDATE_NOW) {
UPDATE_NOW = false;
getPositionMatrix (pos, 2 , cardsMatrix, cardsPositions);
glBindVertexArray(VAO [PLAYER1_POSITION]);
glBindBuffer(GL_ARRAY_BUFFER, VBO[1]);
glBufferData(GL_ARRAY_BUFFER,6*72, cardsPositions, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); // Note that this is allowed, the call to glVertexAttribPointer registered VBO as the currently bound vertex buffer object so afterwards we can safely unbind
glBindVertexArray(0); // Unbind VAO (it's always a good thing to unbind any buffer/array to prevent strange bugs)
// check if its a win
awinner = game.aWin (pos);
if (awinner > 0 ) IN_PLAY = false;// if a win , suspend play
}
// if there is a winner then animate
// sleep for 1 second and flash color change
if (!IN_PLAY ) {
sleepcp(500);
if (workcounter == 1) {
if (awinner == 1) gameShaders [TOGGLE_SHADER] = gameShaders [PLAYER2_POSITION];
if (awinner == 2) gameShaders [TOGGLE_SHADER] = gameShaders [PLAYER1_POSITION];
}
else
gameShaders [TOGGLE_SHADER] = gameShaders [WIN_POSITION];
}
// get play scores...
game.getscores (playscore);
// Render
// Clear the colorbuffer
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// Draw lines
glUseProgram(gameShaders [LINE_POSITION]);
glBindVertexArray(VAO [LINE_POSITION]);
glDrawArrays( GL_LINES, 0, POINTS);
glBindVertexArray(0);
//draw 3 playing caards
// flash color change if there is a win
if (awinner == 2)
glUseProgram(gameShaders [TOGGLE_SHADER]);
else
glUseProgram(gameShaders [PLAYER1_POSITION]);
glBindVertexArray(VAO [PLAYER1_POSITION]);
glDrawArrays( GL_TRIANGLES, 18, 6*3);
glBindVertexArray(0);
// show score for player A
glBindVertexArray(VAO [PLAYER2_POSITION]);
glDrawArrays( GL_TRIANGLES, 0, 3* playscore [0]);
glBindVertexArray(2);
// flash color change if there is a win
if (awinner == 1)
glUseProgram(gameShaders [TOGGLE_SHADER]);
else
glUseProgram(gameShaders [PLAYER2_POSITION]);
glBindVertexArray(VAO [PLAYER1_POSITION]);
glDrawArrays( GL_TRIANGLES, 0, 6*3);
glBindVertexArray(0);
// show score for player B
glBindVertexArray(VAO [PLAYER2_POSITION]);
glDrawArrays( GL_TRIANGLES, 9, 3* playscore [1]);
glBindVertexArray(2);
if (IN_PLAY ) { // only show indicator arrow when game is in play
if (game.whoson() == 1)
glUseProgram(gameShaders [PLAYER2_POSITION]);
else
glUseProgram(gameShaders [PLAYER1_POSITION]);
glBindVertexArray(VAO[INDICATOR_INDEX]);
glDrawArrays( GL_TRIANGLES, 0, 3);
glBindVertexArray(3);
}
// Swap the screen buffers
glfwSwapBuffers(appWindow);
// check if auto AI is enabled and if computer can play
if (IN_PLAY) initiateAImove();
}
// clean up
glDeleteVertexArrays(4, VAO);
glDeleteBuffers(4, VBO);
}
// Is called whenever a key is pressed/released via GLFW
void Scene::mouse_callback(GLFWwindow* window, int button, int action, int mode)
{
if (!IN_PLAY) return;
glfwGetCursorPos(window, &xloc, &yloc); // get clicked x,y location
if (button == 0 && action == 0) { // respond to only single,left click
flowmanager (xloc,yloc);
// sleepcp(3000);
flowmanager (xloc,yloc);
}
}
// called whenever a key is pressed/released via GLFW
void Scene::key_callback(GLFWwindow* window, int key, int scancode, int action, int mode)
{
//std::cout << key << std::endl;
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);
if (!IN_PLAY) {
// a win detected.. reset game on key presss
game.reset();
// reset card postions too
//correct
pos [0] = 0;
pos [1] = 1;
pos [2] = 2;
pos [3] = 6;
pos [4] = 7;
pos [5] = 8;
IN_PLAY = true; // set flag to enable game start/continuation
}
}
void getPositionMatrix (int positions[], int size_ , const GLfloat source_ [], GLfloat rtn_ []) {
int m = 0;
for (int i = 0; i < 6 ; ++ i) {
int j = positions [i];
for (int k = ( j * 18); k < ( j * 18) + 18; ++k ) {
rtn_ [m++] = source_ [k];
}
}
return ;
}
void update (int positions[] , int a, int b) {
for (int i =0 ; i < 6; ++i )
{
if (positions [i] == a) {
positions [i] = b;
return;
}
}
}
int areamatch (double xaxis, double yaxis ) {
//std::cout << "area match is on" <<std::endl;
if ((xaxis < 300 ) && ( xaxis > 100) && (yaxis < 190) && ( yaxis > 50))
return 1;
if ((xaxis < 300 ) && ( xaxis > 100) && (yaxis < 450) && ( yaxis > 350))
return 4;
if ((xaxis < 800 ) && ( xaxis > 600) && (yaxis < 190) && ( yaxis > 50))
return 2;
if ((xaxis < 800 ) && ( xaxis > 600) && (yaxis < 450) && ( yaxis > 350))
return 5;
if ((xaxis < 1300 ) && ( xaxis > 1100) && (yaxis < 190) && ( yaxis > 50))
return 3;
if ((xaxis < 1300 ) && ( xaxis > 1100) && (yaxis < 450) && ( yaxis > 350))
return 6;
if ((xaxis < 300 ) && ( xaxis > 100) && (yaxis < 700) && ( yaxis > 600))
return 7;
if ((xaxis < 800 ) && ( xaxis > 600) && (yaxis < 700) && ( yaxis > 600))
return 8;
if ((xaxis < 1300 ) && ( xaxis > 1100) && (yaxis < 700) && ( yaxis > 600))
return 9;
return 0;
}
int getArrayIndexForAvalue (const int _array [], int _value ) {
for (int i = 0; i < 6; ++i) {
if (_array [i] == _value ) {
return i;
}
}
}
bool areYouOnYourCard (int player , int _position) {
if ((player == 1) && (getArrayIndexForAvalue ( pos, _position) < 3 )) {
return true;
}
if ((player == 0) && (getArrayIndexForAvalue ( pos, _position) > 2 )) {
return true;
}
return false;
}
void flowmanager (double xloc, double yloc) {
int allocation = areamatch ( xloc, yloc) -1 ;
bool A_LOC_SET = false;
//std::cout << "who is playing??..." << game.isCurrentPlayerHuman();
if (allocation > -1 && game.isCurrentPlayerHuman ()) {
int pos_copy [9];
for (int i =0 ; i < 6; ++i )
{
if (pos [i] == allocation) {
sourcePosition = allocation;
A_LOC_SET = true;
}
pos_copy [i] = pos [i];
}
if (!(A_LOC_SET) && sourcePosition > -1)
destinationPosition = allocation;
if (( sourcePosition > -1) && (destinationPosition > -1) &&
(game.validatemove(sourcePosition + 1, destinationPosition + 1 )) && (areYouOnYourCard (game.whoson(),sourcePosition) ))
{
//std::cout << "settting now!! " << std::endl;
update (pos, sourcePosition,destinationPosition);
destinationPosition = -1;
sourcePosition = -1;
UPDATE_NOW = true;
// add updated user move
pos_copy [6] = pos [3];
pos_copy [7] = pos [4];
pos_copy [8] = pos [5];
// capture move to storage
game.capturemove ( _file,pos_copy);
game.nextPlay();
}
}
//std::cout << "ALOC: " <<sourcePosition << " BLOC: "<< destinationPosition<< " allocation " << allocation<< std::endl;
}
//void Scene::initiateAImove () {
void initiateAImove () {
if (! game.isCurrentPlayerHuman ()) {
// is computer is playing
game.compute_AI_NextMove(1,pos);
sleepcp(3000);// wait for 3 seconds before rendering play
UPDATE_NOW = true; // set update flag
game.nextPlay();
}
}
void sleepcp(int milliseconds) // cross-platform sleep function
{
clock_t time_end;
time_end = clock() + milliseconds * CLOCKS_PER_SEC/1000;
while (clock() < time_end)
{
// do nothing
}
}
| [
"Ojewale.Olusegun@ynap.com"
] | Ojewale.Olusegun@ynap.com |
fedd032c32e5506128da8c9e86ba8eb0d2ab1a79 | aa2d8763cc80d4f28033d3f6048b6fbc103cf786 | /c_implementation/main.cpp | 4fe653a381a07878e54fb0a0c873a6d27200d03c | [] | no_license | nitin12384/RectSimulator | 35f5e0e2769147dac894fff3b2c37ce4a2cb5e76 | f0d1b4fef14a8aae7c4d32ffe8ea2ea1660ff9a9 | refs/heads/master | 2022-08-31T10:05:14.864513 | 2022-08-28T08:28:04 | 2022-08-28T08:28:04 | 232,733,073 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,039 | cpp | //#include "source.cpp"
#include <stdio.h>
#include <graphics.h>
#include <math.h>
// MACRO and STRUCTURES
#define ABS(x) ((x>0)?(x):(-x))
#define DEF_COLOR GREEN
#define MAXX 800
#define MAXY 600
#define DIFF 50 // boundary difference
#define TIME_F 0.02 // in second
#define ANGV_MULT 0.027560
#define ANGV_MULT_I 36.284470
#define DEG2RAD 0.0174532925
#define RAD2DEG 57.2957795
typedef struct vectStruct
{
float x;
float y;
}vector;
typedef struct rectStruct
{
vector p[4] ;
vector linV;
vector linA;
float angV; // rad per second
float angA;
float mass;
vector com;
}rect;
//Funtion Declarations
void drawRect(vector[],int) ;
rect initRect(vector[]);
void updateLinear(rect*) ;
void updateAngular(rect*) ;
void printfInfo(rect*) ;
bool updateIfCollision(rect*) ;
bool isStraight(rect*) ;
void rotateRect(rect*,float); // inpute angle in radian
void stabalizeRect(rect*);
float distBtwPoints(vector, vector);
//Function Deinations
void drawRect(vector pt[], int color = DEF_COLOR )
{
setcolor(color);
setfillstyle(SOLID_FILL, color);
//vectors array
int vectors[8] ;
int i;
for(i=0; i<8; i+=2)
{
vectors[i] = (int)(pt[i/2].x) ;
vectors[i+1] = (int)(pt[i/2].y) ;
}
fillpoly(4,vectors);
}
rect initRect(vector pt[])
{
rect abcd;
for(int i=0; i<4; i++)
{
abcd.p[i].x = pt[i].x ;
abcd.p[i].y = pt[i].y ;
abcd.com.x += pt[i].x*0.25 ;
abcd.com.y += pt[i].y*0.25 ;
}
abcd.angA = abcd.angV = 0;
abcd.linA.x = 0.0;
abcd.linA.y = 0.0;
abcd.linV.x = 0.0;
abcd.linV.y = 0.0;
abcd.mass = 1.0;
return abcd;
}
void updateLinear(rect *abcd)
{
float disp;
for(int i=0; i<4; i++)
{
disp = (*abcd).linV.x*TIME_F + (*abcd).linA.x*(TIME_F*TIME_F*0.5) ; // calc displacement in 20 msec s = ut + 1/2(at^2)
(*abcd).linV.x += (*abcd).linA.x*TIME_F ; // change linear velocity wrt current acceleration every 20 sec
(*abcd).p[i].x += disp;
(*abcd).com.x += disp*0.25 ; // update centre of mass also
disp = (*abcd).linV.y*TIME_F + (*abcd).linA.y*(TIME_F*TIME_F*0.5) ;
(*abcd).linV.y += (*abcd).linA.y*TIME_F ;
(*abcd).p[i].y += disp;
(*abcd).com.y += disp*0.25 ;
}
}
void updateAngular(rect *abcd)
{
float theta = (*abcd).angV*TIME_F + (*abcd).angA*(TIME_F*TIME_F*0.5) ; // calc angular disp theta = (omega)dt + 0.5(alpha)dt^2 (in radians)
(*abcd).angV += (*abcd).angA*TIME_F ;
//printf("theta is %f degree \n", theta*RAD2DEG);
rotateRect(abcd,theta);
}
void rotateRect(rect* abcd,float theta)
{
double cosT = cos((double)theta);
double sinT = sin((double)theta);
float tempX,tempY;
for(int i=0; i<4; i++)
{
tempX = (*abcd).p[i].x ;
tempY = (*abcd).p[i].y ;
(*abcd).p[i].x = (*abcd).com.x*(1-cosT) + (*abcd).com.y*sinT + tempX*cosT - tempY*sinT ; //updating coordinates
(*abcd).p[i].y = (*abcd).com.y*(1-cosT) - (*abcd).com.x*sinT + tempY*cosT + tempX*sinT ;
}
//updating com
(*abcd).com.x = 0.0;
(*abcd).com.y = 0.0;
for(int i=0; i<4; i++)
{
(*abcd).com.x += (*abcd).p[i].x*0.25 ;
(*abcd).com.y += (*abcd).p[i].y*0.25 ;
}
}
void printfInfo(rect *abcd)
{
for(int i=0; i<4; i++)
{
printf("%c - (%.0f,%.0f) ",65+i,(*abcd).p[i].x,(*abcd).p[i].y) ;
}
printf("\n");
printf("Parameter-----------X-axis--------------Y-axis-------------- \n");
printf("%-20s%-20.1f%-20.1f \n","Linear Velocity",(*abcd).linV.x,(*abcd).linV.y);
printf("%-20s%-20.1f%-20.1f \n","Linear Acceleration",(*abcd).linA.x,(*abcd).linA.y);
printf("%-20s%-20.1f%-20.1f \n","Center of Mass",(*abcd).com.x,(*abcd).com.y);
printf("Angular velocity is %.1f(deg/sec) Angular acceleration is %.1f \n",(*abcd).angV*ANGV_MULT_I,(*abcd).angA*ANGV_MULT_I);
printf("\n");
}
bool updateIfCollision(rect* abcd)
{
bool isColliding=true;
// Fake Collisions
if((*abcd).com.x > 1500 )
(*abcd).linV.x = -390;
if((*abcd).com.y > 900)
(*abcd).linV.y = -290;
if((*abcd).com.x < 50)
(*abcd).linV.x = 390;
if((*abcd).com.y < 50)
(*abcd).linV.y = 290;
// find minX - l ,maxX - j ,minY- k ,maxY - i for rectangle
int i, j, k, l;
int maxY,maxX,minY,minX;
i = j = k = l = 0;
maxY = minY = (*abcd).p[0].y ;
maxX = minX = (*abcd).p[0].x ;
for(int a=0; a<4; a++)
{
// for maxX
if(maxX < (int)(*abcd).p[a].x )
{
maxX = (int)(*abcd).p[a].x ;
j = a;
}
// for maxY
if(maxY < (int)(*abcd).p[a].y )
{
maxY = (int)(*abcd).p[a].y ;
i = a;
}
// for minX
if(minX > (int)(*abcd).p[a].x )
{
minX = (int)(*abcd).p[a].x ;
l = a;
}
// for minY
if(minY < (int)(*abcd).p[a].y )
{
minY = (int)(*abcd).p[a].y ;
k = a;
}
}
//printf("maxX is %d and its coords (%d,%d)\n",(int)(*abcd).p[j].x , (int)(*abcd).p[j].x ,(int)(*abcd).p[j].y );
//setcolor(WHITE) ;
//setfillstyle(SOLID_FILL, WHITE);
//fillellipse( (int)(*abcd).p[j].x , (int)(*abcd).p[j].y , 5 ,5 ) ;
// Collision with walls
bool colWall[4] = {0,0,0,0} ;
if(minY < 2*DIFF)
{
if(minX < DIFF)
{
//case i-i
colWall[2] = colWall[3] = 1;
}
else if(maxX > MAXX - DIFF)
{
//case i-iii
colWall[2] = colWall[1] = 1;
}
else
{
//case i-ii
colWall[2] = 1;
}
}
else if(maxY > MAXY - DIFF)
{
if(minX < DIFF)
{
//case iii-i
colWall[0] = colWall[3] = 1;
}
else if(maxX > MAXX - DIFF)
{
//case iii-iii
colWall[0] = colWall[1] = 1;
}
else
{
//case iii-ii
colWall[0] = 1;
//if((*abcd).linV.y <= 0)
//isCollidong =
}
}
else
{
if(minX < DIFF)
{
//case ii-i
colWall[3] = 1;
}
else if(maxX > MAXX - DIFF)
{
//case ii-iii
colWall[1] = 1;
}
else
{
//case ii-ii
//no collision
}
}
isColliding = colWall[0] || colWall[1] || colWall[2] || colWall[3] ;
//straight collisions
if( isStraight(abcd) && colWall[0])
(*abcd).linV.y = -ABS((*abcd).linV.y) ;
if( isStraight(abcd) && colWall[1])
(*abcd).linV.x = -ABS((*abcd).linV.x) ;
if( isStraight(abcd) && colWall[2])
(*abcd).linV.y = ABS((*abcd).linV.y) ;
if( isStraight(abcd) && colWall[3])
(*abcd).linV.x = ABS((*abcd).linV.x) ;
//oblique collisions
if(!isStraight )
{
float l,b,tempW;
l = distBtwPoints((*abcd).p[i] , (*abcd).p[j] ) ; // lenght
b = distBtwPoints((*abcd).p[j] , (*abcd).p[k] ) ; // breadth
if(colWall[0])
{
float tempY = (*abcd).linV.y ;
float k0 = (*abcd).p[j].x - (*abcd).p[i].x + (b/l)*( (*abcd).p[j].y - (*abcd).p[i].y ) ;
(*abcd).linV.y = ( (6*k0*k0)-(2*l*l) - 2 );
}
}
return isColliding;
}
bool isStraight(rect* abcd)
{
return ( ((int)(*abcd).p[0].x == (int)(*abcd).p[1].x ) || ((int)(*abcd).p[0].y == (int)(*abcd).p[1].y) ) ;
}
void stabalizeRect(rect* abcd)
{
}
float distBtwPoints(vector a, vector b)
{
float res;
res = sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) );
return res ;
}
int main()
{
vector pt[4] = { {60.0,60.0} ,{200.0,60.0} , {200.0,500.0} , {60.0,500.0} };
rect abcd = initRect(pt); //initialised
abcd.linV.x = 250.0; // pixel per sencond
abcd.linV.y = 440.0;
abcd.linA.x = 0 ;
abcd.linA.y = 0 ; // gravity 9.8 pixel per second square
abcd.angV = 90*DEG2RAD; // 90 degree per second
abcd.angA = -10*DEG2RAD;
rotateRect(&abcd,90*DEG2RAD);
// printf("%f ",abcd.p[2].x) ;
initwindow(MAXX,MAXY);
drawRect(abcd.p,BLUE);
//main animation
int cont = 1;
int straightCount = 1;
int colCount = 0;
// why problem came on declaring char msg[100]***********?????????????????????????????????????**********************
bool isColliding = 0; // 1 if collision is happening 0 if not
int frames = 0;
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar(DIFF,MAXY-DIFF,MAXX-DIFF,MAXY);
bar(0,0,MAXX,DIFF);
while(cont)
{
frames++; //Counting no of frames passed
delay(TIME_F*1000);
// printf("Time passed %.2fsec\n",frames*0.02);
// sprintf(msg,"Time passed %.2fseconds",frames*0.02);
// settextstyle(DEFAULT_FONT, HORIZ_DIR,2);
// outtextxy(1100,20,"msg");
drawRect(abcd.p,BLACK); // erasing cureent rectangle
// updating coordintaes
updateLinear(&abcd);
updateAngular(&abcd);
straightCount += isStraight(&abcd) ;
isColliding = updateIfCollision(&abcd) ;
if (isColliding)
{
colCount++;
printf("Collision with wall *************************** \n");
//setfillstyle(SOLID_FILL, RED);
//fillellipse( 500,500, 100,100 );
}
if(frames%10==0)
printfInfo(&abcd); // printing info on console screen
//printf("straight for %d time \n",straightCount);
printf("collision for %d time \n",colCount);
drawRect(abcd.p,BLUE); // draw new rectangle
}
getch() ;
return 0;
}
| [
"nknitinkumar12384@gmail.com"
] | nknitinkumar12384@gmail.com |
064db25c34817980050aff542eb1745c47220fad | 547ba0f3bd22a851e5e26ed20bf04eae89299bc6 | /Cezar/Cezar/Header.h | baedfb4c701d852b17bf065bcce1846741e0229f | [] | no_license | emikoNauroka/Kryptografia | cccd31a938b015f766959ce1dfacb4b664d7aeef | f2c046ea0d39678de8988ced9d6ac87443ce0995 | refs/heads/master | 2023-03-19T13:06:36.438770 | 2021-03-18T13:14:56 | 2021-03-18T13:14:56 | 349,079,420 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 225 | h | namespace N
{
class funkcje
{
public:
int szyfrowanie(char szyfr);
int odszyfrowanie(char szyfr);
int krypto_analiza_jaw(char szyfr);
int krypto_analiza_njaw(char szyfr);
};
}
| [
"emillia42nawrocka@gmail.com"
] | emillia42nawrocka@gmail.com |
39409e9f5ae996bd53258c5726b10c8ae38d4f04 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/squid/gumtree/squid_repos_function_2430_squid-3.5.27.cpp | 3968f5dc7072baaa86c5a4b8bb10493d56b009ba | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 236 | cpp | int
httpHeaderParseOffset(const char *start, int64_t * value)
{
errno = 0;
int64_t res = strtoll(start, NULL, 10);
if (!res && EINVAL == errno) /* maybe not portable? */
return 0;
*value = res;
return 1;
} | [
"993273596@qq.com"
] | 993273596@qq.com |
bb9cad104b5bfd74c246f47574217707076b9cc0 | faa79e9f0394e57b37563b2b54e45802d2d72178 | /RayTracer/Source/Public/ConfigParser.h | baa6b4047f653f89d50a4d2361412e13dc8352f1 | [] | no_license | Othereum/RayTracer | 033528626c698d593bcfef5d516bbcb445b02f39 | 38640e06fad2e7458bfee0a25b9b189074f4ba87 | refs/heads/master | 2020-06-01T19:52:35.726595 | 2020-03-21T04:45:27 | 2020-03-21T04:45:27 | 190,907,172 | 7 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 348 | h | #pragma once
#include <string>
#include <unordered_map>
struct FConfig
{
FConfig(const char* ConfigFileName);
std::string ImageFileName;
unsigned Width;
unsigned Height;
unsigned NumAASamples;
unsigned NumThread = std::thread::hardware_concurrency() * 5 / 2;
};
const FConfig& GetConfig()
{
const static FConfig Config;
return Config;
}
| [
"seokjin.dev@gmail.com"
] | seokjin.dev@gmail.com |
951794ecdb8e873536d963ec1de377eaeeb4ab46 | 4019b2a358f605382e76a57f9d4f5d2ecb478be4 | /Base/UnderglowController/UnderglowController.ino | f0170f3664623bff377cceea7469ee3e45aa8720 | [
"MIT"
] | permissive | johnnywycliffe/OUC | 5eec532ffa54701f32f39205c909205073ca13b0 | 0a886ad88aa6968d16d449708af5300ff611f662 | refs/heads/main | 2023-06-09T21:08:29.609799 | 2021-07-05T01:24:30 | 2021-07-05T01:24:30 | 312,163,137 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 31,248 | ino | // UnderglowController.ino
// Copyright (c) 2020 Jeremy Stintzcum, all rights reserved.
// License: MIT
// Description: A controller for underglow/LED strips. Designed to grab infor frm a vehicle
// through ODB-II port, display a preset or custom pattern, or act as additional turn signals
// or brake lights.
//=============================================================================================
// TODO (rough order of priority):
// Non-submenu functionality / options
// - Add in menu for Spare 1 and Spare 2
// - Remove LED type menu items.
// LEDHardware settings adjustment
// LED setters
// LED preset modes
// Brake/Turn signal modes
// Bluetooth
// App (Android)
// Chain between vehicles
/*=============================================================================================
* LED pattern - default (Can be changed in settings)
* 18 32|33 47
* | V |
* # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
* 17 > # # < 48
* # PASSENGER #
* # #
* # LEDs are represented a "#" #
* # #
* # #
* # F 0 is driver corner of car #
* # R R #
* 9 > # O E # < 56
* 8 > # N Numbers are positioned along string A # < 57
* # T R #
* # #
* # Long sides are 30 LEDS long #
* # #
* # #
* # Short sides are 18 LEDS long #
* # #
* 0 > # DRIVER # < 65
* # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
* | ^ |
* 95 81|80 66
*/
//Libraries
#include <EEPROM.h>
#include <CAN.h>
#include <OBD2.h>
#include "SSD1306Spi.h"
#include <FastLED.h>
#include <Button.h>
//Defines
#define EEPROM_SIZE 8 //Adjust based on actual need (Get sizeof settings struct)
#define RETRY_SPEED 1000 //In milliseconds, higher is slower
#define DEADZONELOW 300
#define DEADZONEHIGH 3896
#define MAX_BRIGHTNESS 200
//Input
#define UP 0
#define DOWN 1
#define LEFT 2
#define RIGHT 3
#define SELECT 4
#define BACK 5
//Hardware pins - ESP32 defined
#define SPI_MOSI 23
#define SPI_MISO 19
#define SPI_CLK 18
//Pins - Display
#define DISP_RESET 5
#define DISP_CS 4
#define DISP_DC 2
//Pins - input
#define JOYSTICK_X 32
#define JOYSTICK_Y 33
#define JOYSTICK_BUTTON 21
#define BUTTON_0 22
//Pins - LED outputs
#define LED_FRONT 26
#define LED_REAR 27
#define LED_LEFT 13
#define LED_RIGHT 25
#define LED_SPARE1 15
#define LED_SPARE2 14
//Pins - Input signals
#define LTURNSIGNAL 22
#define RTURNSIGNAL 21
#define BRAKE 16
#define CANH 36
#define CANL 39
//Pins - other
#define RELAY 12
//Globals/enums
//Menu
enum State{
main, settings, gauge1, pattern1, pattern2, pattern3, bluetooth, ledsetting1, ledsetting2,
brakeandturn, brake, turn, color, pickpattern, animation, ledorder
};
int sel = 0; //current selection
bool demo = false; //if true, lets user preview LEDS as they scroll through options
bool screenUpdated = false; //Updates screen if true
//LEDs
enum ColorOrder {
rgb, rbg, grb, gbr, brg, bgr
};
enum SelectedPattern {
narrow, medium, large, wide, halfandhalf, quarters, dots, pacifica, risingflames, twinklefox,
murica, colorpop, splatter, drip, christmas, valentines, shamrock, halloween
};
enum SelectedString {
front, rear, passenger, driver, spare1, spare2
};
bool preset = false; //TODO: move to EERPOM saved settings
//Structs/Classes
// Lighting system struct
typedef struct {
uint8_t offsetPos; //How offset from default position pattern is.
CRGBPalette16 RGBP; //RGB color pallette
uint8_t brightness; //Brightness level of LEDs
uint8_t animSpd; //Animation speed
uint8_t trackedPID; // OBD-II PID Datsa to be read (if relevant)
SelectedPattern sp; //Current pattern used
} LEDPatterns;
// Hardware definition struct
typedef struct {
bool reversed = true; //True for backwards, false for forwards
uint8_t ledCount; //num of LEDs on strip.
int startPos; //First led array val
ColorOrder order; //BRG for test code
} LEDHardware;
// Settings struct for running program.
typedef struct{
//Holds setting data to be written to EEPROM
//ADMIN:
char deviceID[10]; //Custom ID for ease of connection
bool AllowSerial;
//LED hardware
//Light patterns
LEDPatterns curr;
LEDPatterns preset1;
LEDPatterns preset2;
LEDPatterns preset3;
LEDPatterns preset4;
LEDPatterns preset5;
//User settings
bool Bluetooth; //Bluetooth on or off
bool rollingShutoff; //If device should cut power when vehicle in motion
bool blinkersAndBrakes; //Mimics blinkers and brakes when driving
} Settings;
// MenuItem Struc for objects
typedef struct{
char *title; //Title text
char *desc; //Description text
int8_t pid; //For storing PIDs
} MenuItem;
// Menu class
class Menu{
MenuItem itemArr[100];
int8_t len;
char *menuTitle;
State s;
State prev;
public:
Menu(){
len = 0;
}
~Menu(){
delete itemArr;
}
//Set
void setState(State state){
s = state;
}
void resetLen(){
len = 0;
}
void setItem(char *t, char *d, int8_t PID = 0){
itemArr[len].title = t;
itemArr[len].desc = d;
itemArr[len].pid = PID;
len++;
}
void setMenuTitle(char *mt){
menuTitle = mt;
}
void setPrevMenu(State s){
prev = s;
}
//Get
int8_t getLen(){
return len;
}
char* getMenuTitle(){
return menuTitle;
}
char* getTitle(int pos){
return itemArr[pos].title;
}
char* getDesc(int pos){
return itemArr[pos].desc;
}
int8_t getPID(int pos){
return itemArr[pos].pid;
}
State getState(){
return s;
}
State getPrevMenu(){
return prev;
}
};
//Initialization
SSD1306Spi display(DISP_RESET, DISP_DC, DISP_CS);
Settings settingStruct;
Button joyButton(JOYSTICK_BUTTON, PULLUP);
Button button1(BUTTON_0, PULLUP);
CRGB *underglow;
Menu mMenu;
State s;
LEDPatterns active;
SelectedString sLEDString;
LEDHardware frontLH;
LEDHardware rightLH;
LEDHardware rearLH;
LEDHardware leftLH;
LEDHardware spare1LH;
LEDHardware spare2LH;
void setup() {
// Set up each system
EEPROM.begin(EEPROM_SIZE);
// Display
display.init();
display.flipScreenVertically();
display.setContrast(255);
// Controls
joyButton.begin();
button1.begin();
// LEDs
setupLEDs();
// OBD2
/*while(!OBD2.begin()){
//Ask user to check connection to vehicle, pause for a second
delay(RETRY_SPEED);
}*/
//Menu
setupMenu(main);
// load settings
loadSetting();
}
void loop() {
// Bluetooth input
// Menu - Change to only be active when needed
int result = menuSelect(&mMenu, sel);
//Return to main menu
if(result==-1){
sel = 0;
if(s != main){
setupMenu(mMenu.getPrevMenu());
}
}
//Behaviours for menu states
switch(s){
default:
//Do nothing
break;
}
//Refresh rate (Faster allows for more inputs, but thumbstick will scroll rapidly)
delay(150);
}
//Set menu options and prepare for display
void setupMenu(State sel){
mMenu.resetLen();
mMenu.setState(sel);
switch(sel){
default: //If a menu hasn't been implemented or an error occurs, return to main
pError("Not defined, returning to main");
case main: //Default menu
mMenu.setMenuTitle("Main Menu");
mMenu.setPrevMenu(main);
mMenu.setItem("Display","Display current selection");
mMenu.setItem("Gauges","Choose a Gauge");
mMenu.setItem("Animations","Choose an LED Animation");
mMenu.setItem("Settings","Display current settings");
break;
case gauge1: //Top level gauge menu
mMenu.setMenuTitle("");
mMenu.setPrevMenu(main);
mMenu.setItem("","");
break;
case pattern1: //Top level pattern menu
mMenu.setMenuTitle("Pattern selection");
mMenu.setPrevMenu(main);
mMenu.setItem("Custom pattern","Choose colors, pattern and animations");
mMenu.setItem("Preset patterns","A selection of pre-made patterns");
break;
case pattern2: //Custom patterns menu
mMenu.setMenuTitle("Custom patterns");
mMenu.setPrevMenu(pattern1);
mMenu.setItem("Set Pattern","Choose specific pattern to display");
mMenu.setItem("Set Colors","Choose colors for display");
mMenu.setItem("Set Animation","Choose animation to display");
break;
case pickpattern: //Choose a pattern + offset
mMenu.setMenuTitle("Pattern Selection");
mMenu.setPrevMenu(pattern2);
mMenu.setItem("Narrow","1 pixels wide");
mMenu.setItem("Medium","2 pixels wide");
mMenu.setItem("Large","3 pixels wide");
mMenu.setItem("Wide","6 pixels wide");
mMenu.setItem("Half-n-Half","2 colors");
mMenu.setItem("Quarters","4 colors");
mMenu.setItem("Dots","Includes trail");
break;
case color: //Pick a method of choosing color (Next level down, include fade or no fade options)
mMenu.setMenuTitle("Color selection");
//TODO: Set prev menus from calling menu
mMenu.setItem("Standard colors","A list of common colors");
mMenu.setItem("Pallete","Pick from a pre-made pallete");
mMenu.setItem("RGB","Pick values by RGB values");
mMenu.setItem("HSV","Pick values by HSV method");
break;
case animation: //Choose animation + Animation speed
mMenu.setMenuTitle("Animation Selection");
mMenu.setPrevMenu(pattern2);
mMenu.setItem("Cycle CW","Cycles pattern clockwise");
mMenu.setItem("Cycle CCW","Cycles pattern counterclockwise");
mMenu.setItem("Breathe","LEDs fade in and out all at once");
mMenu.setItem("Fade","LEDs alternate fading in and out");
mMenu.setItem("Random Fade","LEDs fade randomly");
mMenu.setItem("Cylon","Back and forth");
mMenu.setItem("Color pop","Sparks of color");
mMenu.setItem("Splatter","Like plowing through somethign");
mMenu.setItem("Drip","Color dripping from under car");
break;
case pattern3: //Premade patterns menu
mMenu.setMenuTitle("Premade patterns");
mMenu.setPrevMenu(pattern1);
mMenu.setItem("Pacifica","A calming water effect");
mMenu.setItem("Rising Flames","A not-so-calming flame effect");
mMenu.setItem("TwinkleFox","I got nothin'");
mMenu.setItem("MURICA","FREEDOM MODE");
mMenu.setItem("Valentines","Think fluffy thoughts");
mMenu.setItem("Shamrock","Top o' the mornin'");
mMenu.setItem("Halloween","Spooky");
mMenu.setItem("Christmas","Commercialization!");
break;
case settings: //Main settings menu
mMenu.setMenuTitle("Settings");
mMenu.setPrevMenu(main);
mMenu.setItem("LED Settings","Set up and tweak LEDs");
mMenu.setItem("Brake and Turn","Brake and turn signal wiring");
mMenu.setItem("Bluetooth","Set up bluetooth");
mMenu.setItem("Driving shutoff","Automatically cut lights when car in motion");
mMenu.setItem("Device Info","Licenses, credits, stuff like that");
break;
case ledsetting1: //Pick which LED string is being accessed.
mMenu.setMenuTitle("Set up LED string.");
mMenu.setPrevMenu(settings);
mMenu.setItem("Front string","Direction, number, etc.");
mMenu.setItem("Passenger string","Direction, number, etc.");
mMenu.setItem("Rear string","Direction, number, etc.");
mMenu.setItem("Driver string","Direction, number, etc.");
mMenu.setItem("Spare string 1","Direction, number, etc.");
mMenu.setItem("Spare string 2","Direction, number, etc.");
break;
case ledsetting2:
//TODO: Change title based on LED string selected
mMenu.setPrevMenu(ledsetting1);
mMenu.setItem("Color order","Change RGB color order"); //Default for WS2811s is GRB
mMenu.setItem("Number","Change number of LEDs on the strip"); //Remember to put notice for WS2811s
mMenu.setItem("Direction","Change direction of led flow"); //Reverse strip if installed backwards
break;
case ledorder: //Top level gauge menu
mMenu.setMenuTitle("Select color Order");
mMenu.setPrevMenu(ledsetting2);
mMenu.setItem("RGB","Should display red, green, blue");
mMenu.setItem("RBG","Should display red, green, blue");
mMenu.setItem("GRB","Should display red, green, blue");
mMenu.setItem("GBR","Should display red, green, blue");
mMenu.setItem("BRG","Should display red, green, blue");
mMenu.setItem("BGR","Should display red, green, blue");
break;
case brakeandturn: //Set brake and turn signal behavior
mMenu.setMenuTitle("Brakes and signals");
mMenu.setPrevMenu(settings);
mMenu.setItem("Brakes","Set brake behavior");
mMenu.setItem("Turn signals","Set turn signal behavior");
break;
case bluetooth: //Bluetooth settings
mMenu.setMenuTitle("Bluetooth settings");
mMenu.setPrevMenu(settings);
mMenu.setItem("BT Enabled","Toggle bluttooth on or off.");
mMenu.setItem("BT Name","Name for identifying device.");
mMenu.setItem("BT Pair","Pair a new bluetooth device.");
break;
}
ShowMenu(&mMenu, sel);
}
//Navigate menus
int menuSelect(Menu *m, int &select){
//Get input
int8_t input = getInput();
switch(input){
case UP:
select--;
//Wrap if out of bounds
if(select < 0){
select = m->getLen()-1;
}
break;
case DOWN:
select++;
//Wrap if out of bounds
if(select >= m->getLen()){
select = 0;
}
break;
case LEFT:
case BACK:
//exit back to parent menu
return -1;
break;
case RIGHT:
case SELECT:
//Send state to execution table for further input
return executionTable(m->getState(),select);
break;
}
Serial.println(select);
return 0;
}
//Displays menu item
void ShowMenu(Menu *m, int select){
display.clear();
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawStringMaxWidth(0,12,128,m->getTitle(select));
display.setFont(ArialMT_Plain_10);
display.drawStringMaxWidth(0,28,128,m->getDesc(select));
display.display();
}
//Defines menu behaviour
int executionTable(State s, int &sel){
switch(s){ //Switch based on menu
case main: //Main menu
switch(sel){
case 0: //Display
//Show present configuration
pError("TODO: CURR CONFIG"); //Scrolling text
break;
case 1: //Gauge menu selected
sel = 0;
setupMenu(s=gauge1);
break;
case 2: //Pattern menu selected
sel = 0;
setupMenu(s=pattern1);
break;
case 3: //Settings menu selected
sel = 0;
setupMenu(s=settings);
break;
default:
sel = 0;
pError("Error: Out of bounds");
break;
}
break;
case gauge1:
switch(sel){
default:
sel = 0;
pError("Error: Out of bounds");
break;
}
break;
case pattern1:
switch(sel){
case 0: //Show custom pattern menu
sel = 0;
setupMenu(s=pattern2);
break;
case 1: //Show premade pattern menu
sel = 0;
setupMenu(s=pattern3);
break;
default:
sel = 0;
pError("Error: Out of bounds");
break;
}
break;
case pattern2:
switch(sel){
case 0: //Show pattern menu
sel = 0;
setupMenu(s=pickpattern);
break;
case 1: //Show Color picker menu
sel = 0;
setupMenu(s=color);
break;
case 2: //Show Animation menu
sel = 0;
setupMenu(s=animation);
break;
default:
sel = 0;
pError("Error: Out of bounds");
break;
}
break;
case pickpattern:
switch(sel){
default:
sel = 0;
pError("Error: Out of bounds");
break;
}
break;
case color:
switch(sel){
default:
sel = 0;
pError("Error: Out of bounds");
break;
}
break;
case animation:
switch(sel){
case 4: //Color Pop
pError("TODO: COLORPOP"); //Pattern selection
pError("CHOOSE SPEED"); //Pick speed w/ default
break;
case 5: //Splatter
pError("TODO: SPLATTER"); //Pattern selection
pError("CHOOSE SPEED"); //Pick speed w/ default
break;
case 6: //Drip
pError("TODO: DRIP"); //Pattern selection
pError("CHOOSE SPEED"); //Pick speed w/ default
break;
default:
sel = 0;
pError("Error: Out of bounds");
break;
}
break;
case pattern3:
switch(sel){
case 0: //Pacifica
pError("TODO: PACIFICA"); //Pattern selection
break;
case 1: //Rising FLames
pError("TODO: RISING FLAMES"); //Pattern selection
break;
case 2: //TwinkleFox
pError("TODO: TWINKLEFOX"); //Pattern selection
break;
case 3: //MURICA
pError("TODO: MURICA"); //Pattern selection
break;
case 4: //Valentine's
pError("TODO: VAENTINES"); //Pattern selection
break;
case 5: //Shamrock
pError("TODO: SHAMROCK"); //Pattern selection
break;
case 6: //Halloween
pError("TODO: HALLOWEEN"); //Pattern selection
break;
case 7: //Christmas
pError("TODO: CHRISTMAS"); //Pattern selection
break;
default:
sel = 0;
pError("Error: Out of bounds");
break;
}
break;
case settings:
switch(sel){
case 0: //Set up LED Settings
sel = 0;
setupMenu(s=ledsetting1);
break;
case 1: //Set up Brakes and turn signals
sel = 0;
setupMenu(s=brakeandturn);
break;
case 2: //Set up bluetooth
sel = 0;
setupMenu(s=bluetooth);
break;
case 3: //Set up auto shutoff when driving
pError("TODO: AUTOSHUTOFF"); //Bool (Add warning for ODB-II?)
break;
case 4: //Display device info
pError("TODO: DEVICE INFO"); //Scrolling text
break;
default:
sel = 0;
pError("Error: Out of bounds");
break;
}
break;
case ledsetting1:
switch(sel){
case 0: //Front LED String
sel = 0;
setupMenu(s=ledsetting2);
mMenu.setMenuTitle("Front String");
sLEDString = front;
break;
case 1: //Passenger LED String
sel = 0;
setupMenu(s=ledsetting2);
mMenu.setMenuTitle("Passenger String");
sLEDString = passenger;
break;
case 2: //Rear LED String
sel = 0;
setupMenu(s=ledsetting2);
mMenu.setMenuTitle("Rear String");
sLEDString = rear;
break;
case 3: //Driver LED String
sel = 0;
setupMenu(s=ledsetting2);
mMenu.setMenuTitle("Driver String");
sLEDString = driver;
break;
case 4: //Spare LED String 1
sel = 0;
setupMenu(s=ledsetting2);
mMenu.setMenuTitle("Spare String 1");
sLEDString = spare1;
break;
case 5: //Spare LED String 2
sel = 0;
setupMenu(s=ledsetting2);
mMenu.setMenuTitle("Spare String 2");
sLEDString = spare2;
break;
default:
sel = 0;
pError("Error: Out of bounds");
break;
}
break;
case ledsetting2:
switch(sel){
case 0: //RGB order
pError("TODO: RGB ORDER MENU"); //Sub menu
break;
case 1: // Number of LEDs
pError("TODO: STRING SIZE SELECTION"); //Int
break;
case 2: //Direction
pError("TODO: REVERSE DIRECTION"); //Bool
break;
default:
sel = 0;
pError("Error: Out of bounds");
break;
}
break;
case ledorder:
//Set LEDS strip type after user verifies
//use sLEDSetring to save to correct string
switch(sLEDString){
default:
sel = 0;
pError("Error: Out of bounds");
break;
}
break;
case brakeandturn:
switch(sel){
case 0: //Set brakes
pError("TODO: BRAKE MENU"); //Sub menu
break;
case 1: //Turn signal behaviours
pError("TODO: TURN SIGNAL MENU"); //Sub menu
break;
default:
sel = 0;
pError("Error: Out of bounds");
break;
}
break;
case bluetooth:
switch(sel){
case 0: //BT enabled
pError("TODO: BLUETOOTH ENABLE/DISABLE"); //bool
break;
case 1: //BT name
pError("TODO: RENAME BT DEVICE"); //Text entry
break;
case 2: //BT pair
pError("TODO: BT PAIRING"); //Pair device function
break;
default:
sel = 0;
pError("Error: Out of bounds");
break;
}
break;
default://Menu ID unknown
pError("Error: Menu does not exist");
return -1;
break;
}
}
//Set PID to control - FIXME
void PIDMode(int PID){
if (!OBD2.pidSupported(PID)){
pError("Unsupported");
} else {
//s.curr.trackedPID = PID;
saveSetting();
}
}
//Returns value of sensor PID is monotoring from vehicle - COMPLETE
float fetchCarData(int pid){
if (!OBD2.pidSupported(pid)) pError("Unsupported");
float pidValue = OBD2.pidRead(pid);
if(isnan(pidValue)){
pError("Data not valid");
return -1.0;
}
return pidValue;
}
// Find valid PIDs for connected vehicle - COMPLETE
int8_t getValidPIDs(int *PIDArr){
//Use count as len for menu
int8_t count = 0;
for(int i = 0; i < 96; i++){
if (OBD2.pidSupported(i)) {
PIDArr[i] = i;
count++;
}
}
return count;
}
// Select a PID via menu - FIXME (New menu system)
int selectPID(){
int tempArray[96] = {0};
int8_t len = getValidPIDs(tempArray);
/*Menu pidMenu(len);
pidMenu.setID(1);
int8_t count = 0;
for(int8_t i = 0; i < 96; i++){
if(tempArray[i] == 0){
continue;
} else {
char cBuffer1[32];
char cBuffer2[32];
OBD2.pidName(i).toCharArray(cBuffer1,32);
OBD2.pidUnits(i).toCharArray(cBuffer2,32);
pidMenu.setItem(count, cBuffer1, cBuffer2); //Hacky work-around, remove
count++;
}
int result = menuSelect(&pidMenu);
PIDMode(result);
return result;
}*/
}
//Sends text to screen - Used for errors and some other popups - COMPLETE
void pError(char *eText){
display.clear();
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawStringMaxWidth(0,12,128,"NOTICE:");
display.setFont(ArialMT_Plain_10);
display.drawStringMaxWidth(0,28,128,eText);
display.display();
// Wait for controls to be used
while(getInput() == -1){
continue;
}
//Print to Serial
Serial.println(eText);
//Clear screen
display.clear();
display.display();
}
//EEPROM - get setting value - COMPLETE
char loadSetting(){
EEPROM.get(0,settingStruct);
}
//EEPROM - save value - COMPLETE
void saveSetting(){
EEPROM.put(0,settingStruct);
EEPROM.commit();
//Notify user settings saved
pError("Settings Saved");
}
//EEPROM - Reset - COMPLETE
void EEPROMReset(){
//Create new, zeroed struct
Settings temp = {0};
//Copy important information
for(int8_t i = 0; i < 10; i++){
temp.deviceID[i] = settingStruct.deviceID[i];
}
//Save settings
settingStruct = temp;
saveSetting;
}
//Take input from joystick and button(s). Only accepts one input per cycle. Not building an NES here.
int8_t getInput(){
int analogVal = analogRead(JOYSTICK_Y);
if(analogVal >= DEADZONEHIGH){
return DOWN;
} else if(analogVal <= DEADZONELOW){
return UP;
}
analogVal = analogRead(JOYSTICK_X);
if(analogVal >= DEADZONEHIGH){
return LEFT;
} else if(analogVal <= DEADZONELOW){
return RIGHT;
}
if(button1.pressed()){
return SELECT;
}
if(joyButton.pressed()){
return BACK;
}
}
//LED Initialization - Only run on init
//On reboot, initialize LEDS
void setupLEDs(){
int LEDTotal = 0;
if(preset){
//Load from EEPROM
} else {
//Load test strip setup
LEDS.setBrightness(MAX_BRIGHTNESS);
frontLH.order = brg;
frontLH.ledCount = 18;
rightLH.order = brg;
rightLH.ledCount = 30;
rearLH.order = brg;
rearLH.ledCount = 18;
leftLH.order = brg;
leftLH.ledCount = 30;
spare1LH.order = brg;
spare1LH.ledCount = 2;
spare2LH.order = brg;
spare2LH.ledCount = 2;
}
LEDTotal = frontLH.ledCount + rightLH.ledCount + rearLH.ledCount +
leftLH.ledCount + spare1LH.ledCount + spare2LH.ledCount;
underglow = new CRGB[LEDTotal];
//based on rgb order, initialize front LEDs
LEDTotal = 0;
switch(frontLH.order){
default:
case rgb:
LEDS.addLeds<WS2811,LED_FRONT,RGB>(underglow,LEDTotal,frontLH.ledCount);
break;
case rbg:
LEDS.addLeds<WS2811,LED_FRONT,RBG>(underglow,LEDTotal,frontLH.ledCount);
break;
case grb:
LEDS.addLeds<WS2811,LED_FRONT,GRB>(underglow,LEDTotal,frontLH.ledCount);
break;
case gbr:
LEDS.addLeds<WS2811,LED_FRONT,GBR>(underglow,LEDTotal,frontLH.ledCount);
break;
case brg:
LEDS.addLeds<WS2811,LED_FRONT,BRG>(underglow,LEDTotal,frontLH.ledCount);
break;
case bgr:
LEDS.addLeds<WS2811,LED_FRONT,BGR>(underglow,LEDTotal,frontLH.ledCount);
break;
}
LEDTotal += frontLH.ledCount;
rightLH.startPos = LEDTotal;
switch(rightLH.order){
default:
case rgb:
LEDS.addLeds<WS2811,LED_RIGHT,RGB>(underglow,LEDTotal,rightLH.ledCount);
break;
case rbg:
LEDS.addLeds<WS2811,LED_RIGHT,RBG>(underglow,LEDTotal,rightLH.ledCount);
break;
case grb:
LEDS.addLeds<WS2811,LED_RIGHT,GRB>(underglow,LEDTotal,rightLH.ledCount);
break;
case gbr:
LEDS.addLeds<WS2811,LED_RIGHT,GBR>(underglow,LEDTotal,rightLH.ledCount);
break;
case brg:
LEDS.addLeds<WS2811,LED_RIGHT,BRG>(underglow,LEDTotal,rightLH.ledCount);
break;
case bgr:
LEDS.addLeds<WS2811,LED_RIGHT,BGR>(underglow,LEDTotal,rightLH.ledCount);
break;
}
LEDTotal += rightLH.ledCount;
rearLH.startPos = LEDTotal;
switch(rearLH.order){
default:
case rgb:
LEDS.addLeds<WS2811,LED_REAR,RGB>(underglow,LEDTotal,rearLH.ledCount);
break;
case rbg:
LEDS.addLeds<WS2811,LED_REAR,RBG>(underglow,LEDTotal,rearLH.ledCount);
break;
case grb:
LEDS.addLeds<WS2811,LED_REAR,GRB>(underglow,LEDTotal,rearLH.ledCount);
break;
case gbr:
LEDS.addLeds<WS2811,LED_REAR,GBR>(underglow,LEDTotal,rearLH.ledCount);
break;
case brg:
LEDS.addLeds<WS2811,LED_REAR,BRG>(underglow,LEDTotal,rearLH.ledCount);
break;
case bgr:
LEDS.addLeds<WS2811,LED_REAR,BGR>(underglow,LEDTotal,rearLH.ledCount);
break;
}
LEDTotal += rearLH.ledCount;
leftLH.startPos = LEDTotal;
switch(leftLH.order){
default:
case rgb:
LEDS.addLeds<WS2811,LED_LEFT,RGB>(underglow,LEDTotal,leftLH.ledCount);
break;
case rbg:
LEDS.addLeds<WS2811,LED_LEFT,RBG>(underglow,LEDTotal,leftLH.ledCount);
break;
case grb:
LEDS.addLeds<WS2811,LED_LEFT,GRB>(underglow,LEDTotal,leftLH.ledCount);
break;
case gbr:
LEDS.addLeds<WS2811,LED_LEFT,GBR>(underglow,LEDTotal,leftLH.ledCount);
break;
case brg:
LEDS.addLeds<WS2811,LED_LEFT,BRG>(underglow,LEDTotal,leftLH.ledCount);
break;
case bgr:
LEDS.addLeds<WS2811,LED_LEFT,BGR>(underglow,LEDTotal,leftLH.ledCount);
break;
}
LEDTotal += leftLH.ledCount;
spare1LH.startPos = LEDTotal;
switch(spare1LH.order){
default:
case rgb:
LEDS.addLeds<WS2811,LED_SPARE1,RGB>(underglow,LEDTotal,spare1LH.ledCount);
break;
case rbg:
LEDS.addLeds<WS2811,LED_SPARE1,RBG>(underglow,LEDTotal,spare1LH.ledCount);
break;
case grb:
LEDS.addLeds<WS2811,LED_SPARE1,GRB>(underglow,LEDTotal,spare1LH.ledCount);
break;
case gbr:
LEDS.addLeds<WS2811,LED_SPARE1,GBR>(underglow,LEDTotal,spare1LH.ledCount);
break;
case brg:
LEDS.addLeds<WS2811,LED_SPARE1,BRG>(underglow,LEDTotal,spare1LH.ledCount);
break;
case bgr:
LEDS.addLeds<WS2811,LED_SPARE1,BGR>(underglow,LEDTotal,spare1LH.ledCount);
break;
}
LEDTotal += spare1LH.ledCount;
spare2LH.startPos = LEDTotal;
switch(spare2LH.order){
default:
case rgb:
LEDS.addLeds<WS2811,LED_SPARE2,RGB>(underglow,LEDTotal,spare2LH.ledCount);
break;
case rbg:
LEDS.addLeds<WS2811,LED_SPARE2,RBG>(underglow,LEDTotal,spare2LH.ledCount);
break;
case grb:
LEDS.addLeds<WS2811,LED_SPARE2,GRB>(underglow,LEDTotal,spare2LH.ledCount);
break;
case gbr:
LEDS.addLeds<WS2811,LED_SPARE2,GBR>(underglow,LEDTotal,spare2LH.ledCount);
break;
case brg:
LEDS.addLeds<WS2811,LED_SPARE2,BRG>(underglow,LEDTotal,spare2LH.ledCount);
break;
case bgr:
LEDS.addLeds<WS2811,LED_SPARE2,BGR>(underglow,LEDTotal,spare2LH.ledCount);
break;
}
LEDTotal += spare2LH.ledCount;
}
//Strip flipper. Flips strips.
void colorSorter(CRGB color, int led){
if(led < frontLH.ledCount && frontLH.reversed){
underglow[((frontLH.startPos+frontLH.ledCount-1)-(led-frontLH.startPos))] = color;
} else if (led < rightLH.ledCount + rightLH.startPos && rightLH.reversed){
underglow[((rightLH.startPos+rightLH.ledCount-1)-(led-rightLH.startPos))] = color;
} else if (led < rearLH.ledCount + rearLH.startPos && rearLH.reversed){
underglow[((rearLH.startPos+rearLH.ledCount-1)-(led-rearLH.startPos))] = color;
} else if (led < leftLH.ledCount + leftLH.startPos && leftLH.reversed){
underglow[((leftLH.startPos+leftLH.ledCount-1)-(led-leftLH.startPos))] = color;
} else { //Not flipped, one of the spare strips.
underglow[led] = color;
}
}
| [
"johnnywycliffe@gmail.com"
] | johnnywycliffe@gmail.com |
025ad5a9801c804f2082a72c4b90db33134d2bac | abc3e43233861eb10977082e862599187ff57a30 | /DP_피보나치.cpp | a6c99d4d50b1c5c5dd8bf72067ca60b6bd382af6 | [] | no_license | imgosari/acm | 45287bd6997655bb3e74d045b7d7e42ef8f1882e | 1782bf6dc5bedb612ac484eb4d28052b14508dba | refs/heads/master | 2021-01-10T09:42:49.560371 | 2016-03-06T11:50:45 | 2016-03-06T11:50:45 | 52,941,665 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 391 | cpp | #include <stdio.h>
int memo[100];
int memo2[100];
int top_down(int n)
{
if(n<=1)
return n;
if(memo[n]>0)
return memo[n];
memo[n] = top_down(n-2)+top_down(n-1);
return memo[n];
}
int bottom_up(int n)
{
memo2[0]=0;
memo2[1]=1;
for(int i=2;i<=n;i++)
memo2[i]=memo2[i-1]+memo2[i-2];
return memo2[n];
}
int main()
{
//printf("%d\n", top_down(10));
printf("%d\n", bottom_up(10));
} | [
"imgosari@naver.com"
] | imgosari@naver.com |
58c4f2a6b5e66b2db18928e05ca813dbdc6bc6fe | 03e8850876fc466c6e4d305ad43b2a765eb32b6b | /230B_T-primes.cpp | 840f4f4db57b554413ba07ecaf77e0e7e3494dc1 | [] | no_license | Priyanshu-C/CodeForcesCodes | d35c79bdd082cd0326b8d851da8329dfac075d17 | 94e57b59eeeac550eef867ffed8c669446c82d60 | refs/heads/master | 2022-12-05T07:47:58.787632 | 2020-08-18T07:00:51 | 2020-08-18T07:00:51 | 262,815,670 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,937 | cpp | #include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================
int main() {
//SEIVE
const int MAX=1000000;
vector <bool> SEIVE(MAX + 1, true);
SEIVE[0] = SEIVE[1] = false;
for (int i = 2; i * i <= MAX; ++i)
if (SEIVE[i])
for (int j = i * i; j <= MAX; j += i)
SEIVE[j] = false;
map <ll int,bool> Tprimes;
for(ll int i=2;i<MAX;i++)
{
if(SEIVE[i])
{
Tprimes[i*i] = true;
}
}
ll int n;
cin>>n;
ll int j;
while(n--)
{
cin>>j;
if(Tprimes[j])
cout<<"YES"<<endl;
else
{
cout<<"NO"<<endl;
}
}
return 0;
}
| [
"priyanshuc.info@gmail.com"
] | priyanshuc.info@gmail.com |
1336378dee9609dc9e4351c773be699f2d4a9222 | bddb40149f9028297d9b4f3f6b77514cadac9bca | /Source/Utilities/UnitTest++/src/tests/Main.cpp | 583e0f5f73b32f55fe4fdf8ec81aadab8517c77c | [
"MIT"
] | permissive | JamesTerm/GremlinGames | 91d61a50d0926b8e95cad21053ba2cf6c3316003 | fd0366af007bff8cffe4941b4bb5bb16948a8c66 | refs/heads/master | 2021-10-20T21:15:53.121770 | 2019-03-01T15:45:58 | 2019-03-01T15:45:58 | 173,261,435 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 328 | cpp | #include "../UnitTest++.h"
#include "../TestReporterStdout.h"
int main(int, char const *[])
{
return UnitTest::RunAllTests();
}
/*
TEST(DoIt)
{
CHECK(false);
}
#define FAILURE_TEST(num, name) TEST(name) \
{ \
CHECK(num < 3); \
}
FAILURE_TEST(1, myBad1)
FAILURE_TEST(2, myBad2)
FAILURE_TEST(3, myBad3)
*/ | [
"james@e2c3bcc0-b32a-0410-840c-db224dcf21cb"
] | james@e2c3bcc0-b32a-0410-840c-db224dcf21cb |
24d02e2bb9343702ad718f288b8a7f59a140feea | 19af2f5a0778ffc0dc06b1925956d9acf8abb9c8 | /string/add/Integer.h | b4891e19d4ed8d8e449d6bfcaba23aa3ec7b3e29 | [] | no_license | jianxinzhou/Z_CodeHub | 7e1292edb0c692d6f0075d9e3299595fb8a6bcad | 480a9ab687916599e602213d5f324cbc6e89d483 | refs/heads/master | 2020-04-27T05:38:10.941105 | 2014-10-10T18:21:55 | 2014-10-10T18:21:55 | 24,331,949 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 517 | h | #ifndef INTEGER_H_
#define INTEGER_H_
#include <iostream>
class Integer
{
friend std::ostream &operator<< (std::ostream &os, const Integer &i);
friend std::istream &operator>> (std::istream &is, Integer &i);
public:
Integer(int data = 0); // int -> Integer
Integer &operator=(int data);
Integer &operator++(); //++i
Integer operator++(int); //i++
operator int() //类型转化
{ return data_; }
private:
int data_;
};
#endif /* INTEGER_H_ */
| [
"zhoujx0219@163.com"
] | zhoujx0219@163.com |
17d4587dc0732ecfa9a97a1609b6c77fbbb13801 | af2b67bb434049bef6556faae03d35ecc7744d90 | /byteladianncoins.cpp | 24638ff0c8df35a538b6799775ac38d6ad360f6b | [] | no_license | shubham808/Spoj-Solutions | 10f856ce985f60df0e922d09cd24ea380175c82c | 2fe43fbd905fbadf667d0014f8ff3b708b1d0e32 | refs/heads/master | 2021-01-22T23:10:33.050590 | 2017-05-30T06:02:58 | 2017-05-30T06:02:58 | 92,802,490 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 370 | cpp | #include<bits/stdc++.h>
using namespace std;
long long f(long long,long long*);
main()
{
long long n;
long long s[n];
while(scanf("%lld",&n)==1)
printf("%lld\n",f(n,s));
}
long long f(long long n,long long * s)
{
if(n==0)return 0;
if(s[n]!=0)return s[n];
long long r=f(n/2,s)+f(n/3,s)+f(n/4,s);
if(r>n)
s[n]=r;
else s[n]=n;
return s[n];
}
| [
"noreply@github.com"
] | noreply@github.com |
5297fe8cb6c2e1b3ce10b7517074622ddba2023f | 6d34fa23c708320b2e42d120d107f187106302e3 | /orca/gporca/libgpopt/src/operators/CPhysical.cpp | abc5ac83ce526fc7df38a3f6444caaa4afdf946e | [
"Apache-2.0"
] | permissive | joe2hpimn/dg16.oss | a38ca233ba5c9f803f9caa99016a4c7560da9f08 | 2c4275c832b3e4b715b7475726db6757b127030c | refs/heads/master | 2021-08-23T19:11:49.831210 | 2017-12-06T05:23:22 | 2017-12-06T05:23:22 | 113,322,478 | 2 | 1 | null | 2017-12-06T13:50:44 | 2017-12-06T13:50:44 | null | UTF-8 | C++ | false | false | 34,222 | cpp | //---------------------------------------------------------------------------
// Greenplum Database
// Copyright (C) 2009 Greenplum, Inc.
//
// @filename:
// CPhysical.cpp
//
// @doc:
// Implementation of basic physical operator
//
// @owner:
//
//
// @test:
//
//
//---------------------------------------------------------------------------
#include "gpos/base.h"
#include "gpos/sync/CAutoMutex.h"
#include "gpopt/base/CDrvdPropPlan.h"
#include "gpopt/base/CReqdPropPlan.h"
#include "gpopt/base/COptCtxt.h"
#include "gpopt/base/CPartIndexMap.h"
#include "gpopt/base/CCTEMap.h"
#include "gpopt/base/CCTEReq.h"
#include "gpopt/base/CDistributionSpecHashed.h"
#include "gpopt/base/CDistributionSpecRandom.h"
#include "gpopt/base/CDistributionSpecSingleton.h"
#include "gpopt/base/CDistributionSpecReplicated.h"
#include "gpopt/base/CDistributionSpecAny.h"
#include "gpopt/operators/CExpression.h"
#include "gpopt/operators/CExpressionHandle.h"
#include "gpopt/operators/CPhysical.h"
#include "gpopt/operators/CScalarIdent.h"
using namespace gpopt;
//---------------------------------------------------------------------------
// @function:
// CPhysical::CPhysical
//
// @doc:
// ctor
//
//---------------------------------------------------------------------------
CPhysical::CPhysical
(
IMemoryPool *pmp
)
:
COperator(pmp),
m_phmrcr(NULL),
m_pdrgpulpOptReqsExpanded(NULL),
m_ulTotalOptRequests(1) // by default, an operator creates a single request for each property
{
GPOS_ASSERT(NULL != pmp);
for (ULONG ul = 0; ul < GPOPT_PLAN_PROPS; ul++)
{
// by default, an operator creates a single request for each property
m_rgulOptReqs[ul] = 1;
}
UpdateOptRequests(0 /*ulPropIndex*/, 1 /*ulOrderReqs*/);
m_phmrcr = GPOS_NEW(pmp) HMReqdColsRequest(pmp);
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::UpdateOptRequests
//
// @doc:
// Update number of requests of a given property,
// re-compute total number of optimization requests as the product
// of all properties requests
//
//---------------------------------------------------------------------------
void
CPhysical::UpdateOptRequests
(
ULONG ulPropIndex,
ULONG ulRequests
)
{
GPOS_ASSERT(ulPropIndex < GPOPT_PLAN_PROPS);
CAutoMutex am(m_mutex);
am.Lock();
// update property requests
m_rgulOptReqs[ulPropIndex] = ulRequests;
// compute new value of total requests
ULONG ulOptReqs = 1;
for (ULONG ul = 0; ul < GPOPT_PLAN_PROPS; ul++)
{
ulOptReqs = ulOptReqs * m_rgulOptReqs[ul];
}
// update total requests
m_ulTotalOptRequests = ulOptReqs;
// update expanded requests
const ULONG ulOrderRequests = UlOrderRequests();
const ULONG ulDistrRequests = UlDistrRequests();
const ULONG ulRewindRequests = UlRewindRequests();
const ULONG ulPartPropagateRequests = UlPartPropagateRequests();
CRefCount::SafeRelease(m_pdrgpulpOptReqsExpanded);
m_pdrgpulpOptReqsExpanded = NULL;
m_pdrgpulpOptReqsExpanded = GPOS_NEW(m_pmp) DrgPulp(m_pmp);
for (ULONG ulOrder = 0; ulOrder < ulOrderRequests; ulOrder++)
{
for (ULONG ulDistr = 0; ulDistr < ulDistrRequests; ulDistr++)
{
for (ULONG ulRewind = 0; ulRewind < ulRewindRequests; ulRewind++)
{
for (ULONG ulPartPropagate = 0; ulPartPropagate < ulPartPropagateRequests; ulPartPropagate++)
{
ULONG_PTR *pulpRequest = GPOS_NEW_ARRAY(m_pmp, ULONG_PTR, GPOPT_PLAN_PROPS);
pulpRequest[0] = ulOrder;
pulpRequest[1] = ulDistr;
pulpRequest[2] = ulRewind;
pulpRequest[3] = ulPartPropagate;
m_pdrgpulpOptReqsExpanded->Append(pulpRequest);
}
}
}
}
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::LookupReqNo
//
// @doc:
// Map input request number to order, distribution, rewindability and
// partition propagation requests
//
//---------------------------------------------------------------------------
void
CPhysical::LookupRequest
(
ULONG ulReqNo, // input: request number
ULONG *pulOrderReq, // output: order request number
ULONG *pulDistrReq, // output: distribution request number
ULONG *pulRewindReq, // output: rewindability request number
ULONG *pulPartPropagateReq // output: partition propagation request number
)
{
GPOS_ASSERT(NULL != m_pdrgpulpOptReqsExpanded);
GPOS_ASSERT(ulReqNo < m_pdrgpulpOptReqsExpanded->UlLength());
GPOS_ASSERT(NULL != pulOrderReq);
GPOS_ASSERT(NULL != pulDistrReq);
GPOS_ASSERT(NULL != pulRewindReq);
GPOS_ASSERT(NULL != pulPartPropagateReq);
ULONG_PTR *pulpRequest = (*m_pdrgpulpOptReqsExpanded)[ulReqNo];
*pulOrderReq = (ULONG) pulpRequest[0];
*pulDistrReq = (ULONG) pulpRequest[1];
*pulRewindReq = (ULONG) pulpRequest[2];
*pulPartPropagateReq = (ULONG) pulpRequest[3];
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PdpCreate
//
// @doc:
// Create base container of derived properties
//
//---------------------------------------------------------------------------
CDrvdProp *
CPhysical::PdpCreate
(
IMemoryPool *pmp
)
const
{
return GPOS_NEW(pmp) CDrvdPropPlan();
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PopCopyWithRemappedColumns
//
// @doc:
// Return a copy of the operator with remapped columns
//
//---------------------------------------------------------------------------
COperator *
CPhysical::PopCopyWithRemappedColumns
(
IMemoryPool *, //pmp,
HMUlCr *, //phmulcr,
BOOL //fMustExist
)
{
GPOS_ASSERT(!"Invalid call of CPhysical::PopCopyWithRemappedColumns");
return NULL;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PrpCreate
//
// @doc:
// Create base container of required properties
//
//---------------------------------------------------------------------------
CReqdProp *
CPhysical::PrpCreate
(
IMemoryPool *pmp
)
const
{
return GPOS_NEW(pmp) CReqdPropPlan();
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalHashJoin::CReqdColsRequest::UlHash
//
// @doc:
// Hash function
//
//---------------------------------------------------------------------------
ULONG
CPhysical::CReqdColsRequest::UlHash
(
const CReqdColsRequest *prcr
)
{
GPOS_ASSERT(NULL != prcr);
ULONG ulHash = prcr->Pcrs()->UlHash();
ulHash = UlCombineHashes(ulHash , prcr->UlChildIndex());;
return UlCombineHashes(ulHash , prcr->UlScalarChildIndex());
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalHashJoin::CReqdColsRequest::FEqual
//
// @doc:
// Equality function
//
//---------------------------------------------------------------------------
BOOL
CPhysical::CReqdColsRequest::FEqual
(
const CReqdColsRequest *prcrFst,
const CReqdColsRequest *prcrSnd
)
{
GPOS_ASSERT(NULL != prcrFst);
GPOS_ASSERT(NULL != prcrSnd);
return
prcrFst->UlChildIndex() == prcrSnd->UlChildIndex() &&
prcrFst->UlScalarChildIndex() == prcrSnd->UlScalarChildIndex() &&
prcrFst->Pcrs()->FEqual(prcrSnd->Pcrs());
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PdsCompute
//
// @doc:
// Compute the distribution spec given the table descriptor
//
//---------------------------------------------------------------------------
CDistributionSpec *
CPhysical::PdsCompute
(
IMemoryPool *pmp,
const CTableDescriptor *ptabdesc,
DrgPcr *pdrgpcrOutput
)
{
CDistributionSpec *pds = NULL;
switch (ptabdesc->Ereldistribution())
{
case IMDRelation::EreldistrMasterOnly:
pds = GPOS_NEW(pmp) CDistributionSpecSingleton(CDistributionSpecSingleton::EstMaster);
break;
case IMDRelation::EreldistrRandom:
pds = GPOS_NEW(pmp) CDistributionSpecRandom();
break;
case IMDRelation::EreldistrHash:
{
const DrgPcoldesc *pdrgpcoldesc = ptabdesc->PdrgpcoldescDist();
DrgPcr *pdrgpcr = GPOS_NEW(pmp) DrgPcr(pmp);
const ULONG ulSize = pdrgpcoldesc->UlLength();
for (ULONG ul = 0; ul < ulSize; ul++)
{
CColumnDescriptor *pcoldesc = (*pdrgpcoldesc)[ul];
ULONG ulPos = ptabdesc->UlPos(pcoldesc, ptabdesc->Pdrgpcoldesc());
GPOS_ASSERT(ulPos < ptabdesc->Pdrgpcoldesc()->UlLength() && "Column not found");
CColRef *pcr = (*pdrgpcrOutput)[ulPos];
pdrgpcr->Append(pcr);
}
DrgPexpr *pdrgpexpr = CUtils::PdrgpexprScalarIdents(pmp, pdrgpcr);
pdrgpcr->Release();
pds = GPOS_NEW(pmp) CDistributionSpecHashed(pdrgpexpr, true /*fNullsColocated*/);
break;
}
default:
GPOS_ASSERT(!"Invalid distribution policy");
}
return pds;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PosPassThru
//
// @doc:
// Helper for a simple case of of computing child's required sort order
//
//---------------------------------------------------------------------------
COrderSpec *
CPhysical::PosPassThru
(
IMemoryPool *, // pmp
CExpressionHandle &, // exprhdl
COrderSpec *posRequired,
ULONG // ulChildIndex
)
{
posRequired->AddRef();
return posRequired;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PdsPassThru
//
// @doc:
// Helper for a simple case of computing child's required distribution
//
//---------------------------------------------------------------------------
CDistributionSpec *
CPhysical::PdsPassThru
(
IMemoryPool *, // pmp
CExpressionHandle &, // exprhdl
CDistributionSpec *pdsRequired,
ULONG // ulChildIndex
)
{
pdsRequired->AddRef();
return pdsRequired;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PdsMasterOnlyOrReplicated
//
// @doc:
// Helper for computing child's required distribution when Master-Only/Replicated
// distributions must be requested
//
//---------------------------------------------------------------------------
CDistributionSpec *
CPhysical::PdsMasterOnlyOrReplicated
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl,
CDistributionSpec *pdsRequired,
ULONG ulChildIndex,
ULONG ulOptReq
)
{
GPOS_ASSERT(2 > ulOptReq);
// if expression has to execute on master then we need a gather
if (exprhdl.FMasterOnly())
{
return PdsEnforceMaster(pmp, exprhdl, pdsRequired, ulChildIndex);
}
// if there are outer references, then we need a broadcast (or a gather)
if (exprhdl.FHasOuterRefs())
{
if (0 == ulOptReq)
{
return GPOS_NEW(pmp) CDistributionSpecReplicated();
}
return GPOS_NEW(pmp) CDistributionSpecSingleton(CDistributionSpecSingleton::EstMaster);
}
return NULL;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PdsUnary
//
// @doc:
// Helper for computing child's required distribution in unary operators
// with a scalar child
//
//---------------------------------------------------------------------------
CDistributionSpec *
CPhysical::PdsUnary
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl,
CDistributionSpec *pdsRequired,
ULONG ulChildIndex,
ULONG ulOptReq
)
{
GPOS_ASSERT(0 == ulChildIndex);
GPOS_ASSERT(2 > ulOptReq);
// check if master-only/replicated distribution needs to be requested
CDistributionSpec *pds = PdsMasterOnlyOrReplicated(pmp, exprhdl, pdsRequired, ulChildIndex, ulOptReq);
if (NULL != pds)
{
return pds;
}
// operator does not have distribution requirements, required distribution
// will be enforced on its output
return GPOS_NEW(pmp) CDistributionSpecAny();
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PrsPassThru
//
// @doc:
// Helper for a simple case of of computing child's required rewindability
//
//---------------------------------------------------------------------------
CRewindabilitySpec *
CPhysical::PrsPassThru
(
IMemoryPool *, // pmp
CExpressionHandle &, // exprhdl
CRewindabilitySpec *prsRequired,
ULONG // ulChildIndex
)
{
prsRequired->AddRef();
return prsRequired;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PosDerivePassThruOuter
//
// @doc:
// Helper for common case of sort order derivation
//
//---------------------------------------------------------------------------
COrderSpec *
CPhysical::PosDerivePassThruOuter
(
CExpressionHandle &exprhdl
)
{
COrderSpec *pos = exprhdl.Pdpplan(0 /*ulChildIndex*/)->Pos();
pos->AddRef();
return pos;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PdsDerivePassThruOuter
//
// @doc:
// Helper for common case of distribution derivation
//
//---------------------------------------------------------------------------
CDistributionSpec *
CPhysical::PdsDerivePassThruOuter
(
CExpressionHandle &exprhdl
)
{
CDistributionSpec *pds = exprhdl.Pdpplan(0 /*ulChildIndex*/)->Pds();
pds->AddRef();
return pds;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PrsDerivePassThruOuter
//
// @doc:
// Helper for common case of rewindability derivation
//
//---------------------------------------------------------------------------
CRewindabilitySpec *
CPhysical::PrsDerivePassThruOuter
(
CExpressionHandle &exprhdl
)
{
CRewindabilitySpec *prs = exprhdl.Pdpplan(0 /*ulChildIndex*/)->Prs();
prs->AddRef();
return prs;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PcrsChildReqd
//
// @doc:
// Helper for computing required output columns of the n-th child;
// the caller must be an operator whose ulScalarIndex-th child is a
// scalar
//
//---------------------------------------------------------------------------
CColRefSet *
CPhysical::PcrsChildReqd
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl,
CColRefSet *pcrsRequired,
ULONG ulChildIndex,
ULONG ulScalarIndex
)
{
pcrsRequired->AddRef();
CReqdColsRequest *prcr = GPOS_NEW(pmp) CReqdColsRequest(pcrsRequired, ulChildIndex, ulScalarIndex);
CColRefSet *pcrs = NULL;
{
// scope of AutoMutex
CAutoMutex am(m_mutex);
am.Lock();
// lookup required columns map first
pcrs = m_phmrcr->PtLookup(prcr);
if (NULL != pcrs)
{
prcr->Release();
pcrs->AddRef();
return pcrs;
}
}
// request was not found in map -- we need to compute it
pcrs = GPOS_NEW(pmp) CColRefSet(pmp, *pcrsRequired);
if (ULONG_MAX != ulScalarIndex)
{
// include used columns and exclude defined columns of scalar child
pcrs->Union(exprhdl.Pdpscalar(ulScalarIndex)->PcrsUsed());
pcrs->Exclude(exprhdl.Pdpscalar(ulScalarIndex)->PcrsDefined());
}
// intersect computed column set with child's output columns
pcrs->Intersection(exprhdl.Pdprel(ulChildIndex)->PcrsOutput());
// lookup map again to handle concurrent map lookup/insertion
{
// scope of AutoMutex
CAutoMutex am(m_mutex);
am.Lock();
CColRefSet *pcrsFound = m_phmrcr->PtLookup(prcr);
if (NULL != pcrsFound)
{
// request was found now -- release computed request and use the found request
prcr->Release();
pcrs->Release();
pcrsFound->AddRef();
pcrs = pcrsFound;
}
else
{
// new request -- insert request in map
pcrs->AddRef();
#ifdef GPOS_DEBUG
BOOL fSuccess =
#endif // GPOS_DEBUG
m_phmrcr->FInsert(prcr, pcrs);
GPOS_ASSERT(fSuccess);
}
}
return pcrs;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::FUnaryProvidesReqdCols
//
// @doc:
// Helper for checking if output columns of a unary operator that defines
// no new columns include the required columns
//
//---------------------------------------------------------------------------
BOOL
CPhysical::FUnaryProvidesReqdCols
(
CExpressionHandle &exprhdl,
CColRefSet *pcrsRequired
)
{
GPOS_ASSERT(NULL != pcrsRequired);
CColRefSet *pcrsOutput = exprhdl.Pdprel(0 /*ulChildIndex*/)->PcrsOutput();
return pcrsOutput->FSubset(pcrsRequired);
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PdssMatching
//
// @doc:
// Compute a singleton distribution matching the given distribution
//
//---------------------------------------------------------------------------
CDistributionSpecSingleton *
CPhysical::PdssMatching
(
IMemoryPool *pmp,
CDistributionSpecSingleton *pdss
)
{
CDistributionSpecSingleton::ESegmentType est = CDistributionSpecSingleton::EstSegment;
if (pdss->FOnMaster())
{
est = CDistributionSpecSingleton::EstMaster;
}
return GPOS_NEW(pmp) CDistributionSpecSingleton(est);
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PppsRequiredPushThru
//
// @doc:
// Helper for pushing required partition propagation to the child
//
//---------------------------------------------------------------------------
CPartitionPropagationSpec *
CPhysical::PppsRequiredPushThru
(
IMemoryPool *, // pmp,
CExpressionHandle &, // exprhdl,
CPartitionPropagationSpec *pppsRequired,
ULONG // ulChildIndex
)
{
GPOS_ASSERT(NULL != pppsRequired);
// required partition propagation has been initialized already: pass it down
pppsRequired->AddRef();
return pppsRequired;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PcterPushThru
//
// @doc:
// Helper for pushing cte requirement to the child
//
//---------------------------------------------------------------------------
CCTEReq *
CPhysical::PcterPushThru
(
CCTEReq *pcter
)
{
GPOS_ASSERT(NULL != pcter);
pcter->AddRef();
return pcter;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PcmCombine
//
// @doc:
// Combine the derived CTE maps of the first n children
// of the given expression handle
//
//---------------------------------------------------------------------------
CCTEMap *
CPhysical::PcmCombine
(
IMemoryPool *pmp,
DrgPdp *pdrgpdpCtxt
)
{
GPOS_ASSERT(NULL != pdrgpdpCtxt);
const ULONG ulSize = pdrgpdpCtxt->UlLength();
CCTEMap *pcmCombined = GPOS_NEW(pmp) CCTEMap(pmp);
for (ULONG ul = 0; ul < ulSize; ul++)
{
CCTEMap *pcmChild = CDrvdPropPlan::Pdpplan((*pdrgpdpCtxt)[ul])->Pcm();
// get the remaining requirements that have not been met by child
CCTEMap *pcm = CCTEMap::PcmCombine(pmp, *pcmCombined, *pcmChild);
pcmCombined->Release();
pcmCombined = pcm;
}
return pcmCombined;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PcterNAry
//
// @doc:
// Helper for computing cte requirement for the n-th child
//
//---------------------------------------------------------------------------
CCTEReq *
CPhysical::PcterNAry
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl,
CCTEReq *pcter,
ULONG ulChildIndex,
DrgPdp *pdrgpdpCtxt
)
const
{
GPOS_ASSERT(NULL != pcter);
if (EceoLeftToRight == Eceo())
{
ULONG ulLastNonScalarChild = exprhdl.UlLastNonScalarChild();
if (ULONG_MAX != ulLastNonScalarChild && ulChildIndex < ulLastNonScalarChild)
{
return pcter->PcterAllOptional(pmp);
}
}
else
{
GPOS_ASSERT(EceoRightToLeft == Eceo());
ULONG ulFirstNonScalarChild = exprhdl.UlFirstNonScalarChild();
if (ULONG_MAX != ulFirstNonScalarChild && ulChildIndex > ulFirstNonScalarChild)
{
return pcter->PcterAllOptional(pmp);
}
}
CCTEMap *pcmCombined = PcmCombine(pmp, pdrgpdpCtxt);
// pass the remaining requirements that have not been resolved
CCTEReq *pcterUnresolved = pcter->PcterUnresolved(pmp, pcmCombined);
pcmCombined->Release();
return pcterUnresolved;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PppsRequiredPushThruNAry
//
// @doc:
// Helper for pushing required partition propagation to the children of
// an n-ary operator
//
//---------------------------------------------------------------------------
CPartitionPropagationSpec *
CPhysical::PppsRequiredPushThruNAry
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl,
CPartitionPropagationSpec *pppsReqd,
ULONG ulChildIndex
)
{
GPOS_ASSERT(NULL != pppsReqd);
CPartIndexMap *ppimReqd = pppsReqd->Ppim();
CPartFilterMap *ppfmReqd = pppsReqd->Ppfm();
DrgPul *pdrgpul = ppimReqd->PdrgpulScanIds(pmp);
CPartIndexMap *ppimResult = GPOS_NEW(pmp) CPartIndexMap(pmp);
CPartFilterMap *ppfmResult = GPOS_NEW(pmp) CPartFilterMap(pmp);
const ULONG ulPartIndexIds = pdrgpul->UlLength();
const ULONG ulArity = exprhdl.UlNonScalarChildren();
// iterate over required part index ids and decide which ones to push to the outer
// and which to the inner side of the n-ary op
for (ULONG ul = 0; ul < ulPartIndexIds; ul++)
{
ULONG ulPartIndexId = *((*pdrgpul)[ul]);
GPOS_ASSERT(ppimReqd->FContains(ulPartIndexId));
CBitSet *pbsPartConsumer = GPOS_NEW(pmp) CBitSet(pmp);
for (ULONG ulChildIdx = 0; ulChildIdx < ulArity; ulChildIdx++)
{
if (exprhdl.Pdprel(ulChildIdx)->Ppartinfo()->FContainsScanId(ulPartIndexId))
{
(void) pbsPartConsumer->FExchangeSet(ulChildIdx);
}
}
if (ulArity == pbsPartConsumer->CElements() &&
COperator::EopPhysicalSequence == exprhdl.Pop()->Eopid() &&
(*(exprhdl.Pgexpr()))[0]->FHasCTEProducer())
{
GPOS_ASSERT(2 == ulArity);
// this is a part index id that comes from both sides of a sequence
// with a CTE producer on the outer side, so pretend that part index
// id is not defined the inner sides
pbsPartConsumer->FExchangeClear(1);
}
if (!FCanPushPartReqToChild(pbsPartConsumer, ulChildIndex))
{
// clean up
pbsPartConsumer->Release();
continue;
}
// clean up
pbsPartConsumer->Release();
DrgPpartkeys *pdrgppartkeys = exprhdl.Pdprel(ulChildIndex)->Ppartinfo()->PdrgppartkeysByScanId(ulPartIndexId);
GPOS_ASSERT(NULL != pdrgppartkeys);
pdrgppartkeys->AddRef();
// push requirements to child node
ppimResult->AddRequiredPartPropagation(ppimReqd, ulPartIndexId, CPartIndexMap::EppraPreservePropagators, pdrgppartkeys);
// check if there is a filter on the part index id and propagate that further down
if (ppfmReqd->FContainsScanId(ulPartIndexId))
{
CExpression *pexpr = ppfmReqd->Pexpr(ulPartIndexId);
pexpr->AddRef();
ppfmResult->AddPartFilter(pmp, ulPartIndexId, pexpr, NULL /*pstats */);
}
}
pdrgpul->Release();
return GPOS_NEW(pmp) CPartitionPropagationSpec(ppimResult, ppfmResult);
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::FCanPushPartReqToChild
//
// @doc:
// Check whether we can push a part table requirement to a given child, given
// the knowledge of where the part index id is defined
//
//---------------------------------------------------------------------------
BOOL
CPhysical::FCanPushPartReqToChild
(
CBitSet *pbsPartConsumer,
ULONG ulChildIndex
)
{
GPOS_ASSERT(NULL != pbsPartConsumer);
// if part index id comes from more that one child, we cannot push request to just one child
if (1 < pbsPartConsumer->CElements())
{
return false;
}
// child where the part index is defined should be the same child being processed
return (pbsPartConsumer->FBit(ulChildIndex));
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PppsRequiredPushThruUnresolvedUnary
//
// @doc:
// Helper function for pushing unresolved partition propagation in unary
// operators
//
//---------------------------------------------------------------------------
CPartitionPropagationSpec *
CPhysical::PppsRequiredPushThruUnresolvedUnary
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl,
CPartitionPropagationSpec *pppsRequired
)
{
GPOS_ASSERT(NULL != pppsRequired);
CPartInfo *ppartinfo = exprhdl.Pdprel(0)->Ppartinfo();
CPartIndexMap *ppimReqd = pppsRequired->Ppim();
CPartFilterMap *ppfmReqd = pppsRequired->Ppfm();
DrgPul *pdrgpul = ppimReqd->PdrgpulScanIds(pmp);
CPartIndexMap *ppimResult = GPOS_NEW(pmp) CPartIndexMap(pmp);
CPartFilterMap *ppfmResult = GPOS_NEW(pmp) CPartFilterMap(pmp);
const ULONG ulPartIndexIds = pdrgpul->UlLength();
// iterate over required part index ids and decide which ones to push through
for (ULONG ul = 0; ul < ulPartIndexIds; ul++)
{
ULONG ulPartIndexId = *((*pdrgpul)[ul]);
GPOS_ASSERT(ppimReqd->FContains(ulPartIndexId));
// if part index id is defined in child, push it to the child
if (ppartinfo->FContainsScanId(ulPartIndexId))
{
// push requirements to child node
ppimResult->AddRequiredPartPropagation(ppimReqd, ulPartIndexId, CPartIndexMap::EppraPreservePropagators);
(void) ppfmResult->FCopyPartFilter(pmp, ulPartIndexId, ppfmReqd);
}
}
pdrgpul->Release();
return GPOS_NEW(pmp) CPartitionPropagationSpec(ppimResult, ppfmResult);
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PpimDeriveCombineRelational
//
// @doc:
// Common case of common case of combining partition index maps
// of all logical children
//
//---------------------------------------------------------------------------
CPartIndexMap *
CPhysical::PpimDeriveCombineRelational
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl
)
{
GPOS_ASSERT(0 < exprhdl.UlArity());
CPartIndexMap *ppim = GPOS_NEW(pmp) CPartIndexMap(pmp);
const ULONG ulArity = exprhdl.UlArity();
for (ULONG ul = 0; ul < ulArity; ul++)
{
if (!exprhdl.FScalarChild(ul))
{
CPartIndexMap *ppimChild = exprhdl.Pdpplan(ul)->Ppim();
GPOS_ASSERT(NULL != ppimChild);
CPartIndexMap *ppimCombined = CPartIndexMap::PpimCombine(pmp, *ppim, *ppimChild);
ppim->Release();
ppim = ppimCombined;
}
}
return ppim;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PpimPassThruOuter
//
// @doc:
// Common case of common case of passing through partition index map
//
//---------------------------------------------------------------------------
CPartIndexMap *
CPhysical::PpimPassThruOuter
(
CExpressionHandle &exprhdl
)
{
CPartIndexMap *ppim = exprhdl.Pdpplan(0 /*ulChildIndex*/)->Ppim();
GPOS_ASSERT(NULL != ppim);
ppim->AddRef();
return ppim;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PpfmPassThruOuter
//
// @doc:
// Common case of common case of passing through partition filter map
//
//---------------------------------------------------------------------------
CPartFilterMap *
CPhysical::PpfmPassThruOuter
(
CExpressionHandle &exprhdl
)
{
CPartFilterMap *ppfm = exprhdl.Pdpplan(0 /*ulChildIndex*/)->Ppfm();
GPOS_ASSERT(NULL != ppfm);
ppfm->AddRef();
return ppfm;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PpfmDeriveCombineRelational
//
// @doc:
// Combine derived part filter maps of relational children
//
//---------------------------------------------------------------------------
CPartFilterMap *
CPhysical::PpfmDeriveCombineRelational
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl
)
{
CPartFilterMap *ppfmCombined = GPOS_NEW(pmp) CPartFilterMap(pmp);
const ULONG ulArity = exprhdl.UlArity();
for (ULONG ul = 0; ul < ulArity; ul++)
{
if (!exprhdl.FScalarChild(ul))
{
CPartFilterMap *ppfm = exprhdl.Pdpplan(ul)->Ppfm();
GPOS_ASSERT(NULL != ppfm);
ppfmCombined->CopyPartFilterMap(pmp, ppfm);
}
}
return ppfmCombined;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PcmDerive
//
// @doc:
// Common case of combining cte maps of all logical children
//
//---------------------------------------------------------------------------
CCTEMap *
CPhysical::PcmDerive
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl
)
const
{
GPOS_ASSERT(0 < exprhdl.UlArity());
CCTEMap *pcm = GPOS_NEW(pmp) CCTEMap(pmp);
const ULONG ulArity = exprhdl.UlArity();
for (ULONG ul = 0; ul < ulArity; ul++)
{
if (!exprhdl.FScalarChild(ul))
{
CCTEMap *pcmChild = exprhdl.Pdpplan(ul)->Pcm();
GPOS_ASSERT(NULL != pcmChild);
CCTEMap *pcmCombined = CCTEMap::PcmCombine(pmp, *pcm, *pcmChild);
pcm->Release();
pcm = pcmCombined;
}
}
return pcm;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::FProvidesReqdCTEs
//
// @doc:
// Check if required CTEs are included in derived CTE map
//
//---------------------------------------------------------------------------
BOOL
CPhysical::FProvidesReqdCTEs
(
CExpressionHandle &exprhdl,
const CCTEReq *pcter
)
const
{
CCTEMap *pcmDrvd = CDrvdPropPlan::Pdpplan(exprhdl.Pdp())->Pcm();
GPOS_ASSERT(NULL != pcmDrvd);
return pcmDrvd->FSatisfies(pcter);
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::EpetPartitionPropagation
//
// @doc:
// Compute the enforcing type for the operator
//
//---------------------------------------------------------------------------
CEnfdProp::EPropEnforcingType
CPhysical::EpetPartitionPropagation
(
CExpressionHandle &exprhdl,
const CEnfdPartitionPropagation *pepp
)
const
{
CPartIndexMap *ppimReqd = pepp->PppsRequired()->Ppim();
if (!ppimReqd->FContainsUnresolved())
{
// no unresolved partition consumers left
return CEnfdProp::EpetUnnecessary;
}
CPartIndexMap *ppimDrvd = CDrvdPropPlan::Pdpplan(exprhdl.Pdp())->Ppim();
GPOS_ASSERT(NULL != ppimDrvd);
BOOL fInScope = pepp->FInScope(m_pmp, ppimDrvd);
BOOL fResolved = pepp->FResolved(m_pmp, ppimDrvd);
if (fResolved)
{
// all required partition consumers are resolved
return CEnfdProp::EpetUnnecessary;
}
if (!fInScope)
{
// some partition consumers are not in scope of the operator: need to enforce these on top
return CEnfdProp::EpetRequired;
}
// all partition resolvers are in scope of the operator: do not enforce them on top
return CEnfdProp::EpetProhibited;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::PdsEnforceMaster
//
// @doc:
// Enforce an operator to be executed on the master
//
//---------------------------------------------------------------------------
CDistributionSpec *
CPhysical::PdsEnforceMaster
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl,
CDistributionSpec *pds,
ULONG ulChildIndex
)
{
if (CDistributionSpec::EdtSingleton == pds->Edt())
{
CDistributionSpecSingleton *pdss = CDistributionSpecSingleton::PdssConvert(pds);
if (CDistributionSpecSingleton::EstMaster == pdss->Est())
{
return PdsPassThru(pmp, exprhdl, pds, ulChildIndex);
}
}
return GPOS_NEW(pmp) CDistributionSpecSingleton(CDistributionSpecSingleton::EstMaster);
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::DSkew
//
// @doc:
// Helper to compute skew estimate based on given stats and
// distribution spec
//
//---------------------------------------------------------------------------
CDouble
CPhysical::DSkew
(
IStatistics *pstats,
CDistributionSpec *pds
)
{
CDouble dSkew = 1.0;
if (CDistributionSpec::EdtHashed == pds->Edt())
{
CDistributionSpecHashed *pdshashed = CDistributionSpecHashed::PdsConvert(pds);
const DrgPexpr *pdrgpexpr = pdshashed->Pdrgpexpr();
const ULONG ulSize = pdrgpexpr->UlLength();
for (ULONG ul = 0; ul < ulSize; ul++)
{
CExpression *pexpr = (*pdrgpexpr)[ul];
if (COperator::EopScalarIdent == pexpr->Pop()->Eopid())
{
// consider only hashed distribution direct columns for now
CScalarIdent *popScId = CScalarIdent::PopConvert(pexpr->Pop());
ULONG ulColId = popScId->Pcr()->UlId();
CDouble dSkewCol = pstats->DSkew(ulColId);
if (dSkewCol > dSkew)
{
dSkew = dSkewCol;
}
}
}
}
return CDouble(dSkew);
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::FChildrenHaveCompatibleDistributions
//
// @doc:
// Returns true iff the delivered distributions of the children are
// compatible among themselves.
//
//---------------------------------------------------------------------------
BOOL
CPhysical::FCompatibleChildrenDistributions
(
const CExpressionHandle &exprhdl
)
const
{
GPOS_ASSERT(exprhdl.Pop() == this);
BOOL fSingletonOrUniversalChild = false;
BOOL fNotSingletonOrUniversalDistributedChild = false;
const ULONG ulArity = exprhdl.UlArity();
for (ULONG ul = 0; ul < ulArity; ul++)
{
if (!exprhdl.FScalarChild(ul))
{
CDrvdPropPlan *pdpplanChild = exprhdl.Pdpplan(ul);
// an operator cannot have a singleton or universal distributed child
// and one distributed on multiple nodes
// this assumption is safe for all current operators, but it can be
// too conservative: we could allow for instance the following cases
// * LeftOuterJoin (universal, distributed)
// * AntiSemiJoin (universal, distributed)
// These cases can be enabled if considered necessary by overriding
// this function.
if (CDistributionSpec::EdtUniversal == pdpplanChild->Pds()->Edt() ||
pdpplanChild->Pds()->FSingletonOrStrictSingleton())
{
fSingletonOrUniversalChild = true;
}
else
{
fNotSingletonOrUniversalDistributedChild = true;
}
if (fSingletonOrUniversalChild && fNotSingletonOrUniversalDistributedChild)
{
return false;
}
}
}
return true;
}
//---------------------------------------------------------------------------
// @function:
// CPhysical::FUnaryUsesDefinedColumns
//
// @doc:
// Return true if the given column set includes any of the columns defined
// by the unary node, as given by the handle
//
//---------------------------------------------------------------------------
BOOL
CPhysical::FUnaryUsesDefinedColumns
(
CColRefSet *pcrs,
CExpressionHandle &exprhdl
)
{
GPOS_ASSERT(NULL != pcrs);
GPOS_ASSERT(2 == exprhdl.UlArity() && "Not a unary operator");
if (0 == pcrs->CElements())
{
return false;
}
return !pcrs->FDisjoint(exprhdl.Pdpscalar(1)->PcrsDefined());
}
// EOF
| [
"fengttt@gmail.com"
] | fengttt@gmail.com |
ca24255882a35731c6939305b2388ce239904ce5 | 19acfe6a6670d989c2e9897b267ea823394fc51c | /1st/cblock.h | 91ca09ec9ed6fc0655e00f6e3bca5ec557e2a36e | [] | no_license | Avispa666/cpp_tasks | 175173975b2942c5a3a1ae540a44c6ffea34820b | 116eb737af8bd992f523d4cc447a497d1687a0f0 | refs/heads/master | 2020-03-18T18:07:54.431692 | 2018-05-27T18:53:55 | 2018-05-27T18:53:55 | 135,073,123 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 177 | h | //
// Created by avispa on 26/5/2018.
//
#ifndef CBLOCK_H
#define CBLOCK_H
#include <vector>
struct CBlock {
std::vector<unsigned char> data, hash;
};
#endif // CBLOCK_H
| [
"i.a.mavrin@gmail.com"
] | i.a.mavrin@gmail.com |
d7c1d8214f3ff95d667540597fa90d52c72fc478 | 2a60eb5064dcc45824fe7a1ea073c35647c5407f | /src/modules/voxel/tests/AbstractVoxelTest.h | b2348dda177a6da1a1e0159ae29fc03fdba575ed | [] | no_license | Victorique-GOSICK/engine | a20627a34191c4cdcd6f71acb7970e9176c55214 | a7828cfc610530080dafb70c5664794bde2aaac7 | refs/heads/master | 2021-07-20T00:04:28.543152 | 2017-10-27T18:42:29 | 2017-10-27T18:42:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,272 | h | /**
* @file
*/
#include "core/tests/AbstractTest.h"
#include "voxel/polyvox/PagedVolumeWrapper.h"
#include "voxel/polyvox/PagedVolume.h"
#include "voxel/polyvox/RawVolume.h"
#include "voxel/polyvox/Voxel.h"
#include "voxel/WorldContext.h"
#include "voxel/MaterialColor.h"
#include "voxel/Constants.h"
#include "core/Random.h"
#include "core/Common.h"
namespace voxel {
inline bool operator==(const voxel::RawVolume& volume1, const voxel::RawVolume& volume2) {
for (int i = 0; i < 3; ++i) {
if (volume1.mins()[i] != volume2.mins()[i]) {
return false;
}
if (volume1.maxs()[i] != volume2.maxs()[i]) {
return false;
}
}
const voxel::Region& region = volume1.region();
const int32_t lowerX = region.getLowerX();
const int32_t lowerY = region.getLowerY();
const int32_t lowerZ = region.getLowerZ();
const int32_t upperX = region.getUpperX();
const int32_t upperY = region.getUpperY();
const int32_t upperZ = region.getUpperZ();
for (int32_t z = lowerZ; z <= upperZ; ++z) {
for (int32_t y = lowerY; y <= upperY; ++y) {
for (int32_t x = lowerX; x <= upperX; ++x) {
const glm::ivec3 pos(x, y, z);
const voxel::Voxel& voxel1 = volume1.voxel(pos);
const voxel::Voxel& voxel2 = volume2.voxel(pos);
if (!voxel1.isSame(voxel2)) {
return false;
}
}
}
}
return true;
}
inline ::std::ostream& operator<<(::std::ostream& os, const voxel::Region& region) {
return os << "region["
<< "center(" << glm::to_string(region.getCentre()) << "), "
<< "mins(" << glm::to_string(region.getLowerCorner()) << "), "
<< "maxs(" << glm::to_string(region.getUpperCorner()) << ")"
<< "]";
}
inline ::std::ostream& operator<<(::std::ostream& os, const voxel::Voxel& voxel) {
return os << "voxel[" << voxel::VoxelTypeStr[(int)voxel.getMaterial()] << ", " << (int)voxel.getColor() << "]";
}
inline ::std::ostream& operator<<(::std::ostream& os, const voxel::RawVolume& volume) {
const voxel::Region& region = volume.region();
os << "volume[" << region;
const int threshold = 6;
if (volume.depth() <= threshold && volume.width() <= threshold && volume.height() <= threshold) {
const int32_t lowerX = region.getLowerX();
const int32_t lowerY = region.getLowerY();
const int32_t lowerZ = region.getLowerZ();
const int32_t upperX = region.getUpperX();
const int32_t upperY = region.getUpperY();
const int32_t upperZ = region.getUpperZ();
os << "\n";
for (int32_t z = lowerZ; z <= upperZ; ++z) {
for (int32_t y = lowerY; y <= upperY; ++y) {
for (int32_t x = lowerX; x <= upperX; ++x) {
const glm::ivec3 pos(x, y, z);
const voxel::Voxel& voxel = volume.voxel(pos);
os << x << ", " << y << ", " << z << ": " << voxel << "\n";
}
}
}
}
os << "]";
return os;
}
class AbstractVoxelTest: public core::AbstractTest {
protected:
class Pager: public PagedVolume::Pager {
AbstractVoxelTest* _test;
public:
Pager(AbstractVoxelTest* test) :
_test(test) {
}
bool pageIn(PagedVolume::PagerContext& ctx) override {
return _test->pageIn(ctx.region, ctx.chunk);
}
void pageOut(PagedVolume::Chunk* chunk) override {
}
};
virtual bool pageIn(const Region& region, const PagedVolume::ChunkPtr& chunk) {
const glm::vec3 center(region.getCentre());
for (int z = 0; z < region.getDepthInVoxels(); ++z) {
for (int y = 0; y < region.getHeightInVoxels(); ++y) {
for (int x = 0; x < region.getWidthInVoxels(); ++x) {
const glm::vec3 pos(x, y, z);
const float distance = glm::distance(pos, center);
Voxel uVoxelValue;
if (distance <= 30.0f) {
uVoxelValue = createRandomColorVoxel(VoxelType::Grass);
}
chunk->setVoxel(x, y, z, uVoxelValue);
}
}
}
return true;
}
Pager _pager;
PagedVolume _volData;
PagedVolumeWrapper _ctx;
core::Random _random;
long _seed = 0;
const voxel::Region _region { glm::ivec3(0), glm::ivec3(63) };
AbstractVoxelTest() :
_pager(this), _volData(&_pager, 128 * 1024 * 1024, 64), _ctx(nullptr, nullptr, voxel::Region()) {
}
public:
void SetUp() override {
_volData.flushAll();
core::AbstractTest::SetUp();
ASSERT_TRUE(voxel::initDefaultMaterialColors());
_random.setSeed(_seed);
_ctx = PagedVolumeWrapper(&_volData, _volData.chunk(_region.getCentre()), _region);
}
};
}
| [
"martin.gerhardy@gmail.com"
] | martin.gerhardy@gmail.com |
de5591ae441f7342a67154ebee7cd974934ee6f2 | a8008546990743ed68f8f5ac073347bf7f40c6da | /cpp/RepeatedSubstringPattern.cpp | ce01c2ffbc73cb011d39ca2a041b322049049f07 | [
"CC0-1.0",
"MIT"
] | permissive | Zalasanjay/hacktoberfest2020-1 | 90f186fc3934e38a1e619f599410528288af20ec | c26ec736510d8ce7b83a68097ef4254e428f56e3 | refs/heads/master | 2023-01-14T08:51:40.734859 | 2020-10-30T17:43:59 | 2020-10-30T17:43:59 | 308,698,645 | 1 | 0 | MIT | 2020-10-30T17:44:00 | 2020-10-30T17:24:38 | Jupyter Notebook | UTF-8 | C++ | false | false | 494 | cpp | // Link to the problem : https://leetcode.com/problems/repeated-substring-pattern/
// Problem Name : Repeated Substring Pattern
// Solution Method : Concatenation + Find()
class Solution {
public:
bool repeatedSubstringPattern(string s) {
string x = s;
s = s + s;
s = s.substr(1, s.length() - 2);
size_t found = s.find(x);
if (found != string::npos) {
return true;
}
else {
return false;
}
}
};
| [
"noreply@github.com"
] | noreply@github.com |
9d7cf6df4531a4df865184dabd373c21a5dfd8d6 | d7064f934212f95b897afde0dad4dacafe393aaa | /src/base58.h | cd3a119f4472d8849eb133a43444369cec52e449 | [
"MIT"
] | permissive | mirzaei-ce/core-javabit | 0e382eea4e3e688aac531088818caa41bc84590d | bfc1f145268455ca788c8a0b70fb3f054e4287f9 | refs/heads/master | 2021-07-23T12:13:04.992774 | 2017-11-02T12:27:50 | 2017-11-02T12:27:50 | 109,261,835 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,770 | h | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
/**
* Why base-58 instead of standard base-64 encoding?
* - Don't want 0OIl characters that look the same in some fonts and
* could be used to create visually identical looking data.
* - A string with non-alphanumeric characters is not as easily accepted as input.
* - E-mail usually won't line-break if there's no punctuation to break at.
* - Double-clicking selects the whole string as one word if it's all alphanumeric.
*/
#ifndef JAVABIT_BASE58_H
#define JAVABIT_BASE58_H
#include "chainparams.h"
#include "key.h"
#include "pubkey.h"
#include "script/script.h"
#include "script/standard.h"
#include "support/allocators/zeroafterfree.h"
#include <string>
#include <vector>
/**
* Encode a byte sequence as a base58-encoded string.
* pbegin and pend cannot be NULL, unless both are.
*/
std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend);
/**
* Encode a byte vector as a base58-encoded string
*/
std::string EncodeBase58(const std::vector<unsigned char>& vch);
/**
* Decode a base58-encoded string (psz) into a byte vector (vchRet).
* return true if decoding is successful.
* psz cannot be NULL.
*/
bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet);
/**
* Decode a base58-encoded string (str) into a byte vector (vchRet).
* return true if decoding is successful.
*/
bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet);
/**
* Encode a byte vector into a base58-encoded string, including checksum
*/
std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn);
/**
* Decode a base58-encoded string (psz) that includes a checksum into a byte
* vector (vchRet), return true if decoding is successful
*/
inline bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet);
/**
* Decode a base58-encoded string (str) that includes a checksum into a byte
* vector (vchRet), return true if decoding is successful
*/
inline bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet);
/**
* Base class for all base58-encoded data
*/
class CBase58Data
{
protected:
//! the version byte(s)
std::vector<unsigned char> vchVersion;
//! the actually encoded data
typedef std::vector<unsigned char, zero_after_free_allocator<unsigned char> > vector_uchar;
vector_uchar vchData;
CBase58Data();
void SetData(const std::vector<unsigned char> &vchVersionIn, const void* pdata, size_t nSize);
void SetData(const std::vector<unsigned char> &vchVersionIn, const unsigned char *pbegin, const unsigned char *pend);
public:
bool SetString(const char* psz, unsigned int nVersionBytes = 1);
bool SetString(const std::string& str);
std::string ToString() const;
int CompareTo(const CBase58Data& b58) const;
bool operator==(const CBase58Data& b58) const { return CompareTo(b58) == 0; }
bool operator<=(const CBase58Data& b58) const { return CompareTo(b58) <= 0; }
bool operator>=(const CBase58Data& b58) const { return CompareTo(b58) >= 0; }
bool operator< (const CBase58Data& b58) const { return CompareTo(b58) < 0; }
bool operator> (const CBase58Data& b58) const { return CompareTo(b58) > 0; }
};
/** base58-encoded Javabit addresses.
* Public-key-hash-addresses have version 0 (or 111 testnet).
* The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key.
* Script-hash-addresses have version 5 (or 196 testnet).
* The data vector contains RIPEMD160(SHA256(cscript)), where cscript is the serialized redemption script.
*/
class CJavabitAddress : public CBase58Data {
public:
bool Set(const CKeyID &id);
bool Set(const CScriptID &id);
bool Set(const CTxDestination &dest);
bool IsValid() const;
bool IsValid(const CChainParams ¶ms) const;
CJavabitAddress() {}
CJavabitAddress(const CTxDestination &dest) { Set(dest); }
CJavabitAddress(const std::string& strAddress) { SetString(strAddress); }
CJavabitAddress(const char* pszAddress) { SetString(pszAddress); }
CTxDestination Get() const;
bool GetKeyID(CKeyID &keyID) const;
bool GetIndexKey(uint160& hashBytes, int& type) const;
bool IsScript() const;
};
/**
* A base58-encoded secret key
*/
class CJavabitSecret : public CBase58Data
{
public:
void SetKey(const CKey& vchSecret);
CKey GetKey();
bool IsValid() const;
bool SetString(const char* pszSecret);
bool SetString(const std::string& strSecret);
CJavabitSecret(const CKey& vchSecret) { SetKey(vchSecret); }
CJavabitSecret() {}
};
template<typename K, int Size, CChainParams::Base58Type Type> class CJavabitExtKeyBase : public CBase58Data
{
public:
void SetKey(const K &key) {
unsigned char vch[Size];
key.Encode(vch);
SetData(Params().Base58Prefix(Type), vch, vch+Size);
}
K GetKey() {
K ret;
if (vchData.size() == Size) {
//if base58 encouded data not holds a ext key, return a !IsValid() key
ret.Decode(&vchData[0]);
}
return ret;
}
CJavabitExtKeyBase(const K &key) {
SetKey(key);
}
CJavabitExtKeyBase(const std::string& strBase58c) {
SetString(strBase58c.c_str(), Params().Base58Prefix(Type).size());
}
CJavabitExtKeyBase() {}
};
typedef CJavabitExtKeyBase<CExtKey, 74, CChainParams::EXT_SECRET_KEY> CJavabitExtKey;
typedef CJavabitExtKeyBase<CExtPubKey, 74, CChainParams::EXT_PUBLIC_KEY> CJavabitExtPubKey;
#endif // JAVABIT_BASE58_H
| [
"mirzaei@ce.sharif.edu"
] | mirzaei@ce.sharif.edu |
9c24f878bc36bea8d62b42d937a2c98c3b788bc3 | e4b0bdedd0709dfa9505757163dae094a68d9a5a | /Codeforces/467b.cpp | 2910e9f7f91cdcae04b1874af94ead91ccdaf6dc | [] | no_license | torikazi/Competitive-Programming | 4543fffe87cf8f3ea384a6c2aaa04c9e90f31036 | dac444f6630e7918a3fd423d60bf53137414426a | refs/heads/master | 2021-04-06T20:44:05.539366 | 2018-10-05T00:53:56 | 2018-10-05T00:53:56 | 125,230,160 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 387 | cpp | #include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a[1010];
int main()
{
ll n,m,k,i,j,x,cnt,c,dif=0;
cin>>n>>m>>k;
for(i=0;i<=m;i++)
{
cin>>a[i];
}
for(i=0,dif=0;i<m;i++)
{
x=a[i]^a[m];
for(j=0,cnt=0;j<n;j++)
{
if(x&(1<<j)) cnt++;
}
if(cnt<=k) dif++;
}
cout<<dif<<endl;
}
| [
"kazisratori@gmail.com"
] | kazisratori@gmail.com |
f9f5eecf71712cbce45f67a26aa217dcfccaa717 | ecc574079122277e1b75052808b3e01955b050d8 | /LeetCode/My-LeetCode-Program/TwoSum/TwoSum/源.cpp | c9ea58c6cd42acca84a89843ca0e6c4c971241b3 | [] | no_license | southernriver/My-LeetCode-Program | 695b4a8e903449090aaf34ab2d7f71a7aee80331 | c461ff836e92513acf89720a3576bfc2e5f462f5 | refs/heads/master | 2021-01-09T20:23:14.774687 | 2016-08-09T09:55:23 | 2016-08-09T09:55:23 | 65,281,254 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 825 | cpp | #include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> twoSum(vector<int> &num, int target){
unordered_map<int,int> mapping;
vector<int> result = {};
for (int i = 0; i<num.size(); i++){
mapping[num[i]]=i;
}
for (int i = 0; i < num.size(); i++){
const int gap = target-num[i];
if (mapping.find(gap) != mapping.end() && mapping[gap] != i)
{
result.push_back(i);
result.push_back(mapping[gap]);
break;
}
}
return result;
}
int main(){
vector<int> num = {2,7,11,3};
int target=9;
vector<int> res = twoSum(num,target);
for (auto i:res)
cout<<i<<endl;
system("pause");
return 0;
} | [
"southernriver@163.com"
] | southernriver@163.com |
8766fda1c84aba27db12a35934185b8b38d76618 | 8192a7ebf272e46f3bae2f0ca49877218fd485c2 | /lab4 q5.cpp | a822eb203ce9bdafffe1e4672909368f205570ff | [] | no_license | Satyasaibhoi/programing4 | 5b100b94d2c4ad199ef74b69d17701e9558ee532 | a3ddd36a3a8396cde9797f9dadb2d5e966f3bd65 | refs/heads/master | 2021-07-10T02:25:33.421120 | 2017-10-09T09:34:38 | 2017-10-09T09:34:38 | 106,026,894 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,165 | cpp | #include <iostream>
#include <cmath>
using namespace std;
int Prime(int num)
{
int count=0;
for(int i=2;i<num;i++)
{
if(num%i==0)
count++;
}
if(count==0)
cout<<"\n \n"<<num<<" is a prime number.\n";
else
cout<<"\n \n"<<num<<" is not a prime number. \n";
return 0;
}
//Function to check Armstrong
int Armstrong(int num)
{
int num1, rem, sum = 0,dig;
num1 = num;
while(num1 != 0)
{
dig = num1 % 10;
sum += pow(dig,3);
num1 /= 10;
}
if(sum == num)
cout <<num<< " is an Armstrong number.\n";
else
cout <<num<< " is not an Armstrong number.\n";
return 0;
}
/*Function to check whether a number is Perfect number or not.*/
int Perfect(int num)
{
int i=1,sum=0;
while(i<num)
{
if(num%i==0)
sum=sum+i;
i++;
}
if(sum==num)
cout << num << " is a perfect number\n";
else
cout << num << " is not a perfect number \n";
return 0;
}
int main()
{
int num1;
cout<<"\nProgram to check whether a number is Prime number, Armstrong or Perfect.";
cout<<"\nENTER THE NUMBER: ";
cin>>num1;
Prime(num1);
Perfect(num1);
Armstrong(num1);
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
12cdd4f7ddd8f4b5046e965914b675414b0809f0 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5686275109552128_0/C++/ksun48/B.cpp | d46988559e8f8e1cc164187473f4da7d85055c52 | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 653 | cpp | #include <cstdio>
#include <cstdlib>
#include <cassert>
#include <iostream>
using namespace std;
typedef long long LL;
main() {
FILE *fin = freopen("B-small.in", "r", stdin);
assert( fin!=NULL );
FILE *fout = freopen("B-small.out", "w", stdout);
int T;
cin >> T;
for(int t = 1; t <= T; t++){
cout << "Case #" << t << ": ";
int n;
cin >> n;
int stuff[n];
for(int i = 0; i < n; i++) cin >> stuff[i];
int answer = 1000;
for(int i = 1; i <= 1000; i++){
int cur = i;
for(int j = 0; j < n; j++){
cur += (stuff[j]-1)/i;
}
answer = min(answer, cur);
}
cout << answer << endl;
}
exit(0);
} | [
"eewestman@gmail.com"
] | eewestman@gmail.com |
8dc297cff907476a248f3ed1bf9546f1f1552922 | 548140c7051bd42f12b56e8bb826074609c8b72e | /Engine/Code/Engine/Renderer/Sampler.hpp | 807f12aeb597c57716493c6d6e27151d196be91e | [] | no_license | etrizzo/PersonalEngineGames | 3c55323ae730b6499a2d287c535c8830e945b917 | 6ef9db0fd4fd34c9e4e2f24a8b58540c075af280 | refs/heads/master | 2021-06-16T22:01:57.973833 | 2021-01-26T03:54:58 | 2021-01-26T03:54:58 | 135,343,718 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 258 | hpp | #pragma once
#include "Engine/Core/EngineCommon.hpp"
#include "Engine/Math/Renderer.hpp"
class Sampler{
public:
Sampler();
~Sampler();
void Destroy();
bool Create();
GLuint GetHandle() const { return m_samplerHandle; };
GLuint m_samplerHandle;
}; | [
"emilytrizzo@gmail.com"
] | emilytrizzo@gmail.com |
71100fe4741af58d8b967803fb5492b72c8774eb | 90e96d78a7610fe19d478958be34e5542e1cfb61 | /examenes/pl04/grupo1/p1/p1_mmap.cpp | b881bde716491db6125ef0bd6f5a1265dfb81c6c | [] | no_license | cslucano/CC361_2013II | a2b902c56912d2d18858194f5e45301d02ba8f53 | e3a94afbcf76840bcb80f2f59dabb0784701c7d8 | refs/heads/master | 2020-04-14T01:10:08.584781 | 2013-12-08T19:20:58 | 2013-12-08T19:20:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,230 | cpp | #include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <time.h>
using namespace std;
#define BSIZE 1024
int main(int argc, char *argv[]){
if(argc != 2){
cerr << "Usar: " << argv[0] <<"archivoingreso" << endl;
return -1;
}
int fd_in = open(argv[1], O_RDONLY);
if(fd_in < 0){
perror(argv[1]);
return -1;
}
struct stat info;
if(fstat(fd_in, &info) < 0){
perror("Error status de archivo de ingreso");
return -1;
}
void *addr_in = mmap(0, info.st_size, PROT_READ, MAP_SHARED, fd_in, 0);
if(addr_in == MAP_FAILED){
perror("Error mapeando archivo de ingreso");
return -1;
}
char seq[10] = "\x75\x6e\x69\x66\x63";
int t = 0;
bool f2 = 0;
char *c= (char *)addr_in;
while(t < info.st_size)
{
f2 = 1;
for(int j=0, k=t; j<5; j++, k++)
{
if(c[k] != seq[j])
{
f2 = 0;
break;
}
}
if(f2) break;
t++;
}
cout << "MMAP: " << (f2?"YES":"NO") << endl;
close(fd_in);
return 0;
}
| [
"cslucano@gmail.com"
] | cslucano@gmail.com |
39498a7ebcd859e9cfe78316c4ef38a5bd260246 | 00f6012d89f7d88897abee847980f82c2b5e7e83 | /Allegris 2/BlockFactory.h | 9f50da48047c33df51ecae692901862040399d05 | [] | no_license | Gnash/allegris | 1af2e343512f74bac05ff3aeb474afa227bebcb8 | 4297e884257de563d9dd27f3d915ef187a7ffc05 | refs/heads/master | 2020-04-10T03:58:34.394082 | 2013-07-17T23:30:34 | 2013-07-17T23:30:34 | 10,405,464 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 316 | h | #pragma once
#include "Block.h"
#include "Block_L.h"
#include "Block_O.h"
#include "Block_L_Mirrored.h"
#include "Block_S.h"
#include "Block_S_Mirrored.h"
#include "Block_I.h"
#include "Block_T.h"
class BlockFactory
{
public:
BlockFactory(void);
virtual ~BlockFactory(void);
Block* createRandomBlock(void);
};
| [
"Daniel.Wilken@live.com"
] | Daniel.Wilken@live.com |
a6c0398504e7d1638d91d41a7bf83a25a955d863 | 297497957c531d81ba286bc91253fbbb78b4d8be | /toolkit/crashreporter/google-breakpad/src/processor/stackwalker_arm.h | 27a70e96805e9c09b49767899f97eda9c04ffa69 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"LicenseRef-scancode-unicode-mappings"
] | permissive | marco-c/gecko-dev-comments-removed | 7a9dd34045b07e6b22f0c636c0a836b9e639f9d3 | 61942784fb157763e65608e5a29b3729b0aa66fa | refs/heads/master | 2023-08-09T18:55:25.895853 | 2023-08-01T00:40:39 | 2023-08-01T00:40:39 | 211,297,481 | 0 | 0 | NOASSERTION | 2019-09-29T01:27:49 | 2019-09-27T10:44:24 | C++ | UTF-8 | C++ | false | false | 1,379 | h |
#ifndef PROCESSOR_STACKWALKER_ARM_H__
#define PROCESSOR_STACKWALKER_ARM_H__
#include "google_breakpad/common/breakpad_types.h"
#include "google_breakpad/common/minidump_format.h"
#include "google_breakpad/processor/stackwalker.h"
namespace google_breakpad {
class CodeModules;
class StackwalkerARM : public Stackwalker {
public:
StackwalkerARM(const SystemInfo* system_info,
const MDRawContextARM* context,
int fp_register,
MemoryRegion* memory,
const CodeModules* modules,
StackFrameSymbolizer* frame_symbolizer);
void SetContextFrameValidity(int valid) { context_frame_validity_ = valid; }
private:
virtual StackFrame* GetContextFrame();
virtual StackFrame* GetCallerFrame(const CallStack* stack,
bool stack_scan_allowed);
StackFrameARM* GetCallerByCFIFrameInfo(const vector<StackFrame*> &frames,
CFIFrameInfo* cfi_frame_info);
StackFrameARM* GetCallerByFramePointer(const vector<StackFrame*> &frames);
StackFrameARM* GetCallerByStackScan(const vector<StackFrame*> &frames);
const MDRawContextARM* context_;
int fp_register_;
int context_frame_validity_;
};
}
#endif
| [
"mcastelluccio@mozilla.com"
] | mcastelluccio@mozilla.com |
682443b80a7b11c22a6db72f5462116c3d8e2e12 | 7be8f687743d0832ff67c07070bf8f34a0af4da9 | /은행 계좌/account.cpp | 6ff756d54213b9097871e36a83657b335b88779a | [] | no_license | jhoon12/study | 2a5cb4785a87bd0be710a35b18be23da89a99f4f | 1bff7f6415adb0c93f08dec2328b1560ebc5ce3c | refs/heads/master | 2020-08-27T09:15:06.485671 | 2019-12-30T14:10:54 | 2019-12-30T14:10:54 | 217,313,459 | 1 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 704 | cpp | #include "account.h"
#include<iostream>
using namespace std;
#include <string.h>
int account::GetAccID()
{
return accID;
}
account::account(int ID, int money,char* name)
{
accID = ID;
balance = money;
cusName = new char[strlen(name) + 1];
strcpy(cusName, name);
//cusName = name;
}
void account::showAccInfo()
{
cout << "°èÁÂÁ¤º¸" << endl;
cout << "°èÁÂID: " << accID << endl;
cout << "À̸§: " << cusName << endl;
cout << "ÀÜ ¾×: " << balance << endl;
}
void account::Deposit(int money)
{
balance += money;
}
int account::Withdraw(int money){
if(balance < money)
return 0;
else {
balance -= money;
return money;
}
}
account::~account()
{
delete[]cusName;
}
| [
"yukihoon12@naver.com"
] | yukihoon12@naver.com |
b227a50f7346bcd179ab88facbad241ec7fb5f27 | e51e8a6a04d0e57901cca3d866f33e54736053c9 | /CodeForces/1330/b/75426357_wrong_answer_0.cpp | 2df9719835c583c4e3171deadc3bb3c1a40732d1 | [] | no_license | Nipun4338/Solved-Programming-Problems | 7cb638112ef3d135fc6594eac9c6e79c5b0a0592 | 401a9ecc3157b8b4aa275ceb8c67f4e90213bccd | refs/heads/master | 2023-05-17T02:22:57.007396 | 2021-06-10T17:08:10 | 2021-06-10T17:08:10 | 283,442,802 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,810 | cpp | #include<bits/stdc++.h>
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb emplace_back
#define em emplace
#define pb push_back
#define Mp make_pair
#define ff first
#define ss second
#define mod 1000000007
const double pi = 3.14159265358979323846;
typedef long long ll;
using namespace std;
const int M = (int)(2e6 + 239);
int getnum(string a)
{
int i,p=0;
rep0(i,a.size())
{
p*=10;
p+=a[i]-'0';
}
return p;
}
int main()
{
fast
ll a,b,c;
cin>>a;
while(a--)
{
cin>>b;
vector<ll>v,v2;
multiset<ll>s1;
set<ll>s2,ss;
ll flag3=0;
map<ll,ll>m;
ll top=-1;
for(int i=0; i<b; i++)
{
cin>>c;
v.push_back(c);
s1.insert(c);
ss.insert(c);
m[c]++;
}
vector<ll>v1(all(ss));
for(int i=0; i<v1.size(); i++)
{
if(s1.count(v1[i])>2)
{
flag3=1;
break;
}
}
for(int i=0; i<v1[v1.size()-1]-1; i++)
{
if(m[i+1]<m[i+2])
{
flag3=1;
break;
}
}
if(flag3)
{
cout<<0<<endl;
continue;
}
set<ll>s;
ll temp=-1,flag=0,temp1=-1,temp2=-1;
for(int i=0; i<b; i++)
{
temp1=max(v[i],temp1);
if(s.find(v[i])==s.end())
{
s.insert(v[i]);
}
else
{
temp=i;
break;
}
}
vector<ll>vn(s.begin(),s.end());
set<ll>sx;
for(int i=temp1; i<v.size(); i++)
{
temp2=max(temp2,v[i]);
sx.insert(v[i]);
}
vector<ll>vn1(sx.begin(),sx.end());
if(temp!=vn[s.size()-1] || v.size()-temp!=vn1[sx.size()-1])
{
flag=1;
}
set<ll>s3;
ll temp3=-1;
temp1=-1;
temp2=-1;
ll flag2=0;
for(int i=b-1; i>=0; i--)
{
temp1=max(temp1,v[i]);
if(s3.find(v[i])==s3.end())
{
s3.insert(v[i]);
}
else
{
temp3=i;
break;
}
}
set<ll>sy;
for(int i=temp3; i>=0; i--)
{
temp2=max(temp2,v[i]);
sy.insert(v[i]);
}
vector<ll>vm(s3.begin(),s3.end());
vector<ll>vm1(sy.begin(),sy.end());
if(temp!=vn[s.size()-1] || v.size()-temp!=vn1[sy.size()-1])
{
flag=1;
}
if(v.size()-temp3-1!=vm[s3.size()-1] || temp3+1!=vm1[sy.size()-1])
{
flag2=1;
}
if(flag && flag2)
{
cout<<"0"<<endl;
}
else
{
if(!flag && !flag2 && temp!=temp3+1)
{
cout<<2<<endl;
cout<<temp<<" "<<v.size()-temp<<endl;
cout<<temp3+1<<" "<<v.size()-temp3-1<<endl;
}
else
{
cout<<1<<endl;
if(flag2)
{
cout<<temp<<" "<<v.size()-temp<<endl;
}
else
{
cout<<temp3+1<<" "<<v.size()-temp3-1<<endl;
}
}
}
}
}
| [
"49658560+Nipun4338@users.noreply.github.com"
] | 49658560+Nipun4338@users.noreply.github.com |
f004a7fce95b2358278c9437e3540519312c9341 | 46065da1bbff299072711dd00a567dc65f8f4940 | /demo/mainwindow.cpp | 67627e8922b6c3a7dc03c260058709279873a73c | [
"MIT"
] | permissive | facontidavide/Meanshift | 0459850d7e20c93651f9945ae2888af14c290987 | c0e01610178f854ce9fb301d613f63076f28f24d | refs/heads/master | 2021-07-10T01:17:00.795808 | 2017-10-09T15:18:26 | 2017-10-09T15:18:26 | 106,300,192 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,603 | cpp | #include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
for( QCustomPlot* plot: { ui->plotA, ui->plotB})
{
plot->addGraph();
plot->graph(0)->setLineStyle(QCPGraph::lsNone);
plot->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 1));
plot->xAxis->setRange(0, 11);
plot->yAxis->setRange(0, 11);
}
createPoints( 50*0.002 );
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::createPoints(double noise)
{
std::random_device rd;
std::mt19937 e2(rd());
std::normal_distribution<> dist(0.0, noise);
_points_x.clear();
_points_y.clear();
for (int x=1; x<=10; x++)
{
for (int y=1; y<=10; y++)
{
for (int i=0; i<40; i++)
{
_points_x.push_back( x + dist(e2) );
_points_y.push_back( y + dist(e2) );
}
}
}
ui->plotA->graph(0)->setData(_points_x, _points_y);
ui->plotA->replot();
updateMeanShift();
}
void MainWindow::updateMeanShift()
{
MeanShift2D::PointsVector points, shifted;
points.resize(_points_x.size());
for(int i=0; i<_points_x.size(); i++)
{
points[i] = { _points_x[i], _points_y[i] };
}
_meanshift.setMeanshiftEps( ui->epsilonSpinbox->value() );
shifted = _meanshift.meanshift(points, ui->kernelSpinbox->value() );
_shifted_x.clear();
_shifted_y.clear();
for(int i=0; i<shifted.size(); i++)
{
_shifted_x.push_back( shifted[i][0] );
_shifted_y.push_back( shifted[i][1] );
}
ui->plotB->graph(0)->setData(_shifted_x, _shifted_y);
ui->plotB->replot();
}
void MainWindow::on_horizontalSlider_sliderMoved(int position)
{
double pos = static_cast<double>(position) * 0.002;
createPoints(pos);
}
void MainWindow::on_epsilonSpinbox_valueChanged(double)
{
updateMeanShift();
}
void MainWindow::on_kernelSpinbox_valueChanged(double)
{
updateMeanShift();
}
void MainWindow::on_radioGaussian_toggled(bool checked)
{
if(checked) {
_meanshift.setKernelFunction( GaussianKernel );
updateMeanShift();
}
}
void MainWindow::on_radioQuartic_toggled(bool checked)
{
if(checked){
_meanshift.setKernelFunction( QuarticKernel );
updateMeanShift();
}
}
void MainWindow::on_radioParabolic_toggled(bool checked)
{
if(checked){
_meanshift.setKernelFunction( ParabolicKernel );
updateMeanShift();
}
}
| [
"davide.faconti@gmail.com"
] | davide.faconti@gmail.com |
82baac71741b0a0522deb41ef3fdcd9aec5ee682 | 641fa8341d8c436ad24945bcbf8e7d7d1dd7dbb2 | /chrome/browser/ui/libgtkui/gtk_status_icon.h | e4e0da40981ca58964dfdcbd3fc0f730c9c09ec1 | [
"BSD-3-Clause"
] | permissive | massnetwork/mass-browser | 7de0dfc541cbac00ffa7308541394bac1e945b76 | 67526da9358734698c067b7775be491423884339 | refs/heads/master | 2022-12-07T09:01:31.027715 | 2017-01-19T14:29:18 | 2017-01-19T14:29:18 | 73,799,690 | 4 | 4 | BSD-3-Clause | 2022-11-26T11:53:23 | 2016-11-15T09:49:29 | null | UTF-8 | C++ | false | false | 1,734 | h | // Copyright 2014 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 CHROME_BROWSER_UI_LIBGTKUI_GTK_STATUS_ICON_H_
#define CHROME_BROWSER_UI_LIBGTKUI_GTK_STATUS_ICON_H_
#include <memory>
#include "base/macros.h"
#include "base/strings/string16.h"
#include "chrome/browser/ui/libgtkui/gtk_signal.h"
#include "ui/base/glib/glib_integers.h"
#include "ui/base/glib/glib_signal.h"
#include "ui/views/linux_ui/status_icon_linux.h"
typedef struct _GtkStatusIcon GtkStatusIcon;
namespace gfx {
class ImageSkia;
}
namespace ui {
class MenuModel;
}
namespace libgtkui {
class AppIndicatorIconMenu;
// Status icon implementation which uses the system tray X11 spec (via
// GtkStatusIcon).
class Gtk2StatusIcon : public views::StatusIconLinux {
public:
Gtk2StatusIcon(const gfx::ImageSkia& image, const base::string16& tool_tip);
~Gtk2StatusIcon() override;
// Overridden from views::StatusIconLinux:
void SetImage(const gfx::ImageSkia& image) override;
void SetToolTip(const base::string16& tool_tip) override;
void UpdatePlatformContextMenu(ui::MenuModel* menu) override;
void RefreshPlatformContextMenu() override;
private:
CHROMEG_CALLBACK_0(Gtk2StatusIcon, void, OnClick, GtkStatusIcon*);
CHROMEG_CALLBACK_2(Gtk2StatusIcon,
void,
OnContextMenuRequested,
GtkStatusIcon*,
guint,
guint);
GtkStatusIcon* gtk_status_icon_;
std::unique_ptr<AppIndicatorIconMenu> menu_;
DISALLOW_COPY_AND_ASSIGN(Gtk2StatusIcon);
};
} // namespace libgtkui
#endif // CHROME_BROWSER_UI_LIBGTKUI_GTK_STATUS_ICON_H_
| [
"xElvis89x@gmail.com"
] | xElvis89x@gmail.com |
bfa915bc9b89162ba583ee9886c386fb09133dfc | 77908a9733330da86621515538e062e9ef12a62b | /WebSocketServer/build/debug/moc_queries.cpp | 3b5a92b78b7752665ae76ba1cdcaec2d6c73e03c | [] | no_license | d1m96/EPIC | fafdc807c2a9f2b4503fb1c874c494622935f037 | dde15fefb582d76161c043ba6261a18eb1697ac8 | refs/heads/master | 2021-01-13T10:28:35.941424 | 2016-12-02T02:02:28 | 2016-12-02T02:02:28 | 70,057,108 | 0 | 0 | null | 2016-10-30T06:30:35 | 2016-10-05T12:14:09 | C++ | UTF-8 | C++ | false | false | 2,615 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'queries.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.7.0)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../queries.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'queries.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.7.0. 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
struct qt_meta_stringdata_Query_t {
QByteArrayData data[1];
char stringdata0[6];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_Query_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_Query_t qt_meta_stringdata_Query = {
{
QT_MOC_LITERAL(0, 0, 5) // "Query"
},
"Query"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_Query[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
0 // eod
};
void Query::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
Q_UNUSED(_o);
Q_UNUSED(_id);
Q_UNUSED(_c);
Q_UNUSED(_a);
}
const QMetaObject Query::staticMetaObject = {
{ &QObject::staticMetaObject, qt_meta_stringdata_Query.data,
qt_meta_data_Query, qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};
const QMetaObject *Query::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *Query::qt_metacast(const char *_clname)
{
if (!_clname) return Q_NULLPTR;
if (!strcmp(_clname, qt_meta_stringdata_Query.stringdata0))
return static_cast<void*>(const_cast< Query*>(this));
return QObject::qt_metacast(_clname);
}
int Query::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QObject::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}
QT_END_MOC_NAMESPACE
| [
"noreply@github.com"
] | noreply@github.com |
550e8008af74cc4926db72c278280bb446cc6a89 | 8f726a302a527a43a656c6c8a791fe59a73b029d | /Chapter_4/4.12_Paths_with_Sum/brute_force.cpp | 7c11fc0d3a1831733f6a5f5081f1d292500ad3fb | [] | no_license | aaraki/CtCI | f9d22117e6bc495695839ddd193744e5ef1b18c7 | 6f904251f2e7def3f24e05034ce24341bfc9351f | refs/heads/master | 2022-04-18T15:31:33.421149 | 2020-03-09T02:38:23 | 2020-03-09T02:38:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,423 | cpp | #include <iostream>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
};
int findPath(TreeNode *root, int sum, int curr) {
if (root == nullptr) {
return 0;
}
curr += root->val;
int res = (curr == sum);
res += findPath(root->left, sum, curr) + findPath(root->right, sum, curr);
return res;
}
int pathSum(TreeNode *root, int sum) {
if (root == nullptr) {
return 0;
}
int res = findPath(root, sum, 0);
res += pathSum(root->left, sum) + pathSum(root->right, sum);
return res;
}
int main() {
/*
10
/ \
5 -3
/ \ \
3 2 11
/ \ \
3 -2 1
*/
TreeNode *root = new TreeNode(10);
root->left = new TreeNode(5);
root->right = new TreeNode(-3);
root->left->left = new TreeNode(3);
root->left->right = new TreeNode(2);
root->right->right = new TreeNode(11);
root->left->left->left = new TreeNode(3);
root->left->left->right = new TreeNode(-2);
root->left->right->right = new TreeNode(1);
cout << pathSum(root, 8) << endl; // 3
return 0;
} | [
"tatsuhiro.no.jones@gmail.com"
] | tatsuhiro.no.jones@gmail.com |
3b5b0cda88c5ce1dd2537277af8c6b8f7a44f66e | 865dff01380a5cc40526ce3844324ec339c09936 | /cpp_module_03/ex01/ScavTrap.hpp | 95eb78ef25645ecc3b25b16918a3f5be2af8437b | [] | no_license | hcanon42/Cpp-modules | fa7164ae8110d948f08f4007c869b2ec94ec3bc0 | 82bb8075c766c90cde8ddb05d63f4ac7e85a1915 | refs/heads/master | 2023-09-05T09:54:46.243720 | 2021-11-24T13:37:22 | 2021-11-24T13:37:22 | 430,711,604 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,604 | hpp | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hcanon <hcanon@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/14 16:00:46 by hcanon #+# #+# */
/* Updated: 2020/11/12 12:12:00 by user42 ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SCAVTRAP_HPP
# define SCAVTRAP_HPP
# include <iostream>
# include <stdlib.h>
class ScavTrap
{
private:
int _maxHP;
int _HP;
int _maxEnergy;
int _Energy;
int _level;
std::string _name;
int _meleeDamage;
int _distDamage;
int _armor;
public:
ScavTrap(std::string name);
ScavTrap(ScavTrap const &ref);
~ScavTrap();
ScavTrap &operator=(ScavTrap const &rhs);
void rangedAttack(std::string const &target) const;
void meleeAttack(std::string const &target) const;
void takeDamage(unsigned int amount);
void beRepaired(unsigned int amount);
void challengeNewcomer();
int getEnergy() const;
int getHP() const;
};
#endif
| [
"hcanon@student.42.fr"
] | hcanon@student.42.fr |
1baa287ccc292e49bfc0ccdc20ec1b9eca6c3932 | 4a5824917785ca11b9e0bfae1a8dbdb2dcfb34b7 | /assemble_poisson.hh | 0e5d08e61f21dcd592f5f4b64fc6e5e242b5d274 | [] | no_license | sswayamjyoti/Orbital-Free-Density-Functional-Theory | 89a0f35a03566166d767ac15c8295482f7458ae4 | ac0389afabd111a7f251cab1e0c794171c581da5 | refs/heads/master | 2022-09-28T01:49:33.492615 | 2020-06-08T03:21:02 | 2020-06-08T03:21:02 | 270,505,378 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,085 | hh |
template<class GV>
void P1Elements<GV>::assemble_poisson()
{
const int N = gv.size(dim);
double sum, u;
const LeafIndexSet& set = gv.indexSet();
const LeafIterator itend = gv.template end<0>();
// set sizes of A and b
PoissonMatrix.setSize(N, N, (N + 2*gv.size(dim-1)));
PoissonMatrix.setBuildMode(Matrix::random);
b.resize(N, false);
poisson_diagonal.setSize(N, N, (N + 2*gv.size(dim-1)));
poisson_diagonal.setBuildMode(Matrix::random);
for (int i = 0; i < N; i++)
PoissonMatrix.setrowsize(i,adjacencyPattern[i].size());
PoissonMatrix.endrowsizes();
// set sparsity pattern of A with the information gained in determineAdjacencyPattern
for (int i = 0; i < N; i++)
{
std::template set<int>::iterator setend = adjacencyPattern[i].end();
for (std::template set<int>::iterator setit = adjacencyPattern[i].begin();setit != setend; ++setit)
PoissonMatrix.addindex(i,*setit);
}
PoissonMatrix.endindices();
PoissonMatrix = 0.0;
// Poisson Diagonal (Preconditioner)
for (int i = 0; i < N; i++)
poisson_diagonal.setrowsize(i,adjacencyPattern[i].size());
poisson_diagonal.endrowsizes();
// set sparsity pattern of A with the information gained in determineAdjacencyPattern
for (int i = 0; i < N; i++)
{
std::template set<int>::iterator setend = adjacencyPattern[i].end();
for (std::template set<int>::iterator setit = adjacencyPattern[i].begin();setit != setend; ++setit)
poisson_diagonal.addindex(i,*setit);
}
poisson_diagonal.endindices();
// get a set of P1 shape functions
const P1ShapeFunctionSet<ctype,ctype,dim>& basis = P1ShapeFunctionSet<ctype,ctype,dim>::instance();
for (LeafIterator it = gv.template begin<0>(); it != itend; ++it)
{
// determine geometry type of the current element and get the matching reference element
Dune::GeometryType gt = it->type();
const Dune::template GenericReferenceElement<double,dim> &ref =
Dune::GenericReferenceElements<double,dim>::general(gt);
int vertexsize = ref.size(dim);
// get a quadrature rule of order one for the given geometry type
const Dune::QuadratureRule<ctype,dim>& rule = Dune::QuadratureRules<ctype,dim>::rule(gt,int_order);
for (typename Dune::QuadratureRule<ctype,dim>::const_iterator r = rule.begin();
r != rule.end() ; ++r)
{
// compute the jacobian inverse transposed to transform the gradients
Dune::FieldMatrix<double,dim,dim> jacInvTra = it->geometry().jacobianInverseTransposed(r->position());
// get the weight at the current quadrature point
double weight = r->weight();
// compute Jacobian determinant for the transformation formula
double detjac = it->geometry().integrationElement(r->position());
for (int i = 0; i < vertexsize; i++)
{
// compute transformed gradients
Dune::FieldVector<double,dim> grad1;
jacInvTra.mv(basis[i].evaluateGradient(r->position()),grad1);
for (int j = 0; j < vertexsize; j++)
{
Dune::FieldVector<double,dim> grad2;
jacInvTra.mv(basis[j].evaluateGradient(r->position()),grad2);
// gain global inidices of vertices i and j and update associated matrix entry
PoissonMatrix[set.subIndex(*it,i,dim)][set.subIndex(*it,j,dim)] += (-1/(4*pi))*(grad1*grad2)* weight*detjac;
}
}
}
// get a quadrature rule of order two for the given geometry type
/* const Dune::QuadratureRule<ctype,dim>& rule2 = Dune::QuadratureRules<ctype,dim>::rule(gt,int_order);
for (typename Dune::QuadratureRule<ctype,dim>::const_iterator r = rule2.begin();
r != rule2.end() ; ++r)
{
double weight = r->weight();
double detjac = it->geometry().integrationElement(r->position());
u = 0.0;
for (int i = 0 ; i<vertexsize; i++)
{
sum = basis[i].evaluateFunction(r->position())*u_i[set.subIndex(*it,i,dim)];
u += sum;
}
for (int i = 0 ; i<vertexsize; i++)
{
// evaluate the integrand of the right side
double fval = basis[i].evaluateFunction(r->position()) * pow(u,2);
b[set.subIndex(*it,i,dim)] += fval * weight * detjac;
}
} */
}
// b[atom_node] += -Ncore;
// b += atom_node;
// Dirichlet boundary conditions:
// replace lines in A related to Dirichlet vertices by trivial lines
for ( LeafIterator it = gv.template begin<0>() ; it != itend ; ++it)
{
const IntersectionIterator isend = gv.iend(*it);
for (IntersectionIterator is = gv.ibegin(*it) ; is != isend ; ++is)
{
// determine geometry type of the current element and get the matching reference element
Dune::GeometryType gt = it->type();
const Dune::template GenericReferenceElement<double,dim> &ref =
Dune::GenericReferenceElements<double,dim>::general(gt);
// check whether current intersection is on the boundary
if (is->boundary())
{
// traverse all vertices the intersection consists of
for (int i=0; i < ref.size(is->indexInInside(),1,dim); i++)
{
// and replace the associated line of A and b with a trivial one
int indexi = set.subIndex(*it,ref.subEntity(is->indexInInside(),1,i,dim),dim);
PoissonMatrix[indexi] = 0.0;
PoissonMatrix[indexi][indexi] = 1.0;
// b[indexi] = 0.0;
}
}
}
}
poisson_diagonal = 0.0;
for (int i=0;i<N;i++)
{
poisson_diagonal[i][i] = 1/(PoissonMatrix[i][i]);
}
}
| [
"noreply@github.com"
] | noreply@github.com |
2fe37e9399731b23657a12de7c040ab1c53d2234 | 85191a5432f8eefd49271b5cf76f4218b1b2bfed | /code/5_advanced_oop/solutions/snake/GameObjects.h | 4a399b16bf287473f55b8368e7f5a081ed6b0acc | [] | no_license | ucapsam/Cpp-UCL-Graudate-Programming-Course | 2466f48376a58e2f6d6224ef5f485d8520ab944f | d6db81395edc1eab5b1bb1f09934d6eb39e977be | refs/heads/master | 2021-01-12T11:32:47.664211 | 2016-11-06T20:22:27 | 2016-11-06T20:22:27 | 72,948,563 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 908 | h |
#ifndef GAME_OBJECTS_H
#define GMAE_OBJECTS_H
#include "Game.h"
#include "snake_game.h"
#include "WorldObject.h"
// FORWARD DECLARES //////////////////////
class Apple : public WorldObject
{
public:
Apple(const Vector & initialPos);
virtual void tick(Game & game);
virtual void draw();
virtual void eaten(Game & game);
protected:
virtual void doTick(Game & game) {};
Vector myPos;
};
class BonusApple : public Apple
{
public:
BonusApple(const float lifetime, const Vector & pos);
virtual void draw();
virtual void eaten(Game & game);
private:
virtual void doTick(Game & game);
float myTimeLived;
const float myLifetime;
};
class ObjectGenerator : public WorldObject
{
public:
ObjectGenerator(): myTimeSinceLastInserted(0.0) {}
virtual void tick(Game & game);
virtual void draw() {} // Nothing to draw
private:
float myTimeSinceLastInserted;
};
#endif
| [
"ucapsam@ucl.ac.uk"
] | ucapsam@ucl.ac.uk |
9f0a1c13c8079582cd40e8e08150becdba02b7a1 | 12a18a1fb033d97f4ec0251f61078733cfd8c63f | /chrome/browser/vr/service/browser_xr_runtime.cc | aacde2a98925a4c721454b9844da03f463d2d8b7 | [
"BSD-3-Clause"
] | permissive | compliment/chromium | ddb080627e8a5e75030a2ff2ef296f858e336f0e | bcd6a141ba148374c5b17135e2b61eef5bb32992 | refs/heads/master | 2023-01-13T00:01:38.156170 | 2019-12-19T05:36:59 | 2019-12-19T05:36:59 | 228,990,557 | 0 | 0 | BSD-3-Clause | 2019-12-19T06:32:50 | 2019-12-19T06:32:49 | null | UTF-8 | C++ | false | false | 16,694 | cc | // 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.
#include "chrome/browser/vr/service/browser_xr_runtime.h"
#include <algorithm>
#include <utility>
#include "base/bind_helpers.h"
#include "base/numerics/ranges.h"
#include "chrome/browser/vr/service/vr_service_impl.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "device/vr/buildflags/buildflags.h"
#include "device/vr/public/cpp/session_mode.h"
#include "device/vr/vr_device.h"
#include "ui/gfx/transform.h"
#include "ui/gfx/transform_util.h"
namespace vr {
namespace {
bool IsValidTransform(const gfx::Transform& transform,
float max_translate_meters) {
if (!transform.IsInvertible() || transform.HasPerspective())
return false;
gfx::DecomposedTransform decomp;
if (!DecomposeTransform(&decomp, transform))
return false;
float kEpsilon = 0.1f;
if (abs(decomp.perspective[3] - 1) > kEpsilon) {
// If testing with unexpectedly high values, catch on debug builds rather
// than silently change data. On release builds its better to be safe and
// validate.
DCHECK(false);
return false;
}
for (int i = 0; i < 3; ++i) {
if (abs(decomp.scale[i] - 1) > kEpsilon)
return false;
if (abs(decomp.skew[i]) > kEpsilon)
return false;
if (abs(decomp.perspective[i]) > kEpsilon)
return false;
if (abs(decomp.translate[i]) > max_translate_meters)
return false;
}
// Only rotate and translate.
return true;
}
device::mojom::VREyeParametersPtr ValidateEyeParameters(
const device::mojom::VREyeParameters* eye) {
if (!eye)
return nullptr;
device::mojom::VREyeParametersPtr ret = device::mojom::VREyeParameters::New();
// FOV
float kDefaultFOV = 45;
ret->field_of_view = device::mojom::VRFieldOfView::New();
if (eye->field_of_view->up_degrees < 90 &&
eye->field_of_view->up_degrees > -90 &&
eye->field_of_view->up_degrees > -eye->field_of_view->down_degrees &&
eye->field_of_view->down_degrees < 90 &&
eye->field_of_view->down_degrees > -90 &&
eye->field_of_view->down_degrees > -eye->field_of_view->up_degrees &&
eye->field_of_view->left_degrees < 90 &&
eye->field_of_view->left_degrees > -90 &&
eye->field_of_view->left_degrees > -eye->field_of_view->right_degrees &&
eye->field_of_view->right_degrees < 90 &&
eye->field_of_view->right_degrees > -90 &&
eye->field_of_view->right_degrees > -eye->field_of_view->left_degrees) {
ret->field_of_view->up_degrees = eye->field_of_view->up_degrees;
ret->field_of_view->down_degrees = eye->field_of_view->down_degrees;
ret->field_of_view->left_degrees = eye->field_of_view->left_degrees;
ret->field_of_view->right_degrees = eye->field_of_view->right_degrees;
} else {
ret->field_of_view->up_degrees = kDefaultFOV;
ret->field_of_view->down_degrees = kDefaultFOV;
ret->field_of_view->left_degrees = kDefaultFOV;
ret->field_of_view->right_degrees = kDefaultFOV;
}
// Head-from-Eye Transform
// Maximum 10m translation.
if (IsValidTransform(eye->head_from_eye, 10)) {
ret->head_from_eye = eye->head_from_eye;
}
// else, ret->head_from_eye remains the identity transform
// Renderwidth/height
uint32_t kMaxSize = 16384;
uint32_t kMinSize = 2;
// DCHECK on debug builds to catch legitimate large sizes, but clamp on
// release builds to ensure valid state.
DCHECK(eye->render_width < kMaxSize);
DCHECK(eye->render_height < kMaxSize);
ret->render_width = base::ClampToRange(eye->render_width, kMinSize, kMaxSize);
ret->render_height =
base::ClampToRange(eye->render_height, kMinSize, kMaxSize);
return ret;
}
device::mojom::VRDisplayInfoPtr ValidateVRDisplayInfo(
const device::mojom::VRDisplayInfo* info,
device::mojom::XRDeviceId id) {
if (!info)
return nullptr;
device::mojom::VRDisplayInfoPtr ret = device::mojom::VRDisplayInfo::New();
// Rather than just cloning everything, we copy over each field and validate
// individually. This ensures new fields don't bypass validation.
ret->id = id;
// Maximum 1000km translation.
if (info->stage_parameters &&
IsValidTransform(info->stage_parameters->standing_transform, 1000000)) {
ret->stage_parameters = device::mojom::VRStageParameters::New(
info->stage_parameters->standing_transform,
info->stage_parameters->bounds);
}
ret->left_eye = ValidateEyeParameters(info->left_eye.get());
ret->right_eye = ValidateEyeParameters(info->right_eye.get());
float kMinFramebufferScale = 0.1f;
float kMaxFramebufferScale = 1.0f;
if (info->webxr_default_framebuffer_scale <= kMaxFramebufferScale &&
info->webxr_default_framebuffer_scale >= kMinFramebufferScale) {
ret->webxr_default_framebuffer_scale =
info->webxr_default_framebuffer_scale;
} else {
ret->webxr_default_framebuffer_scale = 1;
}
return ret;
}
// TODO(crbug.com/995377): Report these from the device runtime instead.
constexpr device::mojom::XRSessionFeature kOrientationDeviceFeatures[] = {
device::mojom::XRSessionFeature::REF_SPACE_VIEWER,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL_FLOOR,
};
constexpr device::mojom::XRSessionFeature kGVRDeviceFeatures[] = {
device::mojom::XRSessionFeature::REF_SPACE_VIEWER,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL_FLOOR,
};
constexpr device::mojom::XRSessionFeature kARCoreDeviceFeatures[] = {
device::mojom::XRSessionFeature::REF_SPACE_VIEWER,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL_FLOOR,
device::mojom::XRSessionFeature::REF_SPACE_UNBOUNDED,
};
#if BUILDFLAG(ENABLE_OPENVR)
constexpr device::mojom::XRSessionFeature kOpenVRFeatures[] = {
device::mojom::XRSessionFeature::REF_SPACE_VIEWER,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL_FLOOR,
device::mojom::XRSessionFeature::REF_SPACE_BOUNDED_FLOOR,
};
#endif
#if BUILDFLAG(ENABLE_WINDOWS_MR)
constexpr device::mojom::XRSessionFeature kWindowsMixedRealityFeatures[] = {
device::mojom::XRSessionFeature::REF_SPACE_VIEWER,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL_FLOOR,
device::mojom::XRSessionFeature::REF_SPACE_BOUNDED_FLOOR,
};
#endif
#if BUILDFLAG(ENABLE_OPENXR)
constexpr device::mojom::XRSessionFeature kOpenXRFeatures[] = {
device::mojom::XRSessionFeature::REF_SPACE_VIEWER,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL_FLOOR,
device::mojom::XRSessionFeature::REF_SPACE_BOUNDED_FLOOR,
device::mojom::XRSessionFeature::REF_SPACE_UNBOUNDED,
};
#endif
#if BUILDFLAG(ENABLE_OCULUS_VR)
constexpr device::mojom::XRSessionFeature kOculusFeatures[] = {
device::mojom::XRSessionFeature::REF_SPACE_VIEWER,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL_FLOOR,
device::mojom::XRSessionFeature::REF_SPACE_BOUNDED_FLOOR,
};
#endif
bool ContainsFeature(
base::span<const device::mojom::XRSessionFeature> feature_list,
device::mojom::XRSessionFeature feature) {
return std::find(feature_list.begin(), feature_list.end(), feature) !=
feature_list.end();
}
} // anonymous namespace
BrowserXRRuntime::BrowserXRRuntime(
device::mojom::XRDeviceId id,
mojo::PendingRemote<device::mojom::XRRuntime> runtime,
device::mojom::VRDisplayInfoPtr display_info)
: id_(id),
runtime_(std::move(runtime)),
display_info_(ValidateVRDisplayInfo(display_info.get(), id)) {
DVLOG(2) << __func__ << ": id=" << id;
// Unretained is safe because we are calling through an InterfacePtr we own,
// so we won't be called after runtime_ is destroyed.
runtime_->ListenToDeviceChanges(
receiver_.BindNewEndpointAndPassRemote(),
base::BindOnce(&BrowserXRRuntime::OnDisplayInfoChanged,
base::Unretained(this)));
}
BrowserXRRuntime::~BrowserXRRuntime() {
DVLOG(2) << __func__ << ": id=" << id_;
}
void BrowserXRRuntime::ExitActiveImmersiveSession() {
DVLOG(2) << __func__;
auto* service = GetServiceWithActiveImmersiveSession();
if (service) {
service->ExitPresent(base::DoNothing());
}
}
bool BrowserXRRuntime::SupportsFeature(
device::mojom::XRSessionFeature feature) const {
switch (id_) {
// Test/fake devices support all features.
case device::mojom::XRDeviceId::WEB_TEST_DEVICE_ID:
case device::mojom::XRDeviceId::FAKE_DEVICE_ID:
return true;
case device::mojom::XRDeviceId::ARCORE_DEVICE_ID:
// Only support DOM overlay if the feature flag is enabled.
if (feature ==
device::mojom::XRSessionFeature::DOM_OVERLAY_FOR_HANDHELD_AR) {
return base::FeatureList::IsEnabled(features::kWebXrArDOMOverlay);
}
return ContainsFeature(kARCoreDeviceFeatures, feature);
case device::mojom::XRDeviceId::ORIENTATION_DEVICE_ID:
return ContainsFeature(kOrientationDeviceFeatures, feature);
case device::mojom::XRDeviceId::GVR_DEVICE_ID:
return ContainsFeature(kGVRDeviceFeatures, feature);
#if BUILDFLAG(ENABLE_OPENVR)
case device::mojom::XRDeviceId::OPENVR_DEVICE_ID:
return ContainsFeature(kOpenVRFeatures, feature);
#endif
#if BUILDFLAG(ENABLE_OCULUS_VR)
case device::mojom::XRDeviceId::OCULUS_DEVICE_ID:
return ContainsFeature(kOculusFeatures, feature);
#endif
#if BUILDFLAG(ENABLE_WINDOWS_MR)
case device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID:
return ContainsFeature(kWindowsMixedRealityFeatures, feature);
#endif
#if BUILDFLAG(ENABLE_OPENXR)
case device::mojom::XRDeviceId::OPENXR_DEVICE_ID:
return ContainsFeature(kOpenXRFeatures, feature);
#endif
}
NOTREACHED();
}
bool BrowserXRRuntime::SupportsAllFeatures(
const std::vector<device::mojom::XRSessionFeature>& features) const {
for (const auto& feature : features) {
if (!SupportsFeature(feature))
return false;
}
return true;
}
bool BrowserXRRuntime::SupportsCustomIPD() const {
switch (id_) {
case device::mojom::XRDeviceId::ARCORE_DEVICE_ID:
case device::mojom::XRDeviceId::WEB_TEST_DEVICE_ID:
case device::mojom::XRDeviceId::FAKE_DEVICE_ID:
case device::mojom::XRDeviceId::ORIENTATION_DEVICE_ID:
case device::mojom::XRDeviceId::GVR_DEVICE_ID:
return false;
#if BUILDFLAG(ENABLE_OPENVR)
case device::mojom::XRDeviceId::OPENVR_DEVICE_ID:
return true;
#endif
#if BUILDFLAG(ENABLE_OCULUS_VR)
case device::mojom::XRDeviceId::OCULUS_DEVICE_ID:
return true;
#endif
#if BUILDFLAG(ENABLE_WINDOWS_MR)
case device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID:
return true;
#endif
#if BUILDFLAG(ENABLE_OPENXR)
case device::mojom::XRDeviceId::OPENXR_DEVICE_ID:
return true;
#endif
}
NOTREACHED();
}
bool BrowserXRRuntime::SupportsNonEmulatedHeight() const {
switch (id_) {
case device::mojom::XRDeviceId::ARCORE_DEVICE_ID:
case device::mojom::XRDeviceId::WEB_TEST_DEVICE_ID:
case device::mojom::XRDeviceId::FAKE_DEVICE_ID:
case device::mojom::XRDeviceId::ORIENTATION_DEVICE_ID:
return false;
case device::mojom::XRDeviceId::GVR_DEVICE_ID:
#if BUILDFLAG(ENABLE_OPENVR)
case device::mojom::XRDeviceId::OPENVR_DEVICE_ID:
#endif
#if BUILDFLAG(ENABLE_OCULUS_VR)
case device::mojom::XRDeviceId::OCULUS_DEVICE_ID:
#endif
#if BUILDFLAG(ENABLE_WINDOWS_MR)
case device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID:
#endif
#if BUILDFLAG(ENABLE_OPENXR)
case device::mojom::XRDeviceId::OPENXR_DEVICE_ID:
#endif
return true;
}
NOTREACHED();
}
void BrowserXRRuntime::OnDisplayInfoChanged(
device::mojom::VRDisplayInfoPtr vr_device_info) {
bool had_display_info = !!display_info_;
display_info_ = ValidateVRDisplayInfo(vr_device_info.get(), id_);
if (had_display_info) {
for (VRServiceImpl* service : services_) {
service->OnDisplayInfoChanged();
}
}
// Notify observers of the new display info.
for (BrowserXRRuntimeObserver& observer : observers_) {
observer.SetVRDisplayInfo(display_info_.Clone());
}
}
void BrowserXRRuntime::StopImmersiveSession(
VRServiceImpl::ExitPresentCallback on_exited) {
DVLOG(2) << __func__;
if (immersive_session_controller_) {
immersive_session_controller_.reset();
if (presenting_service_) {
presenting_service_->OnExitPresent();
presenting_service_ = nullptr;
}
for (BrowserXRRuntimeObserver& observer : observers_) {
observer.SetWebXRWebContents(nullptr);
}
}
std::move(on_exited).Run();
}
void BrowserXRRuntime::OnExitPresent() {
DVLOG(2) << __func__;
if (presenting_service_) {
presenting_service_->OnExitPresent();
presenting_service_ = nullptr;
}
}
void BrowserXRRuntime::OnVisibilityStateChanged(
device::mojom::XRVisibilityState visibility_state) {
for (VRServiceImpl* service : services_) {
service->OnVisibilityStateChanged(visibility_state);
}
}
void BrowserXRRuntime::OnServiceAdded(VRServiceImpl* service) {
DVLOG(2) << __func__ << ": id=" << id_;
services_.insert(service);
}
void BrowserXRRuntime::OnServiceRemoved(VRServiceImpl* service) {
DVLOG(2) << __func__ << ": id=" << id_;
DCHECK(service);
services_.erase(service);
if (service == presenting_service_) {
ExitPresent(service, base::DoNothing());
}
}
void BrowserXRRuntime::ExitPresent(
VRServiceImpl* service,
VRServiceImpl::ExitPresentCallback on_exited) {
DVLOG(2) << __func__ << ": id=" << id_ << " service=" << service
<< " presenting_service_=" << presenting_service_;
if (service == presenting_service_) {
runtime_->ShutdownSession(
base::BindOnce(&BrowserXRRuntime::StopImmersiveSession,
weak_ptr_factory_.GetWeakPtr(), std::move(on_exited)));
}
}
void BrowserXRRuntime::SetFramesThrottled(const VRServiceImpl* service,
bool throttled) {
if (service == presenting_service_) {
for (BrowserXRRuntimeObserver& observer : observers_) {
observer.SetFramesThrottled(throttled);
}
}
}
void BrowserXRRuntime::RequestSession(
VRServiceImpl* service,
const device::mojom::XRRuntimeSessionOptionsPtr& options,
RequestSessionCallback callback) {
DVLOG(2) << __func__ << ": id=" << id_;
// base::Unretained is safe because we won't be called back after runtime_ is
// destroyed.
runtime_->RequestSession(
options->Clone(),
base::BindOnce(&BrowserXRRuntime::OnRequestSessionResult,
base::Unretained(this), service->GetWeakPtr(),
options->Clone(), std::move(callback)));
}
void BrowserXRRuntime::OnRequestSessionResult(
base::WeakPtr<VRServiceImpl> service,
device::mojom::XRRuntimeSessionOptionsPtr options,
RequestSessionCallback callback,
device::mojom::XRSessionPtr session,
mojo::PendingRemote<device::mojom::XRSessionController>
immersive_session_controller) {
if (session && service) {
DVLOG(2) << __func__ << ": id=" << id_;
if (device::XRSessionModeUtils::IsImmersive(options->mode)) {
presenting_service_ = service.get();
immersive_session_controller_.Bind(
std::move(immersive_session_controller));
immersive_session_controller_.set_disconnect_handler(base::BindOnce(
&BrowserXRRuntime::OnImmersiveSessionError, base::Unretained(this)));
// Notify observers that we have started presentation.
content::WebContents* web_contents = service->GetWebContents();
for (BrowserXRRuntimeObserver& observer : observers_) {
observer.SetWebXRWebContents(web_contents);
}
}
std::move(callback).Run(std::move(session));
} else {
std::move(callback).Run(nullptr);
if (session) {
// The service has been removed, but we still got a session, so make
// sure to clean up this weird state.
immersive_session_controller_.Bind(
std::move(immersive_session_controller));
StopImmersiveSession(base::DoNothing());
}
}
}
void BrowserXRRuntime::OnImmersiveSessionError() {
DVLOG(2) << __func__ << ": id=" << id_;
StopImmersiveSession(base::DoNothing());
}
} // namespace vr
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
be2c03660ab946eefef3e6afa0127ec58438e860 | 8326bfed5d6fe646bf7ef1dff62b963641536580 | /uva/575-Skew-Binary/575---Skew-Binary.cpp | 14891158280d50c70552a7a8816a3c0109449e0f | [] | no_license | mehranagh20/ACM-ICPC | 04ddbaf7ade9f266b6e74a19b2bd966d19ea442e | 76eb30b5df8545b04efc1df9c2e557ab0f83d2fb | refs/heads/master | 2018-10-20T02:59:43.070665 | 2018-08-10T16:53:56 | 2018-08-10T16:54:12 | 59,946,269 | 15 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 947 | cpp | //In The Name Of God
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;
typedef vector<vvii> vvvii;
typedef vector<vector<viii>> vvviii;
typedef vector<vector<iii>> vviii;
typedef set<int> si;
typedef vector<si> vsi;
typedef pair<double, double> dd;
typedef vector<dd> vdd;
#define inf 1000000000
#define eps 1e-9
int main() {
ios::sync_with_stdio(0);
string str;
while(cin >> str && str != "0") {
ll p = 1, ans = 0;
for(int i = str.size() - 1; i >= 0; i--) ans += ((ll)pow(2, p++) - 1) * (str[i] - '0');
cout << ans << endl;
}
return 0;
} | [
"mehranagh200@gmail.com"
] | mehranagh200@gmail.com |
886dccb09b35c7bf8444f427a3dd8289c9566a2c | 6baff33a7f350b4ed7dd53b7ac0be0165a008b30 | /rmdir/rmdir.cpp | b277c72bdffdcc3dceb86e86773020ea4eeb95fd | [] | no_license | cefeboru/SimpleBashShell | bed4be2d1050c30d0b27535865ba34293183272c | 2b5a54b3bca5396fe1fa9afd6a1b39c7d9be4d8f | refs/heads/master | 2021-01-23T14:33:17.727230 | 2017-09-21T00:56:22 | 2017-09-21T00:56:22 | 102,692,712 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,539 | cpp | #include <string>
#include <iostream>
#include <windows.h>
#include <conio.h>
using namespace std;
int DeleteDirectory(const std::string &refcstrRootDirectory,
bool bDeleteSubdirectories);
int main(int argsc, char *argsv[])
{
int iRC = 0;
string strDirectoryToDelete = "";
bool isRecursive = false;
for (int i = 1; i < argsc; i++)
{
size_t found = string(argsv[i]).find_first_of("-R");
if (found != string::npos)
{
isRecursive = true;
}
else
{
strDirectoryToDelete = argsv[i];
}
}
iRC = DeleteDirectory(strDirectoryToDelete, isRecursive);
if (iRC)
{
if (iRC != -1)
std::cout << "Error " << iRC << std::endl;
return -1;
}
cout << "" << endl;
return 0;
}
int DeleteDirectory(const std::string &refcstrRootDirectory,
bool bDeleteSubdirectories = false)
{
bool bSubdirectory = false; // Flag, indicating whether
// subdirectories have been found
HANDLE hFile; // Handle to directory
std::string strFilePath; // Filepath
std::string strPattern; // Pattern
WIN32_FIND_DATA FileInformation; // File information
strPattern = refcstrRootDirectory + "\\*.*";
hFile = ::FindFirstFile(strPattern.c_str(), &FileInformation);
if (hFile != INVALID_HANDLE_VALUE)
{
do
{
if (FileInformation.cFileName[0] != '.')
{
if (!bDeleteSubdirectories)
{
cout << "The folder is not empty" << endl;
return -1;
}
strFilePath.erase();
strFilePath = refcstrRootDirectory + "\\" + FileInformation.cFileName;
if (FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if (bDeleteSubdirectories)
{
// Delete subdirectory
int iRC = DeleteDirectory(strFilePath, bDeleteSubdirectories);
if (iRC)
return iRC;
}
else
bSubdirectory = true;
}
else
{
// Set file attributes
if (::SetFileAttributes(strFilePath.c_str(),
FILE_ATTRIBUTE_NORMAL) == FALSE)
return ::GetLastError();
// Delete file
if (::DeleteFile(strFilePath.c_str()) == FALSE)
return ::GetLastError();
}
}
} while (::FindNextFile(hFile, &FileInformation) == TRUE);
// Close handle
::FindClose(hFile);
DWORD dwError = ::GetLastError();
if (dwError != ERROR_NO_MORE_FILES)
return dwError;
else
{
if (!bSubdirectory)
{
// Set directory attributes
if (::SetFileAttributes(refcstrRootDirectory.c_str(),
FILE_ATTRIBUTE_NORMAL) == FALSE)
return ::GetLastError();
// Delete directory
if (::RemoveDirectory(refcstrRootDirectory.c_str()) == FALSE)
return ::GetLastError();
}
}
}
return 0;
} | [
"cesar fernando bonilla rueda"
] | cesar fernando bonilla rueda |
10ed4b3727b96e1f4b8e468aa892d926b0c9c6f9 | 47d6cdb9b21e2d729f23dca519ad07ff71df3066 | /third/boost/libs/mpl/preprocessed/src/greater.cpp | 2e8cd7eea2e537cab47abba70fa0291d3f7b464d | [
"BSL-1.0"
] | permissive | fiskercui/testcommon | f71ca147a7a5e4fa3cefe46efd65e2d835721c7b | 9e4f61950816202cf5c6d4d00dd521dfcdd08c8a | refs/heads/master | 2021-01-13T02:10:36.072343 | 2013-08-10T14:36:18 | 2013-08-10T14:36:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 499 | cpp |
// Copyright Aleksey Gurtovoy 2002-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id: greater.cpp 49240 2008-10-10 09:21:07Z agurtovoy $
// $Date: 2008-10-10 02:21:07 -0700 (Fri, 10 Oct 2008) $
// $Revision: 49240 $
#define BOOST_MPL_PREPROCESSING_MODE
#include <boost/config.hpp>
#include <boost/mpl/greater.hpp>
| [
"fisker@ubuntu.(none)"
] | fisker@ubuntu.(none) |
055794c05be30b9cb935af42cfdb73a2fe819307 | d54f34bf7b475791dc8278b2c83453d3fe86f353 | /DirectGraphic/DirectGraphic/BitmapFont.cpp | 3d797b2a67d197c7493a7150389d69afbffd5dae | [] | no_license | DenRen/DirectGraphic | 652ee78e03ff5d1a1baa69e80aee4730d5502e99 | f9d8428605394f50a99f1473db787c43b9a57329 | refs/heads/main | 2023-01-21T06:37:11.077853 | 2020-11-26T21:59:29 | 2020-11-26T21:59:29 | 315,758,694 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,648 | cpp | #include "BitmapFont.h"
#include <fstream>
#include <string>
#include <sstream>
#include "DebugFunc.h"
#include "DXManager.h"
#include "Shaders.h"
#include "Config.h"
wchar_t *CharToWChar (char *mbString)
{
int len = 0;
len = (int) strlen (mbString) + 1;
wchar_t *ucString = new wchar_t[len];
mbstowcs (ucString, mbString, len);
return ucString;
}
BitmapFont::BitmapFont ()
{
m_texture = nullptr;
m_constantBuffer = nullptr;
m_vertexShader = nullptr;
m_pixelShader = nullptr;
m_layout = nullptr;
m_sampleState = nullptr;
m_pixelBuffer = nullptr;
m_WidthTex = 0;
m_HeightTex = 0;
}
bool BitmapFont::Init (const char *fontFilename, const char *fontTexFile)
{
if (!m_parse (fontFilename))
RETURN_FALSE;
HRESULT hr = D3DX11CreateShaderResourceViewFromFile (DXManager::GetDevice (),
fontTexFile, NULL, NULL,
&m_texture, NULL);
CHECK_FAILED (hr);
if (!m_InitShader ("Shader\\BitmapFont.vs", "Shader\\BitmapFont.ps"))
RETURN_FALSE;
return true;
}
bool BitmapFont::m_parse (const char *fontFilename)
{
std::ifstream fin;
fin.open (fontFilename);
if (fin.fail ())
return false;
std::string Line;
std::string Read, Key, Value;
size_t i;
while (!fin.eof ())
{
std::stringstream LineStream;
std::getline (fin, Line);
LineStream << Line;
LineStream >> Read;
if (Read == "common")
{
while (!LineStream.eof ())
{
std::stringstream Converter;
LineStream >> Read;
i = Read.find ('=');
Key = Read.substr (0, i);
Value = Read.substr (i + 1);
Converter << Value;
if (Key == "scaleW")
Converter >> m_WidthTex;
else if (Key == "scaleH")
Converter >> m_HeightTex;
}
}
else if (Read == "page")
{
while (!LineStream.eof ())
{
std::stringstream Converter;
LineStream >> Read;
i = Read.find ('=');
Key = Read.substr (0, i);
Value = Read.substr (i + 1);
std::string str;
Converter << Value;
if (Key == "file")
{
Converter >> str;
wchar_t *name = CharToWChar ((char *)str.substr (1, Value.length () - 2).c_str ());
m_file = name;
//_DELETE_ARRAY (name);
}
}
}
else if (Read == "char")
{
unsigned short CharID = 0;
CharDesc chard;
while (!LineStream.eof ())
{
std::stringstream Converter;
LineStream >> Read;
i = Read.find ('=');
Key = Read.substr (0, i);
Value = Read.substr (i + 1);
Converter << Value;
if (Key == "id")
Converter >> CharID;
else if (Key == "x")
Converter >> chard.srcX;
else if (Key == "y")
Converter >> chard.srcY;
else if (Key == "width")
Converter >> chard.srcW;
else if (Key == "height")
Converter >> chard.srcH;
else if (Key == "xoffset")
Converter >> chard.xOff;
else if (Key == "yoffset")
Converter >> chard.yOff;
else if (Key == "xadvance")
Converter >> chard.xAdv;
}
m_Chars.insert (std::pair<int, CharDesc> (CharID, chard));
}
}
fin.close ();
return true;
}
bool BitmapFont::m_InitShader (const char *vsFilename, const char *psFilename)
{
ID3DBlob *vertexShaderBuffer = nullptr;
HRESULT hr = CompileShaderFromFile (vsFilename, "VS", "vs_4_0", &vertexShaderBuffer);
if (FAILED (hr))
return false;
ID3DBlob *pixelShaderBuffer = nullptr;
HRESULT result = CompileShaderFromFile (psFilename, "PS", "ps_4_0", &pixelShaderBuffer);
if (FAILED (hr))
return false;
result = DXManager::GetDevice ()->CreateVertexShader (vertexShaderBuffer->GetBufferPointer (), vertexShaderBuffer->GetBufferSize (), NULL, &m_vertexShader);
if (FAILED (result))
return false;
result = DXManager::GetDevice ()->CreatePixelShader (pixelShaderBuffer->GetBufferPointer (), pixelShaderBuffer->GetBufferSize (), NULL, &m_pixelShader);
if (FAILED (result))
return false;
D3D11_INPUT_ELEMENT_DESC polygonLayout[2];
polygonLayout[0].SemanticName = "POSITION";
polygonLayout[0].SemanticIndex = 0;
polygonLayout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
polygonLayout[0].InputSlot = 0;
polygonLayout[0].AlignedByteOffset = 0;
polygonLayout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
polygonLayout[0].InstanceDataStepRate = 0;
polygonLayout[1].SemanticName = "TEXCOORD";
polygonLayout[1].SemanticIndex = 0;
polygonLayout[1].Format = DXGI_FORMAT_R32G32_FLOAT;
polygonLayout[1].InputSlot = 0;
polygonLayout[1].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
polygonLayout[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
polygonLayout[1].InstanceDataStepRate = 0;
unsigned int numElements = sizeof (polygonLayout) / sizeof (polygonLayout[0]);
result = DXManager::GetDevice ()->CreateInputLayout (polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer (), vertexShaderBuffer->GetBufferSize (), &m_layout);
if (FAILED (result))
return false;
RELEASE (vertexShaderBuffer);
RELEASE (pixelShaderBuffer);
D3D11_BUFFER_DESC BufferDesc;
BufferDesc.Usage = D3D11_USAGE_DEFAULT;
BufferDesc.ByteWidth = sizeof (ConstantBuffer);
BufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
BufferDesc.CPUAccessFlags = 0;
BufferDesc.MiscFlags = 0;
BufferDesc.StructureByteStride = 0;
result = DXManager::GetDevice ()->CreateBuffer (&BufferDesc, NULL, &m_constantBuffer);
if (FAILED (result))
return false;
BufferDesc.Usage = D3D11_USAGE_DEFAULT;
BufferDesc.ByteWidth = sizeof (PixelBufferType);
BufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
BufferDesc.CPUAccessFlags = 0;
BufferDesc.MiscFlags = 0;
BufferDesc.StructureByteStride = 0;
result = DXManager::GetDevice ()->CreateBuffer (&BufferDesc, NULL, &m_pixelBuffer);
if (FAILED (result))
return false;
D3D11_SAMPLER_DESC samplerDesc;
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 1;
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
samplerDesc.BorderColor[0] = 0;
samplerDesc.BorderColor[1] = 0;
samplerDesc.BorderColor[2] = 0;
samplerDesc.BorderColor[3] = 0;
samplerDesc.MinLOD = 0;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
result = DXManager::GetDevice ()->CreateSamplerState (&samplerDesc, &m_sampleState);
if (FAILED (result))
return false;
return true;
}
void BitmapFont::BuildVertexArray (VertexFont *vertices, const wchar_t *sentence,
int screenWidth, int screenHeight)
{
int numLetters = (int) wcslen (sentence);
float drawX0 = 0.0f;
float drawY0 = 1.0 * m_Chars['A'].srcH / 2;
float drawX = drawX0, drawY = drawY0;
float offsetY = 0;
float offsetX = 0;
int index = 0;
for (int i = 0; i < numLetters; i++)
{
if (sentence[i] == '\n')
{
offsetY += m_Chars['A'].srcH;
drawX = drawX0;
}
float CharX = m_Chars[sentence[i]].srcX;
float CharY = m_Chars[sentence[i]].srcY;
float Width = m_Chars[sentence[i]].srcW;
float Height = m_Chars[sentence[i]].srcH;
float OffsetX = m_Chars[sentence[i]].xOff;
float OffsetY = m_Chars[sentence[i]].yOff + offsetY;
float left = drawX + OffsetX;
float right = left + Width;
float top = drawY - OffsetY;
float bottom = top - Height;
float lefttex = CharX / m_WidthTex;
float righttex = (CharX + Width) / m_WidthTex;
float toptex = CharY / m_HeightTex;
float bottomtex = (CharY + Height) / m_HeightTex;
vertices[index].pos = XMFLOAT3 (left, top, 0.0f);
vertices[index].tex = XMFLOAT2 (lefttex, toptex);
index++;
vertices[index].pos = XMFLOAT3 (right, bottom, 0.0f);
vertices[index].tex = XMFLOAT2 (righttex, bottomtex);
index++;
vertices[index].pos = XMFLOAT3 (left, bottom, 0.0f);
vertices[index].tex = XMFLOAT2 (lefttex, bottomtex);
index++;
vertices[index].pos = XMFLOAT3 (left, top, 0.0f);
vertices[index].tex = XMFLOAT2 (lefttex, toptex);
index++;
vertices[index].pos = XMFLOAT3 (right, top, 0.0f);
vertices[index].tex = XMFLOAT2 (righttex, toptex);
index++;
vertices[index].pos = XMFLOAT3 (right, bottom, 0.0f);
vertices[index].tex = XMFLOAT2 (righttex, bottomtex);
index++;
drawX += m_Chars[sentence[i]].xAdv;
}
}
void BitmapFont::Render (unsigned int index, float r, float g, float b, float x, float y)
{
m_SetShaderParameters (r, g, b, x, y);
m_RenderShader (index);
}
void BitmapFont::m_SetShaderParameters (float r, float g, float b, float x, float y)
{
x *= WndCnf::WIDTH / WndCnf::lenX;
y *= WndCnf::HEIGHT / WndCnf::lenY;
XMMATRIX objmatrix = XMMatrixScaling (1.0f, 1, 1) * XMMatrixTranslation (x, -y, 0);
XMMATRIX wvp = objmatrix * XMMatrixOrthographicLH (WndCnf::WIDTH, WndCnf::HEIGHT, 0.0f, 100.0f);
ConstantBuffer cb;
cb.WVP = XMMatrixTranspose (wvp);
auto devCont = DXManager::GetDeviceContext ();
devCont->UpdateSubresource (m_constantBuffer, 0, NULL, &cb, 0, 0);
devCont->VSSetConstantBuffers (0, 1, &m_constantBuffer);
devCont->PSSetShaderResources (0, 1, &m_texture);
PixelBufferType pb;
pb.pixelColor = XMFLOAT4 (r, g, b, 1.0f);
devCont->UpdateSubresource (m_pixelBuffer, 0, NULL, &pb, 0, 0);
devCont->PSSetConstantBuffers (0, 1, &m_pixelBuffer);
}
void BitmapFont::m_RenderShader (unsigned int index)
{
auto devCont = DXManager::GetDeviceContext ();
devCont->IASetInputLayout (m_layout);
devCont->VSSetShader (m_vertexShader, NULL, 0);
devCont->PSSetShader (m_pixelShader, NULL, 0);
devCont->PSSetSamplers (0, 1, &m_sampleState);
devCont->DrawIndexed (index, 0, 0);
}
void BitmapFont::Close ()
{
RELEASE (m_constantBuffer);
RELEASE (m_pixelBuffer);
RELEASE (m_vertexShader);
RELEASE (m_pixelShader);
RELEASE (m_layout);
RELEASE (m_sampleState);
RELEASE (m_texture);
} | [
"denrenruslan@gmail.com"
] | denrenruslan@gmail.com |
624061f360c55d07928e9c29a67968c9dec4861c | eead1e1aecd0ff16bb5979e6b911aee6572f0502 | /socket/ServerSocket.cc | 49f6203389a861c057b0fb17b4d856ecd7cbcf53 | [] | no_license | ase09/Project-Assignment | 046b83c4b2ad7e610676dd02d46cf88916d8fa4d | 45ab2dce0ca58b9826692b5307b980d2ac50c04f | refs/heads/master | 2020-12-24T13:29:36.135771 | 2009-07-27T12:18:52 | 2009-07-27T12:18:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 615 | cc | /*
* File: ServerSocket.cc
* Author: sanath
*
* Created on July 20, 2009, 3:03 PM
*/
#include "SocketException.hh"
#include "ServerSocket.hh"
ServerSocket::ServerSocket(int port) {
if (!Socket::create()) {
throw SocketException("Could not create server socket.");
}
if (!Socket::bind(port)) {
throw SocketException("Could not bind to port.");
}
if (!Socket::listen()) {
throw SocketException("Could not listen on socket.");
}
}
ServerSocket::ServerSocket() {
}
ServerSocket::ServerSocket(const ServerSocket& orig) {
}
ServerSocket::~ServerSocket() {
}
| [
"ase09@ridgecrest.lk"
] | ase09@ridgecrest.lk |
be332bfb126c7f34ac066cfbbe097d2270f715a3 | d06bb490fa55555e0343c897f5eba11bd408b09e | /libraries/MBB/MDevLM35.cpp | ceafdd59ff69d582fe2159ffd9f818281a794f6d | [] | no_license | xingzhongshu/On_Board_Diagnostic | 22188af3447da3c4f4ee3472656b10edfce5b042 | 9cebcce8e080d3fa856cf68694a202b18acd0839 | refs/heads/master | 2021-01-10T01:21:00.614182 | 2015-09-25T13:02:44 | 2015-09-25T13:02:44 | 43,138,883 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 403 | cpp | #include "MDevLM35.h"
int8_t MDevLM35::onWrite(MBusMsg& msg)
{
return MBB_ERROR_UNKNOWNPORT;
}
int8_t MDevLM35::onRead(MBusMsg& msg)
{
uint8_t len = msg.len;
switch(msg.portid) {
case MBUS_THP_PORTID_DEFAULT:
if(len < 2) return MBB_ERROR_LESSBUF;
if(!lm35.available()) return MBB_ERROR_NODATA;
msg.setat(0, lm35.getNative());
return 2;
default:
return MBB_ERROR_UNKNOWNPORT;
}
}
| [
"xingzhongshu@qq.com"
] | xingzhongshu@qq.com |
6039293f86617d11b8b5cf064781f18a1c96b4f8 | 300dc0bbac1910a3b69b447d11bb930e15ceb08c | /include/ternary_math.hpp | c90226e62b1a6513aca95aa9e8ef39c5ba831448 | [
"MIT"
] | permissive | momikey/trireme | 5cd06fc189d7298fd764bdd87a8cbdd683c3b11c | 9c284882ea0bea13ce02426bfd4c55842edefd6c | refs/heads/master | 2020-08-10T07:25:18.241847 | 2020-02-06T13:26:24 | 2020-02-06T13:26:24 | 214,292,527 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,353 | hpp | #ifndef TRIREME_TERNARY_MATH_HPP
#define TRIREME_TERNARY_MATH_HPP
/**
* @brief Constexpr absolute value function.
*
* @param value Any integer
* @return constexpr int The absolute value of the given integer
*/
template<typename Int = int>
constexpr Int abs_c(Int value)
{
if (value >= 0)
{
return value;
}
else
{
return -value;
}
}
/**
* @brief Returns the sign of a value as a constant expression.
*
* @tparam T Any numeric type where positive, negative, and zero values are defined
* @param value Any value of the given type (usually an integer)
* @return constexpr T +1, -1, or 0 for positive, negative, and zero values, respectively
*/
template<typename Int = int>
constexpr Int sign_c(Int value)
{
if (value > 0)
{
return 1;
} else if (value < 0)
{
return -1;
}
else
{
return 0;
}
}
/**
* @brief Compile-time calculation of an integer power of 3.
*
* @param exponent The exponent, which must be >= 0
* @return constexpr int 3 raised to the given exponent
*/
template<typename Int = int, typename E = unsigned int>
constexpr Int pow3(E exponent) noexcept
{
return (exponent == 0) ? 1 : 3 * pow3<Int>(exponent - 1);
}
/**
* @brief Returns the lowest trit for an integer.
*
* @param value Any signed integer
* @return constexpr int A value {1, 0, -1} representing the lowest balanced trit
*/
template<typename Int = int>
constexpr Int lowest_trit(Int value) noexcept
{
const auto temp = value % 3;
if (abs_c(temp) != 2) {
return temp;
}
else
{
return (value > 0) ? -1 : 1;
}
}
/**
* @brief Shift a number to the right using balanced-ternary arithmetic.
*
* @tparam Int Any integral type
* @param value An integer to shift
* @param places The number of trits to shift
* @return constexpr Int The value shifted to the right by the given number of places
*/
template<typename Int = int>
constexpr Int shift_right(Int value, std::size_t places) noexcept
{
if (places == 0)
{
// Shifting right by 0 is a no-op
return value;
}
else
{
const auto shifted = value / pow3<Int>(places);
const auto halfpow = pow3<Int>(places) / 2;
const auto adjust = abs_c(value - shifted*pow3<Int>(places)) > halfpow
? sign_c(value)
: 0;
return shifted + adjust;
}
}
/**
* @brief Returns the Nth trit of a given number.
*
* @tparam Int Any signed integral type
* @param value The given value
* @param place The desired trit
* @return constexpr Int A value {1,0,-1} at the nth place of the
* balanced ternary represntation of _value_
*/
template<typename Int = int>
constexpr Int nth_trit(Int value, std::size_t place) noexcept
{
return lowest_trit(shift_right(value, place));
}
/**
* @brief Clamp a given value to fit in a certain number of trits.
*
* @tparam Int Any signed integral type
* @tparam Width The maximum number of trits in the result
* @param value The given value
* @return constexpr Int The value, unless it is outside the range
* (+/- (3**width-1) / 2), in which case the appropriate maximum is
* returned.
*/
template<typename Int = int, std::size_t Width>
constexpr Int clamp(Int value) noexcept
{
const auto max = pow3<Int>(Width) / 2;
if (value > max)
{
return max;
}
else if (value < -max)
{
return -max;
}
else
{
return value;
}
}
/**
* @brief Get the lowest N trits of a number.
*
* @tparam Int Any signed integral type
* @param value The given value
* @tparam width The desired number of trits in the result
* @return constexpr Int An integer congruent to _value_ mod 3**Width,
* within the range (+/- (3**Width-1) / 2)
*/
template<typename Int = int>
constexpr Int low_trits(Int value, std::size_t width) noexcept
{
if (width < 1)
{
return 0;
}
const auto power = pow3<Int>(width);
const auto halfpower = power / 2;
if (abs_c(value) > halfpower)
{
const auto m = value % power;
if (abs_c(m) > halfpower)
{
return m - power*sign_c(value);
}
else
{
return m;
}
}
else
{
return value;
}
}
#endif /* TRIREME_TERNARY_MATH_HPP */ | [
"michael@potterpcs.net"
] | michael@potterpcs.net |
dbca01c7b8082a64ed73c56b0aead6783ba75f5f | 60f9e1b56169d0d6b3ee19a6c53762dc267b03da | /Pong Game/Ball.cpp | 03ff5d087668b2a9c06340b953bd8a02f8edf6a8 | [] | no_license | simon778/Pong-game | 8e22953efeb52f81c157231467e5401698bc448c | 88eec4e57ca8d97335f02ea7d86d086a50729da6 | refs/heads/master | 2020-08-18T21:29:34.640086 | 2019-10-17T16:40:47 | 2019-10-17T16:40:47 | 213,513,117 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 423 | cpp | #include "Ball.h"
void Ball::Reset() {
x =originalX;
y = originalY;
direction = STOP;
}
void Ball::Move() {
switch (direction) {
case STOP:
break;
case LEFT:
x--;
break;
case RIGHT:
x++;
break;
case UPLEFT:
y--; x--;
break;
case UPRIGHT:
y--; x++;
break;
case DOWNLEFT:
y++; x--;
break;
case DOWNRIGHT:
y++; x++;
break;
default:
break;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
c2435f08a92714db6f04040e3ac01c680c56bb52 | 5de42c4e14a7ddbc284a742c66cb01b230ba43ce | /codeforces/1282/D.cpp | 9e3ebb4c11f5ce7343f02787ddbfb9a2c0597e60 | [] | no_license | NhatMinh0208/CP-Archive | 42d6cc9b1d2d6b8c85e637b8a88a6852a398cc23 | f95784d53708003e7ba74cbe4f2c7a888d29eac4 | refs/heads/master | 2023-05-09T15:50:34.344385 | 2021-05-04T14:25:00 | 2021-05-19T16:10:11 | 323,779,542 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,001 | cpp | #include <bits/stdc++.h>
using namespace std;
int ask(string s)
{
cout<<s<<endl;
int u;
cin>>u;
if (u<=0) exit(0);
return u;
}
string cur,res;
int n,m,i,j,k,t,t1,u,v,a,b,ca,cb;
int main()
{
cur="a";
u=ask("a");
if (u==300)
{
cur="";
for (i=0;i<300;i++) cur.push_back('b');
ask(cur);
}
for (i=1;i<=u;i++) cur.push_back('a');
v=ask(cur);
if (v==u+1)
{
for (i=0;i<=u;i++) cur[i]='b';
cur.pop_back();
ask(cur);
}
else
{
n=u+1;
cb=v;
ca=n-cb;
for (i=0;i<n;i++)
{
if (i==n-1)
{
if (a<ca) res.push_back('a');
else res.push_back('b');
}
else
{
cur[i]='b';
v=ask(cur);
if (v<cb) {res.push_back('b'); b++;}
else {res.push_back('a'); a++;}
cur[i]='a';
}
}
ask(res);
}
} | [
"minhkhicon2468@gmail.com"
] | minhkhicon2468@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.