hexsha
stringlengths 40
40
| size
int64 7
1.05M
| ext
stringclasses 13
values | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 4
269
| max_stars_repo_name
stringlengths 5
109
| max_stars_repo_head_hexsha
stringlengths 40
40
| max_stars_repo_licenses
listlengths 1
9
| max_stars_count
int64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 4
269
| max_issues_repo_name
stringlengths 5
116
| max_issues_repo_head_hexsha
stringlengths 40
40
| max_issues_repo_licenses
listlengths 1
9
| max_issues_count
int64 1
48.5k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 4
269
| max_forks_repo_name
stringlengths 5
116
| max_forks_repo_head_hexsha
stringlengths 40
40
| max_forks_repo_licenses
listlengths 1
9
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 7
1.05M
| avg_line_length
float64 1.21
330k
| max_line_length
int64 6
990k
| alphanum_fraction
float64 0.01
0.99
| author_id
stringlengths 2
40
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7aa413252796834f146a532eb6f7c0d4d9c3a47f
| 11,822
|
cpp
|
C++
|
Source/TinyEngine/Graphics3D/ModelNode.cpp
|
chenjinxian/FX-Studio
|
cc4afddc4bce688e8366b8e4ceb2708adffd6eb4
|
[
"MIT"
] | 18
|
2016-10-19T00:40:56.000Z
|
2021-10-03T16:45:11.000Z
|
Source/TinyEngine/Graphics3D/ModelNode.cpp
|
chenjinxian/FX-Studio
|
cc4afddc4bce688e8366b8e4ceb2708adffd6eb4
|
[
"MIT"
] | null | null | null |
Source/TinyEngine/Graphics3D/ModelNode.cpp
|
chenjinxian/FX-Studio
|
cc4afddc4bce688e8366b8e4ceb2708adffd6eb4
|
[
"MIT"
] | 4
|
2017-02-10T09:08:59.000Z
|
2021-02-15T08:39:27.000Z
|
#include "ModelNode.h"
#include "CameraNode.h"
#include "Scene.h"
#include "Model.h"
#include "Material.h"
#include "../Actors/Actor.h"
#include "../Actors/RenderComponent.h"
#include "../Actors/TransformComponent.h"
#include "../ResourceCache/ResCache.h"
#include "../ResourceCache/TextureResource.h"
#include "../ResourceCache/MaterialResource.h"
#include "../ResourceCache/XmlResource.h"
#include "../AppFramework/BaseGameApp.h"
#include "boost/lexical_cast.hpp"
#include <DirectXColors.h>
ModelNode::ModelNode(
ActorId actorId, WeakBaseRenderComponentPtr renderComponent, RenderPass renderPass, const Matrix& worldMatrix)
: SceneNode(actorId, renderComponent, renderPass, worldMatrix),
m_pModel(nullptr)
{
ModelRenderComponent* pMeshRender = static_cast<ModelRenderComponent*>(m_pRenderComponent);
if (pMeshRender != nullptr)
{
m_ModelName = pMeshRender->GetModelName();
}
Resource modelRes(m_ModelName);
shared_ptr<ResHandle> pModelResHandle = g_pApp->GetResCache()->GetHandle(&modelRes);
m_pModel = unique_ptr<Model>(DEBUG_NEW Model(pModelResHandle->Buffer(), pModelResHandle->Size()));
SetBoundingBox(m_pModel->GetBoundingBox());
}
ModelNode::~ModelNode()
{
VOnDeleteSceneNode(nullptr);
}
HRESULT ModelNode::VOnInitSceneNode(Scene *pScene)
{
VOnDeleteSceneNode(pScene);
ModelRenderComponent* pMeshRender = static_cast<ModelRenderComponent*>(m_pRenderComponent);
if (pMeshRender != nullptr)
{
m_MaterialNames = pMeshRender->GetMaterialName();
}
uint32_t meshSize = m_pModel->GetMeshes().size();
m_pEffects.resize(meshSize);
m_pPasses.resize(meshSize);
m_pVertexBuffers.resize(meshSize);
m_pIndexBuffers.resize(meshSize);
m_IndexCounts.resize(meshSize);
DEBUG_ASSERT(m_MaterialNames.size() == meshSize);
for (uint32_t i = 0; i < meshSize; i++)
{
const tinyxml2::XMLElement* rootNode = nullptr;
Resource materialRes(m_MaterialNames[i]);
shared_ptr<ResHandle> pMaterialResHandle = g_pApp->GetResCache()->GetHandle(&materialRes);
if (pMaterialResHandle != nullptr)
{
shared_ptr<XmlResourceExtraData> extra = static_pointer_cast<XmlResourceExtraData>(pMaterialResHandle->GetExtraData());
if (extra != nullptr)
{
rootNode = extra->GetRoot();
}
}
if (nullptr == rootNode)
{
DEBUG_ERROR("Material is not exist or valid: " + m_MaterialNames[i]);
return S_FALSE;
}
std::string effectName = rootNode->Attribute("object");
Resource effectRes(effectName);
shared_ptr<ResHandle> pEffectResHandle = g_pApp->GetResCache()->GetHandle(&effectRes);
if (pEffectResHandle != nullptr)
{
shared_ptr<HlslResourceExtraData> extra = static_pointer_cast<HlslResourceExtraData>(pEffectResHandle->GetExtraData());
if (extra != nullptr)
{
m_pEffects[i] = extra->GetEffect();
}
}
if (m_pEffects[i] == nullptr)
{
DEBUG_ERROR("effect is not exist or valid: " + effectName);
}
const tinyxml2::XMLElement* pTechniques = rootNode->FirstChildElement("Techniques");
if (pTechniques == nullptr)
{
DEBUG_ERROR("effect xml is invalid");
}
for (const tinyxml2::XMLElement* pNode = pTechniques->FirstChildElement(); pNode; pNode = pNode->NextSiblingElement())
{
if (pNode->BoolAttribute("checked"))
{
std::string techniqueName = pNode->Attribute("name");
Technique* pCurrentTechnique = m_pEffects[i]->GetTechniquesByName().at(techniqueName);
if (pCurrentTechnique == nullptr)
{
DEBUG_ERROR("technique is not exist: " + techniqueName);
}
m_pPasses[i] = pCurrentTechnique->GetPasses().at(0);
if (m_pPasses[i] == nullptr)
{
DEBUG_ERROR("technique is not exist: " + techniqueName);
}
auto mesh = m_pModel->GetMeshes().at(i);
ID3D11Buffer* pVertexBuffer = nullptr;
ID3D11Buffer* pIndexBuffer = nullptr;
m_pPasses[i]->CreateVertexBuffer(mesh, &pVertexBuffer);
m_pPasses[i]->CreateIndexBuffer(mesh, &pIndexBuffer);
m_pVertexBuffers[i] = pVertexBuffer;
m_pIndexBuffers[i] = pIndexBuffer;
m_IndexCounts[i] = mesh->GetIndices().size();
break;
}
}
}
return S_FALSE;
}
HRESULT ModelNode::VOnDeleteSceneNode(Scene* pScene)
{
for (auto pVertexBuffer : m_pVertexBuffers)
{
SAFE_RELEASE(pVertexBuffer);
}
m_pVertexBuffers.clear();
for (auto pIndexBuffer : m_pIndexBuffers)
{
SAFE_RELEASE(pIndexBuffer);
}
m_pIndexBuffers.clear();
return S_OK;
}
HRESULT ModelNode::VOnUpdate(Scene* pScene, const GameTime& gameTime)
{
return S_OK;
}
HRESULT ModelNode::VRender(Scene* pScene, const GameTime& gameTime)
{
for (uint32_t i = 0, count = m_pModel->GetMeshes().size(); i < count; i++)
{
const tinyxml2::XMLElement* rootNode = nullptr;
Resource materialRes(m_MaterialNames[i]);
shared_ptr<ResHandle> pMaterialResHandle = g_pApp->GetResCache()->GetHandle(&materialRes);
if (pMaterialResHandle != nullptr)
{
shared_ptr<XmlResourceExtraData> extra = static_pointer_cast<XmlResourceExtraData>(pMaterialResHandle->GetExtraData());
if (extra != nullptr)
{
rootNode = extra->GetRoot();
}
}
if (nullptr == rootNode)
return S_FALSE;
const tinyxml2::XMLElement* pVariables = rootNode->FirstChildElement("Variables");
DEBUG_ASSERT(pVariables != nullptr);
const std::map<std::string, Variable*>& variables = m_pEffects[i]->GetVariablesByName();
for (const tinyxml2::XMLElement* pNode = pVariables->FirstChildElement(); pNode; pNode = pNode->NextSiblingElement())
{
Variable* variable = variables.at(pNode->Name());
std::string semantic = variable->GetVariableSemantic();
std::string type = variable->GetVariableType();
if (semantic == "worldviewprojection")
{
if (type == "float4x4")
{
const Matrix& wvp = pScene->GetCamera()->GetWorldViewProjection(pScene);
variable->SetMatrix(wvp);
}
}
else if (semantic == "worldinversetranspose")
{
if (type == "float4x4")
{
Matrix& worldIT = pScene->GetTopMatrix().Invert().Transpose();
variable->SetMatrix(worldIT);
}
}
else if (semantic == "world")
{
if (type == "float4x4")
{
const Matrix& world = pScene->GetTopMatrix();
variable->SetMatrix(world);
}
}
else if (semantic == "viewinverse")
{
if (type == "float4x4")
{
Matrix& viewI = pScene->GetCamera()->GetViewMatrix().Invert();
variable->SetMatrix(viewI);
}
}
else if (semantic == "time")
{
variable->SetFloat(gameTime.GetElapsedTime());
}
else if (type == "float4")
{
std::stringstream ss(pNode->GetText());
Vector4 value;
ss >> value.x >> value.y >> value.z >> value.w;
variable->SetVector(value);
}
else if (type == "float3")
{
std::stringstream ss(pNode->GetText());
Vector3 value;
ss >> value.x >> value.y >> value.z;
variable->SetVector(value);
}
else if (type == "float2")
{
std::stringstream ss(pNode->GetText());
Vector2 value;
ss >> value.x >> value.y;
variable->SetVector(value);
}
else if (type == "float")
{
switch (variable->GetElementsCount())
{
case 0:
{
variable->SetFloat(boost::lexical_cast<float>(pNode->GetText()));
break;
}
case 2:
{
std::stringstream ss(pNode->GetText());
std::vector<float> value(2);
ss >> value[0] >> value[1];
variable->SetFloatArray(value);
break;
}
case 3:
{
std::stringstream ss(pNode->GetText());
std::vector<float> value(3);
ss >> value[0] >> value[1] >> value[2];
variable->SetFloatArray(value);
break;
}
case 4:
{
std::stringstream ss(pNode->GetText());
std::vector<float> value(4);
ss >> value[0] >> value[1] >> value[2] >> value[3];
variable->SetFloatArray(value);
break;
}
default:
break;
}
}
else if (type == "int")
{
variable->SetInt(boost::lexical_cast<int>(pNode->GetText()));
}
else if (type == "Texture1D" || type == "Texture2D" || type == "Texture3D" || type == "TextureCube")
{
const char* resourName = pNode->Attribute("resourcename");
if (resourName != nullptr)
{
std::string textureName = std::string("Textures\\") + resourName;
Resource resource(textureName);
shared_ptr<ResHandle> pTextureRes = g_pApp->GetResCache()->GetHandle(&resource);
if (pTextureRes != nullptr)
{
shared_ptr<D3D11TextureResourceExtraData> extra =
static_pointer_cast<D3D11TextureResourceExtraData>(pTextureRes->GetExtraData());
if (extra != nullptr)
{
variable->SetResource(extra->GetTexture());
}
}
}
}
}
if (m_pPasses[i]->HasHullShader())
{
// D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST start from 33 (32+1)
pScene->GetRenderder()->VInputSetup(
(D3D_PRIMITIVE_TOPOLOGY)(m_pPasses[i]->GetTessellationPrimitive() + 32), m_pPasses[i]->GetInputLayout());
}
else
{
Mesh* mesh = m_pModel->GetMeshes().at(i);
switch (mesh->GetPrimitiveType())
{
case Mesh::PT_Point:
pScene->GetRenderder()->VInputSetup(D3D_PRIMITIVE_TOPOLOGY_POINTLIST, m_pPasses[i]->GetInputLayout());
break;
case Mesh::PT_Line:
pScene->GetRenderder()->VInputSetup(D3D_PRIMITIVE_TOPOLOGY_LINELIST, m_pPasses[i]->GetInputLayout());
break;
case Mesh::PT_Triangle:
pScene->GetRenderder()->VInputSetup(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST, m_pPasses[i]->GetInputLayout());
break;
default:
DEBUG_ERROR("Unsupport primitive type!");
return S_FALSE;
}
}
uint32_t stride = m_pPasses[i]->GetVertexSize();
uint32_t offset = 0;
pScene->GetRenderder()->VSetVertexBuffers(m_pVertexBuffers[i], &stride, &offset);
pScene->GetRenderder()->VSetIndexBuffer(m_pIndexBuffers[i], IRenderer::Format_uint32, 0);
pScene->GetRenderder()->VDrawMesh(m_IndexCounts[i], 0, 0, m_pPasses[i]->GetEffectPass());
pScene->GetRenderder()->VResetShader(
m_pPasses[i]->HasGeometryShader(), m_pPasses[i]->HasHullShader(), m_pPasses[i]->HasDomainShader());
}
return S_OK;
}
void ModelNode::VPick(Scene* pScene, int cursorX, int cursorY)
{
const Matrix& projectMat = pScene->GetCamera()->GetProjectMatrix();
float viewX = (2.0f * cursorX / g_pApp->GetGameConfig().m_ScreenWidth - 1.0f) / projectMat.m[0][0];
float viewY = (1.0f - 2.0f * cursorY / g_pApp->GetGameConfig().m_ScreenHeight) / projectMat.m[1][1];
Matrix toLocal = (m_Properties.GetWorldMatrix() * pScene->GetCamera()->GetViewMatrix()).Invert();
Vector3 rayPos = toLocal.Translation();
//use right-hand coordinates, z should be -1
Vector3 rayDir = Vector3::TransformNormal(Vector3(viewX, viewY, -1.0f), toLocal);
rayDir.Normalize();
Ray ray(rayPos, rayDir);
float distance = 0.0f;
if (ray.Intersects(m_Properties.GetBoundingBox(), distance))
{
if (distance < pScene->GetPickDistance())
{
pScene->SetPickDistance(distance);
int index = 0;
for (auto mesh : m_pModel->GetMeshes())
{
switch (mesh->GetPrimitiveType())
{
case Mesh::PT_Point:
case Mesh::PT_Line:
{
distance = 0.0f;
if (ray.Intersects(mesh->GetBoundingBox(), distance))
{
pScene->SetPickedActor(m_Properties.GetActorId(), index);
}
break;
}
case Mesh::PT_Triangle:
{
uint32_t len = mesh->GetIndices().size();
len = len - len % 3;
for (uint32_t i = 0; i < len; i += 3)
{
const std::vector<Vector3>& vertices = mesh->GetVertices();
const std::vector<uint32_t>& indices = mesh->GetIndices();
Vector3 tri0 = vertices.at(indices[i]);
Vector3 tri1 = vertices.at(indices[i + 1]);
Vector3 tri2 = vertices.at(indices[i + 2]);
distance = 0.0f;
if (ray.Intersects(tri0, tri1, tri2, distance))
{
pScene->SetPickedActor(m_Properties.GetActorId(), index);
return;
}
}
break;
}
default:
break;
}
index++;
}
}
}
}
| 28.834146
| 122
| 0.670868
|
chenjinxian
|
7ab3b27242585af42243c9a6a40815835e0942bf
| 578
|
cpp
|
C++
|
a program to form combination of 0,S AND 1,S upon how much user enter the value of n.cpp
|
Faiquekhan15/C-C-conceptual-Questions
|
a75141bd5a58c32e2446f695e66ffbf979b8c8af
|
[
"MIT"
] | null | null | null |
a program to form combination of 0,S AND 1,S upon how much user enter the value of n.cpp
|
Faiquekhan15/C-C-conceptual-Questions
|
a75141bd5a58c32e2446f695e66ffbf979b8c8af
|
[
"MIT"
] | null | null | null |
a program to form combination of 0,S AND 1,S upon how much user enter the value of n.cpp
|
Faiquekhan15/C-C-conceptual-Questions
|
a75141bd5a58c32e2446f695e66ffbf979b8c8af
|
[
"MIT"
] | null | null | null |
#include<iostream>
#include<vector>
using namespace std;
void printarray(vector<int>&comb)
{
for(int i=0;i<comb.size();i++)
{
cout<<comb[i];
}
cout<<endl;
}
void printallcomb(int n,vector<int>&comb)
{
if(n==0)
{
printarray(comb);
}
else
{
comb.push_back(0);
printallcomb(n-1,comb);
comb.pop_back();
comb.push_back(1);
printallcomb(n-1,comb);
comb.pop_back();
}
}
void printallcomb(int n)
{
vector<int>comb;
printallcomb(n,comb);
}
int main()
{
int n;
cout<<"PLEASE ENTER A NUMBER YOU WANT TO FORM A COMBINATION"<<endl;
cin>>n;
printallcomb(n);
}
| 14.45
| 68
| 0.655709
|
Faiquekhan15
|
7aba225364d6d3e40f27ea20d81556166219085c
| 175
|
cpp
|
C++
|
test/system/test_socket.cpp
|
joydit/solidframe
|
0539b0a1e77663ac4c701a88f56723d3e3688e8c
|
[
"BSL-1.0"
] | null | null | null |
test/system/test_socket.cpp
|
joydit/solidframe
|
0539b0a1e77663ac4c701a88f56723d3e3688e8c
|
[
"BSL-1.0"
] | null | null | null |
test/system/test_socket.cpp
|
joydit/solidframe
|
0539b0a1e77663ac4c701a88f56723d3e3688e8c
|
[
"BSL-1.0"
] | null | null | null |
#include <iostream>
#include "system/cassert.hpp"
using namespace std;
int test_socket(int argc, char **argv){
cout<<"test_socket"<<endl;
//cassert(false);
return -1;
}
| 14.583333
| 39
| 0.697143
|
joydit
|
7abe82b9fc562589c3b86efa5a3796a0161f960e
| 5,253
|
cpp
|
C++
|
time.cpp
|
komasaru/sun_moon
|
d4dee17f1164188f5c7686c76a9119e7688be10a
|
[
"MIT"
] | null | null | null |
time.cpp
|
komasaru/sun_moon
|
d4dee17f1164188f5c7686c76a9119e7688be10a
|
[
"MIT"
] | null | null | null |
time.cpp
|
komasaru/sun_moon
|
d4dee17f1164188f5c7686c76a9119e7688be10a
|
[
"MIT"
] | null | null | null |
#include "time.hpp"
namespace sun_moon {
// 定数
static constexpr unsigned int kJstOffset = 9; // JST - UTC (hours)
static constexpr unsigned int kSecHour = 3600; // Seconds in an hour
static constexpr double kTtTai = 32.184; // TT - TAI
/*
* @brief 変換: JST -> UTC
*
* @param[in] JST (timespec)
* @return UTC (timespec)
*/
struct timespec jst2utc(struct timespec ts_jst) {
struct timespec ts;
try {
ts.tv_sec = ts_jst.tv_sec - kJstOffset * kSecHour;
ts.tv_nsec = ts_jst.tv_nsec;
} catch (...) {
throw;
}
return ts;
}
/*
* @brief 日時文字列生成
*
* @param[in] 日時 (timespec)
* @return 日時文字列 (string)
*/
std::string gen_time_str(struct timespec ts) {
struct tm t;
std::stringstream ss;
std::string str_tm;
try {
localtime_r(&ts.tv_sec, &t);
ss << std::setfill('0')
<< std::setw(4) << t.tm_year + 1900 << "-"
<< std::setw(2) << t.tm_mon + 1 << "-"
<< std::setw(2) << t.tm_mday << " "
<< std::setw(2) << t.tm_hour << ":"
<< std::setw(2) << t.tm_min << ":"
<< std::setw(2) << t.tm_sec << "."
<< std::setw(3) << ts.tv_nsec / 1000000;
return ss.str();
} catch (...) {
throw;
}
}
/*
* @brief コンストラクタ
*
* @param none
*/
Time::Time() {
try {
// うるう秒, DUT1 一覧取得
l_ls.reserve(50); // 予めメモリ確保
l_dut.reserve(250); // 予めメモリ確保
File o_f;
if (!o_f.get_leap_sec_list(l_ls)) throw;
if (!o_f.get_dut1_list(l_dut)) throw;
dlt_t = 0.0;
} catch (...) {
throw;
}
}
/*
* @brief UTC - TAI (協定世界時と国際原子時の差 = うるう秒の総和) 取得
*
* @param[in] UTC (timespec)
* @return UTC - TAI (int)
*/
int Time::get_utc_tai(struct timespec ts) {
struct tm t;
std::stringstream ss; // 対象年月日算出用
std::string dt_t; // 対象年月日
std::string buf; // 1行分バッファ
int i; // ループインデックス
utc_tai = 0; // 初期化
try {
// 対象年月日
localtime_r(&ts.tv_sec, &t);
ss << std::setw(4) << std::setfill('0') << std::right
<< t.tm_year + 1900
<< std::setw(2) << std::setfill('0') << std::right
<< t.tm_mon + 1
<< std::setw(2) << std::setfill('0') << std::right
<< t.tm_mday;
dt_t = ss.str();
// うるう秒取得
for (i = l_ls.size() - 1; i >= 0; --i) {
if (l_ls[i][0] <= dt_t) {
utc_tai = stoi(l_ls[i][1]);
break;
}
}
return utc_tai;
} catch (...) {
throw;
}
}
/*
* @brief DUT1 (UT1(世界時1) と UTC(協定世界時)の差) 取得
*
* @param[in] UTC (timespec)
* @return DUT1 (float)
*/
float Time::get_dut1(struct timespec ts) {
struct tm t;
std::stringstream ss; // 対象年月日算出用
std::string dt_t; // 対象年月日
std::string buf; // 1行分バッファ
int i; // ループインデックス
dut1 = 0.0; // 初期化
try {
// 対象年月日
localtime_r(&ts.tv_sec, &t);
ss << std::setw(4) << std::setfill('0') << std::right
<< t.tm_year + 1900
<< std::setw(2) << std::setfill('0') << std::right
<< t.tm_mon + 1
<< std::setw(2) << std::setfill('0') << std::right
<< t.tm_mday;
dt_t = ss.str();
// DUT1 取得
for (i = l_dut.size() - 1; i >= 0; --i) {
if (l_dut[i][0] <= dt_t) {
dut1 = stod(l_dut[i][1]);
break;
}
}
return dut1;
} catch (...) {
throw;
}
}
/*
* @brief ΔT (TT(地球時) と UT1(世界時1)の差) 計算
*
* @param 時刻 (timespec)
* @param UTC - TAI (int)
* @param DUT1 (float)
* @return ΔT (float)
*/
float Time::calc_dlt_t(struct timespec ts, int utc_tai, float dut1) {
struct tm t;
int year; // 西暦年(対象年)
double y; // 西暦年(計算用)
try {
if (dlt_t != 0.0) return dlt_t;
if (utc_tai != 0) return kTtTai - utc_tai - dut1;
localtime_r(&ts.tv_sec, &t);
year = t.tm_year + 1900;
y = year + (t.tm_mon + 1 - 0.5) / 12;
if ( year < -500) {
dlt_t = calc_dlt_t_bf_m500(y);
} else if ( -500 <= year && year < 500) {
dlt_t = calc_dlt_t_bf_0500(y);
} else if ( 500 <= year && year < 1600) {
dlt_t = calc_dlt_t_bf_1600(y);
} else if ( 1600 <= year && year < 1700) {
dlt_t = calc_dlt_t_bf_1700(y);
} else if ( 1700 <= year && year < 1800) {
dlt_t = calc_dlt_t_bf_1800(y);
} else if ( 1800 <= year && year < 1860) {
dlt_t = calc_dlt_t_bf_1860(y);
} else if ( 1860 <= year && year < 1900) {
dlt_t = calc_dlt_t_bf_1900(y);
} else if ( 1900 <= year && year < 1920) {
dlt_t = calc_dlt_t_bf_1920(y);
} else if ( 1920 <= year && year < 1941) {
dlt_t = calc_dlt_t_bf_1941(y);
} else if ( 1941 <= year && year < 1961) {
dlt_t = calc_dlt_t_bf_1961(y);
} else if ( 1961 <= year && year < 1986) {
dlt_t = calc_dlt_t_bf_1986(y);
} else if ( 1986 <= year && year < 2005) {
dlt_t = calc_dlt_t_bf_2005(y);
} else if ( 2005 <= year && year < 2050) {
dlt_t = calc_dlt_t_bf_2050(y);
} else if ( 2050 <= year && year <= 2150) {
dlt_t = calc_dlt_t_to_2150(y);
} else if ( 2150 < year ) {
dlt_t = calc_dlt_t_af_2150(y);
}
} catch (...) {
throw;
}
return dlt_t;
}
} // namespace sun_moon
| 24.661972
| 73
| 0.503522
|
komasaru
|
7ac4815337ebec182ca2ce2601cb7a81b1c55015
| 237
|
cpp
|
C++
|
src/Resources/config/parameters.cpp
|
Inlife/video-cube
|
1caefa2b2cda7c1386c3b75796086cb7201f5e8d
|
[
"MIT"
] | 2
|
2015-08-19T13:52:43.000Z
|
2016-09-02T23:12:32.000Z
|
src/Resources/config/parameters.cpp
|
Inlife/video-cube
|
1caefa2b2cda7c1386c3b75796086cb7201f5e8d
|
[
"MIT"
] | null | null | null |
src/Resources/config/parameters.cpp
|
Inlife/video-cube
|
1caefa2b2cda7c1386c3b75796086cb7201f5e8d
|
[
"MIT"
] | 1
|
2018-05-25T11:29:45.000Z
|
2018-05-25T11:29:45.000Z
|
using namespace Cooper;
// Set params for DB connection
void loadParams() {
config["dbname"] = "videocube";
config["user"] = "postgres";
config["password"] = "1we2q3";
config["hostaddr"] = "93.73.16.132";
config["port"] = "5432";
}
| 23.7
| 37
| 0.649789
|
Inlife
|
7ac53260bea8f6577ff7db4b87860ab863908f89
| 2,468
|
hh
|
C++
|
src/renderer/font.hh
|
nilium/snow
|
296466e49fd5ebd8d4d40dbf96b14903daa705a8
|
[
"Zlib",
"BSD-2-Clause"
] | 4
|
2015-10-01T20:10:20.000Z
|
2021-08-28T23:43:33.000Z
|
src/renderer/font.hh
|
nilium/snow
|
296466e49fd5ebd8d4d40dbf96b14903daa705a8
|
[
"Zlib",
"BSD-2-Clause"
] | null | null | null |
src/renderer/font.hh
|
nilium/snow
|
296466e49fd5ebd8d4d40dbf96b14903daa705a8
|
[
"Zlib",
"BSD-2-Clause"
] | null | null | null |
/*
font.hh -- Copyright (c) 2013 Noel Cower. All rights reserved.
See COPYING under the project root for the source code license. If this file
is not present, refer to <https://raw.github.com/nilium/snow/master/COPYING>.
*/
#ifndef __SNOW__FONT_HH__
#define __SNOW__FONT_HH__
#include "../config.hh"
#include <snow/math/math3d.hh>
#include <map>
#include <utility>
#include <vector>
namespace snow {
struct rdraw_2d_t;
struct rfont_t;
struct rmaterial_t;
struct database_t;
struct rfont_t
{
rfont_t(database_t &db, const string &name);
~rfont_t();
bool valid() const;
auto name() const -> const string &;
auto line_height() const -> float;
auto leading() const -> float;
auto ascent() const -> float;
auto descent() const -> float;
auto bbox_min() const -> const vec2f_t &;
auto bbox_max() const -> const vec2f_t &;
auto font_page_count() const -> size_t;
void set_font_page(size_t page, rmaterial_t *mat);
auto font_page(size_t page) const -> rmaterial_t *;
void draw_text(rdraw_2d_t &draw, const vec2f_t &baseline, const string &text,
const vec4f_t &color = { 255, 255, 255, 255 },
bool ignore_newlines = true, float scale = 1.0f) const;
private:
void load_from_db(database_t &db);
void load_glyphs_from_db(database_t &db, const int font_id);
void load_kerns_from_db(database_t &db, const int font_id);
auto kern_for(uint32_t first, uint32_t second) const -> float;
struct glyph_t
{
glyph_t() = default;
uint32_t page = -1;
vec2f_t uv_min = vec2f_t::zero;
vec2f_t uv_max = vec2f_t::zero;
vec2f_t size = vec2f_t::zero;
vec2f_t advance = vec2f_t::zero;
vec2f_t offset = vec2f_t::zero;
};
using glyphmap_t = std::map<uint32_t, glyph_t>;
// yes, this is totally sane
using kern_pair_t = std::pair<uint32_t, uint32_t>;
using kernmap_t = std::map<kern_pair_t, float>;
bool valid_ = false;
float line_height_;
float leading_;
float ascent_;
float descent_;
vec2f_t bbox_min_;
vec2f_t bbox_max_;
vec2_t<uint32_t> page_size_;
string name_;
glyphmap_t glyphs_;
kernmap_t kerns_;
std::vector<rmaterial_t *> pages_;
};
} // namespace snow
#endif /* end __SNOW__FONT_HH__ include guard */
| 25.443299
| 79
| 0.632091
|
nilium
|
7ad3497aa709ce5262daa48f6c5146f75093bbc8
| 4,785
|
cpp
|
C++
|
src/plugins/matrixops/matrixops.cpp
|
diehlpk/phylanx
|
7eba54f0f22dc66d18addac0b24f006380d0f798
|
[
"BSL-1.0"
] | null | null | null |
src/plugins/matrixops/matrixops.cpp
|
diehlpk/phylanx
|
7eba54f0f22dc66d18addac0b24f006380d0f798
|
[
"BSL-1.0"
] | null | null | null |
src/plugins/matrixops/matrixops.cpp
|
diehlpk/phylanx
|
7eba54f0f22dc66d18addac0b24f006380d0f798
|
[
"BSL-1.0"
] | null | null | null |
// Copyright (c) 2018 Hartmut Kaiser
//
// 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)
#include <phylanx/config.hpp>
#include <phylanx/plugins/matrixops/matrixops.hpp>
#include <phylanx/plugins/plugin_factory.hpp>
#include <string>
PHYLANX_REGISTER_PLUGIN_MODULE();
PHYLANX_REGISTER_PLUGIN_FACTORY(add_dimension_plugin,
phylanx::execution_tree::primitives::add_dimension::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(arange_plugin,
phylanx::execution_tree::primitives::arange::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(
argmax_plugin, phylanx::execution_tree::primitives::argmax::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(
argmin_plugin, phylanx::execution_tree::primitives::argmin::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(count_nonzero_operation_plugin,
phylanx::execution_tree::primitives::count_nonzero_operation::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(column_slicing_operation_plugin,
phylanx::execution_tree::primitives::slicing_operation::match_data[2]);
PHYLANX_REGISTER_PLUGIN_FACTORY(cumsum_operation_plugin,
phylanx::execution_tree::primitives::cumsum::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(
constant_plugin, phylanx::execution_tree::primitives::constant::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(cross_operation_plugin,
phylanx::execution_tree::primitives::cross_operation::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(determinant_plugin,
phylanx::execution_tree::primitives::determinant::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(diag_operation_plugin,
phylanx::execution_tree::primitives::diag_operation::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(dot_operation_plugin,
phylanx::execution_tree::primitives::dot_operation::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(extract_shape_plugin,
phylanx::execution_tree::primitives::extract_shape::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(gradient_operation_plugin,
phylanx::execution_tree::primitives::gradient_operation::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(hstack_operation_plugin,
phylanx::execution_tree::primitives::hstack_operation::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(
identity_plugin, phylanx::execution_tree::primitives::identity::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(inverse_operation_plugin,
phylanx::execution_tree::primitives::inverse_operation::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(linearmatrix_plugin,
phylanx::execution_tree::primitives::linearmatrix::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(
linspace_plugin, phylanx::execution_tree::primitives::linspace::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(mean_operation_plugin,
phylanx::execution_tree::primitives::mean_operation::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(power_operation_plugin,
phylanx::execution_tree::primitives::power_operation::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(
random_plugin, phylanx::execution_tree::primitives::random::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(row_slicing_operation_plugin,
phylanx::execution_tree::primitives::slicing_operation::match_data[1]);
PHYLANX_REGISTER_PLUGIN_FACTORY(shuffle_operation_plugin,
phylanx::execution_tree::primitives::shuffle_operation::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(slicing_operation_plugin,
phylanx::execution_tree::primitives::slicing_operation::match_data[0]);
PHYLANX_REGISTER_PLUGIN_FACTORY(sum_operation_plugin,
phylanx::execution_tree::primitives::sum_operation::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(transpose_operation_plugin,
phylanx::execution_tree::primitives::transpose_operation::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(vstack_operation_plugin,
phylanx::execution_tree::primitives::vstack_operation::match_data);
PHYLANX_REGISTER_PLUGIN_FACTORY(get_seed,
phylanx::execution_tree::primitives::get_seed_match_data,
"get_seed_action");
PHYLANX_REGISTER_PLUGIN_FACTORY(set_seed,
phylanx::execution_tree::primitives::set_seed_match_data,
"set_seed_action");
namespace phylanx { namespace plugin
{
struct generic_operation_plugin : plugin_base
{
void register_known_primitives() override
{
namespace pet = phylanx::execution_tree;
std::string generic_operation_name("__gen");
for (auto const& pattern :
pet::primitives::generic_operation::match_data)
{
pet::register_pattern(generic_operation_name, pattern);
}
}
};
}}
PHYLANX_REGISTER_PLUGIN_FACTORY(phylanx::plugin::generic_operation_plugin,
generic_operation_plugin,
phylanx::execution_tree::primitives::make_list::match_data, "__gen");
| 48.826531
| 80
| 0.814002
|
diehlpk
|
7ad81a440c2097e32d4f628938d66eda083dd01f
| 344
|
cpp
|
C++
|
ycitoj/week2_div2/b.cpp
|
Zilanlann/cp-code
|
0500acbf6fb05a66f7bdbdf0e0a8bd6170126a4a
|
[
"MIT"
] | 3
|
2022-03-30T14:14:57.000Z
|
2022-03-31T04:30:32.000Z
|
ycitoj/week2_div2/b.cpp
|
Zilanlann/cp-code
|
0500acbf6fb05a66f7bdbdf0e0a8bd6170126a4a
|
[
"MIT"
] | null | null | null |
ycitoj/week2_div2/b.cpp
|
Zilanlann/cp-code
|
0500acbf6fb05a66f7bdbdf0e0a8bd6170126a4a
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <vector>
int main() {
int n;
std::cin >> n;
std::vector<int> ve(n);
for (auto& v : ve) std::cin >> v;
int l = 0, r = n - 1;
while (l < n || r >= 0) {
if (l < n) std::cout << ve[l] << " ";
if (r >= 0) std::cout << ve[r] << " ";
l += 2, r -= 2;
}
return 0;
}
| 19.111111
| 46
| 0.389535
|
Zilanlann
|
7adedafade2a2f8465e127b09567f2f437531595
| 2,483
|
cpp
|
C++
|
rendu/src/Declaration.cpp
|
H4112/GrammairesLangages
|
437a1b692217d85c7146404b0bdb7b8d292de6bd
|
[
"Apache-2.0"
] | null | null | null |
rendu/src/Declaration.cpp
|
H4112/GrammairesLangages
|
437a1b692217d85c7146404b0bdb7b8d292de6bd
|
[
"Apache-2.0"
] | null | null | null |
rendu/src/Declaration.cpp
|
H4112/GrammairesLangages
|
437a1b692217d85c7146404b0bdb7b8d292de6bd
|
[
"Apache-2.0"
] | null | null | null |
/*************************************************************************
Declaration - Déclaration d'une variable/constante
-------------------
début : 8 mars 2016 11:21:34
copyright : (C) 2016 par H4112
*************************************************************************/
//---------- Réalisation de la classe <Declaration> (fichier Declaration.cpp) --
//---------------------------------------------------------------- INCLUDE
//-------------------------------------------------------- Include système
#include <iostream>
using namespace std;
//------------------------------------------------------ Include personnel
#include "Declaration.h"
//------------------------------------------------------------- Constantes
//---------------------------------------------------- Variables de classe
//----------------------------------------------------------- Types privés
//----------------------------------------------------------------- PUBLIC
//-------------------------------------------------------- Fonctions amies
//----------------------------------------------------- Méthodes publiques
bool Declaration::EstUtilise ( ) const
{
return utilise;
}
string Declaration::GetId ( ) const
{
return id;
}
void Declaration::Utiliser ( )
{
utilise = true;
}
int Declaration::GetValeur ( ) const
{
return valeur;
}
//------------------------------------------------- Surcharge d'opérateurs
ostream & operator << ( ostream & out, const Declaration & declaration )
{
if(declaration.EstAffectable())
{
out << "var " << declaration.GetId();
}
else
{
out << "const " << declaration.GetId() << " = " << declaration.GetValeur();
}
return out;
}
//-------------------------------------------- Constructeurs - destructeur
Declaration::Declaration ( string unId, int uneValeur )
: valeur ( uneValeur ), id ( unId ), utilise ( false )
{
#ifdef MAP
cout << "Appel au constructeur de <Declaration>" << endl;
#endif
} //----- Fin de Declaration
Declaration::~Declaration ( )
{
#ifdef MAP
cout << "Appel au destructeur de <Declaration>" << endl;
#endif
} //----- Fin de ~Declaration
//------------------------------------------------------------------ PRIVE
//----------------------------------------------------- Méthodes protégées
//------------------------------------------------------- Méthodes privées
| 28.54023
| 83
| 0.373339
|
H4112
|
7aefcef675d734cdc99c8b7fe4152baee547564e
| 7,706
|
cpp
|
C++
|
ropgenerator/cpp-core/Semantic.cpp
|
avltree9798/ropgenerator
|
c63c81f03e8653dc3911e21300c00003a4224f6a
|
[
"MIT"
] | 1
|
2021-01-07T13:16:19.000Z
|
2021-01-07T13:16:19.000Z
|
ropgenerator/cpp-core/Semantic.cpp
|
avltree9798/ropgenerator
|
c63c81f03e8653dc3911e21300c00003a4224f6a
|
[
"MIT"
] | null | null | null |
ropgenerator/cpp-core/Semantic.cpp
|
avltree9798/ropgenerator
|
c63c81f03e8653dc3911e21300c00003a4224f6a
|
[
"MIT"
] | null | null | null |
#include "Semantic.hpp"
#include "Architecture.hpp"
// SPair
SPair::SPair(ExprObjectPtr e, CondObjectPtr c): _expr(e), _cond(c){};
ExprObjectPtr SPair::expr(){return _expr;}
CondObjectPtr SPair::cond(){return _cond;}
ExprPtr SPair::expr_ptr(){return _expr->expr_ptr();}
CondPtr SPair::cond_ptr(){return _cond->cond_ptr();}
void SPair::set_cond(CondObjectPtr cond){ _cond = cond; }
void SPair::print(ostream& os){
os << "\n\tExpr: " << _expr;
os << "\n\tCond: " << _cond << endl;
}
// Semantics
Semantics::Semantics(){
_regs = vector<reg_pair>();
_mem = vector<mem_pair>();
}
void Semantics::add_reg(int num, vector<SPair> *pairs){
_regs.push_back(make_pair(num, pairs));
}
void Semantics::add_mem(ExprObjectPtr addr, vector<SPair> *pairs){
_mem.push_back(make_pair(addr, pairs));
}
vector<reg_pair>& Semantics::regs(){return _regs;}
vector<mem_pair>& Semantics::mem(){return _mem;}
vector<SPair>* Semantics::get_reg(int num){
vector<reg_pair>::iterator it;
for(it = _regs.begin(); it != _regs.end(); it++ ){
if( (*it).first == num )
return (*it).second;
}
return nullptr;
}
void Semantics::print(ostream& os){
vector<reg_pair>::iterator it;
vector<mem_pair>::iterator mit;
vector<SPair>::iterator pit;
for(it = _regs.begin(); it != _regs.end(); it++ ){
os << "\n-- Register " << curr_arch()->reg_name((*it).first) << endl;
for( pit = (*it).second->begin(); pit != (*it).second->end(); pit++ )
(*pit).print(os);
}
for(mit = _mem.begin(); mit != _mem.end(); mit++ ){
os << "\n-- Memory [ " << (*mit).first << " ]" << endl;
for( pit = (*mit).second->begin(); pit != (*mit).second->end(); pit++ )
(*pit).print(os);
}
}
ostream& operator<< (ostream& os, Semantics* s){
s->print(os);
return os;
}
Semantics::~Semantics(){
vector<reg_pair>::iterator it;
vector<mem_pair>::iterator mit;
for(it = _regs.begin(); it != _regs.end(); it++ ){
delete (*it).second;
(*it).second = nullptr;
}
for(mit = _mem.begin(); mit != _mem.end(); mit++ ){
delete (*mit).second;
(*mit).second = nullptr;
}
}
// Simplifications
void Semantics::simplify(){
vector<reg_pair>::iterator it;
vector<mem_pair>::iterator mit;
vector<SPair>::iterator pit;
vector<SPair>* new_pairs;
for(it = _regs.begin(); it != _regs.end(); it++ ){
new_pairs = new vector<SPair>();
for( pit = (*it).second->begin(); pit != (*it).second->end(); pit++ ){
(*pit).cond()->simplify();
// If the condition is false, ignore it ;)
if( (*pit).cond()->cond_ptr()->type() == COND_FALSE )
continue;
(*pit).expr()->simplify();
new_pairs->push_back(*pit);
}
delete (*it).second;
(*it).second = new_pairs;
}
for(mit = _mem.begin(); mit != _mem.end(); mit++ ){
(*mit).first->simplify();
new_pairs = new vector<SPair>();
for( pit = (*mit).second->begin(); pit != (*mit).second->end(); pit++ ){
(*pit).cond()->simplify();
// If the condition is false, ignore it ;)
if( (*pit).cond()->cond_ptr()->type() == COND_FALSE )
continue;
(*pit).expr()->simplify();
new_pairs->push_back(*pit);
}
delete (*mit).second;
(*mit).second = new_pairs;
}
}
// Tweaking
void Semantics::tweak(bool simplify=true){
vector<reg_pair>::iterator it;
vector<mem_pair>::iterator mit;
vector<SPair>::iterator pit;
pair<ExprObjectPtr,CondObjectPtr> epair;
pair<CondObjectPtr,CondObjectPtr> cpair;
CondObjectPtr tmp;
vector<SPair> add, last;
bool found_new;
// Regs, expressions
for(it = _regs.begin(); it != _regs.end(); it++ ){
last = *(it->second);
do{
add = vector<SPair>();
found_new = false;
for( pit = last.begin(); pit != last.end(); pit++ ){
epair = (*pit).expr()->tweak();
if( epair.first != nullptr ){
found_new = true;
if( simplify ){
epair.first->simplify();
epair.second->simplify();
}
add.push_back(SPair(epair.first, epair.second && pit->cond()));
}
}
it->second->insert(it->second->end(), add.begin(), add.end());
last = std::move(add);
}while( found_new && simplify );
}
// Regs, conditions
for(it = _regs.begin(); it != _regs.end(); it++ ){
last = *(it->second);
do{
add = vector<SPair>();
found_new = false;
for( pit = last.begin(); pit != last.end(); pit++ ){
cpair = (*pit).cond()->tweak();
if( cpair.first != nullptr ){
found_new = true;
tmp = cpair.first && cpair.second;
if( simplify ){
tmp->simplify();
}
add.push_back(SPair(pit->expr(), tmp ));
}
}
it->second->insert(it->second->end(), add.begin(), add.end());
last = std::move(add);
}while( found_new && simplify );
}
// Memory, expressions
for(mit = _mem.begin(); mit != _mem.end(); mit++ ){
last = *(mit->second);
do{
add = vector<SPair>();
found_new = false;
for( pit = last.begin(); pit != last.end(); pit++ ){
epair = (*pit).expr()->tweak();
if( epair.first != nullptr ){
found_new = true;
if( simplify ){
epair.first->simplify();
epair.second->simplify();
}
add.push_back(SPair(epair.first, epair.second && pit->cond()));
}
}
mit->second->insert(mit->second->end(), add.begin(), add.end());
last = std::move(add);
}while( found_new && simplify);
}
// Memory, conditions
for(mit = _mem.begin(); mit != _mem.end(); mit++ ){
last = *(mit->second);
do{
add = vector<SPair>();
found_new = false;
for( pit = last.begin(); pit != last.end(); pit++ ){
cpair = (*pit).cond()->tweak();
if( cpair.first != nullptr ){
found_new = true;
tmp = cpair.second && cpair.first;
if( simplify ){
tmp->simplify();
}
add.push_back(SPair(pit->expr(), tmp));
}
}
mit->second->insert(mit->second->end(), add.begin(), add.end());
last = std::move(add);
}while( found_new && simplify);
}
}
// Filtering
void Semantics::filter(){
vector<reg_pair>::iterator it;
vector<mem_pair>::iterator mit;
vector<SPair>::iterator pit;
for(it = _regs.begin(); it != _regs.end(); it++ ){
for( pit = (*it).second->begin(); pit != (*it).second->end(); pit++ ){
(*pit).expr()->filter();
(*pit).cond()->filter();
}
}
for(mit = _mem.begin(); mit != _mem.end(); mit++ ){
(*mit).first->filter();
for( pit = (*mit).second->begin(); pit != (*mit).second->end(); pit++ ){
(*pit).expr()->filter();
(*pit).cond()->filter();
}
}
}
| 33.215517
| 83
| 0.482481
|
avltree9798
|
7aefe6cf4324a86095607d412beed8d388d0e394
| 2,741
|
cc
|
C++
|
test/cow/surface-source/surface_source_test.cc
|
halleyzhao/alios-mm
|
bef2a6de0c207a5ae9bf4f63de2e562df864aa3e
|
[
"Apache-2.0"
] | null | null | null |
test/cow/surface-source/surface_source_test.cc
|
halleyzhao/alios-mm
|
bef2a6de0c207a5ae9bf4f63de2e562df864aa3e
|
[
"Apache-2.0"
] | null | null | null |
test/cow/surface-source/surface_source_test.cc
|
halleyzhao/alios-mm
|
bef2a6de0c207a5ae9bf4f63de2e562df864aa3e
|
[
"Apache-2.0"
] | null | null | null |
/**
* Copyright (C) 2017 Alibaba Group Holding Limited. All Rights Reserved.
*
*
* 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 <unistd.h>
#include <gtest/gtest.h>
#include <multimedia/component.h>
#include <multimedia/mm_debug.h>
#include <multimedia/component_factory.h>
#include "multimedia/media_attr_str.h"
#include "multimedia/media_buffer.h"
using namespace YUNOS_MM;
class VideosourceTest : public testing::Test {
protected:
virtual void SetUp() {
}
virtual void TearDown() {
}
};
TEST_F(VideosourceTest, videosourceTest) {
mm_status_t status = MM_ERROR_SUCCESS;
ComponentSP sourceSP;
int count = 300;
sourceSP = ComponentFactory::create(NULL, MEDIA_MIMETYPE_VIDEO_SURFACE_SOURCE, false);
MediaMetaSP meta = MediaMeta::create();
meta->setInt32(MEDIA_ATTR_WIDTH, 1280);
meta->setInt32(MEDIA_ATTR_HEIGHT, 720);
meta->setFloat(MEDIA_ATTR_FRAME_RATE, 30.0f);
status = sourceSP->setParameter(meta);
EXPECT_FALSE(status != MM_ERROR_SUCCESS && status != MM_ERROR_ASYNC);
usleep(20*1000ll);
PRINTF("source setParameter done\n");
status = sourceSP->prepare();
EXPECT_FALSE(status != MM_ERROR_SUCCESS && status != MM_ERROR_ASYNC);
usleep(500*1000ll);
PRINTF("source prepared\n");
status = sourceSP->start();
EXPECT_FALSE(status != MM_ERROR_SUCCESS && status != MM_ERROR_ASYNC);
usleep(20*1000ll);
PRINTF("source started\n");
PRINTF("read source...\n");
int i = 0;
Component::ReaderSP reader = sourceSP->getReader(Component::kMediaTypeVideo);
while ((i++ < count) && reader) {
MediaBufferSP buf;
EXPECT_TRUE(reader->read(buf) == MM_ERROR_SUCCESS);
if (!(i % 20))
PRINTF("read %d buffers from source\n", i);
}
status = sourceSP->stop();
EXPECT_FALSE(status != MM_ERROR_SUCCESS && status != MM_ERROR_ASYNC);
usleep(40*1000ll);
PRINTF("source stop\n");
status = sourceSP->reset();
EXPECT_FALSE(status != MM_ERROR_SUCCESS && status != MM_ERROR_ASYNC);
usleep(40*1000ll);
PRINTF("source reset\n");
PRINTF("sourceSP.reset() begin\n");
sourceSP.reset();
PRINTF("sourceSP.reset() done\n");
PRINTF("done\n");
}
| 30.120879
| 90
| 0.686611
|
halleyzhao
|
7af39d6a6e3b660e00e08e3c35746696e18254fa
| 1,629
|
cpp
|
C++
|
HideousGameEngine/utests/Utils/GLKMath_AdditionsTests.cpp
|
chunkyguy/hideous-engine
|
45a37a262897847613022e9c0d7a797b158a29f2
|
[
"MIT"
] | 1
|
2019-09-13T18:18:07.000Z
|
2019-09-13T18:18:07.000Z
|
HideousGameEngine/utests/Utils/GLKMath_AdditionsTests.cpp
|
chunkyguy/hideous-engine
|
45a37a262897847613022e9c0d7a797b158a29f2
|
[
"MIT"
] | null | null | null |
HideousGameEngine/utests/Utils/GLKMath_AdditionsTests.cpp
|
chunkyguy/hideous-engine
|
45a37a262897847613022e9c0d7a797b158a29f2
|
[
"MIT"
] | 1
|
2019-11-21T06:32:56.000Z
|
2019-11-21T06:32:56.000Z
|
//
// GLKMath_Additions.cpp
// HideousGameEngine
//
// Created by Sid on 08/06/13.
// Copyright (c) 2013 whackylabs. All rights reserved.
//
#include <he/Utils/GLKMath_Additions.h>
#include <gtest.h>
TEST(GLKVector2, Equality){
GLKVector2 a = GLKVector2Make(0.5f, 0.5f);
GLKVector2 b = GLKVector2Make(0.5f, 0.5f);
EXPECT_TRUE(a == b);
}
TEST(GLKVector2, AlmostEquality){
GLKVector2 a = GLKVector2Make(0.5f, 0.5f);
GLKVector2 b = GLKVector2Make(0.5000001f, 0.5000001f);
EXPECT_TRUE(a == b);
}
TEST(GLKVector3, Equality){
GLKVector3 a = GLKVector3Make(0.5f, 0.5f, 0.5f);
GLKVector3 b = GLKVector3Make(0.5f, 0.5f, 0.5f);
EXPECT_TRUE(a == b);
}
TEST(GLKVector3, AlmostEquality){
GLKVector3 a = GLKVector3Make(0.5f, 0.5f, 0.5f);
GLKVector3 b = GLKVector3Make(0.5000001f, 0.5000001f, 0.5000001f);
EXPECT_TRUE(a == b);
}
TEST(GLKVector4, Equality){
GLKVector4 a = GLKVector4Make(0.5f, 0.5f, 0.5f, 0.5f);
GLKVector4 b = GLKVector4Make(0.5f, 0.5f, 0.5f, 0.5f);
EXPECT_TRUE(a == b);
}
TEST(GLKVector4, AlmostEquality){
GLKVector4 a = GLKVector4Make(0.5f, 0.5f, 0.5f, 0.5f);
GLKVector4 b = GLKVector4Make(0.5000001f, 0.5000001f, 0.5000001f, 0.5000001f);
EXPECT_TRUE(a == b);
}
TEST(GLKMatrix4, Equality){
GLKMatrix4 a = GLKMatrix4MakeXRotation(1);
GLKMatrix4 b = GLKMatrix4MakeXRotation(1);
EXPECT_TRUE(a == b);
}
TEST(GLKMatrix4, TransformIdentity){
GLKVector3 trans_vec = GLKVector3Make(14, 25, 36);
GLKMatrix4 a = GLKMatrix4MakeTranslation(trans_vec.x, trans_vec.y, trans_vec.z);
GLKMatrix4 b = GLKMatrix4Translate(GLKMatrix4Identity, trans_vec.x, trans_vec.y, trans_vec.z);
EXPECT_TRUE(a == b);
}
| 26.704918
| 95
| 0.715163
|
chunkyguy
|
7afa88bc487a030c3f58270a5bb0b8f13c7703c1
| 779
|
hpp
|
C++
|
include/SFPlot/CartesianData.hpp
|
MoriokaReimen/SFPlot
|
64b50500076a683026e4e439a9315f3725f1236f
|
[
"MIT"
] | 3
|
2021-01-25T14:30:36.000Z
|
2021-03-10T17:12:41.000Z
|
include/SFPlot/CartesianData.hpp
|
MoriokaReimen/SFPlot
|
64b50500076a683026e4e439a9315f3725f1236f
|
[
"MIT"
] | 1
|
2021-06-11T10:35:07.000Z
|
2021-06-11T10:35:07.000Z
|
include/SFPlot/CartesianData.hpp
|
MoriokaReimen/SFPlot
|
64b50500076a683026e4e439a9315f3725f1236f
|
[
"MIT"
] | null | null | null |
#pragma once
#include <vector>
#include <utility>
#include <SFML/Graphics.hpp>
namespace sf
{
/**
* @relates CartesianChart
* data class which holds data member of cartesian chart plot.
*
*/
struct CartesianData {
/**
* @relates CartesianData
* specifier switches plotting method of data
*/
enum class PLOT_TYPE {
POINT, /**< plot data with point */
LINE /**< plot data with line */
};
std::vector<sf::Vector2<double>> data; /**< value of each point */
sf::Color color; /**< plotting color */
PLOT_TYPE type; /**< type of plot */
CartesianData();
virtual ~CartesianData();
std::pair<double, double> getRangeX() const;
std::pair<double, double> getRangeY() const;
};
};
| 24.34375
| 70
| 0.599487
|
MoriokaReimen
|
7afd08ef5616ddc983dffeba64830f44449b9cbe
| 1,030
|
hpp
|
C++
|
src/version.hpp
|
pangenome/smoothxg
|
0f383e5033c6af18d95f5d8dca0a6e17e5dbf524
|
[
"MIT"
] | 18
|
2020-10-02T18:39:03.000Z
|
2022-01-27T11:18:29.000Z
|
src/version.hpp
|
pangenome/smoothxg
|
0f383e5033c6af18d95f5d8dca0a6e17e5dbf524
|
[
"MIT"
] | 50
|
2020-09-30T17:52:18.000Z
|
2022-03-17T10:14:21.000Z
|
src/version.hpp
|
ekg/smoothxg
|
20fee54d5279dd8bb435fb95b93b386cc5eec997
|
[
"MIT"
] | 2
|
2020-08-28T13:08:09.000Z
|
2020-09-23T20:15:17.000Z
|
// version.hpp: Version reflection information for smoothxg builds.
// modified from https://github.com/vgteam/vg/blob/master/src/version.hpp
#include <string>
#include <unordered_map>
namespace smoothxg {
using namespace std;
/// Class for holding smoothxg version.
class Version {
public:
/// The Git version description of this build of smoothxg
const static string VERSION;
/// Get only the version (like v1.7.0-68-g224e7625).
static string get_version();
/// Get the release Git tag version of smoothxg that the current version
/// is based on (e.g. v1.7.0-68-g224e7625 will report v1.7.0).
static string get_release();
/// Get the codename of our released version
static string get_codename();
/// Get a short one-line description of the current version of smoothxg with no terminating newline.
static string get_short();
private:
// Not constructable
Version() = delete;
/// Store all the codenames by major version
const static unordered_map<string, string> codenames;
};
}
| 25.75
| 102
| 0.727184
|
pangenome
|
bb005b41189f732a97e04e3bba59b627948b006f
| 8,103
|
cc
|
C++
|
impl-endpoints/boringssl/runner-src/transport_common.cc
|
mingtaoy/tls-interop-runner
|
1d99bab0dabab21e27dd706b9e86448e4867b531
|
[
"MIT",
"Apache-2.0",
"BSD-3-Clause"
] | 7
|
2020-12-12T00:05:52.000Z
|
2021-05-12T06:59:36.000Z
|
impl-endpoints/boringssl/runner-src/transport_common.cc
|
mingtaoy/tls-interop-runner
|
1d99bab0dabab21e27dd706b9e86448e4867b531
|
[
"MIT",
"Apache-2.0",
"BSD-3-Clause"
] | 35
|
2020-12-11T18:30:41.000Z
|
2022-01-20T21:58:00.000Z
|
impl-endpoints/boringssl/runner-src/transport_common.cc
|
mingtaoy/tls-interop-runner
|
1d99bab0dabab21e27dd706b9e86448e4867b531
|
[
"MIT",
"Apache-2.0",
"BSD-3-Clause"
] | 10
|
2020-12-12T00:05:58.000Z
|
2021-12-02T21:47:07.000Z
|
// SPDX-FileCopyrightText: 2014 Google Inc.
// SPDX-License-Identifier: ISC
#include <openssl/base.h>
#include <string>
#include <vector>
#include <errno.h>
#include <limits.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <unistd.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <openssl/x509.h>
#include "internal.h"
#include "transport_common.h"
using socket_result_t = ssize_t;
static int closesocket(int sock) { return close(sock); }
static inline void *OPENSSL_memset(void *dst, int c, size_t n) {
if (n == 0) {
return dst;
}
return memset(dst, c, n);
}
static void SplitHostPort(std::string *out_hostname, std::string *out_port,
const std::string &hostname_and_port) {
size_t colon_offset = hostname_and_port.find_last_of(':');
const size_t bracket_offset = hostname_and_port.find_last_of(']');
std::string hostname, port;
// An IPv6 literal may have colons internally, guarded by square brackets.
if (bracket_offset != std::string::npos &&
colon_offset != std::string::npos && bracket_offset > colon_offset) {
colon_offset = std::string::npos;
}
if (colon_offset == std::string::npos) {
*out_hostname = hostname_and_port;
*out_port = "443";
} else {
*out_hostname = hostname_and_port.substr(0, colon_offset);
*out_port = hostname_and_port.substr(colon_offset + 1);
}
}
static std::string GetLastSocketErrorString() { return strerror(errno); }
static void PrintSocketError(const char *function) {
std::string error = GetLastSocketErrorString();
fprintf(stderr, "%s: %s\n", function, error.c_str());
}
// Connect sets |*out_sock| to be a socket connected to the destination given
// in |hostname_and_port|, which should be of the form "www.example.com:123".
// It returns true on success and false otherwise.
bool Connect(int *out_sock, const std::string &hostname_and_port) {
std::string hostname, port;
SplitHostPort(&hostname, &port, hostname_and_port);
// Handle IPv6 literals.
if (hostname.size() >= 2 && hostname[0] == '[' &&
hostname[hostname.size() - 1] == ']') {
hostname = hostname.substr(1, hostname.size() - 2);
}
struct addrinfo hint, *result;
OPENSSL_memset(&hint, 0, sizeof(hint));
hint.ai_family = AF_UNSPEC;
hint.ai_socktype = SOCK_STREAM;
int ret = getaddrinfo(hostname.c_str(), port.c_str(), &hint, &result);
if (ret != 0) {
const char *error = gai_strerror(ret);
fprintf(stderr, "getaddrinfo returned: %s\n", error);
return false;
}
bool ok = false;
char buf[256];
*out_sock =
socket(result->ai_family, result->ai_socktype, result->ai_protocol);
if (*out_sock < 0) {
PrintSocketError("socket");
goto out;
}
switch (result->ai_family) {
case AF_INET: {
struct sockaddr_in *sin =
reinterpret_cast<struct sockaddr_in *>(result->ai_addr);
fprintf(stderr, "Connecting to %s:%d\n",
inet_ntop(result->ai_family, &sin->sin_addr, buf, sizeof(buf)),
ntohs(sin->sin_port));
break;
}
case AF_INET6: {
struct sockaddr_in6 *sin6 =
reinterpret_cast<struct sockaddr_in6 *>(result->ai_addr);
fprintf(stderr, "Connecting to [%s]:%d\n",
inet_ntop(result->ai_family, &sin6->sin6_addr, buf, sizeof(buf)),
ntohs(sin6->sin6_port));
break;
}
}
if (connect(*out_sock, result->ai_addr, result->ai_addrlen) != 0) {
PrintSocketError("connect");
goto out;
}
ok = true;
out:
freeaddrinfo(result);
return ok;
}
Listener::~Listener() {
if (server_sock_ >= 0) {
closesocket(server_sock_);
}
}
bool Listener::Init(const uint16_t &port) {
if (server_sock_ >= 0) {
return false;
}
struct sockaddr_in6 addr;
OPENSSL_memset(&addr, 0, sizeof(addr));
addr.sin6_family = AF_INET6;
addr.sin6_addr = IN6ADDR_ANY_INIT;
addr.sin6_port = htons(port);
const int enable = 1;
server_sock_ = socket(addr.sin6_family, SOCK_STREAM, 0);
if (server_sock_ < 0) {
PrintSocketError("socket");
return false;
}
if (setsockopt(server_sock_, SOL_SOCKET, SO_REUSEADDR, (const char *)&enable,
sizeof(enable)) < 0) {
PrintSocketError("setsockopt");
return false;
}
if (bind(server_sock_, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
PrintSocketError("connect");
return false;
}
listen(server_sock_, SOMAXCONN);
return true;
}
bool Listener::Accept(int *out_sock) {
struct sockaddr_in6 addr;
socklen_t addr_len = sizeof(addr);
*out_sock = accept(server_sock_, (struct sockaddr *)&addr, &addr_len);
return *out_sock >= 0;
}
void PrintConnectionInfo(BIO *bio, const SSL *ssl) {
const SSL_CIPHER *cipher = SSL_get_current_cipher(ssl);
BIO_printf(bio, " Version: %s\n", SSL_get_version(ssl));
BIO_printf(bio, " Resumed session: %s\n",
SSL_session_reused(ssl) ? "yes" : "no");
BIO_printf(bio, " Cipher: %s\n", SSL_CIPHER_standard_name(cipher));
uint16_t curve = SSL_get_curve_id(ssl);
if (curve != 0) {
BIO_printf(bio, " ECDHE curve: %s\n", SSL_get_curve_name(curve));
}
uint16_t sigalg = SSL_get_peer_signature_algorithm(ssl);
if (sigalg != 0) {
BIO_printf(bio, " Signature algorithm: %s\n",
SSL_get_signature_algorithm_name(
sigalg, SSL_version(ssl) != TLS1_2_VERSION));
}
BIO_printf(bio, " Secure renegotiation: %s\n",
SSL_get_secure_renegotiation_support(ssl) ? "yes" : "no");
BIO_printf(bio, " Extended master secret: %s\n",
SSL_get_extms_support(ssl) ? "yes" : "no");
const uint8_t *next_proto;
unsigned next_proto_len;
SSL_get0_next_proto_negotiated(ssl, &next_proto, &next_proto_len);
BIO_printf(bio, " Next protocol negotiated: %.*s\n", next_proto_len,
next_proto);
const uint8_t *alpn;
unsigned alpn_len;
SSL_get0_alpn_selected(ssl, &alpn, &alpn_len);
BIO_printf(bio, " ALPN protocol: %.*s\n", alpn_len, alpn);
const char *host_name = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
if (host_name != nullptr && SSL_is_server(ssl)) {
BIO_printf(bio, " Client sent SNI: %s\n", host_name);
}
if (!SSL_is_server(ssl)) {
const uint8_t *ocsp_staple;
size_t ocsp_staple_len;
SSL_get0_ocsp_response(ssl, &ocsp_staple, &ocsp_staple_len);
BIO_printf(bio, " OCSP staple: %s\n", ocsp_staple_len > 0 ? "yes" : "no");
const uint8_t *sct_list;
size_t sct_list_len;
SSL_get0_signed_cert_timestamp_list(ssl, &sct_list, &sct_list_len);
BIO_printf(bio, " SCT list: %s\n", sct_list_len > 0 ? "yes" : "no");
}
BIO_printf(
bio, " Early data: %s\n",
(SSL_early_data_accepted(ssl) || SSL_in_early_data(ssl)) ? "yes" : "no");
// Print the server cert subject and issuer names.
bssl::UniquePtr<X509> peer(SSL_get_peer_certificate(ssl));
if (peer != nullptr) {
BIO_printf(bio, " Cert subject: ");
X509_NAME_print_ex(bio, X509_get_subject_name(peer.get()), 0,
XN_FLAG_ONELINE);
BIO_printf(bio, "\n Cert issuer: ");
X509_NAME_print_ex(bio, X509_get_issuer_name(peer.get()), 0,
XN_FLAG_ONELINE);
BIO_printf(bio, "\n");
}
}
void PrintSSLError(FILE *file, const char *msg, int ssl_err, int ret) {
switch (ssl_err) {
case SSL_ERROR_SSL:
fprintf(file, "%s: %s\n", msg, ERR_reason_error_string(ERR_peek_error()));
break;
case SSL_ERROR_SYSCALL:
if (ret == 0) {
fprintf(file, "%s: peer closed connection\n", msg);
} else {
std::string error = GetLastSocketErrorString();
fprintf(file, "%s: %s\n", msg, error.c_str());
}
break;
case SSL_ERROR_ZERO_RETURN:
fprintf(file, "%s: received close_notify\n", msg);
break;
default:
fprintf(file, "%s: unexpected error: %s\n", msg,
SSL_error_description(ssl_err));
}
ERR_print_errors_fp(file);
}
| 29.790441
| 80
| 0.655066
|
mingtaoy
|
bb0151f5d0be04570308242c3e31d4e57f7f3d44
| 6,864
|
cpp
|
C++
|
Moco/Executable/opensim-moco.cpp
|
zhengsizehrb/opensim-moco
|
9844abc640a34d818a4bb21ef4fea3c3cb0f34ed
|
[
"Apache-2.0"
] | 41
|
2019-11-13T10:29:20.000Z
|
2022-03-10T17:42:30.000Z
|
Moco/Executable/opensim-moco.cpp
|
zhengsizehrb/opensim-moco
|
9844abc640a34d818a4bb21ef4fea3c3cb0f34ed
|
[
"Apache-2.0"
] | 165
|
2019-11-13T00:55:57.000Z
|
2022-03-04T19:02:26.000Z
|
Moco/Executable/opensim-moco.cpp
|
zhengsizehrb/opensim-moco
|
9844abc640a34d818a4bb21ef4fea3c3cb0f34ed
|
[
"Apache-2.0"
] | 15
|
2020-01-24T23:57:57.000Z
|
2021-12-10T21:59:46.000Z
|
/* -------------------------------------------------------------------------- *
* OpenSim Moco: opensim-moco.cpp *
* -------------------------------------------------------------------------- *
* Copyright (c) 2017-19 Stanford University and the Authors *
* *
* Author(s): Christopher Dembia *
* *
* 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 <Moco/About.h>
#include <Moco/MocoProblem.h>
#include <Moco/MocoStudy.h>
#include <Moco/MocoUtilities.h>
#include <iostream>
#include <OpenSim/Common/Object.h>
#include <OpenSim/Common/LoadOpenSimLibrary.h>
#include <OpenSim/Simulation/osimSimulation.h>
using namespace OpenSim;
static const char helpMessage[] =
R"(OpenSim Moco. Use this command to run a MocoStudy (.omoco file).
Usage:
opensim-moco -h | --help
Print this help message.
opensim-moco -V | --version
Print Moco's version.
opensim-moco [--library=<path>] run [--visualize] <.omoco-file>
Run the MocoStudy in the provided .omoco file.
opensim-moco [--library=<path>] print-xml
Print a template XML .omoco file for a MocoStudy.
opensim-moco [--library=<path>] visualize <model-or-omoco-file> [<trajectory-file>]
Visualize an OpenSim model (.osim file) with a MocoTrajectory, if provided.
If a trajectory is not provided, the model is visualized with its default
state.
You can provide a MocoStudy setup file (.omoco) instead of a model.
Use the --library flag to load a plugin.
)";
void run_tool(std::string setupFile, bool visualize) {
auto obj = std::unique_ptr<Object>(Object::makeObjectFromFile(setupFile));
OPENSIM_THROW_IF(obj == nullptr, Exception,
"A problem occurred when trying to load file '{}'.", setupFile);
if (const auto* moco = dynamic_cast<const MocoStudy*>(obj.get())) {
auto solution = moco->solve();
if (visualize) moco->visualize(solution);
} else {
throw Exception(
fmt::format("The provided file '{}' yields a '{}' but a "
"MocoStudy was expected.",
setupFile, obj->getConcreteClassName()));
}
}
void print_xml() {
const auto* obj = Object::getDefaultInstanceOfType("MocoStudy");
if (!obj) {
throw Exception("Cannot create an instance of MocoStudy.");
}
std::string fileName = "default_MocoStudy.omoco";
std::cout << "Printing '" << fileName << "'." << std::endl;
Object::setSerializeAllDefaults(true);
obj->print(fileName);
Object::setSerializeAllDefaults(false);
}
void visualize(std::string file, std::string trajectory_file) {
std::unique_ptr<Model> model;
if (file.rfind(".osim") != std::string::npos) {
model = OpenSim::make_unique<Model>(file);
} else {
MocoStudy study(file);
const MocoPhase& phase = study.getProblem().getPhase(0);
model.reset(phase.getModel().clone());
}
if (trajectory_file.empty()) {
// No motion provided.
model->setUseVisualizer(true);
auto state = model->initSystem();
model->getVisualizer().show(state);
std::cout << "Press any key to exit." << std::endl;
// Wait for user input.
std::cin.get();
} else {
MocoTrajectory trajectory(trajectory_file);
visualize(*model, trajectory.exportToStatesStorage());
}
}
int main(int argc, char* argv[]) {
try {
if (argc == 1) {
std::cout << helpMessage << std::endl;
return EXIT_SUCCESS;
}
std::string arg1(argv[1]);
std::string subcommand;
int offset = 0;
if (arg1 == "-h" || arg1 == "--help") {
std::cout << helpMessage << std::endl;
return EXIT_SUCCESS;
} else if (arg1 == "-V" || arg1 == "--version") {
std::cout << OpenSim::GetMocoVersion() << std::endl;
return EXIT_SUCCESS;
} else if (startsWith(arg1, "--library=")) {
OpenSim::LoadOpenSimLibraryExact(arg1.substr(arg1.find("=") + 1));
subcommand = argv[2];
// Pretend we didn't get a library argument.
--argc;
offset = 1;
} else {
subcommand = arg1;
}
if (subcommand == "run") {
OPENSIM_THROW_IF(argc < 3 || argc > 4, Exception,
"Incorrect number of arguments.");
std::string arg2(argv[2 + offset]);
OPENSIM_THROW_IF(argc == 4 && arg2 != "--visualize", Exception,
fmt::format("Unrecognized option '{}'; did you mean "
"'--visualize'?",
arg2));
std::string setupFile;
bool visualize = false;
if (argc == 3) {
setupFile = arg2;
} else {
setupFile = std::string(argv[3 + offset]);
visualize = true;
}
run_tool(setupFile, visualize);
} else if (subcommand == "print-xml") {
OPENSIM_THROW_IF(
argc != 2, Exception, "Incorrect number of arguments.");
print_xml();
} else if (subcommand == "visualize") {
OPENSIM_THROW_IF(argc < 3 || argc > 4, Exception,
"Incorrect number of arguments.");
std::string file(argv[2 + offset]);
std::string trajectory;
if (argc == 4) {
trajectory = argv[3 + offset];
}
visualize(file, trajectory);
} else {
std::cout << "Unrecognized arguments. See usage with -h or --help"
"."
<< std::endl;
}
} catch (const std::exception& exc) {
std::cout << exc.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
| 37.102703
| 85
| 0.522436
|
zhengsizehrb
|
bb01eedfedaf302956552ab6d5207533c2c4ea93
| 9,359
|
cpp
|
C++
|
src/messages.cpp
|
wltr/maritime-sdr
|
24f434d0fbdb89c627abcee2868c22f7aa78b48e
|
[
"MIT"
] | null | null | null |
src/messages.cpp
|
wltr/maritime-sdr
|
24f434d0fbdb89c627abcee2868c22f7aa78b48e
|
[
"MIT"
] | null | null | null |
src/messages.cpp
|
wltr/maritime-sdr
|
24f434d0fbdb89c627abcee2868c22f7aa78b48e
|
[
"MIT"
] | null | null | null |
#include "messages.h"
#include <stdexcept>
#include <iostream>
uint32_t Messages::integer(const std::vector<bool>& bits, size_t begin, size_t length)
{
if (bits.size() < (begin + length)) {
throw std::runtime_error("Not enough data to extract integer");
}
if (length > 32) {
throw std::runtime_error("Can't extract integers > 32 bits");
}
uint32_t data{0};
for (auto i = 0; i < length; ++i) {
data |= bits[begin + i] << (length - i - 1);
}
return data;
}
std::string Messages::ascii(const std::vector<bool>& bits, size_t begin, size_t length)
{
if (bits.size() < (begin + length)) {
throw std::runtime_error("Not enough data to extract string");
}
if (length % ascii_char_length != 0) {
throw std::runtime_error("Length needs to be a multiple of 6");
}
std::string str;
size_t num_char = length / ascii_char_length;
for (auto i = 0; i < num_char; ++i) {
char data{0};
for (auto j = 0; j < ascii_char_length; ++j) {
data |= bits[begin + j] << (ascii_char_length - j - 1);
}
if (data < 32) {
data += 64;
}
str.append(std::string{data});
begin += ascii_char_length;
}
str.erase(str.find_last_not_of(' ') + 1);
return str;
}
uint8_t Messages::id(const std::vector<bool>& bits)
{
return integer(bits, 0, 6);
}
void Messages::decode(uint8_t channel, const std::vector<bool>& bits)
{
if (bits.empty()) {
return;
}
auto msg_id = id(bits);
switch (msg_id) {
case 1:
case 2:
case 3:
{
auto msg = decode_pos(bits);
msg.channel = channel;
print(msg);
return;
}
case 4:
{
auto msg = decode_4(bits);
msg.channel = channel;
print(msg);
return;
}
case 5:
{
auto msg = decode_5(bits);
msg.channel = channel;
print(msg);
return;
}
case 18:
{
auto msg = decode_18(bits);
msg.channel = channel;
print(msg);
return;
}
case 24:
{
auto msg = decode_24(bits);
msg.channel = channel;
print(msg);
return;
}
default:
std::cout << "AIS Msg ID " << +msg_id << ": No decoder available (" << bits.size() << " bits)" << std::endl;
return;
};
}
float Messages::longitude(int32_t value)
{
if ((value >> 27) & 0x1) {
value |= 0xf0000000;
}
return static_cast<float>(value) / 6.0e5;
}
float Messages::latitude(int32_t value)
{
if ((value >> 26) & 0x1) {
value |= 0xf8000000;
}
return static_cast<float>(value) / 6.0e5;
}
float Messages::rot(int8_t value)
{
auto v = static_cast<float>(value) / 4.733;
return v * v;
}
float Messages::sog(int16_t value)
{
return static_cast<float>(value) / 10.0;
}
float Messages::cog(int16_t value)
{
return static_cast<float>(value) / 10.0;
}
float Messages::draught(int8_t value)
{
return static_cast<float>(value) / 10.0;
}
Messages::msg_pos_t Messages::decode_pos(const std::vector<bool>& bits)
{
if (bits.size() < 168) {
throw std::runtime_error("Not enough data for AIS position report");
}
msg_pos_t msg;
msg.msg_id = id(bits);
msg.repeat = integer(bits, 6, 2);
msg.user_id = integer(bits, 8, 30);
msg.status = integer(bits, 38, 4);
msg.rot = rot(integer(bits, 42, 8));
msg.sog = sog(integer(bits, 50, 10));
msg.accuracy = integer(bits, 60, 1);
msg.lon = longitude(integer(bits, 61, 28));
msg.lat = latitude(integer(bits, 89, 27));
msg.cog = cog(integer(bits, 116, 12));
msg.hdg = integer(bits, 128, 9);
msg.time = integer(bits, 137, 6);
msg.maneuver = integer(bits, 143, 2);
msg.raim_flag = integer(bits, 148, 1);
msg.comm_state = integer(bits, 149, 19);
return std::move(msg);
}
Messages::msg_4_t Messages::decode_4(const std::vector<bool>& bits)
{
if (bits.size() < 168) {
throw std::runtime_error("Not enough data for AIS base station report");
}
msg_4_t msg;
msg.msg_id = id(bits);
msg.repeat = integer(bits, 6, 2);
msg.user_id = integer(bits, 8, 30);
msg.utc_year = integer(bits, 38, 14);
msg.utc_month = integer(bits, 52, 4);
msg.utc_day = integer(bits, 56, 5);
msg.utc_hour = integer(bits, 61, 5);
msg.utc_minute = integer(bits, 66, 6);
msg.utc_second = integer(bits, 72, 6);
msg.accuracy = integer(bits, 78, 1);
msg.lon = longitude(integer(bits, 79, 28));
msg.lat = latitude(integer(bits, 107, 27));
msg.gnss_type = integer(bits, 134, 4);
msg.longrange = integer(bits, 138, 1);
msg.raim_flag = integer(bits, 148, 1);
msg.comm_state = integer(bits, 149, 19);
return std::move(msg);
}
Messages::msg_5_t Messages::decode_5(const std::vector<bool>& bits)
{
if (bits.size() < 424) {
throw std::runtime_error("Not enough data for AIS ship static and voyage related report");
}
msg_5_t msg;
msg.msg_id = id(bits);
msg.repeat = integer(bits, 6, 2);
msg.user_id = integer(bits, 8, 30);
msg.ais_version = integer(bits, 38, 2);
msg.imo_number = integer(bits, 40, 30);
msg.callsign = ascii(bits, 70, 42);
msg.name = ascii(bits, 112, 120);
msg.ship_type = integer(bits, 232, 8);
msg.dimension_a = integer(bits, 240, 9);
msg.dimension_b = integer(bits, 249, 9);
msg.dimension_c = integer(bits, 258, 6);
msg.dimension_d = integer(bits, 264, 6);
msg.gnss_type = integer(bits, 270, 4);
msg.eta_month = integer(bits, 274, 4);
msg.eta_day = integer(bits, 278, 5);
msg.eta_hour = integer(bits, 283, 5);
msg.eta_minute = integer(bits, 288, 6);
msg.draught = draught(integer(bits, 294, 8));
msg.destination = ascii(bits, 302, 120);
msg.dte = integer(bits, 422, 1);
return std::move(msg);
}
Messages::msg_18_t Messages::decode_18(const std::vector<bool>& bits)
{
if (bits.size() < 168) {
throw std::runtime_error("Not enough data for AIS Class B equipment position report");
}
msg_18_t msg;
msg.msg_id = id(bits);
msg.repeat = integer(bits, 6, 2);
msg.user_id = integer(bits, 8, 30);
msg.sog = sog(integer(bits, 46, 10));
msg.accuracy = integer(bits, 56, 1);
msg.lon = longitude(integer(bits, 57, 28));
msg.lat = latitude(integer(bits, 85, 27));
msg.cog = cog(integer(bits, 112, 12));
msg.hdg = integer(bits, 124, 9);
msg.time = integer(bits, 133, 6);
msg.unit_flag = integer(bits, 141, 1);
msg.display_flag = integer(bits, 142, 1);
msg.dsc_flag = integer(bits, 143, 1);
msg.band_flag = integer(bits, 144, 1);
msg.msg22_flag = integer(bits, 145, 1);
msg.mode_flag = integer(bits, 146, 1);
msg.raim_flag = integer(bits, 147, 1);
msg.comm_flag = integer(bits, 148, 1);
msg.comm_state = integer(bits, 149, 19);
return std::move(msg);
}
Messages::msg_24_t Messages::decode_24(const std::vector<bool>& bits)
{
if (bits.size() < 168) {
throw std::runtime_error("Not enough data for AIS Class B equipment position report");
}
msg_24_t msg;
msg.msg_id = id(bits);
msg.repeat = integer(bits, 6, 2);
msg.user_id = integer(bits, 8, 30);
msg.part = integer(bits, 38, 2);
if (msg.part == 0) {
msg.part_a.name = ascii(bits, 40, 120);
} else if (msg.part == 1) {
msg.part_b.ship_type = integer(bits, 40, 8);
msg.part_b.vendor = ascii(bits, 48, 42);
msg.part_b.callsign = ascii(bits, 90, 42);
msg.part_b.dimension_a = integer(bits, 132, 9);
msg.part_b.dimension_b = integer(bits, 141, 9);
msg.part_b.dimension_c = integer(bits, 150, 6);
msg.part_b.dimension_d = integer(bits, 156, 6);
msg.part_b.gnss_type = integer(bits, 162, 4);
}
return msg;
}
void Messages::print(const msg_pos_t& msg)
{
std::cout << "[AIS" << +msg.channel
<< "] Message ID: " << +msg.msg_id
<< ", User ID: " << msg.user_id
<< ", Latitude: " << msg.lat
<< ", Longitute: " << msg.lon
<< ", SOG: " << msg.sog
<< ", COG: " << msg.cog
<< ", HDG: " << msg.hdg
<< ", ROT: " << msg.rot
<< std::endl;
}
void Messages::print(const msg_4_t& msg)
{
std::cout << "[AIS" << +msg.channel
<< "] Message ID: " << +msg.msg_id
<< ", User ID: " << msg.user_id
<< ", Latitude: " << msg.lat
<< ", Longitute: " << msg.lon
<< ", Date: " << msg.utc_year << "/" << msg.utc_month << "/" << msg.utc_day
<< ", Time: " << msg.utc_hour << ":" << msg.utc_minute << ":" << msg.utc_second
<< std::endl;
}
void Messages::print(const msg_5_t& msg)
{
std::cout << "[AIS" << +msg.channel
<< "] Message ID: " << +msg.msg_id
<< ", User ID: " << msg.user_id
<< ", Name: " << msg.name
<< ", Callsign: " << msg.callsign
<< ", Destination: " << msg.destination
<< ", Draught: " << msg.draught
<< std::endl;
}
void Messages::print(const msg_18_t& msg)
{
std::cout << "[AIS" << +msg.channel
<< "] Message ID: " << +msg.msg_id
<< ", User ID: " << msg.user_id
<< ", Latitude: " << msg.lat
<< ", Longitute: " << msg.lon
<< ", SOG: " << msg.sog
<< ", COG: " << msg.cog
<< ", HDG: " << msg.hdg
<< std::endl;
}
void Messages::print(const msg_24_t& msg)
{
std::cout << "[AIS" << +msg.channel
<< "] Message ID: " << +msg.msg_id
<< ", User ID: " << msg.user_id;
if (msg.part == 0) {
std::cout << ", Name: " << msg.part_a.name;
} else if (msg.part == 1) {
std::cout << ", Vendor: " << msg.part_b.vendor
<< ", Callsign: " << msg.part_b.callsign;
} else {
std::cout << " (UNKNOWN PART)";
}
std::cout << std::endl;
}
| 27.937313
| 114
| 0.593546
|
wltr
|
bb0763d3768aa1125acca645e4769cff1f3ef28b
| 1,356
|
hpp
|
C++
|
tools/train/source/transform/OpGrad.hpp
|
xindongzhang/MNN
|
f4740c78dc8fc67ee4596552d2257f12c48af067
|
[
"Apache-2.0"
] | 1
|
2019-08-09T03:16:49.000Z
|
2019-08-09T03:16:49.000Z
|
tools/train/source/transform/OpGrad.hpp
|
xindongzhang/MNN
|
f4740c78dc8fc67ee4596552d2257f12c48af067
|
[
"Apache-2.0"
] | null | null | null |
tools/train/source/transform/OpGrad.hpp
|
xindongzhang/MNN
|
f4740c78dc8fc67ee4596552d2257f12c48af067
|
[
"Apache-2.0"
] | 1
|
2021-08-23T03:40:09.000Z
|
2021-08-23T03:40:09.000Z
|
//
// OpGrad.hpp
// MNN
//
// Created by MNN on 2019/05/05.
// Copyright © 2018, Alibaba Group Holding Limited
//
#ifndef OpGrad_hpp
#define OpGrad_hpp
#include <map>
#include <vector>
#include "OpConverter.hpp"
#include "Tensor.hpp"
class MNN_PUBLIC OpGrad {
public:
enum Type { LINEAR, SEMI_LINEAR, NO_LINEAR };
OpGrad() = default;
virtual ~OpGrad() = default;
Type type() const {
return mType;
}
virtual OpConverter::Result onGrad(const MNN::NetT* net, const MNN::OpT* op,
std::map<int, std::vector<int>>& backwardTensors,
const std::vector<int>& gradTensors) = 0;
virtual bool onGradCommon(MNN::NetT* net, const MNN::OpT* op, std::map<int, std::vector<int>>& backwardTensors);
class Creator {
public:
Creator() {
}
virtual ~Creator() = default;
virtual OpGrad* onCreate(const MNN::OpT* op, const std::vector<MNN::Tensor*>& inputs,
const std::vector<MNN::Tensor*>& outputs) const = 0;
};
static Creator* get(MNN::OpType type);
static void insert(MNN::OpType type, Creator* creator);
protected:
Type mType = LINEAR;
};
MNN_PUBLIC std::string numberToString(int index);
#endif
| 27.673469
| 116
| 0.571534
|
xindongzhang
|
bb076e91aa466d83ddc027c9e5ab24ccf6e8c803
| 344
|
cpp
|
C++
|
test/functional/args.cpp
|
jonathanpoelen/falcon
|
5b60a39787eedf15b801d83384193a05efd41a89
|
[
"MIT"
] | 2
|
2018-02-02T14:19:59.000Z
|
2018-05-13T02:48:24.000Z
|
test/functional/args.cpp
|
jonathanpoelen/falcon
|
5b60a39787eedf15b801d83384193a05efd41a89
|
[
"MIT"
] | null | null | null |
test/functional/args.cpp
|
jonathanpoelen/falcon
|
5b60a39787eedf15b801d83384193a05efd41a89
|
[
"MIT"
] | null | null | null |
#include <test/test.hpp>
#include <falcon/functional/args.hpp>
#include "args.hpp"
void args_test()
{
const int i0 = 1;
const int i1 = 2;
const int i2 = 3;
CHECK((falcon::args<2, 0>()(i0, i1, i2) == std::make_tuple(i2, i0)));
CHECK((falcon::args<-1, -2>()(i0, i1, i2) == std::make_tuple(i2, i1)));
}
FALCON_TEST_TO_MAIN(args_test)
| 21.5
| 73
| 0.627907
|
jonathanpoelen
|
bb0b4994c0b46835f29d28be6d4e15dfc5501b8e
| 8,071
|
cpp
|
C++
|
example/image/blitter/blitter.cpp
|
ufoym/mango
|
9732fc528f66439f50a3a7cb72d4ba42a59a3d54
|
[
"Zlib"
] | 3
|
2021-02-27T10:29:37.000Z
|
2022-02-16T16:31:26.000Z
|
example/image/blitter/blitter.cpp
|
ufoym/mango
|
9732fc528f66439f50a3a7cb72d4ba42a59a3d54
|
[
"Zlib"
] | null | null | null |
example/image/blitter/blitter.cpp
|
ufoym/mango
|
9732fc528f66439f50a3a7cb72d4ba42a59a3d54
|
[
"Zlib"
] | 5
|
2021-03-22T11:06:00.000Z
|
2022-02-22T02:53:19.000Z
|
/*
MANGO Multimedia Development Platform
Copyright (C) 2012-2021 Twilight Finland 3D Oy Ltd. All rights reserved.
*/
#include <mango/core/core.hpp>
#include <mango/image/image.hpp>
using namespace mango;
using namespace mango::image;
struct Test
{
Format dest;
Format source;
const char* note;
};
const Test tests [] =
{
{ Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 0), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), "memcpy" },
{ Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 0), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 0), "memcpy" },
{ Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 8), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), "swap_rg" },
{ Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 8), "swap_rg" },
{ Format(24, Format::UNORM, Format::BGR, 8, 8, 8, 0), Format(24, Format::UNORM, Format::RGB, 8, 8, 8, 0), "swap_rg" },
{ Format(24, Format::UNORM, Format::RGB, 8, 8, 8, 0), Format(24, Format::UNORM, Format::BGR, 8, 8, 8, 0), "swap_rg" },
{ Format(24, Format::UNORM, Format::RGB, 8, 8, 8, 0), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), "scalar" },
{ Format(24, Format::UNORM, Format::BGR, 8, 8, 8, 0), Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 8), "scalar" },
{ Format(24, Format::UNORM, Format::RGB, 8, 8, 8, 0), Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 0), "scalar" },
{ Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), Format(24, Format::UNORM, Format::RGB, 8, 8, 8, 0), "scalar" },
{ Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 8), Format(24, Format::UNORM, Format::RGB, 8, 8, 8, 0), "scalar" },
{ Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 0), Format(24, Format::UNORM, Format::RGB, 8, 8, 8, 0), "scalar" },
{ Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 8), Format(24, Format::UNORM, Format::BGR, 8, 8, 8, 0), "scalar" },
{ Format(24, Format::UNORM, Format::BGR, 8, 8, 8, 0), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), "xx" },
{ Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 8), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 0), "xx" },
{ Format(24, Format::UNORM, Format::RGB, 8, 8, 8, 0), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 0), "xx" },
{ Format(24, Format::UNORM, Format::BGR, 8, 8, 8, 0), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 0), "xx" },
{ Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 0), Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 8), "xx" },
{ Format(24, Format::UNORM, Format::RGB, 8, 8, 8, 0), Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 8), "xx" },
{ Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 0), "xx" },
{ Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 0), Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 0), "swap_rg" },
{ Format(24, Format::UNORM, Format::BGR, 8, 8, 8, 0), Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 0), "xx" },
{ Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 0), Format(24, Format::UNORM, Format::RGB, 8, 8, 8, 0), "xx" },
{ Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), Format(24, Format::UNORM, Format::BGR, 8, 8, 8, 0), "xx" },
{ Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 0), Format(24, Format::UNORM, Format::BGR, 8, 8, 8, 0), "xx" },
{ Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 0), Format(24, Format::UNORM, Format::BGR, 8, 8, 8, 0), "xx" },
{ Format(8, Format::UNORM, Format::RGBA, 2, 2, 2, 2), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), "xx" },
{ Format(32, Format::UNORM, Format::RGBA, 6, 6, 6, 8), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), "xx" },
{ Format(16, Format::UNORM, Format::RGBA, 4, 4, 4, 4), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), "xx" },
{ Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), Format(16, Format::UNORM, Format::RGBA, 4, 4, 4, 4), "xx" },
{ Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 8), Format(16, Format::UNORM, Format::BGRA, 4, 4, 4, 4), "scalar" },
{ Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), Format(16, Format::UNORM, Format::BGRA, 4, 4, 4, 4), "scalar" },
{ Format(16, Format::UNORM, Format::BGRA, 4, 4, 4, 4), Format(32, Format::UNORM, Format::BGRA, 8, 8, 8, 8), "scalar" },
{ Format(16, Format::UNORM, Format::BGRA, 4, 4, 4, 4), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), "scalar" },
{ Format(8, Format::UNORM, Format::R, 8, 0, 0, 0), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), "xx" },
{ Format(128, Format::FLOAT32, Format::RGBA, 32, 32, 32, 32), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), "simd:4" },
{ Format(64, Format::FLOAT16, Format::RGBA, 16, 16, 16, 16), Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), "simd:4" },
{ Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), Format(128, Format::FLOAT32, Format::RGBA, 32, 32, 32, 32), "simd:1" },
{ Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8), Format(64, Format::FLOAT16, Format::RGBA, 16, 16, 16, 16), "simd:1" },
{ Format(128, Format::FLOAT32, Format::RGBA, 32, 32, 32, 32), Format(64, Format::FLOAT16, Format::RGBA, 16, 16, 16, 16), "xx" },
{ Format(64, Format::FLOAT16, Format::RGBA, 16, 16, 16, 16), Format(128, Format::FLOAT32, Format::RGBA, 32, 32, 32, 32), "xx" },
// ...
};
void test(Surface dest, Surface source)
{
dest.clear(0xff00ff00);
int width = dest.width;
int height = dest.height;
constexpr int s = 297;
int x = 0;
int y = 0;
for (size_t i = 0; i < sizeof(tests) / sizeof(Test); ++i)
{
Bitmap a(width, height, tests[i].source);
Bitmap b(width, height, tests[i].dest);
a.blit(x, y, Surface(source, x, y, s, s));
b.blit(x, y, Surface(a, x, y, s, s));
dest.blit(x, y, Surface(b, x, y, s, s));
x += s;
if (x >= width)
{
x = 0;
y += s;
}
}
}
struct Component
{
int size;
int offset;
int channel;
};
static
bool sort_component(Component a, Component b)
{
return a.offset < b.offset;
}
void print(const Format& format)
{
Component component[4];
for (int i = 0; i < 4; ++i)
{
component[i].size = format.size[i];
component[i].offset = format.offset[i];
component[i].channel = i;
}
std::sort(component + 0, component + 3, sort_component);
const char* name[] =
{
"R", "G", "B", "A"
};
printf("[%3d ", format.bits);
int count = 0;
for (int i = 0; i < 4; ++i)
{
Component c = component[i];
if (c.size)
{
printf("%s", name[c.channel]);
++count;
}
}
for ( ; count < 4; ++count)
{
printf(" ");
}
count = 0;
for (int i = 0; i < 4; ++i)
{
Component c = component[i];
if (c.size)
{
printf(" %3d", c.size);
++count;
}
}
for ( ; count < 4; ++count)
{
printf(" ");
}
printf(" ]");
}
void profile(Surface surface)
{
int width = surface.width;
int height = surface.height;
for (size_t i = 0; i < sizeof(tests) / sizeof(Test); ++i)
{
Bitmap a(width, height, tests[i].dest);
Bitmap b(surface, tests[i].source);
u64 time0 = Time::us();
a.blit(0, 0, b);
u64 time1 = Time::us();
u64 s = width * height / std::max(u64(1), ((time1 - time0) * 1));
printf(" %6d us (%5d MP/s) ", int(time1 - time0), int(s));
print(a.format);
printf(" <-- ");
print(b.format);
printf(" %s", tests[i].note);
printf("\n");
}
}
int main()
{
Bitmap bitmap("conquer.jpg", Format(32, Format::UNORM, Format::RGBA, 8, 8, 8, 8));
printf("Image: %d x %d\n", bitmap.width, bitmap.height);
profile(bitmap);
Bitmap target(bitmap.width, bitmap.height, bitmap.format);
test(target, bitmap);
target.save("result.png");
}
| 40.154229
| 132
| 0.548259
|
ufoym
|
bb0f150b890d7267e29e5a7d81e0396873740b41
| 2,479
|
cpp
|
C++
|
opencl/test/unit_test/xe_hpg_core/test_local_work_size_xe_hpg_core.cpp
|
againull/compute-runtime
|
3ef1ab88a4d9fad5c72e343f349365817c54da17
|
[
"Intel",
"MIT"
] | null | null | null |
opencl/test/unit_test/xe_hpg_core/test_local_work_size_xe_hpg_core.cpp
|
againull/compute-runtime
|
3ef1ab88a4d9fad5c72e343f349365817c54da17
|
[
"Intel",
"MIT"
] | null | null | null |
opencl/test/unit_test/xe_hpg_core/test_local_work_size_xe_hpg_core.cpp
|
againull/compute-runtime
|
3ef1ab88a4d9fad5c72e343f349365817c54da17
|
[
"Intel",
"MIT"
] | null | null | null |
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/test_macros/test.h"
#include "opencl/source/command_queue/gpgpu_walker.h"
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
#include "opencl/test/unit_test/mocks/mock_buffer.h"
#include "opencl/test/unit_test/mocks/mock_kernel.h"
using namespace NEO;
using XeHpgCoreComputeWorkgroupSizeTest = Test<ClDeviceFixture>;
XE_HPG_CORETEST_F(XeHpgCoreComputeWorkgroupSizeTest, givenForceWorkgroupSize1x1x1FlagWhenComputeWorkgroupSizeIsCalledThenExpectedLwsIsReturned) {
DebugManagerStateRestore dbgRestore;
auto program = std::make_unique<MockProgram>(toClDeviceVector(*pClDevice));
MockKernelWithInternals mockKernel(*pClDevice);
GraphicsAllocation localMemoryAllocation(0, GraphicsAllocation::AllocationType::BUFFER, nullptr, 123, 456, 789, MemoryPool::LocalMemory);
MockBuffer buffer(localMemoryAllocation);
cl_mem clMem = &buffer;
auto &kernel = *mockKernel.mockKernel;
auto &kernelInfo = mockKernel.kernelInfo;
kernelInfo.addArgBuffer(0, 0);
kernel.isBuiltIn = true;
kernel.initialize();
kernel.setArgBuffer(0, sizeof(cl_mem *), &clMem);
auto hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo();
EXPECT_FALSE(pDevice->isSimulation());
Vec3<size_t> elws{0, 0, 0};
Vec3<size_t> gws{128, 128, 128};
Vec3<size_t> offset{0, 0, 0};
DispatchInfo dispatchInfo{pClDevice, &kernel, 3, gws, elws, offset};
const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo->platform.eProductFamily);
{
DebugManager.flags.ForceWorkgroupSize1x1x1.set(0);
auto expectedLws = computeWorkgroupSize(dispatchInfo);
EXPECT_NE(1u, expectedLws.x * expectedLws.y * expectedLws.z);
}
{
DebugManager.flags.ForceWorkgroupSize1x1x1.set(1);
auto expectedLws = computeWorkgroupSize(dispatchInfo);
EXPECT_EQ(1u, expectedLws.x * expectedLws.y * expectedLws.z);
}
{
DebugManager.flags.ForceWorkgroupSize1x1x1.set(-1);
hwInfo->platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_A0, *hwInfo);
auto expectedLws = computeWorkgroupSize(dispatchInfo);
EXPECT_NE(1u, expectedLws.x * expectedLws.y * expectedLws.z);
}
}
| 38.734375
| 145
| 0.745865
|
againull
|
bb19410f5cf40c9fa3fe15e135163e5a4fca5f77
| 9,502
|
cpp
|
C++
|
source/glraw/source/UniformParser.cpp
|
cginternals/glraw
|
4c9930833e42404e74364b9b6eaf5afd98ac3096
|
[
"MIT"
] | 48
|
2015-07-30T11:20:49.000Z
|
2022-01-10T20:07:51.000Z
|
source/glraw/source/UniformParser.cpp
|
hpicgs/glraw
|
4c9930833e42404e74364b9b6eaf5afd98ac3096
|
[
"MIT"
] | 3
|
2015-08-08T08:51:36.000Z
|
2017-01-17T17:26:54.000Z
|
source/glraw/source/UniformParser.cpp
|
cginternals/glraw
|
4c9930833e42404e74364b9b6eaf5afd98ac3096
|
[
"MIT"
] | 9
|
2015-07-06T15:51:22.000Z
|
2019-04-24T06:23:12.000Z
|
#include "UniformParser.h"
#include <QOpenGLShaderProgram>
#include <QOpenGLFunctions_3_2_Core>
namespace glraw
{
void UniformParser::setUniforms(
QOpenGLFunctions_3_2_Core & gl
, QOpenGLShaderProgram & program
, const QMap<QString, QString> & uniforms)
{
if (uniforms.isEmpty())
return;
if (!program.isLinked())
return;
program.bind();
GLint activeUniforms = 0;
gl.glGetProgramiv(program.programId(), GL_ACTIVE_UNIFORMS, &activeUniforms);
GLint activeUniformMaxLength = 0;
gl.glGetProgramiv(program.programId(), GL_ACTIVE_UNIFORM_MAX_LENGTH, &activeUniformMaxLength);
QMap<QString, GLenum> uniformTypesByName;
// gather all active uniform names and types
for (int i = 0; i < activeUniforms; ++i)
{
GLenum uniformType = 0;
GLchar * uniformName = new GLchar[activeUniformMaxLength];
GLsizei uniformNameLength = -1;
GLint uniformSize = -1;
gl.glGetActiveUniform(program.programId(), i, activeUniformMaxLength
, &uniformNameLength, &uniformSize, &uniformType, uniformName);
uniformTypesByName.insert(QString(uniformName), uniformType);
delete[] uniformName;
}
for (const QString & uniform : uniforms.keys())
{
if (!uniformTypesByName.contains(uniform))
continue;
const GLenum type = uniformTypesByName[uniform];
QString value = uniforms[uniform];
switch (type)
{
case GL_FLOAT:
case GL_DOUBLE:
setFloat(program, uniform, value);
break;
case GL_FLOAT_VEC2:
case GL_DOUBLE_VEC2:
setVec2(program, uniform, value);
break;
case GL_FLOAT_VEC3:
case GL_DOUBLE_VEC3:
setVec3(program, uniform, value);
break;
case GL_FLOAT_VEC4:
case GL_DOUBLE_VEC4:
setVec4(program, uniform, value);
break;
case GL_INT:
setInt(program, uniform, value);
break;
case GL_INT_VEC2:
case GL_INT_VEC3:
case GL_INT_VEC4:
case GL_UNSIGNED_INT:
case GL_UNSIGNED_INT_VEC2:
case GL_UNSIGNED_INT_VEC3:
case GL_UNSIGNED_INT_VEC4:
case GL_BOOL:
case GL_BOOL_VEC2:
case GL_BOOL_VEC3:
case GL_BOOL_VEC4:
case GL_FLOAT_MAT2:
case GL_FLOAT_MAT3:
case GL_FLOAT_MAT4:
case GL_FLOAT_MAT2x3:
case GL_FLOAT_MAT2x4:
case GL_FLOAT_MAT3x2:
case GL_FLOAT_MAT3x4:
case GL_FLOAT_MAT4x2:
case GL_FLOAT_MAT4x3:
case GL_DOUBLE_MAT2:
case GL_DOUBLE_MAT3:
case GL_DOUBLE_MAT4:
case GL_DOUBLE_MAT2x3:
case GL_DOUBLE_MAT2x4:
case GL_DOUBLE_MAT3x2:
case GL_DOUBLE_MAT3x4:
case GL_DOUBLE_MAT4x2:
case GL_DOUBLE_MAT4x3:
default:
typeUnsupported(uniform);
break;
// case GL_SAMPLER_1D:
// case GL_SAMPLER_2D:
// case GL_SAMPLER_3D:
// case GL_SAMPLER_CUBE:
// case GL_SAMPLER_1D_SHADOW:
// case GL_SAMPLER_2D_SHADOW:
// case GL_SAMPLER_1D_ARRAY:
// case GL_SAMPLER_2D_ARRAY:
// case GL_SAMPLER_1D_ARRAY_SHADOW:
// case GL_SAMPLER_2D_ARRAY_SHADOW:
// case GL_SAMPLER_2D_MULTISAMPLE:
// case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
// case GL_SAMPLER_CUBE_SHADOW:
// case GL_SAMPLER_BUFFER:
// case GL_SAMPLER_2D_RECT:
// case GL_SAMPLER_2D_RECT_SHADOW:
// case GL_INT_SAMPLER_1D:
// case GL_INT_SAMPLER_2D:
// case GL_INT_SAMPLER_3D:
// case GL_INT_SAMPLER_CUBE:
// case GL_INT_SAMPLER_1D_ARRAY:
// case GL_INT_SAMPLER_2D_ARRAY:
// case GL_INT_SAMPLER_2D_MULTISAMPLE:
// case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
// case GL_INT_SAMPLER_BUFFER:
// case GL_INT_SAMPLER_2D_RECT:
// case GL_UNSIGNED_INT_SAMPLER_1D:
// case GL_UNSIGNED_INT_SAMPLER_2D:
// case GL_UNSIGNED_INT_SAMPLER_3D:
// case GL_UNSIGNED_INT_SAMPLER_CUBE:
// case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
// case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
// case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
// case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
// case GL_UNSIGNED_INT_SAMPLER_BUFFER:
// case GL_UNSIGNED_INT_SAMPLER_2D_RECT:
// case GL_IMAGE_1D:
// case GL_IMAGE_2D:
// case GL_IMAGE_3D:
// case GL_IMAGE_2D_RECT:
// case GL_IMAGE_CUBE:
// case GL_IMAGE_BUFFER:
// case GL_IMAGE_1D_ARRAY:
// case GL_IMAGE_2D_ARRAY:
// case GL_IMAGE_2D_MULTISAMPLE:
// case GL_IMAGE_2D_MULTISAMPLE_ARRAY:
// case GL_INT_IMAGE_1D:
// case GL_INT_IMAGE_2D:
// case GL_INT_IMAGE_3D:
// case GL_INT_IMAGE_2D_RECT:
// case GL_INT_IMAGE_CUBE:
// case GL_INT_IMAGE_BUFFER:
// case GL_INT_IMAGE_1D_ARRAY:
// case GL_INT_IMAGE_2D_ARRAY:
// case GL_INT_IMAGE_2D_MULTISAMPLE:
// case GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY:
// case GL_UNSIGNED_INT_IMAGE_1D:
// case GL_UNSIGNED_INT_IMAGE_2D:
// case GL_UNSIGNED_INT_IMAGE_3D:
// case GL_UNSIGNED_INT_IMAGE_2D_RECT:
// case GL_UNSIGNED_INT_IMAGE_CUBE:
// case GL_UNSIGNED_INT_IMAGE_BUFFER:
// case GL_UNSIGNED_INT_IMAGE_1D_ARRAY:
// case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
// case GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE:
// case GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY:
// case GL_UNSIGNED_INT_ATOMIC_COUNTER:
// setInt(program, uniform, value);
// break;
}
}
}
void UniformParser::setFloat(
QOpenGLShaderProgram & program
, const QString & uniform
, QString value)
{
bool ok;
float v = value.toFloat(&ok);
if (ok)
program.setUniformValue(uniform.toStdString().c_str(), v);
else
parsingFailed(uniform, value);
}
void UniformParser::setInt(
QOpenGLShaderProgram & program
, const QString & uniform
, QString value)
{
bool ok;
int v = value.toInt(&ok);
if (!ok)
v = static_cast<int>(value.toFloat(&ok));
if (ok)
program.setUniformValue(uniform.toStdString().c_str(), v);
else
parsingFailed(uniform, value);
}
void UniformParser::setUInt(
QOpenGLShaderProgram & program
, const QString & uniform
, QString value)
{
bool ok;
int v = value.toUInt(&ok);
if (!ok)
v = static_cast<unsigned int>(value.toFloat(&ok));
if (ok)
program.setUniformValue(uniform.toStdString().c_str(), v);
else
parsingFailed(uniform, value);
}
void UniformParser::setVec2(
QOpenGLShaderProgram & program
, const QString & uniform
, QString value)
{
if (!value.startsWith("dvec2") && !value.startsWith("vec2"))
{
typeMismatch(uniform);
return;
}
value.remove("dvec2(");
value.remove("vec2(");
value.remove(")");
const QStringList values = value.split(",");
if (values.size() == 2)
{
bool ok[2];
const QVector2D vec2(
values[0].toFloat(&ok[0])
, values[1].toFloat(&ok[1]));
if (ok[0] && ok[1])
{
program.setUniformValue(uniform.toStdString().c_str(), vec2);
return;
}
}
parsingFailed(uniform, value);
}
void UniformParser::setVec3(
QOpenGLShaderProgram & program
, const QString & uniform
, QString value)
{
if (!value.startsWith("dvec3") && !value.startsWith("vec3"))
{
typeMismatch(uniform);
return;
}
value.remove("dvec3(");
value.remove("vec3(");
value.remove(")");
const QStringList values = value.split(",");
if (values.size() == 3)
{
bool ok[3];
const QVector3D vec3(
values[0].toFloat(&ok[0])
, values[1].toFloat(&ok[1])
, values[2].toFloat(&ok[2]));
if (ok[0] && ok[1] && ok[2])
{
program.setUniformValue(uniform.toStdString().c_str(), vec3);
return;
}
}
parsingFailed(uniform, value);
}
void UniformParser::setVec4(
QOpenGLShaderProgram & program
, const QString & uniform
, QString value)
{
if (!value.startsWith("dvec4") && !value.startsWith("vec4"))
{
typeMismatch(uniform);
return;
}
value.remove("dvec4(");
value.remove("vec4(");
value.remove(")");
const QStringList values = value.split(",");
if (values.size() == 4)
{
bool ok[4];
const QVector4D vec4(
values[0].toFloat(&ok[0])
, values[1].toFloat(&ok[1])
, values[2].toFloat(&ok[2])
, values[3].toFloat(&ok[3]));
if (ok[0] && ok[1] && ok[2] && ok[3])
{
program.setUniformValue(uniform.toStdString().c_str(), vec4);
return;
}
}
parsingFailed(uniform, value);
}
void UniformParser::typeMismatch(const QString & uniform)
{
qDebug() << "Uniform value-type missmatch for" << uniform << ".";
}
void UniformParser::typeUnsupported(const QString & uniform)
{
qDebug() << "Uniform value-type" << uniform << " is not supported.";
}
void UniformParser::parsingFailed(const QString & uniform, const QString & value)
{
qDebug() << "Parsing uniform value" << value << "for" << uniform << "failed.";
}
} // namespace glraw
| 27.865103
| 98
| 0.615028
|
cginternals
|
bb1b45f4c16786ec29a40f2e1cbfe0952e4ffbfc
| 1,060
|
cc
|
C++
|
src/boson/test/shared_buffer.cc
|
duckie/boson
|
f3eb787f385c86b7735fcd7bc0ac0dc6a8fb7b1a
|
[
"MIT"
] | 174
|
2016-10-10T12:47:01.000Z
|
2022-03-09T16:06:59.000Z
|
src/boson/test/shared_buffer.cc
|
duckie/boson
|
f3eb787f385c86b7735fcd7bc0ac0dc6a8fb7b1a
|
[
"MIT"
] | 5
|
2017-02-01T21:30:14.000Z
|
2018-09-09T10:02:00.000Z
|
src/boson/test/shared_buffer.cc
|
duckie/boson
|
f3eb787f385c86b7735fcd7bc0ac0dc6a8fb7b1a
|
[
"MIT"
] | 13
|
2016-10-10T12:19:14.000Z
|
2021-12-04T08:23:26.000Z
|
#include "catch.hpp"
#include "boson/boson.h"
#include <unistd.h>
#include "boson/logger.h"
#include "boson/shared_buffer.h"
#include <iostream>
using namespace boson;
/**
* This tests abuses of its knowledge of the framework
* to check that the buffer is effectively shared.
*
* The fact that data is shared between routines through it is
* NOT a feature and should NOT be used.
*/
TEST_CASE("Shared buffer", "[shared_buffer]") {
boson::debug::logger_instance(&std::cout);
boson::run(1, []() {
boson::shared_buffer<std::array<int,4>> buffer;
std::array<int,4> base {1,2,3,0};
buffer.get() = base;
for (int i = 1; i < 10; ++i)
boson::start([](int index) {
boson::shared_buffer<std::array<int, 4>> buffer;
auto& data = buffer.get();
CHECK(data[0] == 1);
CHECK(data[1] == 2);
CHECK(data[2] == 3);
CHECK(data[3] == index-1);
data[3] = index;
boson::yield();
},i);
auto& data = buffer.get();
CHECK(data == (std::array<int,4>({1,2,3,0})));
});
}
| 25.853659
| 63
| 0.589623
|
duckie
|
bb2501ca5d5830dde00ac26ed5f0688544f056a9
| 1,858
|
cc
|
C++
|
src/commonTools.cc
|
MaximilienNaveau/EnergyComputation
|
f9fdefcff197f7527a7c686f990ff496562ebc5e
|
[
"BSD-3-Clause"
] | null | null | null |
src/commonTools.cc
|
MaximilienNaveau/EnergyComputation
|
f9fdefcff197f7527a7c686f990ff496562ebc5e
|
[
"BSD-3-Clause"
] | null | null | null |
src/commonTools.cc
|
MaximilienNaveau/EnergyComputation
|
f9fdefcff197f7527a7c686f990ff496562ebc5e
|
[
"BSD-3-Clause"
] | null | null | null |
#include "commonTools.hh"
using namespace std ;
namespace fs = boost::filesystem;
// Return RC low-pass filter output samples, given input samples,
// time interval dt, and time constant RC
int lowpass( double x, double & y, double i, double a)
{
static double y_1 = 0.0 ;
if (i==0)
{
y = x ;
y_1 = y ;
return 0;
}
else
{
y = a * x + (1-a) * y_1 ;
y_1 = y ;
}
return 0 ;
}
int derivation( double x, double & dx, double i)
{
static double x_1 = 0.0 ;
if (i==0)
{
dx = 0.0 ;
x_1 = x ;
return 0;
}
else
{
double dt = 0.005 ;
dx = (x - x_1)/dt ;
x_1 = x ;
}
return 0 ;
}
int dumpData(string fileName, vector< vector<double> >& data)
{
ofstream dumpStream ;
dumpStream.open(fileName.c_str(),ofstream::out);
int N = data.size()-1;
for (unsigned int i = 0 ; i < N ; ++i)
{
for (unsigned int j = 0 ; j < data[0].size() ; ++j)
{
dumpStream << data[i][j] << " " ;
}
dumpStream << endl ;
}
dumpStream.close();
cout << "dumped" << endl;
return 0 ;
}
void getOptions(int argc,
char *argv[],
path_t & dataRootPath,
path_t & outputFile)
{
//std::cout << "argc:" << argc << std::endl;
if (argc < 2)
{
cerr << " This program takes 1 arguments: " << endl;
cerr << "./hrp2energy DATA_PATH" << endl;
exit(-1);
}
else
{
dataRootPath=path_t(argv[1]);
boost::gregorian::date d = boost::gregorian::day_clock::universal_day();
ostringstream fileName ("") ;
fileName << dataRootPath.string() << "/results_" << d.year() << "_" << d.month() << "_" << d.day() << ".txt" ;
outputFile = path_t(fileName.str());
cout << outputFile.string() << endl ;
}
}
| 22.119048
| 114
| 0.50592
|
MaximilienNaveau
|
bb25d550909e90a6daeb0462909734bff64f9492
| 3,319
|
cpp
|
C++
|
20-iterators/readerEx.20.06/plot.cpp
|
heavy3/programming-abstractions
|
e10eab5fe7d9ca7d7d4cc96551524707214e43a8
|
[
"MIT"
] | 81
|
2018-11-15T21:23:19.000Z
|
2022-03-06T09:46:36.000Z
|
20-iterators/readerEx.20.06/plot.cpp
|
heavy3/programming-abstractions
|
e10eab5fe7d9ca7d7d4cc96551524707214e43a8
|
[
"MIT"
] | null | null | null |
20-iterators/readerEx.20.06/plot.cpp
|
heavy3/programming-abstractions
|
e10eab5fe7d9ca7d7d4cc96551524707214e43a8
|
[
"MIT"
] | 41
|
2018-11-15T21:23:24.000Z
|
2022-02-24T03:02:26.000Z
|
//
// plot.cpp
//
// --------------------------------------------------------------------------
// Attribution: "Programming Abstractions in C++" by Eric Roberts
// Chapter 20, Exercise 06
// Stanford University, Autumn Quarter 2012
// http://web.stanford.edu/class/archive/cs/cs106b/cs106b.1136/materials/CS106BX-Reader.pdf
//
// Most of this code comes from Figure 20-2
// --------------------------------------------------------------------------
//
// Extended by Glenn Streiff on 3/31/17
// Copyright © 2017 Glenn Streiff. All rights reserved. (derivative work)
//
#include "plot.h"
//
// Function: plot
// Usage: plot(gw, fn, minX, maxX, minY, maxY);
// --------------------------------------------
// Plots the specified function (which must map one double to another double)
// on the screen. The remaining arguments indicate the range of values in the
// x and y directions respectively.
//
void plot(GWindow& gw,
ExpressionFunction fn,
double minX,
double maxX) {
double minY;
double maxY;
reasonableYInterval(minY, maxY, minX, maxX, fn);
plot(gw, fn, minX, maxX, minY, maxY);
}
void plot(GWindow& gw,
ExpressionFunction fn,
double minX,
double maxX,
double minY,
double maxY) {
double width = gw.getWidth();
double height = gw.getHeight();
int nSteps = int(width);
double dx = (maxX - minX) / double(nSteps);
// Scale coordinates of first point to screen coordinates
// (reflecting the y-coodinate about the x-axis since positive y
// direction is toward the bottom of the window, opposite to
// Cartesian convention).
double sx0 = 0; // far left side of view port
double sy0 = height - (fn(minX) - minY) / (maxY - minY) * height;
for (int i = 1; i < nSteps && sy0 >= 0; i++) {
double x = minX + i * dx;
double y = fn(x);
double sx1 = (x - minX) / (maxX - minX) * width;
double sy1 = height - (y - minY) / (maxY - minY) * height;
gw.drawLine(sx0, sy0, sx1, sy1);
sx0 = sx1;
sy0 = sy1;
}
}
// Function: reasonableYInterval
// Usage: reasonable(minY, maxY, minX, maxX, fn);
// ----------------------------------------------
// With monotonically increasing or decreasing functions, the usual
// heuristic of establishing minY and maxY by evaluating the function
// at minX and maxX may be acceptable when minY and maxY are not otherwised
// specified.
//
// However, for periodic functions, it's likely that the local function
// minima and maxima do -not- occur at the minX and maxX values
// respectively.
//
// So we detect for that and scale minY and maxY by an order of magnitude,
// centered about the x-axis, if those values are within 10% of each other
// otherwise.
//
// TODO: Calculate local minima and maxima over the X-interval and use
// -that- to drive minY and maxY.
void reasonableYInterval(double& minY,
double& maxY,
double minX,
double maxX,
ExpressionFunction& fn) {
minY = fn(minX);
maxY = fn(maxX);
if (abs(maxY - minY) <= .1) {
maxY = max(minY, maxY) * 5;
minY = -maxY;
}
}
| 31.018692
| 91
| 0.564628
|
heavy3
|
bb25e0091145bd4cd265569e004fdcb6c0699333
| 4,564
|
hpp
|
C++
|
src/session.hpp
|
olekolek1000/multipixel
|
74760f92c6d9cf2be5f05cebc5b10780136f2662
|
[
"BSD-3-Clause"
] | 4
|
2022-02-07T09:57:58.000Z
|
2022-02-27T23:03:07.000Z
|
src/session.hpp
|
olekolek1000/multipixel
|
74760f92c6d9cf2be5f05cebc5b10780136f2662
|
[
"BSD-3-Clause"
] | null | null | null |
src/session.hpp
|
olekolek1000/multipixel
|
74760f92c6d9cf2be5f05cebc5b10780136f2662
|
[
"BSD-3-Clause"
] | null | null | null |
#pragma once
#include "command.hpp"
#include "src/waiter.hpp"
#include "util/event_queue.hpp"
#include "util/mutex.hpp"
#include "util/optional.hpp"
#include "util/smartptr.hpp"
#include "util/timestep.hpp"
#include "util/types.hpp"
#include "ws_server.hpp"
#include <atomic>
#include <memory>
#include <mutex>
#include <queue>
#include <stack>
#include <string>
#include <string_view>
#include <thread>
struct Server;
struct Chunk;
struct WsMessage;
struct Room;
struct LinkedChunk {
Chunk *chunk;
u32 outside_boundary_duration = 0;
};
struct FloodfillCell {
s32 x;
s32 y;
};
struct GlobalPixel {
Int2 pos;
u8 r, g, b;
};
struct HistoryCell {
std::vector<GlobalPixel> pixels;
};
struct Session : std::enable_shared_from_this<Session> {
private:
std::atomic<bool> valid = false;
std::atomic<bool> perform_ticks = true;
std::atomic<bool> stopping = false;
std::atomic<bool> stopped = false;
Server *server;
SharedWsConnection connection;
Optional<SessionID> id;
std::string nickname;
Room *room = nullptr;
Chunk *last_accessed_chunk_cache = nullptr;
// Cursor
bool cursor_down = false;
bool cursor_just_clicked = false;
std::atomic<Int2> cursor_pos;
std::atomic<Int2> cursor_pos_prev;
std::atomic<Int2> cursor_pos_sent;
// Chunk visibility boundary
struct {
s32 start_x, start_y, end_x, end_y;
float zoom;
} boundary;
// Number of chunks received by client
u32 chunks_received = 0;
// Number of chunks sent by server
u32 chunks_sent = 0;
Timestep step_runner;
std::thread thr_runner;
// Queues
Mutex mtx_message_queue;
std::queue<std::shared_ptr<WsMessage>> message_queue;
Mutex mtx_packet_queue;
std::queue<Packet> packet_queue;
Mutex mtx_access;
std::vector<LinkedChunk> linked_chunks;
std::vector<HistoryCell> history_cells;
struct {
u8 to_replace_r, to_replace_g, to_replace_b;
std::stack<FloodfillCell> stack;
s32 start_x;
s32 start_y;
} floodfill;
bool needs_boundary_test;
EventQueue queue;
// Tool settings
struct {
u8 size;
u8 r, g, b;
ToolType type;
} tool;
public:
Session(Server *server, SharedWsConnection &connection);
~Session();
void setID(SessionID id);
Optional<SessionID> getID();
const std::string &getNickname();
bool isValid();
SharedWsConnection &getConnection();
void getMousePosition(s32 *mouseX, s32 *mouseY);
// Returns queued packet count
void pushIncomingMessage(std::shared_ptr<WsMessage> &msg);
void pushPacket(const Packet &packet);
bool hasStopped();
bool isStopping();
/// Non-blocking
void stopRunner();
void stopRunnerWait();
void linkChunk(Chunk *chunk);
void unlinkChunk(Chunk *chunk);
bool isChunkLinked(Chunk *chunk);
bool isChunkLinked(Int2 chunk_pos);
Room *getRoom() const;
inline bool hasRoom() const { return getRoom() != nullptr; }
private:
// Send packet with exception handler
void sendPacket(const Packet &packet);
bool isChunkLinked_nolock(Chunk *chunk);
bool isChunkLinked_nolock(Int2 chunk_pos);
void close();
//--------------------------------------------
// All methods below are run in worker thread
//--------------------------------------------
bool processed_input_message = false;
void runner();
bool runner_tick();
bool runner_processMessageQueue();
bool runner_processPacketQueue();
void runner_performBoundaryTest();
void parseCommand(ClientCmd cmd, const std::string_view data);
void parseCommandAnnounce(const std::string_view data);
void parseCommandMessage(const std::string_view data);
void parseCommandCursorPos(const std::string_view data);
void parseCommandCursorDown(const std::string_view data);
void parseCommandCursorUp(const std::string_view data);
void parseCommandUndo(const std::string_view data);
void parseCommandToolSize(const std::string_view data);
void parseCommandToolColor(const std::string_view data);
void parseCommandToolType(const std::string_view data);
void parseCommandBoundary(const std::string_view data);
void parseCommandChunksReceived(const std::string_view data);
void parseCommandPreviewRequest(const std::string_view data);
void kick(const char *reason);
void kickInvalidPacket();
void updateCursor();
Chunk *getChunkCached_nolock(Int2 chunk_pos);
bool getPixelGlobal_nolock(Int2 global_pos, u8 *r, u8 *g, u8 *b);
void setPixelQueued_nolock(Int2 global_pos, u8 r, u8 g, u8 b);
void setPixelsGlobal_nolock(GlobalPixel *pixels, size_t count);
void setPixelsGlobal(GlobalPixel *pixels, size_t count);
void historyCreateSnapshot();
void historyUndo_nolock();
void historyAddPixel(GlobalPixel *pixel);
};
| 23.895288
| 66
| 0.740578
|
olekolek1000
|
bb28724008a65fcf4694e65e1b3b8d324ca9c76a
| 11,466
|
cc
|
C++
|
src/structure.cc
|
DouglasRMiles/QuProlog
|
798d86f87fb4372b8918ef582ef2f0fc0181af2d
|
[
"Apache-2.0"
] | 5
|
2019-11-20T02:05:31.000Z
|
2022-01-06T18:59:16.000Z
|
src/structure.cc
|
logicmoo/QuProlog
|
798d86f87fb4372b8918ef582ef2f0fc0181af2d
|
[
"Apache-2.0"
] | null | null | null |
src/structure.cc
|
logicmoo/QuProlog
|
798d86f87fb4372b8918ef582ef2f0fc0181af2d
|
[
"Apache-2.0"
] | 2
|
2022-01-08T13:52:24.000Z
|
2022-03-07T17:41:37.000Z
|
// structrure.cc - Contains functions which retrieve information from and
// build up structures.
//
// ##Copyright##
//
// Copyright 2000-2016 Peter Robinson (pjr@itee.uq.edu.au)
//
// 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.00
//
// 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.
//
// ##Copyright##
//
// $Id: structure.cc,v 1.6 2006/02/06 00:51:38 qp Exp $
#include "atom_table.h"
#include "thread_qp.h"
// psi_compound(term)
// Succeed if term is a structure or a list.
// mode(in)
//
Thread::ReturnValue
Thread::psi_compound(Object *& object1)
{
assert(object1->hasLegalSub());
PrologValue pval1(object1);
heap.prologValueDereference(pval1);
return(pval1.getTerm()->isAnyStructure()? RV_SUCCESS : RV_FAIL);
}
// psi_functor(Structure, Functor, Arity)
// mode(in,in,in)
//
Thread::ReturnValue
Thread::psi_functor(Object *& object1, Object *& object2, Object *& object3)
{
int arity = 0, i;
assert(object1->variableDereference()->hasLegalSub());
assert(object2->variableDereference()->hasLegalSub());
assert(object3->variableDereference()->hasLegalSub());
Object* val1 = heap.dereference(object1);
Object* val2 = heap.dereference(object2);
Object* val3 = heap.dereference(object3);
if (val1->isStructure())
{
Structure* str = OBJECT_CAST(Structure*, val1);
Object* arity_object = heap.newInteger(static_cast<qint64>(str->getArity()));
return BOOL_TO_RV(unify(val2, str->getFunctor()) &&
unify(val3, arity_object));
}
else if (val1->isCons())
{
Object* arity_object = heap.newInteger(2);
return BOOL_TO_RV(unify(val2, AtomTable::cons) &&
unify(val3, arity_object));
}
else if (val3->isNumber())
{
arity = val3->getInteger();
if ((arity < 0) || (arity > (signed) ARITY_MAX))
{
PSI_ERROR_RETURN(EV_RANGE, 3);
}
else if (arity == 0)
{
//
// a zero arity structure
//
return BOOL_TO_RV(unify(val1, val2));
}
else if (arity == 2 && val2 == AtomTable::cons)
{
//
// a list
//
Variable* head = heap.newVariable();
head->setOccursCheck();
Variable* tail = heap.newVariable();
tail->setOccursCheck();
Cons* list = heap.newCons(head, tail);
return BOOL_TO_RV(unify(val1, list));
}
else
{
if (val2->isVariable())
{
OBJECT_CAST(Variable*, val2)->setOccursCheck();
}
assert(arity <= MaxArity);
Structure* str = heap.newStructure(arity);
str->setFunctor(val2);
//
// initialise all arguments in the structure.
//
for (i = 1; i <= arity; i++)
{
Variable* arg = heap.newVariable();
arg->setOccursCheck();
str->setArgument(i, arg);
}
return BOOL_TO_RV(unify(val1, str));
}
}
else if (val1->isConstant())
{
Object* arity_object = heap.newInteger(0);
return BOOL_TO_RV(unify(val2, val1) &&
unify(val3, arity_object));
}
else if (val1->isSubstitution())
{
assert(val1->hasLegalSub());
PrologValue pval(val1);
heap.prologValueDereference(pval);
if (pval.getTerm()->isStructure())
{
Structure* str = OBJECT_CAST(Structure*, pval.getTerm());
Object* arity_object = heap.newInteger(static_cast<qint64>(str->getArity()));
assert(pval.getSubstitutionBlockList()->isCons());
Object* funct
= heap.newSubstitution(pval.getSubstitutionBlockList(),
str->getFunctor());
return
BOOL_TO_RV(unify(val2, funct) &&
unify(val3, arity_object));
}
else if (pval.getTerm()->isCons())
{
Object* arity_object = heap.newInteger(2);
return
BOOL_TO_RV(unify(val2, AtomTable::cons) &&
unify(val3, arity_object));
}
else if (pval.getTerm()->isVariable())
{
PSI_ERROR_RETURN(EV_INST, 3);
}
else
{
PSI_ERROR_RETURN(EV_TYPE, 3);
}
}
else // instantiation or type error
{
if (val1->isVariable() && val3->isVariable())
{
PSI_ERROR_RETURN(EV_INST, 3);
}
else
{
PSI_ERROR_RETURN(EV_TYPE, 3);
}
}
}
//
// psi_arg(N, Str, Arg)
// mode(in,in,out)
//
Thread::ReturnValue
Thread::psi_arg(Object *& object1, Object *& object2, Object *& object3)
{
int32 arity, i;
assert(object1->variableDereference()->hasLegalSub());
assert(object2->variableDereference()->hasLegalSub());
Object* val1 = heap.dereference(object1);
Object* val2 = heap.dereference(object2);
if (val1->isShort())
{
i = val1->getInteger();
if (val2->isStructure())
{
Structure* str = OBJECT_CAST(Structure*, val2);
arity = static_cast<int32>(str->getArity());
if ((i <= 0) || (i > arity))
{
PSI_ERROR_RETURN(EV_RANGE, 1);
}
object3 = str->getArgument(i);
return RV_SUCCESS;
}
else if (val2->isCons())
{
Cons* list = OBJECT_CAST(Cons*, val2);
if (i == 1)
{
object3 = list->getHead();
return RV_SUCCESS;
}
else if (i == 2)
{
object3 = list->getTail();
return RV_SUCCESS;
}
else
{
PSI_ERROR_RETURN(EV_RANGE, 1);
}
}
else if (val2->isSubstitution())
{
assert(val2->hasLegalSub());
PrologValue pval(val2);
heap.prologValueDereference(pval);
if (pval.getTerm()->isStructure())
{
Structure* str = OBJECT_CAST(Structure*, pval.getTerm());
arity = static_cast<int32>(str->getArity());
if ((i <= 0) || (i > arity))
{
PSI_ERROR_RETURN(EV_RANGE, 1);
}
assert(pval.getSubstitutionBlockList()->isCons());
object3 = heap.newSubstitution(pval.getSubstitutionBlockList(),
str->getArgument(i));
return RV_SUCCESS;
}
else if(pval.getTerm()->isCons())
{
Cons* list = OBJECT_CAST(Cons*, pval.getTerm());
if (i == 1)
{
assert(pval.getSubstitutionBlockList()->isCons());
object3
= heap.newSubstitution(pval.getSubstitutionBlockList(),
list->getHead());
return RV_SUCCESS;
}
else if (i == 2)
{
assert(pval.getSubstitutionBlockList()->isCons());
object3
= heap.newSubstitution(pval.getSubstitutionBlockList(),
list->getTail());
return RV_SUCCESS;
}
else
{
PSI_ERROR_RETURN(EV_RANGE, 1);
}
}
else if(pval.getTerm()->isVariable())
{
PSI_ERROR_RETURN(EV_INST, 2);
}
else
{
PSI_ERROR_RETURN(EV_TYPE, 2);
}
}
else
{
if (val2->isVariable())
{
PSI_ERROR_RETURN(EV_INST, 2);
}
else
{
PSI_ERROR_RETURN(EV_TYPE, 2);
}
}
}
else
{
if (val1->isVariable())
{
PSI_ERROR_RETURN(EV_INST, 1);
}
else
{
PSI_ERROR_RETURN(EV_TYPE, 1);
}
}
}
//
// psi_put_structure(F, N, Str)
// mode(in,in,out)
//
Thread::ReturnValue
Thread::psi_put_structure(Object *& object1, Object *& object2,
Object *& object3)
{
int32 arity, i;
assert(object1->variableDereference()->hasLegalSub());
assert(object2->variableDereference()->hasLegalSub());
Object* val1 = heap.dereference(object1);
Object* val2 = heap.dereference(object2);
if (val2->isVariable())
{
PSI_ERROR_RETURN(EV_INST, 2);
}
if (!val2->isShort())
{
PSI_ERROR_RETURN(EV_TYPE, 2);
}
arity = val2->getInteger();
if((arity <= 0) || (arity > (signed) ARITY_MAX))
{
PSI_ERROR_RETURN(EV_RANGE, 2);
}
if (arity == 2 && val1 == AtomTable::cons)
{
//
// a list
//
Cons* list = heap.newCons(AtomTable::nil, AtomTable::nil);
object3 = list;
return(RV_SUCCESS);
}
else
{
if (val1->isVariable())
{
OBJECT_CAST(Variable*, val1)->setOccursCheck();
}
assert(arity <= MaxArity);
Structure* str = heap.newStructure(arity);
str->setFunctor(val1);
//
// zero all arguments in the structure.
//
for (i = 1; i <= arity; i++)
{
str->setArgument(i, AtomTable::nil);
}
object3 = str;
return(RV_SUCCESS);
}
}
//
// psi_set_argument(F, N, Arg)
// mode(in,in,in)
//
Thread::ReturnValue
Thread::psi_set_argument(Object *& object1, Object *& object2, Object *& object3)
{
int32 arity, i;
assert(object1->variableDereference()->hasLegalSub());
assert(object2->variableDereference()->hasLegalSub());
assert(object3->variableDereference()->hasLegalSub());
Object* funct = heap.dereference(object1);
Object* val2 = heap.dereference(object2);
Object* val3 = heap.dereference(object3);
assert(val2->isShort());
i = val2->getInteger();
if (funct->isStructure())
{
Structure* str = OBJECT_CAST(Structure*, funct);
arity = static_cast<int32>(str->getArity());
assert((i > 0) && (i <= arity));
if(val3->isVariable())
{
OBJECT_CAST(Variable*, val3)->setOccursCheck();
}
str->setArgument(i, val3);
}
else if (funct->isCons())
{
Cons* list = OBJECT_CAST(Cons*, funct);
assert((i > 0) && (i <= 2));
if (i == 1)
{
if(val3->isVariable())
{
OBJECT_CAST(Variable*, val3)->setOccursCheck();
}
list->setHead(val3);
}
else // i == 2
{
if(val3->isVariable())
{
OBJECT_CAST(Variable*, val3)->setOccursCheck();
}
list->setTail(val3);
}
}
else
{
assert(false);
}
return(RV_SUCCESS);
}
//
// psi_setarg(N, F, Arg)
// mode(in,in,in)
//
// A backtrackabe destructive update to the N'th arg of F
Thread::ReturnValue
Thread::psi_setarg(Object *& object1, Object *& object2, Object *& object3)
{
int32 arity, i;
assert(object1->variableDereference()->hasLegalSub());
assert(object2->variableDereference()->hasLegalSub());
assert(object3->variableDereference()->hasLegalSub());
Object* funct = heap.dereference(object2);
Object* val1 = heap.dereference(object1);
Object* val3 = heap.dereference(object3);
if (!val1->isShort()) {
if (val1->isVariable())
{
PSI_ERROR_RETURN(EV_INST, 1);
}
else
{
PSI_ERROR_RETURN(EV_TYPE, 1);
}
}
i = val1->getInteger();
if (funct->isStructure())
{
Structure* str = OBJECT_CAST(Structure*, funct);
arity = static_cast<int32>(str->getArity());
if ((i <= 0) || (i > arity)) {
PSI_ERROR_RETURN(EV_RANGE, 1);
}
if(val3->isVariable())
{
OBJECT_CAST(Variable*, val3)->setOccursCheck();
}
updateAndTrailObject(reinterpret_cast<heapobject*>(funct), val3, i+1);
}
else if (funct->isCons())
{
if ((i <= 0) && (i > 2)) {
PSI_ERROR_RETURN(EV_RANGE, 1);
}
if(val3->isVariable())
{
OBJECT_CAST(Variable*, val3)->setOccursCheck();
}
updateAndTrailObject(reinterpret_cast<heapobject*>(funct), val3, i);
}
else {
if (funct->isVariable())
{
PSI_ERROR_RETURN(EV_INST, 2);
}
else
{
PSI_ERROR_RETURN(EV_TYPE, 2);
}
}
return(RV_SUCCESS);
}
| 23.163636
| 83
| 0.597855
|
DouglasRMiles
|
bb28a7372d1be4a8dfc4cc9bd378d531af3a745d
| 6,614
|
cpp
|
C++
|
src/postgres/backend/executor/nodeForeignscan.cpp
|
jessesleeping/my_peloton
|
a19426cfe34a04692a11008eaffc9c3c9b49abc4
|
[
"Apache-2.0"
] | 6
|
2017-04-28T00:38:52.000Z
|
2018-11-06T07:06:49.000Z
|
src/postgres/backend/executor/nodeForeignscan.cpp
|
jessesleeping/my_peloton
|
a19426cfe34a04692a11008eaffc9c3c9b49abc4
|
[
"Apache-2.0"
] | 57
|
2016-03-19T22:27:55.000Z
|
2017-07-08T00:41:51.000Z
|
src/postgres/backend/executor/nodeForeignscan.cpp
|
eric-haibin-lin/pelotondb
|
904d6bbd041a0498ee0e034d4f9f9f27086c3cab
|
[
"Apache-2.0"
] | 14
|
2017-01-12T11:09:09.000Z
|
2019-04-19T09:58:20.000Z
|
/*-------------------------------------------------------------------------
*
* nodeForeignscan.c
* Routines to support scans of foreign tables
*
* Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* src/backend/executor/nodeForeignscan.c
*
*-------------------------------------------------------------------------
*/
/*
* INTERFACE ROUTINES
*
* ExecForeignScan scans a foreign table.
* ExecInitForeignScan creates and initializes state info.
* ExecReScanForeignScan rescans the foreign relation.
* ExecEndForeignScan releases any resources allocated.
*/
#include "postgres.h"
#include "executor/executor.h"
#include "executor/nodeForeignscan.h"
#include "foreign/fdwapi.h"
#include "utils/rel.h"
static TupleTableSlot *ForeignNext(ForeignScanState *node);
static bool ForeignRecheck(ForeignScanState *node, TupleTableSlot *slot);
/* ----------------------------------------------------------------
* ForeignNext
*
* This is a workhorse for ExecForeignScan
* ----------------------------------------------------------------
*/
static TupleTableSlot *
ForeignNext(ForeignScanState *node)
{
TupleTableSlot *slot;
ForeignScan *plan = (ForeignScan *) node->ss.ps.plan;
ExprContext *econtext = node->ss.ps.ps_ExprContext;
MemoryContext oldcontext;
/* Call the Iterate function in short-lived context */
oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
slot = node->fdwroutine->IterateForeignScan(node);
MemoryContextSwitchTo(oldcontext);
/*
* If any system columns are requested, we have to force the tuple into
* physical-tuple form to avoid "cannot extract system attribute from
* virtual tuple" errors later. We also insert a valid value for
* tableoid, which is the only actually-useful system column.
*/
if (plan->fsSystemCol && !TupIsNull(slot))
{
HeapTuple tup = ExecMaterializeSlot(slot);
tup->t_tableOid = RelationGetRelid(node->ss.ss_currentRelation);
}
return slot;
}
/*
* ForeignRecheck -- access method routine to recheck a tuple in EvalPlanQual
*/
static bool
ForeignRecheck(ForeignScanState *node, TupleTableSlot *slot)
{
/* There are no access-method-specific conditions to recheck. */
return true;
}
/* ----------------------------------------------------------------
* ExecForeignScan(node)
*
* Fetches the next tuple from the FDW, checks local quals, and
* returns it.
* We call the ExecScan() routine and pass it the appropriate
* access method functions.
* ----------------------------------------------------------------
*/
TupleTableSlot *
ExecForeignScan(ForeignScanState *node)
{
return ExecScan((ScanState *) node,
(ExecScanAccessMtd) ForeignNext,
(ExecScanRecheckMtd) ForeignRecheck);
}
/* ----------------------------------------------------------------
* ExecInitForeignScan
* ----------------------------------------------------------------
*/
ForeignScanState *
ExecInitForeignScan(ForeignScan *node, EState *estate, int eflags)
{
ForeignScanState *scanstate;
Relation currentRelation = NULL;
Index scanrelid = node->scan.scanrelid;
Index tlistvarno;
FdwRoutine *fdwroutine;
/* check for unsupported flags */
Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
/*
* create state structure
*/
scanstate = makeNode(ForeignScanState);
scanstate->ss.ps.plan = (Plan *) node;
scanstate->ss.ps.state = estate;
/*
* Miscellaneous initialization
*
* create expression context for node
*/
ExecAssignExprContext(estate, &scanstate->ss.ps);
scanstate->ss.ps.ps_TupFromTlist = false;
/*
* initialize child expressions
*/
scanstate->ss.ps.targetlist = (List *)
ExecInitExpr((Expr *) node->scan.plan.targetlist,
(PlanState *) scanstate);
scanstate->ss.ps.qual = (List *)
ExecInitExpr((Expr *) node->scan.plan.qual,
(PlanState *) scanstate);
/*
* tuple table initialization
*/
ExecInitResultTupleSlot(estate, &scanstate->ss.ps);
ExecInitScanTupleSlot(estate, &scanstate->ss);
/*
* open the base relation, if any, and acquire an appropriate lock on it;
* also acquire function pointers from the FDW's handler
*/
if (scanrelid > 0)
{
currentRelation = ExecOpenScanRelation(estate, scanrelid, eflags);
scanstate->ss.ss_currentRelation = currentRelation;
fdwroutine = GetFdwRoutineForRelation(currentRelation, true);
}
else
{
/* We can't use the relcache, so get fdwroutine the hard way */
fdwroutine = GetFdwRoutineByServerId(node->fs_server);
}
/*
* Determine the scan tuple type. If the FDW provided a targetlist
* describing the scan tuples, use that; else use base relation's rowtype.
*/
if (node->fdw_scan_tlist != NIL || currentRelation == NULL)
{
TupleDesc scan_tupdesc;
scan_tupdesc = ExecTypeFromTL(node->fdw_scan_tlist, false);
ExecAssignScanType(&scanstate->ss, scan_tupdesc);
/* Node's targetlist will contain Vars with varno = INDEX_VAR */
tlistvarno = INDEX_VAR;
}
else
{
ExecAssignScanType(&scanstate->ss, RelationGetDescr(currentRelation));
/* Node's targetlist will contain Vars with varno = scanrelid */
tlistvarno = scanrelid;
}
/*
* Initialize result tuple type and projection info.
*/
ExecAssignResultTypeFromTL(&scanstate->ss.ps);
ExecAssignScanProjectionInfoWithVarno(&scanstate->ss, tlistvarno);
/*
* Initialize FDW-related state.
*/
scanstate->fdwroutine = fdwroutine;
scanstate->fdw_state = NULL;
/*
* Tell the FDW to initialize the scan.
*/
fdwroutine->BeginForeignScan(scanstate, eflags);
return scanstate;
}
/* ----------------------------------------------------------------
* ExecEndForeignScan
*
* frees any storage allocated through C routines.
* ----------------------------------------------------------------
*/
void
ExecEndForeignScan(ForeignScanState *node)
{
/* Let the FDW shut down */
node->fdwroutine->EndForeignScan(node);
/* Free the exprcontext */
ExecFreeExprContext(&node->ss.ps);
/* clean out the tuple table */
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
ExecClearTuple(node->ss.ss_ScanTupleSlot);
/* close the relation. */
if (node->ss.ss_currentRelation)
ExecCloseScanRelation(node->ss.ss_currentRelation);
}
/* ----------------------------------------------------------------
* ExecReScanForeignScan
*
* Rescans the relation.
* ----------------------------------------------------------------
*/
void
ExecReScanForeignScan(ForeignScanState *node)
{
node->fdwroutine->ReScanForeignScan(node);
ExecScanReScan(&node->ss);
}
| 27.789916
| 77
| 0.641669
|
jessesleeping
|
bb29c8bdf374aa90b1e53803ac9ee5d21b500c75
| 1,270
|
hpp
|
C++
|
code/source/util/mem_pool_chunk.hpp
|
crafn/clover
|
586acdbcdb34c3550858af125e9bb4a6300343fe
|
[
"MIT"
] | 12
|
2015-01-12T00:19:20.000Z
|
2021-08-05T10:47:20.000Z
|
code/source/util/mem_pool_chunk.hpp
|
crafn/clover
|
586acdbcdb34c3550858af125e9bb4a6300343fe
|
[
"MIT"
] | null | null | null |
code/source/util/mem_pool_chunk.hpp
|
crafn/clover
|
586acdbcdb34c3550858af125e9bb4a6300343fe
|
[
"MIT"
] | null | null | null |
#ifndef CLOVER_UTIL_MEM_POOL_CHUNK_HPP
#define CLOVER_UTIL_MEM_POOL_CHUNK_HPP
#include "build.hpp"
#include "util/dyn_bitarray.hpp"
#include "util/dyn_array.hpp"
#include "util/mem_pool.hpp"
namespace clover {
namespace util {
/// Memory pool for equally sized chunks
class ENGINE_API ChunkMemPool : public MemPool {
public:
ChunkMemPool(SizeType chunk_size);
/// Memory allocator interface
/// Allocated size can't be greater than specified in constructor
void* allocate(SizeType size, SizeType alignment);
void deallocate(void* mem);
void* getPtr(SizeType i) const { return base + chunkSize*i; }
bool isUsed(SizeType i) const { return chunkStates[i] == chunkUsed; }
SizeType getAllocatedCount() const { return allocatedCount; }
SizeType getChunkCount() const { return chunkCount; }
SizeType getChunkSize() const { return chunkSize; }
protected:
virtual void onMemoryAcquire() override;
virtual void onMemoryRelease() override;
private:
static constexpr bool chunkUsed= true;
static constexpr bool chunkFree= false;
SizeType chunkSize;
uint8* base= nullptr;
SizeType chunkCount= 0;
util::DynArray<SizeType> freeChunks;
DynBitArray chunkStates;
SizeType allocatedCount= 0;
};
} // util
} // clover
#endif // CLOVER_UTIL_MEM_POOL_CHUNK_HPP
| 25.918367
| 70
| 0.770866
|
crafn
|
bb2cb095e6a3b2170c6f279b7a385772210ddebd
| 559
|
hpp
|
C++
|
graphics/RawMesh.hpp
|
quyse/inanity
|
a39225c5a41f879abe5aa492bb22b500dbe77433
|
[
"MIT"
] | 26
|
2015-04-22T05:25:25.000Z
|
2020-11-15T11:07:56.000Z
|
graphics/RawMesh.hpp
|
quyse/inanity
|
a39225c5a41f879abe5aa492bb22b500dbe77433
|
[
"MIT"
] | 2
|
2015-01-05T10:41:27.000Z
|
2015-01-06T20:46:11.000Z
|
graphics/RawMesh.hpp
|
quyse/inanity
|
a39225c5a41f879abe5aa492bb22b500dbe77433
|
[
"MIT"
] | 5
|
2016-08-02T11:13:57.000Z
|
2018-10-26T11:19:27.000Z
|
#ifndef ___INANITY_GRAPHICS_RAW_MESH_HPP___
#define ___INANITY_GRAPHICS_RAW_MESH_HPP___
#include "graphics.hpp"
BEGIN_INANITY
class File;
END_INANITY
BEGIN_INANITY_GRAPHICS
class VertexLayout;
class RawMesh : public Object
{
private:
ptr<File> vertices;
ptr<VertexLayout> vertexLayout;
ptr<File> indices;
public:
RawMesh(ptr<File> vertices, ptr<VertexLayout> vertexLayout, ptr<File> indices);
~RawMesh();
ptr<File> GetVertices() const;
ptr<VertexLayout> GetVertexLayout() const;
ptr<File> GetIndices() const;
};
END_INANITY_GRAPHICS
#endif
| 15.971429
| 80
| 0.78712
|
quyse
|
bb315fdb065da3856cc2cca11cfc271d0b6d6b78
| 935
|
cpp
|
C++
|
src/saiga/opengl/uniformBuffer.cpp
|
SimonMederer/saiga
|
ff167e60c50b1cead4d19eb5ab2e93acce8c42a3
|
[
"MIT"
] | null | null | null |
src/saiga/opengl/uniformBuffer.cpp
|
SimonMederer/saiga
|
ff167e60c50b1cead4d19eb5ab2e93acce8c42a3
|
[
"MIT"
] | null | null | null |
src/saiga/opengl/uniformBuffer.cpp
|
SimonMederer/saiga
|
ff167e60c50b1cead4d19eb5ab2e93acce8c42a3
|
[
"MIT"
] | null | null | null |
/**
* Copyright (c) 2017 Darius Rückert
* Licensed under the MIT License.
* See LICENSE file for more information.
*/
#include "saiga/opengl/uniformBuffer.h"
namespace Saiga
{
UniformBuffer::UniformBuffer() : Buffer(GL_UNIFORM_BUFFER) {}
UniformBuffer::~UniformBuffer() {}
void UniformBuffer::init(std::shared_ptr<Shader> shader, GLuint location)
{
size = shader->getUniformBlockSize(location);
assert_no_glerror();
createGLBuffer(nullptr, size, GL_DYNAMIC_DRAW);
}
std::ostream& operator<<(std::ostream& os, const UniformBuffer& ub)
{
os << "UniformBuffer "
<< "size=" << ub.size;
return os;
}
GLint UniformBuffer::getMaxUniformBlockSize()
{
GLint ret;
glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &ret);
return ret;
}
GLint UniformBuffer::getMaxUniformBufferBindings()
{
GLint ret;
glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &ret);
return ret;
}
} // namespace Saiga
| 19.893617
| 73
| 0.709091
|
SimonMederer
|
bb35e00a6e05f5e2d3836ef1ea79ddd49b070067
| 4,624
|
cpp
|
C++
|
src/prod/src/Management/healthmanager/PartitionAttributesStoreData.cpp
|
vishnuk007/service-fabric
|
d0afdea185ae932cc3c9eacf179692e6fddbc630
|
[
"MIT"
] | 2,542
|
2018-03-14T21:56:12.000Z
|
2019-05-06T01:18:20.000Z
|
src/prod/src/Management/healthmanager/PartitionAttributesStoreData.cpp
|
vishnuk007/service-fabric
|
d0afdea185ae932cc3c9eacf179692e6fddbc630
|
[
"MIT"
] | 994
|
2019-05-07T02:39:30.000Z
|
2022-03-31T13:23:04.000Z
|
src/prod/src/Management/healthmanager/PartitionAttributesStoreData.cpp
|
vishnuk007/service-fabric
|
d0afdea185ae932cc3c9eacf179692e6fddbc630
|
[
"MIT"
] | 300
|
2018-03-14T21:57:17.000Z
|
2019-05-06T20:07:00.000Z
|
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
// ------------------------------------------------------------
#include "stdafx.h"
using namespace Common;
using namespace std;
using namespace ServiceModel;
using namespace Store;
using namespace Query;
using namespace Management::HealthManager;
PartitionAttributesStoreData::PartitionAttributesStoreData()
: AttributesStoreData()
, partitionId_()
, serviceName_()
, attributeFlags_()
{
}
PartitionAttributesStoreData::PartitionAttributesStoreData(
PartitionHealthId const & partitionId,
Store::ReplicaActivityId const & activityId)
: AttributesStoreData(activityId)
, partitionId_(partitionId)
, serviceName_()
, attributeFlags_()
{
}
PartitionAttributesStoreData::PartitionAttributesStoreData(
PartitionHealthId const & partitionId,
ReportRequestContext const & context)
: AttributesStoreData(context.ReplicaActivityId)
, partitionId_(partitionId)
, serviceName_()
, attributeFlags_()
{
}
PartitionAttributesStoreData::~PartitionAttributesStoreData()
{
}
bool PartitionAttributesStoreData::ShouldUpdateAttributeInfo(ServiceModel::AttributeList const & attributeList) const
{
for (auto it = attributeList.Attributes.begin(); it != attributeList.Attributes.end(); ++it)
{
if (it->first == HealthAttributeNames::ServiceName)
{
if (!attributeFlags_.IsServiceNameSet() || it->second != this->ServiceName)
{
return true;
}
}
}
// No new changes, no need to update attributes
return false;
}
void PartitionAttributesStoreData::SetAttributes(
ServiceModel::AttributeList const & attributeList)
{
for (auto it = attributeList.Attributes.begin(); it != attributeList.Attributes.end(); ++it)
{
if (it->first == HealthAttributeNames::ServiceName)
{
this->ServiceName = it->second;
}
else
{
HMEvents::Trace->DropAttribute(
this->ReplicaActivityId,
it->first,
it->second);
}
}
}
Common::ErrorCode PartitionAttributesStoreData::HasAttributeMatch(
std::wstring const & attributeName,
std::wstring const & attributeValue,
__out bool & isMatch) const
{
isMatch = false;
if (attributeName == HealthAttributeNames::ServiceName)
{
if (!attributeFlags_.IsServiceNameSet())
{
return ErrorCode(ErrorCodeValue::NotFound);
}
isMatch = (attributeValue == this->ServiceName);
}
else if (attributeName == QueryResourceProperties::Partition::PartitionId)
{
isMatch = (attributeValue == wformatString(partitionId_));
}
else
{
return ErrorCode(ErrorCodeValue::InvalidArgument);
}
return ErrorCode(ErrorCodeValue::Success);
}
Common::ErrorCode PartitionAttributesStoreData::GetAttributeValue(
std::wstring const & attributeName,
__inout std::wstring & attributeValue) const
{
if (attributeName == HealthAttributeNames::ServiceName)
{
if (!attributeFlags_.IsServiceNameSet())
{
return ErrorCode(ErrorCodeValue::NotFound);
}
attributeValue = this->ServiceName;
}
else
{
return ErrorCode(ErrorCodeValue::InvalidArgument);
}
return ErrorCode(ErrorCodeValue::Success);
}
ServiceModel::AttributeList PartitionAttributesStoreData::GetEntityAttributes() const
{
ServiceModel::AttributeList attributes;
if (attributeFlags_.IsServiceNameSet())
{
attributes.AddAttribute(HealthAttributeNames::ServiceName, serviceName_);
}
return attributes;
}
std::wstring PartitionAttributesStoreData::ConstructKey() const
{
return partitionId_.ToString();
}
std::wstring const & PartitionAttributesStoreData::get_Type() const
{
return Constants::StoreType_PartitionHealthAttributes;
}
void PartitionAttributesStoreData::WriteTo(__in Common::TextWriter & w, Common::FormatOptions const &) const
{
w.Write(
"{0}({1}:serviceName='{2}',{3})",
this->Type,
this->Key,
serviceName_,
stateFlags_);
}
void PartitionAttributesStoreData::WriteToEtw(uint16 contextSequenceId) const
{
HMCommonEvents::Trace->PartitionAttributesStoreDataTrace(
contextSequenceId,
this->Type,
this->Key,
serviceName_,
stateFlags_);
}
| 27.040936
| 117
| 0.661332
|
vishnuk007
|
7d6b5fd35c6141c57502d5b66c11cbbbac6f515b
| 1,542
|
hpp
|
C++
|
include/Boots/Utils/directory.hpp
|
Plaristote/Boots
|
ba6bd74fd06c5b26f1e159c6c861d46992db1145
|
[
"BSD-3-Clause"
] | null | null | null |
include/Boots/Utils/directory.hpp
|
Plaristote/Boots
|
ba6bd74fd06c5b26f1e159c6c861d46992db1145
|
[
"BSD-3-Clause"
] | null | null | null |
include/Boots/Utils/directory.hpp
|
Plaristote/Boots
|
ba6bd74fd06c5b26f1e159c6c861d46992db1145
|
[
"BSD-3-Clause"
] | null | null | null |
#ifndef DIRECTORY_HPP
# define DIRECTORY_HPP
# ifndef _WIN32
# include <dirent.h>
# include <sys/stat.h>
# include <unistd.h>
# include <string>
typedef struct dirent Dirent;
# else
# define _WINSOCKAPI_
//# include "semaphore.hpp"
# include <Windows.h>
# include <tchar.h>
# include <stdio.h>
# include <strsafe.h>
# include <direct.h>
# include <string>
# define DT_DIR 1
# define DT_REG 2
struct Dirent
{
unsigned char d_type;
std::string d_name;
};
# endif
# include <fstream>
# include <list>
class Filesystem
{
public:
static bool FileContent(const std::string& filepath, std::string& out);
static bool FileCopy(const std::string& from, const std::string& dest);
static bool WriteToFile(const std::string& filename, const std::string& to_write);
static bool FileExists(const std::string& filepath);
static bool FileMove(const std::string& from, const std::string& to);
static bool FileRemove(const std::string& file);
private:
Filesystem() {}
};
class Directory
{
public:
typedef std::list<Dirent> Entries;
static std::string Current(void);
static bool MakeDir(const std::string& str);
static bool RemoveDir(const std::string& str);
bool OpenDir(const std::string& str);
const std::string& Path(void) const { return (_dirName); }
Entries& GetEntries(void) { return (_dirEntries); }
const Entries& GetEntries(void) const { return (_dirEntries); }
private:
Entries _dirEntries;
std::string _dirName;
};
#endif
| 23.014925
| 84
| 0.677691
|
Plaristote
|
7d6b83b73a36810f36478732ba5859e1b324bd82
| 668
|
cpp
|
C++
|
UVa Online Judge/1176.cpp
|
xiezeju/ACM-Code-Archives
|
db135ed0953adcf5c7ab37a00b3f9458291ce0d7
|
[
"MIT"
] | 1
|
2022-02-24T12:44:30.000Z
|
2022-02-24T12:44:30.000Z
|
UVa Online Judge/1176.cpp
|
xiezeju/ACM-Code-Archives
|
db135ed0953adcf5c7ab37a00b3f9458291ce0d7
|
[
"MIT"
] | null | null | null |
UVa Online Judge/1176.cpp
|
xiezeju/ACM-Code-Archives
|
db135ed0953adcf5c7ab37a00b3f9458291ce0d7
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
#define LSOne(S) ((S) & -(S))
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
const int INF = 0x3f3f3f3f;
const long long LLINF = 4e18;
const double EPS = 1e-9;
const int N = 1010;
int js(int n){
int a=n,cnt=0;
while(a){a/=2;cnt++;}
n = ((n<<1)+1)^(1<<cnt);
return n;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
while(cin>>n){
int ans=0;
while(1){
int j;
if((j=js(n))==n) {ans+=2*j;break;}
else {ans+=n-j;n=j;}
}
cout<<ans<<endl;
}
return 0;
}
| 16.7
| 42
| 0.549401
|
xiezeju
|
7d6cf5ff6852f32400c1059bcf4bf3cbc0277544
| 784
|
cpp
|
C++
|
cppPrime/classtemplate_c16/test_02.cpp
|
ilvcr/cpplgproject
|
d3dc492b37c3754e35669eee2dd96d83de63ead4
|
[
"Apache-2.0"
] | null | null | null |
cppPrime/classtemplate_c16/test_02.cpp
|
ilvcr/cpplgproject
|
d3dc492b37c3754e35669eee2dd96d83de63ead4
|
[
"Apache-2.0"
] | null | null | null |
cppPrime/classtemplate_c16/test_02.cpp
|
ilvcr/cpplgproject
|
d3dc492b37c3754e35669eee2dd96d83de63ead4
|
[
"Apache-2.0"
] | null | null | null |
/*************************************************************************
> File Name: test_02.cpp
> Author: yoghourt->ilvcr
> Mail: liyaoliu@foxmail.com @@ ilvcr@outlook.com
> Created Time: 2018年07月19日 星期四 23时06分28秒
> Description: 类模板 Queue 的定义, 其和类模板 QueueItem 的
定义都被放在一个名为 Queue.h的头文件
************************************************************************/
//Queue.h
// QueueItem 的声明
#ifndef QUEUE_H
#define QUEUE_H
// QueueItem 的声明
template<class T> class QueueItem;
template<class Type>
class Queue{
public:
Queue() : front(0), back(0) {}
~Queue();
type& remove();
void add( const Type& );
bool is_empty() const{
return front == 0;
}
private:
QueueItem<Type>* front;
QueueItem<Type>* back;
};
#endif
| 20.102564
| 74
| 0.516582
|
ilvcr
|
7d722438d8351238988776e121a68201fe43c49a
| 1,355
|
hpp
|
C++
|
RubetekIOS-CPP.framework/Versions/A/Headers/libnet/rubetek/utility/multiform/to_property_value.hpp
|
yklishevich/RubetekIOS-CPP-releases
|
7dfbbb45b8de7dbb6fa995ff5dcbca4ec06c2bdb
|
[
"MIT"
] | null | null | null |
RubetekIOS-CPP.framework/Versions/A/Headers/libnet/rubetek/utility/multiform/to_property_value.hpp
|
yklishevich/RubetekIOS-CPP-releases
|
7dfbbb45b8de7dbb6fa995ff5dcbca4ec06c2bdb
|
[
"MIT"
] | null | null | null |
RubetekIOS-CPP.framework/Versions/A/Headers/libnet/rubetek/utility/multiform/to_property_value.hpp
|
yklishevich/RubetekIOS-CPP-releases
|
7dfbbb45b8de7dbb6fa995ff5dcbca4ec06c2bdb
|
[
"MIT"
] | null | null | null |
#pragma once
#include <rubetek/essence/property.hpp>
#include <rubetek/utility/noncopyable.hpp>
#include <rubetek/utility/multiform/multiform.hpp>
#include <rubetek/utility/multiform/apply_visitor.hpp>
namespace rubetek
{
struct multiform_to_property_value_visitor
: utility::noncopyable
{
static_assert(std::is_same<property::value_type, boost::variant<bool, int, float, std::string>>::value, "can't apply visitor");
multiform_to_property_value_visitor(property::value_type& value)
: value_(value)
{}
template <typename T>
void operator () (T const&)
{
throw std::runtime_error("can't find type in property::value_type");
}
void operator () (bool v)
{
value_ = v;
}
void operator () (int v)
{
value_ = v;
}
void operator () (float v)
{
value_ = v;
}
void operator () (std::string const& v)
{
value_ = v;
}
private:
property::value_type& value_;
};
property::value_type to_property_value(multiform const& mf)
{
property::value_type value;
multiform_to_property_value_visitor visitor(value);
apply_multiform_visitor(mf, visitor);
return value;
}
}
| 24.636364
| 135
| 0.58524
|
yklishevich
|
7d75ea708e9473eca02aab0546d590b94fd5cacc
| 465
|
hpp
|
C++
|
includes/eeros/hal/DummyRealOutput.hpp
|
bajric/eeros
|
157dcfa87f87f55bc2fec703ea2c4eb1c27a35c8
|
[
"Apache-2.0"
] | null | null | null |
includes/eeros/hal/DummyRealOutput.hpp
|
bajric/eeros
|
157dcfa87f87f55bc2fec703ea2c4eb1c27a35c8
|
[
"Apache-2.0"
] | null | null | null |
includes/eeros/hal/DummyRealOutput.hpp
|
bajric/eeros
|
157dcfa87f87f55bc2fec703ea2c4eb1c27a35c8
|
[
"Apache-2.0"
] | null | null | null |
#ifndef ORG_EEROS_HAL_DUMMYREALOUTPUT_HPP_
#define ORG_EEROS_HAL_DUMMYREALOUTPUT_HPP_
#include <string>
#include <eeros/hal/ScalablePeripheralOutput.hpp>
namespace eeros {
namespace hal {
class DummyRealOutput : public ScalablePeripheralOutput<double> {
public:
DummyRealOutput(std::string id, double scale = 1, double offset = 0);
virtual double get();
virtual void set(double value);
};
};
};
#endif /* ORG_EEROS_HAL_DUMMYREALOUTPUT_HPP_ */
| 22.142857
| 72
| 0.76129
|
bajric
|
7d77c276d89dc7a8f4a4f478b612c557ecbbae0a
| 1,998
|
cpp
|
C++
|
Solution/Source/Graphics/MeshExporter.cpp
|
TeeNik/GameEngine
|
9a3893455f20e14f967e5df9b2168fa0f004c101
|
[
"MIT"
] | null | null | null |
Solution/Source/Graphics/MeshExporter.cpp
|
TeeNik/GameEngine
|
9a3893455f20e14f967e5df9b2168fa0f004c101
|
[
"MIT"
] | null | null | null |
Solution/Source/Graphics/MeshExporter.cpp
|
TeeNik/GameEngine
|
9a3893455f20e14f967e5df9b2168fa0f004c101
|
[
"MIT"
] | null | null | null |
#pragma once
#include "Graphics/MeshExporter.hpp"
#include "Graphics/Mesh.hpp"
#include "Graphics/SkeletalMesh.hpp"
#include "assimp/Importer.hpp"
#include "assimp/scene.h"
#include "assimp/postprocess.h"
#include "Engine/Engine.hpp"
#include "Graphics/Renderer.hpp"
MeshExporter::MeshExporter(Engine* e)
{
engine = e;
}
std::vector<Mesh*>& MeshExporter::LoadMeshes(const std::string& path)
{
meshes.clear();
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs);
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
{
printf("ERROR::ASSIMP %s\n", importer.GetErrorString());
}
else {
ProcessNode(scene->mRootNode, scene);
}
return meshes;
}
Mesh * MeshExporter::LoadMesh(const std::string & path)
{
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs);
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
{
printf("ERROR::ASSIMP %s\n", importer.GetErrorString());
return nullptr;
}
if (scene->mNumMeshes > 1)
{
printf("ERROR NumMeshes > 1\n");
return nullptr;
}
return ProcessMesh(scene->mMeshes[0], scene);
}
void MeshExporter::ProcessNode(aiNode * node, const aiScene * scene)
{
for (int i = 0; i < node->mNumMeshes; ++i)
{
aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
meshes.push_back(ProcessMesh(mesh, scene));
}
for(int i = 0; i < node->mNumChildren; ++i)
{
ProcessNode(node->mChildren[i], scene);
}
}
Mesh * MeshExporter::ProcessMesh(aiMesh * m, const aiScene * scene)
{
//Mesh* mesh = new Mesh(m, scene);
SkeletalMesh* mesh = new SkeletalMesh(m, scene, engine);
mesh->SetupMesh();
return mesh;
}
SkeletalMesh* MeshExporter::ProcessSkeletalMesh(aiMesh* mesh, const aiScene* scene)
{
SkeletalMesh* sm = new SkeletalMesh(mesh, scene, engine);
sm->SetupMesh();
return sm;
}
| 25.291139
| 92
| 0.682182
|
TeeNik
|
7d82a505be293a1af29273caa9b907acb1bb0696
| 3,066
|
cpp
|
C++
|
avlme.cpp
|
Rajasuryaa/seven
|
87a7e1aa801fa330deb585ba859a09da56c22e90
|
[
"curl"
] | null | null | null |
avlme.cpp
|
Rajasuryaa/seven
|
87a7e1aa801fa330deb585ba859a09da56c22e90
|
[
"curl"
] | null | null | null |
avlme.cpp
|
Rajasuryaa/seven
|
87a7e1aa801fa330deb585ba859a09da56c22e90
|
[
"curl"
] | null | null | null |
#include<stdio.h>
#include<stdlib.h>
using namespace std;
typedef struct node{
int data;
struct node *left;
struct node *right;
int ht;
}node;
int height(node * T)
{
int lh,rh;
if(T==NULL)
return(0);
if(T->left == NULL)
lh = 0;
else
lh = 1 + T->left->ht;
if(T->right == NULL)
rh = 0;
else
rh = 1 + T->right->ht;
if(lh>rh)
return (lh);
return(rh);
}
int BF(node * T)
{
int lh,rh;
if(T==NULL)
return(0);
if(T->left == NULL)
lh = 0;
else
lh = 1 + T->left->ht;
if(T->right == NULL)
rh = 0;
else
rh = 1 + T->right->ht;
return(lh-rh);
}
node *rotateright(node *T)
{
node *temp;
temp = T->left;
T->left = temp->right;
temp->right = T;
T->ht = height(T);
temp->ht = height(temp);
return(temp);
}
node *rotateleft(node *T)
{
node *temp;
temp = T->right;
T->right = temp->left;
temp->left = T;
T->ht = height(T);
temp->ht = height(temp);
return(temp);
}
node *LL(node *T)
{
T = rotateright(T);
return(T);
}
node *LR(node *T)
{
T->left = rotateleft(T->left);
T = rotateright(T);
return(T);
}
node *RR(node *T)
{
T = rotateleft(T);
return(T);
}
node *RL(node *T)
{
T->right = rotateright(T->right);
T = rotateleft(T);
return(T);
}
node * insert(node * T,int key)
{
if(T == NULL)
{
T = (node*)malloc(sizeof(node));
T->data = key;
T->right = NULL;
T->left = NULL;
}
else
if(key < T->data)
{
T->left = insert(T->left,key);
if(BF(T)==2)
if(key < T->left->data)
T = LL(T);
else
T = LR(T);
}
else
if(key > T->data)
{
T->right = insert(T->right,key);
if(BF(T)==-2)
if(key > T->right->data)
T = RR(T);
else
T = RL(T);
}
T->ht = height(T);
return(T);
}
node * delet(node *T,int key)
{
node *temp;
if(T==NULL)
return NULL;
if(key > T->data)
{
T->right=delet(T->right,key);
if(BF(T)==2)
if(BF(T->left)>=0)
T=LL(T);
else
T=LR(T);
}
if(key < T->data)
{
T->right = delet(T->right,key);
if(BF(T) == -2)
if(BF(T->right) <= 0)
T = RR(T);
else
T = LR(T);
}
else
{
if(T->right!=NULL)
{
temp = T->right;
while(temp->left != NULL)
temp = temp->left;
T->data = temp->data;
T->right = delet(T->right,temp->data);
if(BF(T) == 2)
if(BF(T->left) >= 0)
T = LL(T);
else
T = LR(T);
}
else
return(T->left);
}
T->ht = height(T);
return(T);
}
void inorder(node *T)
{
if(T!=NULL)
{
inorder(T->left);
printf("%d(Bf=%d)",T->data,BF(T));
inorder(T->right);
}
else
return;
}
int main()
{
node *root = NULL;
int i,n;
root = NULL;
for(i=0;i<5;i++)
{
scanf("%d",&n);
root = insert(root,n);
}
inorder(root);
printf("Delete :");
scanf("%d",&n);
root = delet(root,n);
inorder(root);
}
| 14.6
| 43
| 0.460535
|
Rajasuryaa
|
7d8957d617b3f89beb5b39a24f6fa1e9d4212437
| 291
|
cpp
|
C++
|
sources/lambda/main_functor.cpp
|
zussel/cpp-overview
|
8a2f1ae7504ad2bb2a1ce8b284bb8a2fee448dbf
|
[
"MIT"
] | null | null | null |
sources/lambda/main_functor.cpp
|
zussel/cpp-overview
|
8a2f1ae7504ad2bb2a1ce8b284bb8a2fee448dbf
|
[
"MIT"
] | null | null | null |
sources/lambda/main_functor.cpp
|
zussel/cpp-overview
|
8a2f1ae7504ad2bb2a1ce8b284bb8a2fee448dbf
|
[
"MIT"
] | null | null | null |
#include <iostream>
struct adder {
adder(int x) : x(x) {}
int operator()(int y) const { return x + y; }
int x;
};
int main()
{
// create an instance of the functor class
adder add42(42);
// and "call" it
std::cout << "8 + 42 = " << add42(8) << "\n";
return 0;
}
| 16.166667
| 49
| 0.52921
|
zussel
|
7d8b95a50341cb59889d9654da14c7ffdea2db90
| 219
|
cpp
|
C++
|
OSE V2/OSE-Core/Resources/Mesh/MeshLoader.cpp
|
rexapex/OSE-V2-Game-Engine-
|
cbf8040d4b017275c073373f8438b227e691858d
|
[
"MIT"
] | 1
|
2019-09-29T17:45:11.000Z
|
2019-09-29T17:45:11.000Z
|
OSE V2/OSE-Core/Resources/Mesh/MeshLoader.cpp
|
rexapex/OSE-V2-Game-Engine-
|
cbf8040d4b017275c073373f8438b227e691858d
|
[
"MIT"
] | 10
|
2020-11-13T13:41:26.000Z
|
2020-11-16T18:46:57.000Z
|
OSE V2/OSE-Core/Resources/Mesh/MeshLoader.cpp
|
rexapex/OSE-Game-Engine
|
cbf8040d4b017275c073373f8438b227e691858d
|
[
"MIT"
] | null | null | null |
#include "stdafx.h"
#include "MeshLoader.h"
namespace ose
{
MeshLoader::MeshLoader(std::string const & project_path) : project_path_(project_path)
{
}
MeshLoader::~MeshLoader() // Free all mesh resources
{
}
}
| 14.6
| 87
| 0.707763
|
rexapex
|
7d8fbcd54bd2f868c61832ee14eaeb9b434c1bde
| 6,368
|
cpp
|
C++
|
Base/Motor2D/DefenseAOE.cpp
|
stormhowlers/StormHowlers
|
e821d07d78e0eea1935828b16abf2b89c344eaa7
|
[
"MIT"
] | 1
|
2019-03-08T16:59:43.000Z
|
2019-03-08T16:59:43.000Z
|
Base/Motor2D/DefenseAOE.cpp
|
stormhowlers/StormHowlers
|
e821d07d78e0eea1935828b16abf2b89c344eaa7
|
[
"MIT"
] | 14
|
2019-04-13T00:59:40.000Z
|
2019-05-25T14:35:03.000Z
|
Base/Motor2D/DefenseAOE.cpp
|
Scarzard/StormHowlers
|
e821d07d78e0eea1935828b16abf2b89c344eaa7
|
[
"MIT"
] | 1
|
2020-06-14T19:41:34.000Z
|
2020-06-14T19:41:34.000Z
|
#include "DefenseAoe.h"
#include "Brofiler\Brofiler.h"
#include "Audio.h"
#include "Player.h"
#include "Render.h"
#include "Log.h"
#include "Transitions.h"
#include <map>
DefenseAoe::DefenseAoe()
{
// NOW IS A COPY OF DEFENSE TARGET WITH DIFERENT BEHAVIOUR (UPDATE)
// NEED TO CHANGE THE NAME INSIDE GetName() TO "defense_aoe" ONCE ANIMATIONS PARSED
}
DefenseAoe::~DefenseAoe()
{
}
DefenseAoe::DefenseAoe(bool isPlayer1, pair<int, int> pos, Collider collider) : Building(Entity::entityType::DEFENSE_AOE, isPlayer1, pos, collider)
{
string path = "animation/" + name + ".tmx";
LoadAnimations(isPlayer1, path.data());
colider = collider;
first_shot = false;
}
bool DefenseAoe::Start()
{
return true;
}
bool DefenseAoe::PreUpdate()
{
BROFILER_CATEGORY("DefenseAoe PreUpdate", Profiler::Color::SandyBrown);
return true;
}
bool DefenseAoe::Update(float dt)
{
BROFILER_CATEGORY("DefenseAoe Update", Profiler::Color::SandyBrown);
//Checks where to look for enemies
Player* tmpMod = (fromPlayer1) ? App->player2 : App->player1;
priority_queue<pair<Troop*,int>, vector<pair<Troop*,int>>, Closest> ListOrder;
// Finds the closest one
int min_distance = 0;
int d = 0;
for (list<Troop*>::iterator tmp = tmpMod->troops.begin(); tmp != tmpMod->troops.end(); tmp++)
{
if (Is_inRange((*tmp)->position, min_distance) == true)
ListOrder.push({ *tmp, min_distance });
}
// Shoots the closest one if in range
if (ListOrder.empty() == false)
{
if (timer.ReadSec() >= rate_of_fire || first_shot == false)
{
if (fromPlayer1)
{
if (!App->player2->inmune)
{
for (int i = 0; i < max_targets; i++)
{
if (ListOrder.empty())
break;
ListOrder.top().first->TakeDamage(damage_lv[level]);
ListOrder.pop();
}
}
}
else if (!fromPlayer1)
{
if (!App->player1->inmune)
{
for (int i = 0; i < max_targets; i++)
{
if (ListOrder.empty())
break;
ListOrder.top().first->TakeDamage(damage_lv[level]);
ListOrder.pop();
}
}
}
first_shot = true;
timer.Start();
App->audio->PlayFx(TESLA_ATTACK);
//LOG("Distance: %d", d);
}
}
else
{
first_shot = false;
}
if (fromPlayer1) // --- Player 1 --------------------------------
{
if (level == 1 && App->scenechange->IsChanging() == false)
{
SDL_Rect upgrade;
upgrade.x = 0;
upgrade.y = 34;
upgrade.w = 32;
upgrade.h = 20;
App->render->Blit(App->scene->upgrade_lvl, position.first + 20, position.second + 10, &upgrade);
}
if (level == 2 && App->scenechange->IsChanging() == false)
{
SDL_Rect upgrade;
upgrade.x = 36;
upgrade.y = 17;
upgrade.w = 32;
upgrade.h = 37;
App->render->Blit(App->scene->upgrade_lvl, position.first + 20, position.second + 10, &upgrade);
}
if (upgrade == true && level <= 1) //upgrade
{
App->player1->gold -= Upgrade_Cost; //pay costs
level++;
damage = damage_lv[level];
Upgrade_Cost = cost_upgrade_lv[level];
health = health_lv[level];
upgrade = false;
//play fx (upgrade);
}
if (building->Finished() && built == false)
{
App->audio->PlayFx(ALLIED_LASER_B);
built = true;
}
if (health <= 0) //destroyed
{
App->player1->DeleteEntity(this);
App->audio->PlayFx(BUILDING_EXPLOSION);
App->render->Blit(App->scene->explosion_tex, position.first + 25, position.second + 25, &App->map->explosion_anim->GetCurrentFrame(dt));
App->audio->PlayFx(ALLIED_LASER_D);
App->player1->AOE_turretsCreated--;
}
}
else if (!fromPlayer1) // --- Player 2 ---------------------------
{
if (level == 1 && App->scenechange->IsChanging() == false)
{
SDL_Rect upgrade;
upgrade.x = 0;
upgrade.y = 34;
upgrade.w = 32;
upgrade.h = 20;
App->render->Blit(App->scene->upgrade_lvl, position.first + 20, position.second + 10, &upgrade);
}
if (level == 2 && App->scenechange->IsChanging() == false)
{
SDL_Rect upgrade;
upgrade.x = 36;
upgrade.y = 17;
upgrade.w = 32;
upgrade.h = 37;
App->render->Blit(App->scene->upgrade_lvl, position.first + 20, position.second + 10, &upgrade);
}
if (upgrade == true && level <= 1) //upgrade
{
App->player2->gold -= Upgrade_Cost; //pay costs
level++;
damage = damage_lv[level];
Upgrade_Cost = cost_upgrade_lv[level];
health = health_lv[level];
upgrade = false;
//play fx (upgrade);
}
if (building->Finished() && built == false)
{
App->audio->PlayFx(SOVIET_LASER_B);
built = true;
}
if (health <= 0) //destroyed
{
App->player2->DeleteEntity(this);
App->audio->PlayFx(BUILDING_EXPLOSION);
App->render->Blit(App->scene->explosion_tex, position.first + 25, position.second + 25, &App->map->explosion_anim->GetCurrentFrame(dt));
App->audio->PlayFx(SOVIET_LASER_D);
App->player2->AOE_turretsCreated--;
}
}
if (fromPlayer1)
{
if (App->player1->currentUI == Player::CURRENT_UI::CURR_SELECTING_BUILDING && App->player1->GetSelectedBuilding() == this)
{
if (building->Finished())
Current_Animation = glow;
}
else
{
if (building->Finished())
Current_Animation = level1;
}
}
else
{
if (App->player2->currentUI == Player::CURRENT_UI::CURR_SELECTING_BUILDING && App->player2->GetSelectedBuilding() == this)
{
if (building->Finished())
Current_Animation = glow;
}
else
{
if (building->Finished())
Current_Animation = level1;
}
}
Building::Update(dt);
return true;
}
void DefenseAoe::CleanUp()
{
// Its needed or the super class is always called?
Entity::CleanUp();
}
bool DefenseAoe::Is_inRange(pair<int, int> pos, int &distance) {
pair <int, int> vector_distance = { position.first - pos.first, position.second - pos.second };
distance = (int)(sqrt(pow(vector_distance.first, 2) + pow(vector_distance.second, 2)));
return distance <= range;
}
void DefenseAoe::LoadAnimations(bool isPlayer1, string path)
{
building = building->LoadAnimation(path.data(), (isPlayer1) ? "allied_aoe_build" : "soviet_aoe_build");
level1 = level1->LoadAnimation(path.data(), (isPlayer1) ? "allied_aoe_idle" : "soviet_aoe_idle");
glow = glow->LoadAnimation(path.data(), (isPlayer1) ? "allied_glow" : "soviet_glow");
level1->speed = 7;
building->speed = 5;
glow->speed = 0;
building->loop = false;
level1->loop = true;
glow->loop = true;
Current_Animation = building;
}
| 23.411765
| 147
| 0.637406
|
stormhowlers
|
7d949ba7c63f157ee1a00e107876a852a1ea9cc9
| 4,249
|
cpp
|
C++
|
imp_core/test/linearmemory_test.cpp
|
mwerlberger/imp
|
2a2e4d31fa59ca1c32ae7f415306b39e31fc1e85
|
[
"MIT"
] | 8
|
2015-10-24T18:31:58.000Z
|
2019-10-16T03:27:27.000Z
|
imp_core/test/linearmemory_test.cpp
|
henrywen2011/imp
|
2a2e4d31fa59ca1c32ae7f415306b39e31fc1e85
|
[
"MIT"
] | 7
|
2015-06-22T09:36:32.000Z
|
2015-08-20T06:56:10.000Z
|
imp_core/test/linearmemory_test.cpp
|
henrywen2011/imp
|
2a2e4d31fa59ca1c32ae7f415306b39e31fc1e85
|
[
"MIT"
] | 3
|
2015-05-13T14:46:48.000Z
|
2017-01-11T09:20:03.000Z
|
#include <gtest/gtest.h>
// system includes
#include <assert.h>
#include <cstdint>
#include <iostream>
#include <random>
#include <functional>
#include <limits>
#include <type_traits>
#include <imp/core/linearmemory.hpp>
template<class T>
typename std::enable_if<std::is_integral<T>::value, std::function<T()> >::type
getRandomGenerator()
{
std::default_random_engine generator(std::random_device{}());
std::uniform_int_distribution<T> distribution(std::numeric_limits<T>::lowest(),
std::numeric_limits<T>::max());
auto random_val = std::bind(distribution, generator);
return random_val;
}
template<class T>
typename std::enable_if<!std::is_integral<T>::value, std::function<T()> >::type
getRandomGenerator()
{
std::default_random_engine generator(std::random_device{}());
std::uniform_real_distribution<T> distribution(std::numeric_limits<T>::lowest(),
std::numeric_limits<T>::max());
auto random_val = std::bind(distribution, generator);
return random_val;
}
template <typename Pixel>
class LinearMemoryTest : public ::testing::Test
{
protected:
LinearMemoryTest() :
linmem_(numel_)
{
using T = typename Pixel::T;
auto random_val_generator = getRandomGenerator<T>();
T val1 = random_val_generator();
T val2;
do
{
val2 = random_val_generator();
} while(std::fabs(val1-val2) < std::numeric_limits<T>::epsilon());
pixel1_ = Pixel(val1);
pixel2_ = Pixel(val2);
}
void setValue()
{
linmem_.setValue(pixel1_);
}
void setRoi()
{
linmem_.setRoi(roi_);
}
void setValueRoi()
{
this->setRoi();
linmem_.setValue(pixel2_);
}
size_t pixel_size_ = sizeof(Pixel);
size_t pixel_bit_depth_ = 8*sizeof(Pixel);
size_t numel_ = 123;
imp::Roi1u roi_ = imp::Roi1u(numel_/3, numel_/3);
imp::LinearMemory<Pixel> linmem_;
Pixel pixel1_;
Pixel pixel2_;
};
// The list of types we want to test.
typedef testing::Types<
imp::Pixel8uC1, imp::Pixel8uC2, imp::Pixel8uC3, imp::Pixel8uC4,
imp::Pixel16uC1, imp::Pixel16uC2, imp::Pixel16uC3, imp::Pixel16uC4,
imp::Pixel32sC1, imp::Pixel32sC2, imp::Pixel32sC3, imp::Pixel32sC4,
imp::Pixel32uC1, imp::Pixel32uC2, imp::Pixel32uC3, imp::Pixel32uC4,
imp::Pixel32fC1, imp::Pixel32fC2, imp::Pixel32fC3, imp::Pixel32fC4> PixelTypes;
TYPED_TEST_CASE(LinearMemoryTest, PixelTypes);
TYPED_TEST(LinearMemoryTest, CheckMemforyAlignment)
{
ASSERT_EQ(0, (std::uintptr_t)reinterpret_cast<void*>(this->linmem_.data()) % 32);
}
TYPED_TEST(LinearMemoryTest, CheckLength)
{
ASSERT_EQ(this->numel_, this->linmem_.length());
}
TYPED_TEST(LinearMemoryTest, CheckNoRoi)
{
ASSERT_EQ(0, this->linmem_.roi().x());
ASSERT_EQ(this->numel_, this->linmem_.roi().length());
}
TYPED_TEST(LinearMemoryTest, CheckRoi)
{
this->setRoi();
ASSERT_EQ(this->roi_.x(), this->linmem_.roi().x());
ASSERT_EQ(this->roi_.length(), this->linmem_.roi().length());
}
TYPED_TEST(LinearMemoryTest, CheckNumBytes)
{
ASSERT_EQ(this->numel_*this->pixel_size_, this->linmem_.bytes());
}
TYPED_TEST(LinearMemoryTest, CheckNumRoiBytes)
{
this->setRoi();
ASSERT_EQ(this->roi_.length()*this->pixel_size_, this->linmem_.roiBytes());
}
TYPED_TEST(LinearMemoryTest, CheckPixelBitDepth)
{
ASSERT_EQ(this->pixel_bit_depth_, this->linmem_.bitDepth());
}
TYPED_TEST(LinearMemoryTest, ReturnsFalseForNonGpuMemory)
{
ASSERT_FALSE(this->linmem_.isGpuMemory());
}
TYPED_TEST(LinearMemoryTest, CheckValues)
{
this->setValue();
for (std::uint32_t i=0; i<this->numel_; ++i)
{
ASSERT_EQ(this->linmem_[i], this->pixel1_);
}
}
TYPED_TEST(LinearMemoryTest, CheckValuesInConstLinearMemory)
{
this->setValue();
const imp::LinearMemory<TypeParam> const_linmem(this->linmem_);
for (std::uint32_t i=0; i<this->numel_; ++i)
{
ASSERT_EQ(const_linmem[i], this->pixel1_);
}
}
TYPED_TEST(LinearMemoryTest, CheckRoiValues)
{
this->setValue();
this->setValueRoi();
for (std::uint32_t i=0; i<this->numel_; ++i)
{
if (i>=this->roi_.x() && i<(this->roi_.x()+this->roi_.length()))
{
ASSERT_EQ(this->pixel2_, this->linmem_[i]);
}
else
{
ASSERT_EQ(this->pixel1_, this->linmem_[i]);
}
}
}
| 23.870787
| 83
| 0.683926
|
mwerlberger
|
7d9a6ae9488c2272e562d773ce48947c04ab2736
| 5,633
|
cpp
|
C++
|
src/light.cpp
|
tenglvjun/geometry
|
b6615adaeb8c600cd1b75a604e6793e6a98e2fb3
|
[
"MIT"
] | null | null | null |
src/light.cpp
|
tenglvjun/geometry
|
b6615adaeb8c600cd1b75a604e6793e6a98e2fb3
|
[
"MIT"
] | null | null | null |
src/light.cpp
|
tenglvjun/geometry
|
b6615adaeb8c600cd1b75a604e6793e6a98e2fb3
|
[
"MIT"
] | null | null | null |
#include "light.h"
#include <cmath>
#include "tools.h"
#include "setting.h"
#include "shader_code_manage.h"
#include "math_tools.h"
GeoLight::GeoLight()
: m_ubo(0)
{
RestoreFromSetting();
m_bindingPoint = Shader::RequestBindingPoint();
InitShader();
InitUniformBuffer();
UpdateUniformBuffer();
}
GeoLight::~GeoLight()
{
ClearUBO();
}
void GeoLight::SetLight(const GeoVector3D &pos, const GeoVector3D &origin, const GeoColor &color)
{
m_pos = pos;
m_color = color;
UpdateUniformBuffer();
}
void GeoLight::SetLightSource(const LightSource_e source)
{
m_source = source;
UpdateUniformBuffer();
}
LightSource_e GeoLight::GetLightSource()
{
return m_source;
}
const GeoVector3D &GeoLight::Position() const
{
return m_pos;
}
void GeoLight::Position(const GeoVector3D &pos)
{
m_pos = pos;
UpdateUniformBuffer();
}
GeoVector3D GeoLight::Direction() const
{
GeoVector3D dir = GeoVector3D(0.0f, 0.0f, 0.0f) - m_pos;
dir.Normalize();
return dir;
}
const unsigned int GeoLight::PointLightAttenuationRange() const
{
return m_pointAttenuationRange;
}
void GeoLight::SetPointLightAttenuationRange(const unsigned int range)
{
m_pointAttenuationRange = range;
UpdateUniformBuffer();
}
GeoVector3D GeoLight::Ambient() const
{
return m_ambient;
}
void GeoLight::Ambient(const GeoVector3D &ambient)
{
m_ambient = ambient;
UpdateUniformBuffer();
}
GeoVector3D GeoLight::Specular() const
{
return m_specular;
}
void GeoLight::Specular(const GeoVector3D &specular)
{
m_specular = specular;
UpdateUniformBuffer();
}
GeoVector3D GeoLight::Diffuse() const
{
return m_diffuse;
}
void GeoLight::Diffuse(const GeoVector3D &diffuse)
{
m_diffuse = diffuse;
UpdateUniformBuffer();
}
GeoColor GeoLight::Color() const
{
return m_color;
}
void GeoLight::Color(const GeoColor &color)
{
m_color = color;
UpdateUniformBuffer();
}
unsigned int GeoLight::GetUniformBlockIndex() const
{
return m_shader.GetUniformBlockIndex("LightBlock");
}
unsigned int GeoLight::GetUniformBindingPoint() const
{
return m_bindingPoint;
}
void GeoLight::BindUniformBlock(const Shader &shader)
{
shader.BindUniformBlock("LightBlock", m_bindingPoint);
}
void GeoLight::ClearUBO()
{
if (m_ubo > 0)
{
glDeleteBuffers(1, &m_ubo);
m_ubo = 0;
}
}
void GeoLight::RestoreFromSetting()
{
OpenGLConfig &config = GeoSetting::GetInstance()->OpenGLConfig();
m_ambient = config.m_light.m_ambient;
m_specular = config.m_light.m_specular;
m_diffuse = config.m_light.m_diffuse;
m_source = config.m_light.m_source;
m_pointAttenuationRange = config.m_light.m_pointAttenuationRange;
m_pos = config.m_light.m_pos;
m_color = config.m_light.m_color;
}
void GeoLight::InitShader()
{
const GeoShaderCode &lightCode = GeoShaderCodeMgr::GetInstance()->GetShaderCode(SCT_Light);
m_shader.Init(lightCode.m_vertex, lightCode.m_fragment);
m_shader.Complie();
}
void GeoLight::InitUniformBuffer()
{
ClearUBO();
std::vector<float> data;
m_pos.Flatten(data);
m_ambient.Flatten(data);
m_diffuse.Flatten(data);
m_specular.Flatten(data);
m_color.Flatten(data);
int size = m_shader.GetUniformBlockSize("LightBlock");
glGenBuffers(1, &m_ubo);
glBindBuffer(GL_UNIFORM_BUFFER, m_ubo);
glBufferData(GL_UNIFORM_BUFFER, size, nullptr, GL_STATIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
glBindBufferRange(GL_UNIFORM_BUFFER, m_bindingPoint, m_ubo, 0, size);
}
void GeoLight::UpdateUniformBuffer()
{
OpenGLConfig &config = GeoSetting::GetInstance()->OpenGLConfig();
float constant = (float)(config.m_light.m_pointAttenuation[m_pointAttenuationRange].m_constant);
float linear = (float)(config.m_light.m_pointAttenuation[m_pointAttenuationRange].m_linear);
float quadratic = (float)(config.m_light.m_pointAttenuation[m_pointAttenuationRange].m_quadratic);
float cutOff = (float)(MathTools::Degree2Radian(config.m_light.m_cutOff));
float outerCutOff = (float)(MathTools::Degree2Radian(config.m_light.m_outerCutOff));
cutOff = cos(cutOff);
outerCutOff = cos(outerCutOff);
unsigned int offset = 0;
glBindBuffer(GL_UNIFORM_BUFFER, m_ubo);
glBufferSubData(GL_UNIFORM_BUFFER, offset, sizeof(int), &m_source);
std::vector<float> data;
m_pos.Flatten(data);
offset = 16;
glBufferSubData(GL_UNIFORM_BUFFER, offset, sizeof(float) * data.size(), &data[0]);
data.clear();
m_ambient.Flatten(data);
offset = 32;
glBufferSubData(GL_UNIFORM_BUFFER, offset, sizeof(float) * data.size(), &data[0]);
data.clear();
m_diffuse.Flatten(data);
offset = 48;
glBufferSubData(GL_UNIFORM_BUFFER, offset, sizeof(float) * data.size(), &data[0]);
data.clear();
m_specular.Flatten(data);
offset = 64;
glBufferSubData(GL_UNIFORM_BUFFER, offset, sizeof(float) * data.size(), &data[0]);
data.clear();
m_color.Flatten(data);
offset = 80;
glBufferSubData(GL_UNIFORM_BUFFER, offset, sizeof(float) * data.size(), &data[0]);
offset = 96;
glBufferSubData(GL_UNIFORM_BUFFER, offset, sizeof(float), &constant);
offset = 100;
glBufferSubData(GL_UNIFORM_BUFFER, offset, sizeof(float), &linear);
offset = 104;
glBufferSubData(GL_UNIFORM_BUFFER, offset, sizeof(float), &quadratic);
offset = 108;
glBufferSubData(GL_UNIFORM_BUFFER, offset, sizeof(float), &cutOff);
offset = 112;
glBufferSubData(GL_UNIFORM_BUFFER, offset, sizeof(float), &outerCutOff);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
| 22.898374
| 102
| 0.709746
|
tenglvjun
|
7da79adea403efc073b6d1f9603643b648a5ee12
| 133
|
hpp
|
C++
|
MyApp/tests/myapp.hpp
|
flowtr/chatlab-engine
|
ab79073d7fac93df49db8c02a07758f43d151fa6
|
[
"Unlicense"
] | 3
|
2021-08-27T23:09:59.000Z
|
2021-08-30T03:49:13.000Z
|
MyApp/tests/myapp.hpp
|
Zephilinox/emscripten-cpp-cmake-template
|
90223195bf2386ed62e1f3e07c0d40baeab7fbef
|
[
"Unlicense"
] | null | null | null |
MyApp/tests/myapp.hpp
|
Zephilinox/emscripten-cpp-cmake-template
|
90223195bf2386ed62e1f3e07c0d40baeab7fbef
|
[
"Unlicense"
] | null | null | null |
//SELF
#include "MyApp/Game.hpp"
//LIBS
#include <doctest/doctest.h>
//STD
TEST_CASE("test")
{
CHECK_EQ(Game::add(1, 2), 3);
}
| 11.083333
| 33
| 0.62406
|
flowtr
|
7da9e1db1eb06a740bafdf4bd116e9412f2c3a8d
| 631
|
cc
|
C++
|
2019/d1s2.cc
|
danielrayali/adventofcode
|
29bfd54013a4ba832b7c846d2770eb03692d67de
|
[
"MIT"
] | null | null | null |
2019/d1s2.cc
|
danielrayali/adventofcode
|
29bfd54013a4ba832b7c846d2770eb03692d67de
|
[
"MIT"
] | null | null | null |
2019/d1s2.cc
|
danielrayali/adventofcode
|
29bfd54013a4ba832b7c846d2770eb03692d67de
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <fstream>
#include <set>
using namespace std;
int main(int argc, char* argv[]) {
if (argc != 2) {
cerr << "Give a file to parse" << endl;
return 0;
}
string path(argv[1]);
int total = 0;
set<int> history;
history.emplace(0);
while (true) {
ifstream in(path);
while (!in.eof()) {
int current = 0;
in >> current;
total += current;
if (history.find(total) != history.end()) {
cout << "First repeat: " << total << endl;
return 0;
}
history.emplace(total);
}
}
cout << "No repeat found!" << endl;
return 0;
}
| 17.527778
| 50
| 0.537242
|
danielrayali
|
7dad39c4f246ecb56a7b1b90958d3af8f9796d25
| 2,774
|
cpp
|
C++
|
src/Robot/leg.cpp
|
TheDarkPhoenix/HexapodRaspberry
|
67116e06f80311b95124357892399e025675bff7
|
[
"MIT"
] | null | null | null |
src/Robot/leg.cpp
|
TheDarkPhoenix/HexapodRaspberry
|
67116e06f80311b95124357892399e025675bff7
|
[
"MIT"
] | 1
|
2018-06-08T15:30:36.000Z
|
2018-06-08T15:35:57.000Z
|
src/Robot/leg.cpp
|
TheDarkPhoenix/HexapodRaspberry
|
67116e06f80311b95124357892399e025675bff7
|
[
"MIT"
] | null | null | null |
#include "Robot/leg.h"
using namespace cv;
Leg::Leg(Point3f joint1, Point3f angles1, Point3f lengths1, cv::Point3f signals1)
{
legJoints.A = joint1;
angles = angles1;
lengths = lengths1;
signals = signals1;
}
void Leg::initJointPoints()
{
calculateJointPoints();
legEnd = legJoints.D;
initAngles = angles;
calculateAngles();
}
void Leg::calculateJointPoints()
{
Mat P1 = (Mat_<float>(3,1) << lengths.x, 0, 0);
Mat R1 = (Mat_<float>(3,3) << cos(angles.x), 0, sin(angles.x), 0, 1, 0, -sin(angles.x), 0, cos(angles.x));
Mat P11 = R1*P1;
P11 = R*P11;
legJoints.B = Point3f(P11.at<float>(0,0), P11.at<float>(0,1), P11.at<float>(0,2)) + legJoints.A;
Mat P2 = (Mat_<float>(3,1) << lengths.y, 0, 0);
Mat R2 = (Mat_<float>(3,3) << cos(angles.y), -sin(angles.y), 0, sin(angles.y), cos(angles.y), 0, 0, 0, 1);
Mat P22 = R1*(R2*P2);
P22 = R*P22;
legJoints.C = Point3f(P22.at<float>(0,0), P22.at<float>(0,1), P22.at<float>(0,2)) + legJoints.B;
Mat P3 = (Mat_<float>(3,1) << lengths.z, 0, 0);
Mat R3 = (Mat_<float>(3,3) << cos(angles.z), -sin(angles.z), 0, sin(angles.z), cos(angles.z), 0, 0, 0, 1);
Mat P33 = R1*(R3*P3);
P33 = R*P33;
legJoints.D = Point3f(P33.at<float>(0,0), P33.at<float>(0,1), P33.at<float>(0,2)) + legJoints.C;
}
int Leg::calculateAngles()
{
Point3f newPos = legEnd-legJoints.A; // pozycja poczatku nogi po przekszta³ceniu
float lx = lengths.x;
float L = sqrt(pow(newPos.x,2)+pow(newPos.z,2));
float iksw = sqrt(pow((L-lx),2)+pow(newPos.y,2));
float a1 = atan((L-lx)/newPos.y);
float a2 = acos((pow(lengths.z,2)-pow(lengths.y,2)-pow(iksw,2))/((-2.)*iksw*lengths.y));
float b = acos((pow(iksw,2)-pow(lengths.y,2)-pow(lengths.z,2))/((-2.)*lengths.y*lengths.z));
if(newPos.x&&newPos.z)
angles.x = -atan(newPos.z/newPos.x);
else
angles.x = 0;
angles.y = -(a1+a2-0.5*CV_PI);
angles.z = (CV_PI - b + angles.y);
relAngles.x = angles.x;
relAngles.y = angles.y;
relAngles.z = b;
if(angles.x != angles.x || angles.y != angles.y || angles.z!=angles.z)//nan detect
{
calculateJointPoints();
return -1;
}
calculateJointPoints();
calculateServoSignals();
return 1;
}
void Leg::calculateServoSignals()
{
float wspolczynnik = 1000/(CV_PI/2 - 1.18);//wspolczynnik zamiany katow na sygnaly
int sygnalA, sygnalB, sygnalC;
sygnalA = relAngles.x*wspolczynnik + signals.x;
sygnalB = -relAngles.y*wspolczynnik + signals.y;
sygnalC = (CV_PI/2 -relAngles.z)*wspolczynnik + signals.z;
if(device)
{
device->setTarget(servos.x, sygnalA);
device->setTarget(servos.y, sygnalB);
device->setTarget(servos.z, sygnalC);
}
}
| 29.827957
| 110
| 0.601298
|
TheDarkPhoenix
|
7daf90ae76c470170441dc43f9bb111d70a22978
| 237
|
cpp
|
C++
|
modules/common/src/visibility_reasoning.cpp
|
ToMadoRe/v4r
|
7cb817e05cb9d99cb2f68db009c27d7144d07f09
|
[
"MIT"
] | 17
|
2015-11-16T14:21:10.000Z
|
2020-11-09T02:57:33.000Z
|
modules/common/src/visibility_reasoning.cpp
|
ToMadoRe/v4r
|
7cb817e05cb9d99cb2f68db009c27d7144d07f09
|
[
"MIT"
] | 35
|
2015-07-27T15:04:43.000Z
|
2019-08-22T10:52:35.000Z
|
modules/common/src/visibility_reasoning.cpp
|
ToMadoRe/v4r
|
7cb817e05cb9d99cb2f68db009c27d7144d07f09
|
[
"MIT"
] | 18
|
2015-08-06T09:26:27.000Z
|
2020-09-03T01:31:00.000Z
|
#include <v4r/common/visibility_reasoning.h>
#include <v4r/common/impl/visibility_reasoning.hpp>
template class V4R_EXPORTS v4r::VisibilityReasoning<pcl::PointXYZ>;
template class V4R_EXPORTS v4r::VisibilityReasoning<pcl::PointXYZRGB>;
| 39.5
| 70
| 0.831224
|
ToMadoRe
|
7db4d703919ef4d6f95092de9280e7128bfb5121
| 4,796
|
hpp
|
C++
|
addons/modules/modules/createTask/module.hpp
|
Krzyciu/A3CS
|
b7144fc9089b5ded6e37cc1fad79b1c2879521be
|
[
"MIT"
] | 1
|
2020-06-07T00:45:49.000Z
|
2020-06-07T00:45:49.000Z
|
addons/modules/modules/createTask/module.hpp
|
Krzyciu/A3CS
|
b7144fc9089b5ded6e37cc1fad79b1c2879521be
|
[
"MIT"
] | 27
|
2020-05-24T11:09:56.000Z
|
2020-05-25T12:28:10.000Z
|
addons/modules/modules/createTask/module.hpp
|
Krzyciu/A3CS
|
b7144fc9089b5ded6e37cc1fad79b1c2879521be
|
[
"MIT"
] | 2
|
2020-05-31T08:52:45.000Z
|
2021-04-16T23:16:37.000Z
|
class GVAR(createTask): GVAR(base) {
scope = 2;
author = "SzwedzikPL";
displayName = CSTRING(createTask_displayName);
icon = "\a3\Modules_F\Data\iconTaskCreate_ca.paa";
category = QGVAR(tasks);
function = QFUNC(createTask_module);
functionPriority = 2;
GVAR(validator) = QFUNC(createTask_validate);
class Attributes: AttributesBase {
class GVAR(moduleShortDescription): GVAR(moduleShortDescription) {};
class GVAR(moduleWarnings): GVAR(moduleWarnings) {};
// Attributes for module activator
#define MODULE_ACTIVATOR_CONTROL QGVAR(dynamicToolboxActivationModeMissionStart)
#define MODULE_ACTIVATOR_DEFAULT_VALUE QUOTE(-1)
#include "\z\a3cs\addons\modules\includes\moduleActivationAttributes.hpp"
class GVAR(baseSettingsSubCategory): GVAR(moduleSubCategory) {
displayName = CSTRING(createTask_Attributes_baseSettingsSubCategory);
property = QGVAR(baseSettingsSubCategory);
};
// Read only task ID, auto generated in validator
class GVAR(id): GVAR(dynamicEdit) {
displayName = CSTRING(createTask_Attributes_id);
tooltip = CSTRING(createTask_Attributes_id_tooltip);
property = QGVAR(id);
defaultValue = "''";
unique = 1;
GVAR(description) = CSTRING(createTask_Attributes_id_desc);
GVAR(disabled) = 1;
ATTRIBUTE_LOCAL;
};
class GVAR(owner): GVAR(dynamicOwnerToolbox) {
displayName = CSTRING(createTask_Attributes_owner);
tooltip = CSTRING(createTask_Attributes_owner_tooltip);
property = QGVAR(owner);
typeName = "NUMBER";
defaultValue = "0";
ATTRIBUTE_LOCAL;
};
class GVAR(parent): GVAR(dynamicCombo) {
displayName = CSTRING(createTask_Attributes_parent);
tooltip = CSTRING(createTask_Attributes_parent_tooltip);
property = QGVAR(parent);
typeName = "STRING";
defaultValue = "''";
GVAR(insertValues) = QFUNC(createTask_parent_insertValues);
ATTRIBUTE_LOCAL;
class values {
class none {
name = CSTRING(createTask_Attributes_parent_none);
tooltip = CSTRING(createTask_Attributes_parent_none_tooltip);
value = "";
default = 1;
};
};
};
class GVAR(title): GVAR(dynamicEdit) {
displayName = CSTRING(createTask_Attributes_title);
tooltip = CSTRING(createTask_Attributes_title_tooltip);
property = QGVAR(title);
GVAR(observeValue) = 1;
ATTRIBUTE_LOCAL;
};
class GVAR(description): GVAR(dynamicEditMulti5) {
displayName = CSTRING(createTask_Attributes_description);
tooltip = CSTRING(createTask_Attributes_description_tooltip);
property = QGVAR(description);
ATTRIBUTE_LOCAL;
};
class GVAR(type): GVAR(dynamicCombo) {
displayName = CSTRING(createTask_Attributes_type);
tooltip = CSTRING(createTask_Attributes_type_tooltip);
property = QGVAR(type);
typeName = "STRING";
defaultValue = "'default'";
GVAR(insertValues) = QFUNC(createTask_type_insertValues);
ATTRIBUTE_LOCAL;
};
class GVAR(state): GVAR(dynamicToolboxTaskState) {
displayName = CSTRING(createTask_Attributes_state);
tooltip = CSTRING(createTask_Attributes_state_tooltip);
property = QGVAR(state);
defaultValue = "0";
ATTRIBUTE_LOCAL;
};
class GVAR(showPos): GVAR(dynamicCheckbox) {
displayName = CSTRING(createTask_Attributes_showPos);
tooltip = CSTRING(createTask_Attributes_showPos_tooltip);
property = QGVAR(showPos);
defaultValue = "true";
GVAR(observeValue) = 0;
ATTRIBUTE_LOCAL;
};
class GVAR(showNotification): GVAR(dynamicCheckbox) {
displayName = CSTRING(createTask_Attributes_showNotification);
tooltip = CSTRING(createTask_Attributes_showNotification_tooltip);
property = QGVAR(showNotification);
defaultValue = "true";
GVAR(observeValue) = 0;
GVAR(description) = CSTRING(createTask_Attributes_showNotification_desc);
ATTRIBUTE_LOCAL;
};
class GVAR(moduleDescription): GVAR(moduleDescription) {};
};
class GVAR(moduleDescription): GVAR(moduleDescription) {
shortDescription = CSTRING(createTask_shortDescription);
};
};
| 38.677419
| 88
| 0.618015
|
Krzyciu
|
7dc2bf5ec8561caf0011e54db7d8718571d4d209
| 1,515
|
cpp
|
C++
|
contests/leetcode-155/b.cpp
|
Nightwish-cn/my_leetcode
|
40f206e346f3f734fb28f52b9cde0e0041436973
|
[
"MIT"
] | 23
|
2020-03-30T05:44:56.000Z
|
2021-09-04T16:00:57.000Z
|
contests/leetcode-155/b.cpp
|
Nightwish-cn/my_leetcode
|
40f206e346f3f734fb28f52b9cde0e0041436973
|
[
"MIT"
] | 1
|
2020-05-10T15:04:05.000Z
|
2020-06-14T01:21:44.000Z
|
contests/leetcode-155/b.cpp
|
Nightwish-cn/my_leetcode
|
40f206e346f3f734fb28f52b9cde0e0041436973
|
[
"MIT"
] | 6
|
2020-03-30T05:45:04.000Z
|
2020-08-13T10:01:39.000Z
|
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
int f = 1, x = 0;
char c = getchar();
while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
return f * x;
}
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
bool isLeaf(TreeNode* root) {
return root->left == NULL && root->right == NULL;
}
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
class Solution {
public:
long long gcd(long long a, long long b) {
return (!b) ? a: gcd(b, a % b);
}
int nthUglyNumber(int n, int a, int b, int c) {
long long lcm = 1ll * a * b / gcd(a, b);
lcm = 1ll * lcm * c / gcd(lcm, c);
long long lcm1 = 1ll * a * b / gcd(a, b), lcm2 = 1ll * c * b / gcd(c, b), lcm3 = 1ll * a * c / gcd(a, c);
int l = 1, r = 2000000000;
while (r > l){
long long mid = (1ll * l + r) >> 1;
long long cnt = mid / a + mid / b + mid / c - mid / lcm1 - mid / lcm2 - mid / lcm3 + mid / lcm;
if (cnt < n) l = mid + 1;
else r = mid;
}
return l;
}
};
Solution sol;
void init(){
cout << sol.nthUglyNumber(1000000000, 2, 217983653, 336916467);
}
void solve(){
// sol.convert();
}
int main(){
init();
solve();
return 0;
}
| 24.836066
| 113
| 0.490429
|
Nightwish-cn
|
7dc2dbd7c0514a3fe68684f455cda5b2224aab75
| 18,861
|
cpp
|
C++
|
GB_APU.cpp
|
mmmaolololo/hey
|
a889c58142b9c8a775a94b24420126b228d1a776
|
[
"Apache-2.0"
] | null | null | null |
GB_APU.cpp
|
mmmaolololo/hey
|
a889c58142b9c8a775a94b24420126b228d1a776
|
[
"Apache-2.0"
] | null | null | null |
GB_APU.cpp
|
mmmaolololo/hey
|
a889c58142b9c8a775a94b24420126b228d1a776
|
[
"Apache-2.0"
] | null | null | null |
#include "GB_APU.h"
const GB_BY APU::ReadTable[0x20] = {
0x80,0x3F,0x00,0xFF,0xBF,
0xFF,0x3F,0x00,0xFF,0xBF,
0x7F,0xFF,0x9F,0xFF,0xBF,
0xFF,0xFF,0x00,0x00,0xBF,
0x00,0x00,0x70,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
};
const GB_BY APU::WaveTable[4][8] = {
{0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,1},
{1,0,0,0,0,1,1,1},
{0,1,1,1,1,1,1,0}
};
const GB_BY APU::NoiseDiv[8] = {8,16,32,48,64,80,96,112};
const GB_BY APU::WaveVol[4] = { 4,0,1,2 };
void APU::APUWrite(GB_DB ad, GB_BY val) {
if (ad < 0xFF30) {
if (Power == 0) {
switch (ad) {//On DMG,the LengthCounter can still working while power off,but not clocked.
case NR52://go forward.
break;
case NR11:
LengthCounter[0] = 64 - (val & 0x3F);
return;
case NR21:
LengthCounter[1] = 64 - (val & 0x3F);
return;
case NR31:
LengthCounter[2] = 256 - val;
return;
case NR41:
LengthCounter[3] = 64 - (val & 0x3F);
default:
return;
}
}
switch (ad) {
case NR10:
//Reg[NR10 - 0xFF10] = val;
SweepPeriod = (val & 0x70) >> 4;
Negate = val & 0x8;
SweepShift = val & 0x7;
if (Negated &&(Negate == 0)) {
Trigger[0] = 0;
SweepEnable = 0;
}
break;
case NR11:
//Reg[NR11 - 0xFF10] = val;
Duty[0] = (val&0xC0)>>6;
LengthLoad[0] = val & 0x3F;
LengthCounter[0] = 64- LengthLoad[0];
break;
case NR12:
//Reg[NR12 - 0xFF10] = val;
VolSet[0] = val >> 4;
VolEnvMode[0] = (val & 0x8) >> 3;
VolEnvPeriod[0] = (val & 0x7);
if (VolSet[0] == 0 && VolEnvMode[0] == 0) {
DACEnable[0] = 0;//disabled DAC should disable the channel immadiately.
Trigger[0] = 0;
}
else DACEnable[0] = 1;
break;
case NR13:
//Reg[NR13 - 0xFF10] = val;
Freq[0] = val|(Freq[0]&0x700);
_Timer[0].limit = (2048 - (Freq[0] & 0x7FF)) << 2;
break;
case NR14:
if ((val & 0x40) >> 6) {
Trigger[0] = 1;//enable length also enable channel.disable length cant disable channel.
}
if (LengthEnable[0] == 0 && (val & 0x40) >> 6 && (step&1)==0) {
if (LengthCounter[0] != 0) {
LengthCounter[0]--;
if (LengthCounter[0] == 0 && (val & 0x80) == 0) {
Trigger[0] = 0;
}
}
}
//Reg[NR14 - 0xFF10] = val;
LengthEnable[0] = (val & 0x40) >> 6;//once be set,it will be used.
Freq[0] = (Freq[0] & 0xFF) | ((val & 0x7) << 8);
if ((val & 0x80) >> 7) {
Trigger[0] = 1;
if (LengthCounter[0] == 0) {
if ((step & 1) == 0 && LengthEnable[0]) {
LengthCounter[0] = 63;
}
else {
LengthCounter[0] = 64;
}
}
_Timer[0].limit = (2048-(Freq[0]&0x7FF))<<2;
_Timer[0].oldLimit = _Timer[0].limit;
_Timer[0].current = 0;//in fact,the last 2 bits are consistent.
EnvTimer[0] = VolEnvPeriod[0];
EnvStop[0] = 0;
VolOut[0] = VolSet[0];
Negated = 0;
Shadow = Freq[0];
if (SweepPeriod != 0) {
SweepTimer = SweepPeriod;
}
else {
SweepTimer = 8;
}
if (SweepShift == 0 && SweepPeriod == 0) {
SweepEnable = 0;//wont stop Channel,just stop sweep.
}
else {
SweepEnable = 1;//needed?
if (SweepShift != 0) {
if (Negate) {
Negated = 1;
if (Shadow - (Shadow >> SweepShift) > 2047)Trigger[0] = 0;
}
else {
if (Shadow + (Shadow >> SweepShift) > 2047)Trigger[0] = 0;
}
}
}
Ptr[0] = 7;
//once overflow,disable the channel.
if (DACEnable[0] == 0)Trigger[0] = 0;// disabled DAC allow data updated,but still disables the channel.
}
break;
case NR21:
//Reg[NR21 - 0xFF10] = val;
Duty[1] = (val & 0xC0) >> 6;
LengthLoad[1] = val & 0x3F;
LengthCounter[1] = 64-LengthLoad[1];
break;
case NR22:
//Reg[NR22 - 0xFF10] = val;
VolSet[1] = val >> 4;
VolEnvMode[1] = (val & 0x8) >> 3;
VolEnvPeriod[1] = (val & 0x7);
if (VolSet[1] == 0 && VolEnvMode[1] == 0) {
DACEnable[1] = 0;
Trigger[1] = 0;
}
else DACEnable[1] = 1;
break;
case NR23:
//Reg[NR23 - 0xFF10] = val;
Freq[1] = val | (Freq[1] & 0x700);
_Timer[1].limit = (2048 - (Freq[1] & 0x7FF)) << 2;//seems that the Timer can be modified while running,but i dont know whether it would
//be reloaded at the same time.
break;
case NR24:
//Reg[NR24 - 0xFF10] = val;
if ((val & 0x40) >> 6) {
Trigger[1] = 1;
}
if (LengthEnable[1] == 0 && (val & 0x40) >> 6 && (step & 1) == 0) {
if (LengthCounter[1] != 0) {
LengthCounter[1]--;
if (LengthCounter[1] == 0 && (val & 0x80)==0) {
Trigger[1] = 0;
}
}
}
LengthEnable[1] = (val & 0x40) >> 6;
Freq[1] = (Freq[1] & 0xFF) | ((val & 0x7) << 8);
if ((val & 0x80) >> 7) {
Trigger[1] = 1;
if (LengthCounter[1] == 0) {
if ((step & 1) == 0 && LengthEnable[1]) {
LengthCounter[1] = 63;
}
else {
LengthCounter[1] = 64;
}
}
_Timer[1].limit = (2048 - (Freq[1] & 0x7FF))<<2;
_Timer[1].oldLimit = _Timer[1].limit;
_Timer[1].current = 0;
EnvTimer[1] = VolEnvPeriod[1];
EnvStop[1] = 0;
VolOut[1] = VolSet[1];
Ptr[1] = 7;
if (DACEnable[1] == 0)Trigger[1] = 0;
}
break;
case NR30:
//Reg[NR30 - 0xFF10] = val;
if (val & 0x80)DACEnable[2] = 1;//Wave channel DAC is not controlled by volume set.
else {
DACEnable[2] = 0;
Trigger[2] = 0;
}
break;
case NR31:
//Reg[NR31 - 0xFF10] = val;
LengthLoad[2] = val;
LengthCounter[2] = 256- val;
break;
case NR32:
//Reg[NR32 - 0xFF10] = val;
VolSet[2] = (val & 0x60) >> 5;
break;
case NR33:
//Reg[NR33 - 0xFF10] = val;
Freq[2] = val | (Freq[2] & 0x700);
_Timer[2].limit = (2048 - (Freq[2] & 0x7FF)) << 1;
break;
case NR34:
if ((val & 0x40) >> 6) {
Trigger[2] = 1;
}
if (LengthEnable[2] == 0 && (val & 0x40) >> 6 && (step & 1) == 0) {
if (LengthCounter[2] != 0) {
LengthCounter[2]--;
if (LengthCounter[2] == 0 && (val & 0x80) == 0) {
Trigger[2] = 0;
}
}
}
//Reg[NR34 - 0xFF10] = val;
LengthEnable[2] = (val & 0x40) >> 6;
Freq[2] = (Freq[2] & 0xFF) | ((val & 0x7) << 8);
if ((val & 0x80) >> 7) {
Trigger[2] = 1;
justTriggered = 1;
if (LengthCounter[2] == 0) {
if ((step & 1) == 0 && LengthEnable[2]) {
LengthCounter[2] = 255;
}
else {
LengthCounter[2] = 256;
}
}
_Timer[2].limit = (2048 - (Freq[2] & 0x7FF))<<1;
_Timer[2].oldLimit = _Timer[2].limit;//?
_Timer[2].current = 0;
VolOut[2] = VolSet[2];
Ptr[2] = 0;
if (DACEnable[2] == 0)Trigger[2] = 0;
}
break;
case NR41:
//Reg[NR41 - 0xFF10] = val;
LengthLoad[3] = val & 0x3F;
LengthCounter[3] = 64- LengthLoad[3];
break;
case NR42:
//Reg[NR42 - 0xFF10] = val;
VolSet[3] = val >> 4;
VolEnvMode[2] = (val & 0x8) >> 3;
VolEnvPeriod[2] = (val & 0x7);
if (VolSet[3] == 0 && VolEnvMode[2] == 0) {
DACEnable[3] = 0;
Trigger[3] = 0;
}
else DACEnable[3] = 1;
break;
case NR43:
//Reg[NR43 - 0xFF10] = val;
DivPtr = val & 0x7;
WidthMode = val & 0x8;
Shift = val & 0xF0;
Freq[3] = NoiseDiv[DivPtr] << (Shift >> 4);
_Timer[3].limit = 2048 - (Freq[3] & 0x7FF);//?
break;
case NR44:
if ((val & 0x40) >> 6) {
Trigger[3] = 1;
}
if (LengthEnable[3] == 0 && (val & 0x40) >> 6 && (step & 1) == 0) {
if (LengthCounter[3] != 0) {
LengthCounter[3]--;
if (LengthCounter[3] == 0 && (val & 0x80) == 0) {
Trigger[3] = 0;
}
}
}
//Reg[NR44 - 0xFF10] = val;
LengthEnable[3] = (val & 0x40) >> 6;
if ((val & 0x80) >> 7) {
Trigger[3] = 1;
if (LengthCounter[3] == 0) {
if ((step & 1) == 0 && LengthEnable[3]) {
LengthCounter[3] = 63;
}
else {
LengthCounter[3] = 64;
}
}
_Timer[3].limit = 2048 - (Freq[3] & 0x7FF);
_Timer[3].oldLimit = _Timer[3].limit;
_Timer[3].current = 0;
EnvTimer[2] = VolEnvPeriod[2];
EnvStop[2] = 0;
LFSR = 0xFF;
if (WidthMode)WidthModeOn = 1;
else WidthModeOn = 0;
VolOut[3] = VolSet[3];
Ptr[3] = 0;
if (DACEnable[3] == 0)Trigger[3] = 0;
}
break;
case NR50://for cartiage,in future.
//Reg[NR50 - 0xFF10] = val;
LVin = (val & 0xF0) >> 4;
RVin = val & 0xF;
break;
case NR51:
//Reg[NR51 - 0xFF10] = val;
Lopen = (val & 0xF0)>>4;
Ropen = val & 0xF;
break;
case NR52:
//Reg[NR52 - 0xFF10] = val;
if (val & 0x80) {
if (Power == 0) {
Power = 0x80;
PowerON();
}
}
else {
if (Power == 0x80) {
Power = 0;
PowerOFF();
}
}
break;
default:
Reg[ad - offset] = val;
}
}
else {
if (Trigger[2] == 0) {
PatternTable[ad - 0xFF30] = val;
}
else {
PatternTable[Ptr[2] >> 1] = val;
}
}
}
GB_BY APU::APURead(GB_DB ad) {
if (ad < 0xFF30) {
switch (ad) {
case NR10:
{
//GB_BY valOri = Reg[NR10 - 0xFF10] | 0x80;;
//GB_BY val2= (SweepPeriod << 4) | Negate | SweepShift | 0x80;
//if (valOri != val2) {
// int a=0;
// a++;//Dont go here.
//}
//return Reg[NR10 - 0xFF10] | 0x80;
return (SweepPeriod << 4) | Negate | SweepShift | 0x80;
}
break;
case NR11:
//return Reg[NR11 - 0xFF10] | 0x3F;
return (Duty[0] << 6) | 0x3F;
break;
case NR12:
//return Reg[NR12 - 0xFF10];
return (VolSet[0] << 4) | (VolEnvMode[0] << 3) | VolEnvPeriod[0];
break;
case NR14:
//return Reg[NR14 - 0xFF10] | 0xBF;
return (LengthEnable[0] << 6) | 0xBF;
break;
case NR21:
//return Reg[NR21 - 0xFF10] | 0x3F;
return (Duty[1] << 6) | 0x3F;
break;
case NR22:
//return Reg[NR22 - 0xFF10];
return (VolSet[1] << 4) | (VolEnvMode[1] << 3) | VolEnvPeriod[1];
break;
case NR24:
//return Reg[NR24 - 0xFF10] | 0xBF;
return (LengthEnable[1] << 6) | 0xBF;
break;
case NR30:
//return Reg[NR30 - 0xFF10] | 0x7F;
return (DACEnable[2] << 7) | 0x7F;
break;
case NR32:
//return Reg[NR32 - 0xFF10] | 0x9F;
return (VolSet[2] << 5) | 0x9F;
break;
case NR34:
//return Reg[NR34 - 0xFF10] | 0xBF;
return (LengthEnable[2] << 6) | 0xBF;
break;
case NR42:
//return Reg[NR42 - 0xFF10];
return (VolSet[3] << 4) | (VolEnvMode[2] << 3) | VolEnvPeriod[2];
break;
case NR43:
//return Reg[NR43 - 0xFF10];
return Shift | WidthMode | DivPtr;
break;
case NR44:
//return Reg[NR44 - 0xFF10]|0xBF;
return (LengthEnable[3] << 6) | 0xBF;
break;
case NR50:
//return Reg[NR50 - 0xFF10];
return (LVin << 4) | RVin;
break;
case NR51:
//return Reg[NR51 - 0xFF10];
return (Lopen << 4) | Ropen;
break;
case NR52:
//return Reg[NR52 - 0xFF10] | 0x70;
return Power | Trigger[0] | (Trigger[1] << 1) | (Trigger[2] << 2) | (Trigger[3] << 3)|0x70;
break;
default:
return 0xFF;
}
}
else {
if (Trigger[2] == 0) {
return PatternTable[ad - 0xFF30];
}
else
return PatternTable[Ptr[2] >> 1];
}
}
void APU::Init() {
for (int i = 0; i < 2; i++) {
_Timer[i].oldLimit=_Timer[i].limit = 2048<<2;
_Timer[i].current = 0;
DACEnable[i] = 0;
}
_Timer[2].oldLimit = _Timer[2].limit = 4;
_Timer[2].current =0;
DACEnable[2] = 0;
_Timer[3].oldLimit = _Timer[3].limit = 8;
_Timer[3].current = 0;
DACEnable[3] = 0;
//frame sequencer
step = 0;//or 7?
Ptr[0] = Ptr[1] = 7;
Ptr[2] = Ptr[3] = 0;
_Timer[4].current = 0;
_Timer[4].limit = SYS / 512;
Power = 0;
}
void APU::PowerON() {
for (int i = 0; i < 2; i++) {
_Timer[i].oldLimit=_Timer[i].limit = 2048 << 2;
_Timer[i].current = 0;
}
_Timer[2].oldLimit=_Timer[2].limit = 4;
_Timer[2].current = 0;
_Timer[3].oldLimit=_Timer[3].limit = 8;
_Timer[3].current = 0;
Ptr[0] = Ptr[1] = 7;
Ptr[2] = Ptr[3] = 0;
step = 7;
for (int i = 0; i < 4; i++) {
_Timer[i].current = _Timer[i].oldLimit;
}
}
void APU::PowerOFF() {
//all set to zero.
//for length counters:
// On CGB, length counters are reset when powered up.
// On DMG, they are unaffected, and not clocked.
for (int i = 0; i < 20; i++) {
Reg[i] = 0;
}
for (int i = 0; i < 4; i++) {
LengthLoad[i]=0;
//for DMG,comment it.
//LengthCounter[i]=0;
Trigger[i]=0;
LengthEnable[i]=0;
VolSet[i]=0;
VolOut[i]=0;
Freq[i]=0;
DACEnable[i]=0;
}
for (int i = 0; i < 3; i++) {
VolEnvPeriod[i]=0;
EnvTimer[i]=0;
EnvStop[i]=0;
VolEnvMode[i]=0;
}
Duty[0] = 0;
Duty[1] = 0;
SweepPeriod=0;
SweepTimer=0;
Negate=0;
SweepShift=0;
SweepEnable=0;
Shadow=0;
WidthMode=0;
WidthModeOn=0;//?
LFSR=0xFF;
Shift=0;
DivPtr=0;
Lopen=Ropen=0;
LVin=RVin=0;
outputL=0;
outputR=0;
SampleBuffer=0;
}
void APU::SendClock(GB_BY delta) {
if (DACEnable[0] == 1) {//well,i think it doesn't matter,but it will save some cpu cycles...
_Timer[0].current += delta;
while (_Timer[0].current >= _Timer[0].oldLimit) {
_Timer[0].current -= _Timer[0].oldLimit;
_Timer[0].oldLimit = _Timer[0].limit;
Square1();
}
}
if (DACEnable[1] == 1) {
_Timer[1].current += delta;
while (_Timer[1].current >= _Timer[1].oldLimit) {
_Timer[1].current -= _Timer[1].oldLimit;
_Timer[1].oldLimit = _Timer[1].limit;
Square2();
}
}
if (DACEnable[2]) {//must always counting when powered?
_Timer[2].current += delta;
while (_Timer[2].current >= _Timer[2].oldLimit) {
_Timer[2].current -= _Timer[2].oldLimit;
_Timer[2].oldLimit = _Timer[2].limit;
Wave();
}
}
if (DACEnable[3] == 1) {
_Timer[3].current += delta;
while (_Timer[3].current >= _Timer[3].oldLimit) {
_Timer[3].current -= _Timer[3].oldLimit;
_Timer[3].oldLimit = _Timer[3].limit;
Noise();
}
}
_Timer[4].current += delta;
if (_Timer[4].current >= _Timer[4].limit) {
_Timer[4].current -= _Timer[4].limit;
Sequence();
}
}
void APU::Sequence() {
step++;
if (step == 8) {
step = 0;
}
if (Power) {
if ((step & 0x1)==0) {
if(Power)//DMG.
LengthCtr();
}
if (step == 7) {
if(Power)
VolEnv();
}
if (step == 2 || step == 6) {
if(SweepTimer!=0)
SweepTimer--;
if (SweepTimer == 0) {
if (SweepPeriod != 0) {
SweepTimer = SweepPeriod;
}
else {
SweepTimer = 8;//0 will be treated as 8,same as envlope timers.
}
if (SweepEnable &&SweepPeriod!=0)
Sweep();
}
}
}
}
inline void APU::LengthCtr() {//disabled channel should still clock length.
for (int i = 0; i < 4; i++) {
if (LengthEnable[i]) {
if (LengthCounter[i] != 0)
LengthCounter[i]--;
if (LengthCounter[i] == 0) {
Trigger[i] = 0;
}
}
}
}
inline void APU::VolEnv() {
if (EnvStop[0] == 0 && VolEnvPeriod[0] != 0) {
EnvTimer[0]--;
if (EnvTimer[0] == 0) {
if (VolEnvPeriod[0] != 0) {
EnvTimer[0] = VolEnvPeriod[0];
}
else {
EnvTimer[0] = 8;
}
if (VolEnvMode[0] == 0) {
if (VolOut[0] != 0)
VolOut[0]--;
else {
EnvStop[0] = 1;
DACEnable[0] = 0;
}
}
else {
if (VolOut[0] != 15)
VolOut[0]++;
else
EnvStop[0] = 1;
}
}
}
if (EnvStop[1] == 0&& VolEnvPeriod[1] != 0) {
EnvTimer[1]--;
if (EnvTimer[1] == 0) {
if (VolEnvPeriod[1] != 0) {
EnvTimer[1] = VolEnvPeriod[1];
}
else {
EnvTimer[1] = 8;
}
if (VolEnvMode[1] == 0) {
if (VolOut[1] != 0)
VolOut[1]--;
else {
EnvStop[1] = 1;
DACEnable[1] = 0;
}
}
else {
if (VolOut[1] != 15)
VolOut[1]++;
else
EnvStop[1] = 1;
}
}
}
if (EnvStop[2] == 0 && VolEnvPeriod[2] != 0) {
EnvTimer[2]--;
if (EnvTimer[2] == 0) {
if (VolEnvPeriod[2] != 0) {
EnvTimer[2] = VolEnvPeriod[2];
}
else {
EnvTimer[2] = 8;
}
if (VolEnvMode[2] == 0) {
if (VolOut[3] != 0)
VolOut[3]--;
else {
EnvStop[2] = 1;
DACEnable[3] = 0;
}
}
else {
if (VolOut[3] != 15)
VolOut[3]++;
else
EnvStop[2] = 1;
}
}
}
}
inline void APU::Sweep() {
if (Negate) {
GB_DB newFreq = Shadow - (Shadow >> SweepShift);
Negated = 1;
if (newFreq < 2048) {
if (SweepShift != 0) {
Freq[0] = newFreq;
Shadow = Freq[0];
if (Shadow - (Shadow >> SweepShift) > 2047) {
SweepEnable = 0;
Trigger[0] = 0;
}
else {
_Timer[0].limit = (2048 - (Freq[0]&0x7FF)) << 2;
}
}
}else {
SweepEnable = 0;
Trigger[0] = 0;
}
}
else {
GB_DB newFreq = Shadow + (Shadow >> SweepShift);
if (newFreq < 2048) {
if (SweepShift != 0) {
Freq[0] = newFreq;
Shadow = Freq[0];
if (Shadow + (Shadow >> SweepShift) > 2047) {
SweepEnable = 0;
Trigger[0] = 0;
}
else {
_Timer[0].limit = (2048 - (Freq[0]&0x7FF)) << 2;
}
}
}else {
SweepEnable = 0;
Trigger[0] = 0;
}
}
}
//its a little too bruce to even simulate the waves,a better way
//is just sending commands directly to soundhardware,but its more
//diffcult actually.
inline void APU::Square1() {
Ptr[0]++;
if (Ptr[0] == 8)Ptr[0] = 0;
Output[0] = WaveTable[Duty[0]][Ptr[0]]*VolOut[0];
}
inline void APU::Square2() {
Ptr[1]++;
if (Ptr[1] == 8)Ptr[1] = 0;
Output[1] = WaveTable[Duty[1]][Ptr[1]]*VolOut[1];
}
/*
inline void APU::Wave() {
//yes,it is.
Ptr[2]++;
if (Ptr[2] == 32)Ptr[2] = 0;
if ((Ptr[2] % 2)==1) {
SampleBuffer = PatternTable[Ptr[2]>>1]&0xF;
}
else {
SampleBuffer = PatternTable[Ptr[2]>>1]>>4;
}
Output[2] = SampleBuffer >> WaveVol[VolOut[2]];
}*/
inline void APU::Wave() {
//yes,it is.
if (justTriggered) {
Output[2] = ((SampleBuffer >> 4) & 0xF)>> WaveVol[VolOut[2]];
justTriggered = 0;
}
else {
GB_BY Loc = Ptr[2] >> 1;
SampleBuffer = PatternTable[Loc];
if (Loc & 1) {
Output[2] = SampleBuffer & 0xF;
}
else {
Output[2] = SampleBuffer >> 4;
}
Output[2] >>= WaveVol[VolOut[2]];
}
Ptr[2]++;
if (Ptr[2] == 32)Ptr[2] = 0;
}
inline void APU::Noise() {
if (Shift > 13) {
Output[3] = ((LFSR & 0x1) == 1) ? 0 : VolOut[3];
}
else {
GB_DB re = ((LFSR & 0x1) ^ ((LFSR >> 1) & 0x1));
if (WidthModeOn) {
LFSR >>= 1;
LFSR |= re << 6;
}
else {
LFSR >>= 1;
LFSR |= re << 15;
}
Output[3] = ((LFSR & 0x1) == 1) ? 0 : VolOut[3];
}
}
| 22.778986
| 139
| 0.503632
|
mmmaolololo
|
7dc7285309d6aa25f456f4ae5d5aa85cd52825a1
| 214
|
hpp
|
C++
|
libstdcxx/compare.hpp
|
F4doraOfDoom/juos
|
cdec685701c406defc9204dcadf154df9eefc879
|
[
"MIT"
] | 3
|
2020-12-22T01:24:56.000Z
|
2021-01-06T11:44:50.000Z
|
libstdcxx/compare.hpp
|
F4doraOfDoom/juos
|
cdec685701c406defc9204dcadf154df9eefc879
|
[
"MIT"
] | null | null | null |
libstdcxx/compare.hpp
|
F4doraOfDoom/juos
|
cdec685701c406defc9204dcadf154df9eefc879
|
[
"MIT"
] | null | null | null |
#ifndef _LIBCXX_COMPARE_H
#define _LIBCXX_COMPARE_H
template <class T>
struct Less
{
bool operator()(const T& x, const T& y) const
{
return x < y;
}
typedef bool result_type;
};
#endif // _LIBCXX_COMPARE_H
| 14.266667
| 46
| 0.714953
|
F4doraOfDoom
|
7dc7b5f5217df8dc038fddd08964b198182da414
| 638
|
cpp
|
C++
|
world/tiles/source/DownStaircaseTile.cpp
|
sidav/shadow-of-the-wyrm
|
747afdeebed885b1a4f7ab42f04f9f756afd3e52
|
[
"MIT"
] | 60
|
2019-08-21T04:08:41.000Z
|
2022-03-10T13:48:04.000Z
|
world/tiles/source/DownStaircaseTile.cpp
|
cleancoindev/shadow-of-the-wyrm
|
51b23e98285ecb8336324bfd41ebf00f67b30389
|
[
"MIT"
] | 3
|
2021-03-18T15:11:14.000Z
|
2021-10-20T12:13:07.000Z
|
world/tiles/source/DownStaircaseTile.cpp
|
cleancoindev/shadow-of-the-wyrm
|
51b23e98285ecb8336324bfd41ebf00f67b30389
|
[
"MIT"
] | 8
|
2019-11-16T06:29:05.000Z
|
2022-01-23T17:33:43.000Z
|
#include "DownStaircaseTile.hpp"
TileType DownStaircaseTile::get_tile_type() const
{
return TileType::TILE_TYPE_DOWN_STAIRCASE;
}
StaircaseType DownStaircaseTile::get_staircase_type() const
{
return StaircaseType::STAIRCASE_DOWN;
}
std::string DownStaircaseTile::get_tile_description_sid() const
{
return TileTextKeys::TILE_DESC_DOWN_STAIRCASE;
}
Tile* DownStaircaseTile::clone()
{
return new DownStaircaseTile(*this);
}
ClassIdentifier DownStaircaseTile::internal_class_identifier() const
{
return ClassIdentifier::CLASS_ID_DOWN_STAIRCASE_TILE;
}
#ifdef UNIT_TESTS
#include "unit_tests/DownStaircaseTile_test.cpp"
#endif
| 20.580645
| 68
| 0.815047
|
sidav
|
7dc86d0384eed19d693f75c4f6528637eefbca70
| 1,792
|
cc
|
C++
|
pagespeed/controller/expensive_operation_rpc_handler.cc
|
dimitrilongo/mod_pagespeed
|
d0d3bc51aa4feddf010b7085872c64cc46b5aae0
|
[
"Apache-2.0"
] | 2
|
2019-11-02T07:54:17.000Z
|
2020-04-16T09:26:51.000Z
|
pagespeed/controller/expensive_operation_rpc_handler.cc
|
dimitrilongo/mod_pagespeed
|
d0d3bc51aa4feddf010b7085872c64cc46b5aae0
|
[
"Apache-2.0"
] | 12
|
2017-03-14T18:26:11.000Z
|
2021-10-01T15:33:50.000Z
|
pagespeed/controller/expensive_operation_rpc_handler.cc
|
dimitrilongo/mod_pagespeed
|
d0d3bc51aa4feddf010b7085872c64cc46b5aae0
|
[
"Apache-2.0"
] | 1
|
2020-04-16T09:28:30.000Z
|
2020-04-16T09:28:30.000Z
|
// Copyright 2016 Google Inc.
//
// 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: cheesy@google.com (Steve Hill)
#include "pagespeed/controller/expensive_operation_rpc_handler.h"
namespace net_instaweb {
ExpensiveOperationRpcHandler::ExpensiveOperationRpcHandler(
grpc::CentralControllerRpcService::AsyncService* service,
::grpc::ServerCompletionQueue* cq, ExpensiveOperationController* controller)
: RequestResultRpcHandler(service, cq, controller) {}
void ExpensiveOperationRpcHandler::HandleClientRequest(
const ScheduleExpensiveOperationRequest& req, Function* callback) {
controller()->ScheduleExpensiveOperation(callback);
}
void ExpensiveOperationRpcHandler::HandleClientResult(
const ScheduleExpensiveOperationRequest& req) {
controller()->NotifyExpensiveOperationComplete();
}
void ExpensiveOperationRpcHandler::HandleOperationFailed() {
controller()->NotifyExpensiveOperationComplete();
}
void ExpensiveOperationRpcHandler::InitResponder(
grpc::CentralControllerRpcService::AsyncService* service,
::grpc::ServerContext* ctx, ReaderWriterT* responder,
::grpc::ServerCompletionQueue* cq, void* callback) {
service->RequestScheduleExpensiveOperation(ctx, responder, cq, cq, callback);
}
} // namespace net_instaweb
| 37.333333
| 80
| 0.781808
|
dimitrilongo
|
7dcd607ad8eaa0650739dcc8f7053a959dab4eb1
| 2,034
|
cpp
|
C++
|
Miscellaneous/tree_traversals.cpp
|
Alecs-Li/Competitive-Programming
|
39941ff8e2c8994abbae8c96a1ed0a04b10058b8
|
[
"MIT"
] | 1
|
2021-07-06T02:14:03.000Z
|
2021-07-06T02:14:03.000Z
|
Miscellaneous/tree_traversals.cpp
|
Alex01890-creator/competitive-programming
|
39941ff8e2c8994abbae8c96a1ed0a04b10058b8
|
[
"MIT"
] | null | null | null |
Miscellaneous/tree_traversals.cpp
|
Alex01890-creator/competitive-programming
|
39941ff8e2c8994abbae8c96a1ed0a04b10058b8
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
struct Node {
int key;
struct Node *left, *right;
Node(int key)
{
this->key = key;
left = right = NULL;
}
};
void inorder(struct Node* node){
if(node == NULL){
return;
}
inorder(node->left);
cout << node->key << " ";
inorder(node->right);
}
void preorder(struct Node* node){
if(node == NULL){
return;
}
cout << node->key << " ";
preorder(node->left);
preorder(node->right);
}
void postorder(struct Node* node){
if(node == NULL){
return;
}
postorder(node->left);
postorder(node->right);
cout << node->key << " ";
}
int n;
vector<int> key, l, r;
struct Node* root;
void makeLTree(struct Node* node, int count){
if(count == 0){
node->left = new Node(key[l[count]]);
if(l[l[count]] != -1){
makeLTree(node->left, l[count]);
} else {
return;
}
}
if(l[count] != -1){
node->left = new Node(key[l[count]]);
}
if(r[count] != -1){
node->right = new Node(key[r[count]]);
}
if(l[l[count]] != -1){
makeLTree(node->left, l[count]);
} else if (r[r[count]] != -1){
makeLTree(node->right, r[count]);
}
return;
}
void makeRTree(struct Node* node, int count){
if(count == 0){
node->right = new Node(key[r[count]]);
if(r[r[count]] != -1){
makeRTree(node->right, r[count]);
} else {
return;
}
}
if(l[count] != -1){
node->left = new Node(key[l[count]]);
}
if(r[count] != -1){
node->right = new Node(key[r[count]]);
}
if(r[r[count]] != -1){
makeRTree(node->right, r[count]);
} else if(l[l[count]] != -1){
makeRTree(node->left, l[count]);
}
return;
}
int main(){
cin >> n;
key.resize(n);
l.resize(n);
r.resize(n);
for (int a=0; a<n; a++) {
cin >> key[a] >> l[a] >> r[a];
}
struct Node* root = new Node(key[0]);
makeLTree(root, 0);
makeRTree(root, 0);
inorder(root);
cout << "\n";
preorder(root);
cout << "\n";
postorder(root);
}
| 17.384615
| 45
| 0.536382
|
Alecs-Li
|
7dce406ca670c41748a5a7137d3b860a57c83289
| 434
|
cpp
|
C++
|
Problem Solving/1. Simple Array Sum.cpp
|
ManthanUgemuge/Hackerrank
|
9fccbf0164c2d33f3493b470c3fbef6edc2fcde1
|
[
"MIT"
] | null | null | null |
Problem Solving/1. Simple Array Sum.cpp
|
ManthanUgemuge/Hackerrank
|
9fccbf0164c2d33f3493b470c3fbef6edc2fcde1
|
[
"MIT"
] | null | null | null |
Problem Solving/1. Simple Array Sum.cpp
|
ManthanUgemuge/Hackerrank
|
9fccbf0164c2d33f3493b470c3fbef6edc2fcde1
|
[
"MIT"
] | null | null | null |
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int numLines;
int currNumber, total = 0;
cin >> numLines;
for (int i=0; i<numLines;i++) {
cin >> currNumber;
total += currNumber;
}
cout << total;
return 0;
}
| 17.36
| 80
| 0.576037
|
ManthanUgemuge
|
7dd30bac0d00404a0609d9c4f66884875c602b1c
| 1,645
|
cpp
|
C++
|
thirdparty/sfs2x/Bitswarm/PendingPacket.cpp
|
godot-addons/godot-sfs2x
|
a8d52aa9d548f6d45bbb64bfdaacab0df10e67c1
|
[
"MIT"
] | 2
|
2020-05-14T07:48:32.000Z
|
2021-02-03T14:58:11.000Z
|
thirdparty/sfs2x/Bitswarm/PendingPacket.cpp
|
godot-addons/godot-sfs2x
|
a8d52aa9d548f6d45bbb64bfdaacab0df10e67c1
|
[
"MIT"
] | 1
|
2020-05-28T16:39:20.000Z
|
2020-05-28T16:39:20.000Z
|
thirdparty/sfs2x/Bitswarm/PendingPacket.cpp
|
godot-addons/godot-sfs2x
|
a8d52aa9d548f6d45bbb64bfdaacab0df10e67c1
|
[
"MIT"
] | 2
|
2018-07-07T20:15:00.000Z
|
2018-10-26T05:18:30.000Z
|
// ===================================================================
//
// Description
// Contains the implementation of PendingPacket
//
// Revision history
// Date Description
// 30-Nov-2012 First version
//
// ===================================================================
#include "PendingPacket.h"
namespace Sfs2X {
namespace Bitswarm {
// -------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------
PendingPacket::PendingPacket(boost::shared_ptr<PacketHeader> header)
{
this->header = header;
buffer = boost::shared_ptr<ByteArray>(new ByteArray());
buffer->Compressed(header->Compressed());
}
// -------------------------------------------------------------------
// Destructor
// -------------------------------------------------------------------
PendingPacket::~PendingPacket()
{
}
// -------------------------------------------------------------------
// Header
// -------------------------------------------------------------------
boost::shared_ptr<PacketHeader> PendingPacket::Header()
{
return header;
}
// -------------------------------------------------------------------
// Buffer
// -------------------------------------------------------------------
boost::shared_ptr<ByteArray> PendingPacket::Buffer()
{
return buffer;
}
// -------------------------------------------------------------------
// Buffer
// -------------------------------------------------------------------
void PendingPacket::Buffer(boost::shared_ptr<ByteArray> value)
{
buffer = value;
}
} // namespace Bitswarm
} // namespace Sfs2X
| 27.881356
| 70
| 0.349544
|
godot-addons
|
7dd622328054eb24b4160a5d08cb31fbd06a7448
| 593
|
cpp
|
C++
|
FickleManette/FickleManette/WindowLoop.cpp
|
nicolasgustafsson/FickleManette
|
9d5d5b58932a5a25b750432156c3acfb22f74d1e
|
[
"MIT"
] | null | null | null |
FickleManette/FickleManette/WindowLoop.cpp
|
nicolasgustafsson/FickleManette
|
9d5d5b58932a5a25b750432156c3acfb22f74d1e
|
[
"MIT"
] | null | null | null |
FickleManette/FickleManette/WindowLoop.cpp
|
nicolasgustafsson/FickleManette
|
9d5d5b58932a5a25b750432156c3acfb22f74d1e
|
[
"MIT"
] | null | null | null |
#include "stdafx.h"
#include "WindowLoop.h"
WindowLoop::WindowLoop()
{
}
WindowLoop::~WindowLoop()
{
}
void WindowLoop::StartLoop()
{
sf::View view(sf::Vector2f(0.0f, 0.0f), sf::Vector2f(1920.f, 1080.f));
sf::RenderWindow window(sf::VideoMode(1280, 720), "Fickle Manette");
window.setView(view);
Drawer drawer(window);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear(sf::Color(101, 156, 239));
myGame.Update();
myGame.Draw(drawer);
window.display();
}
}
| 14.463415
| 71
| 0.647555
|
nicolasgustafsson
|
7dde048bfd615e1eacdb19a34352afc9d050b400
| 130
|
cpp
|
C++
|
test/custom_builds/cpp/rest/src/main.cpp
|
teh-cmc/flecs
|
ef6c366bae1142fa501d505ccb28d3e23d27ebc2
|
[
"MIT"
] | 18
|
2021-09-17T16:41:14.000Z
|
2022-02-01T15:22:20.000Z
|
test/custom_builds/cpp/rest/src/main.cpp
|
teh-cmc/flecs
|
ef6c366bae1142fa501d505ccb28d3e23d27ebc2
|
[
"MIT"
] | 36
|
2021-09-21T10:22:16.000Z
|
2022-01-22T10:25:11.000Z
|
test/custom_builds/cpp/rest/src/main.cpp
|
teh-cmc/flecs
|
ef6c366bae1142fa501d505ccb28d3e23d27ebc2
|
[
"MIT"
] | 6
|
2021-09-26T11:06:32.000Z
|
2022-01-21T15:07:05.000Z
|
#include <rest.h>
#include <iostream>
int main(int, char *[]) {
flecs::world world;
world.set<flecs::rest::Rest>({});
}
| 14.444444
| 37
| 0.592308
|
teh-cmc
|
7de6782886f8356a0906a37b47a5b1ab7d57d9cf
| 728
|
cpp
|
C++
|
src/Application.cpp
|
kernelguy/HelloWorld
|
da2d2c3e17074f661c6ea5abac58d7d37efb98dc
|
[
"Zlib"
] | null | null | null |
src/Application.cpp
|
kernelguy/HelloWorld
|
da2d2c3e17074f661c6ea5abac58d7d37efb98dc
|
[
"Zlib"
] | null | null | null |
src/Application.cpp
|
kernelguy/HelloWorld
|
da2d2c3e17074f661c6ea5abac58d7d37efb98dc
|
[
"Zlib"
] | null | null | null |
/*
* Application.cpp
*
* Created on: 20. aug. 2017
* Author: steffen
*/
#include <iostream>
#include "Application.h"
#include "contracts/ITranslations.h"
#include "ioc/IOC.h"
Application* Application::mpInstance = 0;
Contracts::IApplication& Contracts::IApplication::instance()
{
return *Application::mpInstance;
}
Application::Application()
{
mpInstance = this;
}
Application::~Application()
{
mpInstance = 0;
}
Contracts::IIOC& Application::Ioc()
{
static IOC ioc;
return ioc;
}
int Application::Run()
{
LOG_DEBUG("Running...");
auto translations = Ioc()->resolve< Contracts::ITranslations >();
std::cout << translations->GetText("Hello\nWorld!") << std::endl; // prints Hello\nWorld!
return 0;
}
| 16.177778
| 90
| 0.68544
|
kernelguy
|
8fbd20e193a49576cbcda233c81171730253139d
| 9,205
|
cpp
|
C++
|
Source/BossBattle/Characters/PlayerCharacter.cpp
|
mikirov/Unreal-RL
|
c99ec740c7ef4fd2088c9208b3ac82f3dc65e593
|
[
"Apache-2.0"
] | 1
|
2020-06-11T13:19:21.000Z
|
2020-06-11T13:19:21.000Z
|
Source/BossBattle/Characters/PlayerCharacter.cpp
|
mikirov/Unreal-RL
|
c99ec740c7ef4fd2088c9208b3ac82f3dc65e593
|
[
"Apache-2.0"
] | null | null | null |
Source/BossBattle/Characters/PlayerCharacter.cpp
|
mikirov/Unreal-RL
|
c99ec740c7ef4fd2088c9208b3ac82f3dc65e593
|
[
"Apache-2.0"
] | null | null | null |
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "PlayerCharacter.h"
#include "HeadMountedDisplayFunctionLibrary.h"
#include "Camera/CameraComponent.h"
#include "Components/CapsuleComponent.h"
#include "Components/InputComponent.h"
#include "Components/SceneComponent.h"
#include "Components/ArrowComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "GameFramework/Controller.h"
#include "GameFramework/SpringArmComponent.h"
#include "Kismet/GameplayStatics.h"
#include "Kismet/KismetMathLibrary.h"
#include "Engine/World.h"
#include "Components/CapsuleComponent.h"
#include "GameFramework/PlayerController.h"
#include "GameFramework/Character.h"
#include "DrawDebugHelpers.h"
#include "TimerManager.h"
#include "Blueprint/WidgetBlueprintLibrary.h"
#include "UI/BattleHUD.h"
#include "UI/ChatWidget.h"
#include "GameModes/BossBattleGameMode.h"
#include "GameModes/PlayingGameMode.h"
#include "UI/PlayerStatsWidget.h"
#include "Characters/PlayerCharacterController.h"
#include "Characters/AIEnemyCharacter.h"
#include "Characters/HealthComponent.h"
#include "Utilities/InputType.h"
#include "Utilities/CustomMacros.h"
#include "Weapons/Gun.h"
#include "Components/EditableTextBox.h"
#include "Components/WidgetComponent.h"
#include "Components/SkeletalMeshComponent.h"
#include "Animation/CharacterAnimInstance.h"
APlayerCharacter::APlayerCharacter()
{
// Set size for collision capsule
UCapsuleComponent* Capsule;
Capsule = GetCapsuleComponent();
if (validate(IsValid(Capsule))) {
//change if you change the mesh
Capsule->InitCapsuleSize(42.f, 96.0f);
}
RotationArrow = CreateDefaultSubobject<UArrowComponent>(TEXT("ArrowComponent"));
RotationArrow->SetupAttachment(Capsule);
// set our turn rates for input
// Don't rotate when the controller rotates. Let that just affect the camera.
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = true;
bUseControllerRotationRoll = false;
// Create a spring arm (pulls in towards the player if there is a collision)
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArm"));
SpringArm->SetupAttachment(RootComponent);
SpringArm->TargetArmLength = 500.0f; // The camera follows at this distance behind the character
SpringArm->bUsePawnControlRotation = true; // Rotate the arm based on the controller
// Create a follow camera
TPCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("TPCamera"));
TPCamera->SetupAttachment(SpringArm, USpringArmComponent::SocketName);
TPCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
TPCamera->SetActive(true);
// Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character)
// are set in the derived blueprint asset named MyCharacter (to avoid direct content references in C++)
// Initialise the can crouch property
GetCharacterMovement()->GetNavAgentPropertiesRef().bCanCrouch = true;
}
void APlayerCharacter::SetChat(class UChatWidget* ChatWidgetToSet) {
ChatWidget = ChatWidgetToSet;
}
AGun* APlayerCharacter::GetGun()
{
return Gun;
}
void APlayerCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
{
if (validate(IsValid(PlayerInputComponent)) == false) return;
Super::SetupPlayerInputComponent(PlayerInputComponent);
// Set up gameplay key bindings
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);
PlayerInputComponent->BindAxis("MoveForward", this, &APlayerCharacter::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &APlayerCharacter::MoveRight);
// We have 2 versions of the rotation bindings to handle different kinds of devices differently
// "turn" handles devices that provide an absolute delta, such as a mouse.
// "turnrate" is for devices that we choose to treat as a rate of change, such as an analog joystick
PlayerInputComponent->BindAxis("Turn", this, &ACharacter::AddControllerYawInput);
PlayerInputComponent->BindAxis("TurnRate", this, &APlayerCharacter::TurnAtRate);
PlayerInputComponent->BindAxis("LookUp", this, &ACharacter::AddControllerPitchInput);
PlayerInputComponent->BindAxis("LookUpRate", this, &APlayerCharacter::LookUpAtRate);
PlayerInputComponent->BindAction("Interact", IE_Pressed, this, &APlayerCharacter::ServerInteractWithWeapon);
PlayerInputComponent->BindAction("Reload", IE_Pressed, this, &APlayerCharacter::ServerStartReloading);
PlayerInputComponent->BindAction("Fire", IE_Pressed, this, &APlayerCharacter::ServerStartFiring);
PlayerInputComponent->BindAction("Fire", IE_Released, this, &APlayerCharacter::ServerStopFiring);
PlayerInputComponent->BindAction("OpenChat", IE_Pressed, this, &APlayerCharacter::OpenChat);
PlayerInputComponent->BindAction("Crouch", IE_Pressed, this, &APlayerCharacter::ServerStartCrouching);
PlayerInputComponent->BindAction("Crouch", IE_Released, this, &APlayerCharacter::ServerStopCrouching);
PlayerInputComponent->BindAction("Close", IE_Pressed, this, &APlayerCharacter::Close);
}
void APlayerCharacter::OpenChat() {
UE_LOG(LogTemp, Warning, TEXT("APlayerCharacter::OpenChat"))
if (validate(IsValid(ChatWidget)) == false) return;
ChatWidget->Open();
}
void APlayerCharacter::Close()
{
UE_LOG(LogTemp, Warning, TEXT(" APlayerCharacter::Close()"))
UGameplayStatics::OpenLevel(GetWorld(), "MainMenu");
}
void APlayerCharacter::BeginPlay()
{
Super::BeginPlay();
if (validate(IsValid(HealthComponent))) {
HealthComponent->OnHealthChanged.AddDynamic(this, &APlayerCharacter::OnHealthChanged);
}
}
void APlayerCharacter::Die()
{
Super::Die();
if (IsLocallyControlled()) {
APlayerCharacterController* PlayerController = Cast<APlayerCharacterController>(GetController());
if (validate(IsValid(PlayerController)) == false) { return; }
DisableInput(PlayerController);
}
UWorld* World = GetWorld();
if (validate(IsValid(World)) == false) return;
APlayingGameMode* PlayingGameMode = Cast<APlayingGameMode>(World->GetAuthGameMode());
if (validate(IsValid(PlayingGameMode)) == false) { return; }
APlayerCharacterController* PlayerController = Cast<APlayerCharacterController>(GetController());
if (validate(IsValid(PlayerController)) == false) { return; }
PlayingGameMode->OnPlayerDeath(PlayerController);
}
void APlayerCharacter::OnHealthChanged(float Value)
{
APlayerCharacterController* PlayerController = Cast<APlayerCharacterController>(GetController());
if (validate(IsValid(PlayerController)) == false) return;
ABattleHUD* HUD = Cast<ABattleHUD>(PlayerController->GetHUD());
if (validate(IsValid(HUD)) == false) return;
UPlayerStatsWidget* PlayerStatsWidget = HUD->GetPlayerStatsWidget();
if (validate(IsValid(PlayerStatsWidget)) == false) return;
float Percent = Value / HealthComponent->GetMaxHealth();
UE_LOG(LogTemp, Warning, TEXT("APlayerCharacter::OnHealthChanged(float Value): %f"), Percent);
PlayerStatsWidget->SetHealth(Percent);
}
void APlayerCharacter::OnDeathAnimationEnd()
{
APlayerCharacterController* PlayerController = Cast<APlayerCharacterController>(GetController());
if (validate(IsValid(PlayerController)) == false) return;
PlayerController->OnLoseGame();
Super::OnDeathAnimationEnd();
}
void APlayerCharacter::PickGun(AGun* NewGun)
{
Super::PickGun(NewGun);
NewGun->OnFire.AddDynamic(this, &APlayerCharacter::PlayCameraShake);
}
void APlayerCharacter::PlayCameraShake() {
APlayerController* PlayerController = Cast<APlayerController>(GetController());
if (validate(IsValid(PlayerController)) == false) { return; }
if (validate(IsValid(Gun)) == false) { return; }
TSubclassOf<UCameraShake> GunfireCameraShake = Gun->GetGunfireCameraShake();
if (validate(IsValid(GunfireCameraShake)) == false) { return; }
PlayerController->PlayerCameraManager->PlayCameraShake(
GunfireCameraShake, 1, ECameraAnimPlaySpace::UserDefined, GetControlRotation()
);
}
void APlayerCharacter::TurnAtRate(float Rate)
{
// calculate delta for this frame from the rate information
AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds());
}
void APlayerCharacter::LookUpAtRate(float Rate)
{
// calculate delta for this frame from the rate information
AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());
}
void APlayerCharacter::MoveForward(float Value)
{
if ((Controller != NULL) && (Value != 0.0f))
{
// find out which way is forward
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
// get forward vector
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
AddMovementInput(Direction, Value);
}
}
void APlayerCharacter::MoveRight(float Value)
{
if ( (Controller != NULL) && (Value != 0.0f) )
{
// find out which way is right
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
// get right vector
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
// add movement in that direction
AddMovementInput(Direction, Value);
}
}
| 34.219331
| 109
| 0.777838
|
mikirov
|
8fbee5e822b65fd36154fcb833f4839b3c5c0de1
| 107
|
cpp
|
C++
|
tests/TableEditorGlIssue4/libs/TableEditorHelpers/src/TableEditorHelpers.cpp
|
scandyna/mdt-cmake-modules
|
a6c4ad1ff5ce258ca2fb2bc4fe2875ba8fae1c03
|
[
"BSD-3-Clause"
] | null | null | null |
tests/TableEditorGlIssue4/libs/TableEditorHelpers/src/TableEditorHelpers.cpp
|
scandyna/mdt-cmake-modules
|
a6c4ad1ff5ce258ca2fb2bc4fe2875ba8fae1c03
|
[
"BSD-3-Clause"
] | null | null | null |
tests/TableEditorGlIssue4/libs/TableEditorHelpers/src/TableEditorHelpers.cpp
|
scandyna/mdt-cmake-modules
|
a6c4ad1ff5ce258ca2fb2bc4fe2875ba8fae1c03
|
[
"BSD-3-Clause"
] | null | null | null |
#include "TableEditorHelpers.h"
void TableEditorHelpers::setupSorting()
{
mSetupWidget.setup(mModel);
}
| 15.285714
| 39
| 0.775701
|
scandyna
|
8fc0a904c2cb3123842fe916263c79b614f91dd8
| 2,947
|
cpp
|
C++
|
Source/Core/Serialization/SerializeBase.cpp
|
frobro98/Musa
|
6e7dcd5d828ca123ce8f43d531948a6486428a3d
|
[
"MIT"
] | null | null | null |
Source/Core/Serialization/SerializeBase.cpp
|
frobro98/Musa
|
6e7dcd5d828ca123ce8f43d531948a6486428a3d
|
[
"MIT"
] | null | null | null |
Source/Core/Serialization/SerializeBase.cpp
|
frobro98/Musa
|
6e7dcd5d828ca123ce8f43d531948a6486428a3d
|
[
"MIT"
] | null | null | null |
// Copyright 2020, Nathan Blane
#include "SerializeBase.hpp"
#include "Debugging/Assertion.hpp"
void Serialize(SerializeBase & ser, tchar c)
{
ser.SerializeData(&c, sizeof(tchar));
}
void Serialize(SerializeBase& ser, u8 u)
{
ser.SerializeData(&u, sizeof(u8));
}
void Serialize(SerializeBase& ser, i8 i)
{
ser.SerializeData(&i, sizeof(i8));
}
void Serialize(SerializeBase& ser, u16 u)
{
ser.SerializeData(&u, sizeof(u16));
}
void Serialize(SerializeBase& ser, i16 i)
{
ser.SerializeData(&i, sizeof(i16));
}
void Serialize(SerializeBase& ser, u32 u)
{
ser.SerializeData(&u, sizeof(u32));
}
void Serialize(SerializeBase& ser, i32 i)
{
ser.SerializeData(&i, sizeof(i32));
}
void Serialize(SerializeBase& ser, u64 u)
{
ser.SerializeData(&u, sizeof(u64));
}
void Serialize(SerializeBase& ser, i64 i)
{
ser.SerializeData(&i, sizeof(i64));
}
void Serialize(SerializeBase& ser, float f)
{
ser.SerializeData(&f, sizeof(float));
}
void Serialize(SerializeBase& ser, double d)
{
ser.SerializeData(&d, sizeof(double));
}
void Serialize(SerializeBase& ser, const tchar* c, size_t size)
{
Assert(c != nullptr);
ser.SerializeData(&size, sizeof(size_t));
ser.SerializeData(c, size);
}
void Serialize(SerializeBase& ser, const u8* u, size_t size)
{
Assert(u != nullptr);
ser.SerializeData(&size, sizeof(size_t));
ser.SerializeData(u, size);
}
void Serialize(SerializeBase& ser, const i8* i, size_t size)
{
Assert(i != nullptr);
ser.SerializeData(&size, sizeof(size_t));
ser.SerializeData(i, size);
}
void Serialize(SerializeBase& ser, const u16* u, size_t size)
{
Assert(u != nullptr);
ser.SerializeData(&size, sizeof(size_t));
ser.SerializeData(u, size);
}
void Serialize(SerializeBase& ser, const i16* i, size_t size)
{
Assert(i != nullptr);
ser.SerializeData(&size, sizeof(size_t));
ser.SerializeData(i, size);
}
void Serialize(SerializeBase& ser, const u32* u, size_t size)
{
Assert(u != nullptr);
ser.SerializeData(&size, sizeof(size_t));
ser.SerializeData(u, size);
}
void Serialize(SerializeBase& ser, const i32* i, size_t size)
{
Assert(i != nullptr);
ser.SerializeData(&size, sizeof(size_t));
ser.SerializeData(i, size);
}
void Serialize(SerializeBase& ser, const u64* u, size_t size)
{
Assert(u != nullptr);
ser.SerializeData(&size, sizeof(size_t));
ser.SerializeData(u, size);
}
void Serialize(SerializeBase& ser, const i64* i, size_t size)
{
Assert(i != nullptr);
ser.SerializeData(&size, sizeof(size_t));
ser.SerializeData(i, size);
}
void Serialize(SerializeBase& ser, const f32* f, size_t size)
{
Assert(f != nullptr);
ser.SerializeData(&size, sizeof(size_t));
ser.SerializeData(f, size);
}
void Serialize(SerializeBase& ser, const f64* d, size_t size)
{
Assert(d != nullptr);
ser.SerializeData(&size, sizeof(size_t));
ser.SerializeData(d, size);
}
| 21.510949
| 63
| 0.678317
|
frobro98
|
8fc4083d0998d8d50e46048809c3f193cf275b25
| 1,404
|
cpp
|
C++
|
src/backtracker/IntervalHandlerBase.cpp
|
ndaniel/BEETL
|
4f35e2f6a18be624c1159f3ffe042eb8490f94bf
|
[
"BSD-2-Clause"
] | 53
|
2015-02-05T02:26:15.000Z
|
2022-01-13T05:37:06.000Z
|
src/backtracker/IntervalHandlerBase.cpp
|
ndaniel/BEETL
|
4f35e2f6a18be624c1159f3ffe042eb8490f94bf
|
[
"BSD-2-Clause"
] | 9
|
2015-09-03T23:42:14.000Z
|
2021-10-15T15:25:49.000Z
|
src/backtracker/IntervalHandlerBase.cpp
|
ndaniel/BEETL
|
4f35e2f6a18be624c1159f3ffe042eb8490f94bf
|
[
"BSD-2-Clause"
] | 23
|
2015-01-08T13:43:07.000Z
|
2021-05-19T17:35:42.000Z
|
/**
** Copyright (c) 2011-2014 Illumina, Inc.
**
** This file is part of the BEETL software package,
** covered by the "BSD 2-Clause License" (see accompanying LICENSE file)
**
** Citation: Markus J. Bauer, Anthony J. Cox and Giovanna Rosone
** Lightweight BWT Construction for Very Large String Collections.
** Proceedings of CPM 2011, pp.219-231
**
**/
#include "IntervalHandlerBase.hh"
#include <sstream>
#include <sys/types.h>
#include <sys/stat.h>
using namespace std;
void IntervalHandlerBase::countString( char *bwtSubstring, int length, LetterCount &countsThisRange )
{
for ( int i = 0; i < length; i++ )
countsThisRange += bwtSubstring[i];
}
void IntervalHandlerBase::createOutputFile( const int subsetThreadNum, const int i, const int j, const int cycle, const string &outputDirectory )
{
#define CONCATENATE_J_PILES
// if ( cycle >= ( int )minWordLength_ )
{
ostringstream filename;
#ifdef CONCATENATE_J_PILES
filename << outputDirectory << ( outputDirectory.empty() ? "" : "/" ) << "cycle" << cycle << ".subset" << subsetThreadNum << "." << i;
outFile_.open( filename.str(), ( j == 1 ) ? ios::out : ios::app );
#else
filename << outputDirectory << ( outputDirectory.empty() ? "" : "/" ) << "cycle" << cycle << ".subset" << subsetThreadNum << "." << i << "." << j;
outFile_.open( filename.str() );
#endif
}
}
| 31.909091
| 154
| 0.645299
|
ndaniel
|
8fc8cd04b4591b692a48cda21277a7b66fa17aac
| 660
|
cpp
|
C++
|
d3/a.cpp
|
webdeveloperukraine/adventofcode2020
|
4d4f36437da0fd4889f0fcbe28cad8fecb6f6f34
|
[
"MIT"
] | null | null | null |
d3/a.cpp
|
webdeveloperukraine/adventofcode2020
|
4d4f36437da0fd4889f0fcbe28cad8fecb6f6f34
|
[
"MIT"
] | null | null | null |
d3/a.cpp
|
webdeveloperukraine/adventofcode2020
|
4d4f36437da0fd4889f0fcbe28cad8fecb6f6f34
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<string> input;
void prepare()
{
string resp;
while(getline(cin, resp)){
input.push_back(resp);
}
}
int encounter(int mx, int my)
{
int res = 0;
int x = 0;
int y = 0;
while(y < input.size()){
if(input[y][x] == '#'){
res++;
}
x = (x + mx) % input[0].size();
y += my;
}
return res;
}
int first()
{
return encounter(3,1);
}
ll second()
{
return (ll)encounter(1,1) * encounter(3,1) * encounter(5,1) * encounter(7,1) * encounter(1,2);
}
int main()
{
prepare();
cout << "First: " << first() << endl;
cout << "Second: " << second() << endl;
return 0;
}
| 13.469388
| 95
| 0.568182
|
webdeveloperukraine
|
8fd7061c13956c7783fe6778b3886be78ad97ce3
| 1,233
|
cpp
|
C++
|
src/data/test/ListFileDatasetTest.cpp
|
random-mud-pie/wav2letter
|
e6a543827738ce0d0dc39dedf578932c6f8b3fd1
|
[
"BSD-3-Clause"
] | 21
|
2019-05-09T02:15:28.000Z
|
2021-07-15T23:00:11.000Z
|
src/data/test/ListFileDatasetTest.cpp
|
random-mud-pie/wav2letter
|
e6a543827738ce0d0dc39dedf578932c6f8b3fd1
|
[
"BSD-3-Clause"
] | 7
|
2020-04-03T16:11:06.000Z
|
2020-12-24T03:25:45.000Z
|
src/data/test/ListFileDatasetTest.cpp
|
random-mud-pie/wav2letter
|
e6a543827738ce0d0dc39dedf578932c6f8b3fd1
|
[
"BSD-3-Clause"
] | 8
|
2019-12-16T15:51:06.000Z
|
2021-05-13T10:04:32.000Z
|
/**
* Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <fstream>
#include <iostream>
#include <string>
#include <arrayfire.h>
#include <flashlight/flashlight.h>
#include <gtest/gtest.h>
#include "common/Utils.h"
#include "data/ListFileDataset.h"
using namespace w2l;
namespace {
std::string loadPath = "";
}
TEST(ListFileDatasetTest, LoadData) {
auto data = getFileContent(pathsConcat(loadPath, "data.lst"));
auto rootPath = "/tmp/data.lst";
std::ofstream out(rootPath);
for (auto& d : data) {
replaceAll(d, "<TESTDIR>", loadPath);
out << d;
out << "\n";
}
out.close();
ListFileDataset audiods(rootPath);
ASSERT_EQ(audiods.size(), 3);
for (int i = 0; i < 3; ++i) {
ASSERT_EQ(audiods.get(i).size(), 4);
ASSERT_EQ(audiods.get(i)[0].dims(), af::dim4(1, 24000));
ASSERT_EQ(audiods.get(i)[3].elements(), 1);
}
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
// Resolve directory for data
#ifdef DATA_TEST_DATADIR
loadPath = DATA_TEST_DATADIR;
#endif
return RUN_ALL_TESTS();
}
| 22.418182
| 72
| 0.669911
|
random-mud-pie
|
8fd8cdead876881a7169587444442b323924d3c4
| 15,534
|
cpp
|
C++
|
src/plugins/azoth/plugins/acetamide/channelclentry.cpp
|
devel29a/leechcraft
|
faf5e856010fb785e4bbf3ce7b5c6a5c49f3239a
|
[
"BSL-1.0"
] | null | null | null |
src/plugins/azoth/plugins/acetamide/channelclentry.cpp
|
devel29a/leechcraft
|
faf5e856010fb785e4bbf3ce7b5c6a5c49f3239a
|
[
"BSL-1.0"
] | null | null | null |
src/plugins/azoth/plugins/acetamide/channelclentry.cpp
|
devel29a/leechcraft
|
faf5e856010fb785e4bbf3ce7b5c6a5c49f3239a
|
[
"BSL-1.0"
] | null | null | null |
/**********************************************************************
* LeechCraft - modular cross-platform feature rich internet client.
* Copyright (C) 2010-2011 Oleg Linkin
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
**********************************************************************/
#include "channelclentry.h"
#include <util/sll/prelude.h>
#include <interfaces/azoth/iproxyobject.h>
#include <interfaces/azoth/azothutil.h>
#include "channelhandler.h"
#include "channelpublicmessage.h"
#include "ircmessage.h"
#include "ircaccount.h"
#include "channelconfigwidget.h"
#include "channelsmanager.h"
namespace LeechCraft
{
namespace Azoth
{
namespace Acetamide
{
ChannelCLEntry::ChannelCLEntry (ChannelHandler *handler)
: ICH_ (handler)
, IsWidgetRequest_ (false)
{
Perms_ ["permclass_managment"] << "kick";
Perms_ ["permclass_managment"] << "ban_by_name";
Perms_ ["permclass_managment"] << "ban_by_user_and_domain";
Perms_ ["permclass_managment"] << "ban_by_domain";
Perms_ ["permclass_managment"] << "kick_and_ban";
Perms_ ["permclass_role"] << "participant";
Role2Str_ [ChannelRole::Participant] = "participant";
Aff2Str_ [ChannelRole::Participant] = "noaffiliation";
Managment2Str_ [ChannelManagment::Kick] = "kick";
Managment2Str_ [ChannelManagment::BanByName] = "ban_by_name";
Managment2Str_ [ChannelManagment::BanByDomain] = "ban_by_user_and_domain";
Managment2Str_ [ChannelManagment::BanByUserAndDomain] = "ban_by_domain";
Managment2Str_ [ChannelManagment::KickAndBan] = "kick_and_ban";
Translations_ ["permclass_role"] = tr ("Role");
Translations_ ["participant"] = tr ("Participant");
Translations_ ["permclass_managment"] = tr ("Kick and Ban");
Translations_ ["kick"] = tr ("Kick");
Translations_ ["ban_by_name"] = tr ("Ban by nickname");
Translations_ ["ban_by_domain"] = tr ("Ban by mask (*!*@domain)");
Translations_ ["ban_by_user_and_domain"] = tr ("Ban by mask (*!user@domain)");
Translations_ ["kick_and_ban"] = tr ("Kick and ban");
const auto& iSupport = ICH_->GetChannelsManager ()->GetISupport ();
QString roles = iSupport ["PREFIX"].split (')').value (0);
for (int i = roles.length () - 1; i >= 1; --i)
switch (roles.at (i).toLatin1 ())
{
case 'v':
Perms_ ["permclass_role"] << "voiced";
Role2Str_ [ChannelRole::Voiced] = "voiced";
Aff2Str_ [ChannelRole::Voiced] = "member";
Translations_ ["voiced"] = tr ("Voiced");
break;
case 'h':
Perms_ ["permclass_role"] << "halfoperator";
Role2Str_ [ChannelRole::HalfOperator] = "halfoperator";
Aff2Str_ [ChannelRole::HalfOperator] = "admin";
Translations_ ["halfoperator"] = tr ("HalfOperator");
break;
case 'o':
Perms_ ["permclass_role"] << "operator";
Role2Str_ [ChannelRole::Operator] = "operator";
Aff2Str_ [ChannelRole::Operator] = "admin";
Translations_ ["operator"] = tr ("Operator");
break;
case 'a':
Perms_ ["permclass_role"] << "admin";
Role2Str_ [ChannelRole::Admin] = "administrator";
Aff2Str_ [ChannelRole::Admin] = "admin";
Translations_ ["admin"] = tr ("Admin");
break;
case 'q':
Perms_ ["permclass_role"] << "owner";
Role2Str_ [ChannelRole::Owner] = "owner";
Aff2Str_ [ChannelRole::Owner] = "owner";
Translations_ ["owner"] = tr ("Owner");
break;
}
}
ChannelHandler* ChannelCLEntry::GetChannelHandler () const
{
return ICH_;
}
QObject* ChannelCLEntry::GetQObject ()
{
return this;
}
IAccount* ChannelCLEntry::GetParentAccount () const
{
return ICH_->GetChannelsManager ()->GetAccount ();
}
ICLEntry::Features ChannelCLEntry::GetEntryFeatures () const
{
return FSessionEntry;
}
ICLEntry::EntryType ChannelCLEntry::GetEntryType () const
{
return EntryType::MUC;
}
QString ChannelCLEntry::GetEntryName () const
{
return ICH_->GetChannelID ();
}
void ChannelCLEntry::SetEntryName (const QString&)
{
}
QString ChannelCLEntry::GetEntryID () const
{
return ICH_->GetChannelsManager ()->GetAccount ()->
GetAccountID () + "_" +
ICH_->GetChannelsManager ()->GetServerID () + "_" +
ICH_->GetChannelID ();
}
QString ChannelCLEntry::GetHumanReadableID () const
{
return ICH_->GetChannelID ();
}
QStringList ChannelCLEntry::Groups () const
{
return QStringList () << tr ("Channels");
}
void ChannelCLEntry::SetGroups (const QStringList&)
{
}
QStringList ChannelCLEntry::Variants () const
{
QStringList result;
result << "";
return result;
}
IMessage* ChannelCLEntry::CreateMessage (IMessage::Type,
const QString& variant, const QString& body)
{
if (variant == "")
return new ChannelPublicMessage (body, this);
else
return nullptr;
}
QList<IMessage*> ChannelCLEntry::GetAllMessages () const
{
return AllMessages_;
}
void ChannelCLEntry::PurgeMessages (const QDateTime& before)
{
AzothUtil::StandardPurgeMessages (AllMessages_, before);
}
void ChannelCLEntry::SetChatPartState (ChatPartState, const QString&)
{
}
QList<QAction*> ChannelCLEntry::GetActions () const
{
return QList<QAction*> ();
}
QMap<QString, QVariant> ChannelCLEntry::GetClientInfo (const QString&) const
{
return QMap<QString, QVariant> ();
}
void ChannelCLEntry::MarkMsgsRead ()
{
Core::Instance ().GetPluginProxy ()->MarkMessagesAsRead (this);
}
void ChannelCLEntry::ChatTabClosed ()
{
}
QString ChannelCLEntry::GetRealID (QObject*) const
{
return QString ();
}
EntryStatus ChannelCLEntry::GetStatus (const QString&) const
{
return EntryStatus (SOnline, QString ());
}
void ChannelCLEntry::ShowInfo ()
{
}
IMUCEntry::MUCFeatures ChannelCLEntry::GetMUCFeatures () const
{
return MUCFCanHaveSubject;
}
QString ChannelCLEntry::GetMUCSubject () const
{
return ICH_->GetMUCSubject ();
}
bool ChannelCLEntry::CanChangeSubject () const
{
return !ICH_->GetChannelModes ().InviteMode_ ||
ICH_->GetSelf ()->HighestRole () >= Operator;
}
void ChannelCLEntry::SetMUCSubject (const QString& subject)
{
ICH_->SetTopic (subject);
}
QList<QObject*> ChannelCLEntry::GetParticipants ()
{
return ICH_->GetParticipants ();
}
bool ChannelCLEntry::IsAutojoined () const
{
return false;
}
// TODO implement this
void ChannelCLEntry::Join ()
{
qWarning () << Q_FUNC_INFO << "implement me!";
}
void ChannelCLEntry::Leave (const QString& msg)
{
ICH_->Leave (msg);
}
QString ChannelCLEntry::GetNick () const
{
return ICH_->GetChannelsManager ()->GetOurNick ();
}
void ChannelCLEntry::SetNick (const QString& nick)
{
ICH_->SendPublicMessage ("/nick " + nick);
}
QString ChannelCLEntry::GetGroupName () const
{
return ICH_->GetChannelID ();
}
QVariantMap ChannelCLEntry::GetIdentifyingData () const
{
QVariantMap result;
const auto& channelOpts = ICH_->GetChannelOptions ();
const auto& serverOpts = ICH_->GetChannelsManager ()->GetServerOptions ();
result ["HumanReadableName"] = QString ("%1 on %2@%3:%4")
.arg (GetNick ())
.arg (channelOpts.ChannelName_)
.arg (channelOpts.ServerName_)
.arg (serverOpts.ServerPort_);
result ["AccountID"] = ICH_->GetChannelsManager ()->
GetAccount ()->GetAccountID ();
result ["Nickname"] = GetNick ();
result ["Channel"] = channelOpts.ChannelName_;
result ["Server"] = channelOpts.ServerName_;
result ["Port"] = serverOpts.ServerPort_;
result ["Encoding"] = serverOpts.ServerEncoding_;
result ["SSL"] = serverOpts.SSL_;
return result;
}
void ChannelCLEntry::InviteToMUC (const QString&, const QString&)
{
}
void ChannelCLEntry::HandleMessage (ChannelPublicMessage *msg)
{
AllMessages_ << msg;
emit gotMessage (msg);
}
void ChannelCLEntry::HandleNewParticipants (const QList<ICLEntry*>& parts)
{
emit gotNewParticipants (Util::Map (parts, &ICLEntry::GetQObject));
}
void ChannelCLEntry::HandleSubjectChanged (const QString& subj)
{
emit mucSubjectChanged (subj);
}
QByteArray ChannelCLEntry::GetAffName (QObject *participant) const
{
ChannelParticipantEntry *entry = qobject_cast<ChannelParticipantEntry*> (participant);
if (!entry)
{
qWarning () << Q_FUNC_INFO
<< participant
<< "is not a ChannelParticipantEntry";
return "noaffiliation";
}
return Aff2Str_ [entry->HighestRole ()];
}
QMap<QByteArray, QList<QByteArray>> ChannelCLEntry::GetPerms (QObject *participant) const
{
if (!participant)
participant = ICH_->GetSelf ().get ();
QMap<QByteArray, QList<QByteArray>> result;
const auto entry = qobject_cast<ChannelParticipantEntry*> (participant);
if (!entry)
{
qWarning () << Q_FUNC_INFO
<< participant
<< "is not a ChannelParticipantEntry";
result ["permclass_role"] << "norole";
}
else
for (const auto& role : entry->Roles ())
result ["permclass_role"] << Role2Str_.value (role, "invalid");
return result;
}
QPair<QByteArray, QByteArray> ChannelCLEntry::GetKickPerm () const
{
return QPair<QByteArray, QByteArray> ();
}
QPair<QByteArray, QByteArray> ChannelCLEntry::GetBanPerm () const
{
return QPair<QByteArray, QByteArray> ();
}
void ChannelCLEntry::SetPerm (QObject *participant,
const QByteArray& permClass,
const QByteArray& perm,
const QString& reason)
{
ChannelParticipantEntry *entry = qobject_cast<ChannelParticipantEntry*> (participant);
if (!entry)
{
qWarning () << Q_FUNC_INFO
<< participant
<< "is not a ChannelParticipantEntry";
return;
}
if (permClass == "permclass_role")
ICH_->SetRole (entry, Role2Str_.key (perm), reason);
else if (permClass == "permclass_managment")
ICH_->ManageWithParticipant (entry, Managment2Str_.key (perm));
else
{
qWarning () << Q_FUNC_INFO
<< "unknown perm class"
<< permClass;
return;
}
}
QMap<QByteArray, QList<QByteArray>> ChannelCLEntry::GetPossiblePerms () const
{
return Perms_;
}
QString ChannelCLEntry::GetUserString (const QByteArray& id) const
{
return Translations_.value (id, id);
}
bool ChannelCLEntry::IsLessByPerm (QObject *p1, QObject *p2) const
{
ChannelParticipantEntry *e1 = qobject_cast<ChannelParticipantEntry*> (p1);
ChannelParticipantEntry *e2 = qobject_cast<ChannelParticipantEntry*> (p2);
if (!e1 || !e2)
{
qWarning () << Q_FUNC_INFO
<< p1
<< "or"
<< p2
<< "is not a ChannelParticipantEntry";
return false;
}
return e1->HighestRole () < e2->HighestRole ();
}
namespace
{
bool MayChange (ChannelRole ourRole,
ChannelParticipantEntry *entry,
ChannelRole newRole)
{
ChannelRole role = entry->HighestRole ();
if (ourRole < ChannelRole::HalfOperator)
return false;
if (ourRole == ChannelRole::Owner)
return true;
if (role > ourRole)
return false;
if (newRole > ourRole)
return false;
return true;
}
bool MayManage (ChannelRole ourRole,
ChannelParticipantEntry *entry,
const QString& nick)
{
ChannelRole role = entry->HighestRole ();
if (ourRole < ChannelRole::HalfOperator)
return false;
if (ourRole == ChannelRole::Owner)
return true;
if (role > ourRole)
return false;
if (entry->GetEntryName () == nick)
return false;
return true;
}
}
bool ChannelCLEntry::MayChangePerm (QObject *participant,
const QByteArray& permClass, const QByteArray& perm) const
{
ChannelParticipantEntry *entry = qobject_cast<ChannelParticipantEntry*> (participant);
if (!entry)
{
qWarning () << Q_FUNC_INFO
<< participant
<< "is not a ChannelParticipantEntry";
return false;
}
const ChannelRole ourRole = ICH_->GetSelf ()->HighestRole ();
if (permClass == "permclass_role")
return MayChange (ourRole, entry, Role2Str_.key (perm));
else if (permClass == "permclass_managment")
return MayManage (ourRole, entry, ICH_->GetSelf ()->GetEntryName ());
else
{
qWarning () << Q_FUNC_INFO
<< "unknown perm class"
<< permClass;
return false;
}
}
bool ChannelCLEntry::IsMultiPerm (const QByteArray&) const
{
return true;
}
ChannelModes ChannelCLEntry::GetChannelModes () const
{
return ICH_->GetChannelModes ();
}
QWidget* ChannelCLEntry::GetConfigurationWidget ()
{
return new ChannelConfigWidget (this);
}
void ChannelCLEntry::AcceptConfiguration (QWidget *widget)
{
ChannelConfigWidget *cfg = qobject_cast<ChannelConfigWidget*> (widget);
if (!cfg)
{
qWarning () << Q_FUNC_INFO
<< "unable to cast"
<< widget
<< "to ChannelConfigWidget";
return;
}
cfg->accept ();
}
void ChannelCLEntry::RequestBanList ()
{
ICH_->RequestBanList ();
}
void ChannelCLEntry::RequestExceptList ()
{
ICH_->RequestExceptList ();
}
void ChannelCLEntry::RequestInviteList ()
{
ICH_->RequestInviteList ();
}
void ChannelCLEntry::SetBanListItem (const QString& mask,
const QString& nick, const QDateTime& date)
{
emit gotBanListItem (mask, nick, date);
}
void ChannelCLEntry::SetExceptListItem (const QString& mask,
const QString& nick, const QDateTime& date)
{
emit gotExceptListItem (mask, nick, date);
}
void ChannelCLEntry::SetInviteListItem (const QString& mask,
const QString& nick, const QDateTime& date)
{
emit gotInviteListItem (mask, nick, date);
}
void ChannelCLEntry::SetIsWidgetRequest (bool set)
{
IsWidgetRequest_ = set;
}
bool ChannelCLEntry::GetIsWidgetRequest () const
{
return IsWidgetRequest_;
}
void ChannelCLEntry::AddBanListItem (QString mask)
{
ICH_->AddBanListItem (mask);
}
void ChannelCLEntry::RemoveBanListItem (QString mask)
{
ICH_->RemoveBanListItem (mask);
}
void ChannelCLEntry::AddExceptListItem (QString mask)
{
ICH_->AddExceptListItem (mask);
}
void ChannelCLEntry::RemoveExceptListItem (QString mask)
{
ICH_->RemoveExceptListItem (mask);
}
void ChannelCLEntry::AddInviteListItem (QString mask)
{
ICH_->AddInviteListItem (mask);
}
void ChannelCLEntry::RemoveInviteListItem (QString mask)
{
ICH_->RemoveInviteListItem (mask);
}
void ChannelCLEntry::SetNewChannelModes (const ChannelModes& modes)
{
ICH_->SetNewChannelModes (modes);
}
QString ChannelCLEntry::Role2String (const ChannelRole& role) const
{
return Role2Str_ [role];
}
}
}
}
| 25.014493
| 91
| 0.692288
|
devel29a
|
8fe06f309d158e0e1d83b1841ac621c8dccf6fa9
| 10,194
|
cpp
|
C++
|
lib/MultiI2C/MultiI2C.cpp
|
RDobrinov/espurna32
|
b0bcf5bb80324e3c96a8a7f756014804b618730e
|
[
"NTP",
"Unlicense"
] | null | null | null |
lib/MultiI2C/MultiI2C.cpp
|
RDobrinov/espurna32
|
b0bcf5bb80324e3c96a8a7f756014804b618730e
|
[
"NTP",
"Unlicense"
] | null | null | null |
lib/MultiI2C/MultiI2C.cpp
|
RDobrinov/espurna32
|
b0bcf5bb80324e3c96a8a7f756014804b618730e
|
[
"NTP",
"Unlicense"
] | null | null | null |
#include "MultiI2C.hpp"
#include <Arduino.h>
MultiI2C::MultiI2C(void)
{
_state.port[I2C_NUM_0].port_config.mode = I2C_MODE_MASTER;
_state.port[I2C_NUM_0].port_config.sda_io_num = I2C_SDA_IO_0;
_state.port[I2C_NUM_0].port_config.scl_io_num = I2C_SCL_IO_0;
_state.port[I2C_NUM_0].port_config.sda_pullup_en = GPIO_PULLUP_ENABLE;
_state.port[I2C_NUM_0].port_config.scl_pullup_en = GPIO_PULLUP_ENABLE;
_state.port[I2C_NUM_0].port_config.master.clk_speed = I2C_PORT0_FREQ_HZ;
_state.port[I2C_NUM_0].port_enabled = false;
_state.port[I2C_NUM_1].port_config.mode = I2C_MODE_MASTER;
_state.port[I2C_NUM_1].port_config.sda_io_num = I2C_SDA_IO_1;
_state.port[I2C_NUM_1].port_config.scl_io_num = I2C_SCL_IO_1;
_state.port[I2C_NUM_1].port_config.sda_pullup_en = GPIO_PULLUP_ENABLE;
_state.port[I2C_NUM_1].port_config.scl_pullup_en = GPIO_PULLUP_ENABLE;
_state.port[I2C_NUM_1].port_config.master.clk_speed = I2C_PORT1_FREQ_HZ;
_state.port[I2C_NUM_1].port_enabled = false;
}
MultiI2C::~MultiI2C(void)
{
if(_state.port[I2C_NUM_0].port_activated)
i2c_driver_delete(I2C_NUM_0);
if(_state.port[I2C_NUM_1].port_activated)
i2c_driver_delete(I2C_NUM_1);
}
void MultiI2C::setConfiguration(i2c_config_t &port_config)
{
setConfiguration(I2C_NUM_0, port_config);
}
void MultiI2C::setConfiguration(i2c_port_t i2c_port, i2c_config_t &port_config)
{
_state.port[i2c_port].port_config = port_config;
}
void MultiI2C::setIOPins(gpio_num_t scl_io_num, gpio_num_t sda_io_num)
{
setIOPins(I2C_NUM_0, scl_io_num, sda_io_num);
}
void MultiI2C::setIOPins(i2c_port_t i2c_port, gpio_num_t scl_io_num, gpio_num_t sda_io_num)
{
_state.port[i2c_port].port_config.sda_io_num = sda_io_num;
_state.port[i2c_port].port_config.scl_io_num = scl_io_num;
}
void MultiI2C::setPortFrequency(unsigned int port_freq)
{
setPortFrequency(I2C_NUM_0, port_freq);
}
void MultiI2C::setPortFrequency(i2c_port_t i2c_port, unsigned int port_freq)
{
_state.port[i2c_port].port_config.master.clk_speed = port_freq;
}
bool MultiI2C::init(void)
{
return init(I2C_NUM_0);
}
bool MultiI2C::init(i2c_port_t i2c_port)
{
_config_driver(i2c_port);
_init_driver();
#if I2C_SCAN_ON_STARTUP
i2c_cmd_handle_t cmd;
if(_state.port[i2c_port].port_activated)
for( uint8_t addr_scan = 8; addr_scan<121; addr_scan++)
{
cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (addr_scan << 1) | READ_BIT, ACK_CHECK_EN );
i2c_master_stop(cmd);
if(ESP_OK == i2c_master_cmd_begin(i2c_port, cmd, (i2c_port == I2C_NUM_0) ? I2C_PORT0_BUS_TIMEOUT : I2C_PORT1_BUS_TIMEOUT / portTICK_RATE_MS))
Serial.printf("I2C Address 0x%2X found on I2C_NUM_%u\n", addr_scan, i2c_port);
i2c_cmd_link_delete(cmd);
};
#endif
if(_state.port[i2c_port].port_activated) i2c_set_timeout(i2c_port, 0xFFFFF);
return _state.port[i2c_port].port_activated;
/*return (
(_state.port[I2C_NUM_0].port_activated && _state.port[I2C_NUM_1].port_activated) ||
( _state.port[I2C_NUM_0].port_activated && !_state.port[I2C_NUM_1].port_enabled) ||
( _state.port[I2C_NUM_1].port_activated && !_state.port[I2C_NUM_0].port_enabled) ? ESP_OK : ESP_FAIL); */
}
void MultiI2C::begin(void)
{
init(I2C_NUM_0);
}
esp_err_t MultiI2C::unload(i2c_port_t i2c_port)
{
esp_err_t result = ESP_OK;
if(_state.port[i2c_port].port_activated)
result = i2c_driver_delete(i2c_port);
_state.port[i2c_port].port_activated = (ESP_OK != result );
return result;
}
esp_err_t MultiI2C::read(uint8_t addr_slave, uint8_t *data_rd, size_t size)
{
if(_state.port[I2C_NUM_0].port_activated)
return read(I2C_NUM_0, addr_slave, nullptr, 0, data_rd, size);
else
if(_state.port[I2C_NUM_1].port_activated)
return read(I2C_NUM_1, addr_slave, nullptr, 0, data_rd, size);
return ESP_FAIL;
}
esp_err_t MultiI2C::read(i2c_port_t i2c_port, uint8_t addr_slave, uint8_t *data_rd, size_t size)
{
return read(i2c_port, addr_slave, nullptr, 0, data_rd, size);
}
esp_err_t MultiI2C::read(i2c_port_t i2c_port, uint8_t addr_slave, uint8_t *data_wr, size_t size_wr, uint8_t *data_rd, size_t size_rd)
{
if (size_rd == 0)
{
return ESP_OK;
}
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
if(( data_wr != nullptr ) && (size_wr > 0) )
{
i2c_master_write_byte(cmd, (addr_slave << 1) | WRITE_BIT, ACK_CHECK_EN );
i2c_master_write(cmd, data_wr, size_wr, (i2c_ack_type_t) ACK_CHECK_EN);
i2c_master_start(cmd);
}
i2c_master_write_byte(cmd, (addr_slave << 1) | READ_BIT, ACK_CHECK_EN );
if (size_rd > 1)
i2c_master_read(cmd, data_rd, size_rd - 1, (i2c_ack_type_t) ACK_VAL);
i2c_master_read_byte(cmd, data_rd + size_rd - 1, (i2c_ack_type_t) NACK_VAL);
i2c_master_stop(cmd);
esp_err_t result = i2c_master_cmd_begin(i2c_port, cmd, (i2c_port == I2C_NUM_0) ? I2C_PORT0_BUS_TIMEOUT : I2C_PORT1_BUS_TIMEOUT / portTICK_RATE_MS);
//if( ESP_OK != result )
// Serial.println("i2c_master::read() error");
i2c_cmd_link_delete(cmd);
return result;
}
esp_err_t MultiI2C::read_reg(uint8_t addr_slave, uint8_t reg, uint8_t *data_rd, size_t size)
{
if(_state.port[I2C_NUM_0].port_activated)
return read(I2C_NUM_0, addr_slave, ®, 1, data_rd, size);
else
if(_state.port[I2C_NUM_1].port_activated)
return read(I2C_NUM_1, addr_slave, ®, 1, data_rd, size);
return ESP_FAIL;
}
esp_err_t MultiI2C::read_reg(i2c_port_t i2c_port, uint8_t addr_slave, uint8_t reg, uint8_t *data_rd, size_t size)
{
return read(i2c_port, addr_slave, ®, 1, data_rd, size);
}
esp_err_t MultiI2C::write(uint8_t addr_slave, uint8_t *data_wr, size_t size)
{
if(_state.port[I2C_NUM_0].port_activated)
return write(I2C_NUM_0, addr_slave, data_wr, size);
else
if(_state.port[I2C_NUM_1].port_activated)
return write(I2C_NUM_1, addr_slave, data_wr, size);
return ESP_FAIL;
}
esp_err_t MultiI2C::write(i2c_port_t i2c_port, uint8_t addr_slave, uint8_t *data_wr, size_t size)
{
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (addr_slave << 1) | WRITE_BIT, ACK_CHECK_EN );
i2c_master_write(cmd, data_wr, size, (i2c_ack_type_t) ACK_CHECK_EN);
i2c_master_stop(cmd);
esp_err_t result = i2c_master_cmd_begin(i2c_port, cmd, (i2c_port == I2C_NUM_0) ? I2C_PORT0_BUS_TIMEOUT : I2C_PORT1_BUS_TIMEOUT / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
//if( ESP_OK != result )
// Serial.println("MultiI2C::write() error");
return result;
}
esp_err_t MultiI2C::write_reg(uint8_t addr_slave, uint8_t reg, uint8_t *data_wr, size_t size)
{
if(_state.port[I2C_NUM_0].port_activated)
return write_reg(I2C_NUM_0, addr_slave, reg, data_wr, size);
else
if(_state.port[I2C_NUM_1].port_activated)
return write_reg(I2C_NUM_1, addr_slave, reg, data_wr, size);
return ESP_FAIL;
}
esp_err_t MultiI2C::write_reg(i2c_port_t i2c_port, uint8_t addr_slave, uint8_t reg, uint8_t *data_wr, size_t size)
{
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (addr_slave << 1) | WRITE_BIT, ACK_CHECK_EN );
i2c_master_write_byte(cmd, reg, ACK_CHECK_EN);
i2c_master_write(cmd, data_wr, size, (i2c_ack_type_t) ACK_CHECK_EN);
i2c_master_stop(cmd);
esp_err_t result = i2c_master_cmd_begin(i2c_port, cmd, (i2c_port == I2C_NUM_0) ? I2C_PORT0_BUS_TIMEOUT : I2C_PORT1_BUS_TIMEOUT / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
//if( ESP_OK != result )
// Serial.println("MultiI2C::write_reg() error");
return result;
}
bool MultiI2C::checkSlave(uint8_t addr_slave)
{
if(_state.port[I2C_NUM_0].port_activated)
return checkSlave(I2C_NUM_0, addr_slave);
else
if(_state.port[I2C_NUM_1].port_activated)
return checkSlave(I2C_NUM_1, addr_slave);
return false;
}
bool MultiI2C::checkSlave(i2c_port_t i2c_port, uint8_t addr_slave)
{
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (addr_slave << 1) | READ_BIT, ACK_CHECK_EN );
i2c_master_stop(cmd);
esp_err_t result = i2c_master_cmd_begin(i2c_port, cmd, (i2c_port == I2C_NUM_0) ? I2C_PORT0_BUS_TIMEOUT : I2C_PORT1_BUS_TIMEOUT / portTICK_RATE_MS);
//Serial.printf("MultiI2C::checkSlave(Port%u, 0x%2X)=%s, ESP_ERR=%u\n", i2c_port, addr_slave, (ESP_OK == result)?"true":"false", result);
i2c_cmd_link_delete(cmd);
return (ESP_OK == result);
}
bool MultiI2C::clearBus(void)
{
if(_state.port[I2C_NUM_0].port_activated)
return clearBus(I2C_NUM_0);
else
if(_state.port[I2C_NUM_1].port_activated)
return clearBus(I2C_NUM_1);
return true;
}
bool MultiI2C::clearBus(i2c_port_t i2c_port)
{
return (ESP_OK == i2c_reset_rx_fifo(i2c_port)) & (ESP_OK == i2c_reset_tx_fifo(i2c_port));
}
bool MultiI2C::getState(i2c_port_t i2c_port)
{
return _state.port[i2c_port].port_activated;
}
port_config_t MultiI2C::getConfig(i2c_port_t i2c_port)
{
return _state.port[i2c_port];
}
/* Private */
void MultiI2C::_config_driver(i2c_port_t i2c_port)
{
_state.port[i2c_port].port_enabled = (ESP_OK == i2c_param_config(i2c_port, &_state.port[i2c_port].port_config));
}
void MultiI2C::_init_driver(void)
{
if(_state.port[I2C_NUM_0].port_enabled && !_state.port[I2C_NUM_0].port_activated)
_state.port[I2C_NUM_0].port_activated = (ESP_OK == i2c_driver_install(I2C_NUM_0, _state.port[I2C_NUM_0].port_config.mode, I2C_RX_BUF_DISABLE, I2C_TX_BUF_DISABLE, 0));
if(_state.port[I2C_NUM_1].port_enabled && !_state.port[I2C_NUM_1].port_activated)
_state.port[I2C_NUM_1].port_activated = (ESP_OK == i2c_driver_install(I2C_NUM_1, _state.port[I2C_NUM_1].port_config.mode, I2C_RX_BUF_DISABLE, I2C_TX_BUF_DISABLE, 0));
return;
}
| 38.179775
| 174
| 0.716206
|
RDobrinov
|
8fe19557712a5b45abba265059d4ffc27a728518
| 14,787
|
cc
|
C++
|
src/Fullerene.cc
|
maruinen/FullereneViewer
|
da1554af2de21e90bfa0380a5b635f8bab8e2d8c
|
[
"Apache-2.0"
] | null | null | null |
src/Fullerene.cc
|
maruinen/FullereneViewer
|
da1554af2de21e90bfa0380a5b635f8bab8e2d8c
|
[
"Apache-2.0"
] | null | null | null |
src/Fullerene.cc
|
maruinen/FullereneViewer
|
da1554af2de21e90bfa0380a5b635f8bab8e2d8c
|
[
"Apache-2.0"
] | null | null | null |
/*
* Project: FullereneViewer
* Version: 1.0
* Copyright: (C) 2011-14 Dr.Sc.KAWAMOTO,Takuji (Ext)
*/
#define _CRT_SECURE_NO_WARNINGS
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include "Config.h"
#include "Fullerene.h"
#include "CarbonAllotrope.h"
#include "BoundaryCarbons.h"
#include "Representations.h"
#include "Automorphisms.h"
#include "Characteristic.h"
#include "Generator.h"
#include "DistanceMatrix.h"
#include "Pattern.h"
#include "Utils.h"
#include "Debug.h"
#include "DebugMemory.h"
bool Fullerene::s_need_fullerene_characteristic = false;
bool Fullerene::s_need_distance_matrix = false;
Fullerene::Fullerene()
: p_carbon_allotrope(0), p_error_code(ERROR_CODE_OK), p_n(0), p_m(0), p_h(0),
p_representations(0), p_characteristic(0), p_distance_matrix(0)
{
}
Fullerene::Fullerene(const char* generator_formula)
: p_carbon_allotrope(0), p_error_code(ERROR_CODE_OK), p_n(0), p_m(0), p_h(0),
p_representations(0), p_characteristic(0), p_distance_matrix(0)
{
if (generator_formula[0] == 'C')
{
while ((generator_formula[0] != ' ') && (generator_formula[0] != '\0'))
++generator_formula;
if (generator_formula[0] == ' ')
++generator_formula;
}
if (generator_formula[0] == '(')
{
while ((generator_formula[0] != ' ') && (generator_formula[0] != '\0'))
++generator_formula;
if (generator_formula[0] == ' ')
++generator_formula;
}
while ((generator_formula[0] != 'S') &&
(generator_formula[0] != 'A') &&
(generator_formula[0] != 'T') &&
(generator_formula[0] != 'Y') &&
(generator_formula[0] != '\0'))
++generator_formula;
CarbonAllotrope* ca = new CarbonAllotrope();
if ((generator_formula[0] != 'S') &&
(generator_formula[0] != 'A') &&
(generator_formula[0] != 'T') &&
(generator_formula[0] != 'Y'))
{
p_error_code = ERROR_CODE_ILLEGAL_GENERATOR_FORMULA;
delete ca;
ca = 0;
goto do_nothing;
}
p_generator_formula = generator_formula;
if (strcmp(p_generator_formula, "Y") == 0)
{
ca->make_equator_by_chiral_characteristic(6, 6, 5);
ca->close_normally_once();
int result_number;
int array[100];
array[0] = 7;
array[1] = 6;
array[2] = 7;
array[3] = 6;
array[4] = 6;
array[5] = 6;
array[6] = 7;
array[7] = 6;
array[8] = 7;
array[9] = 6;
ca->enlarge_cylinder_by_n_polygons(new Pattern(10, array), result_number);
ca->append_n_polygon_at_carbon(6, 131 + 48);
ca->append_n_polygon_at_carbon(6, 117 + 48);
ca->append_n_polygon_at_carbon(6, 132 + 48);
ca->append_n_polygon_at_carbon(6, 136 + 48);
ca->append_n_polygon_at_carbon(6, 118 + 48);
ca->append_n_polygon_at_carbon(6, 123 + 48);
ca->append_n_polygon_at_carbon(6, 138 + 48);
ca->append_n_polygon_at_carbon(6, 140 + 48);
array[0] = 156 + 48;
array[1] = 155 + 48;
array[2] = 0;
array[3] = 0;
array[4] = 0;
array[5] = 0;
array[6] = 0;
ca->append_n_polygon_at_carbons(7, array);
array[0] = 154 + 48;
array[1] = 153 + 48;
ca->append_n_polygon_at_carbons(7, array);
array[0] = 160 + 48;
array[1] = 159 + 48;
array[2] = 164 + 48;
array[3] = 163 + 48;
array[4] = 0;
array[5] = 0;
ca->append_n_polygon_at_carbons(6, array);
ca->append_n_polygon_at_carbon(6, 164 + 48);
ca->append_n_polygon_at_carbon(6, 121 + 48);
ca->append_n_polygon_at_carbon(6, 124 + 48);
ca->append_n_polygon_at_carbon(6, 126 + 48);
ca->append_n_polygon_at_carbon(6, 129 + 48);
ca->append_n_polygon_at_carbon(6, 154 + 48);
ca->append_n_polygon_at_carbon(6, 165 + 48);
ca->append_n_polygon_at_carbon(6, 158 + 48);
ca->append_n_polygon_at_carbon(6, 155 + 48);
ca->append_n_polygon_at_carbon(6, 112 + 48);
ca->append_n_polygon_at_carbon(6, 115 + 48);
ca->append_n_polygon_at_carbon(6, 156 + 48);
ca->append_n_polygon_at_carbon(6, 160 + 48);
ca->append_n_polygon_at_carbon(6, 163 + 48);
ca->append_n_polygon_at_carbon(6, 153 + 48);
ca->append_n_polygon_at_carbon(6, 111 + 48);
ca->append_n_polygon_at_carbon(6, 109 + 48);
ca->append_n_polygon_at_carbon(6, 143 + 48);
ca->append_n_polygon_at_carbon(6, 151 + 48);
ca->append_n_polygon_at_carbon(6, 149 + 48);
ca->append_n_polygon_at_carbon(6, 145 + 48);
ca->enlarge_cylinder_by_n_polygons(new Pattern(6), result_number);
ca->enlarge_cylinder_by_n_polygons(new Pattern(6), result_number);
ca->enlarge_cylinder_by_n_polygons(new Pattern(6), result_number);
ca->enlarge_cylinder_by_n_polygons(new Pattern(6), result_number);
ca->close_normally_once();
ca->enlarge_cylinder_by_n_polygons(new Pattern(6), result_number);
ca->enlarge_cylinder_by_n_polygons(new Pattern(6), result_number);
ca->enlarge_cylinder_by_n_polygons(new Pattern(6), result_number);
ca->enlarge_cylinder_by_n_polygons(new Pattern(6), result_number);
ca->close_normally_once();
}
else
{
if (p_generator_formula[0] == 'T')
{
const char *ptr = (char*)p_generator_formula + 1;
p_n = strtol(ptr, (char**)&ptr, 10);
if (*ptr == ',')
++ptr;
p_m = strtol(ptr, (char**)&ptr, 10);
if (*ptr == ',')
++ptr;
p_h = strtol(ptr, (char**)&ptr, 10);
if (*ptr == '\0')
{
ca->make_equator_by_chiral_characteristic(p_n, p_m, p_h);
#if defined(DEBUG_CARBON_ALLOTROPE_CONSTRUCTION)
ca->print_detail();
#endif
goto finish;
}
}
/* 'S' 'A' 'T' */
Generator gen = Generator(generator_formula, 6);
if (gen.type() == GENERATOR_TYPE_ILLEGAL)
{
delete ca;
p_error_code = ERROR_CODE_ILLEGAL_GENERATOR_FORMULA;
ca = 0;
goto do_nothing;
}
if (gen.type() == GENERATOR_TYPE_TUBE)
ca->make_equator_by_chiral_characteristic(gen.n(), gen.m(), gen.h());
else
ca->make_symmetric_scrap(gen.scrap_no());
BoundaryCarbons boundary;
bool symmetric = (gen.type() == GENERATOR_TYPE_SYMMETRIC);
if (!symmetric)
{
boundary.clean();
ca->list_oldest_connected_boundary_carbons(boundary);
}
#if defined(DEBUG_CARBON_ALLOTROPE_CONSTRUCTION)
ca->print_detail();
#endif
while (1)
{
int No = gen.history();
if (No == -1)
break;
int num;
ErrorCode result;
if (symmetric)
result =
ca->fill_n_polygons_around_carbons_closed_to_center_and_pentagons(No, num);
else
{
Carbon* carbon = boundary.get_two_rings_carbon_of_minimum_sequence_no();
assert(carbon);
result = ca->fill_n_polygon_around_carbon(No, carbon, boundary);
}
if (result != ERROR_CODE_OK)
{
delete ca;
p_error_code = result;
ca = 0;
goto do_nothing;
}
#if defined(DEBUG_CARBON_ALLOTROPE_CONSTRUCTION)
ca->print_detail();
#endif
if (symmetric)
{
boundary.clean();
ca->list_oldest_connected_boundary_carbons(boundary);
}
int number_of_carbons_in_boundary = boundary.length();
if (!symmetric && (number_of_carbons_in_boundary == 0))
{
boundary.clean();
ca->list_oldest_connected_boundary_carbons(boundary);
}
}
}
finish:
set_carbon_allotrope(ca);
do_nothing:
;
}
Fullerene::~Fullerene()
{
if (p_carbon_allotrope)
delete p_carbon_allotrope;
if (p_representations)
delete p_representations;
if (p_characteristic)
delete p_characteristic;
if (p_distance_matrix)
delete p_distance_matrix;
}
int Fullerene::compare(const Fullerene* you) const
{
return p_representations->compare(you->p_representations);
}
void Fullerene::set_carbon_allotrope(CarbonAllotrope* carbon_allotrope)
{
p_carbon_allotrope = carbon_allotrope;
if (p_carbon_allotrope && CarbonAllotrope::s_need_representations)
{
int len;
#if defined(DEBUG_FULLERENE_CONSTRUCTION)
printf("* representations ******************************\n");
#endif
p_representations = new Representations();
p_carbon_allotrope->all_representations(p_representations);
#if defined(DEBUG_FULLERENE_CONSTRUCTION)
len = p_representations->length();
for (int i = 0; i < len; ++i)
{
Representation* rep = p_representations->get_representation(i);
rep->print();
}
printf("************************************************\n");
#endif
if (CarbonAllotrope::s_need_all_axes || CarbonAllotrope::s_need_major_axes)
{
Automorphisms ams = Automorphisms(this);
p_carbon_allotrope->all_boundaries();
len = ams.number_of_automorphisms();
for (int i = 0; i < len; ++i)
{
Automorphism* am = ams.get_automorphism(i);
int order = am->order();
if (order == 1)
continue;
int seq0, seq1, seq2, seq3, seq4, seq5, seq6, seq7;
int fixed_carbons = am->fixed_carbons(seq0, seq1);
int fixed_bonds = am->fixed_bonds(seq2, seq3);
int fixed_rings = am->fixed_rings(seq4, seq5);
int fixed_boundaries = am->fixed_boundaries(seq6, seq7);
AxisType type = AXIS_TYPE_CENTER_OF_TWO_CARBONS;
if ((fixed_carbons == 2) && (fixed_bonds == 0) &&
(fixed_rings == 0) && (fixed_boundaries == 0))
type = AXIS_TYPE_CENTER_OF_TWO_CARBONS;
else if ((fixed_carbons == 1) && (fixed_bonds == 1) &&
(fixed_rings == 0) && (fixed_boundaries == 0))
{
type = AXIS_TYPE_CENTER_OF_CARBON_AND_BOND;
seq1 = seq2;
}
else if ((fixed_carbons == 1) && (fixed_bonds == 0) &&
(fixed_rings == 1) && (fixed_boundaries == 0))
{
type = AXIS_TYPE_CENTER_OF_CARBON_AND_RING;
seq1 = seq4;
}
else if ((fixed_carbons == 1) && (fixed_bonds == 0) &&
(fixed_rings == 0) && (fixed_boundaries == 1))
{
type = AXIS_TYPE_CENTER_OF_CARBON_AND_BOUNDARY;
seq1 = seq6;
}
else if ((fixed_carbons == 0) && (fixed_bonds == 2) &&
(fixed_rings == 0) && (fixed_boundaries == 0))
{
type = AXIS_TYPE_CENTER_OF_TWO_BONDS;
seq0 = seq2;
seq1 = seq3;
}
else if ((fixed_carbons == 0) && (fixed_bonds == 1) &&
(fixed_rings == 1) && (fixed_boundaries == 0))
{
type = AXIS_TYPE_CENTER_OF_BOND_AND_RING;
seq0 = seq2;
seq1 = seq4;
}
else if ((fixed_carbons == 0) && (fixed_bonds == 1) &&
(fixed_rings == 0) && (fixed_boundaries == 1))
{
type = AXIS_TYPE_CENTER_OF_BOND_AND_BOUNDARY;
seq0 = seq2;
seq1 = seq6;
}
else if ((fixed_carbons == 0) && (fixed_bonds == 0) &&
(fixed_rings == 2) && (fixed_boundaries == 0))
{
type = AXIS_TYPE_CENTER_OF_TWO_RINGS;
seq0 = seq4;
seq1 = seq5;
}
else if ((fixed_carbons == 0) && (fixed_bonds == 0) &&
(fixed_rings == 1) && (fixed_boundaries == 1))
{
type = AXIS_TYPE_CENTER_OF_RING_AND_BOUNDARY;
seq0 = seq4;
seq1 = seq6;
}
else if ((fixed_carbons == 0) && (fixed_bonds == 0) &&
(fixed_rings == 0) && (fixed_boundaries == 2))
{
type = AXIS_TYPE_CENTER_OF_TWO_BOUNDARIES;
seq0 = seq6;
seq1 = seq7;
}
else if ((fixed_carbons == 1) && (fixed_bonds == 0) &&
(fixed_rings == 0) && (fixed_boundaries == 0))
type = AXIS_TYPE_CENTER_OF_ONLY_ONE_CARBON;
else if ((fixed_carbons == 0) && (fixed_bonds == 1) &&
(fixed_rings == 0) && (fixed_boundaries == 0))
{
type = AXIS_TYPE_CENTER_OF_ONLY_ONE_BOND;
seq0 = seq2;
}
else if ((fixed_carbons == 0) && (fixed_bonds == 0) &&
(fixed_rings == 1) && (fixed_boundaries == 0))
{
type = AXIS_TYPE_CENTER_OF_ONLY_ONE_RING;
seq0 = seq4;
}
else if ((fixed_carbons == 0) && (fixed_bonds == 0) &&
(fixed_rings == 0) && (fixed_boundaries == 1))
{
type = AXIS_TYPE_CENTER_OF_ONLY_ONE_BOUNDARY;
seq0 = seq6;
}
else if ((fixed_carbons == 0) && (fixed_bonds == 0) &&
(fixed_rings == 0) && (fixed_boundaries == 0))
continue;
else
{
printf("fixed carbons = %d\n", fixed_carbons);
printf("fixed bonds = %d\n", fixed_bonds);
printf("fixed rings = %d\n", fixed_rings);
printf("fixed boundaries = %d\n", fixed_boundaries);
assert(0);
}
p_carbon_allotrope->register_axis(new SymmetryAxis(type, order,
seq0, seq1, am));
}
}
}
if (p_carbon_allotrope && s_need_fullerene_characteristic)
p_characteristic = new Characteristic(p_carbon_allotrope);
if (p_carbon_allotrope && s_need_distance_matrix)
p_distance_matrix = new DistanceMatrix(p_carbon_allotrope);
}
void Fullerene::set_fullerene_name(const char* fullerene_name)
{
p_fullerene_name = fullerene_name;
}
void Fullerene::set_generator_formula(const char* generator_formula)
{
p_generator_formula = generator_formula;
}
/* Local Variables: */
/* mode: c++ */
/* End: */
| 35.717391
| 89
| 0.547711
|
maruinen
|
8fe550b79e248ebe699151510079c4cd581ddd9d
| 5,640
|
hpp
|
C++
|
src/Modules/GUIModule/Facades/ofxGuiFacade.hpp
|
danielfilipealmeida/Orange
|
e0118a7d1391e74c15c707e64a2e0458d51d318f
|
[
"MIT"
] | null | null | null |
src/Modules/GUIModule/Facades/ofxGuiFacade.hpp
|
danielfilipealmeida/Orange
|
e0118a7d1391e74c15c707e64a2e0458d51d318f
|
[
"MIT"
] | null | null | null |
src/Modules/GUIModule/Facades/ofxGuiFacade.hpp
|
danielfilipealmeida/Orange
|
e0118a7d1391e74c15c707e64a2e0458d51d318f
|
[
"MIT"
] | null | null | null |
//
// ofxGuiFacade.hpp
// orange
//
// Created by Daniel Almeida on 04/12/2018.
//
#ifndef ofxGuiFacade_hpp
#define ofxGuiFacade_hpp
#include <stdio.h>
#include "ofxGui.h"
#include "GUIFacadeInterface.hpp"
#include "ofxPreview.hpp"
#include "ofxMatrix.hpp"
#include "ofxNavigator.hpp"
#include "ofxList.hpp"
#include <functional>
namespace Orange {
namespace GUI {
class ofxGuiFacade : public GUIFacadeInterface {
ofxPanel previewsPanel, layerPanel, visualPanel, effectsPanel, effectsListPanel;
ofxPanel *currentPanel;
std::map<PanelNames, ofxPanel*> panelsMap;
public:
/*!
Constructor. sets up all needed data interface using ofxGUI
*/
ofxGuiFacade();
/*!
Sets up the Panel used for all previews (output and layers)
*/
void setupPreviewPanel();
/*!
Sets up the panel that gather all layers controls
*/
void setupLayersPanel();
/*!
Sets up the panel of the currently selected visual
*/
void setupVisualPanel();
/*!
Sets up the panel with all the effects for the output and layers
*/
void setupEffectsPanel();
/*!
*/
void setupEffectsListPanel();
/*!
Sets all panels
*/
void setupPanels();
/*!
Sets the name of the current panel
\param ofParameter<string> name
*/
void setName(ofParameter<string> name);
/*!
Creates a parameter group
\param ofParameterGroup parameters
*/
void createParameterGroup(ofParameterGroup parameters);
/*!
Creates a button
*/
void createButton(std::string caption, std::function<void()> callback);
/*!
Creates a float Slider in the GUI
\param string title
\param string name
*/
void createSlider(ofParameter<float> parameter, string name = "");
/*!
Creates a float Slider in the GUI
\param string title
\param float value
\param float minValue
\param float maxValue
\param string name
*/
void createSlider(ofParameter<float> parameter,
std::string title,
float minValue,
float maxValue);
/*!
Creates an integer Slider in the GUI
\param string title
\param int value
\param int minValue
\param int maxValue
\param string name
*/
void createSlider(ofParameter<int> parameter,
std::string title,
int minValue,
int maxValue);
/*!
Creates a label displaying information
\param ofParameter<string> parameter
\param string name
*/
void createLabel(ofParameter<string> parameter);
/*!
Creates a label using a string
\param string text
\param string name
*/
void createLabel(string text);
/*!
Creates and returns a preview of the passed fbo
\param ofFbo *fbo
\param string name
\return ofxPreview*
*/
ofxPreview* createPreview(ofFbo *fbo, string name = "");
/*!
Creates a matrix of textures
\param ofParameter<vector<ofTexture *>>
\return ofxMatrix<ofTexture *>*
*/
ofxMatrix<ofImage *>* createImageMatrix(ofParameter<vector<ofImage *>> value,
string name = "",
unsigned int rows = 2,
unsigned int columns = 2);
ofxList<std::string>* createStringList(ofParameter<vector<std::string>> value, string name = "");
/*!
*/
void createNavigator(ofParameter<ofxPaginatedInterface *> element, string name = "");
/*!
Draws the ofxGui
*/
void draw();
void drawPanel(PanelNames panel);
/*!
Clears the current GUI
*/
void clear();
/*!
Sets the currently active panel to receive actions
\param PanelNames panelName
*/
void setCurrentPanel(PanelNames panelName);
/*!
*/
void mouseEventOnPanel(PanelNames panelName, ofMouseEventArgs & args);
/*!
Returns a ofxGui object by it's name
\param std::string the name
\returns ofxBaseGui*
*/
ofxBaseGui* getControl(std::string name);
};
}
}
#endif /* ofxGuiFacade_hpp */
| 30.160428
| 109
| 0.456915
|
danielfilipealmeida
|
8fe5da76795e50a98ddc29f6d4e96e537f4b8430
| 203
|
cc
|
C++
|
src/FractalStruct/misc_class.cc
|
jmikeowen/Spheral
|
3e1082a7aefd6b328bd3ae24ca1a477108cfc3c4
|
[
"BSD-Source-Code",
"BSD-3-Clause-LBNL",
"FSFAP"
] | 22
|
2018-07-31T21:38:22.000Z
|
2020-06-29T08:58:33.000Z
|
src/FractalStruct/misc_class.cc
|
markguozhiming/spheral
|
bbb982102e61edb8a1d00cf780bfa571835e1b61
|
[
"BSD-Source-Code",
"BSD-3-Clause-LBNL",
"FSFAP"
] | 41
|
2020-09-28T23:14:27.000Z
|
2022-03-28T17:01:33.000Z
|
src/FractalStruct/misc_class.cc
|
markguozhiming/spheral
|
bbb982102e61edb8a1d00cf780bfa571835e1b61
|
[
"BSD-Source-Code",
"BSD-3-Clause-LBNL",
"FSFAP"
] | 7
|
2019-12-01T07:00:06.000Z
|
2020-09-15T21:12:39.000Z
|
#include "libs.hh"
#include "classes.hh"
#include "headers.hh"
//
namespace FractalSpace
{
bool Misc::get_debug() const
{
return debug;
}
void Misc::set_debug(bool& d)
{
debug=d;
}
}
| 12.6875
| 31
| 0.625616
|
jmikeowen
|
8fe76332b2864d48b2aadadc68599cfa209765ee
| 43,323
|
cpp
|
C++
|
src/MesaDLL/glut_hel18.cpp
|
OS2World/LIB-GRAPHICS-The_Mesa_3D_Graphics_Library
|
c0e0cfaeefa9e87e4978101fbac7d0372c39f1a3
|
[
"MIT"
] | null | null | null |
src/MesaDLL/glut_hel18.cpp
|
OS2World/LIB-GRAPHICS-The_Mesa_3D_Graphics_Library
|
c0e0cfaeefa9e87e4978101fbac7d0372c39f1a3
|
[
"MIT"
] | null | null | null |
src/MesaDLL/glut_hel18.cpp
|
OS2World/LIB-GRAPHICS-The_Mesa_3D_Graphics_Library
|
c0e0cfaeefa9e87e4978101fbac7d0372c39f1a3
|
[
"MIT"
] | null | null | null |
/* GENERATED FILE -- DO NOT MODIFY */
#define glutBitmapHelvetica18 XXX
#include "glutbitmap.h"
#undef glutBitmapHelvetica18
/* char: 0xff */
static const GLubyte ch255data[] = {
0x70,0x70,0x18,0x18,0x18,0x18,0x3c,0x24,0x66,0x66,0x66,0xc3,0xc3,0xc3,0x0,0x66,
0x66,
};
static const BitmapCharRec ch255 = {8,17,-1,4,10,ch255data};
/* char: 0xfe */
static const GLubyte ch254data[] = {
0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xde,0x0,0xff,0x0,0xe3,0x0,0xc1,0x80,
0xc1,0x80,0xc1,0x80,0xc1,0x80,0xe3,0x0,0xff,0x0,0xde,0x0,0xc0,0x0,0xc0,0x0,
0xc0,0x0,0xc0,0x0,
};
static const BitmapCharRec ch254 = {9,18,-1,4,11,ch254data};
/* char: 0xfd */
static const GLubyte ch253data[] = {
0x70,0x70,0x18,0x18,0x18,0x18,0x3c,0x24,0x66,0x66,0x66,0xc3,0xc3,0xc3,0x0,0x18,
0xc,0x6,
};
static const BitmapCharRec ch253 = {8,18,-1,4,10,ch253data};
/* char: 0xfc */
static const GLubyte ch252data[] = {
0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x0,0x66,0x66,
};
static const BitmapCharRec ch252 = {8,13,-1,0,10,ch252data};
/* char: 0xfb */
static const GLubyte ch251data[] = {
0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x0,0x66,0x3c,0x18,
};
static const BitmapCharRec ch251 = {8,14,-1,0,10,ch251data};
/* char: 0xfa */
static const GLubyte ch250data[] = {
0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x0,0x18,0xc,0x6,
};
static const BitmapCharRec ch250 = {8,14,-1,0,10,ch250data};
/* char: 0xf9 */
static const GLubyte ch249data[] = {
0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x0,0xc,0x18,0x30,
};
static const BitmapCharRec ch249 = {8,14,-1,0,10,ch249data};
/* char: 0xf8 */
static const GLubyte ch248data[] = {
0xce,0x0,0x7f,0x80,0x31,0x80,0x78,0xc0,0x6c,0xc0,0x66,0xc0,0x63,0xc0,0x31,0x80,
0x3f,0xc0,0xe,0x60,
};
static const BitmapCharRec ch248 = {11,10,0,0,11,ch248data};
/* char: 0xf7 */
static const GLubyte ch247data[] = {
0x18,0x18,0x0,0xff,0xff,0x0,0x18,0x18,
};
static const BitmapCharRec ch247 = {8,8,-1,-1,10,ch247data};
/* char: 0xf6 */
static const GLubyte ch246data[] = {
0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
0x7f,0x0,0x3e,0x0,0x0,0x0,0x36,0x0,0x36,0x0,
};
static const BitmapCharRec ch246 = {9,13,-1,0,11,ch246data};
/* char: 0xf5 */
static const GLubyte ch245data[] = {
0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
0x7f,0x0,0x3e,0x0,0x0,0x0,0x26,0x0,0x2d,0x0,0x19,0x0,
};
static const BitmapCharRec ch245 = {9,14,-1,0,11,ch245data};
/* char: 0xf4 */
static const GLubyte ch244data[] = {
0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
0x7f,0x0,0x3e,0x0,0x0,0x0,0x33,0x0,0x1e,0x0,0xc,0x0,
};
static const BitmapCharRec ch244 = {9,14,-1,0,11,ch244data};
/* char: 0xf3 */
static const GLubyte ch243data[] = {
0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
0x7f,0x0,0x3e,0x0,0x0,0x0,0x18,0x0,0xc,0x0,0x6,0x0,
};
static const BitmapCharRec ch243 = {9,14,-1,0,11,ch243data};
/* char: 0xf2 */
static const GLubyte ch242data[] = {
0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
0x7f,0x0,0x3e,0x0,0x0,0x0,0xc,0x0,0x18,0x0,0x30,0x0,
};
static const BitmapCharRec ch242 = {9,14,-1,0,11,ch242data};
/* char: 0xf1 */
static const GLubyte ch241data[] = {
0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xe3,0xdf,0xce,0x0,0x4c,0x5a,0x32,
};
static const BitmapCharRec ch241 = {8,14,-1,0,10,ch241data};
/* char: 0xf0 */
static const GLubyte ch240data[] = {
0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
0x7f,0x0,0x3e,0x0,0x4c,0x0,0x38,0x0,0x36,0x0,0x60,0x0,
};
static const BitmapCharRec ch240 = {9,14,-1,0,11,ch240data};
/* char: 0xef */
static const GLubyte ch239data[] = {
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x0,0xd8,0xd8,
};
static const BitmapCharRec ch239 = {5,13,0,0,4,ch239data};
/* char: 0xee */
static const GLubyte ch238data[] = {
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0xcc,0x78,0x30,
};
static const BitmapCharRec ch238 = {6,14,1,0,4,ch238data};
/* char: 0xed */
static const GLubyte ch237data[] = {
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x0,0xc0,0x60,0x30,
};
static const BitmapCharRec ch237 = {4,14,0,0,4,ch237data};
/* char: 0xec */
static const GLubyte ch236data[] = {
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x0,0x30,0x60,0xc0,
};
static const BitmapCharRec ch236 = {4,14,0,0,4,ch236data};
/* char: 0xeb */
static const GLubyte ch235data[] = {
0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,0x0,0x36,0x36,
};
static const BitmapCharRec ch235 = {8,13,-1,0,10,ch235data};
/* char: 0xea */
static const GLubyte ch234data[] = {
0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,0x0,0x66,0x3c,0x18,
};
static const BitmapCharRec ch234 = {8,14,-1,0,10,ch234data};
/* char: 0xe9 */
static const GLubyte ch233data[] = {
0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,0x0,0x18,0xc,0x6,
};
static const BitmapCharRec ch233 = {8,14,-1,0,10,ch233data};
/* char: 0xe8 */
static const GLubyte ch232data[] = {
0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,0x0,0x18,0x30,0x60,
};
static const BitmapCharRec ch232 = {8,14,-1,0,10,ch232data};
/* char: 0xe7 */
static const GLubyte ch231data[] = {
0x78,0x6c,0xc,0x38,0x3e,0x7f,0x63,0xc0,0xc0,0xc0,0xc0,0x63,0x7f,0x3e,
};
static const BitmapCharRec ch231 = {8,14,-1,4,10,ch231data};
/* char: 0xe6 */
static const GLubyte ch230data[] = {
0x75,0xe0,0xef,0xf8,0xc7,0x18,0xc6,0x0,0xe6,0x0,0x7f,0xf8,0xe,0x18,0xc6,0x18,
0xef,0xf0,0x7d,0xe0,
};
static const BitmapCharRec ch230 = {13,10,-1,0,15,ch230data};
/* char: 0xe5 */
static const GLubyte ch229data[] = {
0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x38,0x6c,0x6c,0x38,
};
static const BitmapCharRec ch229 = {7,14,-1,0,9,ch229data};
/* char: 0xe4 */
static const GLubyte ch228data[] = {
0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x6c,0x6c,
};
static const BitmapCharRec ch228 = {7,13,-1,0,9,ch228data};
/* char: 0xe3 */
static const GLubyte ch227data[] = {
0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x4c,0x5a,0x32,
};
static const BitmapCharRec ch227 = {7,14,-1,0,9,ch227data};
/* char: 0xe2 */
static const GLubyte ch226data[] = {
0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x66,0x3c,0x18,
};
static const BitmapCharRec ch226 = {7,14,-1,0,9,ch226data};
/* char: 0xe1 */
static const GLubyte ch225data[] = {
0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x30,0x18,0xc,
};
static const BitmapCharRec ch225 = {7,14,-1,0,9,ch225data};
/* char: 0xe0 */
static const GLubyte ch224data[] = {
0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x18,0x30,0x60,
};
static const BitmapCharRec ch224 = {7,14,-1,0,9,ch224data};
/* char: 0xdf */
static const GLubyte ch223data[] = {
0xdc,0xde,0xc6,0xc6,0xc6,0xc6,0xdc,0xdc,0xc6,0xc6,0xc6,0xc6,0x7c,0x38,
};
static const BitmapCharRec ch223 = {7,14,-1,0,9,ch223data};
/* char: 0xde */
static const GLubyte ch222data[] = {
0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x80,0xc1,0xc0,0xc0,0xc0,0xc0,0xc0,
0xc1,0xc0,0xff,0x80,0xff,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
};
static const BitmapCharRec ch222 = {10,14,-1,0,12,ch222data};
/* char: 0xdd */
static const GLubyte ch221data[] = {
0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0xf,0x0,0x19,0x80,
0x30,0xc0,0x30,0xc0,0x60,0x60,0x60,0x60,0xc0,0x30,0xc0,0x30,0x0,0x0,0x6,0x0,
0x3,0x0,0x1,0x80,
};
static const BitmapCharRec ch221 = {12,18,-1,0,14,ch221data};
/* char: 0xdc */
static const GLubyte ch220data[] = {
0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0x0,0x0,0x19,0x80,
0x19,0x80,
};
static const BitmapCharRec ch220 = {11,17,-1,0,13,ch220data};
/* char: 0xdb */
static const GLubyte ch219data[] = {
0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0x0,0x0,0x19,0x80,
0xf,0x0,0x6,0x0,
};
static const BitmapCharRec ch219 = {11,18,-1,0,13,ch219data};
/* char: 0xda */
static const GLubyte ch218data[] = {
0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0x0,0x0,0xc,0x0,
0x6,0x0,0x3,0x0,
};
static const BitmapCharRec ch218 = {11,18,-1,0,13,ch218data};
/* char: 0xd9 */
static const GLubyte ch217data[] = {
0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0x0,0x0,0x6,0x0,
0xc,0x0,0x18,0x0,
};
static const BitmapCharRec ch217 = {11,18,-1,0,13,ch217data};
/* char: 0xd8 */
static const GLubyte ch216data[] = {
0xc7,0xc0,0xff,0xf0,0x78,0x38,0x38,0x18,0x6c,0x1c,0x6e,0xc,0x67,0xc,0x63,0x8c,
0x61,0xcc,0x70,0xdc,0x30,0x78,0x38,0x38,0x1f,0xfc,0x7,0xcc,
};
static const BitmapCharRec ch216 = {14,14,0,0,15,ch216data};
/* char: 0xd7 */
static const GLubyte ch215data[] = {
0xc0,0xc0,0x61,0x80,0x33,0x0,0x1e,0x0,0xc,0x0,0x1e,0x0,0x33,0x0,0x61,0x80,
0xc0,0xc0,
};
static const BitmapCharRec ch215 = {10,9,0,0,10,ch215data};
/* char: 0xd6 */
static const GLubyte ch214data[] = {
0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0xd,0x80,
0xd,0x80,
};
static const BitmapCharRec ch214 = {13,17,-1,0,15,ch214data};
/* char: 0xd5 */
static const GLubyte ch213data[] = {
0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0x9,0x80,
0xb,0x40,0x6,0x40,
};
static const BitmapCharRec ch213 = {13,18,-1,0,15,ch213data};
/* char: 0xd4 */
static const GLubyte ch212data[] = {
0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0xc,0xc0,
0x7,0x80,0x3,0x0,
};
static const BitmapCharRec ch212 = {13,18,-1,0,15,ch212data};
/* char: 0xd3 */
static const GLubyte ch211data[] = {
0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0x3,0x0,
0x1,0x80,0x0,0xc0,
};
static const BitmapCharRec ch211 = {13,18,-1,0,15,ch211data};
/* char: 0xd2 */
static const GLubyte ch210data[] = {
0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0x3,0x0,
0x6,0x0,0xc,0x0,
};
static const BitmapCharRec ch210 = {13,18,-1,0,15,ch210data};
/* char: 0xd1 */
static const GLubyte ch209data[] = {
0xc0,0x60,0xc0,0xe0,0xc1,0xe0,0xc1,0xe0,0xc3,0x60,0xc6,0x60,0xc6,0x60,0xcc,0x60,
0xcc,0x60,0xd8,0x60,0xd8,0x60,0xf0,0x60,0xe0,0x60,0xe0,0x60,0x0,0x0,0x13,0x0,
0x16,0x80,0xc,0x80,
};
static const BitmapCharRec ch209 = {11,18,-1,0,13,ch209data};
/* char: 0xd0 */
static const GLubyte ch208data[] = {
0x7f,0x80,0x7f,0xc0,0x60,0xe0,0x60,0x60,0x60,0x30,0x60,0x30,0xfc,0x30,0xfc,0x30,
0x60,0x30,0x60,0x30,0x60,0x60,0x60,0xe0,0x7f,0xc0,0x7f,0x80,
};
static const BitmapCharRec ch208 = {12,14,0,0,13,ch208data};
/* char: 0xcf */
static const GLubyte ch207data[] = {
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0xcc,
0xcc,
};
static const BitmapCharRec ch207 = {6,17,0,0,6,ch207data};
/* char: 0xce */
static const GLubyte ch206data[] = {
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0xcc,
0x78,0x30,
};
static const BitmapCharRec ch206 = {6,18,0,0,6,ch206data};
/* char: 0xcd */
static const GLubyte ch205data[] = {
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x0,0xc0,
0x60,0x30,
};
static const BitmapCharRec ch205 = {4,18,-2,0,6,ch205data};
/* char: 0xcc */
static const GLubyte ch204data[] = {
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0x30,
0x60,0xc0,
};
static const BitmapCharRec ch204 = {4,18,0,0,6,ch204data};
/* char: 0xcb */
static const GLubyte ch203data[] = {
0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,0x0,0x0,0x33,0x0,
0x33,0x0,
};
static const BitmapCharRec ch203 = {9,17,-1,0,11,ch203data};
/* char: 0xca */
static const GLubyte ch202data[] = {
0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,0x0,0x0,0x33,0x0,
0x1e,0x0,0xc,0x0,
};
static const BitmapCharRec ch202 = {9,18,-1,0,11,ch202data};
/* char: 0xc9 */
static const GLubyte ch201data[] = {
0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,0x0,0x0,0xc,0x0,
0x6,0x0,0x3,0x0,
};
static const BitmapCharRec ch201 = {9,18,-1,0,11,ch201data};
/* char: 0xc8 */
static const GLubyte ch200data[] = {
0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,0x0,0x0,0xc,0x0,
0x18,0x0,0x30,0x0,
};
static const BitmapCharRec ch200 = {9,18,-1,0,11,ch200data};
/* char: 0xc7 */
static const GLubyte ch199data[] = {
0x1e,0x0,0x1b,0x0,0x3,0x0,0xe,0x0,0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,
0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xe0,0x0,0x60,0x30,0x70,0x70,
0x3f,0xe0,0xf,0x80,
};
static const BitmapCharRec ch199 = {12,18,-1,4,14,ch199data};
/* char: 0xc6 */
static const GLubyte ch198data[] = {
0xc1,0xff,0xc1,0xff,0x61,0x80,0x61,0x80,0x7f,0x80,0x3f,0x80,0x31,0xfe,0x31,0xfe,
0x19,0x80,0x19,0x80,0xd,0x80,0xd,0x80,0x7,0xff,0x7,0xff,
};
static const BitmapCharRec ch198 = {16,14,-1,0,18,ch198data};
/* char: 0xc5 */
static const GLubyte ch197data[] = {
0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0xf,0x0,0x19,0x80,
0x19,0x80,0xf,0x0,
};
static const BitmapCharRec ch197 = {12,18,0,0,12,ch197data};
/* char: 0xc4 */
static const GLubyte ch196data[] = {
0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x19,0x80,
0x19,0x80,
};
static const BitmapCharRec ch196 = {12,17,0,0,12,ch196data};
/* char: 0xc3 */
static const GLubyte ch195data[] = {
0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x13,0x0,
0x16,0x80,0xc,0x80,
};
static const BitmapCharRec ch195 = {12,18,0,0,12,ch195data};
/* char: 0xc2 */
static const GLubyte ch194data[] = {
0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x19,0x80,
0xf,0x0,0x6,0x0,
};
static const BitmapCharRec ch194 = {12,18,0,0,12,ch194data};
/* char: 0xc1 */
static const GLubyte ch193data[] = {
0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x6,0x0,
0x3,0x0,0x1,0x80,
};
static const BitmapCharRec ch193 = {12,18,0,0,12,ch193data};
/* char: 0xc0 */
static const GLubyte ch192data[] = {
0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x6,0x0,
0xc,0x0,0x18,0x0,
};
static const BitmapCharRec ch192 = {12,18,0,0,12,ch192data};
/* char: 0xbf */
static const GLubyte ch191data[] = {
0x7c,0xfe,0xc6,0xc6,0xe0,0x70,0x38,0x18,0x18,0x18,0x0,0x0,0x18,0x18,
};
static const BitmapCharRec ch191 = {7,14,-1,4,10,ch191data};
/* char: 0xbe */
static const GLubyte ch190data[] = {
0x18,0x18,0x18,0x18,0xc,0xfc,0x6,0xd8,0x6,0x78,0x73,0x38,0xf9,0x18,0x99,0x88,
0x30,0xc0,0x30,0xc0,0x98,0x60,0xf8,0x30,0x70,0x30,
};
static const BitmapCharRec ch190 = {14,13,0,0,15,ch190data};
/* char: 0xbd */
static const GLubyte ch189data[] = {
0x30,0xf8,0x30,0xf8,0x18,0x60,0xc,0x30,0xc,0x18,0x66,0x98,0x62,0xf8,0x63,0x70,
0x61,0x80,0x61,0x80,0xe0,0xc0,0xe0,0x60,0x60,0x60,
};
static const BitmapCharRec ch189 = {13,13,-1,0,15,ch189data};
/* char: 0xbc */
static const GLubyte ch188data[] = {
0x30,0x30,0x30,0x30,0x19,0xf8,0xd,0xb0,0xc,0xf0,0x66,0x70,0x62,0x30,0x63,0x10,
0x61,0x80,0x61,0x80,0xe0,0xc0,0xe0,0x60,0x60,0x60,
};
static const BitmapCharRec ch188 = {13,13,-1,0,15,ch188data};
/* char: 0xbb */
static const GLubyte ch187data[] = {
0x90,0xd8,0x6c,0x36,0x36,0x6c,0xd8,0x90,
};
static const BitmapCharRec ch187 = {7,8,-1,-1,9,ch187data};
/* char: 0xba */
static const GLubyte ch186data[] = {
0xf8,0x0,0x70,0xd8,0x88,0x88,0xd8,0x70,
};
static const BitmapCharRec ch186 = {5,8,-1,-6,7,ch186data};
/* char: 0xb9 */
static const GLubyte ch185data[] = {
0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x60,
};
static const BitmapCharRec ch185 = {3,8,-1,-5,6,ch185data};
/* char: 0xb8 */
static const GLubyte ch184data[] = {
0xf0,0xd8,0x18,0x70,0x60,
};
static const BitmapCharRec ch184 = {5,5,0,4,5,ch184data};
/* char: 0xb7 */
static const GLubyte ch183data[] = {
0xc0,0xc0,
};
static const BitmapCharRec ch183 = {2,2,-1,-4,4,ch183data};
/* char: 0xb6 */
static const GLubyte ch182data[] = {
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x32,0x72,0xf2,0xf2,0xf2,0xf2,
0x72,0x3f,
};
static const BitmapCharRec ch182 = {8,18,-1,4,10,ch182data};
/* char: 0xb5 */
static const GLubyte ch181data[] = {
0xc0,0xc0,0xc0,0xc0,0xdb,0xff,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,
};
static const BitmapCharRec ch181 = {8,14,-1,4,10,ch181data};
/* char: 0xb4 */
static const GLubyte ch180data[] = {
0xc0,0x60,0x30,
};
static const BitmapCharRec ch180 = {4,3,0,-11,4,ch180data};
/* char: 0xb3 */
static const GLubyte ch179data[] = {
0x70,0xf8,0x98,0x30,0x30,0x98,0xf8,0x70,
};
static const BitmapCharRec ch179 = {5,8,0,-5,6,ch179data};
/* char: 0xb2 */
static const GLubyte ch178data[] = {
0xf8,0xf8,0x60,0x30,0x18,0x98,0xf8,0x70,
};
static const BitmapCharRec ch178 = {5,8,0,-5,6,ch178data};
/* char: 0xb1 */
static const GLubyte ch177data[] = {
0xff,0xff,0x0,0x18,0x18,0x18,0xff,0xff,0x18,0x18,0x18,
};
static const BitmapCharRec ch177 = {8,11,-1,0,10,ch177data};
/* char: 0xb0 */
static const GLubyte ch176data[] = {
0x70,0xd8,0x88,0xd8,0x70,
};
static const BitmapCharRec ch176 = {5,5,-1,-8,7,ch176data};
/* char: 0xaf */
static const GLubyte ch175data[] = {
0xf8,
};
static const BitmapCharRec ch175 = {5,1,0,-12,5,ch175data};
/* char: 0xae */
static const GLubyte ch174data[] = {
0xf,0x80,0x30,0x60,0x40,0x10,0x48,0x50,0x88,0x88,0x89,0x8,0x8f,0x88,0x88,0x48,
0x88,0x48,0x4f,0x90,0x40,0x10,0x30,0x60,0xf,0x80,
};
static const BitmapCharRec ch174 = {13,13,-1,0,14,ch174data};
/* char: 0xad */
static const GLubyte ch173data[] = {
0xf8,0xf8,
};
static const BitmapCharRec ch173 = {5,2,-1,-4,7,ch173data};
/* char: 0xac */
static const GLubyte ch172data[] = {
0x1,0x80,0x1,0x80,0x1,0x80,0xff,0x80,0xff,0x80,
};
static const BitmapCharRec ch172 = {9,5,-1,-3,11,ch172data};
/* char: 0xab */
static const GLubyte ch171data[] = {
0x12,0x36,0x6c,0xd8,0xd8,0x6c,0x36,0x12,
};
static const BitmapCharRec ch171 = {7,8,-1,-1,9,ch171data};
/* char: 0xaa */
static const GLubyte ch170data[] = {
0xf8,0x0,0x68,0xd8,0x48,0x38,0xc8,0x70,
};
static const BitmapCharRec ch170 = {5,8,-1,-6,7,ch170data};
/* char: 0xa9 */
static const GLubyte ch169data[] = {
0xf,0x80,0x30,0x60,0x40,0x10,0x47,0x10,0x88,0x88,0x90,0x8,0x90,0x8,0x90,0x8,
0x88,0x88,0x47,0x10,0x40,0x10,0x30,0x60,0xf,0x80,
};
static const BitmapCharRec ch169 = {13,13,-1,0,15,ch169data};
/* char: 0xa8 */
static const GLubyte ch168data[] = {
0xd8,0xd8,
};
static const BitmapCharRec ch168 = {5,2,0,-11,6,ch168data};
/* char: 0xa7 */
static const GLubyte ch167data[] = {
0x3c,0x7e,0xc3,0xc3,0x7,0xe,0x3e,0x73,0xe3,0xc3,0xc7,0x6e,0x7c,0xf0,0xc3,0xc3,
0x7e,0x3c,
};
static const BitmapCharRec ch167 = {8,18,-1,4,10,ch167data};
/* char: 0xa6 */
static const GLubyte ch166data[] = {
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x0,0x0,0x0,0x0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
0xc0,
};
static const BitmapCharRec ch166 = {2,17,-1,3,4,ch166data};
/* char: 0xa5 */
static const GLubyte ch165data[] = {
0x18,0x18,0x18,0x18,0xff,0x18,0xff,0x3c,0x66,0x66,0x66,0xc3,0xc3,
};
static const BitmapCharRec ch165 = {8,13,-1,0,10,ch165data};
/* char: 0xa4 */
static const GLubyte ch164data[] = {
0xc3,0xff,0x66,0x66,0x66,0xff,0xc3,
};
static const BitmapCharRec ch164 = {8,7,-1,-3,10,ch164data};
/* char: 0xa3 */
static const GLubyte ch163data[] = {
0xdf,0x0,0xff,0x80,0x60,0x80,0x30,0x0,0x18,0x0,0x18,0x0,0x7e,0x0,0x30,0x0,
0x60,0x0,0x61,0x80,0x61,0x80,0x3f,0x0,0x1e,0x0,
};
static const BitmapCharRec ch163 = {9,13,0,0,10,ch163data};
/* char: 0xa2 */
static const GLubyte ch162data[] = {
0x10,0x10,0x3e,0x7f,0x6b,0xc8,0xc8,0xc8,0xc8,0x6b,0x7f,0x3e,0x4,0x4,
};
static const BitmapCharRec ch162 = {8,14,-1,2,10,ch162data};
/* char: 0xa1 */
static const GLubyte ch161data[] = {
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x40,0x40,0x0,0x0,0xc0,0xc0,
};
static const BitmapCharRec ch161 = {2,14,-2,4,6,ch161data};
/* char: 0xa0 */
#ifdef _WIN32
/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
a height or width of zero does not advance the raster position
as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
static const GLubyte ch160data[] = { 0x0 };
static const BitmapCharRec ch160 = {1,1,0,0,5,ch160data};
#else
static const BitmapCharRec ch160 = {0,0,0,0,5,0};
#endif
/* char: 0x7e '~' */
static const GLubyte ch126data[] = {
0xcc,0x7e,0x33,
};
static const BitmapCharRec ch126 = {8,3,-1,-4,10,ch126data};
/* char: 0x7d '}' */
static const GLubyte ch125data[] = {
0xc0,0x60,0x30,0x30,0x30,0x30,0x30,0x30,0x18,0xc,0x18,0x30,0x30,0x30,0x30,0x30,
0x60,0xc0,
};
static const BitmapCharRec ch125 = {6,18,0,4,6,ch125data};
/* char: 0x7c '|' */
static const GLubyte ch124data[] = {
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
0xc0,0xc0,
};
static const BitmapCharRec ch124 = {2,18,-1,4,4,ch124data};
/* char: 0x7b '{' */
static const GLubyte ch123data[] = {
0xc,0x18,0x30,0x30,0x30,0x30,0x30,0x30,0x60,0xc0,0x60,0x30,0x30,0x30,0x30,0x30,
0x18,0xc,
};
static const BitmapCharRec ch123 = {6,18,0,4,6,ch123data};
/* char: 0x7a 'z' */
static const GLubyte ch122data[] = {
0xfe,0xfe,0xc0,0x60,0x30,0x18,0xc,0x6,0xfe,0xfe,
};
static const BitmapCharRec ch122 = {7,10,-1,0,9,ch122data};
/* char: 0x79 'y' */
static const GLubyte ch121data[] = {
0x70,0x70,0x18,0x18,0x18,0x18,0x3c,0x24,0x66,0x66,0x66,0xc3,0xc3,0xc3,
};
static const BitmapCharRec ch121 = {8,14,-1,4,10,ch121data};
/* char: 0x78 'x' */
static const GLubyte ch120data[] = {
0xc3,0xe7,0x66,0x3c,0x18,0x18,0x3c,0x66,0xe7,0xc3,
};
static const BitmapCharRec ch120 = {8,10,-1,0,10,ch120data};
/* char: 0x77 'w' */
static const GLubyte ch119data[] = {
0x19,0x80,0x19,0x80,0x39,0xc0,0x29,0x40,0x69,0x60,0x66,0x60,0x66,0x60,0xc6,0x30,
0xc6,0x30,0xc6,0x30,
};
static const BitmapCharRec ch119 = {12,10,-1,0,14,ch119data};
/* char: 0x76 'v' */
static const GLubyte ch118data[] = {
0x18,0x18,0x3c,0x24,0x66,0x66,0x66,0xc3,0xc3,0xc3,
};
static const BitmapCharRec ch118 = {8,10,-1,0,10,ch118data};
/* char: 0x75 'u' */
static const GLubyte ch117data[] = {
0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,
};
static const BitmapCharRec ch117 = {8,10,-1,0,10,ch117data};
/* char: 0x74 't' */
static const GLubyte ch116data[] = {
0x18,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0xfc,0xfc,0x30,0x30,0x30,
};
static const BitmapCharRec ch116 = {6,13,0,0,6,ch116data};
/* char: 0x73 's' */
static const GLubyte ch115data[] = {
0x78,0xfc,0xc6,0x6,0x3e,0xfc,0xc0,0xc6,0x7e,0x3c,
};
static const BitmapCharRec ch115 = {7,10,-1,0,9,ch115data};
/* char: 0x72 'r' */
static const GLubyte ch114data[] = {
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xe0,0xd8,0xd8,
};
static const BitmapCharRec ch114 = {5,10,-1,0,6,ch114data};
/* char: 0x71 'q' */
static const GLubyte ch113data[] = {
0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x3d,0x80,0x7f,0x80,0x63,0x80,0xc1,0x80,
0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x80,0x7f,0x80,0x3d,0x80,
};
static const BitmapCharRec ch113 = {9,14,-1,4,11,ch113data};
/* char: 0x70 'p' */
static const GLubyte ch112data[] = {
0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xde,0x0,0xff,0x0,0xe3,0x0,0xc1,0x80,
0xc1,0x80,0xc1,0x80,0xc1,0x80,0xe3,0x0,0xff,0x0,0xde,0x0,
};
static const BitmapCharRec ch112 = {9,14,-1,4,11,ch112data};
/* char: 0x6f 'o' */
static const GLubyte ch111data[] = {
0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
0x7f,0x0,0x3e,0x0,
};
static const BitmapCharRec ch111 = {9,10,-1,0,11,ch111data};
/* char: 0x6e 'n' */
static const GLubyte ch110data[] = {
0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xe3,0xdf,0xce,
};
static const BitmapCharRec ch110 = {8,10,-1,0,10,ch110data};
/* char: 0x6d 'm' */
static const GLubyte ch109data[] = {
0xc6,0x30,0xc6,0x30,0xc6,0x30,0xc6,0x30,0xc6,0x30,0xc6,0x30,0xc6,0x30,0xe7,0x30,
0xde,0xf0,0xcc,0x60,
};
static const BitmapCharRec ch109 = {12,10,-1,0,14,ch109data};
/* char: 0x6c 'l' */
static const GLubyte ch108data[] = {
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
};
static const BitmapCharRec ch108 = {2,14,-1,0,4,ch108data};
/* char: 0x6b 'k' */
static const GLubyte ch107data[] = {
0xc7,0xc6,0xce,0xcc,0xd8,0xf8,0xf0,0xd8,0xcc,0xc6,0xc0,0xc0,0xc0,0xc0,
};
static const BitmapCharRec ch107 = {8,14,-1,0,9,ch107data};
/* char: 0x6a 'j' */
static const GLubyte ch106data[] = {
0xe0,0xf0,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0x0,
0x30,0x30,
};
static const BitmapCharRec ch106 = {4,18,1,4,4,ch106data};
/* char: 0x69 'i' */
static const GLubyte ch105data[] = {
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x0,0x0,0xc0,0xc0,
};
static const BitmapCharRec ch105 = {2,14,-1,0,4,ch105data};
/* char: 0x68 'h' */
static const GLubyte ch104data[] = {
0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xe3,0xdf,0xce,0xc0,0xc0,0xc0,0xc0,
};
static const BitmapCharRec ch104 = {8,14,-1,0,10,ch104data};
/* char: 0x67 'g' */
static const GLubyte ch103data[] = {
0x1c,0x0,0x7f,0x0,0x63,0x0,0x1,0x80,0x3d,0x80,0x7f,0x80,0x63,0x80,0xc1,0x80,
0xc1,0x80,0xc1,0x80,0xc1,0x80,0x61,0x80,0x7f,0x80,0x3d,0x80,
};
static const BitmapCharRec ch103 = {9,14,-1,4,11,ch103data};
/* char: 0x66 'f' */
static const GLubyte ch102data[] = {
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0xfc,0xfc,0x30,0x30,0x3c,0x1c,
};
static const BitmapCharRec ch102 = {6,14,0,0,6,ch102data};
/* char: 0x65 'e' */
static const GLubyte ch101data[] = {
0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,
};
static const BitmapCharRec ch101 = {8,10,-1,0,10,ch101data};
/* char: 0x64 'd' */
static const GLubyte ch100data[] = {
0x3d,0x80,0x7f,0x80,0x63,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x80,
0x7f,0x80,0x3d,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,
};
static const BitmapCharRec ch100 = {9,14,-1,0,11,ch100data};
/* char: 0x63 'c' */
static const GLubyte ch99data[] = {
0x3e,0x7f,0x63,0xc0,0xc0,0xc0,0xc0,0x63,0x7f,0x3e,
};
static const BitmapCharRec ch99 = {8,10,-1,0,10,ch99data};
/* char: 0x62 'b' */
static const GLubyte ch98data[] = {
0xde,0x0,0xff,0x0,0xe3,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xe3,0x0,
0xff,0x0,0xde,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
};
static const BitmapCharRec ch98 = {9,14,-1,0,11,ch98data};
/* char: 0x61 'a' */
static const GLubyte ch97data[] = {
0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,
};
static const BitmapCharRec ch97 = {7,10,-1,0,9,ch97data};
/* char: 0x60 '`' */
static const GLubyte ch96data[] = {
0xc0,0xc0,0x80,0x80,0x40,
};
static const BitmapCharRec ch96 = {2,5,-1,-9,4,ch96data};
/* char: 0x5f '_' */
static const GLubyte ch95data[] = {
0xff,0xc0,0xff,0xc0,
};
static const BitmapCharRec ch95 = {10,2,0,4,10,ch95data};
/* char: 0x5e '^' */
static const GLubyte ch94data[] = {
0x82,0xc6,0x6c,0x38,0x10,
};
static const BitmapCharRec ch94 = {7,5,-1,-8,9,ch94data};
/* char: 0x5d ']' */
static const GLubyte ch93data[] = {
0xf0,0xf0,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
0xf0,0xf0,
};
static const BitmapCharRec ch93 = {4,18,0,4,5,ch93data};
/* char: 0x5c '\' */
static const GLubyte ch92data[] = {
0x18,0x18,0x10,0x10,0x30,0x30,0x20,0x20,0x60,0x60,0x40,0x40,0xc0,0xc0,
};
static const BitmapCharRec ch92 = {5,14,0,0,5,ch92data};
/* char: 0x5b '[' */
static const GLubyte ch91data[] = {
0xf0,0xf0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
0xf0,0xf0,
};
static const BitmapCharRec ch91 = {4,18,-1,4,5,ch91data};
/* char: 0x5a 'Z' */
static const GLubyte ch90data[] = {
0xff,0xc0,0xff,0xc0,0xc0,0x0,0x60,0x0,0x30,0x0,0x18,0x0,0x1c,0x0,0xc,0x0,
0x6,0x0,0x3,0x0,0x1,0x80,0x0,0xc0,0xff,0xc0,0xff,0xc0,
};
static const BitmapCharRec ch90 = {10,14,-1,0,12,ch90data};
/* char: 0x59 'Y' */
static const GLubyte ch89data[] = {
0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0xf,0x0,0x19,0x80,
0x30,0xc0,0x30,0xc0,0x60,0x60,0x60,0x60,0xc0,0x30,0xc0,0x30,
};
static const BitmapCharRec ch89 = {12,14,-1,0,14,ch89data};
/* char: 0x58 'X' */
static const GLubyte ch88data[] = {
0xc0,0x60,0xe0,0xe0,0x60,0xc0,0x71,0xc0,0x31,0x80,0x1b,0x0,0xe,0x0,0xe,0x0,
0x1b,0x0,0x31,0x80,0x71,0xc0,0x60,0xc0,0xe0,0xe0,0xc0,0x60,
};
static const BitmapCharRec ch88 = {11,14,-1,0,13,ch88data};
/* char: 0x57 'W' */
static const GLubyte ch87data[] = {
0x18,0x18,0x18,0x18,0x1c,0x38,0x34,0x2c,0x36,0x6c,0x36,0x6c,0x66,0x66,0x66,0x66,
0x62,0x46,0x63,0xc6,0xc3,0xc3,0xc1,0x83,0xc1,0x83,0xc1,0x83,
};
static const BitmapCharRec ch87 = {16,14,-1,0,18,ch87data};
/* char: 0x56 'V' */
static const GLubyte ch86data[] = {
0x6,0x0,0xf,0x0,0xf,0x0,0x19,0x80,0x19,0x80,0x19,0x80,0x30,0xc0,0x30,0xc0,
0x30,0xc0,0x60,0x60,0x60,0x60,0x60,0x60,0xc0,0x30,0xc0,0x30,
};
static const BitmapCharRec ch86 = {12,14,-1,0,14,ch86data};
/* char: 0x55 'U' */
static const GLubyte ch85data[] = {
0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
};
static const BitmapCharRec ch85 = {11,14,-1,0,13,ch85data};
/* char: 0x54 'T' */
static const GLubyte ch84data[] = {
0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,
0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xff,0xc0,0xff,0xc0,
};
static const BitmapCharRec ch84 = {10,14,-1,0,12,ch84data};
/* char: 0x53 'S' */
static const GLubyte ch83data[] = {
0x3f,0x0,0x7f,0xc0,0xe0,0xe0,0xc0,0x60,0x0,0x60,0x0,0xe0,0x3,0xc0,0x1f,0x0,
0x7c,0x0,0xe0,0x0,0xc0,0x60,0xe0,0xe0,0x7f,0xc0,0x1f,0x0,
};
static const BitmapCharRec ch83 = {11,14,-1,0,13,ch83data};
/* char: 0x52 'R' */
static const GLubyte ch82data[] = {
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0x80,0xc1,0x80,0xff,0x0,0xff,0x80,
0xc1,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0xff,0x80,0xff,0x0,
};
static const BitmapCharRec ch82 = {10,14,-1,0,12,ch82data};
/* char: 0x51 'Q' */
static const GLubyte ch81data[] = {
0x0,0x30,0xf,0xb0,0x3f,0xe0,0x70,0xf0,0x61,0xb0,0xe1,0xb8,0xc0,0x18,0xc0,0x18,
0xc0,0x18,0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,
};
static const BitmapCharRec ch81 = {13,15,-1,1,15,ch81data};
/* char: 0x50 'P' */
static const GLubyte ch80data[] = {
0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x80,
0xc1,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0xff,0x80,0xff,0x0,
};
static const BitmapCharRec ch80 = {10,14,-1,0,12,ch80data};
/* char: 0x4f 'O' */
static const GLubyte ch79data[] = {
0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,
};
static const BitmapCharRec ch79 = {13,14,-1,0,15,ch79data};
/* char: 0x4e 'N' */
static const GLubyte ch78data[] = {
0xc0,0x60,0xc0,0xe0,0xc1,0xe0,0xc1,0xe0,0xc3,0x60,0xc6,0x60,0xc6,0x60,0xcc,0x60,
0xcc,0x60,0xd8,0x60,0xf0,0x60,0xf0,0x60,0xe0,0x60,0xc0,0x60,
};
static const BitmapCharRec ch78 = {11,14,-1,0,13,ch78data};
/* char: 0x4d 'M' */
static const GLubyte ch77data[] = {
0xc3,0xc,0xc3,0xc,0xc7,0x8c,0xc4,0x8c,0xcc,0xcc,0xcc,0xcc,0xd8,0x6c,0xd8,0x6c,
0xf0,0x3c,0xf0,0x3c,0xe0,0x1c,0xe0,0x1c,0xc0,0xc,0xc0,0xc,
};
static const BitmapCharRec ch77 = {14,14,-1,0,16,ch77data};
/* char: 0x4c 'L' */
static const GLubyte ch76data[] = {
0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
};
static const BitmapCharRec ch76 = {8,14,-1,0,10,ch76data};
/* char: 0x4b 'K' */
static const GLubyte ch75data[] = {
0xc0,0x70,0xc0,0xe0,0xc1,0xc0,0xc3,0x80,0xc7,0x0,0xce,0x0,0xfc,0x0,0xf8,0x0,
0xdc,0x0,0xce,0x0,0xc7,0x0,0xc3,0x80,0xc1,0xc0,0xc0,0xe0,
};
static const BitmapCharRec ch75 = {12,14,-1,0,13,ch75data};
/* char: 0x4a 'J' */
static const GLubyte ch74data[] = {
0x3c,0x7e,0xe7,0xc3,0xc3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,
};
static const BitmapCharRec ch74 = {8,14,-1,0,10,ch74data};
/* char: 0x49 'I' */
static const GLubyte ch73data[] = {
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
};
static const BitmapCharRec ch73 = {2,14,-2,0,6,ch73data};
/* char: 0x48 'H' */
static const GLubyte ch72data[] = {
0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xff,0xe0,0xff,0xe0,
0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
};
static const BitmapCharRec ch72 = {11,14,-1,0,13,ch72data};
/* char: 0x47 'G' */
static const GLubyte ch71data[] = {
0xf,0xb0,0x3f,0xf0,0x70,0x70,0x60,0x30,0xe0,0x30,0xc1,0xf0,0xc1,0xf0,0xc0,0x0,
0xc0,0x0,0xe0,0x30,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,
};
static const BitmapCharRec ch71 = {12,14,-1,0,14,ch71data};
/* char: 0x46 'F' */
static const GLubyte ch70data[] = {
0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,
};
static const BitmapCharRec ch70 = {9,14,-1,0,11,ch70data};
/* char: 0x45 'E' */
static const GLubyte ch69data[] = {
0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,
};
static const BitmapCharRec ch69 = {9,14,-1,0,11,ch69data};
/* char: 0x44 'D' */
static const GLubyte ch68data[] = {
0xff,0x0,0xff,0x80,0xc1,0xc0,0xc0,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
0xc0,0x60,0xc0,0x60,0xc0,0xc0,0xc1,0xc0,0xff,0x80,0xff,0x0,
};
static const BitmapCharRec ch68 = {11,14,-1,0,13,ch68data};
/* char: 0x43 'C' */
static const GLubyte ch67data[] = {
0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
0xc0,0x0,0xe0,0x0,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,
};
static const BitmapCharRec ch67 = {12,14,-1,0,14,ch67data};
/* char: 0x42 'B' */
static const GLubyte ch66data[] = {
0xff,0x80,0xff,0xc0,0xc0,0xe0,0xc0,0x60,0xc0,0x60,0xc0,0xe0,0xff,0xc0,0xff,0x80,
0xc1,0x80,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0xff,0x80,0xff,0x0,
};
static const BitmapCharRec ch66 = {11,14,-1,0,13,ch66data};
/* char: 0x41 'A' */
static const GLubyte ch65data[] = {
0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,
};
static const BitmapCharRec ch65 = {12,14,0,0,12,ch65data};
/* char: 0x40 '@' */
static const GLubyte ch64data[] = {
0x7,0xe0,0x1f,0xf0,0x38,0x0,0x70,0x0,0x67,0x70,0xcf,0xf8,0xcc,0xcc,0xcc,0x66,
0xcc,0x66,0xcc,0x63,0xc6,0x33,0x67,0x73,0x63,0xb3,0x30,0x6,0x1c,0xe,0xf,0xfc,
0x3,0xf0,
};
static const BitmapCharRec ch64 = {16,17,-1,3,18,ch64data};
/* char: 0x3f '?' */
static const GLubyte ch63data[] = {
0x30,0x30,0x0,0x0,0x30,0x30,0x30,0x38,0x1c,0xe,0xc6,0xc6,0xfe,0x7c,
};
static const BitmapCharRec ch63 = {7,14,-1,0,10,ch63data};
/* char: 0x3e '>' */
static const GLubyte ch62data[] = {
0xc0,0xf0,0x3c,0xe,0x3,0xe,0x3c,0xf0,0xc0,
};
static const BitmapCharRec ch62 = {8,9,-1,0,10,ch62data};
/* char: 0x3d '=' */
static const GLubyte ch61data[] = {
0xfe,0xfe,0x0,0x0,0xfe,0xfe,
};
static const BitmapCharRec ch61 = {7,6,-2,-2,11,ch61data};
/* char: 0x3c '<' */
static const GLubyte ch60data[] = {
0x3,0xf,0x3c,0x70,0xc0,0x70,0x3c,0xf,0x3,
};
static const BitmapCharRec ch60 = {8,9,-1,0,10,ch60data};
/* char: 0x3b ';' */
static const GLubyte ch59data[] = {
0x80,0x40,0x40,0xc0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0xc0,
};
static const BitmapCharRec ch59 = {2,13,-1,3,5,ch59data};
/* char: 0x3a ':' */
static const GLubyte ch58data[] = {
0xc0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0xc0,
};
static const BitmapCharRec ch58 = {2,10,-1,0,5,ch58data};
/* char: 0x39 '9' */
static const GLubyte ch57data[] = {
0x7c,0xfe,0xc6,0x3,0x3,0x3b,0x7f,0xc3,0xc3,0xc3,0xc7,0x7e,0x3c,
};
static const BitmapCharRec ch57 = {8,13,-1,0,10,ch57data};
/* char: 0x38 '8' */
static const GLubyte ch56data[] = {
0x3c,0x7e,0xe7,0xc3,0xc3,0x66,0x7e,0x66,0xc3,0xc3,0xe7,0x7e,0x3c,
};
static const BitmapCharRec ch56 = {8,13,-1,0,10,ch56data};
/* char: 0x37 '7' */
static const GLubyte ch55data[] = {
0x60,0x60,0x30,0x30,0x30,0x18,0x18,0xc,0xc,0x6,0x3,0xff,0xff,
};
static const BitmapCharRec ch55 = {8,13,-1,0,10,ch55data};
/* char: 0x36 '6' */
static const GLubyte ch54data[] = {
0x3c,0x7e,0xe3,0xc3,0xc3,0xc3,0xfe,0xdc,0xc0,0xc0,0x63,0x7f,0x3c,
};
static const BitmapCharRec ch54 = {8,13,-1,0,10,ch54data};
/* char: 0x35 '5' */
static const GLubyte ch53data[] = {
0x7c,0xfe,0xc7,0xc3,0x3,0x3,0xc7,0xfe,0xfc,0xc0,0xc0,0xfe,0xfe,
};
static const BitmapCharRec ch53 = {8,13,-1,0,10,ch53data};
/* char: 0x34 '4' */
static const GLubyte ch52data[] = {
0x3,0x0,0x3,0x0,0x3,0x0,0xff,0x80,0xff,0x80,0xc3,0x0,0x63,0x0,0x33,0x0,
0x33,0x0,0x1b,0x0,0xf,0x0,0x7,0x0,0x3,0x0,
};
static const BitmapCharRec ch52 = {9,13,-1,0,10,ch52data};
/* char: 0x33 '3' */
static const GLubyte ch51data[] = {
0x3c,0x7e,0xc7,0xc3,0x3,0x7,0x1e,0x1c,0x6,0xc3,0xc3,0x7e,0x3c,
};
static const BitmapCharRec ch51 = {8,13,-1,0,10,ch51data};
/* char: 0x32 '2' */
static const GLubyte ch50data[] = {
0xff,0xff,0xc0,0xe0,0x70,0x38,0x1c,0xe,0x7,0x3,0xc3,0xfe,0x3c,
};
static const BitmapCharRec ch50 = {8,13,-1,0,10,ch50data};
/* char: 0x31 '1' */
static const GLubyte ch49data[] = {
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0xf8,0x18,
};
static const BitmapCharRec ch49 = {5,13,-2,0,10,ch49data};
/* char: 0x30 '0' */
static const GLubyte ch48data[] = {
0x3c,0x7e,0x66,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x66,0x7e,0x3c,
};
static const BitmapCharRec ch48 = {8,13,-1,0,10,ch48data};
/* char: 0x2f '/' */
static const GLubyte ch47data[] = {
0xc0,0xc0,0x40,0x40,0x60,0x60,0x20,0x20,0x30,0x30,0x10,0x10,0x18,0x18,
};
static const BitmapCharRec ch47 = {5,14,0,0,5,ch47data};
/* char: 0x2e '.' */
static const GLubyte ch46data[] = {
0xc0,0xc0,
};
static const BitmapCharRec ch46 = {2,2,-1,0,5,ch46data};
/* char: 0x2d '-' */
static const GLubyte ch45data[] = {
0xff,0xff,
};
static const BitmapCharRec ch45 = {8,2,-1,-4,11,ch45data};
/* char: 0x2c ',' */
static const GLubyte ch44data[] = {
0x80,0x40,0x40,0xc0,0xc0,
};
static const BitmapCharRec ch44 = {2,5,-1,3,5,ch44data};
/* char: 0x2b '+' */
static const GLubyte ch43data[] = {
0x18,0x18,0x18,0x18,0xff,0xff,0x18,0x18,0x18,0x18,
};
static const BitmapCharRec ch43 = {8,10,-1,0,10,ch43data};
/* char: 0x2a '*' */
static const GLubyte ch42data[] = {
0x88,0x70,0x70,0xf8,0x20,0x20,
};
static const BitmapCharRec ch42 = {5,6,-1,-8,7,ch42data};
/* char: 0x29 ')' */
static const GLubyte ch41data[] = {
0x80,0xc0,0x60,0x60,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x60,0x60,
0xc0,0x80,
};
static const BitmapCharRec ch41 = {4,18,-1,4,6,ch41data};
/* char: 0x28 '(' */
static const GLubyte ch40data[] = {
0x10,0x30,0x60,0x60,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x60,0x60,
0x30,0x10,
};
static const BitmapCharRec ch40 = {4,18,-1,4,6,ch40data};
/* char: 0x27 ''' */
static const GLubyte ch39data[] = {
0x80,0x40,0x40,0xc0,0xc0,
};
static const BitmapCharRec ch39 = {2,5,-1,-9,4,ch39data};
/* char: 0x26 '&' */
static const GLubyte ch38data[] = {
0x3c,0x70,0x7e,0xe0,0xe7,0xc0,0xc3,0x80,0xc3,0xc0,0xc6,0xc0,0xee,0xc0,0x7c,0x0,
0x3c,0x0,0x66,0x0,0x66,0x0,0x7e,0x0,0x3c,0x0,
};
static const BitmapCharRec ch38 = {12,13,-1,0,13,ch38data};
/* char: 0x25 '%' */
static const GLubyte ch37data[] = {
0x18,0x78,0x18,0xfc,0xc,0xcc,0xc,0xcc,0x6,0xfc,0x6,0x78,0x3,0x0,0x7b,0x0,
0xfd,0x80,0xcd,0x80,0xcc,0xc0,0xfc,0xc0,0x78,0x60,
};
static const BitmapCharRec ch37 = {14,13,-1,0,16,ch37data};
/* char: 0x24 '$' */
static const GLubyte ch36data[] = {
0x8,0x0,0x8,0x0,0x3e,0x0,0x7f,0x0,0xeb,0x80,0xc9,0x80,0x9,0x80,0xf,0x0,
0x3e,0x0,0x78,0x0,0xe8,0x0,0xc8,0x0,0xcb,0x0,0x7f,0x0,0x3e,0x0,0x8,0x0,
};
static const BitmapCharRec ch36 = {9,16,-1,2,10,ch36data};
/* char: 0x23 '#' */
static const GLubyte ch35data[] = {
0x24,0x0,0x24,0x0,0x24,0x0,0xff,0x80,0xff,0x80,0x12,0x0,0x12,0x0,0x12,0x0,
0x7f,0xc0,0x7f,0xc0,0x9,0x0,0x9,0x0,0x9,0x0,
};
static const BitmapCharRec ch35 = {10,13,0,0,10,ch35data};
/* char: 0x22 '"' */
static const GLubyte ch34data[] = {
0x90,0x90,0xd8,0xd8,0xd8,
};
static const BitmapCharRec ch34 = {5,5,0,-9,5,ch34data};
/* char: 0x21 '!' */
static const GLubyte ch33data[] = {
0xc0,0xc0,0x0,0x0,0x80,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
};
static const BitmapCharRec ch33 = {2,14,-2,0,6,ch33data};
/* char: 0x20 ' ' */
#ifdef _WIN32
/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
a height or width of zero does not advance the raster position
as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
static const GLubyte ch32data[] = { 0x0 };
static const BitmapCharRec ch32 = {1,1,0,0,5,ch32data};
#else
static const BitmapCharRec ch32 = {0,0,0,0,5,0};
#endif
static const BitmapCharRec * const chars[] = {
&ch32,
&ch33,
&ch34,
&ch35,
&ch36,
&ch37,
&ch38,
&ch39,
&ch40,
&ch41,
&ch42,
&ch43,
&ch44,
&ch45,
&ch46,
&ch47,
&ch48,
&ch49,
&ch50,
&ch51,
&ch52,
&ch53,
&ch54,
&ch55,
&ch56,
&ch57,
&ch58,
&ch59,
&ch60,
&ch61,
&ch62,
&ch63,
&ch64,
&ch65,
&ch66,
&ch67,
&ch68,
&ch69,
&ch70,
&ch71,
&ch72,
&ch73,
&ch74,
&ch75,
&ch76,
&ch77,
&ch78,
&ch79,
&ch80,
&ch81,
&ch82,
&ch83,
&ch84,
&ch85,
&ch86,
&ch87,
&ch88,
&ch89,
&ch90,
&ch91,
&ch92,
&ch93,
&ch94,
&ch95,
&ch96,
&ch97,
&ch98,
&ch99,
&ch100,
&ch101,
&ch102,
&ch103,
&ch104,
&ch105,
&ch106,
&ch107,
&ch108,
&ch109,
&ch110,
&ch111,
&ch112,
&ch113,
&ch114,
&ch115,
&ch116,
&ch117,
&ch118,
&ch119,
&ch120,
&ch121,
&ch122,
&ch123,
&ch124,
&ch125,
&ch126,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
&ch160,
&ch161,
&ch162,
&ch163,
&ch164,
&ch165,
&ch166,
&ch167,
&ch168,
&ch169,
&ch170,
&ch171,
&ch172,
&ch173,
&ch174,
&ch175,
&ch176,
&ch177,
&ch178,
&ch179,
&ch180,
&ch181,
&ch182,
&ch183,
&ch184,
&ch185,
&ch186,
&ch187,
&ch188,
&ch189,
&ch190,
&ch191,
&ch192,
&ch193,
&ch194,
&ch195,
&ch196,
&ch197,
&ch198,
&ch199,
&ch200,
&ch201,
&ch202,
&ch203,
&ch204,
&ch205,
&ch206,
&ch207,
&ch208,
&ch209,
&ch210,
&ch211,
&ch212,
&ch213,
&ch214,
&ch215,
&ch216,
&ch217,
&ch218,
&ch219,
&ch220,
&ch221,
&ch222,
&ch223,
&ch224,
&ch225,
&ch226,
&ch227,
&ch228,
&ch229,
&ch230,
&ch231,
&ch232,
&ch233,
&ch234,
&ch235,
&ch236,
&ch237,
&ch238,
&ch239,
&ch240,
&ch241,
&ch242,
&ch243,
&ch244,
&ch245,
&ch246,
&ch247,
&ch248,
&ch249,
&ch250,
&ch251,
&ch252,
&ch253,
&ch254,
&ch255,
};
#if !defined(__IBMCPP__)
const
#endif
BitmapFontRec glutBitmapHelvetica18 = {
"-adobe-helvetica-medium-r-normal--18-180-75-75-p-98-iso8859-1",
224,
32,
chars
};
| 22.789584
| 80
| 0.70159
|
OS2World
|
8fef98cbec6853bbc7c0366cdf4e838fb3a3b313
| 20,883
|
cpp
|
C++
|
src/dasm/disassembler.cpp
|
RupertAvery/et3400
|
243c0ed407bee20f43e2f1c528f10cc6ffb12664
|
[
"BSD-3-Clause"
] | 3
|
2020-11-06T22:30:32.000Z
|
2021-12-24T06:30:32.000Z
|
src/dasm/disassembler.cpp
|
RupertAvery/et3400
|
243c0ed407bee20f43e2f1c528f10cc6ffb12664
|
[
"BSD-3-Clause"
] | null | null | null |
src/dasm/disassembler.cpp
|
RupertAvery/et3400
|
243c0ed407bee20f43e2f1c528f10cc6ffb12664
|
[
"BSD-3-Clause"
] | 1
|
2021-12-24T06:30:38.000Z
|
2021-12-24T06:30:38.000Z
|
#include "disassembler.h"
const char Disassembler::op_name_str_orig[128][8] =
{
"aba", "abx", "adca", "adcb", "adda", "addb", "addd", "aim",
"anda", "andb", "asl", "asla", "aslb", "asld", "asr", "asra",
"asrb", "bcc", "bcs", "beq", "bge", "bgt", "bhi", "bita",
"bitb", "ble", "bls", "blt", "bmi", "bne", "bpl", "bra",
"brn", "bsr", "bvc", "bvs", "cba", "clc", "cli", "clr",
"clra", "clrb", "clv", "cmpa", "cmpb", "cmpx", "com", "coma",
"comb", "daa", "dec", "deca", "decb", "des", "dex", "eim",
"eora", "eorb", "illegal", "inc", "inca", "incb", "ins", "inx",
"jmp", "jsr", "lda", "ldb", "ldd", "lds", "ldx", "lsr",
"lsra", "lsrb", "lsrd", "mul", "neg", "nega", "negb", "nop",
"oim", "ora", "orb", "psha", "pshb", "pshx", "pula", "pulb",
"pulx", "rol", "rola", "rolb", "ror", "rora", "rorb", "rti",
"rts", "sba", "sbca", "sbcb", "sec", "sev", "sta", "stb",
"std", "sei", "sts", "stx", "suba", "subb", "subd", "swi",
"wai", "tab", "tap", "tba", "tim", "tpa", "tst", "tsta",
"tstb", "tsx", "txs", "asx1", "asx2", "xgdx", "addx", "adcx"};
const char Disassembler::op_name_str[129][8] =
{
"aba", "abx", "adca", "adcb", "adda", "addb", "addd", "aim",
"anda", "andb", "asl", "asla", "aslb", "asld", "asr", "asra",
"asrb", "bcc", "bcs", "beq", "bge", "bgt", "bhi", "bita",
"bitb", "ble", "bls", "blt", "bmi", "bne", "bpl", "bra",
"brn", "bsr", "bvc", "bvs", "cba", "clc", "cli", "clr",
"clra", "clrb", "clv", "cmpa", "cmpb", "cpx", "com", "coma",
"comb", "daa", "dec", "deca", "decb", "des", "dex", "eim",
"eora", "eorb", "illegal", "inc", "inca", "incb", "ins", "inx",
"jmp", "jsr", "ldaa", "ldab", "ldd", "lds", "ldx", "lsr",
"lsra", "lsrb", "lsrd", "mul", "neg", "nega", "negb", "nop",
"oim", "oraa", "orab", "psha", "pshb", "pshx", "pula", "pulb",
"pulx", "rol", "rola", "rolb", "ror", "rora", "rorb", "rti",
"rts", "sba", "sbca", "sbcb", "sec", "sev", "staa", "stab",
"std", "sei", "sts", "stx", "suba", "subb", "subd", "swi",
"wai", "tab", "tap", "tba", "tim", "tpa", "tst", "tsta",
"tstb", "tsx", "txs", "asx1", "asx2", "xgdx", "addx", "adcx",
"nba"};
/*
* This table defines the opcodes:
* byte meaning
* 0 token (menmonic)
* 1 addressing mode
* 2 invalid opcode for 1:6800/6802/6808, 2:6801/6803, 4:HD63701
*/
int Disassembler::table[258][3] = {
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::nop, Disassembler::inh, 0},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::ill, Disassembler::inh, 7},
/* 00 */
{Disassembler::lsrd, Disassembler::inh, 1},
{Disassembler::asld, Disassembler::inh, 1},
{Disassembler::tap, Disassembler::inh, 0},
{Disassembler::tpa, Disassembler::inh, 0},
{Disassembler::inx, Disassembler::inh, 0},
{Disassembler::dex, Disassembler::inh, 0},
{Disassembler::clv, Disassembler::inh, 0},
{Disassembler::sev, Disassembler::inh, 0},
{Disassembler::clc, Disassembler::inh, 0},
{Disassembler::sec, Disassembler::inh, 0},
{Disassembler::cli, Disassembler::inh, 0},
{Disassembler::sei, Disassembler::inh, 0},
{Disassembler::sba, Disassembler::inh, 0},
{Disassembler::cba, Disassembler::inh, 0},
{Disassembler::asx1, Disassembler::sx1, 1},
{Disassembler::asx2, Disassembler::sx1, 1},
/* 10 */
{Disassembler::nba, Disassembler::inh, 7},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::tab, Disassembler::inh, 0},
{Disassembler::tba, Disassembler::inh, 0},
{Disassembler::xgdx, Disassembler::inh, 3},
{Disassembler::daa, Disassembler::inh, 0},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::aba, Disassembler::inh, 0},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::bra, Disassembler::rel, 0},
{Disassembler::brn, Disassembler::rel, 1},
{Disassembler::bhi, Disassembler::rel, 0},
{Disassembler::bls, Disassembler::rel, 0},
/* 20 */
{Disassembler::bcc, Disassembler::rel, 0},
{Disassembler::bcs, Disassembler::rel, 0},
{Disassembler::bne, Disassembler::rel, 0},
{Disassembler::beq, Disassembler::rel, 0},
{Disassembler::bvc, Disassembler::rel, 0},
{Disassembler::bvs, Disassembler::rel, 0},
{Disassembler::bpl, Disassembler::rel, 0},
{Disassembler::bmi, Disassembler::rel, 0},
{Disassembler::bge, Disassembler::rel, 0},
{Disassembler::blt, Disassembler::rel, 0},
{Disassembler::bgt, Disassembler::rel, 0},
{Disassembler::ble, Disassembler::rel, 0},
{Disassembler::tsx, Disassembler::inh, 0},
{Disassembler::ins, Disassembler::inh, 0},
{Disassembler::pula, Disassembler::inh, 0},
{Disassembler::pulb, Disassembler::inh, 0},
/* 30 */
{Disassembler::des, Disassembler::inh, 0},
{Disassembler::txs, Disassembler::inh, 0},
{Disassembler::psha, Disassembler::inh, 0},
{Disassembler::pshb, Disassembler::inh, 0},
{Disassembler::pulx, Disassembler::inh, 1},
{Disassembler::rts, Disassembler::inh, 0},
{Disassembler::abx, Disassembler::inh, 1},
{Disassembler::rti, Disassembler::inh, 0},
{Disassembler::pshx, Disassembler::inh, 1},
{Disassembler::mul, Disassembler::inh, 1},
{Disassembler::wai, Disassembler::inh, 0},
{Disassembler::swi, Disassembler::inh, 0},
{Disassembler::nega, Disassembler::inh, 0},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::coma, Disassembler::inh, 0},
/* 40 */
{Disassembler::lsra, Disassembler::inh, 0},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::rora, Disassembler::inh, 0},
{Disassembler::asra, Disassembler::inh, 0},
{Disassembler::asla, Disassembler::inh, 0},
{Disassembler::rola, Disassembler::inh, 0},
{Disassembler::deca, Disassembler::inh, 0},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::inca, Disassembler::inh, 0},
{Disassembler::tsta, Disassembler::inh, 0},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::clra, Disassembler::inh, 0},
{Disassembler::negb, Disassembler::inh, 0},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::comb, Disassembler::inh, 0},
/* 50 */
{Disassembler::lsrb, Disassembler::inh, 0},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::rorb, Disassembler::inh, 0},
{Disassembler::asrb, Disassembler::inh, 0},
{Disassembler::aslb, Disassembler::inh, 0},
{Disassembler::rolb, Disassembler::inh, 0},
{Disassembler::decb, Disassembler::inh, 0},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::incb, Disassembler::inh, 0},
{Disassembler::tstb, Disassembler::inh, 0},
{Disassembler::ill, Disassembler::inh, 7},
{Disassembler::clrb, Disassembler::inh, 0},
{Disassembler::neg, Disassembler::idx, 0},
{Disassembler::aim, Disassembler::imx, 3},
{Disassembler::oim, Disassembler::imx, 3},
{Disassembler::com, Disassembler::idx, 0},
/* 60 */
{Disassembler::lsr, Disassembler::idx, 0},
{Disassembler::eim, Disassembler::imx, 3},
{Disassembler::ror, Disassembler::idx, 0},
{Disassembler::asr, Disassembler::idx, 0},
{Disassembler::asl, Disassembler::idx, 0},
{Disassembler::rol, Disassembler::idx, 0},
{Disassembler::dec, Disassembler::idx, 0},
{Disassembler::tim, Disassembler::imx, 3},
{Disassembler::inc, Disassembler::idx, 0},
{Disassembler::tst, Disassembler::idx, 0},
{Disassembler::jmp, Disassembler::idx, 0},
{Disassembler::clr, Disassembler::idx, 0},
{Disassembler::neg, Disassembler::ext, 0},
{Disassembler::aim, Disassembler::imd, 3},
{Disassembler::oim, Disassembler::imd, 3},
{Disassembler::com, Disassembler::ext, 0},
/* 70 */
{Disassembler::lsr, Disassembler::ext, 0},
{Disassembler::eim, Disassembler::imd, 3},
{Disassembler::ror, Disassembler::ext, 0},
{Disassembler::asr, Disassembler::ext, 0},
{Disassembler::asl, Disassembler::ext, 0},
{Disassembler::rol, Disassembler::ext, 0},
{Disassembler::dec, Disassembler::ext, 0},
{Disassembler::tim, Disassembler::imd, 3},
{Disassembler::inc, Disassembler::ext, 0},
{Disassembler::tst, Disassembler::ext, 0},
{Disassembler::jmp, Disassembler::ext, 0},
{Disassembler::clr, Disassembler::ext, 0},
{Disassembler::suba, Disassembler::imb, 0},
{Disassembler::cmpa, Disassembler::imb, 0},
{Disassembler::sbca, Disassembler::imb, 0},
{Disassembler::subd, Disassembler::imw, 1},
/* 80 */
{Disassembler::anda, Disassembler::imb, 0},
{Disassembler::bita, Disassembler::imb, 0},
{Disassembler::lda, Disassembler::imb, 0},
{Disassembler::sta, Disassembler::imb, 7},
{Disassembler::eora, Disassembler::imb, 0},
{Disassembler::adca, Disassembler::imb, 0},
{Disassembler::ora, Disassembler::imb, 0},
{Disassembler::adda, Disassembler::imb, 0},
{Disassembler::cmpx, Disassembler::imw, 0},
{Disassembler::bsr, Disassembler::rel, 0},
{Disassembler::lds, Disassembler::imw, 0},
{Disassembler::sts, Disassembler::imw, 7},
{Disassembler::suba, Disassembler::dir, 0},
{Disassembler::cmpa, Disassembler::dir, 0},
{Disassembler::sbca, Disassembler::dir, 0},
{Disassembler::subd, Disassembler::dir, 1},
/* 90 */
{Disassembler::anda, Disassembler::dir, 0},
{Disassembler::bita, Disassembler::dir, 0},
{Disassembler::lda, Disassembler::dir, 0},
{Disassembler::sta, Disassembler::dir, 0},
{Disassembler::eora, Disassembler::dir, 0},
{Disassembler::adca, Disassembler::dir, 0},
{Disassembler::ora, Disassembler::dir, 0},
{Disassembler::adda, Disassembler::dir, 0},
{Disassembler::cmpx, Disassembler::dir, 0},
{Disassembler::jsr, Disassembler::dir, 1},
{Disassembler::lds, Disassembler::dir, 0},
{Disassembler::sts, Disassembler::dir, 0},
{Disassembler::suba, Disassembler::idx, 0},
{Disassembler::cmpa, Disassembler::idx, 0},
{Disassembler::sbca, Disassembler::idx, 0},
{Disassembler::subd, Disassembler::idx, 1},
/* a0 */
{Disassembler::anda, Disassembler::idx, 0},
{Disassembler::bita, Disassembler::idx, 0},
{Disassembler::lda, Disassembler::idx, 0},
{Disassembler::sta, Disassembler::idx, 0},
{Disassembler::eora, Disassembler::idx, 0},
{Disassembler::adca, Disassembler::idx, 0},
{Disassembler::ora, Disassembler::idx, 0},
{Disassembler::adda, Disassembler::idx, 0},
{Disassembler::cmpx, Disassembler::idx, 0},
{Disassembler::jsr, Disassembler::idx, 0},
{Disassembler::lds, Disassembler::idx, 0},
{Disassembler::sts, Disassembler::idx, 0},
{Disassembler::suba, Disassembler::ext, 0},
{Disassembler::cmpa, Disassembler::ext, 0},
{Disassembler::sbca, Disassembler::ext, 0},
{Disassembler::subd, Disassembler::ext, 1},
/* b0 */
{Disassembler::anda, Disassembler::ext, 0},
{Disassembler::bita, Disassembler::ext, 0},
{Disassembler::lda, Disassembler::ext, 0},
{Disassembler::sta, Disassembler::ext, 0},
{Disassembler::eora, Disassembler::ext, 0},
{Disassembler::adca, Disassembler::ext, 0},
{Disassembler::ora, Disassembler::ext, 0},
{Disassembler::adda, Disassembler::ext, 0},
{Disassembler::cmpx, Disassembler::ext, 0},
{Disassembler::jsr, Disassembler::ext, 0},
{Disassembler::lds, Disassembler::ext, 0},
{Disassembler::sts, Disassembler::ext, 0},
{Disassembler::subb, Disassembler::imb, 0},
{Disassembler::cmpb, Disassembler::imb, 0},
{Disassembler::sbcb, Disassembler::imb, 0},
{Disassembler::addd, Disassembler::imw, 1},
/* c0 */
{Disassembler::andb, Disassembler::imb, 0},
{Disassembler::bitb, Disassembler::imb, 0},
{Disassembler::ldb, Disassembler::imb, 0},
{Disassembler::stb, Disassembler::imb, 7},
{Disassembler::eorb, Disassembler::imb, 0},
{Disassembler::adcb, Disassembler::imb, 0},
{Disassembler::orb, Disassembler::imb, 0},
{Disassembler::addb, Disassembler::imb, 0},
{Disassembler::ldd, Disassembler::imw, 1},
{Disassembler::_std, Disassembler::imw, 1},
{Disassembler::ldx, Disassembler::imw, 0},
{Disassembler::stx, Disassembler::imw, 7},
{Disassembler::subb, Disassembler::dir, 0},
{Disassembler::cmpb, Disassembler::dir, 0},
{Disassembler::sbcb, Disassembler::dir, 0},
{Disassembler::addd, Disassembler::dir, 1},
/* d0 */
{Disassembler::andb, Disassembler::dir, 0},
{Disassembler::bitb, Disassembler::dir, 0},
{Disassembler::ldb, Disassembler::dir, 0},
{Disassembler::stb, Disassembler::dir, 0},
{Disassembler::eorb, Disassembler::dir, 0},
{Disassembler::adcb, Disassembler::dir, 0},
{Disassembler::orb, Disassembler::dir, 0},
{Disassembler::addb, Disassembler::dir, 0},
{Disassembler::ldd, Disassembler::dir, 1},
{Disassembler::_std, Disassembler::dir, 1},
{Disassembler::ldx, Disassembler::dir, 0},
{Disassembler::stx, Disassembler::dir, 0},
{Disassembler::subb, Disassembler::idx, 0},
{Disassembler::cmpb, Disassembler::idx, 0},
{Disassembler::sbcb, Disassembler::idx, 0},
{Disassembler::addd, Disassembler::idx, 1},
/* e0 */
{Disassembler::andb, Disassembler::idx, 0},
{Disassembler::bitb, Disassembler::idx, 0},
{Disassembler::ldb, Disassembler::idx, 0},
{Disassembler::stb, Disassembler::idx, 0},
{Disassembler::eorb, Disassembler::idx, 0},
{Disassembler::adcb, Disassembler::idx, 0},
{Disassembler::orb, Disassembler::idx, 0},
{Disassembler::addb, Disassembler::idx, 0},
{Disassembler::ldd, Disassembler::idx, 1},
{Disassembler::_std, Disassembler::idx, 1},
{Disassembler::ldx, Disassembler::idx, 0},
{Disassembler::stx, Disassembler::idx, 0},
{Disassembler::subb, Disassembler::ext, 0},
{Disassembler::cmpb, Disassembler::ext, 0},
{Disassembler::sbcb, Disassembler::ext, 0},
{Disassembler::addd, Disassembler::ext, 1},
/* f0 */
{Disassembler::andb, Disassembler::ext, 0},
{Disassembler::bitb, Disassembler::ext, 0},
{Disassembler::ldb, Disassembler::ext, 0},
{Disassembler::stb, Disassembler::ext, 0},
{Disassembler::eorb, Disassembler::ext, 0},
{Disassembler::adcb, Disassembler::ext, 0},
{Disassembler::orb, Disassembler::ext, 0},
{Disassembler::addb, Disassembler::ext, 0},
{Disassembler::ldd, Disassembler::ext, 1},
{Disassembler::_std, Disassembler::ext, 1},
{Disassembler::ldx, Disassembler::ext, 0},
{Disassembler::stx, Disassembler::ext, 0},
/* extra instruction $fc for NSC-8105 */
{Disassembler::addx, Disassembler::ext, 0},
/* extra instruction $ec for NSC-8105 */
{Disassembler::adcx, Disassembler::imb, 0}};
int Disassembler::SIGNED(int b)
{
return ((int)((b & 0x80) == 0x80 ? b | 0xffffff00 : b));
}
bool Disassembler::IsSubroutine(int opcode)
{
return opcode == bsr || opcode == jsr;
}
bool Disassembler::IsReturn(int opcode)
{
return opcode == rti || opcode == rts;
}
DasmResult Disassembler::disassemble(uint8_t *memory, int address)
{
static char *instruction = (char *)malloc(8);
static char *operand = (char *)malloc(8);
int flags = 0;
int invalid_mask;
int code = memory[0] & 0xff;
int opcode, args, invalid;
invalid_mask = 1;
opcode = table[code][0];
args = table[code][1];
invalid = table[code][2];
if (IsSubroutine(opcode))
flags = DASMFLAG_STEP_OVER;
else if (IsReturn(opcode))
flags = DASMFLAG_STEP_OUT;
bool is_illegal = false;
// char *operand = nullptr;
// char *instruction = nullptr;
int byteLength = 0;
if ((invalid & invalid_mask) == invalid_mask) /* invalid for this cpu type ? */
{
return DasmResult{true, nullptr, nullptr, flags | DASMFLAG_SUPPORTED, 1};
}
sprintf(instruction, "%-4s", op_name_str[opcode]);
// int byteLength = 0;
sprintf(operand, "");
switch (args)
{
case rel: /* relative */
sprintf(operand, "$%04X", address + SIGNED(memory[1]) + 2);
byteLength = 2;
break;
case imb: /* immediate (byte) */
sprintf(operand, "#$%02X", memory[1]);
byteLength = 2;
break;
case imw: /* immediate (word) */
sprintf(operand, "#$%04X", (memory[1] << 8) + memory[2]);
byteLength = 3;
break;
case idx: /* indexed + byte offset */
sprintf(operand, "$%02X,x", memory[1]);
byteLength = 2;
break;
case imx: /* immediate, indexed + byte offset */
sprintf(operand, "#$%02X,(x+$%02X)", memory[1], memory[2]);
byteLength = 3;
break;
case dir: /* direct address */
sprintf(operand, "$%02X", memory[1]);
byteLength = 2;
break;
case imd: /* immediate, direct address */
sprintf(operand, "#$%02X,$%02X", memory[1], memory[2]);
byteLength = 3;
break;
case ext: /* extended address */
sprintf(operand, "$%04X", (memory[1] << 8) + memory[2]);
byteLength = 3;
break;
case sx1: /* byte from address (s + 1) */
sprintf(operand, "(s+1)");
byteLength = 1;
break;
default:
byteLength = 1;
break;
}
return DasmResult{
is_illegal,
operand,
instruction,
flags | DASMFLAG_SUPPORTED,
byteLength};
// return new DasmResult(){
// Instruction = instruction,
// Operand = operand,
// ByteLength = byteLength,
// Flags = flags | DASMFLAG_SUPPORTED};
}
// static int Disassemble(int[] memory, int pc, ref string buf)
// {
// int flags = 0;
// int invalid_mask;
// int code = memory[pc] & 0xff;
// int opcode, args, invalid;
// invalid_mask = 1;
// opcode = table[code][0];
// args = table[code][1];
// invalid = table[code][2];
// if (IsSubroutine(opcode))
// flags = DASMFLAG_STEP_OVER;
// else if (IsReturn(opcode))
// flags = DASMFLAG_STEP_OUT;
// if ((invalid & invalid_mask) == invalid_mask) /* invalid for this cpu type ? */
// {
// buf += "illegal";
// return 1 | flags | DASMFLAG_SUPPORTED;
// }
// buf += string.Format("{0,-4} ", op_name_str[opcode]);
// switch (args)
// {
// case rel: /* relative */
// buf += string.Format("${0:X4}", pc + SIGNED(memory[pc + 1]) + 2);
// return 2 | flags | DASMFLAG_SUPPORTED;
// case imb: /* immediate (byte) */
// buf += string.Format("#${0:X2}", memory[pc + 1]);
// return 2 | flags | DASMFLAG_SUPPORTED;
// case imw: /* immediate (word) */
// buf += string.Format("#${0:X4}", (memory[pc + 1] << 8) + memory[pc + 2]);
// return 3 | flags | DASMFLAG_SUPPORTED;
// case idx: /* indexed + byte offset */
// buf += string.Format("${0:X2},x", memory[pc + 1]);
// return 2 | flags | DASMFLAG_SUPPORTED;
// case imx: /* immediate, indexed + byte offset */
// buf += string.Format("#${0:X2},(x+${1:X2})", memory[pc + 1], memory[pc + 2]);
// return 3 | flags | DASMFLAG_SUPPORTED;
// case dir: /* direct address */
// buf += string.Format("${0:X2}", memory[pc + 1]);
// return 2 | flags | DASMFLAG_SUPPORTED;
// case imd: /* immediate, direct address */
// buf += string.Format("#${0:X2},${1:X2}", memory[pc + 1], memory[pc + 2]);
// return 3 | flags | DASMFLAG_SUPPORTED;
// case ext: /* extended address */
// buf += string.Format("${0:X4}", (memory[pc + 1] << 8) + memory[pc + 2]);
// return 3 | flags | DASMFLAG_SUPPORTED;
// case sx1: /* byte from address (s + 1) */
// buf += string.Format("(s+1)");
// return 1 | flags | DASMFLAG_SUPPORTED;
// default:
// return 1 | flags | DASMFLAG_SUPPORTED;
// }
// }
// public
// static void SelfTest()
// {
// for (int i = 0; i < table.Length; i++)
// {
// var entry = table[i];
// //if ((entry[2] & 1) == entry[2])
// //{
// if (!((IList)valid6800opcodes).Contains(i))
// {
// // this is an invalid opcode
// Debug.WriteLine("{0:X2}: {1}", i, entry[2]);
// }
// //}
// }
// }
| 40.866928
| 92
| 0.586266
|
RupertAvery
|
8ffb96fc3fd94c26cbf553f6f4c866a95d552959
| 2,867
|
cpp
|
C++
|
src/EntitySystem/EntitySystem.cpp
|
dritory/Cog6
|
a73afc1edbb5e9c0b9f8d97490f65e48aa167a79
|
[
"MIT"
] | null | null | null |
src/EntitySystem/EntitySystem.cpp
|
dritory/Cog6
|
a73afc1edbb5e9c0b9f8d97490f65e48aa167a79
|
[
"MIT"
] | null | null | null |
src/EntitySystem/EntitySystem.cpp
|
dritory/Cog6
|
a73afc1edbb5e9c0b9f8d97490f65e48aa167a79
|
[
"MIT"
] | null | null | null |
#include "EntitySystem.h"
#include "InteractableEntity.h"
EntitySystem::EntitySystem() : m_Next(0), m_SpriteBatcher(nullptr) {
}
EntitySystem::~EntitySystem() = default;
Entity* EntitySystem::Get(const EntityId& id) {
if (id >= m_Entities.size() || !m_Entities[id]) {
std::cout << "Tried to fetch entity that did not exist" << std::endl;
return nullptr;
}
return m_Entities[id].get();
}
void EntitySystem::FixedUpdate(sf::Time elapsed) {
for (auto& it : m_Entities)
if (it != nullptr && !it->Deactivated())
it->FixedUpdate(elapsed);
cleanupEntities();
}
void EntitySystem::Update(sf::Time elapsed) {
for (auto& it : m_Entities)
if (it != nullptr && !it->Deactivated())
it->Update();
for (auto it = m_Interactables.begin(); it < m_Interactables.end(); ++it) {
auto intr = *it;
auto ent = (Entity*)intr;
for (auto it2 = it + 1; it2 < m_Interactables.end(); ++it2) {
auto intr2 = *it2;
auto ent2 = (Entity*)intr2;
if (intr->CanInteract(ent2))
intr->Interact(ent2);
if (intr2->CanInteract(ent))
intr2->Interact(ent);
}
}
}
void EntitySystem::SetBatcher(SpriteBatch& batcher) {
m_SpriteBatcher = &batcher;
}
void EntitySystem::RemoveEntity(EntityId entityId) {
auto ent = Get(entityId);
if (ent->Removed()) return;
ent->Remove();
m_EntitiesToRemove.push(entityId);
}
void EntitySystem::addInteractable(InteractableEntity* entity) {
m_Interactables.push_back(entity);
}
void EntitySystem::removeInteractable(InteractableEntity* entity) {
m_InteractablesToRemove.push(entity);
}
void EntitySystem::cleanupEntities() {
while (m_EntitiesToRemove.size() != 0) {
auto id = m_EntitiesToRemove.front(); m_EntitiesToRemove.pop();
if (m_Entities[id] != nullptr) {
m_Entities[id].reset();
m_UnusedEntityIds.push(id);
}
}
while (m_InteractablesToRemove.size() != 0) {
auto entity = m_InteractablesToRemove.front(); m_InteractablesToRemove.pop();
m_Interactables.erase(std::remove(m_Interactables.begin(), m_Interactables.end(), entity), m_Interactables.end());
}
}
EntityId EntitySystem::getNextId() {
EntityId id = !m_UnusedEntityIds.empty() ? m_UnusedEntityIds.front() : m_Next++;
if (!m_UnusedEntityIds.empty())m_UnusedEntityIds.pop();
if (id + 1 > m_Entities.size()) m_Entities.resize(id + 1);
return id;
}
void EntitySystem::draw(sf::RenderTarget& target, sf::RenderStates states) const {
if (m_SpriteBatcher == nullptr) {
for (const auto& it : m_Entities)
if (it != nullptr && !it->Deactivated())
target.draw(*it, states);
}
else {
for (const auto& it : m_Entities) {
if (it == nullptr || it->Deactivated()) continue;
m_SpriteBatcher->QueueObject(it.get());
}
}
}
void EntitySystem::drawGUI(sf::RenderWindow &window) {
for (const auto& it : m_Entities) {
if (it != nullptr && !it->Deactivated())
it.get()->drawGUI(window, sf::RenderStates());
}
}
| 26.302752
| 116
| 0.686432
|
dritory
|
8ffc545cbf2b83030cbe4b8ec4f2e9b26a8a9270
| 5,520
|
cpp
|
C++
|
pronto/graphics/pc/d3d12_command_queue.cpp
|
MgBag/pronto
|
c10827e094726d8dc285c3da68c9c03be42d9a32
|
[
"MIT"
] | null | null | null |
pronto/graphics/pc/d3d12_command_queue.cpp
|
MgBag/pronto
|
c10827e094726d8dc285c3da68c9c03be42d9a32
|
[
"MIT"
] | null | null | null |
pronto/graphics/pc/d3d12_command_queue.cpp
|
MgBag/pronto
|
c10827e094726d8dc285c3da68c9c03be42d9a32
|
[
"MIT"
] | null | null | null |
#include "d3d12_command_queue.h"
#include "d3d12_command_list.h"
#include <d3d12.h>
#include <cstdint>
#include <assert.h>
namespace pronto
{
namespace graphics
{
//---------------------------------------------------------------------------------------------
CommandQueue::CommandQueue(ID3D12Device2* device, D3D12_COMMAND_LIST_TYPE type) :
fence_value_(0),
command_list_type_(type),
device_(device)
{
D3D12_COMMAND_QUEUE_DESC desc = {};
desc.Type = type;
desc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL;
desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
desc.NodeMask = 0;
assert(SUCCEEDED(
device_->CreateCommandQueue(&desc, IID_PPV_ARGS(&command_q_))));
command_q_->SetName(L"command q lyf");
assert(SUCCEEDED(
device_->CreateFence(
fence_value_,
D3D12_FENCE_FLAG_NONE,
IID_PPV_ARGS(&fence_))));
fence_event_ = ::CreateEvent(NULL, FALSE, FALSE, NULL);
assert(fence_event_ && "Failed to create fence event handle.");
process_in_flight_command_lists_thread_ =
std::thread(&CommandQueue::ProccessInFlightCommandLists, this);
process_in_flight_command_lists_ = true;
}
//---------------------------------------------------------------------------------------------
CommandQueue::~CommandQueue()
{
process_in_flight_command_lists_ = false;
process_in_flight_command_lists_thread_.join();
}
//---------------------------------------------------------------------------------------------
CommandList* CommandQueue::GetCommandList()
{
CommandList* command_list;
if (available_command_lists_.Empty() == false)
{
available_command_lists_.TryPop(command_list);
}
else
{
command_list = new CommandList(device_, command_list_type_);
}
return command_list;
}
//---------------------------------------------------------------------------------------------
uint64_t CommandQueue::ExecuteCommandList(CommandList* command_list)
{
ID3D12GraphicsCommandList* d3d_c_list = command_list->command_list();
d3d_c_list->Close();
ID3D12CommandList* const ppCommandLists[] = {
d3d_c_list
};
command_q_->ExecuteCommandLists(1, ppCommandLists);
//command_allocator_q_.emplace(CommandAllocatorEntry{ fence_value, command_allocator });
//command_list_q_.push(command_list);
uint64_t fence_value = Signal();
inflight_command_lists_.Push({ fence_value, command_list });
return fence_value;
}
//---------------------------------------------------------------------------------------------
uint64_t CommandQueue::Signal()
{
uint64_t fence_value = ++fence_value_;
command_q_->Signal(fence_, fence_value);
return fence_value;
}
//---------------------------------------------------------------------------------------------
bool CommandQueue::IsFenceComplete(uint64_t fence_value)
{
return fence_->GetCompletedValue() >= fence_value;
}
//---------------------------------------------------------------------------------------------
void CommandQueue::WaitForFenceValue(uint64_t fence_value)
{
if (IsFenceComplete(fence_value) == false)
{
fence_->SetEventOnCompletion(fence_value, fence_event_);
::WaitForSingleObject(fence_event_, MAXDWORD);
}
}
//---------------------------------------------------------------------------------------------
void CommandQueue::Flush()
{
std::unique_lock<std::mutex> lock(process_in_flight_command_lists_thread_mutex_);
process_in_flight_command_lists_thread_cv_.wait(
lock, [this] { return inflight_command_lists_.Empty(); });
// In case the command queue was signaled directly
// using the CommandQueue::Signal method then the
// fence value of the command queue might be higher than the fence
// value of any of the executed command lists.
WaitForFenceValue(fence_value_);
}
//---------------------------------------------------------------------------------------------
ID3D12CommandQueue* CommandQueue::command_q() const
{
return command_q_;
}
//---------------------------------------------------------------------------------------------
void CommandQueue::Close()
{
Flush();
::CloseHandle(fence_event_);
}
//---------------------------------------------------------------------------------------------
CommandList* CommandQueue::CreateCommandList()
{
return new CommandList(device_, command_list_type_);
}
void CommandQueue::ProccessInFlightCommandLists()
{
std::unique_lock<std::mutex> lock(process_in_flight_command_lists_thread_mutex_, std::defer_lock);
while (process_in_flight_command_lists_)
{
CommandListEntry command_list_entry;
lock.lock();
while (inflight_command_lists_.TryPop(command_list_entry))
{
auto fence_value = std::get<0>(command_list_entry);
auto command_list = std::get<1>(command_list_entry);
WaitForFenceValue(fence_value);
command_list->Reset();
available_command_lists_.Push(command_list);
}
lock.unlock();
process_in_flight_command_lists_thread_cv_.notify_one();
std::this_thread::yield();
}
}
}
}
| 31.363636
| 104
| 0.536594
|
MgBag
|
8ffd737654e556dd39348902a5905cb2764f93d8
| 1,623
|
hh
|
C++
|
CommTrackingObjects/smartsoft/src-gen/CommTrackingObjects/CommDetectedMarkerEventResultACE.hh
|
canonical-robots/DomainModelsRepositories
|
68b9286d84837e5feb7b200833b158ab9c2922a4
|
[
"BSD-3-Clause"
] | null | null | null |
CommTrackingObjects/smartsoft/src-gen/CommTrackingObjects/CommDetectedMarkerEventResultACE.hh
|
canonical-robots/DomainModelsRepositories
|
68b9286d84837e5feb7b200833b158ab9c2922a4
|
[
"BSD-3-Clause"
] | 2
|
2020-08-20T14:49:47.000Z
|
2020-10-07T16:10:07.000Z
|
CommTrackingObjects/smartsoft/src-gen/CommTrackingObjects/CommDetectedMarkerEventResultACE.hh
|
canonical-robots/DomainModelsRepositories
|
68b9286d84837e5feb7b200833b158ab9c2922a4
|
[
"BSD-3-Clause"
] | 8
|
2018-06-25T08:41:28.000Z
|
2020-08-13T10:39:30.000Z
|
//--------------------------------------------------------------------------
// Code generated by the SmartSoft MDSD Toolchain
// The SmartSoft Toolchain has been developed by:
//
// Service Robotics Research Center
// University of Applied Sciences Ulm
// Prittwitzstr. 10
// 89075 Ulm (Germany)
//
// Information about the SmartSoft MDSD Toolchain is available at:
// www.servicerobotik-ulm.de
//
// Please do not modify this file. It will be re-generated
// running the code generator.
//--------------------------------------------------------------------------
#ifndef COMMTRACKINGOBJECTS_COMMDETECTEDMARKEREVENTRESULT_ACE_H_
#define COMMTRACKINGOBJECTS_COMMDETECTEDMARKEREVENTRESULT_ACE_H_
#include "CommTrackingObjects/CommDetectedMarkerEventResult.hh"
#include <ace/CDR_Stream.h>
// serialization operator for DataStructure CommDetectedMarkerEventResult
ACE_CDR::Boolean operator<<(ACE_OutputCDR &cdr, const CommTrackingObjectsIDL::CommDetectedMarkerEventResult &data);
// de-serialization operator for DataStructure CommDetectedMarkerEventResult
ACE_CDR::Boolean operator>>(ACE_InputCDR &cdr, CommTrackingObjectsIDL::CommDetectedMarkerEventResult &data);
// serialization operator for CommunicationObject CommDetectedMarkerEventResult
ACE_CDR::Boolean operator<<(ACE_OutputCDR &cdr, const CommTrackingObjects::CommDetectedMarkerEventResult &obj);
// de-serialization operator for CommunicationObject CommDetectedMarkerEventResult
ACE_CDR::Boolean operator>>(ACE_InputCDR &cdr, CommTrackingObjects::CommDetectedMarkerEventResult &obj);
#endif /* COMMTRACKINGOBJECTS_COMMDETECTEDMARKEREVENTRESULT_ACE_H_ */
| 45.083333
| 115
| 0.754775
|
canonical-robots
|
890a96e0376015d0bf96903b4aea008afebfe904
| 10,276
|
cpp
|
C++
|
samples/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp
|
hamarb123/dotnet-api-docs
|
6aeb55784944a2f1f5e773b657791cbd73a92dd4
|
[
"CC-BY-4.0",
"MIT"
] | 421
|
2018-04-01T01:57:50.000Z
|
2022-03-28T15:24:42.000Z
|
samples/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp
|
hamarb123/dotnet-api-docs
|
6aeb55784944a2f1f5e773b657791cbd73a92dd4
|
[
"CC-BY-4.0",
"MIT"
] | 5,797
|
2018-04-02T21:12:23.000Z
|
2022-03-31T23:54:38.000Z
|
samples/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp
|
hamarb123/dotnet-api-docs
|
6aeb55784944a2f1f5e773b657791cbd73a92dd4
|
[
"CC-BY-4.0",
"MIT"
] | 1,482
|
2018-03-31T11:26:20.000Z
|
2022-03-30T22:36:45.000Z
|
//<Snippet2>
#using <System.Security.dll>
#using <System.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;
using namespace System::Security::Cryptography;
using namespace System::Security::Cryptography::Xml;
using namespace System::Text;
ref class Class1
{
public:
[STAThread]
static void Main()
{
XmlDocument^ productsXml = LoadProducts();
XmlNodeList^ xsltNodeList = GetXsltAsNodeList();
TransformDoc( productsXml, xsltNodeList );
// Use XmlDsigXsltTransform to resolve a Uri.
Uri^ baseUri = gcnew Uri( L"http://www.contoso.com" );
String^ relativeUri = L"xml";
Uri^ absoluteUri = ResolveUris( baseUri, relativeUri );
Console::WriteLine( L"This sample completed successfully; "
L"press Enter to exit." );
Console::ReadLine();
}
private:
static void TransformDoc( XmlDocument^ xmlDoc, XmlNodeList^ xsltNodeList )
{
try
{
// Construct a new XmlDsigXsltTransform.
//<Snippet1>
XmlDsigXsltTransform^ xmlTransform = gcnew XmlDsigXsltTransform;
//</Snippet1>
// Load the Xslt tranform as a node list.
//<Snippet10>
xmlTransform->LoadInnerXml( xsltNodeList );
//</Snippet10>
// Load the Xml document to perform the tranform on.
//<Snippet11>
XmlNamespaceManager^ namespaceManager;
namespaceManager = gcnew XmlNamespaceManager( xmlDoc->NameTable );
XmlNodeList^ productsNodeList;
productsNodeList = xmlDoc->SelectNodes( L"//.", namespaceManager );
xmlTransform->LoadInput( productsNodeList );
//</Snippet11>
// Retrieve the output from the transform.
//<Snippet7>
Stream^ outputStream = (Stream^)xmlTransform->GetOutput(
System::IO::Stream::typeid );
//</Snippet7>
// Read the output stream into a stream reader.
StreamReader^ streamReader = gcnew StreamReader( outputStream );
// Read the stream into a string.
String^ outputMessage = streamReader->ReadToEnd();
// Close the streams.
outputStream->Close();
streamReader->Close();
// Display to the console the Xml before and after
// encryption.
Console::WriteLine( L"\nResult of transformation: {0}", outputMessage );
ShowTransformProperties( xmlTransform );
}
catch ( Exception^ ex )
{
Console::WriteLine( L"Caught exception in TransformDoc method: {0}", ex );
}
}
static XmlNodeList^ GetXsltAsNodeList()
{
String^ transformXml = L"<xsl:transform version='1.0' ";
transformXml = String::Concat( transformXml,
L"xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>" );
transformXml = String::Concat( transformXml,
L"<xsl:template match='products'>" );
transformXml = String::Concat( transformXml,
L"<table><tr><td>ProductId</td><td>Name</td></tr>" );
transformXml = String::Concat( transformXml,
L"<xsl:apply-templates/></table></xsl:template>" );
transformXml = String::Concat( transformXml,
L"<xsl:template match='product'><tr>" );
transformXml = String::Concat( transformXml,
L"<xsl:apply-templates/></tr></xsl:template>" );
transformXml = String::Concat( transformXml,
L"<xsl:template match='productid'><td>" );
transformXml = String::Concat( transformXml,
L"<xsl:apply-templates/></td></xsl:template>" );
transformXml = String::Concat( transformXml,
L"<xsl:template match='description'><td>" );
transformXml = String::Concat( transformXml,
L"<xsl:apply-templates/></td></xsl:template>" );
transformXml = String::Concat( transformXml,
L"</xsl:transform>" );
Console::WriteLine( L"\nCreated the following Xslt tranform:" );
Console::WriteLine( transformXml );
XmlDocument^ xmlDoc = gcnew XmlDocument;
xmlDoc->LoadXml( transformXml );
return xmlDoc->GetElementsByTagName( L"xsl:transform" );
}
// Encrypt the text in the specified XmlDocument.
static void ShowTransformProperties( XmlDsigXsltTransform^ xmlTransform )
{
//<Snippet12>
String^ classDescription = xmlTransform->ToString();
//</Snippet12>
Console::WriteLine( L"\n** Summary for {0} **", classDescription );
// Retrieve the XML representation of the current transform.
//<Snippet9>
XmlElement^ xmlInTransform = xmlTransform->GetXml();
//</Snippet9>
Console::WriteLine( L"Xml representation of the current transform:\n{0}",
xmlInTransform->OuterXml );
// Ensure the transform is using the proper algorithm.
//<Snippet3>
xmlTransform->Algorithm = SignedXml::XmlDsigXsltTransformUrl;
//</Snippet3>
Console::WriteLine( L"Algorithm used: {0}", classDescription );
// Retrieve the valid input types for the current transform.
//<Snippet4>
array<Type^>^validInTypes = xmlTransform->InputTypes;
//</Snippet4>
Console::WriteLine( L"Transform accepts the following inputs:" );
for ( int i = 0; i < validInTypes->Length; i++ )
{
Console::WriteLine( L"\t{0}", validInTypes[ i ] );
}
//<Snippet5>
array<Type^>^validOutTypes = xmlTransform->OutputTypes;
//</Snippet5>
Console::WriteLine( L"Transform outputs in the following types:" );
for ( int i = validOutTypes->Length - 1; i >= 0; i-- )
{
Console::WriteLine( L"\t {0}", validOutTypes[ i ] );
if ( validOutTypes[ i ] == Object::typeid )
{
//<Snippet8>
Object^ outputObject = xmlTransform->GetOutput();
//</Snippet8>
}
}
}
// Create an XML document describing various products.
static XmlDocument^ LoadProducts()
{
String^ contosoProducts = L"<?xml version='1.0'?>";
contosoProducts = String::Concat( contosoProducts,
L"<products>" );
contosoProducts = String::Concat( contosoProducts,
L"<product><productid>1</productid>" );
contosoProducts = String::Concat( contosoProducts,
L"<description>Widgets</description></product>" );
contosoProducts = String::Concat( contosoProducts,
L"<product><productid>2</productid>" );
contosoProducts = String::Concat( contosoProducts,
L"<description>Gadgits</description></product>" );
contosoProducts = String::Concat( contosoProducts,
L"</products>" );
Console::WriteLine(
L"\nCreated the following Xml document for tranformation:" );
Console::WriteLine( contosoProducts );
XmlDocument^ xmlDoc = gcnew XmlDocument;
xmlDoc->LoadXml( contosoProducts );
return xmlDoc;
}
// Resolve the specified base and relative Uri's .
static Uri^ ResolveUris( Uri^ baseUri, String^ relativeUri )
{
//<Snippet6>
XmlUrlResolver^ xmlResolver = gcnew XmlUrlResolver;
xmlResolver->Credentials =
System::Net::CredentialCache::DefaultCredentials;
XmlDsigXsltTransform^ xmlTransform = gcnew XmlDsigXsltTransform;
xmlTransform->Resolver = xmlResolver;
//</Snippet6>
Uri^ absoluteUri = xmlResolver->ResolveUri( baseUri, relativeUri );
if ( absoluteUri != nullptr )
{
Console::WriteLine(
L"\nResolved the base Uri and relative Uri to the following:" );
Console::WriteLine( absoluteUri );
}
else
{
Console::WriteLine( L"Unable to resolve the base Uri and relative Uri" );
}
return absoluteUri;
}
};
int main()
{
Class1::Main();
}
//
// This sample produces the following output:
//
// Created the following Xml document for tranformation:
// <?xml version='1.0'?><products><product><productid>1</productid><descriptio
// n>Widgets</description></product><product><productid>2</productid><descript
// ion>Gadgits</description></product></products>
//
// Created the following Xslt tranform:
// <xsl:transform version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transfor
// m'><xsl:template match='products'><table><tr><td>ProductId</td><td>Name</td
// ></tr><xsl:apply-templates/></table></xsl:template><xsl:template match='pro
// duct'><tr><xsl:apply-templates/></tr></xsl:template><xsl:emplate match='pro
// ductid'><td><xsl:apply-templates/></td></xsl:template><xsl:template match='
// description'><td><xsl:apply-templates/></td></xsl:template></xsl:transform>
//
// Result of transformation: <table><tr><td>ProductId</td><td>Name</td></tr><t
// r><td>1</td><td>Widgets</td></tr><tr><td>2</td><td>Gadgits</td></tr></table
// >
//
// ** Summary for System.Security.Cryptography.Xml.XmlDsigXsltTransform **
// Xml representation of the current transform:
// <Transform Algorithm="http://www.w3.org/TR/1999/REC-xslt-19991116" xmlns="h
// ttp://www.w3.org/2000/09/xmldsig#"><xsl:transform version="1.0" xmlns:xsl="
// http://www.w3.org/1999/XSL/Transform"><xsl:template match="products"><table
// xmlns=""><tr><td>ProductId</td><td>Name</td></tr><xsl:apply-templates /></
// table></xsl:template><xsl:template match="product"><tr xmlns=""><xsl:apply-
// templates /></tr></xsl:template><xsl:template match="productid"><td xmlns="
// "><xsl:apply-templates /></td></xsl:template><xsl:template match="descripti
// on"><td xmlns=""><xsl:apply-templates /></td></xsl:template></xsl:transform
// ></Transform>
// Algorithm used: System.Security.Cryptography.Xml.XmlDsigXsltTransform
// Transform accepts the following inputs:
// System.IO.Stream
// System.Xml.XmlDocument
// System.Xml.XmlNodeList
// Transform outputs in the following types:
// System.IO.Stream
//
// Resolved the base Uri and relative Uri to the following:
// http://www.contoso.com/xml
// This sample completed successfully; press Enter to exit.
//</Snippet2>
| 39.221374
| 84
| 0.624562
|
hamarb123
|
890d8211e51a1394ea9268973cb6d846fe6e1dce
| 684
|
cpp
|
C++
|
Codes/IF_Ternary.cpp
|
Felipe-Pereira-Barros/CPP
|
050add96024c8e5b0d01ebb6cab52452cbb6dff5
|
[
"MIT"
] | 2
|
2020-05-21T14:44:36.000Z
|
2020-05-28T01:08:18.000Z
|
Codes/IF_Ternary.cpp
|
Felipe-Pereira-Barros/CPP
|
050add96024c8e5b0d01ebb6cab52452cbb6dff5
|
[
"MIT"
] | null | null | null |
Codes/IF_Ternary.cpp
|
Felipe-Pereira-Barros/CPP
|
050add96024c8e5b0d01ebb6cab52452cbb6dff5
|
[
"MIT"
] | null | null | null |
#include <iostream>
using namespace std;
int main()
{
//(expression) ? value : value2;
int n1,n2,note,x,n3;
string res,res2;
cout << "Enter the first note: ";
cin >> n1;
cout << "Enter the second note: ";
cin >> n2;
note=n1+n2;
/* note >= 60 Approved
<60 Not approved*/
(note >= 60) ? res="Approved" : res="Not Approved";
cout <<"\nstudent situation: " << res << "\n";
res2=(note >= 60) ? "Approved" : "Not Approved";
cout <<"\nstudent situation: " << res << "\n";
x=5;
cout << "Enter the X value: ";
cin >> n3;
(n3 >=10) ? x++ : x-- ;
cout << "\nNew X value: " << x << "\n";
return 0;
}
| 16.285714
| 55
| 0.495614
|
Felipe-Pereira-Barros
|
8910934bdcf11f09994d205e0e39faed02caa448
| 1,445
|
cpp
|
C++
|
listdevices/main.cpp
|
abolger/Andor-sCMOS-examples
|
2e2aeab93c11317b7731ffc7ae0adb50fc854f60
|
[
"MIT"
] | 8
|
2018-01-13T08:48:00.000Z
|
2022-03-24T22:19:57.000Z
|
listdevices/main.cpp
|
abolger/Andor-sCMOS-examples
|
2e2aeab93c11317b7731ffc7ae0adb50fc854f60
|
[
"MIT"
] | 1
|
2021-04-24T09:02:36.000Z
|
2021-04-24T10:04:10.000Z
|
listdevices/main.cpp
|
abolger/Andor-sCMOS-examples
|
2e2aeab93c11317b7731ffc7ae0adb50fc854f60
|
[
"MIT"
] | 5
|
2018-04-13T03:25:18.000Z
|
2020-11-10T05:22:58.000Z
|
#include <stdlib.h>
#include <iostream>
#include "atcore.h"
int main()
{
int iErr = AT_InitialiseLibrary();
if (iErr != AT_SUCCESS) {
std::cout << "Error from AT_Initialise : " << iErr << std::endl;
}
long long DeviceCount = 0;
iErr = AT_GetInt(AT_HANDLE_SYSTEM, L"Device Count", &DeviceCount);
if (iErr != AT_SUCCESS) {
std::cout << "Error from AT_GetInt('Device Count') : " << iErr << std::endl;
}
std::cout << "Found " << DeviceCount << " Devices." << std::endl;
for (long long i=0; i<DeviceCount; i++) {
std::cout << "Device " << i << " : ";
AT_H Hndl = AT_HANDLE_UNINITIALISED;
iErr = AT_Open(static_cast<int>(i), &Hndl);
if (iErr != AT_SUCCESS) {
std::cout << "Error from AT_Open() : " << iErr << std::endl;
}
else {
AT_WC CameraModel[128];
iErr = AT_GetString(Hndl, L"Camera Model", CameraModel, 128);
if (iErr != AT_SUCCESS) {
std::cout << "Error from AT_GetString('Camera Model') : " << iErr << std::endl;
}
if (iErr == AT_SUCCESS) {
char szCamModel[128];
wcstombs(szCamModel, CameraModel, 64);
std::cout << szCamModel << std::endl;
}
iErr = AT_Close(Hndl);
if (iErr != AT_SUCCESS) {
std::cout << "Error from AT_Close() : " << iErr << std::endl;
}
}
}
AT_FinaliseLibrary();
std::cout << "Press any key and enter to exit." << std::endl;
char ch;
std::cin >> ch;
}
| 27.264151
| 87
| 0.565398
|
abolger
|
891251bf830e8e8941ddd796ad96cdd681b56174
| 944
|
cc
|
C++
|
keypress.cc
|
pmwheatley/dfterm2
|
81efc85d85c126b22d79be4499755a99119045bf
|
[
"ICU",
"BSD-3-Clause"
] | null | null | null |
keypress.cc
|
pmwheatley/dfterm2
|
81efc85d85c126b22d79be4499755a99119045bf
|
[
"ICU",
"BSD-3-Clause"
] | null | null | null |
keypress.cc
|
pmwheatley/dfterm2
|
81efc85d85c126b22d79be4499755a99119045bf
|
[
"ICU",
"BSD-3-Clause"
] | null | null | null |
#include "interface.hpp"
using namespace trankesbel;
KeyPress::KeyPress(const KeyCode &kc, bool special_key)
{
alt_down = ctrl_down = shift_down = false;
setKeyCode(kc, special_key);
}
KeyPress::KeyPress(const KeyCode &kc, bool special_key, bool alt_down, bool ctrl_down, bool shift_down)
{
setKeyCode(kc, special_key);
setAltDown(alt_down);
setCtrlDown(ctrl_down);
setShiftDown(shift_down);
}
void KeyPress::setKeyCode(const KeyCode &kc, bool special_key)
{
this->special_key = special_key;
keycode = kc;
if (!special_key)
return;
alt_down = ctrl_down = shift_down = false;
if (kc >= Alt0 && kc <= AltLeft)
{
alt_down = true;
return;
}
if (kc == CtrlUp || kc == CtrlDown || kc == CtrlLeft || kc == CtrlRight)
{
ctrl_down = true;
return;
}
if (kc >= SBeg && kc <= SUndo)
{
shift_down = true;
return;
}
}
| 20.521739
| 103
| 0.611229
|
pmwheatley
|
89125c77ce52b79308669f5242e98576fb6cf378
| 356
|
hpp
|
C++
|
src/Missle.hpp
|
AgaBuu/TankBotFight
|
154b176b697b5d88fffb4b0c9c9c2f8dac334afb
|
[
"MIT"
] | null | null | null |
src/Missle.hpp
|
AgaBuu/TankBotFight
|
154b176b697b5d88fffb4b0c9c9c2f8dac334afb
|
[
"MIT"
] | null | null | null |
src/Missle.hpp
|
AgaBuu/TankBotFight
|
154b176b697b5d88fffb4b0c9c9c2f8dac334afb
|
[
"MIT"
] | null | null | null |
#pragma once
#include <SFML/Graphics.hpp>
#include "MovementState.hpp"
class Missle {
public:
Missle(sf::Texture& texture, const MovementState& state);
void draw(sf::RenderWindow& window);
void update();
[[nodiscard]] sf::Vector2f get_pos() const;
private:
sf::Sprite mSprite;
float mSpeed = 20.0f;
sf::Vector2f mPos;
float mAngle;
};
| 18.736842
| 59
| 0.696629
|
AgaBuu
|
891b0fee53d4ff6f9bd33ff208c696cccfce211b
| 2,187
|
cpp
|
C++
|
src/core/map/level_generator/room_repo.cpp
|
MrPepperoni/Reaping2-1
|
4ffef3cca1145ddc06ca87d2968c7b0ffd3ba3fd
|
[
"MIT"
] | null | null | null |
src/core/map/level_generator/room_repo.cpp
|
MrPepperoni/Reaping2-1
|
4ffef3cca1145ddc06ca87d2968c7b0ffd3ba3fd
|
[
"MIT"
] | null | null | null |
src/core/map/level_generator/room_repo.cpp
|
MrPepperoni/Reaping2-1
|
4ffef3cca1145ddc06ca87d2968c7b0ffd3ba3fd
|
[
"MIT"
] | 1
|
2020-09-22T15:41:51.000Z
|
2020-09-22T15:41:51.000Z
|
#include "platform/i_platform.h"
#include "room_repo.h"
#include "simple_room1.h"
#include "vdouble_room1.h"
#include "hdouble_room1.h"
#include "json_room.h"
using platform::AutoId;
namespace map {
DefaultRoom const RoomRepo::mDefault = DefaultRoom();
RoomRepo::RoomRepo()
: Repository<IRoom>(mDefault)
{
int32_t id = AutoId( "simple_room1" );
mElements.insert( id, new SimpleRoom1( id ) );
id = AutoId( "vdouble_room1" ); mElements.insert( id, new VDoubleRoom1( id ) );
id = AutoId( "hdouble_room1" ); mElements.insert( id, new HDoubleRoom1( id ) );
Init();
}
void RoomRepo::Init()
{
PathVect_t Paths;
Filesys& FSys = Filesys::Get();
FSys.GetFileNames( Paths, "rooms" );
for (PathVect_t::const_iterator i = Paths.begin(), e = Paths.end(); i != e; ++i)
{
boost::filesystem::path const& Path = *i;
if (Path.extension().string() != ".json")
{
continue;
}
AutoFile JsonFile = FSys.Open( *i );
if (!JsonFile.get())
{
continue;
}
JsonReader Reader( *JsonFile );
if (!Reader.IsValid())
{
continue;
}
Json::Value Root = Reader.GetRoot();
if (!Root.isArray())
{
continue;
}
for (auto& jsonRoomDesc : Root )
{
std::string str;
if (Json::GetStr( jsonRoomDesc["name"], str ))
{
int32_t id = AutoId( str );
std::unique_ptr<JsonRoom> jsonRoom( new JsonRoom( id ) );
jsonRoom->Load( jsonRoomDesc );
mElements.insert( id, jsonRoom.release() );
}
}
}
for (auto&& e : mElements)
{
e.second->Init();
}
}
platform::Repository<IRoom>::ElementMap_t const& RoomRepo::GetElements()
{
return mElements;
}
void RoomRepo::AddRoom( std::unique_ptr<IRoom> iRoom )
{
int32_t id = iRoom->GetId();
mElements.insert( id, iRoom.release() );
}
DefaultRoom::DefaultRoom()
: IRoom( -1 )
{
}
void DefaultRoom::Generate( RoomDesc& roomDesc, glm::vec2 pos, bool editor /*= false*/ )
{
}
} // namespace map
| 23.021053
| 88
| 0.55647
|
MrPepperoni
|
89203ac7f93b9a6ff4befa2aaada9e47c8835256
| 16,998
|
cpp
|
C++
|
NPlan/NPlan/file/NProjectCalendar.cpp
|
Avens666/NPlan
|
726411b053ded26ce6c1b8c280c994d4c1bac71a
|
[
"Apache-2.0"
] | 16
|
2018-08-30T11:27:14.000Z
|
2021-12-17T02:05:45.000Z
|
NPlan/NPlan/file/NProjectCalendar.cpp
|
Avens666/NPlan
|
726411b053ded26ce6c1b8c280c994d4c1bac71a
|
[
"Apache-2.0"
] | null | null | null |
NPlan/NPlan/file/NProjectCalendar.cpp
|
Avens666/NPlan
|
726411b053ded26ce6c1b8c280c994d4c1bac71a
|
[
"Apache-2.0"
] | 14
|
2018-08-30T12:13:56.000Z
|
2021-02-06T11:07:44.000Z
|
// File: NProjectCalendar.cpp
// Copyright: Copyright(C) 2013-2017 Wuhan KOTEI Informatics Co., Ltd. All rights reserved.
// Website: http://www.nuiengine.com
// Description: This code is part of NPlan Project (Powered by NUI Engine)
// Comments:
// Rev: 1
// Created: 2018/8/27
// Last edit: 2015/2/27
// Author: Chen Zhi and his team
// E-mail: cz_666@qq.com
// License: APACHE V2.0 (see license file)
#include "NProjectCalendar.h"
CNProjectBaseCalendar::CNProjectBaseCalendar():m_days_per_week(5)
, m_hours_per_day(8)
, m_from_time(9, 0, 0)
, m_to_time(18, 0, 0)
, m_rest_start(12, 0, 0)
, m_rest_end(13, 0, 0)
{
}
CNProjectBaseCalendar::~CNProjectBaseCalendar()
{
}
//设置上班时间
void CNProjectBaseCalendar::setWorkingTime(const time_duration & time)
{
m_from_time = time;
}
//设置下班时间
void CNProjectBaseCalendar::setClosingTime(const time_duration & time)
{
m_to_time = time;
}
void CNProjectBaseCalendar::setWorkHours(kn_byte hours)
{
if(hours <= 24)
{
m_hours_per_day = hours;
}
}
kn_byte CNProjectBaseCalendar::getWorkingHoursPerDay() const
{
return m_hours_per_day;
}
//获取上班时间
time_duration CNProjectBaseCalendar::getWorkingTime() const
{
return m_from_time;
}
//获取下班时间
time_duration CNProjectBaseCalendar::getClosingTime() const
{
return m_to_time;
}
//每周工作几天
void CNProjectBaseCalendar::setWorkDaysPerWeek(kn_byte days)
{
if(days <= 7)
{
m_days_per_week = days;
}
}
kn_byte CNProjectBaseCalendar::getWorkDaysPerWeek() const
{
return m_days_per_week;
}
//获取午休开始时间
time_duration CNProjectBaseCalendar::getRestStartTime() const
{
return m_rest_start;
}
//获取午休结束时间
time_duration CNProjectBaseCalendar::getRestEndTime() const
{
return m_rest_end;
}
CNProjectExceptionCalendar::CNProjectExceptionCalendar(const CNProjectExceptionCalendar& other)
{
m_day_type = other.getdayType();
m_start_date = other.getStartDate();
m_end_date = other.getEndDate();
m_start_time = other.getStartTime();
m_end_time = other.getEndTime();
m_except_rule = other.getRule();
}
CNProjectExceptionCalendar::CNProjectExceptionCalendar():m_except_rule(0xFFFFFFFF)
{
}
kn_bool CNProjectExceptionCalendar::isValid()
{
return (m_except_rule != 0xFFFFFFFF);
}
date CNProjectExceptionCalendar::getStartDate() const
{
return m_start_date;
}
date CNProjectExceptionCalendar::getEndDate() const
{
return m_end_date;
}
time_duration CNProjectExceptionCalendar::getStartTime() const
{
return m_start_time;
}
time_duration CNProjectExceptionCalendar::getEndTime() const
{
return m_end_time;
}
kn_int CNProjectExceptionCalendar::getRule() const
{
return m_except_rule;
}
//获取工作日等类型
string CNProjectExceptionCalendar::getdayTypeString() const
{
string str_value;
switch(m_day_type)
{
case WORK_DAY:
str_value = "1";
break;
case OVERTIME_WORK:
str_value = "2";
break;
default:
str_value = "0";
break;
}
return str_value;
}
//获取工作日等类型
DAY_TYPE CNProjectExceptionCalendar::getdayType() const
{
return m_day_type;
}
CNProjectExceptionCalendar::CNProjectExceptionCalendar(kn_byte byWeek/*1-7*/, DAY_TYPE dayType, time_duration s_time, time_duration end_time, date start_date , date end_date)
{
m_except_rule = 0xFFFFFFFF; //in valid
if( (byWeek >= 1) && (byWeek <= 7) )
{
switch (dayType)
{
case HOLIDAY:
case WORK_DAY:
case OVERTIME_WORK:
{
m_except_rule = 1; //week
m_except_rule |= (byWeek << 8);
m_start_date = start_date;
m_end_date = end_date;
m_start_time = s_time;
m_end_time = end_time;
m_day_type = dayType;
}
break;
default:
break;
}
}
}
//每月多少号
CNProjectExceptionCalendar::CNProjectExceptionCalendar(kn_word byDate/*1-31*/, DAY_TYPE dayType, time_duration s_time, time_duration end_time, date start_date, date end_date)
{
m_except_rule = 0xFFFFFFFF; //in valid
if( (byDate >= 1) && (byDate <= 31) )
{
switch (dayType)
{
case HOLIDAY:
case WORK_DAY:
case OVERTIME_WORK:
{
m_except_rule = 2; //day
m_except_rule |= (byDate << 8);
m_start_date = start_date;
m_end_date = end_date;
m_start_time = s_time;
m_end_time = end_time;
m_day_type = dayType;
}
break;
default:
break;
}
}
}
//某个时间段
CNProjectExceptionCalendar::CNProjectExceptionCalendar(date &start_date, date &end_date, DAY_TYPE dayType, time_duration s_time, time_duration end_time )
{
m_except_rule = 0xFFFFFFFF; //in valid
if( !start_date.is_not_a_date() )
{
switch (dayType)
{
case HOLIDAY:
case WORK_DAY:
case OVERTIME_WORK:
{
m_except_rule = 0; //date
m_start_date = start_date;
m_end_date = end_date;
m_start_time = s_time;
m_end_time = end_time;
m_day_type = dayType;
}
break;
default:
break;
}
}
}
//是否为工作日
kn_bool CNProjectExceptionCalendar::isWorkDay() const
{
return (m_day_type == WORK_DAY);
}
//当前日期是否在例外日历中
kn_bool CNProjectExceptionCalendar::inException(const ptime& time) const
{
kn_bool _result ;
date cur_date = time.date();
if( !m_start_date.is_special() )
{
if( cur_date < m_start_date )
{
return false;
}
}
if( !m_end_date.is_special() )
{
if( cur_date > m_end_date )
{
return false;
}
}
time_duration tm = time.time_of_day();
if ( m_start_time != time_duration() )
{
if( tm < m_start_time )
{
return false;
}
}
if ( m_end_time != time_duration() )
{
if( tm > m_end_time )
{
return false;
}
}
kn_byte rule = m_except_rule & 0xFF;
switch (rule)
{
case 1: //week
{
int week = cur_date.day_of_week();
if ( week == 0 )
{
week = 7;// 周日
}
_result = ( week == ((m_except_rule >> 8)& 0xFF) );
}
break;
case 2: //day
_result = ( cur_date.day() == ((m_except_rule >> 8)& 0xFF) );
break;
case 0: //date
break;
default:
break;
}
return _result;
}
//当前日期是否在例外日历中
kn_bool CNProjectExceptionCalendar::inException(const date& dt) const
{
kn_bool _result = true;
if( !m_start_date.is_special() )
{
if( dt < m_start_date )
{
return false;
}
}
if( !m_end_date.is_special() )
{
if( dt > m_end_date )
{
return false;
}
}
kn_byte rule = m_except_rule & 0xFF;
switch (rule)
{
case 1: //week
{
int week = dt.day_of_week();
if ( week == 0 )
{
week = 7;// 周日
}
_result = ( week == ((m_except_rule >> 8)& 0xFF) );
}
break;
case 2: //day
_result = ( dt.day() == ((m_except_rule >> 8)& 0xFF) );
break;
case 0: //date
break;
default:
break;
}
return _result;
}
CNProjectCalendar::CNProjectCalendar()
{
}
CNProjectCalendar::CNProjectCalendar(const CNProjectCalendar& other)
{
m_from_time = other.getWorkingTime();
m_to_time = other.getClosingTime();
m_rest_start = other.getRestStartTime();
m_rest_end = other.getRestEndTime();
m_hours_per_day = other.getWorkingHoursPerDay();
m_days_per_week = other.getWorkDaysPerWeek();
const CNProjectCalendar_LST * p_lists = other.getWorkingdays();
if( NULL != p_lists )
{
copy(p_lists->begin(), p_lists->end(), back_inserter(m_lst_workingdays));
}
p_lists = other.getHolidays();
if( NULL != p_lists )
{
copy(p_lists->begin(), p_lists->end(), back_inserter(m_lst_holiday));
}
p_lists = other.getOvertimeWorkings();
if( NULL != p_lists )
{
copy(p_lists->begin(), p_lists->end(), back_inserter(m_lst_overtime));
}
}
//是否为工作日
//说明:一天只上半天班,也认为当天是工作日(加班不算工作日)
kn_bool CNProjectCalendar::isWorkDay(const date & dt) const
{
//优先判断例外日历
CNProjectCalendar_LST::const_iterator it = m_lst_workingdays.begin();
for(; it != m_lst_workingdays.end(); ++it)
{
if( it->inException(dt) )
{
return it->isWorkDay();
}
}
it = m_lst_holiday.begin();
for(; it != m_lst_holiday.end(); ++it)
{
if( it->inException(dt) )
{
return false;
}
}
kn_bool _result = true;
date::day_of_week_type dw = dt.day_of_week();
if( (0 == dw) || (6 == dw) )//周日,周六 默认为休息日,否则需要设置例外
{
_result = false;
}
return _result;
}
kn_byte CNProjectCalendar::getWorkingHours(const time_duration& frm_time, const time_duration& t_time) const
{
time_duration start_time = frm_time;
time_duration end_time = t_time;
if( frm_time < getWorkingTime() )
{
start_time = getWorkingTime();
}
if( t_time > getClosingTime() ) //移去非工作时间
{
end_time = getClosingTime();
}
time_duration rest_frm_time = max(start_time, getRestStartTime() );
time_duration rest_t_time = min(end_time, getRestEndTime() );
time_duration wrk_time = end_time - start_time;
if( rest_t_time > rest_frm_time ) //有交集
{
wrk_time -= (rest_t_time - rest_frm_time); //减去午休时间
}
kn_byte hours = wrk_time.hours();
return hours;
}
//加班时间不计算在内,只计算工作时间
vector<kn_uint> CNProjectCalendar::getWorkHours(const ptime& from_time, const ptime& to_time ) const
{
vector<kn_uint> vect_hours;
if( (!from_time.is_not_a_date_time()) && (!to_time.is_not_a_date_time()) )
{
kn_uint hours(0);
date from_date = from_time.date();
date to_date = to_time.date();
if ( (from_date == to_date) ) //一天之内
{
if( isWorkDay(from_date) && (to_time > from_time) )
{
hours = getWorkingHours(from_time.time_of_day(), to_time.time_of_day() );
}
vect_hours.push_back(hours);
}
else if(to_date > from_date)
{
if ( isWorkDay(from_date) ) //第一天
{
hours = getWorkingHours(from_time.time_of_day(), CNProjectBaseCalendar::getClosingTime() );
vect_hours.push_back(hours);
}
else
{
vect_hours.push_back(0); //非工作日
}
boost::gregorian::days one_day( 1 );
for(date dt = from_date + one_day; dt != to_date; dt += one_day )
{
if ( isWorkDay(dt) )
{
vect_hours.push_back( CNProjectBaseCalendar::getWorkingHoursPerDay() );
}
else
{
vect_hours.push_back(0); //非工作日
}
}
if ( isWorkDay(to_date) ) //最后一天
{
hours = getWorkingHours(CNProjectBaseCalendar::getWorkingTime(), to_time.time_of_day() );
vect_hours.push_back(hours);
}
else
{
vect_hours.push_back(0); //非工作日
}
}
}
return vect_hours;
}
kn_uint CNProjectCalendar::getWorkDays(const ptime& from_time, const ptime& to_time ) const
{
kn_uint working_days(0);
if( (!from_time.is_not_a_date_time()) && (!to_time.is_not_a_date_time()) )
{
date to_date = to_time.date();
boost::gregorian::days one_day( 1 );
for(date dt = from_time.date(); dt != to_date ; dt += one_day)
{
if ( isWorkDay( dt ) )
{
++working_days;
}
}
}
return working_days;
}
//将某天设置为工作日
void CNProjectCalendar::setWorkDay(/*const*/ date & dt)
{
kn_bool bFind(false);
CNProjectCalendar_LST::iterator it = m_lst_workingdays.begin();
for(; it != m_lst_workingdays.end(); ++it)
{
if( it->inException(dt) )
{
bFind = true;
break;
}
}
if(!bFind)
{
CNProjectExceptionCalendar work_day(dt, dt, WORK_DAY);
m_lst_workingdays.push_back(work_day);
}
it = m_lst_holiday.begin();
for(; it != m_lst_holiday.end(); ++it)
{
if( it->inException(dt) )
{
m_lst_holiday.erase(it);
break;
}
}
}
//将某天设置为假日
void CNProjectCalendar::setHoliday(/*const*/ date & dt)
{
CNProjectCalendar_LST::iterator it = m_lst_workingdays.begin();
for(; it != m_lst_workingdays.end(); ++it)
{
if( it->inException(dt) )
{
m_lst_workingdays.erase(it);
break;
}
}
kn_bool bFind(false);
it = m_lst_holiday.begin();
for(; it != m_lst_holiday.end(); ++it)
{
if( it->inException(dt) )
{
bFind = true;
break;
}
}
if(!bFind)
{
CNProjectExceptionCalendar holiday(dt, dt, HOLIDAY);
m_lst_holiday.push_back(holiday);
}
}
//添加例外规则(每周几)
kn_uint CNProjectCalendar::addException(kn_byte byWeek/*1-7*/, DAY_TYPE dayType, time_duration s_time, time_duration end_time, date start_date , date end_date)
{
kn_uint index(0);
CNProjectExceptionCalendar exp(byWeek, dayType, s_time, end_time, start_date, end_date);
if( exp.isValid() )
{
switch ( exp.getdayType() )
{
case HOLIDAY:
m_lst_holiday.push_back(exp);
index = m_lst_holiday.size() + HOLIDAY_START_ID;
break;
case WORK_DAY:
m_lst_workingdays.push_back(exp);
index = m_lst_workingdays.size() + WORKINGDAY_START_ID;
break;
case OVERTIME_WORK:
m_lst_overtime.push_back(exp);
index = m_lst_overtime.size() + OVERTIME_START_ID;
break;
default:
break;
}
}
return index;
}
//添加例外规则(//每月多少号)
kn_uint CNProjectCalendar::addException(kn_word byDate/*1-31*/, DAY_TYPE dayType, time_duration s_time, time_duration end_time, date start_date, date end_date )
{
kn_uint index(0);
CNProjectExceptionCalendar exp(byDate, dayType, s_time, end_time, start_date, end_date);
if( exp.isValid() )
{
switch ( exp.getdayType() )
{
case HOLIDAY:
m_lst_holiday.push_back(exp);
index = m_lst_holiday.size() + HOLIDAY_START_ID;
break;
case WORK_DAY:
m_lst_workingdays.push_back(exp);
index = m_lst_workingdays.size() + WORKINGDAY_START_ID;
break;
case OVERTIME_WORK:
m_lst_overtime.push_back(exp);
index = m_lst_overtime.size() + OVERTIME_START_ID;
break;
default:
break;
}
}
return index;
}
//添加例外规则(//某个时间段)
kn_uint CNProjectCalendar::addException(date &start_date, date &end_date, DAY_TYPE dayType, time_duration s_time, time_duration end_time)
{
kn_uint index(0);
CNProjectExceptionCalendar exp(start_date, end_date, dayType, s_time, end_time);
if( exp.isValid() )
{
switch ( exp.getdayType() )
{
case HOLIDAY:
m_lst_holiday.push_back(exp);
index = m_lst_holiday.size() + HOLIDAY_START_ID;
break;
case WORK_DAY:
m_lst_workingdays.push_back(exp);
index = m_lst_workingdays.size() + WORKINGDAY_START_ID;
break;
case OVERTIME_WORK:
m_lst_overtime.push_back(exp);
index = m_lst_overtime.size() + OVERTIME_START_ID;
break;
default:
break;
}
}
return index;
}
const CNProjectCalendar_LST * CNProjectCalendar::getWorkingdays() const
{
return &m_lst_workingdays;
}
const CNProjectCalendar_LST * CNProjectCalendar::getHolidays() const
{
return &m_lst_holiday;
}
const CNProjectCalendar_LST * CNProjectCalendar::getOvertimeWorkings() const
{
return &m_lst_overtime;
}
kn_bool CNProjectCalendar::delException(kn_uint index)
{
kn_bool _result = false;
//每种例外设置个数不会超过1W条
if( index > WORKINGDAY_START_ID && (index < (OVERTIME_START_ID + WORKINGDAY_START_ID) ) )
{
if(index < HOLIDAY_START_ID)
{
CNProjectCalendar_LST::iterator iter = m_lst_workingdays.begin();
std::advance(iter, index - WORKINGDAY_START_ID );
m_lst_workingdays.erase(iter); //工作日
_result = true;
}
else if(index < OVERTIME_START_ID)
{
CNProjectCalendar_LST::iterator iter = m_lst_holiday.begin();
std::advance(iter, index - HOLIDAY_START_ID );
m_lst_holiday.erase(iter); //假期
_result = true;
}
else
{
CNProjectCalendar_LST::iterator iter = m_lst_overtime.begin();
std::advance(iter, index - OVERTIME_START_ID );
m_lst_overtime.erase(iter); //加班
_result = true;
}
}
return _result;
}
void CNProjectCalendar::clearAllException()
{
m_lst_workingdays.clear();
m_lst_holiday.clear();
m_lst_overtime.clear();
}
| 22.573705
| 176
| 0.607719
|
Avens666
|
89210885ff79188d7601554ce88e0c00112d1a5d
| 2,809
|
cpp
|
C++
|
ResolutionSystemeDialogue.cpp
|
ElDawgerino/NF05lab
|
62340e718f10e3f1864bee7e9637edc1a3fcae46
|
[
"MIT"
] | 1
|
2016-02-24T13:51:13.000Z
|
2016-02-24T13:51:13.000Z
|
ResolutionSystemeDialogue.cpp
|
ElDawgerino/NF05lab
|
62340e718f10e3f1864bee7e9637edc1a3fcae46
|
[
"MIT"
] | null | null | null |
ResolutionSystemeDialogue.cpp
|
ElDawgerino/NF05lab
|
62340e718f10e3f1864bee7e9637edc1a3fcae46
|
[
"MIT"
] | null | null | null |
#include "ResolutionSystemeDialogue.h"
ResolutionSystemeDialogue::ResolutionSystemeDialogue( wxWindow* parent)
:
ResolutionSystemeDialogueBase( parent )
{
}
/*
* La méthode ResolutionSystemeDialogue prend le nombre d'équation (nombreEquations) indiqué par l'utilisateur et s'en sert pour générer:
* - une grille nombreEquations * nombreEquations pour l'application
* - une grille nombreEquations * 1 pour le vecteur
* (Le système étant : Application * Solution = Vecteur).
*/
void ResolutionSystemeDialogue::SurClicBoutonValiderSysteme(wxCommandEvent& event)
{
int nombreEquations = m_equationsSpin->GetValue();
if(nombreEquations > 0)
{
//On supprime les colonnes et les lignes des deux grilles
if(m_tableauMatriceSysteme->GetRows() > 0)
m_tableauMatriceSysteme->DeleteRows(0, m_tableauMatriceSysteme->GetRows());
if(m_tableauMatriceSysteme->GetCols() > 0)
m_tableauMatriceSysteme->DeleteCols(0, m_tableauMatriceSysteme->GetCols());
if(m_tableauVecteurSysteme->GetRows() > 0)
m_tableauVecteurSysteme->DeleteRows(0, m_tableauVecteurSysteme->GetRows());
if(m_tableauVecteurSysteme->GetCols() > 0)
m_tableauVecteurSysteme->DeleteCols(0, 1);
//On ajoute le nombre de colonnes et de lignes nécessaires
m_tableauMatriceSysteme->AppendRows(nombreEquations);
m_tableauMatriceSysteme->AppendCols(nombreEquations);
m_tableauVecteurSysteme->AppendCols(1);
m_tableauVecteurSysteme->AppendRows(nombreEquations);
}
}
/*
* la fonction ResolutionSystemeDialogue affecte à la matrice application le contenu des valeurs comprises dans la première wxGrid et à la matrice vecteur le contenu de la seconde wxGrid.
* On affiche ensuite la matrice solution obtenu grâce au calcul : Solution = Application^(-1) * Vecteur.
* Si application n'est pas inversible on affiche une erreur.
*/
void ResolutionSystemeDialogue::SurCLicBouttonResoudre(wxCommandEvent& event)
{
int nombreEquations = m_equationsSpin->GetValue(), i ,j;
double valeurCellule;
Matrice Application(nombreEquations, nombreEquations);
Matrice Vecteur(nombreEquations, 1);
Matrice Solution(nombreEquations, 1);
//On affecte le contenu des wxGrid aux matrices:
for (i=0; i<nombreEquations; i++)
{
for (j=0; j<nombreEquations; j++)
{
valeurCellule = 0;
m_tableauMatriceSysteme->GetCellValue(i,j).ToDouble(&valeurCellule);
Application.FixerValeur(i,j, (float)valeurCellule);
}
valeurCellule = 0;
m_tableauVecteurSysteme->GetCellValue(i,0).ToDouble(&valeurCellule);
Vecteur.FixerValeur(i,0, (float)valeurCellule);
}
//Si un résultat existe on l'affiche:
if (Application.Inversible())
{
Solution = Application.Inverse() * Vecteur;
Solution.AfficherMatrice();
}
else
{
wxMessageBox( wxT("Il n'y a aucune solution ou une infinité de solution.") );
}
EndModal(0);
}
| 34.256098
| 187
| 0.765041
|
ElDawgerino
|
8921faa10942cdb468561ab6cfa1b2949a74759c
| 3,791
|
cpp
|
C++
|
rmoss_cam/src/cam_client.cpp
|
TomwKang/rmoss_core
|
058336a2825bbeddb5b6b865e22a7ddd8faad33e
|
[
"Apache-2.0"
] | null | null | null |
rmoss_cam/src/cam_client.cpp
|
TomwKang/rmoss_core
|
058336a2825bbeddb5b6b865e22a7ddd8faad33e
|
[
"Apache-2.0"
] | null | null | null |
rmoss_cam/src/cam_client.cpp
|
TomwKang/rmoss_core
|
058336a2825bbeddb5b6b865e22a7ddd8faad33e
|
[
"Apache-2.0"
] | null | null | null |
// Copyright 2021 RoboMaster-OSS
//
// 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 "rmoss_cam/cam_client.hpp"
#include <string>
#include <memory>
#include "rmoss_interfaces/srv/get_camera_info.hpp"
#include "cv_bridge/cv_bridge.h"
using namespace std::chrono_literals;
namespace rmoss_cam
{
CamClient::CamClient(
rclcpp::Node::SharedPtr node, std::string camera_name, Callback process_fn, bool spin_thread)
: node_(node), camera_name_(camera_name), process_fn_(process_fn), spin_thread_(spin_thread)
{
// create image subscriber
using namespace std::placeholders;
if (spin_thread_) {
callback_group_ = node_->create_callback_group(
rclcpp::CallbackGroupType::MutuallyExclusive, false);
auto sub_opt = rclcpp::SubscriptionOptions();
sub_opt.callback_group = callback_group_;
img_sub_ = node_->create_subscription<sensor_msgs::msg::Image>(
camera_name + "/image_raw", 1, std::bind(&CamClient::img_cb, this, _1), sub_opt);
executor_ = std::make_shared<rclcpp::executors::SingleThreadedExecutor>();
executor_->add_callback_group(callback_group_, node->get_node_base_interface());
executor_thread_ = std::make_unique<std::thread>([&]() {executor_->spin();});
} else {
img_sub_ = node_->create_subscription<sensor_msgs::msg::Image>(
camera_name + "/image_raw", 1, std::bind(&CamClient::img_cb, this, _1));
}
}
CamClient::~CamClient()
{
if (spin_thread_) {
executor_->cancel();
executor_thread_->join();
}
}
void CamClient::img_cb(const sensor_msgs::msg::Image::ConstSharedPtr msg)
{
if (run_flag_) {
auto img = cv_bridge::toCvShare(msg, "bgr8")->image.clone();
// auto img_stamp = msg->header.stamp.sec + 0.000000001 * msg->header.stamp.nanosec;
process_fn_(img, msg->header.stamp);
}
}
bool CamClient::get_camera_info(sensor_msgs::msg::CameraInfo & info)
{
auto callback_group = node_->create_callback_group(
rclcpp::CallbackGroupType::MutuallyExclusive, false);
auto exec = std::make_shared<rclcpp::executors::SingleThreadedExecutor>();
auto client = node_->create_client<rmoss_interfaces::srv::GetCameraInfo>(
camera_name_ + "/get_camera_info",
rmw_qos_profile_services_default,
callback_group);
exec->add_callback_group(callback_group, node_->get_node_base_interface());
while (!client->wait_for_service(std::chrono::seconds(1))) {
if (!rclcpp::ok()) {
RCLCPP_ERROR(node_->get_logger(), "[get_camera_info] client interrupted.");
return false;
}
RCLCPP_INFO(node_->get_logger(), "[get_camera_info] waiting for service.");
}
auto request = std::make_shared<rmoss_interfaces::srv::GetCameraInfo::Request>();
auto result_future = client->async_send_request(request);
if (exec->spin_until_future_complete(result_future, 5s) !=
rclcpp::FutureReturnCode::SUCCESS)
{
RCLCPP_ERROR(node_->get_logger(), "[get_camera_info] waiting for service failed.");
return false;
}
auto result = result_future.get();
if (result->success) {
info = result->camera_info;
return true;
} else {
RCLCPP_ERROR(node_->get_logger(), "[get_camera_info] service call failed.");
return false;
}
}
void CamClient::start() {run_flag_ = true;}
void CamClient::stop() {run_flag_ = false;}
} // namespace rmoss_cam
| 35.429907
| 95
| 0.723556
|
TomwKang
|
8922b7fcb14905b3cfe92c7633eceb8f385378a4
| 7,947
|
cpp
|
C++
|
src/ImageProcessing.cpp
|
zimmers69/CppAss4
|
eabf3f1810ddcefa93e31ddc6ccb3792036c873f
|
[
"MIT"
] | null | null | null |
src/ImageProcessing.cpp
|
zimmers69/CppAss4
|
eabf3f1810ddcefa93e31ddc6ccb3792036c873f
|
[
"MIT"
] | null | null | null |
src/ImageProcessing.cpp
|
zimmers69/CppAss4
|
eabf3f1810ddcefa93e31ddc6ccb3792036c873f
|
[
"MIT"
] | 1
|
2020-04-30T11:56:47.000Z
|
2020-04-30T11:56:47.000Z
|
//
// Created by User on 2020-03-27.
//
#include <iostream>
#include <fstream>
#include "ImageProcessing.h"
#include "Image.h"
#include <experimental/filesystem>
#include <iomanip>
#include <cmath>
namespace fs = std::experimental::filesystem;
using ZMMALE001::ImageProcessing;
using ZMMALE001::Image;
using ZMMALE001::RGB;
using ZMMALE001::clustering;
ImageProcessing::ImageProcessing(string base, int clusters, int bin , bool colour , bool otherMethod) : baseName(base), numClusters(clusters), binSize(bin), colour(colour) , otherMethod(otherMethod) {
// load all the images from <basename> folder and add to this.images
readImages(base);
}
// read all images from a given folder
bool ImageProcessing::readImages(std::string baseName) {
std::cout<<"start reading in images"<<std::endl;
// iterate through all images in basename folder
for (const auto& entry : fs::directory_iterator(baseName)) {
const auto filenameStr = entry.path().filename().string();
if (is_directory(entry)) {
// ignore
continue;
}
else if (is_regular_file(entry)) {
// PPM file. read it in as an image and add to this.images
Image img_ = readImage( baseName, filenameStr);
images.push_back( img_ );
}
else
// ignore
continue;
}
}
// read a single image when given a filepath and return an image variable
Image ImageProcessing::readImage(string baseName,string fname){
//std::cout<<"read in new image :"<< fname << std::endl;
// read header
std::ifstream header_fs(baseName+"/"+fname);
std::string magic_number,r,c,i;
header_fs >> magic_number;
if(magic_number!="P6") {
header_fs.close();
std::cerr << "Wrong image format";
exit(1);
}
header_fs>> r;
header_fs>> c;
header_fs>> i;
int h = (atoi(r.c_str()));
int w = (atoi(c.c_str()));
// create the image variable
Image temp(w,h,fname);
//header_fs.ignore(,'\n');
RGB tmp_pix;
char _r;
char _g;
char _b;
int size = h*w;
for (unsigned int j = 0; j < size; ++j) {
header_fs>> _r;
header_fs>> _g;
header_fs>> _b;
tmp_pix.red=char(_r);
tmp_pix.green=char(_g);
tmp_pix.blue=char(_b);
tmp_pix.grey= (0.21 * tmp_pix.red + 0.72 * tmp_pix.green + 0.07 * tmp_pix.blue);
temp.addPixel(tmp_pix);
}
header_fs.close();
/// implementation of harris starts
if(otherMethod==true){
//is to enhance pixels in a particular range for corners
for (unsigned int y = 0; y < temp.getHeight(); ++y) {
for (unsigned int x = 0; x < temp.getWidth(); ++x) {
if(temp.get(x, y).grey>70){
temp.get(x, y).grey=255;
} else{
temp.get(x, y).grey=0;
}
}
}
//second derivative of Gaussian
for (int y = -mkside; y <=mkside ; ++y) {
for (int x = -mkside; x <=mkside ; ++x) {
xSqrtDervMask[y+mkside][x+mkside]=(pow(x,2),-pow(segma,2))*exp(-(pow(x,2)+pow(y,2))/(2*pow(segma,2)))*1.0/pow(segma,4);
}
}
for (int y = -mkside; y <=mkside ; ++y) {
for (int x = -mkside; x <=mkside ; ++x) {
ySqrtDervMask[y+mkside][x+mkside]=(pow(y,2),-pow(segma,2))*exp(-(pow(x,2)+pow(y,2))/(2*pow(segma,2)))*1.0/pow(segma,4);
}
}
for (int y = -mkside; y <=mkside ; ++y) {
for (int x = -mkside; x <=mkside ; ++x) {
xyDervMask[y+mkside][x+mkside]=(x*y)*exp(-(pow(x,2)+pow(y,2))/(2*pow(segma,2)))*1.0/pow(segma,4);
}
}
//std:: cout<< mksize;
calRvalue(temp);
double globalMaxR = GlobalMaxR(temp);
NonMaximalSuppression(globalMaxR,temp);
//std:: cout<< mksize;
}//end of harris
// int cx=16,cy=16;
int count=0;
// double Dvalue=0;
// vector<double> v;
//// DEBUG CODE prints out the images of the coners or if make false can make it print out the other images
if(otherMethod==true) {
for (unsigned int y = 0; y < temp.getHeight(); ++y) {
for (unsigned int x = 0; x < temp.getWidth(); ++x) {
RGB &ref_colour = temp.get(x, y);
//std::cout << std::setw(3) << ref_colour.corner << " ";
//std::cout << "RGB {" <<std::setw (3) <<(int) ref_colour.red << ", " <<std::setw (3) << (int) ref_colour.green << ", "<<std::setw (3) << (int) ref_colour.blue << "}";
if (ref_colour.corner == true) {
std::cout << std::setw(3) << "C ";
// double dis=sqrt(pow((cx-x),2)+pow((cy-y),2));
// v.push_back(dis);
// Dvalue+= dis;
count++;
} else { std::cout << std::setw(3) << (int) ref_colour.grey << " "; }
// if((int)ref_colour.grey>100)
// {
// std::cout<< std::setw (3) << (int)ref_colour.grey;
// } else{
// std::cout<<std::setw(3)<<" ";
// }
}
std::cout << std::endl;
}
if (count == 0) {
std::cout << -1;
} else {
std::cout << (count);
}
}
// std::cout<<std::endl;
return temp;
}
void ZMMALE001::ImageProcessing::processAllHist() {
for(int i=0;i<images.size();i++){
//std::cout<<"Image : "<< images.at(i).getFilename()<<std::endl;
images.at(i).processHist(binSize,colour);
//std::cout<< std::endl;
}
}
void ZMMALE001::ImageProcessing::classify() {
clustering(numClusters,binSize,colour,images);
}
int ZMMALE001::ImageProcessing::getNumClusters() const {
return numClusters;
}
void ZMMALE001::ImageProcessing::calRvalue(Image &temp) {
float k= 0.05;
for (int j = mkside; j < temp.getHeight()-mkside; ++j) {
for (int i = mkside; i < temp.getWidth()-mkside; ++i) {
double xx=0.0, yy=0.0,xy=0.0;
for (int dy = -mkside; dy <=mkside ; ++dy) {
for (int dx = -mkside; dx <=mkside ; ++dx) {
xx+= (xSqrtDervMask[dy + mkside][dx + mkside]) * temp.get(i + dx, j + dy).grey;
yy+= (ySqrtDervMask[dy + mkside][dx + mkside]) *temp.get(i+dx,j+dy).grey;
xy+= (xyDervMask[dy + mkside][dx + mkside]) *temp.get(i+dx,j+dy).grey;
}
}
//R=detM -k(traceM)^2
double trace= xx+yy;
double det = (xx*yy)-(xy*xy);
double x = det - k * (pow(trace, 2));
temp.get(i,j).R=x;
//std::cout<<x<< " ";
}
}
}
void ZMMALE001::ImageProcessing::NonMaximalSuppression(float globalMaxRvalue, Image &temp) {
int gap =2;
for (int j = gap; j < temp.getHeight()-gap; ++j) {
for (int i = gap; i < temp.getWidth() - gap; ++i) {
int maxi=i, maxj =j;
float MaxR=-1000000000;
for (int dy = -gap; dy <=gap ; ++dy) {
for (int dx = -gap; dx <=gap ; ++dx) {
if(temp.get(i+dx,j+dy).R>MaxR){
MaxR=temp.get(i+dx,j+dy).R;
maxi=i+dx;
maxj=j+dy;
}
}
}
if(maxi==i && maxj ==j && MaxR>0.01*globalMaxRvalue){
temp.get(i,j).corner=true;
}
}
}
}
float ZMMALE001::ImageProcessing::GlobalMaxR( Image &temp) {
float Max =-100000000;
for (int j = mkside; j < temp.getHeight()-mkside; ++j) {
for (int i = mkside; i < temp.getWidth() - mkside; ++i) {
if(temp.get(i,j).R>Max){
Max=temp.get(i,j).R;
}
}
}
return Max;
}
| 32.703704
| 200
| 0.504593
|
zimmers69
|
89261c8ee01c9533b1e1ab40fa3b599ae96e4152
| 1,082
|
cpp
|
C++
|
vendor/uncrustify-0.59/tests/output/cpp/30701-function-def.cpp
|
b4hand/sauce
|
8e1528944bc1bd42f4c1cb36d1bebd04e4f0447b
|
[
"MIT"
] | null | null | null |
vendor/uncrustify-0.59/tests/output/cpp/30701-function-def.cpp
|
b4hand/sauce
|
8e1528944bc1bd42f4c1cb36d1bebd04e4f0447b
|
[
"MIT"
] | null | null | null |
vendor/uncrustify-0.59/tests/output/cpp/30701-function-def.cpp
|
b4hand/sauce
|
8e1528944bc1bd42f4c1cb36d1bebd04e4f0447b
|
[
"MIT"
] | null | null | null |
int &
Function()
{
static int x;
return (x);
}
void
foo1(
int param1,
int param2,
char *param2
);
void
foo2(
int param1,
int param2,
char *param2
);
void
foo3(
int param1,
int param2, // comment
char *param2
);
struct whoopee *
foo4(
int param1,
int param2,
char *param2 /* comment */
);
const struct snickers *
foo5(
int param1,
int param2,
char *param2
);
void
foo(
int param1,
int param2,
char *param2
)
{
printf("boo!\n");
}
int
classname::method();
int
classname::method()
{
foo();
}
int
classname::method2();
int
classname::method2()
{
foo2();
}
const int&
className::method1(
void
) const
{
// stuff
}
const longtypename&
className::method2(
void
) const
{
// stuff
}
int &
foo();
int &
foo()
{
list_for_each(a,b) {
bar(a);
}
return nuts;
}
void
Foo::bar() {
}
Foo::Foo() {
}
Foo::~Foo() {
}
void
func(
void
)
{
Directory dir("arg");
}
| 9.247863
| 74
| 0.505545
|
b4hand
|
892a270cd7de86ce345e63b0c6972c2a36cc4257
| 1,852
|
cpp
|
C++
|
Omniscript/src/Script.cpp
|
aaronh82/Omniscript
|
a072dad8a7a2e94032a144eb8e7115b9d4ccc29f
|
[
"MIT"
] | null | null | null |
Omniscript/src/Script.cpp
|
aaronh82/Omniscript
|
a072dad8a7a2e94032a144eb8e7115b9d4ccc29f
|
[
"MIT"
] | null | null | null |
Omniscript/src/Script.cpp
|
aaronh82/Omniscript
|
a072dad8a7a2e94032a144eb8e7115b9d4ccc29f
|
[
"MIT"
] | null | null | null |
//
// Script.cpp
// OmniScript
//
// Created by Aaron Houghton on 8/26/14.
// Copyright (c) 2014 CCBAC. All rights reserved.
//
#include "Script.h"
#include "Logger.h"
namespace script {
Script::Script(std::string name, unsigned int id, std::string lastModified, std::istream *data, bool enabled):
name_(name), id_(id), enabled_(enabled), restart_(false) {
startingBlocks_ = util::XML::build(data, *this);
std::time_t curTime = convertTime(lastModified);
if (curTime > lastModified_) {
lastModified_ = curTime;
}
}
std::time_t Script::convertTime(const std::string& sql_time) {
struct tm time_info;
strptime(sql_time.c_str(), "%Y-%m-%d %H:%M:%S", &time_info);
time_info.tm_isdst = -1;
return mktime(&time_info);
}
// Public
void Script::name(std::string n) {
name_ = n;
}
std::string Script::name() const {
return name_;
}
unsigned int Script::id() {
return id_;
}
unsigned int Script::id() const {
return id_;
}
const std::vector<var_ptr>& Script::variables() {
return variables_;
}
const std::vector<point_ptr>& Script::points() {
return points_;
}
std::vector<dev_ptr>& Script::devices() {
return devices_;
}
void Script::enable() {
enabled_ = true;
}
void Script::disable() {
enabled_ = false;
}
bool Script::isEnabled() {
return enabled_;
}
bool Script::isEnabled() const {
return enabled_;
}
std::map<int, block_ptr> Script::startingBlocks() {
return startingBlocks_;
}
bool Script::updated(std::string sql_time) {
std::time_t new_time = convertTime(sql_time);
if (new_time > lastModified_) {
lastModified_ = new_time;
return true;
}
return false;
}
void Script::updateScript(std::istream *data) {
startingBlocks_ = util::XML::build(data, *this);
}
bool Script::needsRestart() {
return restart_;
}
}
| 19.092784
| 113
| 0.655508
|
aaronh82
|
8938a851c235271cad5eaf93bf0dd5d448b2fc7b
| 3,945
|
hpp
|
C++
|
Maze/cell.hpp
|
CodeBulletin/Maze.Exe
|
2cd3e7b2733f8f236dcd4f09e5048aba295f66e5
|
[
"MIT"
] | 1
|
2021-09-07T11:53:16.000Z
|
2021-09-07T11:53:16.000Z
|
Maze/cell.hpp
|
CodeBulletin/Maze.Exe
|
2cd3e7b2733f8f236dcd4f09e5048aba295f66e5
|
[
"MIT"
] | null | null | null |
Maze/cell.hpp
|
CodeBulletin/Maze.Exe
|
2cd3e7b2733f8f236dcd4f09e5048aba295f66e5
|
[
"MIT"
] | null | null | null |
#pragma once
#include "wall.hpp"
struct cell {
int i, j;
sf::Vector2f pos;
float size, wallSize;
sf::Color col, visitedCol, activeCol, currentCol, walkColor, PathColor, frontColor, wallActiveCol, cCol = { 0, 0, 0, 0 };
bool visited = false, inStack = false, current=false;
sf::Vertex v[4];
wall walls[4];
cell() {}
cell(int i, int j, const sf::Vector2f& pos, float size, float wallSize, const sf::Color& col, const sf::Color& visitedCol,
const sf::Color stack_col, const sf::Color& current, const sf::Color& walkColor, const sf::Color& PathColor,
const sf::Color& frontColor, const sf::Color& wallActiveCol) :
i(i), j(j), pos(pos), size(size), wallSize(wallSize), col(col), visitedCol(visitedCol), activeCol(stack_col),
currentCol(current), walkColor(walkColor), PathColor(PathColor), frontColor(frontColor), wallActiveCol(wallActiveCol) {
makeSquare();
}
void makeSquare() {
v[0].color = col;
v[0].position = { pos.x - size / 2, pos.y - size / 2 };
v[1].color = col;
v[1].position = { pos.x + size / 2, pos.y - size / 2 };
walls[0] = wall(
{ v[0].position.x + wallSize, v[0].position.y },
{ v[1].position.x - wallSize, v[1].position.y },
{ v[1].position.x - wallSize, v[1].position.y - wallSize },
{ v[0].position.x + wallSize, v[0].position.y - wallSize },
wallActiveCol);
v[2].color = col;
v[2].position = { pos.x + size / 2, pos.y + size / 2 };
walls[1] = wall(
{ v[1].position.x, v[1].position.y + wallSize },
{ v[2].position.x, v[2].position.y - wallSize },
{ v[2].position.x + wallSize, v[2].position.y - wallSize },
{ v[1].position.x + wallSize, v[1].position.y + wallSize },
wallActiveCol);
v[3].color = col;
v[3].position = { pos.x - size / 2, pos.y + size / 2 };
walls[2] = wall(
{ v[2].position.x - wallSize, v[2].position.y },
{ v[3].position.x + wallSize, v[3].position.y },
{ v[3].position.x + wallSize, v[3].position.y + wallSize },
{ v[2].position.x - wallSize, v[2].position.y + wallSize },
wallActiveCol);
walls[3] = wall(
{ v[3].position.x, v[3].position.y - wallSize },
{ v[0].position.x, v[0].position.y + wallSize },
{ v[0].position.x - wallSize, v[0].position.y + wallSize },
{ v[3].position.x - wallSize, v[3].position.y - wallSize },
wallActiveCol);
}
void draw(std::vector<sf::Vertex>& drawVec, std::vector<sf::Vertex>& drawWall) {
drawVec.push_back(v[0]);
drawVec.push_back(v[1]);
drawVec.push_back(v[2]);
drawVec.push_back(v[3]);
walls[0].draw(drawWall);
walls[1].draw(drawWall);
walls[2].draw(drawWall);
walls[3].draw(drawWall);
}
void setVisited() {
v[0].color = visitedCol;
v[1].color = visitedCol;
v[2].color = visitedCol;
v[3].color = visitedCol;
}
void setInStack() {
v[0].color = activeCol;
v[1].color = activeCol;
v[2].color = activeCol;
v[3].color = activeCol;
}
void setCurrent() {
v[0].color = currentCol;
v[1].color = currentCol;
v[2].color = currentCol;
v[3].color = currentCol;
}
void setWalk() {
v[0].color = walkColor;
v[1].color = walkColor;
v[2].color = walkColor;
v[3].color = walkColor;
}
void setPath() {
v[0].color = PathColor;
v[1].color = PathColor;
v[2].color = PathColor;
v[3].color = PathColor;
}
void setFront() {
v[0].color = frontColor;
v[1].color = frontColor;
v[2].color = frontColor;
v[3].color = frontColor;
}
void setColor(const sf::Color& Col) {
v[0].color = Col;
v[1].color = Col;
v[2].color = Col;
v[3].color = Col;
cCol = Col;
}
void addWalls(std::vector<sf::Vector3i>& WallsList, int dont = -1) {
if (dont != 3) {
WallsList.push_back({ i, j, 3 });
}
if (dont != 2) {
WallsList.push_back({ i, j, 2 });
}
if (dont != 1) {
WallsList.push_back({ i, j, 1 });
}
if (dont != 0) {
WallsList.push_back({ i, j, 0 });
}
}
};
| 30.581395
| 124
| 0.591888
|
CodeBulletin
|
9f135f484649fa712521d8a6bfaa4d9a34529cf0
| 1,281
|
hpp
|
C++
|
sydney-2017-03-29/make_crowd.hpp
|
cjdb/cpp-conferences
|
bafe69cf11ca38451367553460e956cb52df3dd2
|
[
"Apache-2.0"
] | 3
|
2017-09-15T00:10:25.000Z
|
2018-09-22T12:50:18.000Z
|
sydney-2017-03-29/make_crowd.hpp
|
cjdb/cppcon
|
bafe69cf11ca38451367553460e956cb52df3dd2
|
[
"Apache-2.0"
] | 1
|
2017-12-04T22:12:16.000Z
|
2017-12-04T22:12:16.000Z
|
sydney-2017-03-29/make_crowd.hpp
|
cjdb/cppcon
|
bafe69cf11ca38451367553460e956cb52df3dd2
|
[
"Apache-2.0"
] | 1
|
2017-12-04T10:50:54.000Z
|
2017-12-04T10:50:54.000Z
|
#ifndef MAKE_CROWD_HPP
#define MAKE_CROWD_HPP
#include <experimental/ranges/algorithm>
#include <experimental/ranges/iterator>
#include <iostream>
#include <random>
namespace ranges = std::experimental::ranges;
template <ranges::InputRange Rng>
Rng make_crowd(const int children, const int adults, const int seniors)
{
auto crowd = std::vector<int>{};
// random number generator in C++... much better than what you're used to!
auto generator = std::mt19937{std::random_device{}()};
auto distribute = std::uniform_int_distribution<>{0, 17};
for (auto i = 0; i < children; ++i)
crowd.push_back(distribute(generator));
distribute = std::uniform_int_distribution<>{18, 64};
for (auto i = 0; i < adults; ++i)
crowd.push_back(distribute(generator));
distribute = std::uniform_int_distribution<>{65, 128};
for (auto i = 0; i < seniors; ++i)
crowd.push_back(distribute(generator));
return {crowd.cbegin(), crowd.cend()};
}
template <ranges::InputIterator I, ranges::Sentinel<I> S>
void print_crowd(I first, S last)
{
ranges::copy(first, last, ranges::ostream_iterator<ranges::value_type_t<I>>{std::cout, " "});
std::cout << '\n';
}
constexpr auto young_adult = 18;
constexpr auto almost_senior = 64;
#endif // MAKE_CROWD_HPP
| 29.113636
| 96
| 0.697112
|
cjdb
|
9f157989e2003e03d1acf338cb9d60f7ae458cd2
| 567
|
cc
|
C++
|
test/regression/aarch64/Exception.cc
|
viper12590/SimEng
|
e9fc4d24a8823e553e042c60801aa0a0e3f077ca
|
[
"Apache-2.0"
] | null | null | null |
test/regression/aarch64/Exception.cc
|
viper12590/SimEng
|
e9fc4d24a8823e553e042c60801aa0a0e3f077ca
|
[
"Apache-2.0"
] | null | null | null |
test/regression/aarch64/Exception.cc
|
viper12590/SimEng
|
e9fc4d24a8823e553e042c60801aa0a0e3f077ca
|
[
"Apache-2.0"
] | null | null | null |
#include "AArch64RegressionTest.hh"
namespace {
using Exception = AArch64RegressionTest;
// Test that branching to an address that is misaligned raises an exception.
TEST_P(Exception, misaligned_pc) {
RUN_AARCH64(R"(
mov x0, 5
br x0
)");
const char err[] = "\nEncountered misaligned program counter exception";
EXPECT_EQ(stdout_.substr(0, sizeof(err) - 1), err);
}
INSTANTIATE_TEST_SUITE_P(AArch64, Exception,
::testing::Values(EMULATION, INORDER, OUTOFORDER),
coreTypeToString);
} // namespace
| 25.772727
| 76
| 0.673721
|
viper12590
|
9f1db262822705206e17c844efd4d2ef303535d9
| 3,744
|
hpp
|
C++
|
include/System/Diagnostics/CorrelationManager.hpp
|
RedBrumbler/BeatSaber-Quest-Codegen
|
73dda50b5a3e51f10d86b766dcaa24b0c6226e25
|
[
"Unlicense"
] | null | null | null |
include/System/Diagnostics/CorrelationManager.hpp
|
RedBrumbler/BeatSaber-Quest-Codegen
|
73dda50b5a3e51f10d86b766dcaa24b0c6226e25
|
[
"Unlicense"
] | null | null | null |
include/System/Diagnostics/CorrelationManager.hpp
|
RedBrumbler/BeatSaber-Quest-Codegen
|
73dda50b5a3e51f10d86b766dcaa24b0c6226e25
|
[
"Unlicense"
] | null | null | null |
// Autogenerated from CppHeaderCreator
// Created by Sc2ad
// =========================================================================
#pragma once
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
#include "beatsaber-hook/shared/utils/byref.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Begin forward declares
// Forward declaring namespace: System::Collections
namespace System::Collections {
// Forward declaring type: Stack
class Stack;
}
// Completed forward declares
// Type namespace: System.Diagnostics
namespace System::Diagnostics {
// Forward declaring type: CorrelationManager
class CorrelationManager;
}
#include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp"
NEED_NO_BOX(::System::Diagnostics::CorrelationManager);
DEFINE_IL2CPP_ARG_TYPE(::System::Diagnostics::CorrelationManager*, "System.Diagnostics", "CorrelationManager");
// Type namespace: System.Diagnostics
namespace System::Diagnostics {
// Size: 0x10
#pragma pack(push, 1)
// Autogenerated type: System.Diagnostics.CorrelationManager
// [TokenAttribute] Offset: FFFFFFFF
class CorrelationManager : public ::Il2CppObject {
public:
// public System.Collections.Stack get_LogicalOperationStack()
// Offset: 0x1CA72F4
::System::Collections::Stack* get_LogicalOperationStack();
// private System.Collections.Stack GetLogicalOperationStack()
// Offset: 0x1CA72F8
::System::Collections::Stack* GetLogicalOperationStack();
// System.Void .ctor()
// Offset: 0x1CA72EC
// Implemented from: System.Object
// Base method: System.Void Object::.ctor()
template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary>
static CorrelationManager* New_ctor() {
static auto ___internal__logger = ::Logger::get().WithContext("::System::Diagnostics::CorrelationManager::.ctor");
return THROW_UNLESS((::il2cpp_utils::New<CorrelationManager*, creationType>()));
}
}; // System.Diagnostics.CorrelationManager
#pragma pack(pop)
}
#include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
// Writing MetadataGetter for method: System::Diagnostics::CorrelationManager::get_LogicalOperationStack
// Il2CppName: get_LogicalOperationStack
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::System::Collections::Stack* (System::Diagnostics::CorrelationManager::*)()>(&System::Diagnostics::CorrelationManager::get_LogicalOperationStack)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(System::Diagnostics::CorrelationManager*), "get_LogicalOperationStack", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: System::Diagnostics::CorrelationManager::GetLogicalOperationStack
// Il2CppName: GetLogicalOperationStack
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::System::Collections::Stack* (System::Diagnostics::CorrelationManager::*)()>(&System::Diagnostics::CorrelationManager::GetLogicalOperationStack)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(System::Diagnostics::CorrelationManager*), "GetLogicalOperationStack", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: System::Diagnostics::CorrelationManager::New_ctor
// Il2CppName: .ctor
// Cannot get method pointer of value based method overload from template for constructor!
// Try using FindMethod instead!
| 49.92
| 218
| 0.753472
|
RedBrumbler
|
9f1fb38cdbba05f28499311ca0ad0b6682ac61bb
| 2,393
|
cpp
|
C++
|
samples/tools/create_HV_registration_image_mask.cpp
|
v4r-tuwien/v4r
|
ff3fbd6d2b298b83268ba4737868bab258262a40
|
[
"BSD-1-Clause",
"BSD-2-Clause"
] | 2
|
2021-02-22T11:36:33.000Z
|
2021-07-20T11:31:08.000Z
|
samples/tools/create_HV_registration_image_mask.cpp
|
v4r-tuwien/v4r
|
ff3fbd6d2b298b83268ba4737868bab258262a40
|
[
"BSD-1-Clause",
"BSD-2-Clause"
] | null | null | null |
samples/tools/create_HV_registration_image_mask.cpp
|
v4r-tuwien/v4r
|
ff3fbd6d2b298b83268ba4737868bab258262a40
|
[
"BSD-1-Clause",
"BSD-2-Clause"
] | 3
|
2018-10-19T10:39:23.000Z
|
2021-04-07T13:39:03.000Z
|
#include <pcl/io/pcd_io.h>
#include <v4r/io/filesystem.h>
#include <opencv2/opencv.hpp>
#include <boost/program_options.hpp>
namespace po = boost::program_options;
int main(int argc, char **argv) {
typedef pcl::PointXYZRGB PointT;
bf::path input_dir;
bf::path output_file = "/tmp/depth_mask.png";
bool search_recursive = false;
po::options_description desc(
"Tool to compute the image mask from a set of point clouds. The mask shows which points of a registered point"
"cloud are visible\n======================================\n**Allowed options");
desc.add_options()("help,h", "produce help message");
desc.add_options()("input_dir,i", po::value<bf::path>(&input_dir)->required(),
"input directory containing the .pcd files");
desc.add_options()("output_file,o", po::value<bf::path>(&output_file)->default_value(output_file),
"path to where the image mask (.png) will be saved to.");
desc.add_options()("recursive_file_search, r", po::value<bool>(&search_recursive)->default_value(search_recursive),
"include sub-folders for input");
po::positional_options_description p;
p.add("input_dir", 1);
p.add("output_file", 1);
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
if (vm.count("help")) {
std::cout << desc << std::endl;
return false;
}
try {
po::notify(vm);
} catch (std::exception &e) {
std::cerr << "Error: " << e.what() << std::endl << std::endl << desc << std::endl;
return false;
}
std::vector<std::string> sub_folder_names = v4r::io::getFilesInDirectory(input_dir, ".*.pcd", search_recursive);
cv::Mat_<unsigned char> img_mask;
for (const std::string &basename : sub_folder_names) {
bf::path input_fn = input_dir / basename;
std::cout << "Loading image " << input_fn.string() << std::endl;
pcl::PointCloud<PointT> cloud;
pcl::io::loadPCDFile(input_fn.string(), cloud);
if (!img_mask.data) {
img_mask = cv::Mat_<unsigned char>(cloud.height, cloud.width);
img_mask.setTo(0);
}
for (size_t u = 0; u < cloud.width; u++) {
for (size_t v = 0; v < cloud.height; v++) {
if (pcl::isFinite(cloud.at(u, v)))
img_mask.at<unsigned char>(v, u) = 255;
}
}
}
cv::imwrite(output_file.string(), img_mask);
}
| 34.185714
| 117
| 0.630171
|
v4r-tuwien
|
9f2006353b806e7fdc2fd4ee024dc538cdeb10e4
| 6,819
|
hh
|
C++
|
ncrystal_core/include/NCrystal/internal/NCString.hh
|
mctools/ncrystal
|
33ec51187a3bef418046c30e591ff7d8f239d54f
|
[
"Apache-2.0"
] | 22
|
2017-08-31T08:44:10.000Z
|
2022-03-21T08:18:26.000Z
|
ncrystal_core/include/NCrystal/internal/NCString.hh
|
XuShuqi7/ncrystal
|
acf26db3dfd5f0a95355c7c3bbfcbfee55040175
|
[
"Apache-2.0"
] | 77
|
2018-01-23T10:19:45.000Z
|
2022-03-21T07:57:32.000Z
|
ncrystal_core/include/NCrystal/internal/NCString.hh
|
XuShuqi7/ncrystal
|
acf26db3dfd5f0a95355c7c3bbfcbfee55040175
|
[
"Apache-2.0"
] | 11
|
2017-09-14T19:49:50.000Z
|
2022-02-28T11:07:00.000Z
|
#ifndef NCrystal_String_hh
#define NCrystal_String_hh
////////////////////////////////////////////////////////////////////////////////
// //
// This file is part of NCrystal (see https://mctools.github.io/ncrystal/) //
// //
// Copyright 2015-2021 NCrystal developers //
// //
// 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. //
// //
////////////////////////////////////////////////////////////////////////////////
//String-related utilities
#include "NCrystal/NCDefs.hh"
#include <ostream>
namespace NCrystal {
//All bytes must be in range 32..126 (plus optionally new-lines and tabs).
bool isSimpleASCII(const std::string&, bool allow_tab=false, bool allow_newline = false);
//Strip excess whitespace (" \t\r\n") from both ends of string:
void trim( std::string& );
//Split input string on separator (default sep=0 means splitting on general
//whitespace - " \t\r\n"). Results are placed in output vector, which is first
//cleared of existing contents. Empty parts are only kept when sep!=0 (similar
//to pythons str.split()). Finally, maxsplit can be used to limit the number
//of splittings performed:
VectS split2( const std::string& input,
std::size_t maxsplit = 0,
char sep = 0);
//Backwards compatible version (eventually we will remove this and rename
//split2->split):
void split(VectS& output,
const std::string& input,
std::size_t maxsplit = 0,
char sep = 0 );
//Substrings at edges:
bool startswith(const std::string& str, const std::string& substr);
bool endswith(const std::string& str, const std::string& substr);
//Check if given char or substring (needle) is present in a string (haystack):
bool contains(const std::string& haystack, char needle );
bool contains(const std::string& haystack, const std::string& needle);
//Check if any of the chars in "needles" is present in the string (haystack):
bool contains_any(const std::string& haystack, const std::string& needles);
//Check if "haystack" consists entirely of chars from string needles:
bool contains_only(const std::string& haystack, const std::string& needles);
//Change string casing:
std::string lowerCase( std::string );
std::string upperCase( std::string );
//Check if alphanumeric (defined as containing only a-zA-Z0-9):
bool isAlphaNumeric( const char );
bool isAlphaNumeric( const std::string& );
//Convert strings to numbers. In case of problems, a BadInput exception will
//be thrown (provide err to modify the message in that exception):
NCRYSTAL_API double str2dbl(const std::string&, const char * errmsg = 0);//marked NCRYSTAL_API since used in custom physics example
int str2int(const std::string&, const char * errmsg = 0);
//Versions which don't throw:
bool safe_str2dbl(const std::string&, double& result );
bool safe_str2int(const std::string&, int& result );
//Convenience:
inline bool isDouble( const std::string& ss ) { double dummy; return safe_str2dbl(ss,dummy); }
inline bool isInt( const std::string& ss ) { int dummy; return safe_str2int(ss,dummy); }
//How many digits does string end with (e.g. 1 in "H1", 0 in "H1a", 3 in "Bla123".
unsigned countTrailingDigits( const std::string& ss );
//"Bla123" => ("Bla","123"). Special cases: "Bla" -> ("Bla","") "Bla012" -> ("Bla","012")
PairSS decomposeStrWithTrailingDigits( const std::string& ss );
//Replace all occurances of oldtxt in str with newtxt:
void strreplace(std::string& str, const std::string& oldtxt, const std::string& newtxt);
//["a","bb","123"] -> "a bb 123":
std::string joinstr(const VectS& parts, std::string separator = " ");
//Pretty-prints a value. If detectSimpleRationalNumbers detects a simple
//fraction, it will be printed as e.g. "2/9", or "3" (in case of integers). If
//not, it will be printed as a floating point (with a particular precision in
//case prec!=0):
void prettyPrintValue(std::ostream& os, double value, unsigned prec=0 );
std::string prettyPrintValue2Str(double value, unsigned prec=0 );
//Convert values to/from hex strings:
std::string bytes2hexstr(const std::vector<uint8_t>& v);
std::vector<uint8_t> hexstr2bytes(const std::string& v);
//Common access to environment variables - will always be prefixed with
//NCRYSTAL_. Unset variables means that the default values will be
//returned. The _dbl/_int versions throws BadInput exceptions in case of
//problems:
//NB: Assuming no-one calls setenv/putenv/unsetenv, concurrent calls to these
//functions are safe (since C++11).
std::string ncgetenv(std::string, std::string defval = std::string() );
double ncgetenv_dbl(std::string, double defval = 0.0);
int ncgetenv_int(std::string, int defval = 0 );
bool ncgetenv_bool(std::string);//if set to 1 -> true, 0/unset -> false (otherwise exception).
}
////////////////////////////
// Inline implementations //
////////////////////////////
namespace NCrystal {
inline std::string lowerCase( std::string s )
{
static_assert('A'+32 == 'a',"");
for (auto& c : s)
if ( c >= 'A' && c <= 'Z' )
c += 32;
return s;
}
inline std::string upperCase( std::string s )
{
static_assert('A'+32 == 'a',"");
for (auto& c : s)
if ( c >= 'a' && c <= 'z' )
c -= 32;
return s;
}
inline bool isAlphaNumeric( const char c )
{
return ( c>='a' && c<='z' ) || ( c>='A' && c<='Z' ) || ( c>='0' && c<='9' );
}
inline bool isAlphaNumeric( const std::string& s )
{
for ( auto c : s )
if (!isAlphaNumeric(c))
return false;
return true;
}
}
#endif
| 41.579268
| 133
| 0.587476
|
mctools
|
9f28065ee8f60cb3b0ac482ee26eebb5c574507e
| 3,654
|
cpp
|
C++
|
source/04_Geometry/05_Sutherland-Hodgman Algorithm.cpp
|
KerakTelor86/AlgoCopypasta
|
900d989c0651b51b55c551d336c2e92faead0fc8
|
[
"WTFPL"
] | 1
|
2021-06-25T05:46:11.000Z
|
2021-06-25T05:46:11.000Z
|
source/04_Geometry/05_Sutherland-Hodgman Algorithm.cpp
|
KerakTelor86/AlgoCopypasta
|
900d989c0651b51b55c551d336c2e92faead0fc8
|
[
"WTFPL"
] | null | null | null |
source/04_Geometry/05_Sutherland-Hodgman Algorithm.cpp
|
KerakTelor86/AlgoCopypasta
|
900d989c0651b51b55c551d336c2e92faead0fc8
|
[
"WTFPL"
] | null | null | null |
// Complexity: linear time
// Ada 2 poligon, cari poligon intersectionnya
// poly_point = hasilnya, clipper = pemotongnya
#include<bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
struct point {
double x, y;
point(double _x, double _y): x(_x), y(_y) {}
};
struct vec {
double x, y;
vec(double _x, double _y): x(_x), y(_y) {}
};
point pivot(0, 0);
vec toVec(point a, point b) {
return vec(b.x - a.x, b.y - a.y);
}
double dist(point a, point b) {
return hypot(a.x - b.x, a.y - b.y);
}
double cross(vec a, vec b) {
return a.x * b.y - a.y * b.x;
}
bool ccw(point p, point q, point r) {
return cross(toVec(p, q), toVec(p, r)) > 0;
}
bool collinear(point p, point q, point r) {
return fabs(cross(toVec(p, q), toVec(p, r))) < EPS;
}
bool lies(point a, point b, point c) {
if((c.x >= min(a.x, b.x) && c.x <= max(a.x, b.x)) &&
(c.y >= min(a.y, b.y) && c.y <= max(a.y, b.y)))
return true;
else
return false;
}
bool anglecmp(point a, point b) {
if(collinear(pivot, a, b))
return dist(pivot, a) < dist(pivot, b);
double d1x = a.x - pivot.x, d1y = a.y - pivot.y;
double d2x = b.x - pivot.x, d2y = b.y - pivot.y;
return (atan2(d1y, d1x) - atan2(d2y, d2x)) < 0;
}
point intersect(point s1, point e1, point s2, point e2) {
double x1, x2, x3, x4, y1, y2, y3, y4;
x1 = s1.x;
y1 = s1.y;
x2 = e1.x;
y2 = e1.y;
x3 = s2.x;
y3 = s2.y;
x4 = e2.x;
y4 = e2.y;
double num1 = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);
double num2 = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);
double den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
double new_x = num1 / den;
double new_y = num2 / den;
return point(new_x, new_y);
}
void clip(vector <point>& poly_points, point point1, point point2) {
vector <point> new_points;
new_points.clear();
for(int i = 0; i < poly_points.size(); i++) {
int k = (i + 1) % poly_points.size();
double i_pos = ccw(point1, point2, poly_points[i]);
double k_pos = ccw(point1, point2, poly_points[k]);
//in in
if(i_pos <= 0 && k_pos <= 0)
new_points.push_back(poly_points[k]);
//out in
else if(i_pos > 0 && k_pos <= 0) {
new_points.push_back(intersect(point1, point2, poly_points[i],
poly_points[k]));
new_points.push_back(poly_points[k]);
}
// in out
else if(i_pos <= 0 && k_pos > 0) {
new_points.push_back(intersect(point1, point2, poly_points[i],
poly_points[k]));
}
//out out
else {
}
}
poly_points.clear();
for(int i = 0; i < new_points.size(); i++)
poly_points.push_back(new_points[i]);
}
double area(const vector <point>& P) {
double result = 0.0;
double x1, y1, x2, y2;
for(int i = 0; i < P.size() - 1; i++) {
x1 = P[i].x;
y1 = P[i].y;
x2 = P[i + 1].x;
y2 = P[i + 1].y;
result += (x1 * y2 - x2 * y1);
}
return fabs(result) / 2;
}
void suthHodgClip(vector <point>& poly_points, vector <point> clipper_points) {
for(int i = 0; i < clipper_points.size(); i++) {
int k = (i + 1) % clipper_points.size();
clip(poly_points, clipper_points[i], clipper_points[k]);
}
}
vector<point> sortku(vector<point> P) {
int P0 = 0;
int i;
for(i = 1; i < 3; i++) {
if(P[i].y < P[P0].y || (P[i].y == P[P0].y && P[i].x > P[P0].x))
P0 = i;
}
point temp = P[0];
P[0] = P[P0];
P[P0] = temp;
pivot = P[0];
sort(++P.begin(), P.end(), anglecmp);
reverse(++P.begin(), P.end());
return P;
}
int main {
clipper_points = sortku(clipper_points);
suthHodgClip(poly_points, clipper_points);
}
| 27.473684
| 82
| 0.552819
|
KerakTelor86
|
9f2c023c6d4f8b815290948989696f2db3dea2a7
| 14,835
|
cpp
|
C++
|
src/RcppExports.cpp
|
lgaborini/rdirdirgamma
|
f3087f0a81c9e4b08ff56efcc260873eaa16232d
|
[
"MIT"
] | null | null | null |
src/RcppExports.cpp
|
lgaborini/rdirdirgamma
|
f3087f0a81c9e4b08ff56efcc260873eaa16232d
|
[
"MIT"
] | null | null | null |
src/RcppExports.cpp
|
lgaborini/rdirdirgamma
|
f3087f0a81c9e4b08ff56efcc260873eaa16232d
|
[
"MIT"
] | null | null | null |
// Generated by using Rcpp::compileAttributes() -> do not edit by hand
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#include <RcppArmadillo.h>
#include <RcppGSL.h>
#include <Rcpp.h>
using namespace Rcpp;
// sample_ABC_rdirdirgamma_beta_cpp
Rcpp::NumericMatrix sample_ABC_rdirdirgamma_beta_cpp(const unsigned int& n_sample, const unsigned int& m_sample, const double& alpha_0, const double& beta_0, const Rcpp::NumericVector& nu_0, const Rcpp::NumericMatrix& mtx_obs, const unsigned int& reps, const double& p_norm, const bool use_optimized_summary);
RcppExport SEXP _rdirdirgamma_sample_ABC_rdirdirgamma_beta_cpp(SEXP n_sampleSEXP, SEXP m_sampleSEXP, SEXP alpha_0SEXP, SEXP beta_0SEXP, SEXP nu_0SEXP, SEXP mtx_obsSEXP, SEXP repsSEXP, SEXP p_normSEXP, SEXP use_optimized_summarySEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const unsigned int& >::type n_sample(n_sampleSEXP);
Rcpp::traits::input_parameter< const unsigned int& >::type m_sample(m_sampleSEXP);
Rcpp::traits::input_parameter< const double& >::type alpha_0(alpha_0SEXP);
Rcpp::traits::input_parameter< const double& >::type beta_0(beta_0SEXP);
Rcpp::traits::input_parameter< const Rcpp::NumericVector& >::type nu_0(nu_0SEXP);
Rcpp::traits::input_parameter< const Rcpp::NumericMatrix& >::type mtx_obs(mtx_obsSEXP);
Rcpp::traits::input_parameter< const unsigned int& >::type reps(repsSEXP);
Rcpp::traits::input_parameter< const double& >::type p_norm(p_normSEXP);
Rcpp::traits::input_parameter< const bool >::type use_optimized_summary(use_optimized_summarySEXP);
rcpp_result_gen = Rcpp::wrap(sample_ABC_rdirdirgamma_beta_cpp(n_sample, m_sample, alpha_0, beta_0, nu_0, mtx_obs, reps, p_norm, use_optimized_summary));
return rcpp_result_gen;
END_RCPP
}
// generate_acceptable_data_cpp
arma::cube generate_acceptable_data_cpp(const unsigned int& n_sample, const unsigned int& m_sample, const double& alpha_0, const double& beta_0, const Rcpp::NumericVector& nu_0, const Rcpp::NumericMatrix& mtx_obs, const Rcpp::NumericVector& summarize_eps, const unsigned int reps, const unsigned int max_iter, const double& p_norm, const bool use_optimized_summary);
RcppExport SEXP _rdirdirgamma_generate_acceptable_data_cpp(SEXP n_sampleSEXP, SEXP m_sampleSEXP, SEXP alpha_0SEXP, SEXP beta_0SEXP, SEXP nu_0SEXP, SEXP mtx_obsSEXP, SEXP summarize_epsSEXP, SEXP repsSEXP, SEXP max_iterSEXP, SEXP p_normSEXP, SEXP use_optimized_summarySEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const unsigned int& >::type n_sample(n_sampleSEXP);
Rcpp::traits::input_parameter< const unsigned int& >::type m_sample(m_sampleSEXP);
Rcpp::traits::input_parameter< const double& >::type alpha_0(alpha_0SEXP);
Rcpp::traits::input_parameter< const double& >::type beta_0(beta_0SEXP);
Rcpp::traits::input_parameter< const Rcpp::NumericVector& >::type nu_0(nu_0SEXP);
Rcpp::traits::input_parameter< const Rcpp::NumericMatrix& >::type mtx_obs(mtx_obsSEXP);
Rcpp::traits::input_parameter< const Rcpp::NumericVector& >::type summarize_eps(summarize_epsSEXP);
Rcpp::traits::input_parameter< const unsigned int >::type reps(repsSEXP);
Rcpp::traits::input_parameter< const unsigned int >::type max_iter(max_iterSEXP);
Rcpp::traits::input_parameter< const double& >::type p_norm(p_normSEXP);
Rcpp::traits::input_parameter< const bool >::type use_optimized_summary(use_optimized_summarySEXP);
rcpp_result_gen = Rcpp::wrap(generate_acceptable_data_cpp(n_sample, m_sample, alpha_0, beta_0, nu_0, mtx_obs, summarize_eps, reps, max_iter, p_norm, use_optimized_summary));
return rcpp_result_gen;
END_RCPP
}
// compute_ABC_cpp
Rcpp::List compute_ABC_cpp(const unsigned int& n_sample, const unsigned int& m_sample, const double& alpha_0, const double& beta_0, const Rcpp::NumericVector& nu_0, const Rcpp::NumericMatrix& mtx_obs, const Rcpp::NumericVector& summarize_eps, const unsigned int reps, const double& p_norm, const bool use_optimized_summary, const bool return_distances);
RcppExport SEXP _rdirdirgamma_compute_ABC_cpp(SEXP n_sampleSEXP, SEXP m_sampleSEXP, SEXP alpha_0SEXP, SEXP beta_0SEXP, SEXP nu_0SEXP, SEXP mtx_obsSEXP, SEXP summarize_epsSEXP, SEXP repsSEXP, SEXP p_normSEXP, SEXP use_optimized_summarySEXP, SEXP return_distancesSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const unsigned int& >::type n_sample(n_sampleSEXP);
Rcpp::traits::input_parameter< const unsigned int& >::type m_sample(m_sampleSEXP);
Rcpp::traits::input_parameter< const double& >::type alpha_0(alpha_0SEXP);
Rcpp::traits::input_parameter< const double& >::type beta_0(beta_0SEXP);
Rcpp::traits::input_parameter< const Rcpp::NumericVector& >::type nu_0(nu_0SEXP);
Rcpp::traits::input_parameter< const Rcpp::NumericMatrix& >::type mtx_obs(mtx_obsSEXP);
Rcpp::traits::input_parameter< const Rcpp::NumericVector& >::type summarize_eps(summarize_epsSEXP);
Rcpp::traits::input_parameter< const unsigned int >::type reps(repsSEXP);
Rcpp::traits::input_parameter< const double& >::type p_norm(p_normSEXP);
Rcpp::traits::input_parameter< const bool >::type use_optimized_summary(use_optimized_summarySEXP);
Rcpp::traits::input_parameter< const bool >::type return_distances(return_distancesSEXP);
rcpp_result_gen = Rcpp::wrap(compute_ABC_cpp(n_sample, m_sample, alpha_0, beta_0, nu_0, mtx_obs, summarize_eps, reps, p_norm, use_optimized_summary, return_distances));
return rcpp_result_gen;
END_RCPP
}
// compute_distances_gen_obs_cpp
Rcpp::NumericVector compute_distances_gen_obs_cpp(const Rcpp::NumericMatrix& mtx_gen, const Rcpp::NumericMatrix& mtx_obs, const double& p_norm, const bool use_optimized_summary);
RcppExport SEXP _rdirdirgamma_compute_distances_gen_obs_cpp(SEXP mtx_genSEXP, SEXP mtx_obsSEXP, SEXP p_normSEXP, SEXP use_optimized_summarySEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< const Rcpp::NumericMatrix& >::type mtx_gen(mtx_genSEXP);
Rcpp::traits::input_parameter< const Rcpp::NumericMatrix& >::type mtx_obs(mtx_obsSEXP);
Rcpp::traits::input_parameter< const double& >::type p_norm(p_normSEXP);
Rcpp::traits::input_parameter< const bool >::type use_optimized_summary(use_optimized_summarySEXP);
rcpp_result_gen = Rcpp::wrap(compute_distances_gen_obs_cpp(mtx_gen, mtx_obs, p_norm, use_optimized_summary));
return rcpp_result_gen;
END_RCPP
}
// get_number_summary_statistics
unsigned int get_number_summary_statistics(bool use_optimized_summary);
RcppExport SEXP _rdirdirgamma_get_number_summary_statistics(SEXP use_optimized_summarySEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< bool >::type use_optimized_summary(use_optimized_summarySEXP);
rcpp_result_gen = Rcpp::wrap(get_number_summary_statistics(use_optimized_summary));
return rcpp_result_gen;
END_RCPP
}
// get_optimized_summary_statistics_cpp
Rcpp::NumericMatrix get_optimized_summary_statistics_cpp(const Rcpp::NumericMatrix& mtx);
RcppExport SEXP _rdirdirgamma_get_optimized_summary_statistics_cpp(SEXP mtxSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< const Rcpp::NumericMatrix& >::type mtx(mtxSEXP);
rcpp_result_gen = Rcpp::wrap(get_optimized_summary_statistics_cpp(mtx));
return rcpp_result_gen;
END_RCPP
}
// get_standard_summary_statistics_cpp
Rcpp::NumericMatrix get_standard_summary_statistics_cpp(const Rcpp::NumericMatrix& mtx);
RcppExport SEXP _rdirdirgamma_get_standard_summary_statistics_cpp(SEXP mtxSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< const Rcpp::NumericMatrix& >::type mtx(mtxSEXP);
rcpp_result_gen = Rcpp::wrap(get_standard_summary_statistics_cpp(mtx));
return rcpp_result_gen;
END_RCPP
}
// get_summary_statistics_cpp
Rcpp::NumericMatrix get_summary_statistics_cpp(const Rcpp::NumericMatrix& mtx, const bool use_optimized_summary);
RcppExport SEXP _rdirdirgamma_get_summary_statistics_cpp(SEXP mtxSEXP, SEXP use_optimized_summarySEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< const Rcpp::NumericMatrix& >::type mtx(mtxSEXP);
Rcpp::traits::input_parameter< const bool >::type use_optimized_summary(use_optimized_summarySEXP);
rcpp_result_gen = Rcpp::wrap(get_summary_statistics_cpp(mtx, use_optimized_summary));
return rcpp_result_gen;
END_RCPP
}
// rdirichlet_cpp
Rcpp::NumericVector rdirichlet_cpp(const Rcpp::NumericVector& alpha, const unsigned long int seed);
RcppExport SEXP _rdirdirgamma_rdirichlet_cpp(SEXP alphaSEXP, SEXP seedSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const Rcpp::NumericVector& >::type alpha(alphaSEXP);
Rcpp::traits::input_parameter< const unsigned long int >::type seed(seedSEXP);
rcpp_result_gen = Rcpp::wrap(rdirichlet_cpp(alpha, seed));
return rcpp_result_gen;
END_RCPP
}
// rdirichlet_beta_cpp
Rcpp::NumericMatrix rdirichlet_beta_cpp(const unsigned int n, Rcpp::NumericVector alpha);
RcppExport SEXP _rdirdirgamma_rdirichlet_beta_cpp(SEXP nSEXP, SEXP alphaSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const unsigned int >::type n(nSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type alpha(alphaSEXP);
rcpp_result_gen = Rcpp::wrap(rdirichlet_beta_cpp(n, alpha));
return rcpp_result_gen;
END_RCPP
}
// rdirdirgamma_cpp
RcppGSL::Matrix rdirdirgamma_cpp(const unsigned int& n, const unsigned int& m, const double& alpha_0, const double& beta_0, const Rcpp::NumericVector& nu_0, const unsigned int seed);
RcppExport SEXP _rdirdirgamma_rdirdirgamma_cpp(SEXP nSEXP, SEXP mSEXP, SEXP alpha_0SEXP, SEXP beta_0SEXP, SEXP nu_0SEXP, SEXP seedSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const unsigned int& >::type n(nSEXP);
Rcpp::traits::input_parameter< const unsigned int& >::type m(mSEXP);
Rcpp::traits::input_parameter< const double& >::type alpha_0(alpha_0SEXP);
Rcpp::traits::input_parameter< const double& >::type beta_0(beta_0SEXP);
Rcpp::traits::input_parameter< const Rcpp::NumericVector& >::type nu_0(nu_0SEXP);
Rcpp::traits::input_parameter< const unsigned int >::type seed(seedSEXP);
rcpp_result_gen = Rcpp::wrap(rdirdirgamma_cpp(n, m, alpha_0, beta_0, nu_0, seed));
return rcpp_result_gen;
END_RCPP
}
// rdirdirgamma_beta_cpp
Rcpp::NumericMatrix rdirdirgamma_beta_cpp(const unsigned int& n, const unsigned int& m, const double& alpha_0, const double& beta_0, const Rcpp::NumericVector nu_0);
RcppExport SEXP _rdirdirgamma_rdirdirgamma_beta_cpp(SEXP nSEXP, SEXP mSEXP, SEXP alpha_0SEXP, SEXP beta_0SEXP, SEXP nu_0SEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const unsigned int& >::type n(nSEXP);
Rcpp::traits::input_parameter< const unsigned int& >::type m(mSEXP);
Rcpp::traits::input_parameter< const double& >::type alpha_0(alpha_0SEXP);
Rcpp::traits::input_parameter< const double& >::type beta_0(beta_0SEXP);
Rcpp::traits::input_parameter< const Rcpp::NumericVector >::type nu_0(nu_0SEXP);
rcpp_result_gen = Rcpp::wrap(rdirdirgamma_beta_cpp(n, m, alpha_0, beta_0, nu_0));
return rcpp_result_gen;
END_RCPP
}
// colsd
Rcpp::NumericVector colsd(const Rcpp::NumericMatrix& mtx);
RcppExport SEXP _rdirdirgamma_colsd(SEXP mtxSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< const Rcpp::NumericMatrix& >::type mtx(mtxSEXP);
rcpp_result_gen = Rcpp::wrap(colsd(mtx));
return rcpp_result_gen;
END_RCPP
}
// colkurtosis
arma::rowvec colkurtosis(const arma::mat& mtx);
RcppExport SEXP _rdirdirgamma_colkurtosis(SEXP mtxSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< const arma::mat& >::type mtx(mtxSEXP);
rcpp_result_gen = Rcpp::wrap(colkurtosis(mtx));
return rcpp_result_gen;
END_RCPP
}
// colskewness
arma::rowvec colskewness(const arma::mat& mtx);
RcppExport SEXP _rdirdirgamma_colskewness(SEXP mtxSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< const arma::mat& >::type mtx(mtxSEXP);
rcpp_result_gen = Rcpp::wrap(colskewness(mtx));
return rcpp_result_gen;
END_RCPP
}
// norm_minkowski
double norm_minkowski(const Rcpp::NumericVector& v, const double p);
RcppExport SEXP _rdirdirgamma_norm_minkowski(SEXP vSEXP, SEXP pSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< const Rcpp::NumericVector& >::type v(vSEXP);
Rcpp::traits::input_parameter< const double >::type p(pSEXP);
rcpp_result_gen = Rcpp::wrap(norm_minkowski(v, p));
return rcpp_result_gen;
END_RCPP
}
static const R_CallMethodDef CallEntries[] = {
{"_rdirdirgamma_sample_ABC_rdirdirgamma_beta_cpp", (DL_FUNC) &_rdirdirgamma_sample_ABC_rdirdirgamma_beta_cpp, 9},
{"_rdirdirgamma_generate_acceptable_data_cpp", (DL_FUNC) &_rdirdirgamma_generate_acceptable_data_cpp, 11},
{"_rdirdirgamma_compute_ABC_cpp", (DL_FUNC) &_rdirdirgamma_compute_ABC_cpp, 11},
{"_rdirdirgamma_compute_distances_gen_obs_cpp", (DL_FUNC) &_rdirdirgamma_compute_distances_gen_obs_cpp, 4},
{"_rdirdirgamma_get_number_summary_statistics", (DL_FUNC) &_rdirdirgamma_get_number_summary_statistics, 1},
{"_rdirdirgamma_get_optimized_summary_statistics_cpp", (DL_FUNC) &_rdirdirgamma_get_optimized_summary_statistics_cpp, 1},
{"_rdirdirgamma_get_standard_summary_statistics_cpp", (DL_FUNC) &_rdirdirgamma_get_standard_summary_statistics_cpp, 1},
{"_rdirdirgamma_get_summary_statistics_cpp", (DL_FUNC) &_rdirdirgamma_get_summary_statistics_cpp, 2},
{"_rdirdirgamma_rdirichlet_cpp", (DL_FUNC) &_rdirdirgamma_rdirichlet_cpp, 2},
{"_rdirdirgamma_rdirichlet_beta_cpp", (DL_FUNC) &_rdirdirgamma_rdirichlet_beta_cpp, 2},
{"_rdirdirgamma_rdirdirgamma_cpp", (DL_FUNC) &_rdirdirgamma_rdirdirgamma_cpp, 6},
{"_rdirdirgamma_rdirdirgamma_beta_cpp", (DL_FUNC) &_rdirdirgamma_rdirdirgamma_beta_cpp, 5},
{"_rdirdirgamma_colsd", (DL_FUNC) &_rdirdirgamma_colsd, 1},
{"_rdirdirgamma_colkurtosis", (DL_FUNC) &_rdirdirgamma_colkurtosis, 1},
{"_rdirdirgamma_colskewness", (DL_FUNC) &_rdirdirgamma_colskewness, 1},
{"_rdirdirgamma_norm_minkowski", (DL_FUNC) &_rdirdirgamma_norm_minkowski, 2},
{NULL, NULL, 0}
};
RcppExport void R_init_rdirdirgamma(DllInfo *dll) {
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}
| 60.304878
| 366
| 0.786855
|
lgaborini
|
9f3455771192f590690b610b29c1f3c2da2f3f74
| 1,809
|
cpp
|
C++
|
3DEngine/src/3D Engine/RenderingManager.cpp
|
tobbep1997/Bitfrost_2.0
|
a092db19d4658062554b7df759f28439fc1ad4f8
|
[
"Apache-2.0"
] | null | null | null |
3DEngine/src/3D Engine/RenderingManager.cpp
|
tobbep1997/Bitfrost_2.0
|
a092db19d4658062554b7df759f28439fc1ad4f8
|
[
"Apache-2.0"
] | null | null | null |
3DEngine/src/3D Engine/RenderingManager.cpp
|
tobbep1997/Bitfrost_2.0
|
a092db19d4658062554b7df759f28439fc1ad4f8
|
[
"Apache-2.0"
] | null | null | null |
#include "3DEngine/EnginePCH.h"
#include "RenderingManager.h"
RenderingManager::RenderingManager()
{
m_wnd = new Window();
m_engine = new Engine3D();
}
RenderingManager::~RenderingManager()
{
delete m_wnd;
delete m_engine;
}
RenderingManager * RenderingManager::GetInstance()
{
static RenderingManager m_instance;
return &m_instance;
}
void RenderingManager::Init(HINSTANCE hInstance)
{
#if _DEBUG
DEBUG = true;
#else
DEBUG = true;
#endif
m_hInstance = hInstance;
WindowContext wind;
wind.clientWidth = 1280;
wind.clientHeight = 720;
wind.fullscreen = false;
wind.windowInstance = hInstance;
wind.windowTitle = L"BitFrost 2.0";
//Will override the Settings above
SettingLoader::LoadWindowSettings(wind);
m_wnd->Init(wind);
m_engine->Init(m_wnd->GetHandler(), wind.fullscreen, wind.clientWidth, wind.clientHeight);
}
void RenderingManager::Update()
{
//while (m_wnd->isOpen())
{
InputHandler::WindowSetShowCursor();
m_wnd->PollEvents();
#if _DEBUG
if (GetAsyncKeyState(int('P')))
{
_reloadShaders();
}
#endif
}
}
void RenderingManager::UpdateSingleThread()
{
InputHandler::WindowSetShowCursor();
m_wnd->PollEvents();
#if _DEBUG
if (GetAsyncKeyState(int('P')))
{
_reloadShaders();
}
#endif
}
void RenderingManager::Clear()
{
this->m_engine->Clear();
}
void RenderingManager::Flush(Camera & camera)
{
//Draws Everything in the queue
m_engine->Flush(camera);
DX::g_deviceContext->ClearState();
}
void RenderingManager::Present()
{
m_engine->Present();
}
void RenderingManager::Release()
{
m_engine->Release();
}
Window& RenderingManager::GetWindow()
{
return *m_wnd;
}
ProcMsg RenderingManager::GetWindowProcMsg()
{
return m_wnd->GetWindowProcMsg();
}
void RenderingManager::_reloadShaders()
{
DX::g_shaderManager.ReloadAllShaders();
}
| 15.868421
| 91
| 0.725815
|
tobbep1997
|
9f3757a0fea66d0fe42392c4c74d3919750f0876
| 3,545
|
cpp
|
C++
|
src/Output/WebCamVJ.cpp
|
aurelijusb/webcam-games
|
cced15d3decdba637c41d1620a97e0a4f8ec3cb0
|
[
"MIT"
] | 3
|
2017-02-05T21:14:42.000Z
|
2017-04-11T22:46:09.000Z
|
src/Output/WebCamVJ.cpp
|
aurelijusb/webcam-games
|
cced15d3decdba637c41d1620a97e0a4f8ec3cb0
|
[
"MIT"
] | null | null | null |
src/Output/WebCamVJ.cpp
|
aurelijusb/webcam-games
|
cced15d3decdba637c41d1620a97e0a4f8ec3cb0
|
[
"MIT"
] | null | null | null |
#include <opencv/highgui.h>
#include "WebCamVJ.h"
#include "../Tracker/TrackerMotion.h"
#define INTESITY(x, y) { setIntensivity(x, y, getIntensity(x, y)); }
#define MAX_INTESITY(x, y) { setMaxIntensivity(x, y, getIntensity(x, y)); }
WebCamVJ::WebCamVJ(int webCamDevice): TrackerMotion(webCamDevice) {
for (int i=0; i < MAP_MAX * MAP_MAX; i++) {
effects.push_back(NULL);
}
frame = 0;
bigImage = cvCreateImage(cvSize(1280, 960), 8, 3);
}
/*
* Configurations.
*/
void WebCamVJ::run() {
setFlip();
add(0, 3, image, "../Data/img_1449.jpg");
add(7, 3, image, "../Data/img_1196.jpg");
add(4, 0, rectangules, "");
cvNamedWindow("Motion tracker", CV_WINDOW_NORMAL);
cvSetWindowProperty("Motion tracker", CV_WND_PROP_FULLSCREEN,
CV_WINDOW_FULLSCREEN);
loop("Motion tracker");
}
bool WebCamVJ::onKeyPress(char c) {
switch (c) {
case 27:
case 'q':
return false;
}
setMaxIntensivity(0, 3, 255);
setMaxIntensivity(7, 3, 255);
setMaxIntensivity(4, 0, 255);
INTESITY(0, 3);
INTESITY(7, 3);
INTESITY(4, 0);
show(getFrame());
return true;
}
/*
* Rendering
*/
void WebCamVJ::show(IplImage *background) {
/* About boxes */
int edgeWidth = background->width / MAP_MAX;
int edgeHeight = background->height / MAP_MAX;
for (int x = 0; x < MAP_MAX; x++) {
for (int y = 0; y < MAP_MAX; y++) {
int i = MAP_X(x) + MAP_Y(y);
if (effects[i]) {
effects[i]->markControllAreas(background,
x * edgeWidth, y * edgeHeight,
edgeWidth, edgeHeight);
}
}
}
/* Efects */
if (!frame) {
frame = cvCloneImage(background);
}
cvCopy(background, frame);
for (unsigned i = 0; i < effects.size(); i++) {
if (effects[i]) {
effects[i]->apply(frame);
}
}
showFullScreen();
}
void WebCamVJ::showFullScreen() {
cvZero(bigImage);
cvResize(frame, bigImage, CV_INTER_LINEAR);
fullScreen("Images", bigImage);
}
/*
* State
*/
void WebCamVJ::add(int mapX, int mapY, effectType type, const std::string file) {
int key = getKey(mapX, mapY);
if (!effects[key]) {
effects[key] = new WebCamEffect(type, file);
} else {
cerr << "Key allready exists: " << mapX << " " << mapY << endl;
}
}
void WebCamVJ::setIntensivity(int mapX, int mapY, unsigned value) {
int key = getKey(mapX, mapY);
if (effects[key]) {
effects[key]->setIntensivity(value);
} else {
cerr << "Bad coordinates: " << mapX << " " << mapY << endl;
}
}
void WebCamVJ::setMaxIntensivity(int mapX, int mapY, unsigned value) {
int key = getKey(mapX, mapY);
if (effects[key]) {
effects[key]->setMaxIntensivity(value);
} else {
cerr << "Bad maxIntensity coordinates: " << mapX << " " << mapY << endl;
}
}
int WebCamVJ::getKey(int mapX, int mapY) {
RANGE(mapX, 0, MAP_MAX - 1);
RANGE(mapY, 0, MAP_MAX - 1);
return MAP_X(mapX) + MAP_Y(mapY);
}
/*
* Destruction
*/
WebCamVJ::~WebCamVJ() {
WebCamEffect* effect;
for (unsigned i = 0; i < effects.size(); i++) {
effect = effects[i];
if (effect) {
delete effect;
}
}
effects.clear();
if (frame) {
cvReleaseImage(&frame);
}
if (bigImage) {
cvReleaseImage(&bigImage);
}
}
| 23.476821
| 81
| 0.550071
|
aurelijusb
|
9f38777fb1f90919a0c58b2e79b574362fdcc321
| 2,460
|
cpp
|
C++
|
source/demo/src/keyboard_demo.cpp
|
DavideCorradiDev/houzi-game-engine
|
d704aa9c5b024300578aafe410b7299c4af4fcec
|
[
"MIT"
] | 2
|
2018-04-12T20:59:20.000Z
|
2018-07-26T16:04:07.000Z
|
source/demo/src/keyboard_demo.cpp
|
DavideCorradiDev/houzi-game-engine
|
d704aa9c5b024300578aafe410b7299c4af4fcec
|
[
"MIT"
] | null | null | null |
source/demo/src/keyboard_demo.cpp
|
DavideCorradiDev/houzi-game-engine
|
d704aa9c5b024300578aafe410b7299c4af4fcec
|
[
"MIT"
] | null | null | null |
// Houzi Game Engine
// Copyright (c) 2018 Davide Corradi
// Licensed under the MIT license.
#include "hou/cor/cor_module.hpp"
#include "hou/mth/mth_module.hpp"
#include "hou/sys/sys_module.hpp"
#include "hou/cor/clock.hpp"
#include "hou/sys/event.hpp"
#include "hou/sys/keyboard.hpp"
#include "hou/sys/window.hpp"
#include <iostream>
#include <thread>
int main(int, char**)
{
hou::cor_module::initialize();
hou::mth_module::initialize();
hou::sys_module::initialize();
bool loop = true;
auto on_quit = [&loop](hou::event::timestamp) { loop = false; };
hou::event::set_quit_callback(on_quit);
hou::window w("KeyboardDemo", hou::vec2u(640u, 480u));
w.set_bordered(true);
w.set_visible(true);
w.raise();
w.focus();
std::cout << "The keyboard state will be printed every second." << std::endl;
std::chrono::nanoseconds elapsed_time(0);
std::chrono::nanoseconds tick_period(std::chrono::seconds(1));
hou::clock c;
while(loop)
{
hou::event::process_all();
elapsed_time += c.reset();
while(elapsed_time > tick_period)
{
elapsed_time -= tick_period;
hou::span<const uint8_t> keys_state = hou::keyboard::get_keys_state();
std::vector<int> pressed_keys;
pressed_keys.reserve(keys_state.size());
for(size_t i = 0; i < keys_state.size(); ++i)
{
if(keys_state[i])
{
pressed_keys.push_back(i);
HOU_ASSERT(hou::keyboard::is_key_pressed(hou::scan_code(i)));
// HOU_ASSERT(hou::keyboard::is_key_pressed(
// hou::get_key_code(hou::scan_code(i))));
}
else
{
HOU_ASSERT(!hou::keyboard::is_key_pressed(hou::scan_code(i)));
// HOU_ASSERT(!hou::keyboard::is_key_pressed(
// hou::get_key_code(hou::scan_code(i))));
}
}
std::cout << "Window has focus: "
<< hou::to_string(w.has_keyboard_focus()) << std::endl;
std::cout << "Pressed scan codes:";
for(auto i : pressed_keys)
{
std::cout << " " << hou::scan_code(i);
}
std::cout << std::endl;
std::cout << "Pressed key codes:";
for(auto i : pressed_keys)
{
std::cout << " " << get_key_code(hou::scan_code(i));
}
std::cout << std::endl;
std::cout << "Modifier keys: " << hou::keyboard::get_modifier_keys()
<< std::endl;
std::cout << std::endl;
}
}
return EXIT_SUCCESS;
}
| 25.625
| 79
| 0.594715
|
DavideCorradiDev
|
9f3aa8ed334745463f4a49aa3263097e79fd43ed
| 1,219
|
cpp
|
C++
|
test/class/class.cpp
|
ExpLife0011/ezpp
|
2c484155be17e4dda98bf082325ac1d6d79ea3bb
|
[
"MIT"
] | 26
|
2018-05-02T13:54:23.000Z
|
2022-02-09T05:49:59.000Z
|
test/class/class.cpp
|
ez8-co/ezpp
|
2c484155be17e4dda98bf082325ac1d6d79ea3bb
|
[
"MIT"
] | null | null | null |
test/class/class.cpp
|
ez8-co/ezpp
|
2c484155be17e4dda98bf082325ac1d6d79ea3bb
|
[
"MIT"
] | 6
|
2018-05-19T00:43:15.000Z
|
2020-08-19T08:28:41.000Z
|
#include "../../ezpp.hpp"
#include <iostream>
#ifdef _MSC_VER
#include <windows.h>
#else
#define Sleep(ms) usleep(ms * 1000)
#endif
using namespace std;
class test
{
public:
EZPP_CLS_REGISTER();
test(void) {EZPP_CLS_INIT();}
};
void test_(void)
{
{
test all;
test all1;
test all2;
Sleep(2000);
}
test all3;
}
class test_do
{
public:
EZPP_CLS_REGISTER_DO();
test_do(void) {EZPP_CLS_INIT_DO();}
};
void test_do_(void)
{
{
test_do do0;
test_do do2;
test_do do3;
Sleep(2000);
}
test_do do3;
}
class test_ex
{
public:
EZPP_CLS_REGISTER_EX();
test_ex(void) {EZPP_CLS_INIT_EX("EZPP_CLS_INIT_EX");}
};
void test_ex_(void)
{
{
test_ex ex;
test_ex ex1;
test_ex ex2;
Sleep(2000);
}
test_ex ex3;
}
class test_ex_do
{
public:
EZPP_CLS_REGISTER_EX_DO();
test_ex_do(void) {EZPP_CLS_INIT_EX_DO("EZPP_CLS_INIT_EX_DO");}
};
void test_ex_do_(void)
{
{
test_ex_do ex_do;
test_ex_do ex_do1;
test_ex_do ex_do2;
Sleep(2000);
}
test_ex_do ex_do3;
}
int main(int argc, char** argv)
{
try {
EZPP_ADD_OPTION(EZPP_OPT_FORCE_ENABLE);
test_();
test_do_();
test_ex_();
test_ex_do_();
}
catch(std::exception& e) {
std::cout << e.what() << std::endl;
}
return 0;
}
| 12.313131
| 63
| 0.66694
|
ExpLife0011
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.