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 108 | 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 67k ⌀ | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
e960710f7378f48754c078c90573c372f2620647 | 924 | hh | C++ | src/Nuxed/Http/Server/__Private/NextMiddlewareProcessor.hh | tomoki1337/framework | ff06d260c5bf2a78a99b8d17b041de756550f95a | [
"MIT"
] | 1 | 2019-01-25T20:05:55.000Z | 2019-01-25T20:05:55.000Z | src/Nuxed/Http/Server/__Private/NextMiddlewareProcessor.hh | gitter-badger/framework-27 | 368b734f2753b06b7f19f819185091f896838467 | [
"MIT"
] | null | null | null | src/Nuxed/Http/Server/__Private/NextMiddlewareProcessor.hh | gitter-badger/framework-27 | 368b734f2753b06b7f19f819185091f896838467 | [
"MIT"
] | null | null | null | <?hh // strict
namespace Nuxed\Http\Server\__Private;
use type Nuxed\Contract\Http\Message\ResponseInterface;
use type Nuxed\Contract\Http\Message\ServerRequestInterface;
use type Nuxed\Contract\Http\Server\RequestHandlerInterface;
use type Nuxed\Contract\Http\Server\MiddlewareInterface;
use type SplPriorityQueue;
class NextMiddlewareProcessor implements RequestHandlerInterface {
private SplPriorityQueue<MiddlewareInterface> $queue;
public function __construct(
SplPriorityQueue<MiddlewareInterface> $queue,
private RequestHandlerInterface $handler,
) {
$this->queue = clone $queue;
}
public async function handle(
ServerRequestInterface $request,
): Awaitable<ResponseInterface> {
if (0 === $this->queue->count()) {
return await $this->handler->handle($request);
}
$middleware = $this->queue->extract();
return await $middleware->process($request, $this);
}
}
| 28 | 66 | 0.75 | tomoki1337 |
e9641a6eaf305100f2dd9618b38a25e3872bfd3d | 13,989 | cpp | C++ | src/Rendu.cpp | Moret84/JdidBack | 344296fc99f3cb5164850d9fa4582676357883aa | [
"MIT"
] | null | null | null | src/Rendu.cpp | Moret84/JdidBack | 344296fc99f3cb5164850d9fa4582676357883aa | [
"MIT"
] | null | null | null | src/Rendu.cpp | Moret84/JdidBack | 344296fc99f3cb5164850d9fa4582676357883aa | [
"MIT"
] | null | null | null | #include "Rendu.hpp"
using namespace irr;
using namespace core;
using namespace video;
using namespace scene;
using namespace std;
using namespace gui;
Rendu::Rendu() : m_partie()
{
//Device avec API = OPENGL, Fenêtre de taille 640 x 480p et 32bits par pixel
m_device = createDevice(EDT_OPENGL, dimension2d<u32>(800,600), 32, false, false, false, this);
m_device->setWindowCaption(L"Jdidback");
m_driver = m_device->getVideoDriver();
m_sceneManager = m_device->getSceneManager();
//Lumière ambiante
m_sceneManager->setAmbientLight(SColorf(1.0,1.0,1.0,0.0));
//Caméra fixe
m_sceneManager->addCameraSceneNode(0, vector3df(1.6f, 4, 4.5f), vector3df(1.6f, 1, 1.0f));
//Debug FPS
//m_sceneManager->addCameraSceneNodeFPS(0,100.0f,0.005f,-1);
//Chargement du mesh
m_wumpa = m_sceneManager->getMesh("media/mesh/apple.obj");
//Noeud père des cases du plateau
m_pereCases = m_sceneManager->addEmptySceneNode(0, CASE);
//Noeud père des cases du plateau
m_pereSpheres = m_sceneManager->addEmptySceneNode(0, SPHERE);
//Sphère cliquée
m_clickedSphere = nullptr;
//Monde à prendre en compte pour les collisions
m_metaSelector = m_sceneManager->createMetaTriangleSelector();
m_casePlateau.resize(m_partie.getTaille());
m_sphere.resize(m_partie.getTaille());
for(int i = 0; i < m_partie.getTaille(); ++i)
{
m_casePlateau[i].resize(m_partie.getTaille());
m_sphere[i].resize(m_partie.getTaille());
}
m_sceneManager->addSkyDomeSceneNode(m_driver->getTexture("media/textures/nsanitybeach.jpg"), 16, 8, 1.0, 2.0, 1000.0, 0, -1);
IGUIFont* policeTirsRestants = m_device->getGUIEnvironment()->getFont("media/fonts/superwumpa.xml");
IGUIFont* policeNiveau = m_device->getGUIEnvironment()->getFont("media/fonts/superWumpaNiveau.xml");
IGUIFont* fontMini = m_device->getGUIEnvironment()->getFont("media/fonts/superWumpaToutpetit.xml");
SColor orangeBandicoot = SColor(255, 234, 102, 0);
m_device->getGUIEnvironment()->getSkin()->setFont(fontMini);
m_device->getGUIEnvironment()->getSkin()->setColor(EGDC_BUTTON_TEXT, orangeBandicoot);
m_device->getGUIEnvironment()->getSkin()->setColor(EGDC_ACTIVE_CAPTION, orangeBandicoot);
m_device->getGUIEnvironment()->getSkin()->setColor(EGDC_INACTIVE_CAPTION, orangeBandicoot);
m_tirsRestants = m_device->getGUIEnvironment()->addStaticText(stringw(m_partie.getTirsRestants()).c_str(), rect<s32>(5, 10, 105, 80));
m_tirsRestants->setOverrideFont(policeTirsRestants);
IGUIStaticText* labelNiveau = m_device->getGUIEnvironment()->addStaticText(stringw(L"Niveau").c_str(), rect<s32>(650, 30, 750, 80));
labelNiveau->setOverrideFont(policeNiveau);
m_niveau = m_device->getGUIEnvironment()->addStaticText(stringw(m_partie.getNiveauPartie()).c_str(), rect <s32>(760, 30, 800, 80));
m_niveau->setOverrideFont(policeNiveau);
dessinerPlateau();
m_etapeChargement = 0;
chargerSpheres();
m_etatJeu = EN_JEU;
}
void Rendu::dessinerPlateau()
{
f32 x, y, z;
x = y = z = 0.0f;
for(int i = 0; i < m_partie.getTaille(); ++i, x = 0.0f, z += 1.0f)
{
for(int j = m_partie.getTaille() - 1; j >= 0; --j, x+= 1.0f)
{
m_casePlateau[i][j] = m_sceneManager->addCubeSceneNode(
1.0f, //Taille du cube
m_pereCases, //Tous les cubes sont fils du noeud pereCases
i * m_partie.getTaille() + j, //Calcul du numéro ID
vector3df(x, y, z), //Position du cube, change à chaque tour de boucle
vector3df(0), //Rotation, ici aucune
vector3df(1.0f, 0.15f , 1.0f)); //Échelle, 0.15f en y pour une caisse fine en hauteur
m_casePlateau[i][j]->setMaterialTexture(0, m_driver->getTexture("media/textures/caisse.png"));
}
}
}
void Rendu::dessinerSphere(int x, int y)
{
u32 niveauCase = m_partie.getNiveauCase(x, y);
if(niveauCase != 0)
{
vector3df echelle;
switch(niveauCase)
{
case 1:
echelle = vector3df(1.0/3);
break;
case 2:
echelle = vector3df(2.0/3);
break;
case 3:
echelle = vector3df(1);
break;
}
vector3df positionCase(m_casePlateau[x][y]->getPosition());
vector3df positionSphere(positionCase.X , positionCase.Y + 0.11f, positionCase.Z); //Place la sphère au dessus de cette case
m_sphere[x][y].node = m_sceneManager->addAnimatedMeshSceneNode(
m_wumpa, //Mesh chargé plus haut
m_pereSpheres, //Toutes les sphères sont filles de pereSpheres
x * m_partie.getTaille() + y, //Calcul du numéro ID
positionSphere, //Position calculée
vector3df(0), //Rotation, ici aucune
echelle); //Echelle calculée
m_sphere[x][y].node->setMaterialFlag(EMF_LIGHTING, false);
ITriangleSelector* selector = m_sceneManager->createTriangleSelectorFromBoundingBox(m_sphere[x][y].node);
m_sphere[x][y].node->setTriangleSelector(selector);
selector->drop();
m_metaSelector->addTriangleSelector(m_sphere[x][y].node->getTriangleSelector());
//Rotation
ISceneNodeAnimator* animator;
animator = m_sceneManager->createRotationAnimator(vector3df(0, 3, 0));
m_sphere[x][y].node->addAnimator(animator);
animator->drop();
}
else
m_sphere[x][y].node = nullptr;
}
void Rendu::chargerSpheres()
{
if(m_etapeChargement > 1)
m_etapeChargement = -1;
if(m_etapeChargement == -1)
return;
vector3df positionDepart, positionArrivee;
for(int i = 0; i < m_partie.getTaille(); ++i)
{
for(int j = 0; j < m_partie.getTaille(); ++j)
{
if(m_etapeChargement == 0)
dessinerSphere(i, j);
if(m_sphere[i][j].node)
{
//Chute
if(m_etapeChargement == 0)
{
positionDepart = m_casePlateau[i][j]->getPosition();
positionDepart.Y += 10.0;
positionArrivee = m_casePlateau[i][j]->getPosition();
positionArrivee.Y += 0.11;
m_sphere[i][j].animator = m_sceneManager->createFlyStraightAnimator(positionDepart, positionArrivee, 500, false, false);
m_spheresEnChargement.push_back(m_sphere[i][j].animator);
m_sphere[i][j].node->addAnimator(m_sphere[i][j].animator);
}
//Lévitation
else if(m_etapeChargement == 1)
{
positionDepart = m_sphere[i][j].node->getPosition();
positionArrivee = positionDepart;
positionArrivee.Y += 0.15f;
m_sphere[i][j].node->removeAnimator(m_sphere[i][j].animator);
m_sphere[i][j].animator = m_sceneManager
->createFlyStraightAnimator(positionDepart, positionArrivee, 500, true, true);
}
m_sphere[i][j].node->addAnimator(m_sphere[i][j].animator);
}
}
}
++m_etapeChargement;
}
Rendu::~Rendu()
{
}
void Rendu::clear()
{
m_metaSelector->removeAllTriangleSelectors();
for(int i = 0; i < m_partie.getTaille(); ++i)
{
for(int j = 0; j < m_partie.getTaille(); ++j)
{
if(m_sphere[i][j].node)
{
m_sceneManager->addToDeletionQueue(m_sphere[i][j].node);
m_sphere[i][j].node = nullptr;
}
}
}
}
void Rendu::afficher()
{
for(int i = 0; i < m_partie.getTaille(); ++i)
{
for(int j = 0; j < m_partie.getTaille(); ++j)
{
if(!m_sphere[i][j].node)
cout<<"0 ";
else
cout<< m_sphere[i][j].node->getScale().X << " ";
}
cout<<endl;
}
for(int i = 0; i < m_partie.getTaille(); ++i)
{
for(int j = 0; j < m_partie.getTaille(); ++j)
cout<<"("<<m_casePlateau[i][j]->getPosition().X<<", "<<m_casePlateau[i][j]->getPosition().Z<<") ";
cout<<endl;
}
}
bool Rendu::onCollision(const ISceneNodeAnimatorCollisionResponse &animator)
{
int index = animator.getCollisionNode()->getID();
int x = index / m_partie.getTaille();
int y = index % m_partie.getTaille();
m_sceneManager->addToDeletionQueue(animator.getTargetNode());
augmenterNiveauSphere(x, y);
return true;
}
void Rendu::testAnimator()
{
if(m_spheresEnVol.empty() && m_spheresEnChargement.empty())
return;
if(m_spheresEnChargement.empty())
{
auto it = m_spheresEnVol.begin();
while(it != m_spheresEnVol.end())
{
if(it->animatorCollision->collisionOccurred() || it->animatorDelete->hasFinished())
m_spheresEnVol.erase(it++);
else
++it;
}
}
else
{
auto it = m_spheresEnChargement.begin();
while(it != m_spheresEnChargement.end())
{
if((*it)->hasFinished())
m_spheresEnChargement.erase(it++);
else
++it;
}
}
}
bool Rendu::OnEvent(const SEvent &event)
{
if(event.EventType == EET_MOUSE_INPUT_EVENT)
{
if(event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN && m_etatJeu != PERDU)
{
position2d <s32> curseur = m_device
->getCursorControl()
->getPosition(); //Position du curseur au clic
m_clickedSphere = m_sceneManager
->getSceneCollisionManager()
->getSceneNodeFromScreenCoordinatesBB(curseur, 0, false, m_pereSpheres); //Sphère en collision avec le clic
if(!m_clickedSphere)
{
m_clickedSphere = m_sceneManager
->getSceneCollisionManager()
->getSceneNodeFromScreenCoordinatesBB(curseur, 0, false, m_pereCases); //Case en collision avec le clic
}
return true;
}
}
else if(event.EventType == EET_GUI_EVENT)
{
if(event.GUIEvent.EventType == EGET_MESSAGEBOX_YES)
{
recommencer();
return true;
}
else if(event.GUIEvent.EventType == EGET_MESSAGEBOX_NO)
{
m_device->closeDevice();
return true;
}
}
return false;
}
void Rendu::majSphere()
{
if(!m_spheresEnVol.empty())
{
m_clickedSphere = nullptr;
return;
}
if(!m_clickedSphere || m_partie.getTirsRestants() <= 0)
return;
m_partie.diminuerTirsRestants();
m_tirsRestants->setText(stringw(m_partie.getTirsRestants()).c_str());
s32 i = m_clickedSphere->getID() / m_partie.getTaille();
s32 j = m_clickedSphere->getID() % m_partie.getTaille();
augmenterNiveauSphere(i, j);
m_clickedSphere = nullptr;
}
void Rendu::augmenterNiveauSphere(int x, int y)
{
if(!m_sphere[x][y].node)
{
m_partie.choixCase(x, y);
dessinerSphere(x, y);
}
else if(m_sphere[x][y].node->getScale() == vector3df(1.0/3))
{
m_sphere[x][y].node->setScale(m_sphere[x][y].node->getScale() * 2);
m_partie.choixCase(x, y);
}
else if(m_sphere[x][y].node->getScale() == vector3df(2.0/3))
{
m_sphere[x][y].node->setScale(m_sphere[x][y].node->getScale() * 3.0/2);
m_partie.choixCase(x, y);
}
else if(m_sphere[x][y].node->getScale() == vector3df(1))
exploserSphere(x, y);
}
void Rendu::exploserSphere(int x, int y)
{
if(!m_sphere[x][y].node)
return;
vector3df destinationMiniSphere, positionMiniSphere;
f32 tempsAnimation, vitesseAnimation(0.003f);
for(s32 k = NORD; k <= OUEST; ++k)
{
positionMiniSphere = m_sphere[x][y].node->getPosition();
destinationMiniSphere = calculDestinationMiniSphere(x, y, (directionSphere) k);
if(k == NORD || k == SUD)
tempsAnimation = abs_(destinationMiniSphere.Z - positionMiniSphere.Z) / vitesseAnimation;
else
tempsAnimation = abs_(destinationMiniSphere.X - positionMiniSphere.X) / vitesseAnimation;
m_miniSphere[k].node = m_sceneManager->addAnimatedMeshSceneNode(
m_wumpa,
0,
-1,
positionMiniSphere,
vector3df(0),
vector3df(1.0/3));
m_miniSphere[k].node->setMaterialFlag(EMF_LIGHTING, false);
m_miniSphere[k].animatorVol = m_sceneManager->createFlyStraightAnimator(positionMiniSphere, destinationMiniSphere, tempsAnimation);
//On retire la sphère venant d'exploser du sélecteur de triangle
m_metaSelector->removeTriangleSelector(m_sphere[x][y].node->getTriangleSelector());
m_miniSphere[k].animatorCollision = m_sceneManager
->createCollisionResponseAnimator(
m_metaSelector,
m_miniSphere[k].node,
vector3df(1.0/3),
vector3df(0));
m_miniSphere[k].animatorCollision->setCollisionCallback(this);
m_miniSphere[k].animatorDelete = m_sceneManager->createDeleteAnimator(tempsAnimation);
m_spheresEnVol.push_back(m_miniSphere[k]);
}
if(m_sphere[x][y].node)
{
m_sceneManager->addToDeletionQueue(m_sphere[x][y].node);
m_sphere[x][y].node = nullptr;
}
m_partie.choixCase(x, y);
for(auto it = m_miniSphere.begin(); it != m_miniSphere.end(); ++it)
{
it->node->addAnimator(it->animatorVol);
it->animatorVol->drop();
if(it->animatorCollision)
it->node->addAnimator(it->animatorCollision);
if(it->animatorDelete)
it->node->addAnimator(it->animatorDelete);
}
}
vector3df Rendu::calculDestinationMiniSphere(s32 x, s32 y, directionSphere direction)
{
vector3df arrivee(m_sphere[x][y].node->getPosition());
switch(direction)
{
case NORD:
arrivee.Z = - m_casePlateau[0][0]->getScale().Z;
break;
case SUD:
arrivee.Z = m_partie.getTaille() * m_casePlateau[0][0]->getScale().Z;
break;
case EST:
arrivee.X = - m_casePlateau[0][0]->getScale().X;
break;
case OUEST:
arrivee.X = m_partie.getTaille() * m_casePlateau[0][0]->getScale().X;
break;
}
return arrivee;
}
void Rendu::rendre()
{
m_driver->beginScene(true, true, SColor(255, 255, 255, 255));
m_sceneManager->drawAll();
//cout<<R.getDriver()->getFPS()<<endl;
m_device->getGUIEnvironment()->drawAll();
testAnimator();
if(m_spheresEnChargement.empty() && m_etapeChargement > 0)
chargerSpheres();
m_driver->endScene();
}
void Rendu::lancer()
{
while(m_device->run())
{
if(m_etatJeu != PERDU)
majSphere();
rendre();
rafraichir();
}
m_device->drop();
}
void Rendu::rafraichir()
{
if(m_spheresEnVol.empty() && m_etatJeu != PERDU)
{
if(m_partie.resolu())
{
clear();
m_partie.levelUp();
m_niveau->setText(stringw(m_partie.getNiveauPartie()).c_str());
m_etapeChargement = 0;
chargerSpheres();
}
majCombos();
if(m_partie.getTirsRestants() <= 0)
{
clear();
m_etatJeu = PERDU;
m_device->getGUIEnvironment()->addMessageBox(L"Game Over", L"Vous avez perdu. \nRecommencer ?", true, EMBF_YES|EMBF_NO);
}
}
}
void Rendu::majCombos()
{
if(m_partie.getNbCombos() > 2)
{
m_partie.augmenterTirsRestants();
m_tirsRestants->setText(stringw(m_partie.getTirsRestants()).c_str());
m_device->getGUIEnvironment()->drawAll();
}
m_partie.resetCombos();
}
void Rendu::recommencer()
{
m_partie.recommencer();
m_etatJeu = EN_JEU;
m_etapeChargement = 0;
chargerSpheres();
}
| 25.715074 | 135 | 0.68704 | Moret84 |
e967df369a1370287ea146a5884a86af97483f3e | 8,214 | cpp | C++ | inetcore/outlookexpress/inetcomm/ess/debug.cpp | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | inetcore/outlookexpress/inetcomm/ess/debug.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | inetcore/outlookexpress/inetcomm/ess/debug.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | //+---------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1996 - 1996.
//
// File: debug.cpp
//
// Contents: Debug sub system APIs implementation
//
//
// 03/20/96 kevinr wrote it
// 04/17/96 kevinr added OSS init
// 05-Sep-1997 pberkman added sub-system debug.
//
//----------------------------------------------------------------------------
#ifdef SMIME_V3
#if DBG
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <memory.h>
#include <string.h>
#include <process.h>
#include <time.h>
#include <crtdbg.h>
#include <asn1code.h>
#include "badstrfunctions.h"
//#include "regtest.h" // JLS
#include "dbgdef.h"
// set DEBUG_MASK=0x26
LPSTR pszDEBUG_MASK = "DEBUG_MASK";
#define DEBUG_MASK_DELAY_FREE_MEM _CRTDBG_DELAY_FREE_MEM_DF /* 0x02 */
#define DEBUG_MASK_CHECK_ALWAYS _CRTDBG_CHECK_ALWAYS_DF /* 0x04 */
#define DEBUG_MASK_LEAK_CHECK _CRTDBG_LEAK_CHECK_DF /* 0x20 */
#define DEBUG_MASK_MEM \
(DEBUG_MASK_DELAY_FREE_MEM | DEBUG_MASK_CHECK_ALWAYS | DEBUG_MASK_LEAK_CHECK)
// from asn1code.h:
// #define DEBUGPDU 0x02 /* produce tracing output */
// #define DEBUG_ERRORS 0x10 /* print decoder errors to output */
// set OSS_DEBUG_MASK=0x02
// set OSS_DEBUG_MASK=0x10 - only print decoder errors
LPSTR pszOSS_DEBUG_MASK = "OSS_DEBUG_MASK";
// receives trace output
LPSTR pszOSS_DEBUG_TRACEFILE = "OSS_DEBUG_TRACEFILE";
static char *pszDEBUG_PRINT_MASK = "DEBUG_PRINT_MASK";
static char *pszDefualtSSTag = "ISPU";
static DBG_SS_TAG sSSTags[] = __DBG_SS_TAGS;
#if 0 // JLS
//
//+-------------------------------------------------------------------------
//
// Pithy stubs to create stdcall proc from cdecl
//
//--------------------------------------------------------------------------
void*
_stdcall
scMalloc( size_t size)
{
return malloc(size);
}
void*
_stdcall
scRealloc( void *memblock, size_t size)
{
return realloc(memblock, size);
}
void
_stdcall
scFree( void *memblock)
{
free(memblock);
}
//+-------------------------------------------------------------------------
//
// Function: DbgGetDebugFlags
//
// Synopsis: Get the debug flags.
//
// Returns: the debug flags
//
//--------------------------------------------------------------------------
int
WINAPI
DbgGetDebugFlags()
{
char *pszEnvVar;
char *p;
int iDebugFlags = 0;
if (pszEnvVar = getenv( pszDEBUG_MASK))
iDebugFlags = strtol( pszEnvVar, &p, 16);
return iDebugFlags;
}
//+-------------------------------------------------------------------------
//
// Function: DbgProcessAttach
//
// Synopsis: Handle process attach.
//
// Returns: TRUE
//
//--------------------------------------------------------------------------
BOOL
WINAPI
DbgProcessAttach()
{
int tmpFlag;
#ifdef _DEBUG
tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); // get current
tmpFlag |= DbgGetDebugFlags(); // enable flags
tmpFlag &= ~_CRTDBG_CHECK_CRT_DF; // disable CRT block checking
_CrtSetDbgFlag( tmpFlag); // set new value
#endif
return TRUE;
}
//+-------------------------------------------------------------------------
//
// Function: DbgProcessDetach
//
// Synopsis: Handle process detach.
//
// Returns: TRUE
//
//--------------------------------------------------------------------------
BOOL
WINAPI
DbgProcessDetach()
{
return TRUE;
}
//+-------------------------------------------------------------------------
//
// Function: DbgInitOSS
//
// Synopsis: Do OSS init for debug.
//
// Returns: TRUE
//
// Note: Always FRONT_ALIGN encoding
//
//--------------------------------------------------------------------------
BOOL
WINAPI
DbgInitOSS(
OssGlobal *pog)
{
char *pszEnvVar;
char *p;
// from asn1code.h:
// #define DEBUGPDU 0x02 /* produce tracing output */
// #define DEBUG_ERRORS 0x10 /* print decoder errors to output */
// set OSS_DEBUG_MASK=0x02
// set OSS_DEBUG_MASK=0x10 - only print decoder errors
if (pszEnvVar = getenv( pszOSS_DEBUG_MASK)) {
unsigned long ulEnvVar;
ulEnvVar = strtoul( pszEnvVar, &p, 16) & (DEBUGPDU | DEBUG_ERRORS);
if ( ulEnvVar)
ossSetDecodingFlags( pog, ulEnvVar | RELAXBER);
if ( DEBUGPDU & ulEnvVar)
ossSetEncodingFlags( pog, DEBUGPDU | FRONT_ALIGN);
else
ossSetEncodingFlags( pog, FRONT_ALIGN);
} else {
ossSetDecodingFlags( pog, DEBUG_ERRORS | RELAXBER);
ossSetEncodingFlags( pog, FRONT_ALIGN);
}
if (pszEnvVar = getenv( pszOSS_DEBUG_TRACEFILE))
ossOpenTraceFile( pog, pszEnvVar);
#ifdef _DEBUG
if (DbgGetDebugFlags() & DEBUG_MASK_MEM) {
pog->mallocp = scMalloc;
pog->reallocp = scRealloc;
pog->freep = scFree;
}
#else
pog->mallocp = scMalloc;
pog->reallocp = scRealloc;
pog->freep = scFree;
#endif
return TRUE;
}
//+-------------------------------------------------------------------------
//
// Function: DebugDllMain
//
// Synopsis: Initialize the debug DLL
//
// Returns: TRUE
//
//--------------------------------------------------------------------------
BOOL
WINAPI
DebugDllMain(
HMODULE hInst,
ULONG ulReason,
LPVOID lpReserved)
{
BOOL fRet = TRUE;
switch (ulReason) {
case DLL_PROCESS_ATTACH:
fRet = DbgProcessAttach();
// fRet &= RegTestInit(); // JLS
break;
case DLL_PROCESS_DETACH:
fRet = DbgProcessDetach();
// RegTestCleanup(); // JLS
break;
default:
break;
}
return fRet;
}
const char *DbgGetSSString(DWORD dwSubSystemId)
{
DBG_SS_TAG *psSS;
psSS = &sSSTags[0];
while (psSS->dwSS > 0)
{
if ((psSS->dwSS & dwSubSystemId) > 0)
{
if (psSS->pszTag)
{
return(psSS->pszTag);
}
return(pszDefualtSSTag);
}
psSS++;
}
return(pszDefualtSSTag);
}
static BOOL DbgIsSSActive(DWORD dwSSIn)
{
char *pszEnvVar;
DWORD dwEnv;
dwEnv = 0;
if (pszEnvVar = getenv(pszDEBUG_PRINT_MASK))
{
dwEnv = (DWORD)strtol(pszEnvVar, NULL, 16);
}
return((dwEnv & dwSSIn) > 0);
}
//+-------------------------------------------------------------------------
//
// Function: DbgPrintf
//
// Synopsis: outputs debug info to stdout and debugger
//
// Returns: number of chars output
//
//--------------------------------------------------------------------------
int WINAPIV DbgPrintf(DWORD dwSubSystemId, LPCSTR lpFmt, ...)
{
va_list arglist;
CHAR ach1[1024];
CHAR ach2[1080];
int cch;
HANDLE hStdOut;
DWORD cb;
DWORD dwErr;
dwErr = GetLastError();
if (!(DbgIsSSActive(dwSubSystemId)))
{
SetLastError(dwErr);
return(0);
}
_try
{
va_start(arglist, lpFmt);
wvnsprintf( ach1, ARRAYSIZE(ach1), lpFmt, arglist);
va_end(arglist);
cch = wnsprintf(ach2, ARRAYSZIE(ach2),"%s: %s", DbgGetSSString(dwSubSystemId), ach1);
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (hStdOut != INVALID_HANDLE_VALUE)
{
WriteConsole( hStdOut, ach2, strlen(ach2), &cb, NULL);
}
OutputDebugString(ach2);
} _except( EXCEPTION_EXECUTE_HANDLER)
{
// return failure
cch = 0;
}
SetLastError(dwErr);
return cch;
}
#else // !0 // JLS
int WINAPIV DbgPrintf(DWORD dwSubSystemId, LPCSTR lpFmt, ...)
{
return 0;
}
#endif // 0 JLS
#endif // DBG
#endif // SMIME_V3
| 23.138028 | 94 | 0.493426 | npocmaka |
e96957d7604f6b91f2f1403e55a8f6b3dc262022 | 10,293 | hpp | C++ | core/src/cogs/collections/slink.hpp | cogmine/cogs | ef1c369a36a4f811704e0ced0493c3a6f8eca821 | [
"MIT"
] | 5 | 2019-02-08T15:59:14.000Z | 2022-01-22T19:12:33.000Z | core/src/cogs/collections/slink.hpp | cogmine/cogs | ef1c369a36a4f811704e0ced0493c3a6f8eca821 | [
"MIT"
] | 1 | 2019-12-03T03:11:34.000Z | 2019-12-03T03:11:34.000Z | core/src/cogs/collections/slink.hpp | cogmine/cogs | ef1c369a36a4f811704e0ced0493c3a6f8eca821 | [
"MIT"
] | null | null | null | //
// Copyright (C) 2000-2020 - Colen M. Garoutte-Carson <colen at cogmine.com>, Cog Mine LLC
//
// Status: Good
#ifndef COGS_HEADER_COLLECTION_SLINK
#define COGS_HEADER_COLLECTION_SLINK
#include <type_traits>
#include "cogs/mem/ptr.hpp"
namespace cogs {
/// @defgroup CollectionMixIns Collection Mix-In's
/// @{
/// @ingroup Collections
/// @}
/// @defgroup CollectionAccessorMixIns Accessor Mix-In's
/// @{
/// @ingroup CollectionMixIns
/// @brief Accessor mix-in's provide intrusive collection algorithms with access to the links within intrusive elements.
/// They are an alternative to deriving from an intrusive link base class. They allow use of an intrusive element that
/// do not publicly expose access to the link accessors.
/// @}
/// @ingroup CollectionAccessorMixIns
/// @brief Provides a default slink accessor mix-in type which leverages accessors in the intrusive element.
/// @tparam link_t The link type to wrap access to.
/// @tparam ref_type Type used to reference elements. Default: ptr
template <class link_t, template <typename> class ref_type = ptr>
class default_slink_accessor
{
public:
typedef ref_type<link_t> ref_t;
static const ref_t& get_next(const link_t& l) { return l.get_next_link(); }
static const volatile ref_t& get_next(const volatile link_t& l) { return l.get_next_link(); }
static void set_next(link_t& l, const ref_t& src) { l.set_next_link(src); }
static void set_next(volatile link_t& l, const ref_t& src) { l.set_next_link(src); }
};
template <class link_t, template <typename> class ref_type = ptr, class link_accessor = default_slink_accessor<link_t, ref_type> >
class slink_methods
{
public:
typedef ref_type<link_t> ref_t;
static const ref_t& get_next(const link_t& l) { return link_accessor::get_next(l); }
static const volatile ref_t& get_next(const volatile link_t& l) { return link_accessor::get_next(l); }
static void set_next(link_t& l, const ref_t& src) { link_accessor::set_next_link(l, src); }
static void set_next(volatile link_t& l, const ref_t& src) { link_accessor::set_next_link(l, src); }
static void insert_next(link_t& ths, const ref_t& l)
{
set_next(*l, get_next(ths));
set_next(ths, l);
}
static ref_t remove_next(link_t& ths)
{
ref_t l(get_next(ths));
set_next(ths, get_next(*l));
return l;
}
static void insert_segment(link_t& ths, const ref_t& seq_start, const ref_t& seq_end)
{
set_next(*seq_end, get_next(ths));
set_next(ths, seq_start);
}
static ref_t insert_terminated_list(link_t& ths, const ref_t& l, const ref_t& terminator = ref_t())
{
ref_t last(find_last_terminated(ths, l, terminator));
set_next(*last, get_next(ths));
set_next(ths, l);
return last;
}
static ref_t insert_circular_list(link_t& ths, const ref_t& l)
{
ref_t last(find_last_circular(l));
set_next(*last, get_next(ths));
set_next(ths, l);
return last;
}
static ref_t insert_list(link_t& ths, const ref_t& l, const ref_t& terminator = ref_t())
{
ref_t last(find_last(l, terminator)); // supports terminator or full circular
set_next(*last, get_next(ths));
set_next(ths, l);
return last;
}
static bool is_circular(const link_t& ths, const ref_t& terminator = ref_t())
{
bool result = false;
size_t count = 0;
size_t loop_at = 1;
ref_t loop = ths;
ref_t cur(get_next(ths));
for(;;)
{
if (terminator != cur)
{
if (loop != cur)
{
if (++count == loop_at)
{
loop_at <<= 1;
count = 0;
loop = cur;
}
cur = get_next(*cur);
continue;
}
result = true;
}
break;
}
return result;
}
static bool is_full_circular(const link_t& ths, const ref_t& terminator = ref_t())
{
bool result = false;
size_t count = 0;
size_t loop_at = 1;
ref_t loop;
ref_t cur(get_next(ths));
for(;;)
{
if (terminator != cur)
{
if (cur != ths)
{
if (++count == loop_at)
{
loop_at <<= 1;
count = 0;
loop = cur;
}
cur = get_next(*cur);
if (loop == cur)
break;
continue;
}
result = true;
}
break;
}
return result;
}
static bool is_tail_circular(const link_t& ths, const ref_t& terminator = ref_t())
{
bool result = false;
size_t count = 0;
size_t loop_at = 1;
ref_t loop;
ref_t cur(get_next(ths));
for(;;)
{
if (terminator != cur)
{
if (ths != cur)
{
if (++count == loop_at)
{
loop_at <<= 1;
count = 0;
loop = cur;
}
cur = get_next(*cur);
if (loop != cur)
continue;
result = true;
}
}
break;
}
return result;
}
static ref_t find_last(const ref_t& l, const ref_t& terminator = ref_t())
{
ref_t last(l);
for (;;)
{
ref_t cur(get_next(*last));
if ((cur != l) && (cur != terminator))
{
last = cur;
continue;
}
break;
}
return last;
}
static ref_t find_last_terminated(const ref_t& l, const ref_t& terminator = ref_t())
{
ref_t last(l);
for (;;)
{
ref_t cur(get_next(*last));
if (cur != terminator)
{
last = cur;
continue;
}
break;
}
return last;
}
static ref_t find_last_circular(const ref_t& l)
{
ref_t last(l);
for (;;)
{
ref_t cur(get_next(*last));
if (cur != l)
{
last = cur;
continue;
}
break;
}
return last;
}
static ref_t reverse(const ref_t& l)
{
if (!l)
return l;
ref_t cur(l);
ref_t prev;
ref_t prevprev;
do {
prevprev = prev;
prev = cur;
cur = get_next(*cur);
get_next(*prev) = prevprev;
} while (!!cur);
return prev;
}
};
/// @ingroup Collections
/// @brief Base class for a single-link list element. Does not include storage or link accessor methods.
/// @tparam derived_t Derived type of this class.
/// This <a href="https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern">curiously recurring template pattern</a>
/// allows links to refer to the derived type. Storage and access can be defined in the derived type.
/// @tparam ref_type Type used to reference elements. Default: ptr
/// @tparam link_accessor Mix-in type providing access to the link. Default: default_slink_accessor<derived_t, ref_type>
template <class derived_t, template <typename> class ref_type = ptr, class link_accessor = default_slink_accessor<derived_t, ref_type> >
class slink_base
{
public:
typedef slink_base<derived_t, ref_type, link_accessor> this_t;
typedef std::conditional_t<std::is_void_v<derived_t>, this_t, derived_t> link_t;
typedef ref_type<link_t> ref_t;
typedef slink_methods<link_t, ref_type, link_accessor> slink_methods_t;
// non-volatile misc
void insert_next(const ref_t& l) { slink_methods_t::insert_next(*(derived_t*)this, l); }
ref_t remove_next() { return slink_methods_t::remove_next(*(derived_t*)this); }
void insert_segment(const ref_t& seq_start, const ref_t& seq_end) { slink_methods_t::insert_segment(*(derived_t*)this, seq_start, seq_end); }
ref_t insert_terminated_list(const ref_t& l, const ref_t& terminator = ref_t()) { return slink_methods_t::insert_terminated_list(*(derived_t*)this, l, terminator); }
ref_t insert_circular_list(const ref_t& l) { return slink_methods_t::insert_circular_list(*(derived_t*)this, l); }
ref_t insert_list(const ref_t& l, const ref_t& terminator = ref_t()) { return slink_methods_t::insert_list(*(derived_t*)this, l, terminator); }
bool is_circular(const ref_t& terminator = ref_t()) const { return slink_methods_t::is_circular(*(derived_t*)this, terminator); }
bool is_full_circular(const ref_t& terminator = ref_t()) const { return slink_methods_t::is_full_circular(*(derived_t*)this, terminator); }
bool is_tail_circular(const ref_t& terminator = ref_t()) const { return slink_methods_t::is_tail_circular(*(derived_t*)this, terminator); }
static ref_t find_last(const ref_t& l, const ref_t& terminator = ref_t()) { return slink_methods_t::find_last(l, terminator); }
static ref_t find_last_terminated(const ref_t& l, const ref_t& terminator = ref_t()) { return slink_methods_t::find_last_terminated(l, terminator); }
static ref_t find_last_circular(const ref_t& l) { return slink_methods_t::find_last_circular(l); }
static ref_t reverse(const ref_t& l) { return slink_methods_t::reverse(l); }
};
/// @ingroup Collections
/// @brief Base class for a single-link list element.
/// @tparam derived_t Derived type of this class.
/// This <a href="https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern">curiously recurring template pattern</a>
/// allows links to refer to the derived type.
/// If void is specified, links will point to slink_t<void, ref_type, link_accessor>. Default: void
/// @tparam ref_type Type used to reference elements. Default: ptr
/// @tparam link_accessor Mix-in type providing access to the link. Default: default_slink_accessor<derived_t, ref_type>
template <class derived_t = void, template <typename> class ref_type = ptr, class link_accessor = default_slink_accessor<derived_t, ref_type> >
class slink_t : public slink_base<derived_t, ref_type, link_accessor>
{
public:
typedef slink_t<derived_t, ref_type, link_accessor> this_t;
typedef std::conditional_t<std::is_void_v<derived_t>, this_t, derived_t> link_t;
typedef ref_type<link_t> ref_t;
typedef default_slink_accessor<this_t, ref_type> default_link_accessor;
private:
ref_t m_next;
slink_t(const this_t& t) = delete;
this_t& operator=(const this_t& t) = delete;
public:
slink_t() { }
slink_t(this_t&& t)
: m_next(std::move(t.m_next))
{
}
this_t& operator=(this_t&& t)
{
m_next = std::move(t.m_next);
return *this;
}
ref_t& get_next_link() { return m_next; }
const ref_t& get_next_link() const { return m_next; }
volatile ref_t& get_next_link() volatile { return m_next; }
const volatile ref_t& get_next_link() const volatile { return m_next; }
void set_next_link(const ref_t& n) { m_next = n; }
void set_next_link(const volatile ref_t& n) { m_next = n; }
void set_next_link(const ref_t& n) volatile { m_next = n; }
void set_next_link(const volatile ref_t& n) volatile { m_next = n; }
};
template <template <typename> class ref_type>
class default_slink_accessor<void, ref_type> : public default_slink_accessor<slink_t<void, ref_type, default_slink_accessor<void, ref_type> > >
{
};
typedef slink_t<void> slink;
}
#endif
| 28.671309 | 166 | 0.69727 | cogmine |
e96b9ffc9bfccf5fd044d06f47b7ba2dd9f07800 | 1,587 | hpp | C++ | CheckBoxList.hpp | chrisoldwood/WCL | 608a83f9e41f4c1d2a7ac6991abbcf264d5924e0 | [
"MIT"
] | 5 | 2017-10-02T04:10:35.000Z | 2021-07-26T04:45:35.000Z | CheckBoxList.hpp | chrisoldwood/WCL | 608a83f9e41f4c1d2a7ac6991abbcf264d5924e0 | [
"MIT"
] | null | null | null | CheckBoxList.hpp | chrisoldwood/WCL | 608a83f9e41f4c1d2a7ac6991abbcf264d5924e0 | [
"MIT"
] | null | null | null | /******************************************************************************
** (C) Chris Oldwood
**
** MODULE: CHECKBOXLIST.HPP
** COMPONENT: Windows C++ Library.
** DESCRIPTION: The CCheckBoxList class declaration.
**
*******************************************************************************
*/
// Check for previous inclusion
#ifndef CHECKBOXLIST_HPP
#define CHECKBOXLIST_HPP
#if _MSC_VER > 1000
#pragma once
#endif
#include "ListView.hpp"
/******************************************************************************
**
** This is a ListView derived class used to display a list of check boxes.
**
*******************************************************************************
*/
class CCheckBoxList : public CListView
{
public:
//
// Constructors/Destructor.
//
CCheckBoxList();
~CCheckBoxList();
//
// Methods.
//
void ItemCheck(size_t nItem, bool bChecked);
bool IsItemChecked(size_t nItem);
protected:
//
// Members.
//
//
// Message processors.
//
virtual void OnCreate(const CRect& rcClient);
};
/******************************************************************************
**
** Implementation of inline functions.
**
*******************************************************************************
*/
inline void CCheckBoxList::ItemCheck(size_t nItem, bool bChecked)
{
uint nState = INDEXTOSTATEIMAGEMASK((bChecked ? 2 : 1));
ListView_SetItemState(m_hWnd, nItem, nState, LVIS_STATEIMAGEMASK);
}
inline bool CCheckBoxList::IsItemChecked(size_t nItem)
{
return ListView_GetCheckState(m_hWnd, nItem);
}
#endif //CHECKBOXLIST_HPP
| 21.445946 | 79 | 0.499685 | chrisoldwood |
e96bd7ccbe48938a31e49d9b6304e55f8f1a0773 | 399 | cpp | C++ | 1914.cpp | Valarr/Uri | 807de771b14b0e60d44b23835ad9ee7423c83471 | [
"MIT"
] | null | null | null | 1914.cpp | Valarr/Uri | 807de771b14b0e60d44b23835ad9ee7423c83471 | [
"MIT"
] | null | null | null | 1914.cpp | Valarr/Uri | 807de771b14b0e60d44b23835ad9ee7423c83471 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
int main(){
int a;
scanf("%d",&a);
int b,c;
string k, par, l, impar;
while(a--){
cin >> k >> par >> l >> impar;
scanf("%d %d", &b,&c);
if((b+c)%2==0){
if(par=="PAR"){ cout << k << "\n";}
else{ cout << l << "\n";}
}
else{
if(par=="IMPAR"){ cout << k << "\n";}
else{ cout << l << "\n";}
}
}
}
| 17.347826 | 43 | 0.401003 | Valarr |
e96ee95be7010cc6916ec20a22735213dd50df5a | 10,433 | cc | C++ | iree/vm/stack_test.cc | rsuderman/iree | fa5faf0a254db3311dafacc70c383a7469376095 | [
"Apache-2.0"
] | 2 | 2021-01-03T04:45:05.000Z | 2021-01-03T04:45:08.000Z | iree/vm/stack_test.cc | rsuderman/iree | fa5faf0a254db3311dafacc70c383a7469376095 | [
"Apache-2.0"
] | null | null | null | iree/vm/stack_test.cc | rsuderman/iree | fa5faf0a254db3311dafacc70c383a7469376095 | [
"Apache-2.0"
] | 1 | 2020-03-06T06:22:26.000Z | 2020-03-06T06:22:26.000Z | // Copyright 2019 Google LLC
//
// 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
//
// https://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 "iree/vm/stack.h"
#include <cstring>
#include "iree/base/api.h"
#include "iree/base/ref_ptr.h"
#include "iree/testing/gtest.h"
#include "iree/vm/ref.h"
namespace {
#define MODULE_A_SENTINEL reinterpret_cast<iree_vm_module_t*>(1)
#define MODULE_B_SENTINEL reinterpret_cast<iree_vm_module_t*>(2)
#define MODULE_A_STATE_SENTINEL reinterpret_cast<iree_vm_module_state_t*>(101)
#define MODULE_B_STATE_SENTINEL reinterpret_cast<iree_vm_module_state_t*>(102)
static int module_a_state_resolve_count = 0;
static int module_b_state_resolve_count = 0;
static iree_status_t SentinelStateResolver(
void* state_resolver, iree_vm_module_t* module,
iree_vm_module_state_t** out_module_state) {
if (module == MODULE_A_SENTINEL) {
++module_a_state_resolve_count;
*out_module_state = MODULE_A_STATE_SENTINEL;
return IREE_STATUS_OK;
} else if (module == MODULE_B_SENTINEL) {
++module_b_state_resolve_count;
*out_module_state = MODULE_B_STATE_SENTINEL;
return IREE_STATUS_OK;
}
return IREE_STATUS_NOT_FOUND;
}
// Tests simple stack usage, mainly just for demonstration.
TEST(VMStackTest, Usage) {
auto stack = std::make_unique<iree_vm_stack_t>();
iree_vm_state_resolver_t state_resolver = {nullptr, SentinelStateResolver};
IREE_EXPECT_OK(iree_vm_stack_init(state_resolver, stack.get()));
EXPECT_EQ(nullptr, iree_vm_stack_current_frame(stack.get()));
EXPECT_EQ(nullptr, iree_vm_stack_parent_frame(stack.get()));
iree_vm_function_t function_a = {MODULE_A_SENTINEL,
IREE_VM_FUNCTION_LINKAGE_INTERNAL, 0};
iree_vm_stack_frame_t* frame_a = nullptr;
IREE_EXPECT_OK(
iree_vm_stack_function_enter(stack.get(), function_a, &frame_a));
EXPECT_EQ(0, frame_a->function.ordinal);
EXPECT_EQ(frame_a, iree_vm_stack_current_frame(stack.get()));
EXPECT_EQ(nullptr, iree_vm_stack_parent_frame(stack.get()));
iree_vm_function_t function_b = {MODULE_B_SENTINEL,
IREE_VM_FUNCTION_LINKAGE_INTERNAL, 1};
iree_vm_stack_frame_t* frame_b = nullptr;
IREE_EXPECT_OK(
iree_vm_stack_function_enter(stack.get(), function_b, &frame_b));
EXPECT_EQ(1, frame_b->function.ordinal);
EXPECT_EQ(frame_b, iree_vm_stack_current_frame(stack.get()));
EXPECT_EQ(frame_a, iree_vm_stack_parent_frame(stack.get()));
IREE_EXPECT_OK(iree_vm_stack_function_leave(stack.get()));
EXPECT_EQ(frame_a, iree_vm_stack_current_frame(stack.get()));
EXPECT_EQ(nullptr, iree_vm_stack_parent_frame(stack.get()));
IREE_EXPECT_OK(iree_vm_stack_function_leave(stack.get()));
EXPECT_EQ(nullptr, iree_vm_stack_current_frame(stack.get()));
EXPECT_EQ(nullptr, iree_vm_stack_parent_frame(stack.get()));
IREE_EXPECT_OK(iree_vm_stack_deinit(stack.get()));
}
// Tests stack cleanup with unpopped frames (like during failure teardown).
TEST(VMStackTest, DeinitWithRemainingFrames) {
auto stack = std::make_unique<iree_vm_stack_t>();
iree_vm_state_resolver_t state_resolver = {nullptr, SentinelStateResolver};
IREE_EXPECT_OK(iree_vm_stack_init(state_resolver, stack.get()));
iree_vm_function_t function_a = {MODULE_A_SENTINEL,
IREE_VM_FUNCTION_LINKAGE_INTERNAL, 0};
iree_vm_stack_frame_t* frame_a = nullptr;
IREE_EXPECT_OK(
iree_vm_stack_function_enter(stack.get(), function_a, &frame_a));
EXPECT_EQ(0, frame_a->function.ordinal);
EXPECT_EQ(frame_a, iree_vm_stack_current_frame(stack.get()));
EXPECT_EQ(nullptr, iree_vm_stack_parent_frame(stack.get()));
// Don't pop the last frame before deinit; it should handle it.
IREE_EXPECT_OK(iree_vm_stack_deinit(stack.get()));
EXPECT_EQ(nullptr, iree_vm_stack_current_frame(stack.get()));
}
// Tests stack overflow detection.
TEST(VMStackTest, StackOverflow) {
auto stack = std::make_unique<iree_vm_stack_t>();
iree_vm_state_resolver_t state_resolver = {nullptr, SentinelStateResolver};
IREE_EXPECT_OK(iree_vm_stack_init(state_resolver, stack.get()));
EXPECT_EQ(nullptr, iree_vm_stack_current_frame(stack.get()));
EXPECT_EQ(nullptr, iree_vm_stack_parent_frame(stack.get()));
// Fill the entire stack up to the max.
iree_vm_function_t function_a = {MODULE_A_SENTINEL,
IREE_VM_FUNCTION_LINKAGE_INTERNAL, 0};
for (int i = 0; i < IREE_MAX_STACK_DEPTH; ++i) {
iree_vm_stack_frame_t* frame_a = nullptr;
IREE_EXPECT_OK(
iree_vm_stack_function_enter(stack.get(), function_a, &frame_a));
}
// Try to push on one more frame.
iree_vm_function_t function_b = {MODULE_B_SENTINEL,
IREE_VM_FUNCTION_LINKAGE_INTERNAL, 1};
iree_vm_stack_frame_t* frame_b = nullptr;
EXPECT_EQ(IREE_STATUS_RESOURCE_EXHAUSTED,
iree_vm_stack_function_enter(stack.get(), function_b, &frame_b));
// Should still be frame A.
EXPECT_EQ(0, iree_vm_stack_current_frame(stack.get())->function.ordinal);
IREE_EXPECT_OK(iree_vm_stack_deinit(stack.get()));
}
// Tests unbalanced stack popping.
TEST(VMStackTest, UnbalancedPop) {
auto stack = std::make_unique<iree_vm_stack_t>();
iree_vm_state_resolver_t state_resolver = {nullptr, SentinelStateResolver};
IREE_EXPECT_OK(iree_vm_stack_init(state_resolver, stack.get()));
EXPECT_EQ(IREE_STATUS_FAILED_PRECONDITION,
iree_vm_stack_function_leave(stack.get()));
IREE_EXPECT_OK(iree_vm_stack_deinit(stack.get()));
}
// Tests module state reuse and querying.
TEST(VMStackTest, ModuleStateQueries) {
auto stack = std::make_unique<iree_vm_stack_t>();
iree_vm_state_resolver_t state_resolver = {nullptr, SentinelStateResolver};
IREE_EXPECT_OK(iree_vm_stack_init(state_resolver, stack.get()));
EXPECT_EQ(nullptr, iree_vm_stack_current_frame(stack.get()));
EXPECT_EQ(nullptr, iree_vm_stack_parent_frame(stack.get()));
module_a_state_resolve_count = 0;
module_b_state_resolve_count = 0;
// [A (queried)]
iree_vm_function_t function_a = {MODULE_A_SENTINEL,
IREE_VM_FUNCTION_LINKAGE_INTERNAL, 0};
iree_vm_stack_frame_t* frame_a = nullptr;
IREE_EXPECT_OK(
iree_vm_stack_function_enter(stack.get(), function_a, &frame_a));
EXPECT_EQ(MODULE_A_STATE_SENTINEL, frame_a->module_state);
EXPECT_EQ(1, module_a_state_resolve_count);
// [A, B (queried)]
iree_vm_function_t function_b = {MODULE_B_SENTINEL,
IREE_VM_FUNCTION_LINKAGE_INTERNAL, 1};
iree_vm_stack_frame_t* frame_b = nullptr;
IREE_EXPECT_OK(
iree_vm_stack_function_enter(stack.get(), function_b, &frame_b));
EXPECT_EQ(MODULE_B_STATE_SENTINEL, frame_b->module_state);
EXPECT_EQ(1, module_b_state_resolve_count);
// [A, B, B (reuse)]
IREE_EXPECT_OK(
iree_vm_stack_function_enter(stack.get(), function_b, &frame_b));
EXPECT_EQ(MODULE_B_STATE_SENTINEL, frame_b->module_state);
EXPECT_EQ(1, module_b_state_resolve_count);
IREE_EXPECT_OK(iree_vm_stack_function_leave(stack.get()));
IREE_EXPECT_OK(iree_vm_stack_function_leave(stack.get()));
IREE_EXPECT_OK(iree_vm_stack_function_leave(stack.get()));
IREE_EXPECT_OK(iree_vm_stack_deinit(stack.get()));
}
// Tests that module state query failures propagate to callers correctly.
TEST(VMStackTest, ModuleStateQueryFailure) {
auto stack = std::make_unique<iree_vm_stack_t>();
iree_vm_state_resolver_t state_resolver = {
nullptr,
+[](void* state_resolver, iree_vm_module_t* module,
iree_vm_module_state_t** out_module_state) -> iree_status_t {
// NOTE: always failing.
return IREE_STATUS_INTERNAL;
}};
IREE_EXPECT_OK(iree_vm_stack_init(state_resolver, stack.get()));
// Push should fail if we can't query state, status should propagate.
iree_vm_function_t function_a = {MODULE_A_SENTINEL,
IREE_VM_FUNCTION_LINKAGE_INTERNAL, 0};
iree_vm_stack_frame_t* frame_a = nullptr;
EXPECT_EQ(IREE_STATUS_INTERNAL,
iree_vm_stack_function_enter(stack.get(), function_a, &frame_a));
IREE_EXPECT_OK(iree_vm_stack_deinit(stack.get()));
}
static int dummy_object_count = 0;
class DummyObject : public iree::RefObject<DummyObject> {
public:
static iree_vm_ref_type_t kTypeID;
static void RegisterType() {
static iree_vm_ref_type_descriptor_t descriptor;
descriptor.type_name = iree_string_view_t{
typeid(DummyObject).name(), std::strlen(typeid(DummyObject).name())};
descriptor.offsetof_counter = DummyObject::offsetof_counter();
descriptor.destroy = DummyObject::DirectDestroy;
iree_vm_ref_register_type(&descriptor);
kTypeID = descriptor.type;
}
DummyObject() { ++dummy_object_count; }
~DummyObject() { --dummy_object_count; }
};
iree_vm_ref_type_t DummyObject::kTypeID = IREE_VM_REF_TYPE_NULL;
// Tests stack frame ref register cleanup.
TEST(VMStackTest, RefRegisterCleanup) {
auto stack = std::make_unique<iree_vm_stack_t>();
iree_vm_state_resolver_t state_resolver = {nullptr, SentinelStateResolver};
IREE_EXPECT_OK(iree_vm_stack_init(state_resolver, stack.get()));
dummy_object_count = 0;
DummyObject::RegisterType();
iree_vm_function_t function_a = {MODULE_A_SENTINEL,
IREE_VM_FUNCTION_LINKAGE_INTERNAL, 0};
iree_vm_stack_frame_t* frame_a = nullptr;
IREE_EXPECT_OK(
iree_vm_stack_function_enter(stack.get(), function_a, &frame_a));
frame_a->registers.ref_register_count = 1;
memset(&frame_a->registers.ref[0], 0, sizeof(iree_vm_ref_t));
IREE_EXPECT_OK(iree_vm_ref_wrap_assign(
new DummyObject(), DummyObject::kTypeID, &frame_a->registers.ref[0]));
EXPECT_EQ(1, dummy_object_count);
// This should release the ref for us. Heap checker will yell if it doesn't.
IREE_EXPECT_OK(iree_vm_stack_function_leave(stack.get()));
EXPECT_EQ(0, dummy_object_count);
IREE_EXPECT_OK(iree_vm_stack_deinit(stack.get()));
}
} // namespace
| 39.97318 | 78 | 0.75012 | rsuderman |
e976852fe01b660f90e281aae7d41b1bfa44be63 | 435 | inl | C++ | node_modules/lzz-gyp/lzz-source/smtc_TmplFuncDefn.inl | SuperDizor/dizornator | 9f57dbb3f6af80283b4d977612c95190a3d47900 | [
"ISC"
] | 3 | 2019-09-18T16:44:33.000Z | 2021-03-29T13:45:27.000Z | node_modules/lzz-gyp/lzz-source/smtc_TmplFuncDefn.inl | SuperDizor/dizornator | 9f57dbb3f6af80283b4d977612c95190a3d47900 | [
"ISC"
] | null | null | null | node_modules/lzz-gyp/lzz-source/smtc_TmplFuncDefn.inl | SuperDizor/dizornator | 9f57dbb3f6af80283b4d977612c95190a3d47900 | [
"ISC"
] | 2 | 2019-03-29T01:06:38.000Z | 2019-09-18T16:44:34.000Z | // smtc_TmplFuncDefn.inl
//
#ifdef LZZ_ENABLE_INLINE
#define LZZ_INLINE inline
#else
#define LZZ_INLINE
#endif
namespace smtc
{
LZZ_INLINE TmplFuncDefn::TmplFuncDefn (TmplSpecPtrVector const & tmpl_spec_set, FuncDefnPtr const & func_defn)
: TmplFuncDecl (tmpl_spec_set, func_defn)
{}
}
namespace smtc
{
LZZ_INLINE FuncDefnPtr TmplFuncDefn::getFuncDefn () const
{
return getFuncDecl ();
}
}
#undef LZZ_INLINE
| 18.913043 | 112 | 0.744828 | SuperDizor |
e976bb3f488e776db80e97ce4b4eca75e15d8607 | 2,641 | cpp | C++ | demos/Tweening.cpp | liavt/MACE | 9a4e83b2b5cb39d9a69b2e699b57c05d9dd94aad | [
"MIT"
] | 9 | 2016-03-01T03:10:50.000Z | 2021-04-15T09:17:14.000Z | demos/Tweening.cpp | liavt/The-Poor-Plebs-Engine | 9a4e83b2b5cb39d9a69b2e699b57c05d9dd94aad | [
"MIT"
] | 10 | 2016-07-09T04:00:27.000Z | 2019-12-09T09:14:49.000Z | demos/Tweening.cpp | liavt/The-Poor-Plebs-Engine | 9a4e83b2b5cb39d9a69b2e699b57c05d9dd94aad | [
"MIT"
] | 3 | 2017-05-24T04:07:40.000Z | 2019-10-11T20:31:25.000Z | /*
Copyright (c) 2016-2019 Liav Turkia
See LICENSE.md for full copyright information
*/
#include <MACE/MACE.h>
using namespace mc;
gfx::Image square;
void create(gfx::WindowModule& win) {
square = gfx::Image(Colors::RED);
square.setX(-0.5f);
square.setY(0.5f);
square.setWidth(0.1f);
square.setHeight(0.1f);
std::shared_ptr<gfx::ComponentQueue> queue = std::shared_ptr<gfx::ComponentQueue>(new gfx::ComponentQueue());
TransformMatrix dest1 = TransformMatrix();
dest1.scaler = { 0.2f, 0.2f, 0.0f };
dest1.translation = { 0.5f, 0.5f, 0.0f };
dest1.rotation = { 0.0f, 0.0f, 0.5f };
gfx::EaseSettings settings = gfx::EaseSettings();
settings.ms = 1000;
settings.ease = gfx::EaseFunctions::BOUNCE_OUT;
settings.repeats = 1;
settings.reverseOnRepeat = false;
queue->addComponent(std::shared_ptr<gfx::Component>(new gfx::TweenComponent(&square, dest1, settings)));
TransformMatrix dest2 = TransformMatrix(dest1);
dest2.scaler = { 0.5f, 0.5f, 0.0f };
dest2.translation = { 0.5f, -0.5f, 0.0f };
dest2.rotation = { 0.0f, 0.0f, 1.5f };
settings.ms = 1500;
settings.ease = gfx::EaseFunctions::QUADRATIC_IN;
settings.repeats = 3;
settings.reverseOnRepeat = true;
queue->addComponent(std::shared_ptr<gfx::Component>(new gfx::TweenComponent(&square, dest1, dest2, settings)));
TransformMatrix dest3 = TransformMatrix(dest2);
dest3.scaler = { 0.05f, 0.05f, 0.0f };
dest3.translation = { -0.5f, -0.5f, 0.0f };
dest3.rotation = { 0.0f, 0.0f, 6.0f };
settings.ms = 2000;
settings.ease = gfx::EaseFunctions::LINEAR;
settings.repeats = 1;
settings.reverseOnRepeat = false;
queue->addComponent(std::shared_ptr<gfx::Component>(new gfx::TweenComponent(&square, dest2, dest3, settings)));
//have it end up at the same place
settings.ms = 2000;
settings.ease = gfx::EaseFunctions::ELASTIC_IN;
settings.repeats = 3;
settings.reverseOnRepeat = false;
queue->addComponent(std::shared_ptr<gfx::Component>(new gfx::TweenComponent(&square, dest3, square.getTransformation(), settings)));
square.addComponent(queue);
win.addChild(square);
win.getContext()->getRenderer()->setRefreshColor(Colors::DARK_BLUE);
}
int main() {
Instance instance = Instance();
try {
gfx::WindowModule::LaunchConfig config = gfx::WindowModule::LaunchConfig(600, 600, "Tweening Demo");
config.onCreate = &create;
config.resizable = true;
gfx::WindowModule module = gfx::WindowModule(config);
instance.addModule(module);
os::ErrorModule errModule = os::ErrorModule();
instance.addModule(errModule);
instance.start();
} catch (const std::exception& e) {
Error::handleError(e, instance);
return -1;
}
return 0;
}
| 29.344444 | 133 | 0.709958 | liavt |
e97db13c29a28aecb05281afbf709bf303a77a36 | 5,352 | cc | C++ | squid_wrap/squid_win_helpers/auth/ext_AD_Group/AD_group/rfc1738.cc | NPaolini/NPS_OpenSource | 0c7da066b02b57ce282a1903a3901a563d04a28f | [
"Unlicense"
] | null | null | null | squid_wrap/squid_win_helpers/auth/ext_AD_Group/AD_group/rfc1738.cc | NPaolini/NPS_OpenSource | 0c7da066b02b57ce282a1903a3901a563d04a28f | [
"Unlicense"
] | null | null | null | squid_wrap/squid_win_helpers/auth/ext_AD_Group/AD_group/rfc1738.cc | NPaolini/NPS_OpenSource | 0c7da066b02b57ce282a1903a3901a563d04a28f | [
"Unlicense"
] | null | null | null | /*
* Copyright (C) 1996-2018 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
* Please see the COPYING and CONTRIBUTORS files for details.
*/
#define _CRT_SECURE_NO_WARNINGS
//#include "squid.h"
#include "rfc1738.h"
//#if HAVE_STRING_H
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
//#endif
/*
* RFC 1738 defines that these characters should be escaped, as well
* any non-US-ASCII character or anything between 0x00 - 0x1F.
*/
static TCHAR rfc1738_unsafe_chars[] = {
(TCHAR) 0x3C, /* < */
(TCHAR) 0x3E, /* > */
(TCHAR) 0x22, /* " */
(TCHAR) 0x23, /* # */
#if 0 /* done in code */
(TCHAR) 0x20, /* space */
(TCHAR) 0x25, /* % */
#endif
(TCHAR) 0x7B, /* { */
(TCHAR) 0x7D, /* } */
(TCHAR) 0x7C, /* | */
(TCHAR) 0x5C, /* \ */
(TCHAR) 0x5E, /* ^ */
(TCHAR) 0x7E, /* ~ */
(TCHAR) 0x5B, /* [ */
(TCHAR) 0x5D, /* ] */
(TCHAR) 0x60, /* ` */
(TCHAR) 0x27 /* ' */
};
static TCHAR rfc1738_reserved_chars[] = {
(TCHAR) 0x3b, /* ; */
(TCHAR) 0x2f, /* / */
(TCHAR) 0x3f, /* ? */
(TCHAR) 0x3a, /* : */
(TCHAR) 0x40, /* @ */
(TCHAR) 0x3d, /* = */
(TCHAR) 0x26 /* & */
};
/*
* rfc1738_escape - Returns a static buffer contains the RFC 1738
* compliant, escaped version of the given url.
*/
TCHAR *
rfc1738_do_escape(const TCHAR *url, int flags)
{
static TCHAR *buf;
static size_t bufsize = 0;
const TCHAR *src;
TCHAR *dst;
unsigned int i, do_escape;
if (buf == NULL || _tcslen(url) * 3 > bufsize) {
delete []buf;
bufsize = _tcslen(url) * 3 + 1;
buf = new TCHAR[bufsize];
}
for (src = url, dst = buf; *src != _T('\0') && dst < (buf + bufsize - 1); src++, dst++) {
/* a-z, A-Z and 0-9 are SAFE. */
if ((*src >= _T('a') && *src <= _T('z')) || (*src >= _T('A') && *src <= _T('Z')) || (*src >= _T('0') && *src <= _T('9'))) {
*dst = *src;
continue;
}
do_escape = 0;
/* RFC 1738 defines these chars as unsafe */
if ((flags & RFC1738_ESCAPE_UNSAFE)) {
for (i = 0; i < sizeof(rfc1738_unsafe_chars); i++) {
if (*src == rfc1738_unsafe_chars[i]) {
do_escape = 1;
break;
}
}
/* Handle % separately */
if (!(flags & RFC1738_ESCAPE_NOPERCENT) && *src == _T('%'))
do_escape = 1;
/* Handle space separately */
else if (!(flags & RFC1738_ESCAPE_NOSPACE) && *src <= _T(' '))
do_escape = 1;
}
/* RFC 1738 defines these chars as reserved */
if ((flags & RFC1738_ESCAPE_RESERVED) && do_escape == 0) {
for (i = 0; i < sizeof(rfc1738_reserved_chars); i++) {
if (*src == rfc1738_reserved_chars[i]) {
do_escape = 1;
break;
}
}
}
if ((flags & RFC1738_ESCAPE_CTRLS) && do_escape == 0) {
/* RFC 1738 says any control chars (0x00-0x1F) are encoded */
if ((unsigned char) *src <= (unsigned char) 0x1F)
do_escape = 1;
/* RFC 1738 says 0x7f is encoded */
else if (*src == (TCHAR) 0x7F)
do_escape = 1;
/* RFC 1738 says any non-US-ASCII are encoded */
else if (((unsigned char) *src >= (unsigned char) 0x80))
do_escape = 1;
}
/* Do the triplet encoding, or just copy the TCHAR */
if (do_escape == 1) {
(void)_sntprintf(dst, (bufsize-(dst-buf)), _T("%%%02X"), (unsigned) *src);
dst += 2; //sizeof(TCHAR) * 2;
} else {
*dst = *src;
}
}
*dst = _T('\0');
return (buf);
}
/*
* Converts a ascii hex code into a binary character.
*/
static int
fromhex(TCHAR ch)
{
if (ch >= _T('0') && ch <= _T('9'))
return ch - _T('0');
if (ch >= _T('a') && ch <= _T('f'))
return ch - _T('a') + 10;
if (ch >= _T('A') && ch <= _T('F'))
return ch - _T('A') + 10;
return -1;
}
/*
* rfc1738_unescape() - Converts escaped characters (%xy numbers) in
* given the string. %% is a %. %ab is the 8-bit hexadecimal number "ab"
*/
void
rfc1738_unescape(TCHAR *s)
{
int i, j; /* i is write, j is read */
for (i = j = 0; s[j]; i++, j++) {
s[i] = s[j];
if (s[j] != _T('%')) {
/* normal case, nothing more to do */
} else if (s[j + 1] == _T('%')) { /* %% case */
j++; /* Skip % */
} else {
/* decode */
int v1, v2, x;
v1 = fromhex(s[j + 1]);
if (v1 < 0)
continue; /* non-hex or \0 */
v2 = fromhex(s[j + 2]);
if (v2 < 0)
continue; /* non-hex or \0 */
x = v1 << 4 | v2;
if (x > 0 && x <= 255) {
s[i] = x;
j += 2;
}
}
}
s[i] = _T('\0');
}
| 30.237288 | 131 | 0.448617 | NPaolini |
e97f3b8b5f0e037da3dccfaba4bac513eb31f0f4 | 29 | cpp | C++ | DinoLasers/ContactManifold.cpp | QRayarch/DinoLasers | 500f4144fad2a813cd140d6067b41a41f4573e8c | [
"MIT"
] | null | null | null | DinoLasers/ContactManifold.cpp | QRayarch/DinoLasers | 500f4144fad2a813cd140d6067b41a41f4573e8c | [
"MIT"
] | null | null | null | DinoLasers/ContactManifold.cpp | QRayarch/DinoLasers | 500f4144fad2a813cd140d6067b41a41f4573e8c | [
"MIT"
] | null | null | null | #include "ContactManifold.h"
| 14.5 | 28 | 0.793103 | QRayarch |
e97f792fcdfd9dde7882bb657cf63e706c34d5e9 | 15,997 | cpp | C++ | source/MultiLibrary/Window/Windows/Window.cpp | danielga/multilibrary | 3d1177dd3affa875e06015f5e3e42dda525f3336 | [
"BSD-3-Clause"
] | 2 | 2018-06-22T12:43:57.000Z | 2019-05-31T21:56:27.000Z | source/MultiLibrary/Window/Windows/Window.cpp | danielga/multilibrary | 3d1177dd3affa875e06015f5e3e42dda525f3336 | [
"BSD-3-Clause"
] | 1 | 2017-09-09T01:21:31.000Z | 2017-11-12T17:52:56.000Z | source/MultiLibrary/Window/Windows/Window.cpp | danielga/multilibrary | 3d1177dd3affa875e06015f5e3e42dda525f3336 | [
"BSD-3-Clause"
] | 1 | 2022-03-30T18:57:41.000Z | 2022-03-30T18:57:41.000Z | /*************************************************************************
* MultiLibrary - https://danielga.github.io/multilibrary/
* A C++ library that covers multiple low level systems.
*------------------------------------------------------------------------
* Copyright (c) 2014-2022, Daniel Almeida
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************/
#include <MultiLibrary/Window/Window.hpp>
#include <MultiLibrary/Window/Windows/Context.hpp>
#include <MultiLibrary/Common/Unicode.hpp>
#include <stdexcept>
#include <cstring>
#include <Windows.h>
#undef CreateWindow
namespace MultiLibrary
{
enum ButtonState
{
BUTTON_RELEASED,
BUTTON_PRESSED,
BUTTON_STICKY
};
namespace Internal
{
class WindowInitializer
{
public:
WindowInitializer( ) :
class_atom( nullptr )
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = WindowProcedure;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof( void * ) + sizeof( int32_t );
wc.hInstance = GetModuleHandle( nullptr );
wc.hCursor = LoadCursor( nullptr, IDC_ARROW );
wc.hbrBackground = nullptr;
wc.lpszMenuName = nullptr;
wc.lpszClassName = window_class;
wc.hIcon = LoadIcon( nullptr, IDI_WINLOGO );
ATOM atom = RegisterClass( &wc );
if( atom == 0 )
throw std::runtime_error( "failed to create window class" );
class_atom = MAKEINTATOM( atom );
HWND temp_window = CreateWindowEx( 0, L"STATIC", L"", WS_POPUP | WS_DISABLED, 0, 0, 0, 0, nullptr, nullptr, GetModuleHandle( nullptr ), nullptr );
if( temp_window == nullptr )
throw std::runtime_error( "failed to create temporary window" );
{
Context context( temp_window, WindowSettings( ) );
context.SetActive( true );
if( glewInit( ) != GLEW_OK )
throw new std::runtime_error( "unable to initialize glew" );
}
DestroyWindow( temp_window );
}
~WindowInitializer( )
{
UnregisterClass( class_atom, GetModuleHandle( nullptr ) );
}
LPCWSTR GetWindowClass( )
{
return class_atom;
}
private:
static LRESULT CALLBACK WindowProcedure( HWND window, UINT msg, WPARAM wparam, LPARAM lparam )
{
switch( msg )
{
case WM_NCCREATE:
{
LPCREATESTRUCT create_struct = reinterpret_cast<LPCREATESTRUCT>( lparam );
SetWindowLongPtr( window, GWLP_USERDATA, reinterpret_cast<LONG_PTR>( create_struct->lpCreateParams ) );
break;
}
case WM_CLOSE:
reinterpret_cast<Window *>( GetWindowLongPtr( window, GWLP_USERDATA ) )->SetShouldClose( true );
return 0;
}
return DefWindowProc( window, msg, wparam, lparam );
}
LPCWSTR class_atom;
static const wchar_t window_class[];
};
const wchar_t WindowInitializer::window_class[] = L"MultiLibrary";
static void GetFullWindowSize( DWORD flags, DWORD exflags, int32_t win, int32_t hin, int32_t &wout, int32_t &hout )
{
RECT rect = { 0, 0, win, hin };
if( AdjustWindowRectEx( &rect, flags, FALSE, exflags ) == FALSE )
return;
wout = rect.right - rect.left;
hout = rect.bottom - rect.top;
}
} // namespace Internal
struct Window::Handle
{
Handle( HWND window, const WindowSettings &window_settings ) :
handle( window, DestroyWindow ),
icon( nullptr, DestroyIcon ),
context( window, window_settings )
{
std::memset( keyboard_buttons, BUTTON_RELEASED, sizeof( keyboard_buttons ) );
std::memset( mouse_buttons, BUTTON_RELEASED, sizeof( mouse_buttons ) );
}
std::unique_ptr<HWND__, BOOL ( WINAPI * )( HWND )> handle;
std::unique_ptr<HICON__, BOOL ( WINAPI * )( HICON )> icon;
Context context;
Monitor monitor;
DWORD flags;
DWORD exflags;
bool sticky_keys;
bool sticky_mouse;
ButtonState keyboard_buttons[KEY_CODE_LAST + 1];
ButtonState mouse_buttons[MOUSE_BUTTON_LAST + 1];
};
Window::Window( ) :
should_close( false )
{ }
Window::Window( const std::string &title, const WindowSettings &window_setup ) :
should_close( false )
{
Create( title, window_setup );
}
Window::~Window( )
{ }
bool Window::IsValid( ) const
{
return static_cast<bool>( window_internal );
}
bool Window::Create( const std::string &title, const WindowSettings &window_setup )
{
if( IsValid( ) )
return false;
static Internal::WindowInitializer window_initializer;
std::wstring widetitle;
UTF16::FromUTF8( title.begin( ), title.end( ), std::back_inserter( widetitle ) );
DWORD flags = WS_CLIPSIBLINGS | WS_CLIPCHILDREN, exflags = WS_EX_APPWINDOW | WS_EX_ACCEPTFILES;
int32_t x = window_setup.x, y = window_setup.y, w = 0, h = 0;
if( window_setup.monitor.IsValid( ) )
{
flags |= WS_POPUP;
if( window_setup.visible )
flags |= WS_VISIBLE;
Vector2i pos = window_setup.monitor.GetPosition( );
x = pos.x;
y = pos.y;
w = window_setup.width;
h = window_setup.height;
}
else
{
if( window_setup.decorated )
{
flags |= WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
if( window_setup.resizable )
{
flags |= WS_MAXIMIZEBOX | WS_SIZEBOX;
exflags |= WS_EX_WINDOWEDGE;
}
}
else
{
flags |= WS_POPUP;
}
if( window_setup.visible )
flags |= WS_VISIBLE;
Internal::GetFullWindowSize( flags, exflags, window_setup.width, window_setup.height, w, h );
}
HWND handle = CreateWindowEx(
exflags,
window_initializer.GetWindowClass( ),
widetitle.c_str( ),
flags,
x, y,
w, h,
nullptr,
nullptr,
GetModuleHandle( nullptr ),
this
);
if( handle == nullptr )
return false;
#if defined MSGFLT_ALLOW
ChangeWindowMessageFilterEx( handle, WM_DROPFILES, MSGFLT_ALLOW, nullptr );
ChangeWindowMessageFilterEx( handle, WM_COPYDATA, MSGFLT_ALLOW, nullptr );
ChangeWindowMessageFilterEx( handle, 0x0049, MSGFLT_ALLOW, nullptr ); // WM_COPYGLOBALDATA
#endif
DWORD newflags = GetWindowLong( handle, GWL_STYLE );
DWORD newexflags = GetWindowLong( handle, GWL_EXSTYLE );
window_settings = window_setup;
window_internal = std::make_shared<Handle>( handle, window_setup );
window_internal->flags = newflags;
window_internal->exflags = newexflags;
window_internal->monitor = window_setup.monitor;
return true;
}
void Window::Close( )
{
if( !IsValid( ) )
return;
window_internal.reset( );
}
bool Window::ShouldClose( ) const
{
if( !IsValid( ) )
return false;
return should_close;
}
void Window::SetShouldClose( bool close )
{
if( !IsValid( ) )
return;
should_close = close;
}
bool Window::IsActive( ) const
{
return window_internal->context.IsActive( );
}
void Window::SetActive( bool active )
{
if( !IsValid( ) )
return;
window_internal->context.SetActive( active );
}
void Window::SetTitle( const std::string &title )
{
if( !IsValid( ) )
return;
std::wstring widetitle;
UTF16::FromUTF8( title.begin( ), title.end( ), std::back_inserter( widetitle ) );
SetWindowText( window_internal->handle.get( ), widetitle.c_str( ) );
}
void Window::SetIcon( uint32_t width, uint32_t height, const uint8_t *pixels )
{
std::vector<uint8_t> iconPixels( width * height * 4 );
for( std::size_t i = 0; i < iconPixels.size( ) / 4; ++i )
{
iconPixels[i * 4 + 0] = pixels[i * 4 + 2];
iconPixels[i * 4 + 1] = pixels[i * 4 + 1];
iconPixels[i * 4 + 2] = pixels[i * 4 + 0];
iconPixels[i * 4 + 3] = pixels[i * 4 + 3];
}
window_internal->icon.reset( CreateIcon( GetModuleHandle( nullptr ), width, height, 1, 32, nullptr, &iconPixels[0] ) );
if( window_internal->icon )
{
SendMessage( window_internal->handle.get( ), WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>( window_internal->icon.get( ) ) );
SendMessage( window_internal->handle.get( ), WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>( window_internal->icon.get( ) ) );
}
}
Vector2i Window::GetSize( ) const
{
Vector2i size;
if( !IsValid( ) )
return size;
RECT area;
if( GetClientRect( window_internal->handle.get( ), &area ) == FALSE )
return size;
size.x = area.right;
size.y = area.bottom;
return size;
}
void Window::SetSize( const Vector2i &size )
{
if( !IsValid( ) )
return;
int32_t w = 0, h = 0;
Internal::GetFullWindowSize( window_internal->flags, window_internal->exflags, size.x, size.y, w, h );
SetWindowPos( window_internal->handle.get( ), HWND_TOP, 0, 0, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOZORDER );
}
Vector2i Window::GetFramebufferSize( ) const
{
return GetSize( );
}
Vector2i Window::GetPosition( ) const
{
Vector2i pos;
if( !IsValid( ) )
return pos;
POINT wpos = { 0, 0 };
if( ClientToScreen( window_internal->handle.get( ), &wpos ) == FALSE )
return pos;
pos.x = wpos.x;
pos.y = wpos.y;
return pos;
}
void Window::SetPosition( const Vector2i &pos )
{
if( !IsValid( ) )
return;
RECT rect = { pos.x, pos.y, pos.x, pos.y };
if( AdjustWindowRectEx( &rect, window_internal->flags, FALSE, window_internal->exflags ) == FALSE )
return;
SetWindowPos( window_internal->handle.get( ), nullptr, rect.left, rect.top, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE );
}
Vector2i Window::GetCursorPos( ) const
{
Vector2i pos;
if( !IsValid( ) )
return pos;
POINT point;
if( ::GetCursorPos( &point ) == FALSE )
return pos;
if( ScreenToClient( window_internal->handle.get( ), &point ) == FALSE )
return pos;
pos.x = point.x;
pos.y = point.y;
return pos;
}
void Window::SetCursorPos( const Vector2i &pos )
{
if( !IsValid( ) )
return;
POINT wpos = { pos.x, pos.y };
if( ClientToScreen( window_internal->handle.get( ), &wpos ) == FALSE )
return;
::SetCursorPos( wpos.x, wpos.y );
}
std::string Window::GetClipboardString( ) const
{
std::string clipboard;
if( !IsValid( ) )
return clipboard;
if( IsClipboardFormatAvailable( CF_UNICODETEXT ) == FALSE )
return clipboard;
if( OpenClipboard( window_internal->handle.get( ) ) == FALSE )
return clipboard;
HANDLE string_handle = GetClipboardData( CF_UNICODETEXT );
if( string_handle == nullptr )
{
CloseClipboard( );
return clipboard;
}
wchar_t *widechar = reinterpret_cast<wchar_t *>( GlobalLock( string_handle ) );
GlobalUnlock( string_handle );
CloseClipboard( );
if( widechar == nullptr )
return clipboard;
UTF8::FromUTF16( widechar, widechar + wcslen( widechar ), std::back_inserter( clipboard ) );
return clipboard;
}
void Window::SetClipboardString( const std::string &text )
{
if( !IsValid( ) )
return;
std::wstring widetext;
UTF16::FromUTF8( text.begin( ), text.end( ), std::back_inserter( widetext ) );
size_t widesize = widetext.size( ) + 1;
HANDLE string_handle = GlobalAlloc( GMEM_MOVEABLE, widesize );
if( string_handle == nullptr )
return;
void *buffer = GlobalLock( string_handle );
if( buffer == nullptr )
return;
std::memcpy( buffer, widetext.c_str( ), widesize );
GlobalUnlock( string_handle );
if( OpenClipboard( window_internal->handle.get( ) ) == FALSE )
{
GlobalFree( string_handle );
return;
}
EmptyClipboard( );
SetClipboardData( CF_UNICODETEXT, string_handle );
CloseClipboard( );
}
CursorMode Window::GetCursorMode( ) const
{
if( !IsValid( ) )
return static_cast<CursorMode>( -1 );
return static_cast<CursorMode>( -1 );
}
void Window::SetCursorMode( CursorMode mode )
{
if( !IsValid( ) )
return;
switch( mode )
{
case CURSOR_MODE_DISABLED:
break;
case CURSOR_MODE_HIDDEN:
break;
case CURSOR_MODE_NORMAL:
break;
}
}
bool Window::GetStickyKeysActive( ) const
{
if( !IsValid( ) )
return false;
return window_internal->sticky_keys;
}
void Window::SetStickyKeysActive( bool active )
{
if( !IsValid( ) )
return;
window_internal->sticky_keys = active;
}
bool Window::GetStickyMouseButtonsActive( ) const
{
if( !IsValid( ) )
return false;
return window_internal->sticky_mouse;
}
void Window::SetStickyMouseButtonsActive( bool active )
{
if( !IsValid( ) )
return;
window_internal->sticky_mouse = active;
}
bool Window::IsKeyPressed( KeyCode code ) const
{
if( !IsValid( ) )
return false;
ButtonState state = window_internal->keyboard_buttons[code];
if( state == BUTTON_STICKY )
window_internal->keyboard_buttons[code] = BUTTON_RELEASED;
return state != BUTTON_RELEASED;
}
bool Window::IsMouseButtonPressed( MouseButton code ) const
{
if( !IsValid( ) )
return false;
ButtonState state = window_internal->mouse_buttons[code];
if( state == BUTTON_STICKY )
window_internal->mouse_buttons[code] = BUTTON_RELEASED;
return state != BUTTON_RELEASED;
}
Monitor Window::GetFullscreenMonitor( ) const
{
if( !IsValid( ) )
return Monitor( );
return window_internal->monitor;
}
bool Window::IsFocused( ) const
{
if( !IsValid( ) )
return false;
return GetForegroundWindow( ) == window_internal->handle.get( );
}
bool Window::IsResizable( ) const
{
if( !IsValid( ) )
return false;
return window_settings.resizable;
}
bool Window::IsDecorated( ) const
{
if( !IsValid( ) )
return false;
return window_settings.decorated;
}
bool Window::IsIconified( ) const
{
if( !IsValid( ) )
return false;
return IsIconic( window_internal->handle.get( ) ) == TRUE;
}
void Window::SetIconified( bool iconified )
{
if( !IsValid( ) )
return;
ShowWindow( window_internal->handle.get( ), iconified ? SW_MINIMIZE : SW_RESTORE );
}
bool Window::IsVisible( ) const
{
if( !IsValid( ) )
return false;
return IsWindowVisible( window_internal->handle.get( ) ) == TRUE;
}
void Window::SetVisible( bool visible )
{
if( !IsValid( ) )
return;
ShowWindow( window_internal->handle.get( ), visible ? SW_SHOWNORMAL : SW_HIDE );
}
bool Window::SwapBuffers( )
{
if( !IsValid( ) )
return false;
return ::SwapBuffers( window_internal->context.device_context ) == TRUE;
}
bool Window::SwapInterval( int32_t refreshes )
{
if( !IsValid( ) || wglSwapIntervalEXT == nullptr )
return false;
return wglSwapIntervalEXT( refreshes ) == TRUE;
}
void Window::PollEvents( )
{
MSG msg;
while( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) == TRUE )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
void Window::WaitEvents( )
{
WaitMessage( );
PollEvents( );
}
void Window::OnClose( ) { }
void Window::OnRefresh( ) { }
void Window::OnResize( const Vector2i & ) { }
void Window::OnReposition( const Vector2i & ) { }
void Window::OnFocus( bool ) { }
void Window::OnIconify( bool ) { }
void Window::OnFramebufferResize( const Vector2i & ) { }
void Window::OnKeyPress( int32_t, int32_t, int32_t, int32_t ) { }
void Window::OnCharacterInput( uint32_t ) { }
void Window::OnMousePress( int32_t, int32_t, int32_t ) { }
void Window::OnCursorReposition( const Vector2d & ) { }
void Window::OnCursorEnter( bool ) { }
void Window::OnScroll( const Vector2d & ) { }
} // namespace MultiLibrary
| 22.918338 | 148 | 0.69213 | danielga |
e98115dad0b67cb249eb5edf68b6ed356f982b17 | 1,223 | hpp | C++ | minige/src/math/mat4.hpp | vitaminac/metaphysics | 0f9fda58e3b29a10535d873824a00497e0fc5ac2 | [
"MIT"
] | null | null | null | minige/src/math/mat4.hpp | vitaminac/metaphysics | 0f9fda58e3b29a10535d873824a00497e0fc5ac2 | [
"MIT"
] | null | null | null | minige/src/math/mat4.hpp | vitaminac/metaphysics | 0f9fda58e3b29a10535d873824a00497e0fc5ac2 | [
"MIT"
] | null | null | null | #pragma once
#include "vec3.hpp"
#include "vec4.hpp"
namespace gengine {
namespace math {
/* Column Major 4x4 Matrix */
typedef struct mat4 {
union
{
float elements[4 * 4];
vec4 columns[4];
};
mat4() = default;
SO_API friend mat4 operator*(const mat4& left, const mat4& right);
SO_API friend vec3 operator*(const mat4& left, const vec3& right);
SO_API friend vec4 operator*(const mat4& left, const vec4& right);
const vec4& operator[](const int index) const;
SO_API static mat4 diagonal(const float diagonal);
SO_API static mat4 identity();
SO_API static mat4 zero();
SO_API static mat4 translation(const vec3& translation);
SO_API static mat4 rotation(const vec3& axis, const float angle);
SO_API static mat4 scale(const vec3& k);
SO_API static mat4 orthographic(const float left, const float right, const float bottom, const float top, const float near, const float far);
SO_API static mat4 perspective(const float fov, const float aspectRatio, const float near, const float far);
SO_API static mat4 perspective_frustum(const float left, const float right, const float bottom, const float top, const float near, const float far);
} mat4;
}
} | 29.119048 | 151 | 0.716271 | vitaminac |
e984acd57e07bbd11e2f3a3f8bfcd4b8762ead7b | 4,770 | cpp | C++ | Uno/GUI/ServerScreen.cpp | Wolchy/Uno | 3ebb485b7e71b801cdd08d2cf97bbbb9579f44b5 | [
"MIT"
] | null | null | null | Uno/GUI/ServerScreen.cpp | Wolchy/Uno | 3ebb485b7e71b801cdd08d2cf97bbbb9579f44b5 | [
"MIT"
] | null | null | null | Uno/GUI/ServerScreen.cpp | Wolchy/Uno | 3ebb485b7e71b801cdd08d2cf97bbbb9579f44b5 | [
"MIT"
] | null | null | null | #include "ServerScreen.h"
ServerScreen::ServerScreen(Mya mya) : Screen::Screen("screenServer")
{
assets = new Assets(mya);
tv_port = new TextView(*assets->font, "Port: ", 5, 5, mya.getRenderer());
et_port = new EditText("9998", *assets->font, mya.getRenderer(), tv_port->tex.w + 5, 5);
btn_host = new Button("Host", *assets->font, mya.getRenderer(), 5, 35);
tv_player = new TextView(*assets->font, "Players: ", 5, 35, mya.getRenderer());
btn_startRound = new Button("Start Round", *assets->font, mya.getRenderer(), 5, 5);
network.isServer = true;
}
void ServerScreen::render(Mya mya)
{
if (!isOn) {
tv_port->render(mya.getRenderer());
et_port->butt->renderButton(mya.getRenderer());
btn_host->renderButton(mya.getRenderer());
}
else {
btn_startRound->renderButton(mya.getRenderer());
tv_player->render(mya.getRenderer());
for (TextView* tv : tv_players)
tv->render(mya.getRenderer());
}
}
void ServerScreen::update(Mya mya)
{
if (isOn) {
network.server_update();
if (network.hasNewMessage) {
SplitString ss;
for (std::string s : network._buffer) {
std::cout << s << std::endl;
std::vector<std::string> abba = ss.split(s, "&");
int id = std::stoi(abba[0]);
std::string o = abba[1];
std::vector<std::string> b = ss.split(o, "|");
if (b[0] == "regPlayer") {
Player p;
p.user = id;
p.name = b[1];
board.players.push_back(p);
tv_players.push_back(new TextView(*assets->font, p.name, 25, 65 + (tv_players.size() * 30), mya.getRenderer()));
}
if (b[0] == "ichewyou") {
Card c;
c.type = b[1];
c.color = b[2];
board.pile.deck.push_back(c);
bool aboola = false;
if (b[1] == "cardWild" || b[1] == "cardWild4") {
c.color = "null";
aboola = true;
}
if (b[1] == "cardPlusTwo") {
board.cycleUser();
std::string s = "fix1]";
for (int i = 0; i < 2; i++) {
SDL_Delay(20);
Card wah = board.deck.grabCard();
board.players[board.user].takeCard(wah);
s = s + "heresanude|" + c.type + "|" + c.color + "^";
}
network.server_sendMessage(board.user, s);
}
if (b[1] == "cardWild4") {
board.cycleUser();
std::string s = "fix1]";
for (int i = 0; i < 4; i++) {
SDL_Delay(20);
Card wah = board.deck.grabCard();
board.players[board.user].takeCard(wah);
s = s + "heresanude|" + c.type + "|" + c.color + "^";
}
network.server_sendMessage(board.user, s);
}
board.players[id].useCard(c);
if(!aboola)
board.pile.deck.push_back(c);
board.useCard(c);
//UNO check
if (board.players[id].cards.size() == 1)
network.sendMessage("UNO|" + board.players[id].name);
if (board.players[id].cards.size() == 0) {
network.sendMessage("WINNER|" + board.players[id].name);
}
board.cycleUser();
Card ncard = board.pile.deck[board.pile.deck.size()-1];//not what it looks like
SDL_Delay(20);
std::cout << std::to_string(board.user) << std::endl;
network.server_sendMessage(board.user, "urturnsir|" + ncard.type + "|" + ncard.color);
}
if (b[0] == "sendnudes") {
Card c = board.deck.grabCard();
board.players[id].takeCard(c);
SDL_Delay(20);
network.server_sendMessage(id, "heresanude|" + c.type + "|" + c.color);
board.cycleUser();
Card ncard = board.pile.deck[board.pile.deck.size() - 1];//not what it looks like
SDL_Delay(20);
std::cout << std::to_string(board.user) << std::endl;
network.server_sendMessage(board.user, "urturnsir|" + ncard.type + "|" + ncard.color);
}
}
network._buffer.clear();
network.hasNewMessage = false;
}
}
}
void ServerScreen::mouseKeyUp(Mya mya, SDL_MouseButtonEvent & k)
{
if (k.button == SDL_BUTTON_LEFT) {
if (!isOn) {
et_port->wasPressed(mouseX, mouseY);
if (btn_host->wasPressed(mouseX, mouseY)) {
isOn = true;
network.PORT = std::stoi(et_port->butt->tv->getText());
network.init();
}
}
else {
if (btn_startRound->wasPressed(mouseX, mouseY)) {
board.isThisRealLife = true;
board.start();
network.sendMessage("clean");
for (int i = 0; i < board.players.size(); i++) {
std::string s = "fix1]";
for (Card c : board.players[i].cards) {
s = s + "heresanude|" + c.type + "|" + c.color + "^";
}
SDL_Delay(25);
network.server_sendMessage(board.players[i].user, s);
}
SDL_Delay(25);
Card ncard = board.pile.deck[board.pile.deck.size() - 1];//not what it looks like
network.server_sendMessage(board.user, "urturnsir|" + ncard.type + "|" + ncard.color);
}
}
}
}
void ServerScreen::keyUp(Mya mya, Uint8 k)
{
if (!isOn)
et_port->handleKey(k, mya.getRenderer());
}
| 29.444444 | 117 | 0.592034 | Wolchy |
e9860e961e26f6900dea4d6d50ad1d4df42b20c0 | 564 | cpp | C++ | src/model/common/comtu.cpp | fanghaocong/GitlHEVCAnalyzer | 1dbf3adca4822b0a55af03c7a7f49c92798c91d6 | [
"Apache-2.0"
] | null | null | null | src/model/common/comtu.cpp | fanghaocong/GitlHEVCAnalyzer | 1dbf3adca4822b0a55af03c7a7f49c92798c91d6 | [
"Apache-2.0"
] | null | null | null | src/model/common/comtu.cpp | fanghaocong/GitlHEVCAnalyzer | 1dbf3adca4822b0a55af03c7a7f49c92798c91d6 | [
"Apache-2.0"
] | null | null | null | #include "comtu.h"
ComTU::ComTU()
{
}
bool ComTU::isValid(int cuLeft, int cuTop, int cuRight, int cuBottom)
{
if ( m_iX < cuLeft || m_iX > cuRight )
{
return false;
}
if ( m_iY < cuTop || m_iY > cuBottom )
{
return false;
}
int tuRight = m_iX + m_iWidth - 1;
if (tuRight < m_iX || tuRight > cuRight )
{
return false;
}
int tuBottom = m_iY + m_iHeight - 1;
if (tuBottom < m_iY || tuBottom > cuBottom )
{
return false;
}
return true;
}
| 17.090909 | 70 | 0.5 | fanghaocong |
e9862a8d8d79bf90db88df6722c9342dbab39e70 | 11,842 | hpp | C++ | include/fiction/algorithms/network_transformation/fanout_substitution.hpp | ElderDelp/fiction | f16bf67bbfd94e5a3d5b6b5cd9cbce5275e44ce8 | [
"MIT"
] | null | null | null | include/fiction/algorithms/network_transformation/fanout_substitution.hpp | ElderDelp/fiction | f16bf67bbfd94e5a3d5b6b5cd9cbce5275e44ce8 | [
"MIT"
] | null | null | null | include/fiction/algorithms/network_transformation/fanout_substitution.hpp | ElderDelp/fiction | f16bf67bbfd94e5a3d5b6b5cd9cbce5275e44ce8 | [
"MIT"
] | null | null | null | //
// Created by marcel on 31.05.21.
//
#ifndef FICTION_FANOUT_SUBSTITUTION_HPP
#define FICTION_FANOUT_SUBSTITUTION_HPP
#include "fiction/algorithms/network_transformation/network_conversion.hpp"
#include "fiction/traits.hpp"
#include <mockturtle/algorithms/cleanup.hpp>
#include <mockturtle/traits.hpp>
#include <mockturtle/utils/node_map.hpp>
#include <mockturtle/views/topo_view.hpp>
#include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <queue>
#include <utility>
#include <vector>
#if (PROGRESS_BARS)
#include <mockturtle/utils/progress_bar.hpp>
#endif
namespace fiction
{
struct fanout_substitution_params
{
enum substitution_strategy
{
BREADTH,
DEPTH
};
/**
* Decomposition strategy (DEPTH vs. BREADTH).
*/
substitution_strategy strategy = BREADTH;
/**
* Maximum output degree of each fan-out node.
*/
uint32_t degree = 2ul;
/**
* Maximum number of outputs any gate is allowed to have before substitution applies.
*/
uint32_t threshold = 1ul;
};
namespace detail
{
template <typename NtkDest, typename NtkSrc>
class fanout_substitution_impl
{
public:
fanout_substitution_impl(const NtkSrc& src, const fanout_substitution_params p) :
ntk_topo{convert_network<NtkDest>(src)},
available_fanouts{ntk_topo},
ps{p}
{}
NtkDest run()
{
// initialize a network copy
auto init = mockturtle::initialize_copy_network<NtkDest>(ntk_topo);
auto substituted = init.first;
auto old2new = init.second;
ntk_topo.foreach_pi([this, &substituted, &old2new](const auto& pi)
{ generate_fanout_tree(substituted, pi, old2new); });
#if (PROGRESS_BARS)
// initialize a progress bar
mockturtle::progress_bar bar{static_cast<uint32_t>(ntk_topo.num_gates()), "[i] fanout substitution: |{0}|"};
#endif
ntk_topo.foreach_gate(
[&, this](const auto& n, [[maybe_unused]] auto i)
{
// gather children, but substitute fanouts where applicable
std::vector<mockturtle::signal<mockturtle::topo_view<NtkDest>>> children{};
ntk_topo.foreach_fanin(n,
[this, &old2new, &children, &substituted](const auto& f)
{
const auto fn = ntk_topo.get_node(f);
auto child = old2new[fn];
// constants do not need fanout trees
if (!ntk_topo.is_constant(fn))
{
child = get_fanout(substituted, fn, child);
}
children.push_back(child);
});
// clone the node with new children according to its depth
old2new[n] = substituted.clone_node(ntk_topo, n, children);
// generate the fanout tree for n
generate_fanout_tree(substituted, n, old2new);
#if (PROGRESS_BARS)
// update progress
bar(i);
#endif
});
// add primary outputs to finalize the network
ntk_topo.foreach_po(
[this, &old2new, &substituted](const auto& po)
{
const auto po_node = ntk_topo.get_node(po);
auto tgt_signal = old2new[po_node];
auto tgt_po = get_fanout(substituted, po_node, tgt_signal);
tgt_po = ntk_topo.is_complemented(po) ? substituted.create_not(tgt_signal) : tgt_po;
substituted.create_po(tgt_po);
});
// restore signal names if applicable
fiction::restore_names(ntk_topo, substituted, old2new);
return substituted;
}
private:
mockturtle::topo_view<NtkDest> ntk_topo;
using old2new_map = mockturtle::node_map<mockturtle::signal<NtkDest>, mockturtle::topo_view<NtkDest>>;
using old2new_queue_map =
mockturtle::node_map<std::queue<mockturtle::signal<NtkDest>>, mockturtle::topo_view<NtkDest>>;
old2new_queue_map available_fanouts;
const fanout_substitution_params ps;
void generate_fanout_tree(NtkDest& substituted, const mockturtle::node<NtkSrc>& n, const old2new_map& old2new)
{
// skip fanout tree generation if n is a proper fanout node
if constexpr (has_is_fanout_v<NtkDest>)
{
if (ntk_topo.is_fanout(n) && ntk_topo.fanout_size(n) <= ps.degree)
return;
}
auto num_fanouts = static_cast<uint32_t>(
std::ceil(static_cast<double>(std::max(
static_cast<int32_t>(ntk_topo.fanout_size(n)) - static_cast<int32_t>(ps.threshold), 0)) /
static_cast<double>(std::max(static_cast<int32_t>(ps.degree) - 1, 1))));
auto child = old2new[n];
if (num_fanouts == 0)
return;
if (ps.strategy == fanout_substitution_params::substitution_strategy::DEPTH)
{
std::queue<mockturtle::signal<NtkDest>> q{};
for (auto i = 0u; i < num_fanouts; ++i)
{
child = substituted.create_buf(child);
q.push(child);
}
available_fanouts[n] = q;
}
else if (ps.strategy == fanout_substitution_params::substitution_strategy::BREADTH)
{
std::queue<mockturtle::signal<NtkDest>> q{{child}};
for (auto f = 0ul; f < num_fanouts; ++f)
{
child = q.front();
q.pop();
child = substituted.create_buf(child);
for (auto i = 0u; i < ps.degree; ++i) q.push(child);
}
available_fanouts[n] = q;
}
}
mockturtle::signal<NtkDest> get_fanout(const NtkDest& substituted, const mockturtle::node<NtkSrc>& n,
mockturtle::signal<NtkDest>& child)
{
if (substituted.fanout_size(child) >= ps.threshold)
{
if (auto fanouts = available_fanouts[n]; !fanouts.empty())
{
// find non-overfull fanout node
do {
child = fanouts.front();
if (substituted.fanout_size(child) >= ps.degree)
fanouts.pop();
else
break;
} while (true);
}
}
return child;
}
};
template <typename Ntk>
class is_fanout_substituted_impl
{
public:
is_fanout_substituted_impl(const Ntk& src, fanout_substitution_params p) : ntk{src}, ps{p} {}
bool run()
{
ntk.foreach_node(
[this](const auto& n)
{
// skip constants
if (ntk.is_constant(n))
return substituted;
// check degree of fanout nodes
if constexpr (fiction::has_is_fanout_v<Ntk>)
{
if (ntk.is_fanout(n))
{
if (ntk.fanout_size(n) > ps.degree)
{
substituted = false;
}
return substituted;
}
}
// check threshold of non-fanout nodes
if (ntk.fanout_size(n) > ps.threshold)
{
substituted = false;
}
return substituted;
});
return substituted;
}
private:
const Ntk& ntk;
const fanout_substitution_params ps;
bool substituted = true;
};
} // namespace detail
/**
* Substitutes high-output degrees in a logic network with fanout nodes that compute the identity function. For this
* purpose, create_buf is utilized. Therefore, NtkDest should support identity nodes. If it does not, no new nodes will
* in fact be created. In either case, the returned network will be logically equivalent to the input one.
*
* The process is rather naive with two possible strategies to pick from: breath-first and depth-first. The former
* creates partially balanced fanout trees while the latter leads to fanout chains. Further parameterization includes
* thresholds for the maximum number of output each node and fanout is allowed to have.
*
* The returned network is newly created from scratch because its type NtkDest may differ from NtkSrc.
*
* NOTE: The physical design algorithms natively provided in fiction do not require their input networks to be
* fanout-substituted. If that is necessary, they will do it themselves. Providing already substituted networks does
* however allows for the control over maximum output degrees.
*
* @tparam NtkDest Type of the returned logic network.
* @tparam NtkSrc Type of the input logic network.
* @param ntk_src The input logic network.
* @param ps Parameters.
* @return A fanout-substituted logic network of type NtkDest that is logically equivalent to ntk_src.
*/
template <typename NtkDest, typename NtkSrc>
NtkDest fanout_substitution(const NtkSrc& ntk_src, fanout_substitution_params ps = {})
{
static_assert(mockturtle::is_network_type_v<NtkSrc>, "NtkSrc is not a network type");
static_assert(mockturtle::is_network_type_v<NtkDest>, "NtkDest is not a network type");
static_assert(mockturtle::has_is_constant_v<NtkDest>, "NtkSrc does not implement the is_constant function");
static_assert(mockturtle::has_create_pi_v<NtkDest>, "NtkDest does not implement the create_pi function");
static_assert(mockturtle::has_create_not_v<NtkDest>, "NtkDest does not implement the create_not function");
static_assert(mockturtle::has_create_po_v<NtkDest>, "NtkDest does not implement the create_po function");
static_assert(mockturtle::has_create_buf_v<NtkDest>, "NtkDest does not implement the create_buf function");
static_assert(mockturtle::has_clone_node_v<NtkDest>, "NtkDest does not implement the clone_node function");
static_assert(mockturtle::has_fanout_size_v<NtkDest>, "NtkDest does not implement the fanout_size function");
static_assert(mockturtle::has_foreach_gate_v<NtkDest>, "NtkDest does not implement the foreach_gate function");
static_assert(mockturtle::has_foreach_fanin_v<NtkDest>, "NtkDest does not implement the foreach_fanin function");
static_assert(mockturtle::has_foreach_po_v<NtkDest>, "NtkDest does not implement the foreach_po function");
detail::fanout_substitution_impl<NtkDest, NtkSrc> p{ntk_src, ps};
auto result = p.run();
return result;
}
/**
* Checks if a logic network is properly fanout-substituted with regard to the provided parameters, i.e., if no node
* exceeds the specified fanout limits.
*
* @tparam Ntk Logic network type.
* @param ntk The logic network to check.
* @param ps Parameters.
* @return True iff ntk is properly fanout-substituted with regard to ps.
*/
template <typename Ntk>
bool is_fanout_substituted(const Ntk& ntk, fanout_substitution_params ps = {}) noexcept
{
static_assert(mockturtle::is_network_type_v<Ntk>, "NtkSrc is not a network type");
static_assert(mockturtle::has_foreach_gate_v<Ntk>, "Ntk does not implement the foreach_gate function");
static_assert(mockturtle::has_fanout_size_v<Ntk>, "Ntk does not implement the fanout_size function");
detail::is_fanout_substituted_impl<Ntk> p{ntk, ps};
auto result = p.run();
return result;
}
} // namespace fiction
#endif // FICTION_FANOUT_SUBSTITUTION_HPP
| 35.561562 | 119 | 0.613748 | ElderDelp |
e98806e16efb7f40814f0608d6d0ee95dbbb26ea | 1,617 | hpp | C++ | Offer_012/Solution.hpp | DreamWaterFound/JZ_Offer | 054fd4bc08d00c94128bce93d30536a918b077bd | [
"WTFPL"
] | null | null | null | Offer_012/Solution.hpp | DreamWaterFound/JZ_Offer | 054fd4bc08d00c94128bce93d30536a918b077bd | [
"WTFPL"
] | null | null | null | Offer_012/Solution.hpp | DreamWaterFound/JZ_Offer | 054fd4bc08d00c94128bce93d30536a918b077bd | [
"WTFPL"
] | null | null | null |
using namespace std;
class Solution {
public:
double Power(double base, int exponent) {
if(exponent==0)
{
//指数不合法
return 1.0;
}
else if(exponent<0) //如果指数为负
{
mbNegative=true;
exponent=-exponent;
}
else
{
//指数为正
mbNegative=false;
}
//计算指数数值
double res=1.0;
for(int i=0;i<exponent;i++)
{
res*=base;
}
if(mbNegative)
{
res=1.0/res;
}
return res;
}
/**
* @brief 使用了递归方式
*
* @param[in] base 基数
* @param[in] exponent 指数
* @return double 计算结果
*/
double Power2(double base, int exponent) {
//首先是判断输入数据是否合法
if(exponent==0)
{
//不管你的基数是什么都返回1
return 1.0;
}
else if(exponent<0)
{
mbNegative=true;
return 1.0/subPower(base,exponent);
}
else
{
mbNegative=false;
return subPower(base,exponent);
}
}
//实现递归的函数
double subPower(double base,int exp)
{
if(exp==0)
{
return 1.0;
}
double tmp;
//如果指数是偶数
if(exp%2==0)
{
tmp=subPower(base,exp>>1);
return tmp*tmp;
}
else
{
//说明指数是奇数
tmp=subPower(base,(exp-1)>>1);
return tmp*tmp*base;
}
}
private:
//指数为负数的标志
bool mbNegative;
};
| 17.202128 | 47 | 0.40569 | DreamWaterFound |
e988506ac6657e8bea19a368918fbb2a90b88158 | 1,400 | hh | C++ | source/format/KBWPointCluster.hh | KUNPL/KEBII | 7feba36bb2ac2812c0dec21f5e3f3a0dcc1c8e39 | [
"MIT"
] | null | null | null | source/format/KBWPointCluster.hh | KUNPL/KEBII | 7feba36bb2ac2812c0dec21f5e3f3a0dcc1c8e39 | [
"MIT"
] | null | null | null | source/format/KBWPointCluster.hh | KUNPL/KEBII | 7feba36bb2ac2812c0dec21f5e3f3a0dcc1c8e39 | [
"MIT"
] | null | null | null | #ifndef KBWPOINTCLUSTER_HH
#define KBWPOINTCLUSTER_HH
#ifdef ACTIVATE_EVE
#include "TEveElement.h"
#include "TEvePointSet.h"
#endif
#include "KBWPoint.hh"
#include <vector>
#include <cmath>
/* Cluster of TWPoint.
* Adding KBWPoint to KBWPointCluster will calculate mean, covariance.
* MeanError(i,j) returns covariance/weight_sum.
*/
class KBWPointCluster : public KBWPoint
{
public:
KBWPointCluster();
virtual ~KBWPointCluster();
virtual void Print(Option_t *option = "") const;
virtual void Clear(Option_t *option = "");
virtual void Copy (TObject &object) const;
void Add(KBWPoint wp);
void Remove(KBWPoint wp);
void SetCov(Double_t cov[][3]);
void SetCov(Int_t i, Int_t j, Double_t cov);
void SetPosSigma(Double_t sigx, Double_t sigy, Double_t sigz);
void SetPosSigma(TVector3 sig);
TVector3 GetPosSigma();
Double_t StandardDeviation(Int_t i) { return sqrt(fCov[i][i]); }
Double_t Covariance(Int_t i, Int_t j) { return fCov[i][j]; }
Double_t MeanError(Int_t i, Int_t j) { return fCov[i][j]/fW; }
#ifdef ACTIVATE_EVE
virtual bool DrawByDefault();
virtual bool IsEveSet();
virtual TEveElement *CreateEveElement();
virtual void SetEveElement(TEveElement *element);
virtual void AddToEveSet(TEveElement *eveSet);
#endif
protected:
Double_t fCov[3][3];
ClassDef(KBWPointCluster, 1)
};
#endif
| 24.561404 | 70 | 0.707143 | KUNPL |
e9890a4a899fe4210cd202c733f2a7fea34326f7 | 2,060 | cpp | C++ | src/feata/util/shared_lib.cpp | master-clown/ofeata | 306cbc3a402551fb62b3925d23a2d4f63f60d525 | [
"MIT"
] | 1 | 2021-08-30T13:51:42.000Z | 2021-08-30T13:51:42.000Z | src/feata/util/shared_lib.cpp | master-clown/ofeata | 306cbc3a402551fb62b3925d23a2d4f63f60d525 | [
"MIT"
] | null | null | null | src/feata/util/shared_lib.cpp | master-clown/ofeata | 306cbc3a402551fb62b3925d23a2d4f63f60d525 | [
"MIT"
] | 1 | 2021-08-30T13:51:35.000Z | 2021-08-30T13:51:35.000Z | #include "util/shared_lib.hpp"
#include "util/filesys.hpp"
#include "defs/arch.hpp"
#if defined(FEATA_SYSTEM_WIN)
#include <Windows.h>
#elif defined(FEATA_SYSTEM_UNIX)
#include <dlfcn.h>
#endif
namespace util
{
SharedLib::SharedLib(const String& file_name,
const bool local_search)
{
Load(file_name, local_search);
}
SharedLib::~SharedLib()
{
Free();
}
SharedLib::SharedLib(SharedLib&& lib)
{
handle_ = lib.handle_;
lib.handle_ = nullptr;
}
SharedLib& SharedLib::operator=(SharedLib&& lib)
{
handle_ = lib.handle_;
lib.handle_ = nullptr;
return *this;
}
bool SharedLib::Load(const String& file_name, const bool local_search)
{
if(local_search && !util::filesys::IsFileExists(file_name))
return false;
if(IsOpen())
Free();
#if defined(FEATA_SYSTEM_WIN)
const auto ws { file_name.toStdWString() };
handle_ = LoadLibraryW(ws.c_str());
#elif defined(FEATA_SYSTEM_UNIX)
const auto str { file_name.toStdString() };
handle_ = dlopen(str.c_str(), RTLD_LAZY);
#endif
return IsOpen();
}
void SharedLib::Free()
{
if(!IsOpen())
return;
#if defined(FEATA_SYSTEM_WIN)
FreeLibrary(static_cast<HMODULE>(handle_));
#elif defined(FEATA_SYSTEM_UNIX)
dlclose(handle_);
#endif
handle_ = nullptr;
}
void* SharedLib::FindSymbol(const String& name)
{
if(!IsOpen())
return nullptr;
const auto str { name.toStdString() };
#if defined(FEATA_SYSTEM_WIN)
return (void*)GetProcAddress(static_cast<HMODULE>(handle_), str.c_str());
#elif defined(FEATA_SYSTEM_UNIX)
return dlsym(handle_, str.c_str());
#endif
}
bool SharedLib::IsOpen() const { return handle_ != nullptr; }
shlib_t SharedLib::GetHandle() const { return handle_; }
}
| 23.146067 | 82 | 0.581553 | master-clown |
e991b46d1a4e8d9dd727ad89a3fc06d1a7d53e0f | 544 | cpp | C++ | BOJ19941/BOJ19941_src.cpp | wjoh0315/BOJSolutions4 | 1a5910f6dda33c58fdcb806ed0a2806a4f5d764a | [
"MIT"
] | null | null | null | BOJ19941/BOJ19941_src.cpp | wjoh0315/BOJSolutions4 | 1a5910f6dda33c58fdcb806ed0a2806a4f5d764a | [
"MIT"
] | null | null | null | BOJ19941/BOJ19941_src.cpp | wjoh0315/BOJSolutions4 | 1a5910f6dda33c58fdcb806ed0a2806a4f5d764a | [
"MIT"
] | null | null | null | //https://www.acmicpc.net/problem/19941
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k;
cin >> n >> k;
string pos;
cin >> pos;
int j = 0;
int cnt = 0;
for (int i=0; i < n; i++)
{
if (pos[i] == 'H') continue;
for (j=max(j, i-k); j < min(n, i+k+1); j++)
{
if (pos[j] == 'P') continue;
j++;
cnt++;
break;
}
}
cout << cnt << '\n';
return 0;
} | 17.548387 | 51 | 0.420956 | wjoh0315 |
e99231162c2d584303967d08d9698450e8de3fda | 11,923 | cpp | C++ | dao/reservadao.cpp | stsewd/polideportivo | 420da8135b4529115fb5f5acae901c0b6cbca3f7 | [
"MIT"
] | null | null | null | dao/reservadao.cpp | stsewd/polideportivo | 420da8135b4529115fb5f5acae901c0b6cbca3f7 | [
"MIT"
] | null | null | null | dao/reservadao.cpp | stsewd/polideportivo | 420da8135b4529115fb5f5acae901c0b6cbca3f7 | [
"MIT"
] | null | null | null | #include "reservadao.h"
reservadao::reservadao()
{
dataBase = new ConexionDB("localhost:3306","root","1234","Polideportivo");
//espacioComplementariodao = new EspacioComplementarioDAO();
//espacioDeportivodao = new EspacioComplementarioDAO();
//clientedao = new ClienteDAO();
}
Reserva reservadao::add(Reserva reserva)
{
try{
dataBase->resultset = dataBase->statement->executeQuery("SELECT * FROM Reserva WHERE ('" + getFecha(&(reserva.fechaReservacion)) +
"' <= fechaReservacion AND fechaReservacion <= '"+getFecha(&(reserva.fechaFinReservacion))+"')");
if(!dataBase->resultset->next()){
throw std::string("Ya existe una reservacion entre esas fechas, consultes en la tabla de reservas");
}
dataBase->statement->execute("INSERT INTO Reserva values('" + reserva.cliente->cedula + "', '" +
reserva.espacio->nombre + "', ' " + getFecha(&(reserva.fechaReservacion)) +"', '"+
getFecha(&(reserva.fechaReserva))+ "', ' " + getFecha(&(reserva.fechaFinReservacion))+")");
}catch(...){
throw std::string("No se puede agregar la reserva");
}
}
Reserva reservadao::mod(Reserva reserva)
{
}
void reservadao::del(std::string cedula, std::string nombreEspacio, time_t fechaReservacion, time_t fechafinReservacion)
{
try{
dataBase->statement->execute("DELETE FROM Reserva where idCliente='" + cedula +"' and idEspacio='"+
nombreEspacio + "' and fechaReservacion='" + getFecha(&(fechaReservacion)) +
"' and fechafinReservacion='"+getFecha(&(fechafinReservacion))+"')");
}catch(...){
throw std::string("No se pudo eliminar");
}
}
std::vector<Reserva> reservadao::get(std::string cedulaCliente)
{
//sacar la reserva
//sacar el cliente
//sacar el espacio
//llenar el objeto reserva
//incluir a un vector de reservas
Reserva reserva;
Espacio espacio;
std::vector<Reserva> reservas;
try{
ClienteDAO clienteDAO;
dataBase->resultset=dataBase->statement->executeQuery("SELECT * FROM Polideportivo.Reserva where idCliente='" + cedulaCliente+ "'");
while(dataBase->resultset->next()){
Cliente cliente = clientedao.get(dataBase->resultset->getString(1));
try{
EspacioDeportivo espacioDeportivo = espacioDeportivodao.get(dataBase->resultset->getString(2));
espacio = static_cast<Espacio> (espacioDeportivo);
}catch(...){
try{
EspacioComplementario espacioComplementario = espacioComplementariodao.get(dataBase->resultset->getString(2));
espacio = static_cast<Espacio> (espacioComplementario);
}catch(...){
throw std::string("No existe el espacio");
}
}
reserva.cliente = &cliente;
reserva.espacio = &espacio;
reserva.fechaReservacion = getFechaString(dataBase->resultset->getString(3));
reserva.fechaReserva = getFechaString(dataBase->resultset->getString(4));
reserva.fechaFinReservacion = getFechaString(dataBase->resultset->getString(5));
reservas.push_back(reserva);
}
}catch(...){
throw std::string("No se encuentra");
}
return reservas;
}
std::vector<Reserva> reservadao::get(time_t fecha)
{
ClienteDAO clienteDAO;
Reserva reserva;
Espacio espacio;
std::vector<Reserva> reservas;
time_t aux = fecha+3600*24;
try{
dataBase->resultset=dataBase->statement->executeQuery("SELECT * FROM Reserva WHERE ('" + getFecha(&fecha) +
"' <= fechaReservacion AND fechaReservacion <= '"+getFecha(&aux)+"')");
while(dataBase->resultset->next()){
Cliente cliente = clientedao.get(dataBase->resultset->getString(1)); //cliente puede salir de aca y ponerse una linea mas arriba
try{
EspacioDeportivo espacioDeportivo = espacioDeportivodao.get(dataBase->resultset->getString(2));
espacio = static_cast<Espacio> (espacioDeportivo);
}catch(...){
try{
EspacioComplementario espacioComplementario = espacioComplementariodao.get(dataBase->resultset->getString(2));
espacio = static_cast<Espacio> (espacioComplementario);
}catch(...){
throw std::string("No existe el espacio");
}
}
reserva.cliente = &cliente;
reserva.espacio = &espacio;
reserva.fechaReservacion = getFechaString(dataBase->resultset->getString(3));
reserva.fechaReserva = getFechaString(dataBase->resultset->getString(4));
reserva.fechaFinReservacion = getFechaString(dataBase->resultset->getString(5));
reservas.push_back(reserva);
}
}catch(...){
throw std::string("No se encuentra");
}
return reservas;
}
std::vector<Reserva> reservadao::get(std::string cedulaCliente, time_t fecha)
{
ClienteDAO clienteDAO;
Reserva reserva;
Espacio espacio;
std::vector<Reserva> reservas;
time_t aux = fecha+3600*24;
try{
dataBase->resultset=dataBase->statement->executeQuery("SELECT * FROM Reserva WHERE ('" + getFecha(&fecha) +
"' <= fechaReservacion AND fechaReservacion <= '"+getFecha(&aux)+"') and idCliente='"+cedulaCliente+"'");
while(dataBase->resultset->next()){
Cliente cliente = clientedao.get(dataBase->resultset->getString(1)); //cliente puede salir de aca y ponerse una linea mas arriba
try{
EspacioDeportivo espacioDeportivo = espacioDeportivodao.get(dataBase->resultset->getString(2));
espacio = static_cast<Espacio> (espacioDeportivo);
}catch(...){
try{
EspacioComplementario espacioComplementario = espacioComplementariodao.get(dataBase->resultset->getString(2));
espacio = static_cast<Espacio> (espacioComplementario);
}catch(...){
throw std::string("No existe el espacio");
}
}
reserva.cliente = &cliente;
reserva.espacio = &espacio;
reserva.fechaReservacion = getFechaString(dataBase->resultset->getString(3));
reserva.fechaReserva = getFechaString(dataBase->resultset->getString(4));
reserva.fechaFinReservacion = getFechaString(dataBase->resultset->getString(5));
reservas.push_back(reserva);
}
}catch(...){
throw std::string("No se encuentra");
}
return reservas;
}
std::vector<Reserva> reservadao::get(time_t fechaInicial, time_t fechaFinal)
{
ClienteDAO clienteDAO;
Reserva reserva;
Espacio espacio;
std::vector<Reserva> reservas;
try{
dataBase->resultset=dataBase->statement->executeQuery("SELECT * FROM Reserva WHERE ('" + getFecha(&fechaInicial) +
"' <= fechaReservacion AND fechaReservacion <= '"+getFecha(&fechaFinal)+"')");
while(dataBase->resultset->next()){
Cliente cliente = clientedao.get(dataBase->resultset->getString(1)); //cliente puede salir de aca y ponerse una linea mas arriba
try{
EspacioDeportivo espacioDeportivo = espacioDeportivodao.get(dataBase->resultset->getString(2));
espacio = static_cast<Espacio> (espacioDeportivo);
}catch(...){
try{
EspacioComplementario espacioComplementario = espacioComplementariodao.get(dataBase->resultset->getString(2));
espacio = static_cast<Espacio> (espacioComplementario);
}catch(...){
throw std::string("No existe el espacio");
}
}
reserva.cliente = &cliente;
reserva.espacio = &espacio;
reserva.fechaReservacion = getFechaString(dataBase->resultset->getString(3));
reserva.fechaReserva = getFechaString(dataBase->resultset->getString(3));
reserva.fechaFinReservacion = getFechaString(dataBase->resultset->getString(5));
reservas.push_back(reserva);
reservas.push_back(reserva);
}
}catch(...){
throw std::string("No se encuentra");
}
return reservas;
}
std::vector<Reserva> reservadao::get(std::string cedulaCliente, time_t fechaInicial, time_t fechaFinal)
{
ClienteDAO clienteDAO;
Reserva reserva;
Espacio espacio;
std::vector<Reserva> reservas;
try{
dataBase->resultset=dataBase->statement->executeQuery("SELECT * FROM Reserva WHERE ('" + getFecha(&fechaInicial) +
"' <= fechaReservacion AND fechaReservacion <= '"+getFecha(&fechaFinal)+"') and idCliente='"+cedulaCliente+"'");
while(dataBase->resultset->next()){
Cliente cliente = clientedao.get(dataBase->resultset->getString(1)); //cliente puede salir de aca y ponerse una linea mas arriba
try{
EspacioDeportivo espacioDeportivo = espacioDeportivodao.get(dataBase->resultset->getString(2));
espacio = static_cast<Espacio> (espacioDeportivo);
}catch(...){
try{
EspacioComplementario espacioComplementario = espacioComplementariodao.get(dataBase->resultset->getString(2));
espacio = static_cast<Espacio> (espacioComplementario);
}catch(...){
throw std::string("No existe el espacio");
}
}
reserva.cliente = &cliente;
reserva.espacio = &espacio;
reserva.fechaReservacion = getFechaString(dataBase->resultset->getString(3));
reserva.fechaReserva = getFechaString(dataBase->resultset->getString(4));
reserva.fechaFinReservacion = getFechaString(dataBase->resultset->getString(5));
reservas.push_back(reserva);
}
}catch(...){
throw std::string("No se encuentra");
}
return reservas;
}
std::vector<Reserva> reservadao::get()
{
ClienteDAO clienteDAO;
Reserva reserva;
Espacio espacio;
std::vector<Reserva> reservas;
try{
dataBase->resultset=dataBase->statement->executeQuery("SELECT * FROM Reserva ");
while(dataBase->resultset->next()){
Cliente cliente = clientedao.get(dataBase->resultset->getString(1)); //cliente puede salir de aca y ponerse una linea mas arriba
try{
EspacioDeportivo espacioDeportivo = espacioDeportivodao.get(dataBase->resultset->getString(2));
espacio = static_cast<Espacio> (espacioDeportivo);
}catch(...){
try{
EspacioComplementario espacioComplementario = espacioComplementariodao.get(dataBase->resultset->getString(2));
espacio = static_cast<Espacio> (espacioComplementario);
}catch(...){
throw std::string("No existe el espacio");
}
}
reserva.cliente = &cliente;
reserva.espacio = &espacio;
reserva.fechaReservacion = getFechaString(dataBase->resultset->getString(3));
reserva.fechaReserva = getFechaString(dataBase->resultset->getString(4));
reserva.fechaFinReservacion = getFechaString(dataBase->resultset->getString(5));
reservas.push_back(reserva);
}
}catch(...){
throw std::string("No se encuentra");
}
return reservas;
}
| 45.507634 | 174 | 0.60203 | stsewd |
e993ca58efd042faa8667ada9364d12b35a1e14b | 17,027 | cpp | C++ | Ambit/Source/Ambit/Actors/Spawners/SpawnerBase.cpp | brhook-aws/aws-ambit-scenario-designer-ue4 | 4f1fea7d4ac27a4fad792607a1d6dbf2aa237747 | [
"Apache-2.0"
] | null | null | null | Ambit/Source/Ambit/Actors/Spawners/SpawnerBase.cpp | brhook-aws/aws-ambit-scenario-designer-ue4 | 4f1fea7d4ac27a4fad792607a1d6dbf2aa237747 | [
"Apache-2.0"
] | null | null | null | Ambit/Source/Ambit/Actors/Spawners/SpawnerBase.cpp | brhook-aws/aws-ambit-scenario-designer-ue4 | 4f1fea7d4ac27a4fad792607a1d6dbf2aa237747 | [
"Apache-2.0"
] | null | null | null | // Copyright Amazon.com, Inc. or its affiliates. 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 "SpawnerBase.h"
#include "EngineUtils.h"
#include "Components/BillboardComponent.h"
#include "Kismet/GameplayStatics.h"
#include "Kismet/KismetMathLibrary.h"
#include "Ambit/AmbitModule.h"
#include "Ambit/Actors/SpawnedObjectConfigs/SpawnedObjectConfig.h"
#include "Ambit/Mode/Constant.h"
#include "Ambit/Utils/AmbitSpawnerCollisionHelpers.h"
#include "Ambit/Utils/UserMetricsSubsystem.h"
#include "AmbitUtils/JsonHelpers.h"
#include <AmbitUtils/MenuHelpers.h>
// Sets default values
ASpawnerBase::ASpawnerBase()
{
IconComponent = CreateDefaultSubobject<UBillboardComponent>("Icon");
}
void ASpawnerBase::GenerateSpawnedObjectConfiguration()
{
GenerateSpawnedObjectConfiguration(RandomSeed);
}
void ASpawnerBase::GenerateSpawnedObjectConfiguration(int32 Seed)
{
USpawnedObjectConfig* Config = NewObject<USpawnedObjectConfig>();
const int32 OriginalSeed = RandomSeed;
RandomSeed = Seed;
Config->SpawnedObjects = GenerateActors();
DestroyGeneratedActors();
RandomSeed = OriginalSeed;
auto FinalConfig = TScriptInterface<IConfigJsonSerializer>(Config);
OnSpawnedObjectConfigCompleted.ExecuteIfBound(FinalConfig, true);
}
template <typename Struct>
TSharedPtr<Struct> ASpawnerBase::GetConfiguration() const
{
TSharedPtr<Struct> Config = MakeShareable(new Struct);
Config->SpawnerLocation = this->GetActorLocation();
Config->SpawnerRotation = this->GetActorRotation();
Config->MatchBy = MatchBy;
Config->SurfaceNamePattern = SurfaceNamePattern;
Config->SurfaceTags = SurfaceTags;
Config->DensityMin = DensityMin;
Config->DensityMax = DensityMax;
Config->RotationMin = RotationMin;
Config->RotationMax = RotationMax;
Config->bAddPhysics = bAddPhysics;
TArray<TSubclassOf<AActor>> ActorsToSpawnClean;
for (const auto& Actor : ActorsToSpawn)
{
ActorsToSpawnClean.AddUnique(Actor);
}
Config->ActorsToSpawn = ActorsToSpawnClean;
Config->bRemoveOverlaps = bRemoveOverlaps;
Config->RandomSeed = RandomSeed;
return Config;
}
template <typename Struct>
void ASpawnerBase::Configure(const TSharedPtr<Struct>& Config)
{
MatchBy = Config->MatchBy;
SurfaceNamePattern = Config->SurfaceNamePattern;
SurfaceTags = Config->SurfaceTags;
DensityMin = Config->DensityMin;
DensityMax = Config->DensityMax;
RotationMin = Config->RotationMin;
RotationMax = Config->RotationMax;
bAddPhysics = Config->bAddPhysics;
ActorsToSpawn = Config->ActorsToSpawn;
bRemoveOverlaps = Config->bRemoveOverlaps;
RandomSeed = Config->RandomSeed;
}
// Called when the game starts or when spawned
void ASpawnerBase::BeginPlay()
{
Super::BeginPlay();
GenerateActors();
const TSharedRef<FJsonObject> MetricContextData = MakeShareable(new FJsonObject);
MetricContextData->SetNumberField(UserMetrics::AmbitSpawner::KAmbitSpawnerSpawnNumberContextData,
SpawnedActors.Num());
GEngine->GetEngineSubsystem<UUserMetricsSubsystem>()->Track(UserMetrics::AmbitSpawner::KAmbitSpawnerRunEvent,
UserMetrics::AmbitSpawner::KAmbitSpawnerNameSpace,
MetricContextData);
}
void ASpawnerBase::PostActorCreated()
{
//Currently there is a bug that this function could be called twice in UE engine
if (!HasAllFlags(RF_Transient))
{
GEngine->GetEngineSubsystem<UUserMetricsSubsystem>()->Track(UserMetrics::AmbitSpawner::KAmbitSpawnerPlacedEvent,
UserMetrics::AmbitSpawner::KAmbitSpawnerNameSpace);
}
}
void ASpawnerBase::DestroyGeneratedActors()
{
// Remove previously created actors.
for (AActor* Actor : SpawnedActors)
{
// This class does not explicitly retain strong references to the actors in the
// SpawnedActors array. Therefore, we must check for null pointers to
// accommodate cases where the actor no longer exists.
if (IsValid(Actor))
{
Actor->Destroy();
}
}
SpawnedActors.Empty();
}
bool ASpawnerBase::HasActorsToSpawn() const
{
return ActorsToSpawn.Num() > 0 && !ActorsToSpawn.Contains(nullptr);
}
void ASpawnerBase::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
PostEditErrorFixes();
}
bool ASpawnerBase::AreParametersValid() const
{
if (ActorsToSpawn.Num() > 0)
{
for (const auto& Actor : ActorsToSpawn)
{
if (!IsValid(Actor))
{
const FString& Message = FString::Printf(
TEXT("An actor to spawn in the array of %s is not specified, which is not allowed."),
*this->GetActorLabel());
FMenuHelpers::DisplayMessagePopup(Message, "Warning");
return false;
}
}
}
else
{
const FString& Message = FString::Printf(
TEXT("The array ActorsToSpawn of %s is not specified, which is not allowed."), *this->GetActorLabel());
FMenuHelpers::DisplayMessagePopup(Message, "Warning");
return false;
}
return AreMinMaxValid();
}
bool ASpawnerBase::AreMinMaxValid() const
{
if (RotationMin > RotationMax)
{
const FString& Message = FString::Printf(
TEXT(
"The minimum degree of rotation is greater than the maximum degree of rotation in %s, which is not allowed."),
*this->GetActorLabel());
FMenuHelpers::DisplayMessagePopup(Message, "Warning");
return false;
}
if (DensityMin > DensityMax)
{
const FString& Message = FString::Printf(
TEXT("The minimum density is greater than the maximum density in %s, which is not allowed."),
*this->GetActorLabel());
FMenuHelpers::DisplayMessagePopup(Message, "Warning");
return false;
}
return true;
}
void ASpawnerBase::PostEditErrorFixes()
{
if (bRestrictToOneRotation && RotationMax != RotationMin)
{
RotationMax = RotationMin;
}
const float DensityWarningLimit = 3.f;
const float PracticalMax = FMath::Max(DensityMin, DensityMax);
if (PracticalMax > DensityWarningLimit)
{
// TODO: This text should eventually support localization.
const FString& Message = FString::Printf(
TEXT(
"You've set a maximum density of %s items per square meter in %s, which is pretty high. Be aware that high density values may cause performance problems when you run your simulation."),
*FString::SanitizeFloat(PracticalMax), *this->GetActorLabel());
FMenuHelpers::DisplayMessagePopup(Message, "Warning");
}
}
void ASpawnerBase::CleanAndSetUpActorsToSpawn(TArray<TSubclassOf<AActor>>& OutArray,
TMap<FString, TArray<FCollisionResponseTemplate>>& OutMap)
{
OutMap.Empty();
OutArray.Empty();
for (const TSubclassOf<AActor>& Actor : ActorsToSpawn)
{
const int32 LastIndex = OutArray.Num() - 1;
// AddUnique returns the Index of the provided Actor
// if it already exists in the array; if not,
// AddUnique adds Actor to the end of the array;
// this checks if the actor already existed, and if so,
// notifies the user that a duplicate was found in the array
if (OutArray.AddUnique(Actor) <= LastIndex)
{
UE_LOG(LogAmbit, Warning, TEXT("%s: Duplicate of %s found in ActorsToSpawn. Ignoring..."),
*this->GetActorLabel(), *Actor->GetName());
}
else
{
TArray<UStaticMeshComponent*> StaticMeshComponents;
AmbitSpawnerCollisionHelpers::FindDefaultStaticMeshComponents(Actor.Get(), StaticMeshComponents);
AmbitSpawnerCollisionHelpers::StoreCollisionProfiles(Actor->GetPathName(), StaticMeshComponents, OutMap);
AmbitSpawnerCollisionHelpers::SetCollisionForAllStaticMeshComponents(StaticMeshComponents, bRemoveOverlaps);
}
}
}
void ASpawnerBase::SpawnActorsAtTransforms(const TArray<FTransform>& Transforms,
TMap<FString, TArray<FTransform>>& OutMap)
{
OutMap.Empty();
Random.Initialize(RandomSeed);
UWorld* World = GetWorld();
TArray<AActor*> AllActors;
UGameplayStatics::GetAllActorsOfClass(World, AActor::StaticClass(), AllActors);
TMap<FString, TArray<bool>> OriginalGenerateOverlapEventsMap;
for (AActor* Actor : AllActors)
{
TArray<bool> OriginalGenerateOverlapEvents;
// Set GenerateOverlapEvents to true while Play mode is active
AmbitSpawnerCollisionHelpers::SetGenerateOverlapEventsForActor(Actor, OriginalGenerateOverlapEvents);
// Store original overlap event settings
OriginalGenerateOverlapEventsMap.Add(Actor->GetName(), OriginalGenerateOverlapEvents);
}
// Remove duplicates from array and set up collision profiles for ActorsToSpawn
TArray<TSubclassOf<AActor>> ActorsToSpawnClean;
TMap<FString, TArray<FCollisionResponseTemplate>> OriginalCollisionProfiles;
CleanAndSetUpActorsToSpawn(ActorsToSpawnClean, OriginalCollisionProfiles);
for (const FTransform& Transform : Transforms)
{
FVector SpawnedActorLocation = Transform.GetLocation();
const FRotator& SpawnedActorRotation = Transform.Rotator();
int32 RandomIndex = 0;
if (ActorsToSpawnClean.Num() > 1)
{
RandomIndex = Random.RandRange(0, ActorsToSpawnClean.Num() - 1);
}
// ActorsToSpawnClean will always have at least one element;
// it contains all elements of a non-empty ActorsToSpawn (with duplicates removed)
TSubclassOf<AActor> ChosenActor = ActorsToSpawnClean[RandomIndex];
FActorSpawnParameters ActorSpawnParams;
ActorSpawnParams.SpawnCollisionHandlingOverride =
ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButDontSpawnIfColliding;
// Try to spawn actor at location
// will do nothing if it would overlap with any other spawned actor
AActor* SpawnedActor = World->SpawnActor(ChosenActor.Get(), &SpawnedActorLocation, &SpawnedActorRotation,
ActorSpawnParams);
// Try to spawn actor again at offset
// if bAddPhysics is true and first spawn attempt failed
// in order to potentially "stack"
// TODO: If Add Physics is turned on, should AmbitSpawners spawn obstacles one at a time?
// TODO: Unreal Engine does not necessarily have a set order in which Actors are processed,
// so this may be non-deterministic
if (!IsValid(SpawnedActor) && bAddPhysics)
{
FVector LocationOffset(0, 0, 100);
SpawnedActorLocation = SpawnedActorLocation + LocationOffset;
SpawnedActor = World->SpawnActor(ChosenActor.Get(), &SpawnedActorLocation, &SpawnedActorRotation,
ActorSpawnParams);
}
if (IsValid(SpawnedActor))
{
UStaticMeshComponent* PhysicsComponent = SpawnedActor->FindComponentByClass<UStaticMeshComponent>();
if (bAddPhysics)
{
// Set mobility
PhysicsComponent->SetMobility(EComponentMobility::Movable);
// If actor could not be spawned at surface level,
// we want to sweep it to the surface and check for collision along the way
// before enabling SimulatePhysics
if (SpawnedActor->GetActorLocation() != Transform.GetLocation())
{
PhysicsComponent->SetWorldLocation(Transform.GetLocation(), true, nullptr,
ETeleportType::ResetPhysics);
}
}
// Check for any overlaps and verify that overlaps are not beyond the surface
// of the overlapping actor
TArray<UPrimitiveComponent*> OverlappingComponents;
SpawnedActor->GetOverlappingComponents(OverlappingComponents);
for (UPrimitiveComponent* OverlappingComponent : OverlappingComponents)
{
if (AmbitSpawnerCollisionHelpers::IsPenetratingOverlap(OverlappingComponent, SpawnedActor))
{
SpawnedActor->Destroy();
break;
}
}
// Makes sure that SpawnedActor did not have any overlaps
// and was not destroyed
if (IsValid(SpawnedActor))
{
// Set the collision profile(s) of this ActorToSpawn instance
// to the original collision profile(s) of the class default object
TArray<UStaticMeshComponent*> StaticMeshComponents;
SpawnedActor->GetComponents<UStaticMeshComponent>(StaticMeshComponents);
const FString& PathName = ChosenActor.Get()->GetPathName();
const TArray<FCollisionResponseTemplate> OriginalResponses = OriginalCollisionProfiles.FindChecked(
PathName);
for (int i = 0; i < StaticMeshComponents.Num(); i++)
{
UStaticMeshComponent* StaticMeshComponent = StaticMeshComponents[i];
FCollisionResponseTemplate Response = OriginalResponses[i];
// Restores the collision profile of this specific actor
// to match expected collision behavior of the asset
// Maintains ObjectType as "AmbitSpawnerObstacle"
// to ensure no overlaps occur with future spawned objects
StaticMeshComponent->SetCollisionResponseToChannels(Response.ResponseToChannels);
StaticMeshComponent->SetCollisionEnabled(Response.CollisionEnabled);
// Maintains that "Overlappable" Obstacles
// are continued to be recognized as such
// This is set to Overlap to ensure that
// actors (not spawned by AmbitSpawners)
// will respond to the spawned obstacle correctly
// if it is supposed to generate overlap events.
// The AmbitSpawner Overlap detection/destruction
// will ignore AMBIT_SPAWNER_OVERLAP typed objects.
StaticMeshComponent->SetCollisionResponseToChannel(ECC_GameTraceChannel2, // AMBIT_SPAWNED_OVERLAP
ECR_Overlap);
}
// Turn on Simulate Physics if bAddPhysics is true
if (bAddPhysics && !PhysicsComponent->IsSimulatingPhysics())
{
PhysicsComponent->SetSimulatePhysics(true);
}
// Add FTransform to map for SDF export
SpawnedActors.Push(SpawnedActor);
TArray<FTransform> PathNameTransforms;
if (bAddPhysics)
{
PathNameTransforms.Add(PhysicsComponent->GetComponentTransform());
}
else
{
PathNameTransforms.Add(SpawnedActor->GetActorTransform());
}
// Update map array value to include new transform
if (OutMap.Find(PathName) != nullptr)
{
PathNameTransforms.Append(OutMap.FindAndRemoveChecked(PathName));
}
OutMap.Add(PathName, PathNameTransforms);
}
}
}
// Restore CDO collision profiles to original
AmbitSpawnerCollisionHelpers::ResetCollisionProfiles(OriginalCollisionProfiles, ActorsToSpawnClean);
for (const auto& Actor : AllActors)
{
TArray<bool> OriginalGenerateOverlapEvents = OriginalGenerateOverlapEventsMap.FindChecked(Actor->GetName());
// Reset GenerateOverlapEvents
AmbitSpawnerCollisionHelpers::SetGenerateOverlapEventsForActor(Actor, OriginalGenerateOverlapEvents, true);
}
}
| 41.32767 | 201 | 0.646914 | brhook-aws |
e996ad96f208f01c2890faf6e7faf6925d2b8fa2 | 1,351 | cpp | C++ | cpp/src/test.cpp | cnloni/othello | f80f190e505b6a4dd2b2bd49054651dbea4f00fa | [
"Apache-2.0"
] | 1 | 2021-01-16T03:34:06.000Z | 2021-01-16T03:34:06.000Z | cpp/src/test.cpp | cnloni/othello | f80f190e505b6a4dd2b2bd49054651dbea4f00fa | [
"Apache-2.0"
] | null | null | null | cpp/src/test.cpp | cnloni/othello | f80f190e505b6a4dd2b2bd49054651dbea4f00fa | [
"Apache-2.0"
] | null | null | null | #include <iostream>
#include "b16.hpp"
#include "b36.hpp"
#include "board.hpp"
using namespace std;
int execute16(uint64_t bp, uint64_t wp, int turn, int alpha, int beta) {
Board<B16> board;
int result = board.getBestResult(bp, wp, turn, alpha, beta);
cout << board.getFinalBoardString() << endl;
cout << "Initial = " << board.getInitialNodeString() << endl;
cout << "Final = " << board.getFinalNodeString() << endl;
cout << "Result = " << result << endl;
cout << "Moves = " << board.getMoveListString() << endl;
cout << "Count = " << board.getNodeCount() << endl;
cout << "Elapsed = " << board.getElapsedTime() << endl;
return 0;
}
int execute36(uint64_t bp, uint64_t wp, int turn, int alpha, int beta) {
Board<B36> board;
int result = board.getBestResult(bp, wp, turn, alpha, beta);
cout << board.getFinalBoardString() << endl;
cout << "Initial = " << board.getInitialNodeString() << endl;
cout << "Final = " << board.getFinalNodeString() << endl;
cout << "Result = " << result << endl;
cout << "Moves = " << board.getMoveListString() << endl;
cout << "Count = " << board.getNodeCount() << endl;
cout << "Elapsed = " << board.getElapsedTime() << endl;
return 0;
}
int main() {
execute16(B16::INITIAL_BP, B16::INITIAL_WP, 0, -(B16::CELLS+1), B16::CELLS+1);
//14駒から
execute36(551158016, 69329408, 0, -6, -2);
return 0;
}
| 32.166667 | 79 | 0.640266 | cnloni |
e9a15c19c744761de516e90c7b1462b5aaa9fea7 | 6,116 | cpp | C++ | emulator/src/devices/bus/a2bus/a2applicard.cpp | rjw57/tiw-computer | 5ef1c79893165b8622d1114d81cd0cded58910f0 | [
"MIT"
] | 1 | 2022-01-15T21:38:38.000Z | 2022-01-15T21:38:38.000Z | emulator/src/devices/bus/a2bus/a2applicard.cpp | rjw57/tiw-computer | 5ef1c79893165b8622d1114d81cd0cded58910f0 | [
"MIT"
] | null | null | null | emulator/src/devices/bus/a2bus/a2applicard.cpp | rjw57/tiw-computer | 5ef1c79893165b8622d1114d81cd0cded58910f0 | [
"MIT"
] | null | null | null | // license:BSD-3-Clause
// copyright-holders:R. Belmont
/*********************************************************************
a2applicard.c
Implementation of the PCPI AppliCard Z-80 card
Unlike the SoftCard and clones, this has its own 64k of RAM on board
and the Z80 runs completely independently of the host's 6502.
*********************************************************************/
#include "emu.h"
#include "a2applicard.h"
#include "cpu/z80/z80.h"
#include "machine/z80ctc.h"
/***************************************************************************
PARAMETERS
***************************************************************************/
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
DEFINE_DEVICE_TYPE(A2BUS_APPLICARD, a2bus_applicard_device, "a2aplcrd", "PCPI Applicard")
#define Z80_TAG "z80"
#define Z80_ROM_REGION "z80_rom"
void a2bus_applicard_device::z80_mem(address_map &map)
{
map(0x0000, 0xffff).rw(this, FUNC(a2bus_applicard_device::dma_r), FUNC(a2bus_applicard_device::dma_w));
}
void a2bus_applicard_device::z80_io(address_map &map)
{
map(0x00, 0x60).mirror(0xff00).rw(this, FUNC(a2bus_applicard_device::z80_io_r), FUNC(a2bus_applicard_device::z80_io_w));
}
ROM_START( a2applicard )
ROM_REGION(0x800, Z80_ROM_REGION, 0)
ROM_LOAD( "applicard-v9.bin", 0x000000, 0x000800, CRC(1d461000) SHA1(71d633be864b6084362e85108a4e600cbe6e44fe) )
ROM_END
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
MACHINE_CONFIG_START(a2bus_applicard_device::device_add_mconfig)
MCFG_CPU_ADD(Z80_TAG, Z80, 6000000) // Z80 runs at 6 MHz
MCFG_CPU_PROGRAM_MAP(z80_mem)
MCFG_CPU_IO_MAP(z80_io)
MACHINE_CONFIG_END
//-------------------------------------------------
// device_rom_region - device-specific ROMs
//-------------------------------------------------
const tiny_rom_entry *a2bus_applicard_device::device_rom_region() const
{
return ROM_NAME( a2applicard );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
a2bus_applicard_device::a2bus_applicard_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, type, tag, owner, clock),
device_a2bus_card_interface(mconfig, *this),
m_z80(*this, Z80_TAG), m_bROMAtZ80Zero(false), m_z80stat(false), m_6502stat(false), m_toz80(0), m_to6502(0), m_z80rom(nullptr)
{
}
a2bus_applicard_device::a2bus_applicard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
a2bus_applicard_device(mconfig, A2BUS_APPLICARD, tag, owner, clock)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void a2bus_applicard_device::device_start()
{
// locate Z80 ROM
m_z80rom = device().machine().root_device().memregion(this->subtag(Z80_ROM_REGION).c_str())->base();
save_item(NAME(m_bROMAtZ80Zero));
save_item(NAME(m_z80stat));
save_item(NAME(m_6502stat));
save_item(NAME(m_toz80));
save_item(NAME(m_to6502));
save_item(NAME(m_z80ram));
memset(m_z80ram, 0, 64*1024);
}
void a2bus_applicard_device::device_reset()
{
m_bROMAtZ80Zero = true;
m_z80stat = false;
}
uint8_t a2bus_applicard_device::read_c0nx(uint8_t offset)
{
switch (offset & 0xf)
{
case 0:
m_6502stat = false;
return m_to6502;
case 1:
return m_toz80;
case 2:
if (m_z80stat)
{
return 0x80;
}
return false;
case 3:
if (m_6502stat)
{
return 0x80;
}
return false;
case 5:
m_bROMAtZ80Zero = true;
m_toz80 = false;
m_to6502 = false;
m_z80->reset();
break;
case 6: // IRQ on Z80 via CTC channel 3 (CP/M doesn't use the CTC or IRQs)
fatalerror("Applicard: Z80 IRQ not supported yet\n");
case 7: // NMI on Z80 (direct)
m_z80->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
break;
}
return 0xff;
}
void a2bus_applicard_device::write_c0nx(uint8_t offset, uint8_t data)
{
switch (offset & 0xf)
{
case 0: // are these legal to write?
case 2:
case 3:
break;
case 1:
m_z80stat = true;
m_toz80 = data;
break;
case 5:
case 6:
case 7:
read_c0nx(offset); // let the read handler take care of these
break;
}
}
READ8_MEMBER( a2bus_applicard_device::z80_io_r )
{
uint8_t tmp = 0;
switch (offset)
{
case 0:
return m_to6502;
case 0x20:
m_z80stat = false;
return m_toz80;
case 0x40:
if (m_z80stat)
{
tmp |= 0x80;
}
if (m_6502stat)
{
tmp |= 1;
}
return tmp;
case 0x60:
break;
}
return 0xff;
}
WRITE8_MEMBER( a2bus_applicard_device::z80_io_w )
{
switch (offset)
{
case 0:
m_to6502 = data;
m_6502stat = true;
break;
case 0x60:
if (data & 1)
{
m_bROMAtZ80Zero = true;
}
else
{
m_bROMAtZ80Zero = false;
}
break;
}
}
//-------------------------------------------------
// dma_r -
//-------------------------------------------------
READ8_MEMBER( a2bus_applicard_device::dma_r )
{
if (offset < 0x8000)
{
if (m_bROMAtZ80Zero)
{
return m_z80rom[offset & 0x7ff];
}
else
{
return m_z80ram[offset];
}
}
else
{
return m_z80ram[offset];
}
// never executed
//return 0xff;
}
//-------------------------------------------------
// dma_w -
//-------------------------------------------------
WRITE8_MEMBER( a2bus_applicard_device::dma_w )
{
if (offset < 0x8000)
{
// writing only works if ROM not mapped from 0-7fff
if (!m_bROMAtZ80Zero)
{
m_z80ram[offset] = data;
}
}
else
{
m_z80ram[offset] = data;
}
}
bool a2bus_applicard_device::take_c800()
{
return false;
}
| 22 | 147 | 0.554284 | rjw57 |
e9a1ff9570260abd9e652b8d41c348b4db46b0a4 | 18,729 | cpp | C++ | test/unittest/regextest.cpp | lktrgl/rapidjson | f09bafdd7e5eac006ea1d926a16a5b941ea71d9a | [
"BSD-3-Clause"
] | null | null | null | test/unittest/regextest.cpp | lktrgl/rapidjson | f09bafdd7e5eac006ea1d926a16a5b941ea71d9a | [
"BSD-3-Clause"
] | null | null | null | test/unittest/regextest.cpp | lktrgl/rapidjson | f09bafdd7e5eac006ea1d926a16a5b941ea71d9a | [
"BSD-3-Clause"
] | null | null | null | // Tencent is pleased to support the open source community by making RapidJSON available.
//
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
//
// Licensed under the MIT License (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// 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 "unittest.h"
#include "rapidjson/internal/regex.h"
using namespace rapidjson::internal;
TEST ( Regex, Single )
{
Regex re ( "a" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "a" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "b" ) );
}
TEST ( Regex, Concatenation )
{
Regex re ( "abc" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "abc" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "a" ) );
EXPECT_FALSE ( rs.Match ( "b" ) );
EXPECT_FALSE ( rs.Match ( "ab" ) );
EXPECT_FALSE ( rs.Match ( "abcd" ) );
}
TEST ( Regex, Alternation1 )
{
Regex re ( "abab|abbb" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "abab" ) );
EXPECT_TRUE ( rs.Match ( "abbb" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "ab" ) );
EXPECT_FALSE ( rs.Match ( "ababa" ) );
EXPECT_FALSE ( rs.Match ( "abb" ) );
EXPECT_FALSE ( rs.Match ( "abbbb" ) );
}
TEST ( Regex, Alternation2 )
{
Regex re ( "a|b|c" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "a" ) );
EXPECT_TRUE ( rs.Match ( "b" ) );
EXPECT_TRUE ( rs.Match ( "c" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "aa" ) );
EXPECT_FALSE ( rs.Match ( "ab" ) );
}
TEST ( Regex, Parenthesis1 )
{
Regex re ( "(ab)c" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "abc" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "a" ) );
EXPECT_FALSE ( rs.Match ( "b" ) );
EXPECT_FALSE ( rs.Match ( "ab" ) );
EXPECT_FALSE ( rs.Match ( "abcd" ) );
}
TEST ( Regex, Parenthesis2 )
{
Regex re ( "a(bc)" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "abc" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "a" ) );
EXPECT_FALSE ( rs.Match ( "b" ) );
EXPECT_FALSE ( rs.Match ( "ab" ) );
EXPECT_FALSE ( rs.Match ( "abcd" ) );
}
TEST ( Regex, Parenthesis3 )
{
Regex re ( "(a|b)(c|d)" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "ac" ) );
EXPECT_TRUE ( rs.Match ( "ad" ) );
EXPECT_TRUE ( rs.Match ( "bc" ) );
EXPECT_TRUE ( rs.Match ( "bd" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "ab" ) );
EXPECT_FALSE ( rs.Match ( "cd" ) );
}
TEST ( Regex, ZeroOrOne1 )
{
Regex re ( "a?" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "" ) );
EXPECT_TRUE ( rs.Match ( "a" ) );
EXPECT_FALSE ( rs.Match ( "aa" ) );
}
TEST ( Regex, ZeroOrOne2 )
{
Regex re ( "a?b" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "b" ) );
EXPECT_TRUE ( rs.Match ( "ab" ) );
EXPECT_FALSE ( rs.Match ( "a" ) );
EXPECT_FALSE ( rs.Match ( "aa" ) );
EXPECT_FALSE ( rs.Match ( "bb" ) );
EXPECT_FALSE ( rs.Match ( "ba" ) );
}
TEST ( Regex, ZeroOrOne3 )
{
Regex re ( "ab?" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "a" ) );
EXPECT_TRUE ( rs.Match ( "ab" ) );
EXPECT_FALSE ( rs.Match ( "b" ) );
EXPECT_FALSE ( rs.Match ( "aa" ) );
EXPECT_FALSE ( rs.Match ( "bb" ) );
EXPECT_FALSE ( rs.Match ( "ba" ) );
}
TEST ( Regex, ZeroOrOne4 )
{
Regex re ( "a?b?" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "" ) );
EXPECT_TRUE ( rs.Match ( "a" ) );
EXPECT_TRUE ( rs.Match ( "b" ) );
EXPECT_TRUE ( rs.Match ( "ab" ) );
EXPECT_FALSE ( rs.Match ( "aa" ) );
EXPECT_FALSE ( rs.Match ( "bb" ) );
EXPECT_FALSE ( rs.Match ( "ba" ) );
EXPECT_FALSE ( rs.Match ( "abc" ) );
}
TEST ( Regex, ZeroOrOne5 )
{
Regex re ( "a(ab)?b" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "ab" ) );
EXPECT_TRUE ( rs.Match ( "aabb" ) );
EXPECT_FALSE ( rs.Match ( "aab" ) );
EXPECT_FALSE ( rs.Match ( "abb" ) );
}
TEST ( Regex, ZeroOrMore1 )
{
Regex re ( "a*" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "" ) );
EXPECT_TRUE ( rs.Match ( "a" ) );
EXPECT_TRUE ( rs.Match ( "aa" ) );
EXPECT_FALSE ( rs.Match ( "b" ) );
EXPECT_FALSE ( rs.Match ( "ab" ) );
}
TEST ( Regex, ZeroOrMore2 )
{
Regex re ( "a*b" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "b" ) );
EXPECT_TRUE ( rs.Match ( "ab" ) );
EXPECT_TRUE ( rs.Match ( "aab" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "bb" ) );
}
TEST ( Regex, ZeroOrMore3 )
{
Regex re ( "a*b*" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "" ) );
EXPECT_TRUE ( rs.Match ( "a" ) );
EXPECT_TRUE ( rs.Match ( "aa" ) );
EXPECT_TRUE ( rs.Match ( "b" ) );
EXPECT_TRUE ( rs.Match ( "bb" ) );
EXPECT_TRUE ( rs.Match ( "ab" ) );
EXPECT_TRUE ( rs.Match ( "aabb" ) );
EXPECT_FALSE ( rs.Match ( "ba" ) );
}
TEST ( Regex, ZeroOrMore4 )
{
Regex re ( "a(ab)*b" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "ab" ) );
EXPECT_TRUE ( rs.Match ( "aabb" ) );
EXPECT_TRUE ( rs.Match ( "aababb" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "aa" ) );
}
TEST ( Regex, OneOrMore1 )
{
Regex re ( "a+" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "a" ) );
EXPECT_TRUE ( rs.Match ( "aa" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "b" ) );
EXPECT_FALSE ( rs.Match ( "ab" ) );
}
TEST ( Regex, OneOrMore2 )
{
Regex re ( "a+b" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "ab" ) );
EXPECT_TRUE ( rs.Match ( "aab" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "b" ) );
}
TEST ( Regex, OneOrMore3 )
{
Regex re ( "a+b+" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "ab" ) );
EXPECT_TRUE ( rs.Match ( "aab" ) );
EXPECT_TRUE ( rs.Match ( "abb" ) );
EXPECT_TRUE ( rs.Match ( "aabb" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "b" ) );
EXPECT_FALSE ( rs.Match ( "ba" ) );
}
TEST ( Regex, OneOrMore4 )
{
Regex re ( "a(ab)+b" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "aabb" ) );
EXPECT_TRUE ( rs.Match ( "aababb" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "ab" ) );
}
TEST ( Regex, QuantifierExact1 )
{
Regex re ( "ab{3}c" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "abbbc" ) );
EXPECT_FALSE ( rs.Match ( "ac" ) );
EXPECT_FALSE ( rs.Match ( "abc" ) );
EXPECT_FALSE ( rs.Match ( "abbc" ) );
EXPECT_FALSE ( rs.Match ( "abbbbc" ) );
}
TEST ( Regex, QuantifierExact2 )
{
Regex re ( "a(bc){3}d" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "abcbcbcd" ) );
EXPECT_FALSE ( rs.Match ( "ad" ) );
EXPECT_FALSE ( rs.Match ( "abcd" ) );
EXPECT_FALSE ( rs.Match ( "abcbcd" ) );
EXPECT_FALSE ( rs.Match ( "abcbcbcbcd" ) );
}
TEST ( Regex, QuantifierExact3 )
{
Regex re ( "a(b|c){3}d" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "abbbd" ) );
EXPECT_TRUE ( rs.Match ( "acccd" ) );
EXPECT_TRUE ( rs.Match ( "abcbd" ) );
EXPECT_FALSE ( rs.Match ( "ad" ) );
EXPECT_FALSE ( rs.Match ( "abbd" ) );
EXPECT_FALSE ( rs.Match ( "accccd" ) );
EXPECT_FALSE ( rs.Match ( "abbbbd" ) );
}
TEST ( Regex, QuantifierMin1 )
{
Regex re ( "ab{3,}c" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "abbbc" ) );
EXPECT_TRUE ( rs.Match ( "abbbbc" ) );
EXPECT_TRUE ( rs.Match ( "abbbbbc" ) );
EXPECT_FALSE ( rs.Match ( "ac" ) );
EXPECT_FALSE ( rs.Match ( "abc" ) );
EXPECT_FALSE ( rs.Match ( "abbc" ) );
}
TEST ( Regex, QuantifierMin2 )
{
Regex re ( "a(bc){3,}d" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "abcbcbcd" ) );
EXPECT_TRUE ( rs.Match ( "abcbcbcbcd" ) );
EXPECT_FALSE ( rs.Match ( "ad" ) );
EXPECT_FALSE ( rs.Match ( "abcd" ) );
EXPECT_FALSE ( rs.Match ( "abcbcd" ) );
}
TEST ( Regex, QuantifierMin3 )
{
Regex re ( "a(b|c){3,}d" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "abbbd" ) );
EXPECT_TRUE ( rs.Match ( "acccd" ) );
EXPECT_TRUE ( rs.Match ( "abcbd" ) );
EXPECT_TRUE ( rs.Match ( "accccd" ) );
EXPECT_TRUE ( rs.Match ( "abbbbd" ) );
EXPECT_FALSE ( rs.Match ( "ad" ) );
EXPECT_FALSE ( rs.Match ( "abbd" ) );
}
TEST ( Regex, QuantifierMinMax1 )
{
Regex re ( "ab{3,5}c" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "abbbc" ) );
EXPECT_TRUE ( rs.Match ( "abbbbc" ) );
EXPECT_TRUE ( rs.Match ( "abbbbbc" ) );
EXPECT_FALSE ( rs.Match ( "ac" ) );
EXPECT_FALSE ( rs.Match ( "abc" ) );
EXPECT_FALSE ( rs.Match ( "abbc" ) );
EXPECT_FALSE ( rs.Match ( "abbbbbbc" ) );
}
TEST ( Regex, QuantifierMinMax2 )
{
Regex re ( "a(bc){3,5}d" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "abcbcbcd" ) );
EXPECT_TRUE ( rs.Match ( "abcbcbcbcd" ) );
EXPECT_TRUE ( rs.Match ( "abcbcbcbcbcd" ) );
EXPECT_FALSE ( rs.Match ( "ad" ) );
EXPECT_FALSE ( rs.Match ( "abcd" ) );
EXPECT_FALSE ( rs.Match ( "abcbcd" ) );
EXPECT_FALSE ( rs.Match ( "abcbcbcbcbcbcd" ) );
}
TEST ( Regex, QuantifierMinMax3 )
{
Regex re ( "a(b|c){3,5}d" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "abbbd" ) );
EXPECT_TRUE ( rs.Match ( "acccd" ) );
EXPECT_TRUE ( rs.Match ( "abcbd" ) );
EXPECT_TRUE ( rs.Match ( "accccd" ) );
EXPECT_TRUE ( rs.Match ( "abbbbd" ) );
EXPECT_TRUE ( rs.Match ( "acccccd" ) );
EXPECT_TRUE ( rs.Match ( "abbbbbd" ) );
EXPECT_FALSE ( rs.Match ( "ad" ) );
EXPECT_FALSE ( rs.Match ( "abbd" ) );
EXPECT_FALSE ( rs.Match ( "accccccd" ) );
EXPECT_FALSE ( rs.Match ( "abbbbbbd" ) );
}
// Issue538
TEST ( Regex, QuantifierMinMax4 )
{
Regex re ( "a(b|c){0,3}d" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "ad" ) );
EXPECT_TRUE ( rs.Match ( "abd" ) );
EXPECT_TRUE ( rs.Match ( "acd" ) );
EXPECT_TRUE ( rs.Match ( "abbd" ) );
EXPECT_TRUE ( rs.Match ( "accd" ) );
EXPECT_TRUE ( rs.Match ( "abcd" ) );
EXPECT_TRUE ( rs.Match ( "abbbd" ) );
EXPECT_TRUE ( rs.Match ( "acccd" ) );
EXPECT_FALSE ( rs.Match ( "abbbbd" ) );
EXPECT_FALSE ( rs.Match ( "add" ) );
EXPECT_FALSE ( rs.Match ( "accccd" ) );
EXPECT_FALSE ( rs.Match ( "abcbcd" ) );
}
// Issue538
TEST ( Regex, QuantifierMinMax5 )
{
Regex re ( "a(b|c){0,}d" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "ad" ) );
EXPECT_TRUE ( rs.Match ( "abd" ) );
EXPECT_TRUE ( rs.Match ( "acd" ) );
EXPECT_TRUE ( rs.Match ( "abbd" ) );
EXPECT_TRUE ( rs.Match ( "accd" ) );
EXPECT_TRUE ( rs.Match ( "abcd" ) );
EXPECT_TRUE ( rs.Match ( "abbbd" ) );
EXPECT_TRUE ( rs.Match ( "acccd" ) );
EXPECT_TRUE ( rs.Match ( "abbbbd" ) );
EXPECT_TRUE ( rs.Match ( "accccd" ) );
EXPECT_TRUE ( rs.Match ( "abcbcd" ) );
EXPECT_FALSE ( rs.Match ( "add" ) );
EXPECT_FALSE ( rs.Match ( "aad" ) );
}
#define EURO "\xE2\x82\xAC" // "\xE2\x82\xAC" is UTF-8 rsquence of Euro sign U+20AC
TEST ( Regex, Unicode )
{
Regex re ( "a" EURO "+b" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "a" EURO "b" ) );
EXPECT_TRUE ( rs.Match ( "a" EURO EURO "b" ) );
EXPECT_FALSE ( rs.Match ( "a?b" ) );
EXPECT_FALSE ( rs.Match ( "a" EURO "\xAC" "b" ) ); // unaware of UTF-8 will match
}
TEST ( Regex, AnyCharacter )
{
Regex re ( "." );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "a" ) );
EXPECT_TRUE ( rs.Match ( "b" ) );
EXPECT_TRUE ( rs.Match ( EURO ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "aa" ) );
}
TEST ( Regex, CharacterRange1 )
{
Regex re ( "[abc]" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "a" ) );
EXPECT_TRUE ( rs.Match ( "b" ) );
EXPECT_TRUE ( rs.Match ( "c" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "`" ) );
EXPECT_FALSE ( rs.Match ( "d" ) );
EXPECT_FALSE ( rs.Match ( "aa" ) );
}
TEST ( Regex, CharacterRange2 )
{
Regex re ( "[^abc]" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "`" ) );
EXPECT_TRUE ( rs.Match ( "d" ) );
EXPECT_FALSE ( rs.Match ( "a" ) );
EXPECT_FALSE ( rs.Match ( "b" ) );
EXPECT_FALSE ( rs.Match ( "c" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "aa" ) );
}
TEST ( Regex, CharacterRange3 )
{
Regex re ( "[a-c]" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "a" ) );
EXPECT_TRUE ( rs.Match ( "b" ) );
EXPECT_TRUE ( rs.Match ( "c" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "`" ) );
EXPECT_FALSE ( rs.Match ( "d" ) );
EXPECT_FALSE ( rs.Match ( "aa" ) );
}
TEST ( Regex, CharacterRange4 )
{
Regex re ( "[^a-c]" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "`" ) );
EXPECT_TRUE ( rs.Match ( "d" ) );
EXPECT_FALSE ( rs.Match ( "a" ) );
EXPECT_FALSE ( rs.Match ( "b" ) );
EXPECT_FALSE ( rs.Match ( "c" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "aa" ) );
}
TEST ( Regex, CharacterRange5 )
{
Regex re ( "[-]" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "-" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "a" ) );
}
TEST ( Regex, CharacterRange6 )
{
Regex re ( "[a-]" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "a" ) );
EXPECT_TRUE ( rs.Match ( "-" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "`" ) );
EXPECT_FALSE ( rs.Match ( "b" ) );
}
TEST ( Regex, CharacterRange7 )
{
Regex re ( "[-a]" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "a" ) );
EXPECT_TRUE ( rs.Match ( "-" ) );
EXPECT_FALSE ( rs.Match ( "" ) );
EXPECT_FALSE ( rs.Match ( "`" ) );
EXPECT_FALSE ( rs.Match ( "b" ) );
}
TEST ( Regex, CharacterRange8 )
{
Regex re ( "[a-zA-Z0-9]*" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "Milo" ) );
EXPECT_TRUE ( rs.Match ( "MT19937" ) );
EXPECT_TRUE ( rs.Match ( "43" ) );
EXPECT_FALSE ( rs.Match ( "a_b" ) );
EXPECT_FALSE ( rs.Match ( "!" ) );
}
TEST ( Regex, Search )
{
Regex re ( "abc" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Search ( "abc" ) );
EXPECT_TRUE ( rs.Search ( "_abc" ) );
EXPECT_TRUE ( rs.Search ( "abc_" ) );
EXPECT_TRUE ( rs.Search ( "_abc_" ) );
EXPECT_TRUE ( rs.Search ( "__abc__" ) );
EXPECT_TRUE ( rs.Search ( "abcabc" ) );
EXPECT_FALSE ( rs.Search ( "a" ) );
EXPECT_FALSE ( rs.Search ( "ab" ) );
EXPECT_FALSE ( rs.Search ( "bc" ) );
EXPECT_FALSE ( rs.Search ( "cba" ) );
}
TEST ( Regex, Search_BeginAnchor )
{
Regex re ( "^abc" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Search ( "abc" ) );
EXPECT_TRUE ( rs.Search ( "abc_" ) );
EXPECT_TRUE ( rs.Search ( "abcabc" ) );
EXPECT_FALSE ( rs.Search ( "_abc" ) );
EXPECT_FALSE ( rs.Search ( "_abc_" ) );
EXPECT_FALSE ( rs.Search ( "a" ) );
EXPECT_FALSE ( rs.Search ( "ab" ) );
EXPECT_FALSE ( rs.Search ( "bc" ) );
EXPECT_FALSE ( rs.Search ( "cba" ) );
}
TEST ( Regex, Search_EndAnchor )
{
Regex re ( "abc$" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Search ( "abc" ) );
EXPECT_TRUE ( rs.Search ( "_abc" ) );
EXPECT_TRUE ( rs.Search ( "abcabc" ) );
EXPECT_FALSE ( rs.Search ( "abc_" ) );
EXPECT_FALSE ( rs.Search ( "_abc_" ) );
EXPECT_FALSE ( rs.Search ( "a" ) );
EXPECT_FALSE ( rs.Search ( "ab" ) );
EXPECT_FALSE ( rs.Search ( "bc" ) );
EXPECT_FALSE ( rs.Search ( "cba" ) );
}
TEST ( Regex, Search_BothAnchor )
{
Regex re ( "^abc$" );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Search ( "abc" ) );
EXPECT_FALSE ( rs.Search ( "" ) );
EXPECT_FALSE ( rs.Search ( "a" ) );
EXPECT_FALSE ( rs.Search ( "b" ) );
EXPECT_FALSE ( rs.Search ( "ab" ) );
EXPECT_FALSE ( rs.Search ( "abcd" ) );
}
TEST ( Regex, Escape )
{
const char* s = "\\^\\$\\|\\(\\)\\?\\*\\+\\.\\[\\]\\{\\}\\\\\\f\\n\\r\\t\\v[\\b][\\[][\\]]";
Regex re ( s );
ASSERT_TRUE ( re.IsValid() );
RegexSearch rs ( re );
EXPECT_TRUE ( rs.Match ( "^$|()?*+.[]{}\\\x0C\n\r\t\x0B\b[]" ) );
EXPECT_FALSE ( rs.Match ( s ) ); // Not escaping
}
TEST ( Regex, Invalid )
{
#define TEST_INVALID(s) \
{\
Regex re(s);\
EXPECT_FALSE(re.IsValid());\
}
TEST_INVALID ( "" );
TEST_INVALID ( "a|" );
TEST_INVALID ( "()" );
TEST_INVALID ( "(" );
TEST_INVALID ( ")" );
TEST_INVALID ( "(a))" );
TEST_INVALID ( "(a|)" );
TEST_INVALID ( "(a||b)" );
TEST_INVALID ( "(|b)" );
TEST_INVALID ( "?" );
TEST_INVALID ( "*" );
TEST_INVALID ( "+" );
TEST_INVALID ( "{" );
TEST_INVALID ( "{}" );
TEST_INVALID ( "a{a}" );
TEST_INVALID ( "a{0}" );
TEST_INVALID ( "a{-1}" );
TEST_INVALID ( "a{}" );
// TEST_INVALID("a{0,}"); // Support now
TEST_INVALID ( "a{,0}" );
TEST_INVALID ( "a{1,0}" );
TEST_INVALID ( "a{-1,0}" );
TEST_INVALID ( "a{-1,1}" );
TEST_INVALID ( "a{4294967296}" ); // overflow of unsigned
TEST_INVALID ( "a{1a}" );
TEST_INVALID ( "[" );
TEST_INVALID ( "[]" );
TEST_INVALID ( "[^]" );
TEST_INVALID ( "[\\a]" );
TEST_INVALID ( "\\a" );
#undef TEST_INVALID
}
TEST ( Regex, Issue538 )
{
Regex re ( "^[0-9]+(\\\\.[0-9]+){0,2}" );
EXPECT_TRUE ( re.IsValid() );
}
TEST ( Regex, Issue583 )
{
Regex re ( "[0-9]{99999}" );
ASSERT_TRUE ( re.IsValid() );
}
#undef EURO
| 27.182874 | 94 | 0.567729 | lktrgl |
e9a2baf6896da4c6ee2705cc615b91f091062f2f | 295 | hpp | C++ | include/sge/initializers/sdl-image.hpp | smaudet/sdl-game-engine | e49a001541c6e30c0cc0ee6aa04ee6ba2b5f4af7 | [
"MIT"
] | 75 | 2017-07-19T14:00:55.000Z | 2022-01-10T21:50:44.000Z | include/sge/initializers/sdl-image.hpp | smaudet/sdl-game-engine | e49a001541c6e30c0cc0ee6aa04ee6ba2b5f4af7 | [
"MIT"
] | 3 | 2017-04-05T00:57:33.000Z | 2018-11-14T07:48:40.000Z | include/sge/initializers/sdl-image.hpp | smaudet/sdl-game-engine | e49a001541c6e30c0cc0ee6aa04ee6ba2b5f4af7 | [
"MIT"
] | 12 | 2017-09-19T09:51:48.000Z | 2021-12-05T18:11:53.000Z | #ifndef __SGE_SDL_IMAGE_INIT_HPP
#define __SGE_SDL_IMAGE_INIT_HPP
#include <sge/init.hpp>
namespace sge
{
class SDLImageInitializer : public Initializer
{
public:
void do_initialize();
void do_shutdown();
};
}
#endif /* __SGE_SDL_IMAGE_INIT_HPP */
| 17.352941 | 50 | 0.667797 | smaudet |
e9a7332b6220e9db2bf28f1d62a71dbe5f91d530 | 3,711 | hpp | C++ | include/ccbase/platform/bswap.hpp | adityaramesh/ccbase | 595e1416aab3cc8bc976aad9bb3e262c7d11e3b2 | [
"BSD-3-Clause-Clear"
] | 8 | 2015-01-08T05:44:43.000Z | 2021-05-11T15:54:17.000Z | include/ccbase/platform/bswap.hpp | adityaramesh/ccbase | 595e1416aab3cc8bc976aad9bb3e262c7d11e3b2 | [
"BSD-3-Clause-Clear"
] | 1 | 2016-01-31T08:48:53.000Z | 2016-01-31T08:54:28.000Z | include/ccbase/platform/bswap.hpp | adityaramesh/ccbase | 595e1416aab3cc8bc976aad9bb3e262c7d11e3b2 | [
"BSD-3-Clause-Clear"
] | 2 | 2015-03-26T11:08:18.000Z | 2016-01-30T03:28:06.000Z | /*
** File Name: bswap.hpp
** Author: Aditya Ramesh
** Date: 04/14/2014
** Contact: _@adityaramesh.com
*/
#ifndef Z2C1D91E3_6CC1_415A_A95D_65604B557F77
#define Z2C1D91E3_6CC1_415A_A95D_65604B557F77
#include <algorithm>
#include <cstdint>
#include <type_traits>
#include <ccbase/platform/attributes.hpp>
#include <ccbase/platform/identification.hpp>
#if !(PLATFORM_COMPILER == PLATFORM_COMPILER_CLANG || \
PLATFORM_COMPILER == PLATFORM_COMPILER_GCC || \
PLATFORM_COMPILER == PLATFORM_COMPILER_ICC)
#warning "Unsupported compiler for cc::bswap."
#warning "The operation will not use intrinsics."
#endif
namespace cc {
CC_ALWAYS_INLINE constexpr
int8_t bswap(int8_t x) noexcept
{ return x; }
CC_ALWAYS_INLINE constexpr
int16_t bswap(int16_t x) noexcept
{
#if PLATFORM_COMPILER == PLATFORM_COMPILER_CLANG || \
PLATFORM_COMPILER == PLATFORM_COMPILER_GCC || \
PLATFORM_COMPILER == PLATFORM_COMPILER_ICC
return __builtin_bswap16(x);
#else
return ((x & 0xFF) << 8) | ((x & 0xFF00) >> 8);
#endif
}
CC_ALWAYS_INLINE constexpr
int32_t bswap(int32_t x) noexcept
{
#if PLATFORM_COMPILER == PLATFORM_COMPILER_CLANG || \
PLATFORM_COMPILER == PLATFORM_COMPILER_GCC || \
PLATFORM_COMPILER == PLATFORM_COMPILER_ICC
return __builtin_bswap32(x);
#else
return ((x & 0xFF) << 24) |
((x & 0xFF00) << 8) |
((x & 0xFF0000) >> 8) |
((x & 0xFF0000000) >> 24);
#endif
}
CC_ALWAYS_INLINE constexpr
int64_t bswap(int64_t x) noexcept
{
#if PLATFORM_COMPILER == PLATFORM_COMPILER_CLANG || \
PLATFORM_COMPILER == PLATFORM_COMPILER_GCC || \
PLATFORM_COMPILER == PLATFORM_COMPILER_ICC
return __builtin_bswap64(x);
#else
return ((x & 0xFF) << 56) |
((x & 0xFF00) << 40) |
((x & 0xFF0000) << 24) |
((x & 0xFF000000) << 8) |
((x & 0xFF00000000) >> 8) |
((x & 0xFF0000000000) >> 24) |
((x & 0xFF000000000000) >> 40) |
((x & 0xFF00000000000000) >> 56);
#endif
}
CC_ALWAYS_INLINE constexpr
uint8_t bswap(uint8_t x) noexcept
{ return x; }
CC_ALWAYS_INLINE constexpr
uint16_t bswap(uint16_t x) noexcept
{
#if PLATFORM_COMPILER == PLATFORM_COMPILER_CLANG || \
PLATFORM_COMPILER == PLATFORM_COMPILER_GCC || \
PLATFORM_COMPILER == PLATFORM_COMPILER_ICC
return __builtin_bswap16(x);
#else
return ((x & 0xFF) << 8) | ((x & 0xFF00) >> 8);
#endif
}
CC_ALWAYS_INLINE constexpr
uint32_t bswap(uint32_t x) noexcept
{
#if PLATFORM_COMPILER == PLATFORM_COMPILER_CLANG || \
PLATFORM_COMPILER == PLATFORM_COMPILER_GCC || \
PLATFORM_COMPILER == PLATFORM_COMPILER_ICC
return __builtin_bswap32(x);
#else
return ((x & 0xFF) << 24) |
((x & 0xFF00) << 8) |
((x & 0xFF0000) >> 8) |
((x & 0xFF0000000) >> 24);
#endif
}
CC_ALWAYS_INLINE constexpr
uint64_t bswap(uint64_t x) noexcept
{
#if PLATFORM_COMPILER == PLATFORM_COMPILER_CLANG || \
PLATFORM_COMPILER == PLATFORM_COMPILER_GCC || \
PLATFORM_COMPILER == PLATFORM_COMPILER_ICC
return __builtin_bswap64(x);
#else
return ((x & 0xFF) << 56) |
((x & 0xFF00) << 40) |
((x & 0xFF0000) << 24) |
((x & 0xFF000000) << 8) |
((x & 0xFF00000000) >> 8) |
((x & 0xFF0000000000) >> 24) |
((x & 0xFF000000000000) >> 40) |
((x & 0xFF00000000000000) >> 56);
#endif
}
CC_ALWAYS_INLINE
auto bswap(float x) noexcept ->
std::enable_if<sizeof(float) == 4, float>::type
{
auto buf = uint32_t{};
std::copy_n((char*)&x, sizeof(float), (char*)&buf);
return bswap(buf);
}
CC_ALWAYS_INLINE
auto bswap(double x) noexcept ->
std::enable_if<sizeof(double) == 8, double>::type
{
auto buf = uint64_t{};
std::copy_n((char*)&x, sizeof(double), (char*)&buf);
return bswap(buf);
}
}
#endif
| 25.244898 | 55 | 0.665319 | adityaramesh |
e9a9db49b0ab476f52bff58296aa37f1b8e47a89 | 5,313 | hpp | C++ | libs/boost_1_72_0/boost/spirit/home/support/char_encoding/standard_wide.hpp | henrywarhurst/matrix | 317a2a7c35c1c7e3730986668ad2270dc19809ef | [
"BSD-3-Clause"
] | null | null | null | libs/boost_1_72_0/boost/spirit/home/support/char_encoding/standard_wide.hpp | henrywarhurst/matrix | 317a2a7c35c1c7e3730986668ad2270dc19809ef | [
"BSD-3-Clause"
] | null | null | null | libs/boost_1_72_0/boost/spirit/home/support/char_encoding/standard_wide.hpp | henrywarhurst/matrix | 317a2a7c35c1c7e3730986668ad2270dc19809ef | [
"BSD-3-Clause"
] | null | null | null | /*=============================================================================
Copyright (c) 2001-2011 Hartmut Kaiser
Copyright (c) 2001-2011 Joel de Guzman
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)
=============================================================================*/
#if !defined(BOOST_SPIRIT_STANDARD_WIDE_NOVEMBER_10_2006_0913AM)
#define BOOST_SPIRIT_STANDARD_WIDE_NOVEMBER_10_2006_0913AM
#if defined(_MSC_VER)
#pragma once
#endif
#include <cwctype>
#include <string>
#include <boost/assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/spirit/home/support/assert_msg.hpp>
namespace boost {
namespace spirit {
namespace traits {
template <std::size_t N> struct wchar_t_size {
BOOST_SPIRIT_ASSERT_MSG(N == 1 || N == 2 || N == 4,
not_supported_size_of_wchar_t, ());
};
template <> struct wchar_t_size<1> {
enum { mask = 0xff };
};
template <> struct wchar_t_size<2> {
enum { mask = 0xffff };
};
template <> struct wchar_t_size<4> {
enum { mask = 0xffffffff };
};
} // namespace traits
} // namespace spirit
} // namespace boost
namespace boost {
namespace spirit {
namespace char_encoding {
///////////////////////////////////////////////////////////////////////////
// Test characters for specified conditions (using std wchar_t functions)
///////////////////////////////////////////////////////////////////////////
struct standard_wide {
typedef wchar_t char_type;
typedef wchar_t classify_type;
template <typename Char>
static typename std::char_traits<Char>::int_type to_int_type(Char ch) {
return std::char_traits<Char>::to_int_type(ch);
}
template <typename Char>
static Char to_char_type(typename std::char_traits<Char>::int_type ch) {
return std::char_traits<Char>::to_char_type(ch);
}
static bool ischar(int ch) {
// we have to watch out for sign extensions (casting is there to
// silence certain compilers complaining about signed/unsigned
// mismatch)
return (std::size_t(0) ==
std::size_t(ch &
~traits::wchar_t_size<sizeof(wchar_t)>::mask) ||
std::size_t(~0) ==
std::size_t(ch |
traits::wchar_t_size<sizeof(wchar_t)>::mask)) !=
0; // any wchar_t, but no other bits set
}
// *** Note on assertions: The precondition is that the calls to
// these functions do not violate the required range of ch (type int)
// which is that strict_ischar(ch) should be true. It is the
// responsibility of the caller to make sure this precondition is not
// violated.
static bool strict_ischar(int ch) {
// ch should be representable as a wchar_t
return ch >= WCHAR_MIN && ch <= WCHAR_MAX;
}
static bool isalnum(wchar_t ch) {
using namespace std;
BOOST_ASSERT(strict_ischar(ch));
return iswalnum(to_int_type(ch)) != 0;
}
static bool isalpha(wchar_t ch) {
using namespace std;
BOOST_ASSERT(strict_ischar(ch));
return iswalpha(to_int_type(ch)) != 0;
}
static bool iscntrl(wchar_t ch) {
using namespace std;
BOOST_ASSERT(strict_ischar(ch));
return iswcntrl(to_int_type(ch)) != 0;
}
static bool isdigit(wchar_t ch) {
using namespace std;
BOOST_ASSERT(strict_ischar(ch));
return iswdigit(to_int_type(ch)) != 0;
}
static bool isgraph(wchar_t ch) {
using namespace std;
BOOST_ASSERT(strict_ischar(ch));
return iswgraph(to_int_type(ch)) != 0;
}
static bool islower(wchar_t ch) {
using namespace std;
BOOST_ASSERT(strict_ischar(ch));
return iswlower(to_int_type(ch)) != 0;
}
static bool isprint(wchar_t ch) {
using namespace std;
return iswprint(to_int_type(ch)) != 0;
}
static bool ispunct(wchar_t ch) {
using namespace std;
BOOST_ASSERT(strict_ischar(ch));
return iswpunct(to_int_type(ch)) != 0;
}
static bool isspace(wchar_t ch) {
using namespace std;
BOOST_ASSERT(strict_ischar(ch));
return iswspace(to_int_type(ch)) != 0;
}
static bool isupper(wchar_t ch) {
using namespace std;
BOOST_ASSERT(strict_ischar(ch));
return iswupper(to_int_type(ch)) != 0;
}
static bool isxdigit(wchar_t ch) {
using namespace std;
BOOST_ASSERT(strict_ischar(ch));
return iswxdigit(to_int_type(ch)) != 0;
}
static bool isblank BOOST_PREVENT_MACRO_SUBSTITUTION(wchar_t ch) {
BOOST_ASSERT(strict_ischar(ch));
return (ch == L' ' || ch == L'\t');
}
///////////////////////////////////////////////////////////////////////
// Simple character conversions
///////////////////////////////////////////////////////////////////////
static wchar_t tolower(wchar_t ch) {
using namespace std;
BOOST_ASSERT(strict_ischar(ch));
return isupper(ch) ? to_char_type<wchar_t>(towlower(to_int_type(ch))) : ch;
}
static wchar_t toupper(wchar_t ch) {
using namespace std;
BOOST_ASSERT(strict_ischar(ch));
return islower(ch) ? to_char_type<wchar_t>(towupper(to_int_type(ch))) : ch;
}
static ::boost::uint32_t toucs4(int ch) {
BOOST_ASSERT(strict_ischar(ch));
return ch;
}
};
} // namespace char_encoding
} // namespace spirit
} // namespace boost
#endif
| 28.718919 | 80 | 0.618859 | henrywarhurst |
e9aa21e5e2009af651a29c53ee8d38a52b2363be | 1,322 | cc | C++ | chrome/browser/extensions/api/messaging/native_messaging_policy_handler.cc | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 14,668 | 2015-01-01T01:57:10.000Z | 2022-03-31T23:33:32.000Z | chrome/browser/extensions/api/messaging/native_messaging_policy_handler.cc | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 113 | 2015-05-04T09:58:14.000Z | 2022-01-31T19:35:03.000Z | chrome/browser/extensions/api/messaging/native_messaging_policy_handler.cc | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 5,941 | 2015-01-02T11:32:21.000Z | 2022-03-31T16:35:46.000Z | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/api/messaging/native_messaging_policy_handler.h"
#include "components/prefs/pref_value_map.h"
#include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest.h"
namespace extensions {
NativeMessagingHostListPolicyHandler::NativeMessagingHostListPolicyHandler(
const char* policy_name,
const char* pref_path,
bool allow_wildcards)
: policy::ListPolicyHandler(policy_name, base::Value::Type::STRING),
pref_path_(pref_path),
allow_wildcards_(allow_wildcards) {}
NativeMessagingHostListPolicyHandler::~NativeMessagingHostListPolicyHandler() {}
bool NativeMessagingHostListPolicyHandler::CheckListEntry(
const base::Value& value) {
const std::string& str = value.GetString();
if (allow_wildcards_ && str == "*")
return true;
return NativeMessagingHostManifest::IsValidName(str);
}
void NativeMessagingHostListPolicyHandler::ApplyList(base::Value filtered_list,
PrefValueMap* prefs) {
DCHECK(filtered_list.is_list());
prefs->SetValue(pref_path_, std::move(filtered_list));
}
} // namespace extensions
| 34.789474 | 84 | 0.748865 | zealoussnow |
e9ab070a8c1c9ebe1be9d1edee3761064e7865af | 4,454 | cpp | C++ | src/quantum_state.cpp | twesterhout/walking-lanczos | cf7798b345d2219f92577e3dbbefbbc2f329acf0 | [
"BSD-3-Clause-Clear"
] | null | null | null | src/quantum_state.cpp | twesterhout/walking-lanczos | cf7798b345d2219f92577e3dbbefbbc2f329acf0 | [
"BSD-3-Clause-Clear"
] | 1 | 2018-10-18T17:52:06.000Z | 2018-10-29T13:05:22.000Z | src/quantum_state.cpp | twesterhout/walking-lanczos | cf7798b345d2219f92577e3dbbefbbc2f329acf0 | [
"BSD-3-Clause-Clear"
] | null | null | null | // Copyright Tom Westerhout (c) 2018
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// * Neither the name of Tom Westerhout nor the names of other
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "quantum_state.hpp"
#include <numeric>
auto QuantumState::clear() -> void
{
for (auto& table : _maps) {
table.clear();
}
}
auto QuantumState::insert(value_type&& x) -> std::pair<map_type::iterator, bool>
{
return _maps[spin_to_index(x.first, _maps.size())].insert(std::move(x));
}
auto QuantumState::remove_least(std::size_t count) -> void
{
_entries.clear();
for (auto const& table : _maps) {
for (auto const& x : table) {
_entries.push_back({x.first, std::norm(x.second)});
}
}
std::sort(std::begin(_entries), std::end(_entries),
[](auto const& x, auto const& y) { return x.second < y.second; });
for (std::size_t i = 0; i < count; ++i) {
auto& table = _maps.at(spin_to_index(_entries[i].first, _maps.size()));
TCM_ASSERT(table.count(_entries[i].first));
table.erase(_entries[i].first);
}
}
auto QuantumState::normalize() -> QuantumState&
{
double norm = 0.0;
for (auto const& table : _maps) {
norm += std::accumulate(
table.begin(), table.end(), 0.0, [](auto const acc, auto const& x) {
return acc + std::norm(x.second);
});
}
auto const scale = 1.0 / std::sqrt(norm);
for (auto& table : _maps) {
for (auto& [_, coeff] : table) {
coeff *= scale;
}
}
return *this;
}
auto QuantumState::shrink() -> void
{
auto const size = std::accumulate(std::begin(_maps), std::end(_maps), 0ul,
[](auto const acc, auto const& x) { return acc + x.size(); });
if (size > _soft_max_size) { remove_least(size - _soft_max_size); }
}
auto operator<<(std::ostream& out, QuantumState const& psi) -> std::ostream&
{
psi.for_each([&out](auto const& x) {
out << x.first << '\t' << x.second.real() << '\t' << x.second.imag()
<< '\n';
});
return out;
}
auto operator>>(std::istream& is, QuantumState& x) -> std::istream&
{
std::string line;
SpinVector spin;
double real, imag;
x.clear();
while (std::getline(is, line)) {
if (!line.empty() && line.front() != '#') {
std::istringstream line_stream{line};
if ((line_stream >> spin >> real >> imag).fail()) {
is.setstate(std::ios_base::failbit);
throw_with_trace(std::runtime_error{"Failed to parse |ψ₀〉."});
}
if (!x.insert({spin, std::complex{real, imag}}).second) {
is.setstate(std::ios_base::failbit);
throw_with_trace(std::runtime_error{
"Failed to parse |ψ₀〉: Duplicate basis elements."});
}
}
}
if (!is.eof()) {
is.setstate(std::ios_base::failbit);
throw_with_trace(std::runtime_error{"Failed to parse |ψ₀〉."});
}
return is;
}
| 35.919355 | 80 | 0.621688 | twesterhout |
e9acc2eb1780b01d5820b99d173334f3e07e58d2 | 4,731 | cpp | C++ | src/mapmaker/Util.cpp | gshaw/closecombat | 8c0f8a9ee29a109784a465aadda063922543ac72 | [
"Zlib"
] | 5 | 2015-02-03T04:04:20.000Z | 2020-03-19T01:07:47.000Z | src/mapmaker/Util.cpp | gshaw/closecombat | 8c0f8a9ee29a109784a465aadda063922543ac72 | [
"Zlib"
] | null | null | null | src/mapmaker/Util.cpp | gshaw/closecombat | 8c0f8a9ee29a109784a465aadda063922543ac72 | [
"Zlib"
] | null | null | null | #include "StdAfx.h"
#include "Util.h"
bool CC2_IsDataFolderValid(const CString& FolderPath)
{
// return true if FolderPath is a valid folder path to the close combat 2 game folder
bool ok = false;
// look for data\base\elements
CString PathName(FolderPath);
PathName += _T("\\data\\base\\elements");
CFileStatus Status;
if (CFile::GetStatus(PathName, Status))
{
ok = true;
}
return ok;
}
char* ReadFile(const CString& PathName)
{
char* pBuffer = NULL;
try
{
CFile File(PathName, CFile::modeRead);
int BufferLen = File.GetLength();
pBuffer = new char[BufferLen+1];
ZeroMemory(pBuffer, BufferLen+1);
File.Read(pBuffer, BufferLen);
}
catch (...)
{
if (pBuffer)
{
delete pBuffer;
pBuffer = NULL;
}
}
return pBuffer;
}
int GetColumnInt(const char* p, int col)
{
// find the int at the col'th tab stop
// if not a valid int throw an exception
ASSERT(p != NULL);
while (col > 0)
{
p++;
// check for column out of range
if ((*p == '\0') || (*p == '\r') || (*p == '\n'))
{
TRACE("could not find column %d. Found new line instead.\n", col);
throw;
}
// check for start of comment
if (*p == '\\')
{
if (*(p+1) == '\\')
{
TRACE("could not find column %d. Found start of comment instead.\n", col);
throw;
}
}
// check for tab stop
if (*p == '\t')
col--;
}
// p should now point to an int
int i = 0;
if (sscanf(p, "%d", &i) != 1)
{
TRACE("could not parse an int. sscanf return bad value.\n");
throw;
}
return i;
}
CString GetColumnStr(const char* p, int col)
{
// find the int at the col'th tab stop
// if not a valid int throw an exception
ASSERT(p != NULL);
while (col > 0)
{
p++;
// check for column out of range
if ((*p == '\0') || (*p == '\r') || (*p == '\n'))
{
TRACE("could not find column %d. Found new line instead.\n", col);
throw;
}
// check for start of comment
if (*p == '\\')
{
if (*(p+1) == '\\')
{
TRACE("could not find column %d. Found start of comment instead.\n", col);
throw;
}
}
// check for tab stop
if (*p == '\t')
col--;
}
// p should now point to an int
char str[128];
char* s = str;
while ((*p != '\r') && (*p != '\n') && (*p != '\t'))
*s++ = *p++;
*s = NULL;
return CString(str);
}
const char* NextLine(const char* p)
{
ASSERT(p != NULL);
while ((*p != '\0') && (*p != '\r') && (*p != '\n'))
p++;
ASSERT(*p != '\0');
while ((*p == '\r') || (*p == '\n'))
p++;
return p;
}
const char* FindChar(const char* p, char ch)
{
ASSERT(p != NULL);
while ((*p != '\0') && (*p != ch))
p++;
return p;
}
int CountRowsTo(const char* p, char ch)
{
int NumRows = 0;
while (*p != ch)
{
p = NextLine(p);
NumRows++;
}
return NumRows;
}
void TgaWrite(const CString& PathName, CDIB* pImage)
{
TGAINFO info;
ZeroMemory(&info, sizeof(TGAINFO));
info.width = pImage->GetWidth();
info.height = pImage->GetHeight();
if (pImage->GetBpp() > 8)
{
info.bpp = 32;
}
else
{
info.bpp = 8;
info.startcolor = 0;
info.numcolors = 256;
RGBQUAD* pRGB = pImage->GetColorTable();
for (int i = 0; i < 256; i++)
{
info.palette[i].a = 255;
info.palette[i].r = pRGB[i].rgbRed;
info.palette[i].g = pRGB[i].rgbGreen;
info.palette[i].b = pRGB[i].rgbBlue;
}
}
char* pathname = (char*)((const char*)PathName);
// TODO: write TGA to pathname
}
CDIB* TgaRead(const CString& PathName)
{
CDIB* pImage = NULL;
char* pathname = (char*)((const char*)PathName);
// TODO: read TGA image into CDIB
return pImage;
}
unsigned int GetBigEndian(void* pBuffer, int count)
{
unsigned char* p = (unsigned char*) pBuffer;
unsigned int value;
value = 0;
while (count--)
{
value = (value<<8) + ((*p++));
}
return value;
}
| 21.120536 | 92 | 0.452124 | gshaw |
e9b24241a88b3cdb0a584f0db991ab04d178e1f2 | 514 | hpp | C++ | src/OutSources/tabix/tabix.hpp | bioinformatics-centre/AsmVar | 5abd91a47feedfbd39b89ec3e2d6d20c02fe5a5e | [
"MIT"
] | 17 | 2015-12-25T10:58:03.000Z | 2021-05-06T01:56:40.000Z | src/OutSources/tabix/tabix.hpp | bioinformatics-centre/AsmVar | 5abd91a47feedfbd39b89ec3e2d6d20c02fe5a5e | [
"MIT"
] | 3 | 2017-07-20T22:12:16.000Z | 2021-04-19T14:37:14.000Z | src/OutSources/tabix/tabix.hpp | bioinformatics-centre/AsmVar | 5abd91a47feedfbd39b89ec3e2d6d20c02fe5a5e | [
"MIT"
] | 3 | 2018-01-26T02:03:04.000Z | 2020-08-07T08:01:20.000Z | #ifndef TABIX_H
#define TABIX_H
#include <string>
#include <stdlib.h>
#include <sys/stat.h>
#include "bgzf.h"
#include "tabix.h"
#include <iostream>
using namespace std;
class Tabix {
tabix_t *t;
ti_iter_t iter;
const ti_conf_t *idxconf;
int tid, beg, end;
string firstline;
public:
string filename;
Tabix(void);
Tabix(string& file);
~Tabix(void);
void getHeader(string& header);
bool setRegion(string& region);
bool getNextLine(string& line);
};
#endif
| 13.526316 | 35 | 0.655642 | bioinformatics-centre |
e9b46aae8acc01efce87618e24f8ef5cd322537d | 7,749 | cpp | C++ | compute/tensor/src/gpu/mali/fp16/matmul_mali_fp16.cpp | ysh329/bolt | 5c70e0ab68599331492f97cca197654ae4131216 | [
"MIT"
] | 1 | 2021-11-30T18:21:09.000Z | 2021-11-30T18:21:09.000Z | compute/tensor/src/gpu/mali/fp16/matmul_mali_fp16.cpp | ysh329/bolt | 5c70e0ab68599331492f97cca197654ae4131216 | [
"MIT"
] | null | null | null | compute/tensor/src/gpu/mali/fp16/matmul_mali_fp16.cpp | ysh329/bolt | 5c70e0ab68599331492f97cca197654ae4131216 | [
"MIT"
] | null | null | null | // Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved.
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "sys.h"
#include "error.h"
#include "types.h"
#include "gpu/mali/fp16/matmul_mali_fp16.h"
inline EE matmul_checkpara_mali_fp16(
TensorDesc matrixADesc, TensorDesc matrixBDesc, TensorDesc matrixCDesc)
{
if (matrixADesc.dt != matrixBDesc.dt || matrixADesc.dt != matrixCDesc.dt ||
matrixADesc.dt != DT_F16) {
return NOT_MATCH;
}
return SUCCESS;
}
inline EE matmul_core_mali_fp16(GCLHandle_t handle,
TensorDesc matrixADesc,
bool transposeA,
const GCLMem_t matrixA,
TensorDesc matrixBDesc,
bool transposeB,
const GCLMem_t matrixB,
GCLMem_t tmp,
TensorDesc matrixCDesc,
GCLMem_t matrixC,
ForwardRunInfoMali_t forwardRunInfo)
{
UNUSED(tmp);
UNUSED(matrixCDesc);
U32 adims = matrixADesc.nDims;
U32 ac = (adims > 2) ? matrixADesc.dims[2] : 1;
U32 ah = matrixADesc.dims[1];
U32 aw = matrixADesc.dims[0];
U32 bh = matrixBDesc.dims[1];
U32 bw = matrixBDesc.dims[0];
U32 item_w = forwardRunInfo->best_w[0];
U32 item_c = forwardRunInfo->best_c[0];
U32 item_k = forwardRunInfo->best_k[0];
cl_mem A, B, C;
A = matrixA->mem;
B = matrixB->mem;
C = matrixC->mem;
char kernelname[128];
Kernel kernel;
U32 gs[3];
U32 ls[3] = {0, 0, 0};
U32 dim = 3;
if (matrixA->desc.offset[0] != 0 || matrixA->desc.offset[1] != 0 ||
matrixB->desc.offset[0] != 0 || matrixB->desc.offset[1] != 0 ||
matrixC->desc.offset[0] != 0 || matrixC->desc.offset[1] != 0) {
CHECK_STATUS(NOT_SUPPORTED);
}
if (transposeA && !transposeB) {
U32 M = matrixA->desc.stride[0];
U32 N = matrixB->desc.stride[0];
U32 K = ah;
U32 ow_str = matrixC->desc.stride[0];
U32 A_str = M * matrixA->desc.stride[1];
U32 B_str = N * matrixB->desc.stride[1];
U32 C_str = ow_str * matrixC->desc.stride[1];
U32 batch = ac;
gs[0] = (bw + item_w - 1) / item_w;
gs[1] = (aw + item_k - 1) / item_k;
gs[2] = batch;
sprintf(kernelname, "gemm_tn_nobias_%d%d", item_k, item_w);
CHECK_STATUS(gcl_create_kernel(handle, kernelname, &kernel));
CHECK_STATUS(gcl_set_kernelArgs(kernel, M, N, K, ow_str, A_str, B_str, C_str, 0, 0, bw, aw,
gs[0], gs[1], 0, 0, A, B, C));
gcl_set_kernelVec(handle, kernel, dim, gs, ls, kernelname);
#ifdef _DEBUG
CHECK_STATUS(gcl_run_kernel(handle, kernel, dim, gs, ls, kernelname));
CHECK_STATUS(gcl_print_memory<F16>(handle, matrixA, "gemm_tn_a"));
CHECK_STATUS(gcl_print_memory<F16>(handle, matrixB, "gemm_tn_b"));
CHECK_STATUS(gcl_print_memory<F16>(handle, matrixC, "gemm_tn_c"));
handle->t_total += handle->t_execute;
#endif
return SUCCESS;
}
if (!transposeA && transposeB) {
U32 KA = matrixA->desc.stride[0];
U32 KB = matrixB->desc.stride[0];
U32 K = (aw + item_c - 1) / item_c * item_c;
U32 ow_str = matrixC->desc.stride[0];
U32 A_str = KA * matrixA->desc.stride[1];
U32 B_str = KB * matrixB->desc.stride[1];
U32 C_str = ow_str * matrixC->desc.stride[1];
U32 batch = ac;
gs[0] = (bh + item_w - 1) / item_w;
gs[1] = (ah + item_k - 1) / item_k;
gs[2] = batch;
sprintf(kernelname, "gemm_nt_nobias_%d%d%d", item_k, item_w, (item_c >> 1));
CHECK_STATUS(gcl_create_kernel(handle, kernelname, &kernel));
CHECK_STATUS(gcl_set_kernelArgs(
kernel, KA, KB, K, ow_str, A_str, B_str, C_str, 0, 0, bh, ah, gs[0], gs[1], A, B, C));
gcl_set_kernelVec(handle, kernel, dim, gs, ls, kernelname);
#ifdef _DEBUG
CHECK_STATUS(gcl_run_kernel(handle, kernel, dim, gs, ls, kernelname));
CHECK_STATUS(gcl_print_memory<F16>(handle, matrixA, "gemm_nt_a"));
CHECK_STATUS(gcl_print_memory<F16>(handle, matrixB, "gemm_nt_b"));
CHECK_STATUS(gcl_print_memory<F16>(handle, matrixC, "gemm_nt_c"));
handle->t_total += handle->t_execute;
#endif
return SUCCESS;
}
if (transposeA && transposeB) {
if (matrixADesc.df != DF_MKT) {
CHECK_STATUS(NOT_SUPPORTED);
}
U32 m, k, t;
get_nlp_mkt_val(matrixADesc, NULL, &m, &k, &t);
if (t != 1) {
CHECK_STATUS(NOT_SUPPORTED);
}
if (m != 1) {
CHECK_STATUS(NOT_SUPPORTED);
}
if (aw != 1) {
CHECK_STATUS(NOT_SUPPORTED);
}
if (ah != k) {
CHECK_STATUS(NOT_MATCH);
}
U32 KA = matrixA->desc.stride[2] * 4;
U32 KB = matrixB->desc.stride[0];
U32 K = (ah + item_c - 1) / item_c * item_c;
U32 ow_str = matrixC->desc.stride[0];
U32 batch = 1;
gs[0] = (bh + item_w - 1) / item_w;
gs[1] = 1;
gs[2] = batch;
sprintf(kernelname, "gemm_nt_nobias_%d%d%d", item_k, item_w, (item_c >> 1));
CHECK_STATUS(gcl_create_kernel(handle, kernelname, &kernel));
CHECK_STATUS(gcl_set_kernelArgs(
kernel, KA, KB, K, ow_str, 0, 0, 0, 0, 0, bh, 1, gs[0], gs[1], A, B, C));
gcl_set_kernelVec(handle, kernel, dim, gs, ls, kernelname);
#ifdef _DEBUG
CHECK_STATUS(gcl_run_kernel(handle, kernel, dim, gs, ls, kernelname));
CHECK_STATUS(gcl_print_memory<F16>(handle, matrixA, "gemm_nt_a"));
CHECK_STATUS(gcl_print_memory<F16>(handle, matrixB, "gemm_nt_b"));
CHECK_STATUS(gcl_print_memory<F16>(handle, matrixC, "gemm_nt_c"));
handle->t_total += handle->t_execute;
#endif
return SUCCESS;
}
return NOT_SUPPORTED;
}
EE matmul_infer_forward_tmp_bytes_mali_fp16(TensorDesc matrixADesc,
bool transposeA,
TensorDesc matrixBDesc,
bool transposeB,
U32 *bytes,
ForwardRunInfoMali_t forwardRunInfo)
{
UNUSED(matrixADesc);
UNUSED(transposeA);
UNUSED(matrixBDesc);
UNUSED(transposeB);
UNUSED(forwardRunInfo);
*bytes = 0;
return SUCCESS;
}
EE matmul_mali_fp16(GCLHandle_t handle,
TensorDesc matrixADesc,
bool transposeA,
const GCLMem_t matrixA,
TensorDesc matrixBDesc,
bool transposeB,
const GCLMem_t matrixB,
GCLMem_t tmp,
TensorDesc matrixCDesc,
GCLMem_t matrixC,
ForwardRunInfoMali_t forwardRunInfo)
{
CHECK_STATUS(matmul_checkpara_mali_fp16(matrixADesc, matrixBDesc, matrixCDesc));
CHECK_STATUS(fill_output_zero(handle, matrixC, matrixCDesc));
CHECK_STATUS(matmul_core_mali_fp16(handle, matrixADesc, transposeA, matrixA, matrixBDesc,
transposeB, matrixB, tmp, matrixCDesc, matrixC, forwardRunInfo));
return SUCCESS;
}
| 39.136364 | 149 | 0.642535 | ysh329 |
e9b8592556b593f91d4c5c6db852c2a33f897a95 | 608 | cc | C++ | src/plugin/graphics/3d/src/shader/shader.cc | motor-dev/Motor | 98cb099fe1c2d31e455ed868cc2a25eae51e79f0 | [
"BSD-3-Clause"
] | null | null | null | src/plugin/graphics/3d/src/shader/shader.cc | motor-dev/Motor | 98cb099fe1c2d31e455ed868cc2a25eae51e79f0 | [
"BSD-3-Clause"
] | null | null | null | src/plugin/graphics/3d/src/shader/shader.cc | motor-dev/Motor | 98cb099fe1c2d31e455ed868cc2a25eae51e79f0 | [
"BSD-3-Clause"
] | null | null | null | /* Motor <motor.devel@gmail.com>
see LICENSE for detail */
#include <motor/plugin.graphics.3d/stdafx.h>
#include <motor/plugin.graphics.3d/shader/ishaderbuilder.hh>
#include <motor/plugin.graphics.3d/shader/shader.meta.hh>
#include <motor/plugin.graphics.3d/shader/types.meta.hh>
namespace Motor {
ShaderProgramDescription::ShaderProgramDescription(minitl::vector< ref< Shaders::Output > > outputs)
: m_outputs(outputs)
{
}
ShaderProgramDescription::~ShaderProgramDescription()
{
}
void ShaderProgramDescription::buildSource(Shaders::IShaderBuilder& /*builder*/) const
{
}
} // namespace Motor
| 24.32 | 100 | 0.764803 | motor-dev |
e9ba8ae7ee0dc7b184cda9f5193bce46908d91e3 | 4,414 | cpp | C++ | src/guo_hall_thinning.cpp | ericdanz/rgb_line_follower | 89e534301e1c4dd83649b0fa750d5f808caa2df8 | [
"BSD-3-Clause"
] | null | null | null | src/guo_hall_thinning.cpp | ericdanz/rgb_line_follower | 89e534301e1c4dd83649b0fa750d5f808caa2df8 | [
"BSD-3-Clause"
] | null | null | null | src/guo_hall_thinning.cpp | ericdanz/rgb_line_follower | 89e534301e1c4dd83649b0fa750d5f808caa2df8 | [
"BSD-3-Clause"
] | null | null | null | /*
* \guo_hall_thinning.cpp
* \takes a image and converts it to a trajectory for the robot to follow
*
* \author Chris Dunkers, CMU - cmdunkers@cmu.edu
* \date October 31, 2014
*/
#include "rgb_line_follower/guo_hall_thinning.h"
convert_to_line::convert_to_line(){
//the main node handle
ros::NodeHandle nh;
//grab the parameters
ros::NodeHandle private_node_handle_("~");
private_node_handle_.param<std::string>("image_topic_thinning", image_topic, "/image_hsv");
//initialize the publishers and subscribers
image_pub = nh.advertise<sensor_msgs::Image>("image_thin", 1000);
image_sub = nh.subscribe(image_topic, 1000, &convert_to_line::update_image, this);
// min and max hsv values values
cv::namedWindow(OPENCV_WINDOW);
}
convert_to_line::~convert_to_line(){
cv::destroyWindow(OPENCV_WINDOW);
}
void convert_to_line::update_image(const sensor_msgs::Image::ConstPtr& img_msg){
cv_bridge::CvImagePtr cv_ptr;
try
{
cv_ptr = cv_bridge::toCvCopy(img_msg, sensor_msgs::image_encodings::BGR8);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
cv_ptr->image.copyTo(thin_image);
frame = img_msg->header.frame_id;
//run the thinning algorithm
//cv::Mat ThinImage;
//cv::cvtColor(cv_ptr->image, ThinImage, CV_BGR2GRAY);
//thinningGuoHall(ThinImage);
//make the cv image to a ros message
//cv_bridge::CvImage out_msg;
//out_msg.header.frame_id = img_msg->header.frame_id; // Same tf frame as input image
//out_msg.header.stamp = ros::Time::now();
//out_msg.encoding = sensor_msgs::image_encodings::MONO8; // black and white
//out_msg.image = ThinImage; //cv::Mat image
//image_pub.publish(out_msg.toImageMsg());
}
void convert_to_line::make_thin_image(){
if (!thin_image.empty()) {
cv::Mat ThinImage;
cv::cvtColor(thin_image, ThinImage, CV_BGR2GRAY);
thinningGuoHall(ThinImage);
//make the cv image to a ros message
cv_bridge::CvImage out_msg;
out_msg.header.frame_id = frame; // Same tf frame as input image
out_msg.header.stamp = ros::Time::now();
out_msg.encoding = sensor_msgs::image_encodings::MONO8; // black and white
out_msg.image = ThinImage; //cv::Mat image
image_pub.publish(out_msg.toImageMsg());
}
}
/**
* Perform one thinning iteration.
* Normally you wouldn't call this function directly from your code.
*
* @param im Binary image with range = 0-1
* @param iter 0=even, 1=odd
*/
void thinningGuoHallIteration(cv::Mat& im, int iter)
{
cv::Mat marker = cv::Mat::zeros(im.size(), CV_8UC1);
for (int i = 1; i < im.rows; i++)
{
for (int j = 1; j < im.cols; j++)
{
uchar p2 = im.at<uchar>(i-1, j);
uchar p3 = im.at<uchar>(i-1, j+1);
uchar p4 = im.at<uchar>(i, j+1);
uchar p5 = im.at<uchar>(i+1, j+1);
uchar p6 = im.at<uchar>(i+1, j);
uchar p7 = im.at<uchar>(i+1, j-1);
uchar p8 = im.at<uchar>(i, j-1);
uchar p9 = im.at<uchar>(i-1, j-1);
int C = (!p2 & (p3 | p4)) + (!p4 & (p5 | p6)) +
(!p6 & (p7 | p8)) + (!p8 & (p9 | p2));
int N1 = (p9 | p2) + (p3 | p4) + (p5 | p6) + (p7 | p8);
int N2 = (p2 | p3) + (p4 | p5) + (p6 | p7) + (p8 | p9);
int N = N1 < N2 ? N1 : N2;
int m = iter == 0 ? ((p6 | p7 | !p9) & p8) : ((p2 | p3 | !p5) & p4);
if (C == 1 && (N >= 2 && N <= 3) & m == 0)
marker.at<uchar>(i,j) = 1;
}
}
im &= ~marker;
}
/**
* Function for thinning the given binary image
*
* @param im Binary image with range = 0-255
*/
void thinningGuoHall(cv::Mat& im)
{
im /= 255;
cv::Mat prev = cv::Mat::zeros(im.size(), CV_8UC1);
cv::Mat diff;
do {
thinningGuoHallIteration(im, 0);
thinningGuoHallIteration(im, 1);
cv::absdiff(im, prev, diff);
im.copyTo(prev);
}
while (cv::countNonZero(diff) > 0);
im *= 255;
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "guo_hall_thining_algorithm");
convert_to_line img_to_line = convert_to_line();
ROS_INFO("guo hall thinning node started!");
ros::Rate loop_rate(10);
while (ros::ok())
{
img_to_line.make_thin_image();
ros::spinOnce();
loop_rate.sleep();
}
return 0;
}
| 27.416149 | 93 | 0.600362 | ericdanz |
e9baa7e515d37dfc4be9c540fb0bcf15835f58d1 | 4,224 | cpp | C++ | utilities/analog_random.cpp | jamessynge/arduino | 082ede0532f667b65c711ab2e56e0f7e6fb29f52 | [
"MIT"
] | null | null | null | utilities/analog_random.cpp | jamessynge/arduino | 082ede0532f667b65c711ab2e56e0f7e6fb29f52 | [
"MIT"
] | 1 | 2019-11-15T20:26:00.000Z | 2019-11-15T20:26:00.000Z | utilities/analog_random.cpp | jamessynge/arduino | 082ede0532f667b65c711ab2e56e0f7e6fb29f52 | [
"MIT"
] | 1 | 2019-10-05T13:05:34.000Z | 2019-10-05T13:05:34.000Z | #include "analog_random.h"
#include "Arduino.h"
// The analog pin identifiers A0, etc., don't have values matching the number
// that is in their name (i.e. A0 != 0). So we build up a table mapping from pin
// number (0, 1, ...) to the corresponding pin identifier (A0, A1, ...).
// As of this writing (March, 2019), the Arduino reference states that the board
// the the greatest number of analog pins has A0 through A14.
static const int kAnalogPinTable[] = {
A0, A1, A2,
#if NUM_ANALOG_INPUTS > 3
A3,
#endif
#if NUM_ANALOG_INPUTS > 4
A4,
#endif
#if NUM_ANALOG_INPUTS > 5
A5,
#endif
#if NUM_ANALOG_INPUTS > 6
A6,
#endif
#if NUM_ANALOG_INPUTS > 7
A7,
#endif
#if NUM_ANALOG_INPUTS > 8
A8,
#endif
#if NUM_ANALOG_INPUTS > 9
A9,
#endif
#if NUM_ANALOG_INPUTS > 10
A10,
#endif
#if NUM_ANALOG_INPUTS > 11
A11,
#endif
#if NUM_ANALOG_INPUTS > 12
A12,
#endif
#if NUM_ANALOG_INPUTS > 13
A13,
#endif
#if NUM_ANALOG_INPUTS > 14
A14,
#endif
};
constexpr int kNumAnalogPins =
sizeof kAnalogPinTable / sizeof kAnalogPinTable[0];
// We store next_pin_ in a byte, so make sure we don't have too many pins.
static_assert(kNumAnalogPins <= 256, "Too many pins!");
int AnalogRandom::randomBit(int readLimit) {
// Produce a single random bit by reading from an unreliable source of data,
// the analog pins of the Arduino. We treat them as a source of biased bits,
// taking only the low bit of each reading, as it will be the least stable
// even when reading a pin that is hooked up to a fairly stable voltage). The
// idea is that we can "debias" a biased source of numbers (e.g. an unfair
// coin) by taking two readings of the source at a time rather than one, each
// reading producing 1 bit. Our action table is:
//
// 0,0: Try again
// 0,1: Output a 1
// 1,0, Output a 0
// 1,1: Try again.
//
// We don't know what is hooked up to our analog pins, so it is possible that
// there is more correlation on some pins than on others (e.g. a slowly rising
// voltage, which might result in toggling back and forth between producing a
// 0 and a 1), so each pair of values is read from a different pins. We
// cycling through all the pin identifiers in kAnalogPinTable before starting
// over.
//
// This is based on:
// http://www.utopiamechanicus.com/article/better-arduino-random-numbers/
// which in turn is based on earlier work, at least back to Alan Turing.
// I first read about this in either C/C++ Users Journal or Dr. Dobbs,
// but haven't found the original reference.
do {
// Cycle through the pin numbers.
int pinNum = next_pin_++ % kNumAnalogPins;
if (next_pin_ >= kNumAnalogPins) {
next_pin_ = next_pin_ % kNumAnalogPins;
}
// Translate from pin number to pin identifier (e.g. from 3 to A3).
int pinId = kAnalogPinTable[pinNum];
// Read the analog pin twice, keeping just the low order bit each time.
int bit0 = analogRead(pinId) & 1;
int bit1 = analogRead(pinId) & 1;
// And if they are different, output bit1.
if (bit1 != bit0) {
return bit1;
}
// Not different, so we'll try again until we've called analogRead at
// least readLimit times.
readLimit -= 2;
} while (readLimit > 0);
// Not good, didn't find enough randomness.
return -1;
}
int AnalogRandom::randomByte(int perBitReadLimit) {
uint32_t result;
if (randomBits(8, perBitReadLimit, &result)) {
return result & 0xff;
} else {
return -1;
}
}
uint32_t AnalogRandom::random32(int perBitReadLimit) {
uint32_t result;
if (randomBits(32, perBitReadLimit, &result)) {
return result;
} else {
return 0;
}
}
bool AnalogRandom::randomBits(int numBits, int perBitReadLimit, uint32_t* output) {
uint32_t result = 0;
for (int i = 0; i < numBits; ++i) {
int bit = randomBit(perBitReadLimit);
if (bit < 0) {
// Not enough randomness found to produce a single bit.
return false;
}
result = (result << 1) | bit;
}
*output = result;
return true;
}
bool AnalogRandom::seedArduinoRNG() {
uint32_t seed = random32();
if (seed != 0) {
randomSeed(seed);
return true;
} else {
return false;
}
}
| 28.931507 | 83 | 0.670691 | jamessynge |
e9bb3e6703c393cce61ebb3097f41be8c021c38c | 585 | cpp | C++ | src/main.cpp | philong6297/tetravex-solver | 3d427f00a697c22c2231c57445140c7f1bb76572 | [
"MIT"
] | null | null | null | src/main.cpp | philong6297/tetravex-solver | 3d427f00a697c22c2231c57445140c7f1bb76572 | [
"MIT"
] | null | null | null | src/main.cpp | philong6297/tetravex-solver | 3d427f00a697c22c2231c57445140c7f1bb76572 | [
"MIT"
] | null | null | null | #include <iostream>
#include "engine/game_generator.h"
#include "solver/solver.h"
int main() {
std::ios::sync_with_stdio(false);
// absolute dir = full name of the path
Game game = GameGenerator::ReadFromFile("D:/cpp-projects/tetravex-solver/data/6x6.txt");
// {
// Solver solver;
// std::cout << "sequential:\n";
// solver.SequentialBacktracking(game);
// }
{
ThreadPool pool(std::thread::hardware_concurrency());
std::cout << "parallel:\n";
Solver solver;
solver.ParallelBacktracking(game, pool);
}
return 0;
}
| 23.4 | 91 | 0.62735 | philong6297 |
e9bca392665c427444ae656aca0eecf95dfb1c26 | 379 | cpp | C++ | src/core/core_render.cpp | RichardMarks/allegro-5-project-template | cdeb83a5eecf70d43e89f31ed7f56d87b00745c8 | [
"MIT"
] | null | null | null | src/core/core_render.cpp | RichardMarks/allegro-5-project-template | cdeb83a5eecf70d43e89f31ed7f56d87b00745c8 | [
"MIT"
] | null | null | null | src/core/core_render.cpp | RichardMarks/allegro-5-project-template | cdeb83a5eecf70d43e89f31ed7f56d87b00745c8 | [
"MIT"
] | null | null | null | #include "core.h"
bool core_render() {
// printf("core_render()\n");
if (__CoreGlobals__.Redraw && al_is_event_queue_empty(__CoreGlobals__.Queue)) {
__CoreGlobals__.Redraw = false;
al_set_target_bitmap(__CoreGlobals__.DisplayBuffer);
al_clear_to_color(al_map_rgb(0, 0, 0)); // FIXME: should use a global background color
return true;
}
return false;
}
| 25.266667 | 90 | 0.717678 | RichardMarks |
e9bca8c576562c4aca5fcf476011b27c3163db43 | 2,453 | cpp | C++ | tests/satparser_tests.cpp | Ezibenroc/satsolver | 5f58b8f9502090f05cbc2351304a289530b74f63 | [
"MIT"
] | 1 | 2017-11-29T00:46:23.000Z | 2017-11-29T00:46:23.000Z | tests/satparser_tests.cpp | Ezibenroc/satsolver | 5f58b8f9502090f05cbc2351304a289530b74f63 | [
"MIT"
] | null | null | null | tests/satparser_tests.cpp | Ezibenroc/satsolver | 5f58b8f9502090f05cbc2351304a289530b74f63 | [
"MIT"
] | null | null | null | #include <sstream>
#include <iostream>
#include <cppunit/Test.h>
#include <cppunit/TestFixture.h>
#include <cppunit/TestAssert.h>
#include <cppunit/TestSuite.h>
#include <cppunit/TestCaller.h>
#include "parsers/sat.h"
#include "satparser_tests.h"
void SatParserTests::testBasic() {
std::istringstream stream("p cnf 5 3\n3 0\n1 2 4 0\n5 1 0\n");
std::istringstream &stream2 = stream;
std::vector<std::shared_ptr<satsolver::Clause>> clauses;
std::set<std::set<int>> clauses_set;
std::shared_ptr<satsolver::Formula> formula;
satsolver::SatParser *parser;
parser = new satsolver::SatParser(stream2);
CPPUNIT_ASSERT_NO_THROW(parser->parse());
clauses = parser->get_clauses();
CPPUNIT_ASSERT(clauses[0]->to_set() == std::set<int>({3}));
CPPUNIT_ASSERT(clauses[1]->to_set() == std::set<int>({1, 2, 4}));
CPPUNIT_ASSERT(clauses[2]->to_set() == std::set<int>({1, 5}));
CPPUNIT_ASSERT(clauses[0]->to_set() == std::set<int>({3}));
formula = parser->get_formula();
//clauses_set.insert(clauses[0]->to_set()); -> deleted by pretreatment in formula instanciation
clauses_set.insert(clauses[1]->to_set());
clauses_set.insert(clauses[2]->to_set());
CPPUNIT_ASSERT(formula->to_set() == clauses_set);
std::set<int> *set = formula->get_aff()->to_set();
CPPUNIT_ASSERT(*set == std::set<int>({3}));
delete parser;
delete set;
}
void SatParserTests::testExtraWhitespaces() {
std::istringstream stream("c 0 foo bar\np cnf 5 3\n3 0\n\n\n1 2 4 0\nc oof\n5 1 0\n");
std::istringstream &stream2 = stream;
std::vector<std::shared_ptr<satsolver::Clause>> clauses;
satsolver::SatParser *parser;
parser = new satsolver::SatParser(stream2);
CPPUNIT_ASSERT_NO_THROW(parser->parse());
clauses = parser->get_clauses();
CPPUNIT_ASSERT(clauses[0]->to_set() == std::set<int>({3}));
CPPUNIT_ASSERT(clauses[1]->to_set() == std::set<int>({1, 2, 4}));
CPPUNIT_ASSERT(clauses[2]->to_set() == std::set<int>({1, 5}));
delete parser;
}
CppUnit::Test* SatParserTests::suite() {
CppUnit::TestSuite *suite = new CppUnit::TestSuite("SatParserTests");
suite->addTest(new CppUnit::TestCaller<SatParserTests>("SatParserTest_testBasic",
&SatParserTests::testBasic));
suite->addTest(new CppUnit::TestCaller<SatParserTests>("SatParserTest_testExtraWhitespaces",
&SatParserTests::testExtraWhitespaces));
return suite;
}
| 40.883333 | 99 | 0.674684 | Ezibenroc |
e9be7c556e7b0c101995ed2f889771d2360dcade | 2,471 | cc | C++ | StRoot/StTrsMaker/src/StSimpleMagneticField.cc | xiaohaijin/RHIC-STAR | a305cb0a6ac15c8165bd8f0d074d7075d5e58752 | [
"MIT"
] | 2 | 2018-12-24T19:37:00.000Z | 2022-02-28T06:57:20.000Z | StRoot/StTrsMaker/src/StSimpleMagneticField.cc | xiaohaijin/RHIC-STAR | a305cb0a6ac15c8165bd8f0d074d7075d5e58752 | [
"MIT"
] | null | null | null | StRoot/StTrsMaker/src/StSimpleMagneticField.cc | xiaohaijin/RHIC-STAR | a305cb0a6ac15c8165bd8f0d074d7075d5e58752 | [
"MIT"
] | null | null | null | /***************************************************************************
*
* $Id: StSimpleMagneticField.cc,v 1.5 2012/06/11 15:04:55 fisyak Exp $
*
* Author: Thomas Ullrich, May 1998
***************************************************************************
*
* Description: Class is implemented as a Singleton
*
***************************************************************************
*
* $Log: StSimpleMagneticField.cc,v $
* Revision 1.5 2012/06/11 15:04:55 fisyak
* std namespace
*
* Revision 1.4 1999/03/16 01:59:27 lasiuk
* Use Units at Initialization
*
* Revision 1.3 1999/03/15 13:45:44 lasiuk
* units consistency added here (tesla)
*
* Revision 1.2 1999/01/18 21:02:45 lasiuk
* comment diagnostics
*
* Revision 1.1 1998/11/10 17:12:20 fisyak
* Put Brian trs versin into StRoot
*
* Revision 1.2 1998/05/20 19:02:05 ullrich
* Renamed getInstance() to instance().
*
* Revision 1.1 1998/05/20 14:59:28 ullrich
* Initial Revision
*
**************************************************************************/
#include "StSimpleMagneticField.hh"
#include "StGetConfigValue.hh"
using namespace std;
StMagneticField* StSimpleMagneticField::mInstance = 0; // static member
StSimpleMagneticField::StSimpleMagneticField() {/* noop */}
StSimpleMagneticField::StSimpleMagneticField(const StThreeVector<double>& v)
: mB(v) {/* noop */}
StSimpleMagneticField::StSimpleMagneticField(const char* filename)
{
StGetConfigValue(filename, "StSimpleMagneticField.mB", mB);
//PR(mB);
// Make sure units are correct
mB *= tesla;
PR(mB/tesla);
}
StSimpleMagneticField::~StSimpleMagneticField() {/* noop */}
StMagneticField*
StSimpleMagneticField::instance(const StThreeVector<double>& B)
{
if (mInstance == 0)
mInstance = new StSimpleMagneticField(B);
else {
cerr << "StSimpleMagneticField::getInstance(): " << endl;
cerr << "\tWARNING" << endl;
cerr << "\tSingleton class is already instantiated." << endl;
cerr << "\tArgument (StThreeVector) is ignored." << endl;
}
return mInstance;
}
StMagneticField* StSimpleMagneticField::instance(const char* file)
{
if (mInstance == 0)
mInstance = new StSimpleMagneticField(file);
else {
cerr << "StSimpleMagneticField::getInstance(): " << endl;
cerr << "\tWARNING" << endl;
cerr << "\tSingleton class is already instantiated." << endl;
cerr << "\tArgument (const char*) is ignored." << endl;
}
return mInstance;
}
| 29.070588 | 76 | 0.603399 | xiaohaijin |
e9be9d0ab7adf2d26b5fd92d101e2fd841f88d42 | 1,354 | cpp | C++ | Algorithms/Warmup/TimeConversion.cpp | latimercaleb/hacker-rank-results | 2cb5e0eca306835eb7607c157f8ee8ee166d3630 | [
"MIT"
] | null | null | null | Algorithms/Warmup/TimeConversion.cpp | latimercaleb/hacker-rank-results | 2cb5e0eca306835eb7607c157f8ee8ee166d3630 | [
"MIT"
] | null | null | null | Algorithms/Warmup/TimeConversion.cpp | latimercaleb/hacker-rank-results | 2cb5e0eca306835eb7607c157f8ee8ee166d3630 | [
"MIT"
] | null | null | null | // https://www.hackerrank.com/challenges/time-conversion/problem
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <sstream>
#include<iomanip>
using namespace std;
int main(){
string time;
cin >> time;
char delim = ':';
stringstream newTime;
newTime << time;
int hours,minutes,seconds;
string ampm;
newTime >> hours;
newTime >> delim;
newTime>> minutes;
newTime >> delim;
newTime>> seconds;
newTime>> ampm;
if(ampm == "PM"){
switch(hours){
case 1:hours = 13;
break;
case 2:hours = 14;
break;
case 3:hours = 15;
break;
case 4:hours = 16;
break;
case 5:hours = 17;
break;
case 6:hours = 18;
break;
case 7:hours = 19;
break;
case 8:hours = 20;
break;
case 9:hours = 21;
break;
case 10:hours = 22;
break;
case 11:hours = 23;
break;
}
}
else if(ampm == "AM" && hours == 12 ){
hours = 0;
}
cout << setw(2)<< setfill('0') << hours << ":" << setw(2)<< setfill('0') << minutes << ":" << setw(2)<< setfill('0') << seconds << endl;
return 0;
}
| 23.344828 | 141 | 0.474151 | latimercaleb |
e9c9c5a72f7134523d50bff6723e2e9bac9f5ab4 | 2,280 | cpp | C++ | hamonize-admin/server/src/VeyonServerProtocol.cpp | bsairline/hamonize | 6632d93b0149ed300d12c4eeb06cfc4fb01fce92 | [
"Apache-2.0"
] | null | null | null | hamonize-admin/server/src/VeyonServerProtocol.cpp | bsairline/hamonize | 6632d93b0149ed300d12c4eeb06cfc4fb01fce92 | [
"Apache-2.0"
] | 1 | 2022-03-25T19:24:44.000Z | 2022-03-25T19:24:44.000Z | hamonize-admin/server/src/VeyonServerProtocol.cpp | gon1942/hamonize | 0456d934569ad664e9f71c6355424426654caabf | [
"Apache-2.0",
"MIT"
] | null | null | null | /*
* VeyonServerProtocol.cpp - implementation of the VeyonServerProtocol class
*
* Copyright (c) 2017-2021 Tobias Junghans <tobydox@veyon.io>
*
* This file is part of Veyon - https://veyon.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "ServerAuthenticationManager.h"
#include "ServerAccessControlManager.h"
#include "VeyonServerProtocol.h"
VeyonServerProtocol::VeyonServerProtocol( QTcpSocket* socket,
VncServerClient* client,
ServerAuthenticationManager& serverAuthenticationManager,
ServerAccessControlManager& serverAccessControlManager ) :
VncServerProtocol( socket, client ),
m_serverAuthenticationManager( serverAuthenticationManager ),
m_serverAccessControlManager( serverAccessControlManager )
{
}
QVector<RfbVeyonAuth::Type> VeyonServerProtocol::supportedAuthTypes() const
{
return m_serverAuthenticationManager.supportedAuthTypes();
}
void VeyonServerProtocol::processAuthenticationMessage(VariantArrayMessage &message)
{
m_serverAuthenticationManager.processAuthenticationMessage( client(), message );
}
void VeyonServerProtocol::performAccessControl()
{
// perform access control via ServerAccessControl manager if either
// client just entered access control or is still waiting to be
// processed (e.g. desktop access dialog already active for a different connection)
if( client()->accessControlState() == VncServerClient::AccessControlState::Init ||
client()->accessControlState() == VncServerClient::AccessControlState::Waiting )
{
m_serverAccessControlManager.addClient( client() );
}
}
| 34.029851 | 84 | 0.771491 | bsairline |
e9cc92831ba96d53b71b6a3c19769aa3eec198d4 | 1,317 | hpp | C++ | src/osm_node_wrap.hpp | simonpoole/node-osmium | 379bc61c2584e6fb441ee37f37af34aea97213dd | [
"BSL-1.0"
] | 104 | 2015-02-02T19:05:38.000Z | 2021-04-25T19:54:46.000Z | src/osm_node_wrap.hpp | simonpoole/node-osmium | 379bc61c2584e6fb441ee37f37af34aea97213dd | [
"BSL-1.0"
] | 75 | 2015-01-10T02:04:18.000Z | 2021-08-16T07:15:36.000Z | src/osm_node_wrap.hpp | simonpoole/node-osmium | 379bc61c2584e6fb441ee37f37af34aea97213dd | [
"BSL-1.0"
] | 29 | 2015-01-21T19:32:58.000Z | 2022-03-28T16:08:28.000Z | #ifndef OSM_NODE_WRAP_HPP
#define OSM_NODE_WRAP_HPP
#include "include_nan.hpp"
// osmium
#include <osmium/osm/node.hpp>
namespace osmium {
class OSMEntity;
}
// node-osmium
#include "node_osmium.hpp"
#include "osm_entity_wrap.hpp"
#include "osm_object_wrap.hpp"
#include "utils.hpp"
namespace node_osmium {
class OSMNodeWrap : public OSMWrappedObject {
static NAN_GETTER(get_type) {
info.GetReturnValue().Set(Nan::New(symbol_node));
}
static NAN_GETTER(get_coordinates);
static NAN_GETTER(get_lon);
static NAN_GETTER(get_lat);
static NAN_METHOD(wkb);
static NAN_METHOD(wkt);
public:
static Nan::Persistent<v8::FunctionTemplate> constructor;
static void Initialize(v8::Local<v8::Object> target);
static NAN_METHOD(New);
static const osmium::Node& wrapped(const v8::Local<v8::Object>& object) {
return static_cast<const osmium::Node&>(unwrap<OSMEntityWrap>(object));
}
OSMNodeWrap() :
OSMWrappedObject() {
}
OSMNodeWrap(const osmium::OSMEntity& entity) :
OSMWrappedObject(entity) {
}
private:
~OSMNodeWrap() = default;
}; // class OSMNodeWrap
} // namespace node_osmium
#endif // OSM_NODE_WRAP_HPP
| 22.322034 | 83 | 0.645406 | simonpoole |
e9ccc3114f817b50f91137b8ae6c9157045f0c5a | 441 | cpp | C++ | Acrolinx.Sidebar.SDK/COMInstanceMngr.cpp | acrolinx/sidebar-sdk-cpp | c2e640f9f512934162337704be062fc2e16e4ed9 | [
"Apache-2.0"
] | null | null | null | Acrolinx.Sidebar.SDK/COMInstanceMngr.cpp | acrolinx/sidebar-sdk-cpp | c2e640f9f512934162337704be062fc2e16e4ed9 | [
"Apache-2.0"
] | null | null | null | Acrolinx.Sidebar.SDK/COMInstanceMngr.cpp | acrolinx/sidebar-sdk-cpp | c2e640f9f512934162337704be062fc2e16e4ed9 | [
"Apache-2.0"
] | null | null | null | #include "StdAfx.h"
#include "COMInstanceMngr.h"
CCOMInstanceMngr::CCOMInstanceMngr(void)
: m_isInstanceCreated(FALSE)
{
}
CCOMInstanceMngr::~CCOMInstanceMngr(void)
{
}
BOOL CCOMInstanceMngr::Instantiate(void)
{
if(m_isInstanceCreated)
{
ACROASSERT(m_isInstanceCreated == FALSE, "Instance already exists");
return FALSE;
}
else
{
m_isInstanceCreated = TRUE;
return TRUE;
}
}
| 15.206897 | 76 | 0.662132 | acrolinx |
e9cef0ce617b376f774209bba0f60b265ca0cfa1 | 179 | cpp | C++ | cmake/localeconv.cpp | sniperkit/snk.fork.drishti_hunter_test | 106c4924930290928a0e350a9f8b54ea39a8c40d | [
"BSD-3-Clause"
] | 346 | 2017-05-13T05:12:51.000Z | 2022-01-31T08:57:14.000Z | cmake/localeconv.cpp | sniperkit/snk.fork.drishti_hunter_test | 106c4924930290928a0e350a9f8b54ea39a8c40d | [
"BSD-3-Clause"
] | 238 | 2017-05-12T20:22:26.000Z | 2021-06-08T20:54:11.000Z | cmake/localeconv.cpp | sniperkit/snk.fork.drishti_hunter_test | 106c4924930290928a0e350a9f8b54ea39a8c40d | [
"BSD-3-Clause"
] | 84 | 2017-06-30T06:50:56.000Z | 2022-03-24T01:21:54.000Z | /* localeconv example */
#include <locale.h> /* setlocale, LC_MONETARY, struct lconv, localeconv */
int main ()
{
struct lconv * lc;
lc=localeconv();
return 0;
}
| 17.9 | 78 | 0.620112 | sniperkit |
83980baa8d1290fd029bca8e886690c355532cd0 | 974 | cc | C++ | vos/p2/sub/tp_cmd/TpQuitCmd.cc | NASA-AMMOS/VICAR | 4504c1f558855d9c6eaef89f4460217aa4909f8e | [
"BSD-3-Clause"
] | 16 | 2020-10-21T05:56:26.000Z | 2022-03-31T10:02:01.000Z | vos/p2/sub/tp_cmd/TpQuitCmd.cc | NASA-AMMOS/VICAR | 4504c1f558855d9c6eaef89f4460217aa4909f8e | [
"BSD-3-Clause"
] | null | null | null | vos/p2/sub/tp_cmd/TpQuitCmd.cc | NASA-AMMOS/VICAR | 4504c1f558855d9c6eaef89f4460217aa4909f8e | [
"BSD-3-Clause"
] | 2 | 2021-03-09T01:51:08.000Z | 2021-03-23T00:23:24.000Z | /////////////////////////////////////////////////////////////////////////////
// TpQuitCmd.cc: Exit the application if there is no tiepoint file to save.
// Otherwise execute TpCloseCmd and provide it with 'this' pointer so that
// TpCloseCmd object could call us again when it is done with closing project.
//////////////////////////////////////////////////////////////////////////////
// Vadim Parizher - July 1997 JPL
//////////////////////////////////////////////////////////////////////////////
#include "TpQuitCmd.h"
#include "TpMatchManager.h"
#include "TpCloseCmd.h"
#include "TpApplication.h"
TpQuitCmd::TpQuitCmd(const char *name, int active, TpMatchManager *mm)
: NoUndoCmd(name, active)
{
_matchManager = mm;
}
void TpQuitCmd::doit()
{
if (_matchManager->isDirty()) {
Cmd *saveCmd = new TpCloseCmd ("close", True,
_matchManager, (Cmd *)this);
saveCmd->execute();
}
else {
exit(theTpApplication->getExitStatus());
}
}
| 31.419355 | 78 | 0.526694 | NASA-AMMOS |
8399c01ccfa2859713571d9b22bf725093207988 | 4,794 | cpp | C++ | src/debugger/breakpoint_break.cpp | sar/netcoredbg | c9b95f74452d3ac58ebe6642f64143fbe225df83 | [
"MIT"
] | 402 | 2017-12-12T13:12:39.000Z | 2022-03-28T01:43:25.000Z | src/debugger/breakpoint_break.cpp | sar/netcoredbg | c9b95f74452d3ac58ebe6642f64143fbe225df83 | [
"MIT"
] | 83 | 2018-01-10T16:23:43.000Z | 2022-03-22T07:25:42.000Z | src/debugger/breakpoint_break.cpp | sar/netcoredbg | c9b95f74452d3ac58ebe6642f64143fbe225df83 | [
"MIT"
] | 66 | 2018-01-10T10:39:59.000Z | 2022-03-27T15:55:10.000Z | // Copyright (c) 2021 Samsung Electronics Co., LTD
// Distributed under the MIT License.
// See the LICENSE file in the project root for more information.
#include "debugger/breakpoint_break.h"
#include "debugger/threads.h"
#include "metadata/modules.h"
#include "utils/torelease.h"
namespace netcoredbg
{
HRESULT BreakBreakpoint::GetFullyQualifiedIlOffset(ICorDebugThread *pThread, FullyQualifiedIlOffset_t &fullyQualifiedIlOffset)
{
HRESULT Status;
ToRelease<ICorDebugFrame> pFrame;
IfFailRet(pThread->GetActiveFrame(&pFrame));
if (pFrame == nullptr)
return E_FAIL;
mdMethodDef methodToken;
IfFailRet(pFrame->GetFunctionToken(&methodToken));
ToRelease<ICorDebugFunction> pFunc;
IfFailRet(pFrame->GetFunction(&pFunc));
ToRelease<ICorDebugModule> pModule;
IfFailRet(pFunc->GetModule(&pModule));
CORDB_ADDRESS modAddress;
IfFailRet(pModule->GetBaseAddress(&modAddress));
ToRelease<ICorDebugILFrame> pILFrame;
IfFailRet(pFrame->QueryInterface(IID_ICorDebugILFrame, (LPVOID*) &pILFrame));
ULONG32 ilOffset;
CorDebugMappingResult mappingResult;
IfFailRet(pILFrame->GetIP(&ilOffset, &mappingResult));
fullyQualifiedIlOffset.modAddress = modAddress;
fullyQualifiedIlOffset.methodToken = methodToken;
fullyQualifiedIlOffset.ilOffset = ilOffset;
return S_OK;
}
void BreakBreakpoint::SetLastStoppedIlOffset(ICorDebugProcess *pProcess, const ThreadId &lastStoppedThreadId)
{
std::lock_guard<std::mutex> lock(m_breakMutex);
m_lastStoppedIlOffset.Reset();
if (lastStoppedThreadId == ThreadId::AllThreads)
return;
ToRelease<ICorDebugThread> pThread;
if (SUCCEEDED(pProcess->GetThread(int(lastStoppedThreadId), &pThread)))
GetFullyQualifiedIlOffset(pThread, m_lastStoppedIlOffset);
}
HRESULT BreakBreakpoint::ManagedCallbackBreak(ICorDebugThread *pThread, const ThreadId &lastStoppedThreadId)
{
HRESULT Status;
ToRelease<ICorDebugFrame> iCorFrame;
IfFailRet(pThread->GetActiveFrame(&iCorFrame));
// Ignore break on Break() outside of code with loaded PDB (see JMC setup during module load).
if (iCorFrame != nullptr)
{
ToRelease<ICorDebugFunction> iCorFunction;
IfFailRet(iCorFrame->GetFunction(&iCorFunction));
ToRelease<ICorDebugFunction2> iCorFunction2;
IfFailRet(iCorFunction->QueryInterface(IID_ICorDebugFunction2, (LPVOID*) &iCorFunction2));
BOOL JMCStatus;
IfFailRet(iCorFunction2->GetJMCStatus(&JMCStatus));
if (JMCStatus == FALSE)
return S_OK;
}
ThreadId threadId(getThreadId(pThread));
// Prevent stop event duplicate, if previous stop event was for same thread and same code point.
// The idea is - store "fully qualified IL offset" (data for module + method + IL) on any stop event
// and only at Break() callback check the real sequence point (required delegate call).
// Note, that step/breakpoint/etc stop event at "Debugger.Break()" source line and stop event
// generated by CoreCLR during Debugger.Break() execution in managed code have different IL offsets,
// but same sequence point.
std::lock_guard<std::mutex> lock(m_breakMutex);
if (threadId != lastStoppedThreadId ||
m_lastStoppedIlOffset.modAddress == 0 ||
m_lastStoppedIlOffset.methodToken == 0)
return S_FALSE;
FullyQualifiedIlOffset_t fullyQualifiedIlOffset;
IfFailRet(GetFullyQualifiedIlOffset(pThread, fullyQualifiedIlOffset));
if (fullyQualifiedIlOffset.modAddress == 0 ||
fullyQualifiedIlOffset.methodToken == 0 ||
fullyQualifiedIlOffset.modAddress != m_lastStoppedIlOffset.modAddress ||
fullyQualifiedIlOffset.methodToken != m_lastStoppedIlOffset.methodToken)
return S_FALSE;
Modules::SequencePoint lastSP;
IfFailRet(m_sharedModules->GetSequencePointByILOffset(m_lastStoppedIlOffset.modAddress, m_lastStoppedIlOffset.methodToken,
m_lastStoppedIlOffset.ilOffset, lastSP));
Modules::SequencePoint curSP;
IfFailRet(m_sharedModules->GetSequencePointByILOffset(fullyQualifiedIlOffset.modAddress, fullyQualifiedIlOffset.methodToken,
fullyQualifiedIlOffset.ilOffset, curSP));
if (lastSP.startLine != curSP.startLine ||
lastSP.startColumn != curSP.startColumn ||
lastSP.endLine != curSP.endLine ||
lastSP.endColumn != curSP.endColumn ||
lastSP.offset != curSP.offset ||
lastSP.document != curSP.document)
return S_FALSE;
return S_OK;
}
} // namespace netcoredbg
| 38.047619 | 129 | 0.701293 | sar |
839aa948208c5719d99ba773ed28827aa0875089 | 1,315 | cpp | C++ | src/Core/Models/ShortId.cpp | Fookdies301/GrinPlusPlus | 981a99af0ae04633afbd02666894b5c199e06339 | [
"MIT"
] | 135 | 2018-12-17T15:38:16.000Z | 2022-03-01T05:38:29.000Z | src/Core/Models/ShortId.cpp | Fookdies301/GrinPlusPlus | 981a99af0ae04633afbd02666894b5c199e06339 | [
"MIT"
] | 185 | 2018-12-21T13:56:29.000Z | 2022-03-23T14:41:46.000Z | src/Core/Models/ShortId.cpp | Fookdies301/GrinPlusPlus | 981a99af0ae04633afbd02666894b5c199e06339 | [
"MIT"
] | 49 | 2018-12-23T12:05:51.000Z | 2022-03-26T14:24:49.000Z | #include <Core/Models/ShortId.h>
#include <Crypto/Hasher.h>
ShortId::ShortId(CBigInteger<6>&& id)
: m_id(id)
{
}
ShortId ShortId::Create(const CBigInteger<32>& hash, const CBigInteger<32>& blockHash, const uint64_t nonce)
{
// take the block hash and the nonce and hash them together
Serializer serializer;
serializer.AppendBigInteger<32>(blockHash);
serializer.Append<uint64_t>(nonce);
const CBigInteger<32> hashWithNonce = Hasher::Blake2b(serializer.GetBytes());
// extract k0/k1 from the block_hash
ByteBuffer byteBuffer(hashWithNonce.GetData());
const uint64_t k0 = byteBuffer.ReadU64_LE();
const uint64_t k1 = byteBuffer.ReadU64_LE();
// SipHash24 our hash using the k0 and k1 keys
const uint64_t sipHash = Hasher::SipHash24(k0, k1, hash.GetData());
// construct a short_id from the resulting bytes (dropping the 2 most significant bytes)
Serializer serializer2;
serializer2.AppendLittleEndian<uint64_t>(sipHash);
return ShortId(CBigInteger<6>(&serializer2.GetBytes()[0]));
}
void ShortId::Serialize(Serializer& serializer) const
{
serializer.AppendBigInteger<6>(m_id);
}
ShortId ShortId::Deserialize(ByteBuffer& byteBuffer)
{
CBigInteger<6> id = byteBuffer.ReadVector(6);
return ShortId(std::move(id));
}
Hash ShortId::GetHash() const
{
return Hasher::Blake2b(m_id.GetData());
} | 27.395833 | 108 | 0.756654 | Fookdies301 |
839ab305106ca145ed99a3a1a51b61938e5042db | 356 | cpp | C++ | 800-1000/1626A-Equidistant Letters.cpp | Ozzey/Codeforces | 36626f19382a08f54e66ade28431d7d440664e67 | [
"MIT"
] | 1 | 2022-02-11T16:38:52.000Z | 2022-02-11T16:38:52.000Z | 800-1000/1626A-Equidistant Letters.cpp | Ozzey/Codeforces | 36626f19382a08f54e66ade28431d7d440664e67 | [
"MIT"
] | null | null | null | 800-1000/1626A-Equidistant Letters.cpp | Ozzey/Codeforces | 36626f19382a08f54e66ade28431d7d440664e67 | [
"MIT"
] | null | null | null | // https://codeforces.com/problemset/problem/1626/A
#include <bits/stdc++.h>
using namespace std;
int fn(string str){
sort(str.begin(),str.end());
cout<<str<<endl;
return 0;
}
int main(){
int tc;
string s;
cin >> tc;
int count=0;
while(count<tc) {
cin>>s;
fn(s);
count++;
}
return 0;
}
| 13.185185 | 51 | 0.525281 | Ozzey |
83a17c4201313c1fea5af8dfe92af3133d1a8fd8 | 1,284 | hpp | C++ | include/brynet/net/wrapper/HttpServiceBuilder.hpp | mr-cn/brynet | 93ddf823ccc451b336cc5d78d636c75fd712ae59 | [
"MIT"
] | null | null | null | include/brynet/net/wrapper/HttpServiceBuilder.hpp | mr-cn/brynet | 93ddf823ccc451b336cc5d78d636c75fd712ae59 | [
"MIT"
] | null | null | null | include/brynet/net/wrapper/HttpServiceBuilder.hpp | mr-cn/brynet | 93ddf823ccc451b336cc5d78d636c75fd712ae59 | [
"MIT"
] | null | null | null | #pragma once
#include <brynet/net/http/HttpService.hpp>
#include <brynet/net/wrapper/ServiceBuilder.hpp>
namespace brynet { namespace net { namespace wrapper {
class HttpListenerBuilder : public BaseListenerBuilder<HttpListenerBuilder>
{
public:
HttpListenerBuilder& configureEnterCallback(http::HttpSession::EnterCallback&& callback)
{
mHttpEnterCallback = std::forward<http::HttpSession::EnterCallback>(callback);
return *this;
}
void asyncRun()
{
if (mHttpEnterCallback == nullptr)
{
throw BrynetCommonException("not setting http enter callback");
}
auto connectionOptions =
BaseListenerBuilder<HttpListenerBuilder>::getConnectionOptions();
auto callback = mHttpEnterCallback;
connectionOptions.push_back(
AddSocketOption::AddEnterCallback(
[callback](const TcpConnection::Ptr& session) {
http::HttpService::setup(session, callback);
}));
BaseListenerBuilder<HttpListenerBuilder>::asyncRun(connectionOptions);
}
private:
http::HttpSession::EnterCallback mHttpEnterCallback;
};
} } } | 32.923077 | 96 | 0.620717 | mr-cn |
83a2f83c46cd8f9206c79479e23b3c51629cfd60 | 1,032 | cpp | C++ | delta/dynamics/properties.cpp | KonstantinosKr/vega | 82ed6d98cbfdab8e143b7ccc59730af866d50225 | [
"MIT"
] | 4 | 2016-03-23T09:33:27.000Z | 2022-03-15T10:06:20.000Z | delta/dynamics/properties.cpp | KonstantinosKr/vega | 82ed6d98cbfdab8e143b7ccc59730af866d50225 | [
"MIT"
] | 1 | 2016-11-17T17:14:05.000Z | 2017-05-03T23:38:10.000Z | delta/dynamics/properties.cpp | KonstantinosKr/vega | 82ed6d98cbfdab8e143b7ccc59730af866d50225 | [
"MIT"
] | 1 | 2018-09-24T11:33:04.000Z | 2018-09-24T11:33:04.000Z | /*
* properties.cpp
*
* Created on: 17 Jun 2017
* Author: konstantinos
*/
#include "properties.h"
iREAL delta::dynamics::properties::getKineticRotationalEnergy(
iREAL velocity[3],
iREAL angular[3],
iREAL inertia[9],
iREAL mass)
{
iREAL rotation = 0.5 * inertia[0]*(angular[0]*angular[0])+0.5*inertia[4]*(angular[1]*angular[1])+0.5*inertia[4]*(angular[2]*angular[2]);
iREAL kinetic = 0.5 * mass*(velocity[0]*velocity[0])+(velocity[1]*velocity[1])+(velocity[2]*velocity[2]);
return rotation+kinetic;
}
iREAL delta::dynamics::properties::getKineticEnergy(
iREAL velocity[3],
iREAL mass)
{
iREAL kinetic = 0.5 * mass*(velocity[0]*velocity[0])+(velocity[1]*velocity[1])+(velocity[2]*velocity[2]);
return kinetic;
}
iREAL delta::dynamics::properties::getRotationalEnergy(
iREAL angular[3],
iREAL inertia[9])
{
iREAL rotation = 0.5 * inertia[0]*(angular[0]*angular[0])+0.5*inertia[4]*(angular[1]*angular[1])+0.5*inertia[4]*(angular[2]*angular[2]);
return rotation;
}
| 26.461538 | 138 | 0.662791 | KonstantinosKr |
83a80d6a3de3738253f89231fa5ed65d803f222c | 1,273 | cpp | C++ | cpp/problem067.cpp | curtislb/ProjectEuler | 7baf8d7b7ac0e8697d4dec03458b473095a45da4 | [
"MIT"
] | null | null | null | cpp/problem067.cpp | curtislb/ProjectEuler | 7baf8d7b7ac0e8697d4dec03458b473095a45da4 | [
"MIT"
] | null | null | null | cpp/problem067.cpp | curtislb/ProjectEuler | 7baf8d7b7ac0e8697d4dec03458b473095a45da4 | [
"MIT"
] | null | null | null | /*
* problem067.cpp
*
* Problem 67: Maximum path sum II
*
* By starting at the top of the triangle below and moving to adjacent numbers
* on the row below, the maximum total from top to bottom is 23.
*
* 3
* 7 4
* 2 4 6
* 8 5 9 3
*
* That is, 3 + 7 + 4 + 9 = 23.
*
* Find the maximum total from top to bottom in the triangle contained in the
* file INPUT_FILE.
*
* NOTE: This is a much more difficult version of Problem 18. It is not
* possible to try every route to solve this problem, as there are 2^99
* altogether! If you could check one trillion (10^12) routes every second it
* would take over twenty billion years to check them all. There is an
* efficient algorithm to solve it.
*
* Author: Curtis Belmonte
* Created: Aug 29, 2014
*/
#include <iostream>
#include <vector>
#include "common.h"
using namespace std;
/* PARAMETERS ****************************************************************/
static const char *IN_FILE = "../input/067.txt"; // default: "../input/067.txt"
/* SOLUTION ******************************************************************/
int main() {
vector<vector<long> > triangle = common::numbersFromFile(IN_FILE);
cout << common::maxTrianglePath(triangle) << endl;
return 0;
}
| 27.085106 | 79 | 0.595444 | curtislb |
83a862224907608ff44f9777f127ed24abdaa333 | 583 | cpp | C++ | project3D/main.cpp | deadglow/AIE-bootstrap-pathfinding | 158ee426f896413d47293f3803a1a7aae687da21 | [
"MIT"
] | 1 | 2022-02-16T20:45:04.000Z | 2022-02-16T20:45:04.000Z | project3D/main.cpp | deadglow/AIE-bootstrap-pathfinding | 158ee426f896413d47293f3803a1a7aae687da21 | [
"MIT"
] | null | null | null | project3D/main.cpp | deadglow/AIE-bootstrap-pathfinding | 158ee426f896413d47293f3803a1a7aae687da21 | [
"MIT"
] | null | null | null | //----------------------------------------------------------------------------
// This is the entry-point for your game.
// Creates and runs the Application3D class which contains the game loop.
//----------------------------------------------------------------------------
#include <crtdbg.h>
#include "Game3D.h"
int main()
{
// Check for memeory leaks.
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
// Create the Application.
Game3D* game = new Game3D("AIE", 1280, 720, false);
// Run the game loop.
game->Run();
// Clean up.
delete game;
return 0;
} | 25.347826 | 78 | 0.511149 | deadglow |
83ac69eeeba4b2f8da6447db9ab1b473e848e553 | 605 | cpp | C++ | src/library/BlackBox_Manager.cpp | RoboticsBrno/BlackBox_library | 2047f0102f1aacc780b8a7ba1d20da9dba3f63b4 | [
"MIT"
] | 1 | 2021-06-23T15:34:46.000Z | 2021-06-23T15:34:46.000Z | src/library/BlackBox_Manager.cpp | RoboticsBrno/BlackBox_library | 2047f0102f1aacc780b8a7ba1d20da9dba3f63b4 | [
"MIT"
] | 9 | 2020-03-09T19:50:34.000Z | 2021-07-18T12:06:11.000Z | src/library/BlackBox_Manager.cpp | RoboticsBrno/BlackBox_library | 2047f0102f1aacc780b8a7ba1d20da9dba3f63b4 | [
"MIT"
] | 1 | 2020-03-09T16:10:25.000Z | 2020-03-09T16:10:25.000Z | #include "library/BlackBox_Manager.hpp"
namespace BlackBox {
Manager::Manager()
: m_touchpad{16, 0b1110, 1, 1, 1, 1} { // FIXME: Remove this piece of ductape
}
void Manager::init() {
m_ldc.init();
m_lock.init();
m_power.init();
m_rtc.init();
m_touchpad.init(&m_ldc);
}
LDC& Manager::ldc() {
return m_ldc;
}
Lock& Manager::lock() {
return m_lock;
}
Power& Manager::power() {
return m_power;
}
Ring& Manager::ring() {
return m_ring;
}
RTC& Manager::rtc() {
return m_rtc;
}
Touchpad& Manager::touchpad() {
return m_touchpad;
}
} // namespace BlackBox
| 14.756098 | 81 | 0.621488 | RoboticsBrno |
83ad325f7cecdce7f7aef751aad06e5e892f081e | 1,999 | cpp | C++ | C++_-_opengl_samples/redbook/003_lines.cpp | RussianPenguin/samples | 4300c1423a5f9f5820a6c50a3fa3bd823d005030 | [
"MIT"
] | null | null | null | C++_-_opengl_samples/redbook/003_lines.cpp | RussianPenguin/samples | 4300c1423a5f9f5820a6c50a3fa3bd823d005030 | [
"MIT"
] | null | null | null | C++_-_opengl_samples/redbook/003_lines.cpp | RussianPenguin/samples | 4300c1423a5f9f5820a6c50a3fa3bd823d005030 | [
"MIT"
] | null | null | null | #include <GL/glut.h>
#define drawOneLine(x1,y1,x2,y2) glBegin(GL_LINES);glVertex2f((x1),(y1));glVertex2f((x2),(y2));glEnd();
void init(void){
glClearColor(1.0,1.0,1.0,0.0);
glShadeModel(GL_FLAT);
}
void display(void){
int i;
glClear(GL_COLOR_BUFFER_BIT);
//Черный цвет для всех линий
glColor3f(0.0,0.0,0.0);
glEnable(GL_LINE_STIPPLE);
//В первом ряду три линии с разными шаблонами
glLineWidth(1.0);
glLineStipple(1,0x0101); //Пунктирная
drawOneLine(50.0,125.0,150.0,125.0);
glLineStipple(1,0x00FF); //Штриховая
drawOneLine(150.0,125.0,250.0,125.0);
glLineStipple(1,0x1C47); //Штрих-пунктирная
drawOneLine(250.0,125.0,350.0,125.0);
//Во втором ряду три толстые линии с аналогичными шаблонами
glLineWidth(5.0);
glLineStipple(1,0x0101); //Пунктирная
drawOneLine(50.0,100.0,150.0,100.0);
glLineStipple(1,0x00FF); //Штриховая
drawOneLine(150.0,100.0,250.0,100.0);
glLineStipple(1,0x1C47); //Штрих-пунктирная
drawOneLine(250.0,100.0,350.0,100.0);
//В третьем ряду шесть штрих-пунктирных линий, объединенных в ломаную
glLineWidth(1.0);
glLineStipple(1,0x1C47); //Штрих-пунктирная
glBegin(GL_LINE_STRIP);
for (i=0;i<7;i++)
glVertex2f(50.0+((GLfloat)i*50.0),75.0);
glEnd();
//В четвертом ряду шесть независимых линий того же шаблона
for (i=0;i<6;i++){
drawOneLine(50.0+((GLfloat)i*50.0),50.0,50.0+((GLfloat)(i+1)*50.0),50.0);
}
//В пятом ряду 1 штрих-пунктирная линия с фактором повторения=5
glLineStipple(5,0x1c47);
drawOneLine(50.0,25.0,350.0,25.0);
glDisable(GL_LINE_STIPPLE);
glFlush();
}
void reshape(int w,int h){
glViewport(0,0,(GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,400.0,0.0,150.0);
}
int main(int argc, char **argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(400,150);
glutInitWindowPosition(100,100);
glutCreateWindow("Line Stipple Patterns");
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}
| 27.013514 | 103 | 0.716858 | RussianPenguin |
83afa5c4e1a850e5b60637ab9a5ca4b88f9e1e75 | 367 | cpp | C++ | src/main/cpp/miscar/Log.cpp | MisCar/libmiscar | b7da8ea84f1183ce4a8c5b51bcb29bea7052f7b2 | [
"BSD-3-Clause"
] | null | null | null | src/main/cpp/miscar/Log.cpp | MisCar/libmiscar | b7da8ea84f1183ce4a8c5b51bcb29bea7052f7b2 | [
"BSD-3-Clause"
] | null | null | null | src/main/cpp/miscar/Log.cpp | MisCar/libmiscar | b7da8ea84f1183ce4a8c5b51bcb29bea7052f7b2 | [
"BSD-3-Clause"
] | null | null | null | // Copyright (c) MisCar 1574
#include "miscar/Log.h"
#include <networktables/NetworkTableInstance.h>
#include <frc/Errors.h>
void miscar::log::Warning(const std::string& message) {
FRC_ReportError(frc::err::Error, "[MisCar] {}", message);
}
void miscar::log::Error(const std::string& message) {
FRC_ReportError(frc::warn::Warning, "[MisCar] {}", message);
}
| 22.9375 | 62 | 0.697548 | MisCar |
83b0c94bfd73bc3ee43ccde95f849830e4779402 | 1,246 | hpp | C++ | libs/core/include/fcppt/container/map_values_ref.hpp | pmiddend/fcppt | 9f437acbb10258e6df6982a550213a05815eb2be | [
"BSL-1.0"
] | null | null | null | libs/core/include/fcppt/container/map_values_ref.hpp | pmiddend/fcppt | 9f437acbb10258e6df6982a550213a05815eb2be | [
"BSL-1.0"
] | null | null | null | libs/core/include/fcppt/container/map_values_ref.hpp | pmiddend/fcppt | 9f437acbb10258e6df6982a550213a05815eb2be | [
"BSL-1.0"
] | null | null | null | // Copyright Carl Philipp Reh 2009 - 2018.
// 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)
#ifndef FCPPT_CONTAINER_MAP_VALUES_REF_HPP_INCLUDED
#define FCPPT_CONTAINER_MAP_VALUES_REF_HPP_INCLUDED
#include <fcppt/is_reference.hpp>
#include <fcppt/algorithm/map.hpp>
#include <fcppt/type_traits/value_type.hpp>
namespace fcppt
{
namespace container
{
/**
\brief Maps the mapped values of an associative container to a container of references.
\ingroup fcpptcontainer
\tparam Result A sequence container of <code>fcppt::reference<Map::mapped_type></code> or <code>fcppt::reference<Map::mapped_type const></code>.
\tparam Map An associative container.
*/
template<
typename Result,
typename Map
>
Result
map_values_ref(
Map &_map
)
{
static_assert(
fcppt::is_reference<
fcppt::type_traits::value_type<
Result
>
>::value,
"Result::value_type must be an fcppt::reference"
);
return
fcppt::algorithm::map<
Result
>(
_map,
[](
auto &&_element
)
{
return
fcppt::type_traits::value_type<
Result
>{
_element.second
};
}
);
}
}
}
#endif
| 17.8 | 144 | 0.699037 | pmiddend |
83b2800bbebe3c208ed2a7cba70404718cc10869 | 1,221 | cpp | C++ | Algorithms/Mathematical-Algorithms/Computational-Geometry/triangle_check.cpp | tensorush/Computer-Scientists-Toolkit | f48aadf6387b935ac593f6a5513352c3bf562cb0 | [
"MIT"
] | 9 | 2021-07-11T19:53:36.000Z | 2022-03-28T15:04:38.000Z | Algorithms/Mathematical-Algorithms/Computational-Geometry/triangle_check.cpp | geotrush/Computer-Scientists-Toolkit | f48aadf6387b935ac593f6a5513352c3bf562cb0 | [
"MIT"
] | 1 | 2022-01-18T09:49:36.000Z | 2022-01-18T17:50:12.000Z | Algorithms/Mathematical-Algorithms/Computational-Geometry/triangle_check.cpp | geotrush/Computer-Scientists-Toolkit | f48aadf6387b935ac593f6a5513352c3bf562cb0 | [
"MIT"
] | 2 | 2021-11-15T08:02:25.000Z | 2022-03-21T14:29:15.000Z | /*
Triangle Check
--------------------------
| Segments | Points |
--------------------------
| Time: O(1) | O(1) |
| Space: O(1) | O(1) |
--------------------------
*/
#include <iostream>
struct Point {
int x, y;
};
bool TriangleCheckForSegments(const unsigned& A, const unsigned& B, const unsigned& C) {
bool isTriangle = false;
if (A + B > C && A + C > B && B + C > A)
isTriangle = true;
return isTriangle;
}
bool TriangleCheckForPoints(const Point& A, const Point& B, const Point& C) {
bool isTriangle = true;
int crossProduct = (B.x - A.x) * (C.y - A.y) - (B.y - A.y) * (C.x - A.x);
if (crossProduct == 0)
isTriangle = false;
return isTriangle;
}
int main() {
unsigned segment_1, segment_2, segment_3;
std::cin >> segment_1 >> segment_2 >> segment_3;
std::cout << std::boolalpha << TriangleCheckForSegments(segment_1, segment_2, segment_3) << std::endl;
Point point_1, point_2, point_3;
std::cin >> point_1.x >> point_1.y >> point_2.x >> point_2.y >> point_3.x >> point_3.y;
std::cout << std::boolalpha << TriangleCheckForPoints(point_1, point_2, point_3) << std::endl;
return EXIT_SUCCESS;
} | 29.780488 | 106 | 0.555283 | tensorush |
83b5d11d1c083c52929d5110ab7677aa043a2baf | 1,792 | cpp | C++ | Cpp/Codes/Practice/LeetCodeCN/443 String Compression.cpp | QuincyWork/AllCodes | 59fe045608dda924cb993dde957da4daff769438 | [
"MIT"
] | null | null | null | Cpp/Codes/Practice/LeetCodeCN/443 String Compression.cpp | QuincyWork/AllCodes | 59fe045608dda924cb993dde957da4daff769438 | [
"MIT"
] | null | null | null | Cpp/Codes/Practice/LeetCodeCN/443 String Compression.cpp | QuincyWork/AllCodes | 59fe045608dda924cb993dde957da4daff769438 | [
"MIT"
] | 1 | 2019-04-01T10:30:03.000Z | 2019-04-01T10:30:03.000Z | #include<gtest/gtest.h>
using namespace std;
namespace LC443
{
class Solution {
public:
int compress(vector<char>& chars) {
if (chars.empty())
{
return 0;
}
int result = 0;
int output = 0;
int count = 1;
int prev = chars[0];
for (auto i = 1; i < chars.size(); ++i)
{
if (chars[i] != prev)
{
chars[output++] = prev;
result++;
if (count > 1)
{
int base = 1000; // 1 <= len(chars) <= 1000
bool contain = false;
while (base != 0)
{
int value = count / base;
count %= base;
base /= 10;
if (value > 0)
{
contain = true;
}
if (contain)
{
chars[output++] = value + '0';
result++;
}
}
}
prev = chars[i];
count = 0;
}
count++;
}
chars[output++] = prev;
result++;
if (count > 1)
{
int base = 1000; // 1 <= len(chars) <= 1000
bool contain = false;
while (base != 0)
{
int value = count / base;
count %= base;
base /= 10;
if (value > 0)
{
contain = true;
}
if (contain)
{
chars[output++] = value + '0';
result++;
}
}
}
return result;
}
};
TEST(LeetCodeCN, tCompress)
{
Solution s;
vector<char> data = {'a','a','b','b','c','c','c' };
int count = s.compress(data);
ASSERT_EQ(count, 6);
data = {};
count = s.compress(data);
ASSERT_EQ(count, 0);
data = {'a'};
count = s.compress(data);
ASSERT_EQ(count, 1);
data = { 'a','a','a','a','a','a','a','a','a','a'};
count = s.compress(data);
ASSERT_EQ(count, 3);
data = { 'a','a','b','a','b','b','b','d','c','b','b','a' };
count = s.compress(data);
ASSERT_EQ(count,11);
}
} | 17.568627 | 61 | 0.449219 | QuincyWork |
83b6f1b38fb302d7e00efb4714bb7c74ce46d811 | 86,312 | inl | C++ | src/fonts/stb_font_consolas_bold_22_latin_ext.inl | stetre/moonfonts | 5c8010c02ea62edcf42902e09478b0cd14af56ea | [
"MIT"
] | 3 | 2018-03-13T12:51:57.000Z | 2021-10-11T11:32:17.000Z | src/fonts/stb_font_consolas_bold_22_latin_ext.inl | stetre/moonfonts | 5c8010c02ea62edcf42902e09478b0cd14af56ea | [
"MIT"
] | null | null | null | src/fonts/stb_font_consolas_bold_22_latin_ext.inl | stetre/moonfonts | 5c8010c02ea62edcf42902e09478b0cd14af56ea | [
"MIT"
] | null | null | null | // Font generated by stb_font_inl_generator.c (4/1 bpp)
//
// Following instructions show how to use the only included font, whatever it is, in
// a generic way so you can replace it with any other font by changing the include.
// To use multiple fonts, replace STB_SOMEFONT_* below with STB_FONT_consolas_bold_22_latin_ext_*,
// and separately install each font. Note that the CREATE function call has a
// totally different name; it's just 'stb_font_consolas_bold_22_latin_ext'.
//
/* // Example usage:
static stb_fontchar fontdata[STB_SOMEFONT_NUM_CHARS];
static void init(void)
{
// optionally replace both STB_SOMEFONT_BITMAP_HEIGHT with STB_SOMEFONT_BITMAP_HEIGHT_POW2
static unsigned char fontpixels[STB_SOMEFONT_BITMAP_HEIGHT][STB_SOMEFONT_BITMAP_WIDTH];
STB_SOMEFONT_CREATE(fontdata, fontpixels, STB_SOMEFONT_BITMAP_HEIGHT);
... create texture ...
// for best results rendering 1:1 pixels texels, use nearest-neighbor sampling
// if allowed to scale up, use bilerp
}
// This function positions characters on integer coordinates, and assumes 1:1 texels to pixels
// Appropriate if nearest-neighbor sampling is used
static void draw_string_integer(int x, int y, char *str) // draw with top-left point x,y
{
... use texture ...
... turn on alpha blending and gamma-correct alpha blending ...
glBegin(GL_QUADS);
while (*str) {
int char_codepoint = *str++;
stb_fontchar *cd = &fontdata[char_codepoint - STB_SOMEFONT_FIRST_CHAR];
glTexCoord2f(cd->s0, cd->t0); glVertex2i(x + cd->x0, y + cd->y0);
glTexCoord2f(cd->s1, cd->t0); glVertex2i(x + cd->x1, y + cd->y0);
glTexCoord2f(cd->s1, cd->t1); glVertex2i(x + cd->x1, y + cd->y1);
glTexCoord2f(cd->s0, cd->t1); glVertex2i(x + cd->x0, y + cd->y1);
// if bilerping, in D3D9 you'll need a half-pixel offset here for 1:1 to behave correct
x += cd->advance_int;
}
glEnd();
}
// This function positions characters on float coordinates, and doesn't require 1:1 texels to pixels
// Appropriate if bilinear filtering is used
static void draw_string_float(float x, float y, char *str) // draw with top-left point x,y
{
... use texture ...
... turn on alpha blending and gamma-correct alpha blending ...
glBegin(GL_QUADS);
while (*str) {
int char_codepoint = *str++;
stb_fontchar *cd = &fontdata[char_codepoint - STB_SOMEFONT_FIRST_CHAR];
glTexCoord2f(cd->s0f, cd->t0f); glVertex2f(x + cd->x0f, y + cd->y0f);
glTexCoord2f(cd->s1f, cd->t0f); glVertex2f(x + cd->x1f, y + cd->y0f);
glTexCoord2f(cd->s1f, cd->t1f); glVertex2f(x + cd->x1f, y + cd->y1f);
glTexCoord2f(cd->s0f, cd->t1f); glVertex2f(x + cd->x0f, y + cd->y1f);
// if bilerping, in D3D9 you'll need a half-pixel offset here for 1:1 to behave correct
x += cd->advance;
}
glEnd();
}
*/
#ifndef STB_FONTCHAR__TYPEDEF
#define STB_FONTCHAR__TYPEDEF
typedef struct
{
// coordinates if using integer positioning
float s0,t0,s1,t1;
signed short x0,y0,x1,y1;
int advance_int;
// coordinates if using floating positioning
float s0f,t0f,s1f,t1f;
float x0f,y0f,x1f,y1f;
float advance;
} stb_fontchar;
#endif
#define STB_FONT_consolas_bold_22_latin_ext_BITMAP_WIDTH 256
#define STB_FONT_consolas_bold_22_latin_ext_BITMAP_HEIGHT 286
#define STB_FONT_consolas_bold_22_latin_ext_BITMAP_HEIGHT_POW2 512
#define STB_FONT_consolas_bold_22_latin_ext_FIRST_CHAR 32
#define STB_FONT_consolas_bold_22_latin_ext_NUM_CHARS 560
#define STB_FONT_consolas_bold_22_latin_ext_LINE_SPACING 14
static unsigned int stb__consolas_bold_22_latin_ext_pixels[]={
0x33221991,0x20000000,0x3000dffb,0x99910003,0x0dffa801,0xca801880,
0x26666600,0xb982b880,0x004d4400,0x40028826,0x41301998,0x00198818,
0xbca80660,0x33332a01,0x9880ea04,0x41331001,0x3ff11ff8,0x00ae2d40,
0x154ffee0,0x8017fee0,0x5401efe8,0xff5002ff,0x02ffd40d,0xb0bfffff,
0x37fcc5ff,0x09ffff90,0x27fc3fee,0x01eff980,0x70ff33ff,0xf70001ff,
0x3fff20bf,0xfffffb03,0x5413fee0,0xffb801ff,0x7c47fe23,0x27ff501f,
0x22001ffa,0x40bf51aa,0x004fddfb,0xc88019d9,0x9df5000c,0x1bfea0bf,
0x85ffeee8,0x3fe62ffd,0xf99dfd06,0x11ff909f,0xff3009ff,0x7ffdc01b,
0x00ffb84f,0x27eefdc0,0x40fff54c,0x702aaefd,0x3fea09ff,0x23ffa801,
0x3ff11ff8,0xfd8dff30,0xd988000f,0x2199103f,0x664401cb,0x7fffcc01,
0x970cc800,0x40077205,0x84d985ff,0x0efc81db,0x8ae03fe6,0x3cb800b9,
0x207bb500,0x22000ffb,0x403970cc,0x05fd83ff,0x3ea01990,0x3ffa801f,
0x7fc47fe2,0x440ffe81,0x3f2006ff,0x8801ffff,0xffff1000,0x7c47dc03,
0x00000003,0x00005ff8,0x7f901ff3,0x00000000,0x07fdc011,0x36000001,
0x005fd84f,0x0ffd4011,0xf11ffd40,0x907fe23f,0x3fe605ff,0xffffe805,
0x3fee06ff,0xb82fffff,0x2603f88f,0x2a01fedf,0x3fffffff,0x017ffffe,
0x7fdc2ffc,0x3f227fc0,0xcafdc463,0x5ff882ff,0xff105ff9,0xfffff70b,
0x23fee5ff,0x7e42effd,0x85ff882f,0x05fd84fd,0x7fffffdc,0x543ff52f,
0x5ff30eff,0xff88ffc4,0x2e027fc1,0x3fee00ff,0x85fffc8c,0xffffeffd,
0xfbbfa82f,0x00ddcc03,0x3fffffea,0x3ffffe3f,0x70bff005,0x24ff81ff,
0xfffa8ff8,0xbff16faf,0x3e25ff70,0x42ffb85f,0xffffeffd,0xffdff72f,
0x7fc43fff,0xd82ffb85,0x205fd84f,0xffffeffd,0x223ff52f,0x3fe60eff,
0x7c47fe22,0x00bfea1f,0x7fc05ff3,0x83ff7fa5,0x1bf22ff9,0xf00bffb0,
0x99880fff,0x263ffa99,0xf005ff99,0x81ff70bf,0x23be64ff,0x6f9ffeff,
0xdfd03ff6,0x7f40ffd8,0xf917fcc6,0x9cfffb8d,0x7fec5ffa,0xfb837f40,
0xf305fd86,0x2a37e45f,0x1ffe89ff,0xff117fcc,0xfd87fe23,0x04ff800f,
0x3be65ff3,0x1fea1ff9,0x19801ff3,0x2ffff980,0x81ffc400,0xbff005ff,
0xff81ff70,0x37ef3ee4,0x2a7f8ff9,0x0ffe22ff,0x7fc45ff5,0x3e63fd43,
0xb13fee0f,0x17fd41ff,0x3e607ff1,0x0bfb09cf,0x1ff31fea,0x7fecffd4,
0x221ff981,0xe82aa1ff,0x0dfb006f,0x67dc7fea,0x3fea3ff8,0x75c1fea1,
0x700dffff,0x8009ffff,0xbff03ff8,0x2e17fe00,0xb27fc0ff,0xdf35fb5f,
0x25ff8df1,0x5ff80ffb,0xff503fee,0x3ee3fd43,0x20ffdc0f,0x03fee5ff,
0xfb3ffe98,0xa87fea0b,0x7effd47f,0x43ff102f,0x7fc01ff8,0x20ff7004,
0x23fd0ffb,0x5f7f44ff,0xfff05ffc,0xd01dfffd,0x800ffb9f,0xbff03ff8,
0x2e17fe00,0xb27fc0ff,0xbf53fd5f,0x0ffc8df3,0x3ff20bfd,0x3fa0bfd0,
0x5c5ffcbe,0x0ffdc0ff,0x2ff43ff2,0x25dffb10,0x3bfa05fd,0x7d45ffcb,
0xf101ffff,0x00ffc43f,0x7d4013fe,0x88ffb80f,0xfd13fe7f,0x201bffff,
0x217fdc0b,0x1ffbaff8,0x40ffe200,0xbff005ff,0xff81ff70,0x27fe7fa4,
0x4c5fadfb,0x02ff9bff,0x5ff37ff3,0x3fffffa0,0x207fdc0d,0x7fcc0ffc,
0x2e02ff9b,0x02fec0ff,0x1bfffffd,0xfffaffa8,0x7c419900,0x037ec01f,
0xff507fc8,0x3fe29f73,0x26a37ee3,0x3ff88000,0x7fcc7fd4,0x0ffe2003,
0xff802ffc,0x7c0ffb85,0x3fe7fa4f,0x83fbcfc9,0x407fcefe,0x707fcefe,
0x201351bf,0x3ff40ffb,0x07fcefe8,0x2fec2fe4,0x09a8dfb8,0xff53ff50,
0x8ffc400d,0x1ff21ee8,0xf983ff40,0xff32fdaf,0x004f7e45,0xff999710,
0x3fe6fd89,0x0ffe2006,0xff802ffc,0x7c0ffb85,0x3fabf64f,0x81ffeffd,
0x404ffffa,0x904ffffa,0xfb8013df,0x40fff20f,0x404ffffa,0x05fd84fd,
0xa8013df9,0x89ff91ff,0x3fe21ff9,0x7d43ff11,0x05ff801f,0xfc9ffbfe,
0x3fffe60f,0xfc80ceff,0x44ffffff,0x03ff24ff,0xfb9ffc40,0x6fffffff,
0x3fffffee,0x81ff76ff,0x2ebf24ff,0x04ffedff,0x2007fffe,0xf301ffff,
0x19dfffff,0x7ff7ffdc,0x7fffc06f,0x6c27ec01,0xffff305f,0x7d419dff,
0xc8fffa1f,0x47fe24ff,0x3fe21ff8,0x017fcc03,0xf71bfff9,0xeefe887f,
0x7dc6ffff,0x4ff999df,0xffa87fe6,0x27ff3002,0xfffffffb,0x3fffee6f,
0xff76ffff,0x3f24ff81,0x006a2554,0x3200bff9,0x3fa205ff,0x26ffffee,
0x3ffffffb,0x805ffc80,0x05fd84fd,0xfffddfd1,0x10ffd4df,0x3fe63fff,
0x7c47fe22,0x007ff41f,0xffb00ffb,0xe81dffff,0x21ffc86f,0x27fc47fd,
0xfffffff9,0x3fea00bf,0x002fe802,0x31ffc400,0x7e4000ff,0x3ff9001f,
0x7e437f40,0x031ff71f,0x801ffc80,0x05fd84fe,0x3ff90dfd,0x22044000,
0x83ff11ff,0xff906ff9,0xffff1005,0x09ff109f,0x7fec1ff7,0x749ffd31,
0xffffffff,0x0ffd8187,0x3202fdc0,0x3fea003e,0x04427f42,0x200bff50,
0x3e205ffa,0x70ffb84f,0xfa8001ff,0x2ff9805f,0xff885fd8,0x880ffb84,
0x7c4000ee,0x503ff11f,0x5ffa89ff,0x013bf500,0xcaacfff8,0x7ffdc5ff,
0xf14feffe,0xf933337f,0xfcdfd83f,0xefd804ff,0x805fd00a,0x40fffdcd,
0xfcabdffa,0x77ff6d42,0x3ffb6a00,0x67ffc00e,0x2e5ffcaa,0xeda800ff,
0x3ae00eff,0xdffb07ff,0x567ffcbd,0xf505ffca,0x3ff1000f,0x7dc07fe2,
0x01dff12f,0x4c00bf60,0x4ffffffe,0xb3dfff90,0x203fee9f,0x7fec4ff9,
0xa800cfff,0xff881fff,0x7ffff400,0xfffff501,0xdfffa83d,0x6fffd400,
0xfffe9800,0x7fdc4fff,0xdfffa800,0x0f7fe400,0x27ffffd8,0xffffffe9,
0x0013f204,0x7fc47fe2,0x7447f601,0x02aa000e,0x15575300,0x7ec01300,
0x2a1bfe06,0x44000aba,0x0055101a,0x88015753,0x57101ab9,0x06ae2003,
0x2aaea600,0x10019880,0x26200357,0x4cccc400,0x0aaba981,0x400054c0,
0x3ff11ff8,0x00044080,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x80000000,0x002aa0aa,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x17a20000,0x913cb880,0xb8039999,0x2000c403,0x00001cc9,
0x01300000,0x10026620,0x00000000,0x22000620,0x00980099,0x19880000,
0x00000000,0x005fb800,0x3e2bfff7,0x3203ffff,0xfffb83ff,0x77c400df,
0xafd401fd,0x23fe05fa,0xfc800fe8,0xfff9100f,0xfff30dff,0x9ff07939,
0xe801ff70,0x000fe807,0xa807bfe6,0xfff101ff,0x3fffffff,0xfffffb10,
0x03fffc0d,0xfff88ff9,0xe800bfd0,0xeff8803f,0xff55511a,0x227fe407,
0xfffffffd,0x3e27ea01,0xffffe802,0x3ffff202,0x03ffd004,0xffffffd1,
0xfffbfb0f,0x709ff0bf,0x06f801ff,0x3e6007f8,0x1ffb804f,0xffffff10,
0xfa83ffff,0x07ffffff,0x205ffff3,0x17fec7fc,0xaa800bfd,0x00ffa800,
0xbb101ffc,0x4ceffdc1,0x3e205ffc,0xb8800fee,0xcca801cc,0x413aa002,
0x0a60cffb,0x81e5c462,0x0ffb84ff,0x6dc17e20,0x8805efff,0x2e009889,
0x266601ff,0x4199bffb,0x989cfff8,0xffff705b,0xfa9ff209,0x002ff44f,
0x37dc0022,0x4001ffc0,0x1ffd86ff,0x00073220,0x00000331,0xffd81988,
0xff000000,0x101ff709,0x7443bf95,0x07ffffff,0x3ea1fe40,0xffffffff,
0x405ff303,0x74002ffd,0xf907fdcf,0xd03bfe2f,0x3fee00bf,0xc82fffff,
0x53ff806f,0x7fffffff,0x3ea0ffe6,0x5c27fc2f,0xffd880ff,0x27fc6fff,
0x6c407fdc,0x326fffff,0x4ff804ff,0x3fe0ffb8,0x5c0ffb84,0x326fffff,
0x4acfccff,0x507fa600,0xffffffff,0x0bfe607f,0x20037fc4,0x1ffbaff8,
0x3ffb7fc8,0xfb00bfd0,0x5fffffdf,0xff00df90,0x3ffffea7,0x03ff53ff,
0x4ff87ff3,0x7d40ffb8,0x47ffffff,0x0ffb84ff,0x7fffffd4,0x3fffea7f,
0x709ff00b,0x427fc1ff,0x3ff20ffb,0x3fe6efef,0x2e005f96,0x440ffffe,
0x99affb99,0x05ff3009,0x9988ffe6,0x98ffa819,0xaffc83ff,0x0bfd03ff,
0x3f22ff98,0x2017f206,0x333313ff,0x3fee7ff5,0x7c4ff881,0x20ffb84f,
0x989cfff8,0x5c27fc5b,0x3ffe20ff,0x645b989c,0x40dfffff,0x0ffb84ff,
0x3fee13fe,0xfb1bff30,0x6d7ff411,0xfffd800f,0x3ee06fff,0x5ff3001f,
0xfe8bfea0,0x37ec0fff,0xfff90dff,0x02ff40df,0x1ff31fea,0x01ffd4c4,
0xff101ffc,0x2207ff27,0x427fc4ff,0x3ff60ffb,0x709ff002,0x17fec1ff,
0xffffb300,0x5c27fc1f,0x213fe0ff,0x5ff70ffb,0x3fff21fa,0x7fd400ff,
0x04ffff8c,0x26003ff7,0x5ff702ff,0x207ffff4,0x03ff24ff,0x03ffbff9,
0xff5017fa,0x3ea3fd43,0x7ff003ff,0xfb9ffc40,0x43ff981f,0x0ffb84ff,
0x7c00dff1,0x10ffb84f,0x22000dff,0x3fe4fffb,0x3e0ffb84,0xb0ffb84f,
0x6c1be1ff,0x00cfffff,0x33be6dfd,0x03ff707f,0x540bfe60,0x0ffb83ff,
0xffa87fe6,0x7fcffe42,0xd00bfd06,0x8bff97df,0x800cffe9,0x3fe203ff,
0xf507ff53,0xb84ff85f,0x47ff30ff,0x7fc19998,0xf30ffb84,0x0cccc47f,
0xff37fcc0,0x7c1ff709,0x367fb84f,0x205f88ff,0x1fffffd9,0x57f93ff8,
0x3ff701ff,0x40bfe600,0xffb85ff8,0x3fffff20,0xbfe45fff,0x5fe84ffb,
0xfffffe80,0x07ff300d,0x7c407ff0,0xb0dff13f,0x84ff81ff,0x5ff50ffb,
0xf07ffff4,0x21ff709f,0x3ffa2ffa,0x5ff800ff,0x3fee13fe,0x3f617fe0,
0x3e6bff25,0x7f6fcc04,0xf97fc46f,0xa81ff98f,0xff3002ff,0x20fff405,
0x3ffa0ffb,0x47ffffff,0x07ffa7fc,0xdfb80bfd,0xfd8009a8,0x203ff804,
0x3ff63ff8,0x84ffc99d,0x0ffb84ff,0x7ff45ff7,0x213fe0ff,0x5ff70ffb,
0xd87ffff4,0xffd9899b,0x3ee13fe4,0xa8fff60f,0x3ffe63ff,0xf7038bfc,
0x3fe1ffe7,0x1ff55fab,0x041bff30,0x2a02ff98,0xfc99bfff,0x337ff10f,
0x643ff933,0x83bfe67f,0x99999efe,0x0013df90,0x7fc037e4,0x88ffe203,
0x5ffffffe,0xff709ff0,0x2e0ffea1,0x213fe0ff,0x7ff50ffb,0x3fe1ff70,
0x46ffffff,0x0ffb84ff,0x3fffffe6,0x7ffe40df,0x3f906fff,0x37fa1bfa,
0x40ff93fc,0x03fefffe,0xfc805ff3,0x0fffffff,0xff301ff7,0x3f23fe49,
0x3ffffa4f,0xfff35fff,0x2019dfff,0x3ff806fc,0x910ffe20,0x7c09ffff,
0x227fb84f,0x0ffb85ff,0x9fee13fe,0xffb85ff8,0xffffffb0,0xb84ff817,
0xfffd987f,0x3ff6603f,0x3ab3a5ff,0xc84ffdbf,0xffa8ffff,0x3fffa604,
0x05ff303f,0xdffffd50,0xff037ec9,0x3e23fe4d,0xffffd2ff,0x3fa2bfff,
0x06ffffee,0x7ff00df7,0x981ffcc0,0x2ff402ff,0x3ffa37ec,0xfd07fdc1,
0xfe8dfb0b,0x207fdc1f,0x3fa00999,0x2206fd85,0x3fb002ff,0xffffff81,
0xffd105ff,0x001dffff,0x00001331,0x20002660,0x00000efa,0xfc86fe80,
0x806fb81f,0x3fea03ff,0x267bfe02,0x51ffec1c,0xfffa89ff,0x20ffc99b,
0x3fea3ffd,0x4dfffd44,0xe880ffc9,0x47ffb00e,0x3f204ffa,0x641fa005,
0x02deffed,0x27ffff44,0x40077440,0xd1000ee8,0x3fe0001d,0x003ba201,
0x9ff10fb2,0xf501ff70,0x33ff805f,0x5c01ffb0,0x446fffff,0xffffffff,
0xfffffc80,0x3fe20fff,0x80ffffff,0xfffffffc,0x207fa80f,0xfffffff8,
0x2bbf600f,0x4406f800,0x3fe2005f,0x1fea0009,0x5003fd40,0x3e2000ff,
0x0ff502cf,0x3fe0bfa0,0x5ffcaacf,0x453bffa0,0xfb3ffeee,0x009fff9b,
0x303bffd5,0x01bffffd,0x77ffff54,0xffffe984,0x3ffaa00d,0x9f904eff,
0xffffe980,0x7ffd400d,0x202fc401,0x3ea004fa,0x04fc8005,0x64009f90,
0x3fa0004f,0x009f906f,0xfd301ff1,0x809fffff,0xff15ffd8,0x3ff67fff,
0x0000cfff,0x30001300,0x00260013,0x53002660,0x0004c001,0x322006a2,
0x000e4c02,0x53000353,0x002a6001,0x40000a98,0x015300a9,0xa9805510,
0x22000aab,0x26666609,0x002aeaa0,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x04c00000,
0x00000000,0x01000200,0x40400001,0x00000000,0x40405500,0x10331000,
0x20005ffd,0x2601effa,0x999001cc,0x3e601999,0x801ff9af,0x3101effa,
0xfc800013,0x7fffd40f,0xfff3ffff,0xff0ff987,0x40ff985f,0x3c9cfff9,
0x27ecdf70,0x7ffffffc,0xfb37dc2f,0xfffffc89,0x447fc03d,0x3ea000fe,
0x7ecdf705,0x3fffb204,0x02ffb84f,0x2027fd40,0x801fdef8,0x00ffffff,
0x007fffa2,0x32213fea,0x266fffff,0xffe802ff,0x7ffffd41,0xdfff3fff,
0xfff0ff98,0x6c0ff98d,0x05ffffdf,0x1bfe1ffb,0x3ffffffe,0xf87fec2f,
0x7fffe46f,0x3f205fff,0x31004fff,0x3ff607fb,0xfd10dff0,0x20bfffff,
0x554002a9,0xf89fa801,0x99999802,0x00aa8801,0xfd103550,0x64ffffff,
0x4ea804ff,0xbffb9988,0x5ffff099,0xfff87fcc,0x103fe62f,0x980f2e23,
0x3e076a3d,0x099999df,0x83b51ecc,0xfeb99ffc,0x0b32a01f,0x3fffff20,
0x6d47b301,0x9adffe81,0x006204b9,0x3e200310,0x00000fee,0x4004cc40,
0x7fdc0998,0xff98a60c,0x40331002,0xfff82ff9,0x7c3fe66f,0x3fe66fff,
0x10006200,0x004ff803,0x5c7fc800,0x00c403ff,0x7ffffff4,0xffa80006,
0x3fff2005,0x3ff200df,0x64400dff,0x427fc01c,0x7e440ffb,0xc886ffff,
0x366fffff,0x008800ff,0x4ffffec8,0xff82ff98,0x1ff32ffd,0x4cbff3fe,
0xfffc80ff,0x3ff200df,0x4ff80dff,0xfb84ff80,0xf98ff90f,0xffff903f,
0x19ff701b,0xff0bfff9,0x45ffffff,0xfd001ffd,0x03ffffff,0xfffffffd,
0x03fffc03,0x3fee13fe,0x3ffffa20,0x7ff447ff,0x3f27ffff,0x00cc804f,
0xffffffd1,0xf05ff30b,0x3e6bfd5f,0xdfb5ff0f,0xffd03fe6,0xd03fffff,
0x3fffffff,0xaaaadff8,0x2e13fe0a,0x44ff90ff,0xffe80ffe,0x7c1fffff,
0x3ff7fa5f,0x7fffffc0,0x01ffa2ff,0x64ceffdc,0x6ffdc5ff,0x305ffc99,
0x7c05ffff,0x20ffb84f,0x0a60cffb,0x14c19ff7,0x017ffff5,0x3fa03ff1,
0x84b99adf,0xaff82ff9,0x0ff99ffa,0x35ff35ff,0x6ffdc1ff,0x5c5ffc99,
0xffc99dff,0x7fffffc5,0x213fe0ff,0xdff90ffb,0xf705ffff,0xbff933bf,
0xef997fcc,0x6ffc1ff9,0x3e099999,0x6ff8806f,0xff10ffd8,0x701ffb0d,
0x7c09ffff,0x20ffb84f,0xfd800ffd,0xfffc800f,0x3fe20dff,0x005ffa81,
0x3fe0bfe6,0x1ff39ff2,0x4f7ecbfe,0x0dff10ff,0x3fe21ffb,0x3e0ffd86,
0x0eeeeeff,0x3fee13fe,0xdfffff90,0xb0dff101,0x47fea1ff,0x43ff8cfb,
0x7fc404ff,0x83ff9806,0x7ff32ffa,0xfd05ff50,0x7fc0ffb9,0x320ffb84,
0xffc804ff,0xfffb3004,0x07fe21ff,0x98007ff6,0x72ff82ff,0x3e1ff5ff,
0xff9ff32f,0x2a0ffe61,0x07ff32ff,0x27fc5ff5,0x7dc27fc0,0xf73ff90f,
0x07ff30df,0x3fee5ff5,0x13fe3fd0,0xfff009ff,0x303ff500,0x07fea7ff,
0xff10ffe6,0x3e03ff75,0x20ffb84f,0x00bffffa,0x017ffff5,0x29fff710,
0x7fe81ff9,0x417fcc00,0xfbff12ff,0xfd8bfe1f,0x3ff50fff,0x3ea7ff30,
0x23ff981f,0x4ff804ff,0xff90ffb8,0x3ea17fdc,0x73ff981f,0x7cff11ff,
0x556ffc4f,0x3ffa0aaa,0x40ffdc01,0x3ff74ff8,0xfa89ff10,0xf03ff98f,
0x81ff709f,0x0dfffffc,0xdfffffc8,0x36ff9800,0x0dff05ff,0xf82ff980,
0x3ffff22f,0x7fcc5ff0,0x03ff70ff,0x3fee9ff1,0x3e4ff881,0x84ff804f,
0x4ff90ffb,0x7fdc6ff8,0xf54ff881,0x3e29f73f,0x7ffffc3f,0x3fee0fff,
0x40ffdc05,0x3ff74ff8,0xfd89ff10,0x7fc1bfe6,0x980ffb84,0x80fffffd,
0x0fffffd9,0xff36ff80,0x806ff885,0x9bffb998,0x7cc5ff09,0x85ff0fff,
0xff70fffd,0x2e9ff103,0x4ff881ff,0x266677fe,0x2e13fe09,0xc8ff90ff,
0x07fee2ff,0x7fcd3fe2,0x5ff32fda,0xeeeefff8,0x37ffe20e,0xff75b99a,
0x2e7ff303,0x3ff981ff,0x1ff927fc,0xff709ff0,0x7ffdc401,0x3ffee204,
0xb31337b4,0x0bfe69ff,0x3ea01ffe,0x3fffffff,0xfffd85ff,0xff985ff0,
0x303ff70f,0x07fee7ff,0xfff8ffe6,0x3e2fffff,0x90ffb84f,0x26ff98ff,
0xff981ffb,0xc9ffbfe3,0x027fc0ff,0xffffffa8,0x507ff55f,0x0ffea5ff,
0xff98bfea,0x3e0bfea1,0x007fb84f,0xf300dff3,0x3ffffedf,0xff50efff,
0x803ffd07,0xfffffffa,0xf985ff3f,0xb05ff0ff,0x0ffea1ff,0x7fd4bfea,
0x3e2ffa83,0x2fffffff,0x9fee13fe,0x2ffd87fc,0xff507ff5,0x46fffe45,
0x4ff83ffb,0x3fff6600,0x0dff13ef,0x3fe21ffb,0x320ffd86,0xffffffff,
0xfd85fe85,0x017fe006,0xfffdaffc,0x3ea0cfff,0x05ffb83f,0x001df300,
0x21ff9000,0xffd86ff8,0xfb0dff10,0x0efa801f,0x1bf617fa,0x86ff8800,
0x7fec0ffd,0xf80effff,0x4fd8004f,0x933bff90,0xdffc89ff,0x744ffc99,
0xffffffff,0x2a3ffd87,0x4cdec4ff,0x364ffd98,0xffd9899b,0xa83fdcc4,
0xfff883ff,0x405b99ad,0x1dd102fe,0xc8dff000,0xffc99dff,0x4ceffe44,
0xff804ffc,0xf51ffec2,0x03ba209f,0xc99dffc8,0xfff884ff,0x37fe04ff,
0x20099999,0xffd101ff,0x881dffff,0xeffffffe,0x266ffe20,0x441ffc99,
0xffffffff,0x7fffffc0,0x7fffc6ff,0xf906ffff,0x40266209,0xfffffffa,
0x4167fc05,0x7e4007fa,0x7ff443ff,0x440effff,0xeffffffe,0x167fc400,
0xfffffff1,0x01fea01f,0xffffffd1,0x13bf501d,0xffffff00,0x1be205ff,
0x9ffffb10,0x7fffec40,0x980ffb84,0xffe984ff,0xffd80dff,0x6c0bffff,
0x0bffffff,0x80003fb0,0x3effffd8,0x6437fec0,0x7ff4004f,0xffffb104,
0x7ffec409,0x3ff6004f,0x7ffff4c6,0x013f200d,0x13ffff62,0x3e002fd8,
0x2fffffff,0x08800260,0xfb004400,0x2037fc0d,0x13330009,0x00133300,
0x88000031,0x40d4c001,0x554000a9,0x80011000,0x15300008,0xa98004c0,
0x40044000,0x000000aa,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x26aa6000,0x04000400,0x17ff4404,0x017fec00,0x403dff50,
0xeff9bffa,0x009ff701,0x3fe6ffea,0x0001311e,0x02200101,0x31000000,
0x013fee01,0x903bdb10,0x80199999,0x44004ffb,0x300401a9,0x03fffffd,
0x7939fff3,0x9fb37dc0,0x400bfee0,0x02ffdfe8,0x5404ffa8,0x04ff9aff,
0x013f7bee,0x9ff35ff5,0x2000ffa8,0x013f66fb,0xff805ff3,0x8000fe88,
0xdefb83ff,0xdfd1004f,0x3ffffe01,0x37bee00f,0xfff7004f,0x07fee01f,
0xfb9bfff1,0xfffbfb03,0x87fec0bf,0x0aa606ff,0x2a88d4c0,0xa801aa80,
0x4403550a,0xa802aa2a,0x3e03550a,0x3ff6003f,0xfb80dff0,0x7ffe404f,
0xffb8004f,0x15515440,0x9809db00,0x22019999,0x7002aa2a,0x201ddfff,
0x7fdc3ffe,0x2e231002,0x51ecc03c,0x2000003b,0x00000198,0x10000000,
0x00ff9003,0x03b51ecc,0xa801ed88,0xfd0002cc,0x9801880b,0x10009999,
0x09988003,0x800ffe80,0x7fdc1ffc,0x00000004,0x3ee13fe0,0xfffd880f,
0x427fc6ff,0x13fe0ffb,0x9ff03fee,0xf901ff70,0x2201bfff,0x000002ff,
0x80000000,0xff901ff9,0x3fe01bff,0x7e405fff,0x9100dfff,0x40dfffff,
0x22004ff8,0x1efff980,0x80ffff00,0xfffffffa,0x2e13fe3f,0x7ffd40ff,
0x7fc7ffff,0x3e0ffb84,0x40ffb84f,0x0ffb84ff,0x7ffffff4,0x80dfb01f,
0xff881ffc,0x3fffff25,0xfff06fff,0x0dfb000f,0x3ffffffa,0xffeee81f,
0x3ffffa05,0x7f441fff,0x207fffff,0x91002ff9,0xfffff889,0x3fe600cf,
0x3fea02ff,0x23ffffff,0x0ffb84ff,0x2273ffe2,0x427fc5b9,0x13fe0ffb,
0x9ff03fee,0x7dc1ff70,0x5ffc99df,0x4403ff30,0x0ffc85ff,0x3ffffff2,
0xfff986ff,0x3fe2002f,0x99dffb82,0x7fc05ffc,0x33bff705,0xffb8bff9,
0xfa80a60c,0x8ff3001f,0xfffc9ffd,0xffff700e,0x7dccc409,0x3fe099bf,
0x360ffb84,0x9ff002ff,0x7fc1ff70,0x7c0ffb84,0x10ffb84f,0x1ffb0dff,
0xf9013fa0,0x227fc43f,0xfeaaaaa9,0xffffb84f,0x21ff2004,0xffd86ff8,
0x2217fe00,0x0ffd86ff,0x2a003ff6,0xcccffdcc,0x41ff9302,0x3ffa66ff,
0xffb9fd05,0x40bfe600,0x0ffb84ff,0x7c00dff1,0x20ffb84f,0x0ffb84ff,
0x7fdc27fc,0xf507ff30,0x03fee05f,0x3f25ff88,0x6ff9800f,0x0ffb9fd0,
0x7cc27fc0,0x02ffa83f,0x3fe617fe,0x322ffa83,0xffc804ff,0x44ffffff,
0x20ffffd8,0x3fa21ffe,0x5d7fc40f,0xff9801ff,0xf709ff02,0x88ffe61f,
0x27fc1999,0x9ff07fdc,0xff81ff70,0xf50ffb84,0x07ff303f,0xf900ffe2,
0x009ff11f,0x3e207ffa,0x801ffbaf,0xffa80ffa,0x203ff981,0x1ffa85ff,
0x3ea3ff98,0x5300bfff,0x3555ffd5,0x0abdffd8,0xfc8bffee,0x4c7fd41f,
0xff9803ff,0xf709ff02,0xe8bfea1f,0x3fe0ffff,0x3e0ffb84,0x40ffb84f,
0x0ffb84ff,0xff103ff7,0x2037e409,0x0ffbcff8,0x504ffb80,0x07ff31ff,
0x3ee0bfd0,0x04ff881f,0x3fee17fe,0x644ff881,0x00dfffff,0xff8817fa,
0x77ffec06,0x6fd87fe9,0x3e601bfe,0x709ff02f,0x8bfee1ff,0x3e0ffffe,
0x20ffb84f,0x0ffb84ff,0x7fdc27fc,0xf103ff70,0x17fc409f,0x13ffff20,
0xd81bfe60,0x301bfe6f,0x3fee03ff,0x204ff881,0x1ffb85ff,0xd984ff88,
0xf00fffff,0x27fcc09f,0x7ffffdc0,0x324ff83f,0x7fcc00ff,0xf709ff02,
0x20ffea1f,0x13fe0ffb,0x4ff83fee,0x7fc0ffb8,0xf70ffb84,0x07ff303f,
0x7c405fd8,0xfe800fff,0xc93fe01f,0x1bf600ff,0xf981ffb8,0x217fe03f,
0xff981ffb,0x3ffee203,0x403ff884,0xd8800fff,0xff984fff,0x300bfea1,
0x13fe05ff,0x5ff89fee,0x3fe0ffb8,0x7fc7fb84,0xff87fb84,0x3ea7fb84,
0x02ffa83f,0x3200ffd4,0xffb804ff,0xa87fe604,0x7ff102ff,0x541ffd40,
0x17fe02ff,0x3ea0ffea,0x6ff9802f,0x6c02ff98,0x4019beff,0xffc85ffb,
0x05ffffff,0xfe817fcc,0x7f46fd85,0xd07fdc1f,0xe8dfb0bf,0xe86fd85f,
0x226fd85f,0x0ffd86ff,0x5404fe80,0x7fcc02ff,0x7fffe406,0xf705ffff,
0x86ff880f,0x3fe00ffd,0xd86ff885,0xbff000ff,0xd003ff50,0x021fffff,
0x3fa17fe2,0x7fffffff,0xd817fcc0,0x13fea3ff,0x9337fff5,0x1ffec1ff,
0xffd89ff5,0x3613fea3,0x13fea3ff,0xf933bff9,0x3fee009f,0x00bfea00,
0xfe803ffd,0x7fffffff,0xf9009ff0,0x9ff933bf,0xf905ff80,0x9ff933bf,
0xd9899bd8,0x07fd84ff,0x43fffaa0,0xffecbcee,0x4cdffc42,0x441ffc99,
0x99bffb99,0x3ffffe20,0xffc80fff,0x20ffffff,0xfffffff8,0x7fffc40f,
0xf880ffff,0x0fffffff,0x7fffff44,0xff1000ef,0x017fd407,0x5555bff7,
0x26ffe255,0x41ffc999,0xe8800ffa,0x0effffff,0xe882ffc0,0x0effffff,
0x7ffffffc,0x3ffb326f,0x74310004,0x83ffffff,0xff980ffb,0x7ffffd44,
0x7f4c3fff,0x2a00dfff,0x84effffe,0x0dffffe9,0xbffffd30,0x7fff4c01,
0xffb100df,0xf90009ff,0x017fd40d,0xfffffffd,0x203feeff,0x2ff44ff9,
0xffffb100,0x3fffee09,0x6c46ffff,0xfb04ffff,0x417fffff,0x0005fffe,
0x2aeeaa20,0x7c0dfb00,0x7fffd46f,0x2603ffff,0x00998000,0x09800130,
0x40009800,0x2a200008,0x05ff500a,0x7ffffff4,0x40dfb7ff,0x005546ff,
0x7dc00880,0x6fffffff,0x4cc00220,0x00575009,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00101000,0x20199988,0x00404ffb,0x07ffd100,0x8802ffd8,0x40022000,
0x00802ee9,0x20000000,0x0efb8efb,0x204ffd80,0x00cccccc,0xb81effa8,
0x205fc8df,0x1ff9aff9,0x2027fdc0,0x1ff9aff9,0x3f66fb80,0x7fff5404,
0xefb81fff,0xfff984fd,0xe8803c9c,0x3fa201ef,0x3e602ffd,0x2ff9802f,
0x1ffffd40,0xc9cfff98,0xfd11ff03,0x3a23fe01,0x3ffea00f,0x05ffb005,
0x0ffffff8,0x2027fd40,0x8805fffb,0x5c01fffe,0x4404fdef,0xb001fffe,
0x81bfe1ff,0xfeeffffe,0x5515441f,0xfffdfd81,0x02a9805f,0x05511a98,
0x5c027fdc,0x376604ff,0xfd81ed88,0x905ffffd,0x6409ffff,0x9804ffff,
0x1551002a,0x33333300,0x20035500,0x2a2002a9,0x5154400a,0x0aa88015,
0xda8f6600,0xfffff901,0x0003ff53,0x03cb88c4,0x88006620,0x0f6c4019,
0x880f6c40,0x44620019,0x665403cb,0x02cca802,0x00006620,0x00000000,
0x00000000,0x00000000,0x27fffffe,0x7ffc1ffa,0x0005ffff,0x3ffffb20,
0x3fffb204,0x0000004f,0x00003fee,0x00000000,0x89ffffd9,0x3dfffffc,
0xffffff50,0x05fe87ff,0xbfffff90,0x30fffe07,0x427fc1ff,0x3ffe27fc,
0x1fffffff,0x207fff80,0x9ffffff8,0x7ffc1ffa,0x3fe5ffff,0x207fcc3f,
0xffffffe8,0xffffe885,0x3ffea5ff,0x7c3fffff,0x2fffffff,0x2a003fee,
0xffffffff,0x7fffffc3,0x3ffea2ff,0x443fffff,0x5ffffffe,0x7fffffe4,
0xffffa85f,0x7f43ffff,0xffff9005,0xfff0bfff,0x3e0ff98d,0x227fc84f,
0xffffffff,0x7fcc01ff,0x3ffe02ff,0x1ffa9fff,0x7fcccccc,0xf31bffe5,
0xadffe81f,0xffe84b99,0x2a4b99ad,0xffffffff,0x7fffffc3,0x03fee2ff,
0x3ffffea0,0x7ffc3fff,0x2a2fffff,0xffffffff,0x4d6fff43,0x4ffe44b9,
0x441ffeb9,0x99bffb99,0xc802ff40,0xffeb99ff,0x317fffc1,0x427fc1ff,
0x5cccc7fc,0x80199bff,0x204ffffb,0xa9fffffe,0x5ff801ff,0xf98bfffe,
0x017fea0f,0x4402ffd4,0x99bffb99,0x4cceffc0,0x83fee099,0xff733100,
0xdff81337,0x22099999,0x99bffb99,0x4017fea0,0x1ffdc7fc,0x7405ff30,
0x8ff9005f,0x7ffc3ffb,0xf83fe66f,0x207fc84f,0x74002ff9,0x2607fdcf,
0xfa9fffff,0x25ff801f,0x3e66ffff,0x007ff60f,0x2000ffec,0x3fe02ff9,
0xd8ffb804,0x3e601eff,0x013fe02f,0x3605ff30,0xff9001ff,0x2603ff98,
0x17fa02ff,0x3e63fe40,0x7feffc3f,0x7fc1ff32,0x2607fc84,0x3e2002ff,
0x201ffbaf,0xfa9fffe9,0x25ff801f,0xf32ffdff,0x003ff41f,0xf3000ffd,
0x027fc05f,0x7fff7fdc,0x5ff300ff,0x20027fc0,0xffd02ff9,0xd13fe400,
0x7fcc01ff,0x4017fa02,0x3ffa27fc,0xaff57fc0,0x37fe0ff9,0x07fdaaaa,
0xa800bfe6,0x03ff98ff,0xffa8aa88,0x3e5ff801,0xff35feaf,0xf0037fc1,
0xff3000df,0x556ffc05,0x3fee0aaa,0x03ffc9cf,0x7fc05ff3,0x00aaaaad,
0x3fe05ff3,0x3bff2006,0x4c02ffff,0x17fa02ff,0x7ff7fe40,0xaaff82ff,
0x20ff99ff,0xffffffff,0x0bfe607f,0x3fe6fd80,0x1ffa8006,0x3fe5ff80,
0xff99ffaa,0x200dff10,0x98006ff8,0x3ffe02ff,0x2e0fffff,0x13fe24ff,
0xff017fcc,0x01ffffff,0x3e20bfe6,0x3ff2006f,0x9800efff,0x17fa02ff,
0x7ffffe40,0x3e5ff00e,0x3e0ff9cf,0xfeeeeeff,0x00bfe607,0x3ff24ff8,
0x0ffd4000,0x5ff2ffc0,0x83fe73fe,0x3fe007ff,0x2ff98007,0x3bbbffe0,
0x03fee0ee,0x3fe609ff,0x3bbffe02,0xff300eee,0x801ffe05,0x6ffb9ffc,
0x202ff980,0xff9005fe,0x3e0dff73,0xff5ff72f,0x7e427fc1,0x00bfe607,
0xff50ffcc,0x1ffa8005,0x3fe5ff80,0x1ff5ff72,0xe800fff4,0x7cc001ff,
0x013fe02f,0x9ff03fee,0xf80bfe60,0x7fcc004f,0x003ffd02,0x2ffb9ff2,
0xd017fcc0,0x9ff200bf,0x2ff82ffb,0x41ffbff1,0x07fc84ff,0x6400bfe6,
0xffffffff,0x07fe4005,0xff93fe20,0x1ffbff12,0xb802ffdc,0x7cc005ff,
0x013fe02f,0x9ff03fee,0xf80bfe60,0x7fcc004f,0x00bff702,0x6ff89ff2,
0xd017fcc0,0x9ff200bf,0x2ff86ff8,0xf83ffff2,0x207fc84f,0xfd002ff9,
0xffffffff,0xdfd104c0,0xffb11c88,0xff917fc5,0x7ffc41ff,0x445b99ad,
0xb99adfff,0x405ff305,0xffb804ff,0xf9827fc0,0x013fe02f,0x2205ff30,
0xb99adfff,0x3f23fe45,0x7dccc42f,0x7f4099bf,0x4099999e,0x17fe47fc,
0xfff98bfe,0x3213fe0f,0x0bfe607f,0x266ffe20,0x881ffc99,0x2fffddff,
0x7fffffc4,0xff317fc6,0xfffa81ff,0xfa85ffff,0x25ffffff,0x9bffb998,
0x4ceffc09,0x3fee0999,0x33127fc0,0x81337ff7,0x99999dff,0x3fee6620,
0x7fd4099b,0x645fffff,0x237fcc7f,0xfffffffa,0x7ffff43f,0x3fe45fff,
0x5ff1bfe6,0x3e0fffd8,0x207fc84f,0xfb802ff9,0x84ff980f,0x3fffffe9,
0xcffffd88,0x3f617fc0,0xffd880ff,0xfb103eff,0x7d47dfff,0x3fffffff,
0x7ffffffc,0xf03fee2f,0x7fffd49f,0x7fc3ffff,0x22ffffff,0xfffffffa,
0xfffd883f,0x43fe43ef,0x3fea2ffd,0x43ffffff,0xfffffffe,0x7ec3fe45,
0xf30bfe2f,0x427fc1ff,0x3fe607fc,0x206fd802,0x2ea606ff,0x2009800a,
0x7ffcc2ff,0x2000c400,0xffff5018,0xff87ffff,0x22ffffff,0x27fc0ffb,
0xfffffff5,0xfffff87f,0x3fea2fff,0x03ffffff,0x000000c4,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x0e644000,0x8027fdc0,0x54004ffb,
0x7fcc1eff,0x1001ff9a,0xf5007ffd,0x664403df,0x26bfe601,0x1bf701ff,
0x3fa20bf9,0x6664002f,0x2a000ccc,0xf5001eff,0x7fdc03df,0x17ff4404,
0xcccccc80,0x013fee00,0x101effa8,0xffff8801,0x3f7bee01,0x7ef7dc04,
0x09ff5004,0x00ffff44,0x801efe88,0x7c404ffa,0x3a201fff,0x7dc01fff,
0xffb805ff,0x3fffe002,0xff5000ff,0x27fd4009,0x13f7bee0,0x200bfee0,
0x00ffffff,0x009fbdf7,0xfd709ff5,0xf701bfff,0x2a207f11,0x54402aa2,
0x2a002aa2,0x0aa8801a,0x800aa600,0x8fb801aa,0x554403f8,0x00553000,
0x3300154c,0x54003333,0x0d54001a,0x0aa8aa20,0x9802a980,0x51019999,
0x2a005545,0xfdfff01a,0xbfa81dff,0x000003fb,0x00000000,0x40000000,
0x003fbbfa,0x00000000,0x00000000,0x00000000,0x00000000,0x3ee05c00,
0x85ffd82f,0x57ee05fc,0xff881ffc,0x3fffff25,0x3ff26fff,0x06ffffff,
0x3fffffe6,0xf30fffe3,0x17ff601f,0xfffffff8,0x7ffffc2f,0xfff801de,
0x1fffe007,0x207fff80,0xff881ffc,0x00ffff05,0xffffffff,0xffffff85,
0x7fffc2ff,0x7fc2ffff,0x02ffffff,0x0881ffc4,0x7dc0bf90,0xf90bff14,
0x7fffe41f,0x3f26ffff,0x6fffffff,0x3fffff20,0x31bffe3f,0x00cc01ff,
0x3ffffffe,0x7ffffc2f,0x3e604fff,0xf9802fff,0xf9802fff,0xff102fff,
0x301ff90b,0xf805ffff,0x2fffffff,0x7ffffffc,0x7ffffc2f,0x7ffc2fff,
0x442fffff,0x74ffcccb,0x74ff81ff,0x927e40bf,0x27fc43ff,0x3aaaaaa6,
0x2aaa64ff,0x204ffeaa,0xff04feff,0x07fcc5ff,0x37ffffae,0x999dff80,
0x4e7fc099,0x702fffb9,0x7009ffff,0x7009ffff,0x6409ffff,0x13fe21ff,
0x027fffdc,0x266677fe,0x4ceffc09,0x6ffc0999,0x7c099999,0x099999df,
0x3ffffff2,0xf81ff74f,0x640df74f,0xc97fe24f,0xff9800ff,0x06ff9806,
0x413f3bea,0x3e66ffff,0x7f7ffc0f,0x27fc0eff,0x7c44ff80,0xfb9fd07f,
0xfb9fd00f,0xfb9fd00f,0x92ffc40f,0x33fa01ff,0x27fc07fd,0xf004ff80,
0x13fe009f,0x333bff70,0x03fee9ff,0xc9bea9ff,0xff90ff26,0x2009ff11,
0xfe801ffe,0x32ff601f,0xffbff04f,0x1703fe65,0x7fc2ffb8,0xb09ff004,
0xaff883ff,0x3e201ffb,0x201ffbaf,0x1ffbaff8,0x3e23ff20,0x75ff104f,
0x27fc03ff,0xf004ff80,0x13fe009f,0xff88ffb0,0xff81ff74,0x3fe2df54,
0xff887fb2,0xb800ffbc,0xffb804ff,0x323fe204,0x3fe099df,0x1ff35fea,
0xf87ff100,0x0aaaaadf,0x7fdc27fc,0x7cc7fd42,0x23fea03f,0x3ea03ff9,
0x203ff98f,0x0ffbcff8,0xff31ff50,0x556ffc07,0x6ffc0aaa,0x7c0aaaaa,
0x0aaaaadf,0x55556ffc,0x263ffb0a,0x1ff74ffe,0x2df34ff8,0x05fb4ffa,
0x009ffff9,0xf300dff3,0x95fc80df,0x7fc5ffff,0xff99ffaa,0xfcccb880,
0x7ffffc4f,0x27fc0fff,0x3f61ffd4,0xfd81bfe6,0xfd81bfe6,0xf901bfe6,
0x7ec09fff,0xff81bfe6,0x40ffffff,0xffffffff,0x7fffffc0,0x7fffc0ff,
0xff70ffff,0x29fdffdf,0xa7fc0ffb,0x2fffb7f9,0xfff882fd,0x1ffe800f,
0x401ffe80,0xddff92ff,0xcff97fc3,0x7fe40ff9,0x7c4fffff,0x0eeeeeff,
0x7fd427fc,0xff927fc2,0xfc93fe01,0x649ff00f,0x3fe200ff,0x93fe00ff,
0xfff00ffc,0xf81ddddd,0x0eeeeeff,0x77777ffc,0x777ffc0e,0x3ff20eee,
0xf74fd9ef,0xf14ff81f,0x367fbbef,0x09ff901f,0x7009ff70,0x7fa809ff,
0x97fc13f2,0x20ffaffb,0xf999dffb,0x8027fc4f,0x1ffb84ff,0xffa87fe6,
0x2a1ff982,0x1ff982ff,0xf900bfea,0x0ffcc09f,0x3fe05ff5,0x009ff004,
0x7fc013fe,0x7cc26004,0x5c1ff70f,0xf5ff14ff,0x03fd9f97,0xf300bfea,
0xdff300df,0xfddffb00,0x44bfe09f,0x360ffdff,0x227fc47f,0x9ff004ff,
0x7e41ffb0,0x5fffffff,0xffffffc8,0xfffc85ff,0x405fffff,0x3f202ffa,
0x5fffffff,0x3e009ff0,0x09ff004f,0x40013fe0,0x33fea3fe,0xf14fffb8,
0xddf33fbf,0x0bfea01f,0xd003ffd0,0xff8803ff,0xf04fffff,0x7fffe45f,
0x74c7ff60,0x027fc4ff,0x7fd44ff8,0x7fffff45,0xffe87fff,0x87ffffff,
0xfffffffe,0x17fd407f,0xffffffd0,0x13fe0fff,0xf8027fc0,0x09ff004f,
0x44b7fe00,0xfeffffff,0xff9bffe4,0x5ff500ff,0x556ffdc0,0x3fee2aaa,
0x22aaaaad,0xfd999efb,0x8bfe099d,0x2e0ffff9,0xfeffefff,0x4cceffc4,
0x4e7fc099,0x220fffca,0xc9999bff,0x2ffe21ff,0x1ffc9999,0x2666ffe2,
0x2a01ffc9,0x7ff102ff,0x3ff93333,0x3333bff0,0x99dff813,0x6ffc0999,
0x7c099999,0x099999df,0xf53ffe40,0x49fb3dff,0x3ff24fff,0x05ff500f,
0x7ffffff4,0x3fffa7ff,0x3a7fffff,0x7fffe43f,0xffb0bfe4,0xefffc81f,
0x7ffc4fd9,0x7c2fffff,0x1effffff,0x7cc07fdc,0x203fee4f,0x3fee4ff9,
0x204ff980,0xff702ffa,0xf09ff301,0x5fffffff,0xfffffff8,0x7ffffc2f,
0x7ffc2fff,0x802fffff,0x401981a8,0x3fea1ffe,0x80bfea07,0xfffffffe,
0x3ffffa7f,0xff37ffff,0x4ffffc81,0xfff30bfe,0x3e002601,0x2fffffff,
0x1ef7fffc,0x3fe06fd8,0xff81bf66,0xff81bf66,0x40bfea06,0x1bfe06fd,
0x3ffffffe,0x7ffffc2f,0x7ffc2fff,0x7c2fffff,0x2fffffff,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x0bffa200,0x07bfea00,0xa8027fdc,0x06209803,0x10006e60,
0x4013fa33,0x33000999,0x40098801,0x02006209,0x00330660,0x44266001,
0x104c4099,0x28826013,0x88001980,0x04cc4199,0x7dc00260,0x3fea002f,
0x3f7bee04,0x027fdc04,0x01fe67fe,0xf7001ffe,0xb003ff1f,0x3e2009ff,
0x3ffe203f,0x3e67fe01,0x9fffb307,0x7ec77dc0,0x3f637ee3,0x3ff601ef,
0x440dff99,0x80ef9afe,0x09ff0ffb,0x3002ffdc,0xfe983dff,0x37ffe01f,
0x00154c02,0x15440355,0x7fdc0155,0x7fffdc04,0x07ffc404,0xdf5ff700,
0x005ff900,0x0fffffff,0x01ff9fd1,0x213fffee,0x6ffefffa,0x70ffff20,
0xfffffddf,0xf13ff701,0x7ff4409f,0x11ff900f,0x37ee09ff,0xff9804fd,
0x3ffb100d,0x1bffffe0,0x00000000,0x50019900,0x36a007bb,0x57fdc002,
0x0664c02c,0xeffeee80,0x7951cb85,0x441eed40,0x7ff50cff,0x7dc1e5c0,
0x3ffc9cff,0x05971cc8,0xb8039910,0x32202e62,0xb803970c,0x0997003c,
0x97ffeea6,0xfffffffa,0x3fffea3f,0x3ea3ffff,0x3fffffff,0x00200040,
0x1fee0000,0x7c400000,0x4400003f,0xd81ff700,0xff70006f,0x0027fc49,
0x00000800,0x00000000,0x21ffd100,0xfffffffa,0x3fffea3f,0x3ea3ffff,
0x3fffffff,0x04fffd98,0x013fff66,0x83dfffd7,0x7ffffec8,0xdfffd700,
0x3fff6a03,0x3fae03ff,0x7f5c1eff,0x3f60dfff,0x7feccccf,0x3dfffd70,
0x9ff03fee,0x3fe07fdc,0x3fff6604,0x7c0ffb84,0xf03fee4f,0x207fdc9f,
0x07fdc4ff,0x7fe413fe,0x7ff73312,0x5ccc4133,0x22099bff,0x99bffb99,
0x7f7ffd40,0xefffa86f,0xffe886ff,0x3e61ffff,0x07ffffff,0x7fffff44,
0xffffc81f,0xfe883fff,0x7c1fffff,0x0efffeff,0xfffffffd,0xfffe88ff,
0x1ff71fff,0x3fee4ff8,0xfa827fc0,0x5c6ffeff,0x727fc0ff,0x24ff81ff,
0x27fc0ffb,0x9ff03fee,0x2607ff60,0xff9802ff,0x02ff9802,0x3ea19ff1,
0x433fe23f,0x7fe43ffa,0x3a1c99ad,0x01ff22ff,0x9335bff9,0x10dffa83,
0xbff907ff,0x0b839335,0xefd97fdc,0x41999999,0xc99adffc,0xff81ff71,
0xff03fee4,0x219ff109,0x3fee3ffa,0xff727fc0,0x3ee4ff81,0x2e27fc0f,
0x527fc0ff,0x260dffb5,0xff9802ff,0x02ff9802,0x6fd81ff7,0xdfb03fee,
0x2a037fc4,0x03fdc3ff,0x3a00dff1,0x0ffe20ff,0x4000dff1,0x1ff93ff8,
0x80dff100,0x27fc0ffb,0x4ff81ff7,0x7ec0ffb8,0xff03fee6,0x3e07fdc9,
0xf03fee4f,0x40ffb89f,0x3fffe4ff,0x05ff300e,0x3005ff30,0x3ff605ff,
0x27fecccc,0xeccccffd,0x00bfea7f,0x7fb81ff7,0x400bfea0,0x1ffc45ff,
0x8800bfea,0x54ffcccb,0x20881bff,0x7dc02ffa,0xf727fc0f,0xd84ff81f,
0xfeccccff,0xff03fee7,0x3e07fdc9,0xf03fee4f,0x40ffb89f,0x0b7fe4ff,
0x3005ff30,0xff3005ff,0x3ffffa05,0x3fa7ffff,0x7fffffff,0xfb007fee,
0x5c0ff70f,0xff8801ff,0x2e1ffc44,0xff9001ff,0x6c9fffff,0x2ffeefff,
0xf7007fee,0x2e4ff81f,0x427fc0ff,0xfffffffe,0xf03fee7f,0x207fdc9f,
0x03fee4ff,0x0ffb89ff,0x05ff27fc,0x3005ff30,0xff3005ff,0x267bf605,
0x3f619999,0x1999999e,0xf900bfee,0x207fb81f,0xf8802ffb,0x21ffc45f,
0xfb802ffb,0x4ff999df,0x77ffffdc,0x700bfee2,0x24ff81ff,0x27fc0ffb,
0x4cccf7ec,0x03fee199,0x07fdc9ff,0x0ffb93fe,0x3fee27fc,0x39727fc0,
0x005ff300,0xf3005ff3,0x03ff205f,0x2003ff20,0x7dc05ff9,0x81ffa21f,
0xff005ff9,0x4c3ffb8d,0x7fd805ff,0xe8827fc4,0x05ff984f,0x07fdc000,
0xff909ff7,0x41ff7001,0x3fee4ffb,0xfb93fee0,0x713fee0f,0x27fdc1ff,
0x17fcc002,0x4017fcc0,0xff502ff9,0x3ea0881b,0x3a0440df,0x1b989dff,
0xfd31bff3,0xdffe80ff,0x7ec1b989,0x3fffb8bf,0x989dffe8,0x4c7ff61b,
0xff304ffe,0x44efff40,0x0ee881b9,0xf719ff50,0xbff509ff,0x3fea0881,
0x24fffb8c,0xffb8cffa,0x233fea4f,0x7d44fffb,0x4fffb8cf,0xf3009ff1,
0x5ff3005f,0x405ff300,0xffeefffd,0x777ffec2,0x7ffcc2ff,0x3f62ffff,
0x07feffff,0x7fffffcc,0x7fffcc2f,0xf983feff,0x22ffffff,0xeffefffb,
0x35ff704f,0xffffff30,0x40ff505f,0xeffffff8,0xdfffb04f,0x7fc45ffd,
0x24feffff,0xeffffff8,0x3fffe24f,0x7c44feff,0x4fefffff,0x2620fff7,
0x099bffb9,0x2ffee662,0x2e662099,0xb8099bff,0x82ffffff,0x2ffffffb,
0xeffffd88,0x2ffff621,0xfd8807f9,0xfa81efff,0x03fd8eff,0x3dffffb1,
0xd9efffc8,0x7fff104f,0x3ffff620,0x404fc81e,0xfd9efffa,0x3fffee04,
0x7ffd42ff,0x7d44fd9e,0x44fd9eff,0xfd9efffa,0x9efffa84,0x09ff14fd,
0x3fffffea,0x3ffea3ff,0x2a3fffff,0xffffffff,0x00266203,0x44002662,
0x0004c401,0x04400620,0x98018800,0x054c4000,0x2a600c40,0x00033000,
0x33002662,0x3000cc00,0x40198003,0x3ffea018,0x2a3fffff,0xffffffff,
0x3ffffea3,0x00003fff,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00988000,0x44028826,
0x0198000a,0x88333100,0x98000099,0x00999809,0x100006e4,0x033014c0,
0x804c4131,0x2600a209,0x19988001,0x00004cc4,0x0cc0bfb0,0x41300300,
0x7f900028,0x7fc3fee0,0x3bfff504,0x5ffb809b,0x0f7fcc00,0x0007ffa6,
0xff709ff0,0x7cc1fb9d,0x8dfb804f,0x7ec1effd,0x427dc2ff,0x0ef9afe8,
0x9ff0ffb8,0x002ffdc0,0xe983dff3,0x130001ff,0xffb817fc,0x3fffee05,
0xf0ffb84f,0xfe98009f,0xf11ff901,0x3b3b609f,0x3ee04fff,0xf3004fdd,
0x3f6201bf,0x3fe0001f,0x7fffed44,0x02ff40ff,0x7fff77dc,0xf5bf50ff,
0x8807fc4b,0xf900fffe,0x209ff11f,0x804fddfb,0xb100dff9,0x7d4003ff,
0x2e0ff11f,0xfd84fddf,0xc84feeff,0x04ff88ff,0x0ffffeb8,0x00b98ae0,
0x2203cb82,0x003970cc,0x32e00797,0x13fe0004,0x09fffffb,0x3ee00ff2,
0x3ffc9cff,0x6c3f65f9,0x0e64402f,0x80b98ae0,0x03970cc8,0x97003cb8,
0x8ffdc009,0x0cc883c9,0x2ffc4397,0x2e62b804,0x7fffec00,0x001006ff,
0x00100010,0x00100010,0x46a27fc0,0x7f40fff8,0x49ff7005,0x25f74ff8,
0x005fb8fe,0x80010006,0x40004000,0x07fee000,0x7fcc0600,0x0044000d,
0xff8cffa8,0xffd704ff,0x7f5c019f,0x3ae00cff,0x2e00cfff,0x200cfffe,
0x00cfffeb,0x3fffff6a,0xffffea84,0xb80815c4,0x8a7fc0ff,0xff8efcef,
0x7fffdc00,0xfffb304f,0x7ffecc09,0x3fff6604,0x7ffecc04,0xfffff504,
0x2e07ffff,0x7c4fffff,0x2e02dfff,0x00dffffe,0x677cdbfa,0xffffd87f,
0xffd80fff,0xd80fffff,0x0fffffff,0xffffffd8,0xffffd80f,0xffc80fff,
0x6c4fffff,0x0fffffff,0xfffcbfcc,0xff03fee3,0x6c77f5c9,0x7ffec02f,
0xffa84fee,0xfa86ffef,0xa86ffeff,0x06ffefff,0xdffdfff5,0xffffff50,
0xffb07fff,0xe989fddf,0xf82fffff,0x0efffeff,0x2ff27ff0,0x3fea0ffa,
0x44ffda9d,0xfda9dffa,0x4effd44f,0x7d44ffda,0x4ffda9df,0x6d4effd4,
0x6ffd44ff,0x7d49ff10,0x87ff50df,0xffffdff9,0xf81ff71f,0x0bf5084f,
0x4085ff88,0xff50cff8,0xa867fc47,0x33fe23ff,0xf887ff50,0x87ff50cf,
0x9affb998,0x2ffc4099,0xffec9804,0x3ee05c1f,0xf2ff882f,0x743ff31f,
0x747fe86f,0x747fe86f,0x747fe86f,0x747fe86f,0x747fe86f,0xd27fc0ff,
0x37fc41ff,0x2a77ffe6,0x81ff74ff,0x1ff104ff,0x00dff980,0x3f607fdc,
0xfb03fee6,0x3607fdcd,0x207fdc6f,0x3fee06fd,0x06ffcc01,0x01ffe400,
0xff81ffc4,0x1ff55fab,0x7fe427fc,0x3f213fe0,0x3213fe0f,0x213fe0ff,
0x13fe0ffc,0x5ff83ff2,0x17fe4ff8,0xdff31ffa,0x1ff76fe8,0x5fb04ff8,
0x7ffc0131,0x9ffb02df,0x6cffd999,0xfeccccff,0x3333ff67,0x7fec7fec,
0x07fecccc,0x3e007fee,0x1882dfff,0xb881ffc8,0xd04ffccc,0x3f27f9bf,
0x2e0ffe27,0x07ff11ff,0x3fe23ff7,0xf11ffb83,0x23ff707f,0xffb83ff8,
0xff09ff11,0x3613fe29,0x217fcc7f,0x81ff76fd,0x9dfa84ff,0xfd305fff,
0xfe85ffff,0x7fffffff,0x3ffffffa,0x3fffa7ff,0x747fffff,0xffffffff,
0x007fee07,0x3fffffa6,0x3fbbfea2,0xfffc86ff,0xf904ffff,0x9ff51fff,
0x7dc2ffc4,0x70bff10f,0x17fe21ff,0x7fc43fee,0xf10ffb85,0x21ff70bf,
0x4ff84ff8,0xffd0bff1,0x7ec2ff98,0xff81ff76,0x7f47fc44,0x32602fdb,
0x3f61fffe,0x1999999e,0x26667bf6,0x27bf6199,0x6c199999,0x999999ef,
0x007fee01,0x1fffec98,0x9ffffff3,0x99dffb81,0xfd104ff9,0x81dfffff,
0x47fe87ff,0x47fe87ff,0x47fe87ff,0x47fe87ff,0x47fe87ff,0x27fdc6ff,
0x5ff88fff,0x3f617fcc,0x21ffcc06,0x3e6df3fc,0x47ff9004,0xfc800ffc,
0x0ffc800f,0x001ff900,0x0005ff50,0x3310fff2,0x223fec03,0x3fa204ff,
0xff904fff,0x89ff913b,0xfc89dffc,0x4effe44f,0x7e44ffc8,0x4ffc89df,
0x644effe4,0x97fec4ff,0x3f64fffb,0x3ffd89cf,0x3f617fcc,0x517fe406,
0x4f9bfcbf,0x0ffe40c4,0x0881bff5,0x11037fea,0x2206ffd4,0x206ffd40,
0x37fe6008,0xf9031020,0x01dd103f,0x7f4c7ff6,0x27fe204f,0x7fffc400,
0x7c40efff,0x0effffff,0x7fffffc4,0x7ffc40ef,0x440effff,0xefffffff,
0x7ffffcc0,0x3fe24fef,0x986fffff,0x837ec2ff,0x3a26fff9,0x3fb3f20f,
0x7f77fd42,0xfffd86ff,0x7ec2ffee,0x42ffeeff,0xffeefffd,0xeefffd82,
0x7ff402ff,0x7fd43fef,0x506fffee,0x7ffdc0ff,0x204feffe,0x362005fa,
0x2204ffff,0x204ffffd,0x04ffffd8,0x13ffff62,0x4ffffd88,0x27bffea0,
0x7ff444fc,0xff980cff,0xfa837ec2,0x10ff20df,0xff309ffb,0x2019ffff,
0x2ffffffb,0xffffffb8,0xfffffb82,0xffff702f,0xfe9805ff,0x7fcc3fff,
0x900cffff,0xfffc809f,0x2604fd9e,0x0130001a,0x4c000980,0x0004c000,
0x01880026,0x3e600cc0,0x8837ec2f,0x8008001a,0x22001998,0x99880099,
0x00998800,0x80013310,0x26200998,0x00a98019,0x00000130,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x54400000,0x000cc000,0x2620ccc4,0x2a620009,0x00033101,0x4cc40000,
0x9884cc01,0x40022009,0x008000a8,0x00040000,0x0980ccc4,0x22098062,
0x44033001,0x00019999,0xff500662,0x5c09b3bf,0x3e6005ff,0x7ff4c1ef,
0x7ffe4401,0x07fdc1ef,0x33fff200,0x77fcc000,0x267ff601,0xffb80dff,
0x542fffff,0x44d9dfff,0x4fffbaff,0x3bfff6a0,0xfb1bf74e,0x3e6005df,
0x33ff01ef,0x4cffc0ff,0x5ffb807f,0x0fffffb0,0xffffd900,0x3fb3b609,
0xbbf704ff,0xbff3009f,0x07ff6201,0xffdeffd8,0x003fee0f,0x5fffffe8,
0x037fe600,0xff89ffb8,0xffdffb04,0xced85fff,0x7fc4fffe,0x84fffffe,
0xfffffffc,0xfffddf74,0xff9803ff,0x3ffee00d,0x3ffee04f,0x6efdc04f,
0xffeec84f,0x3ffa2007,0x8205ffff,0x199103cb,0x7970072e,0x4c132e00,
0x8bfea4ff,0xf5000ffb,0x007fee3f,0x66401e5c,0x3e605971,0x081bf22f,
0x3ffe0f2e,0x547fe8ae,0x9ff10dff,0x2a73ffee,0x1e5c05ff,0x803dda80,
0x64403dda,0x6403970c,0x3ffa007f,0x804b99ad,0x00220008,0x04400088,
0x3ea1ffa8,0x083fee1f,0xff89bf20,0x00040402,0x98ff5001,0x7c0000ff,
0xd1fee0ff,0x74ff81ff,0x0ffd89ff,0x000000c0,0x90000004,0x3fea00ff,
0x7ff5c005,0xfeb80dff,0xeb80dfff,0x700dffff,0x41bffffd,0xdff10ffb,
0xffd8ffb8,0x70ffb82e,0x3ff601ff,0x02ffeacf,0x019fffd7,0x7fa87fea,
0x7fc0ffb8,0x55313fe4,0x4ff85ff8,0xffb81ff7,0xfffffb81,0x7c0ffb84,
0xfffeb84f,0xfffff00c,0x00ff900b,0xf0007ff6,0x1dfffdff,0xfffefff8,
0x7f7ffc0e,0xfff80eff,0xf70efffe,0x81dfd11f,0xffffeffb,0x5effc41f,
0xddf103ff,0x3ffdffff,0xffffffd8,0x97dfd00f,0x1ff70bff,0x13fe4ff8,
0x3e13fe20,0xb81ff74f,0x7ffec1ff,0xffb84fee,0x3f627fc0,0x80ffffff,
0x805fffff,0xffd007fc,0xfb817000,0x3ee05c2f,0x3ee05c2f,0x7dc0b82f,
0xf71ff72f,0x9fff703f,0xf90bff53,0x14407fff,0x93f69ff3,0xfda9dffa,
0xffffd04f,0x1ff701bf,0x13fe4ff8,0x3e13fe20,0xc81ff74f,0x17fe20ff,
0xf03fee02,0x4effd49f,0x9984ffda,0xfc805ff9,0xff066cc7,0x3e20000d,
0x3ff8803f,0x003ff880,0x3fee7ff1,0xfb82ffb8,0x207fec4f,0x5512fffc,
0xf51ff801,0x7f437f4b,0x9a8dfb87,0xf03fee00,0x8027fc9f,0xa7fdc6ff,
0x3ff40ffb,0x20037fe6,0x27fc0ffb,0x0ffd0dfd,0xfc805ff8,0x453ffe27,
0x710006ff,0x109ff999,0x09ff9997,0x9ff99971,0x3f332e20,0xf31ff74f,
0x0ffb85ff,0xffb0ffdc,0x1ff31ffd,0x99ff9530,0x427fcdfb,0x77e40ffc,
0x0ffb8009,0x09ff27fc,0x7dcbff60,0x41ff74ff,0xfff83ffc,0x3fee02df,
0x9ff27fc0,0x7c01ff90,0x27fc805f,0x3fe6fff9,0xfffc8007,0x7e44ffff,
0x44ffffff,0xfffffffc,0xfffffc84,0x21ff74ff,0x3ee3fffb,0x98ffdc0f,
0xaeff9aff,0xffffd87f,0xf16fffff,0x83ff707f,0xeffffff9,0x207fdc0c,
0x013fe4ff,0x7fffffcc,0xdfff74ff,0x3a60dfff,0xb82fffff,0x8a7fc0ff,
0x1ffb83ff,0x32017fe0,0xd17ff47f,0x7dc003ff,0x4ff999df,0x26677fee,
0x37fee4ff,0x5c4ff999,0xff999dff,0x7d41ff74,0x81ff71ff,0x4ff90ffc,
0x5c6ffffa,0x99ff99ef,0x0bff1099,0xfe881ff7,0x46ffffee,0x27fc0ffb,
0x7d4009ff,0x74ff9eff,0x07ffffff,0x3fffd930,0x7fc0ffb8,0xf70bff14,
0x02ffc01f,0x20d43fe4,0x36005ffb,0xb27fc47f,0x24ff88ff,0x27fc47fd,
0x9ff11ff6,0xff703fee,0xfd03fee7,0x3f23fe4f,0xf1fec2ff,0x43ffc03f,
0x86fe87fe,0x3fee1ffc,0x0013fee0,0x29ff0c40,0x00018ffb,0xff70fff2,
0xff27fdc1,0xf80ffd0f,0x07fc805f,0x35bfff10,0x3ffb0b73,0xfd93ffa6,
0x49ffd31f,0xffd31ffd,0xd31ffd89,0x03fee9ff,0x3fee5ff5,0xfa8fff20,
0x0bffe64f,0x13fee9f9,0x44effe41,0x7fc44ffc,0x2a0ffb84,0xfffb8cff,
0x000ee884,0x3fee9ff0,0xf9031000,0x8cffa83f,0x3f24fffb,0x4ffc89df,
0x6402ffc0,0x3fea007f,0xb85fffff,0xfeffefff,0x3fbffee4,0x3fee4fef,
0x44feffef,0xeffefffb,0xf91ff74f,0x3ee1dffd,0x86fffeff,0xfffffffe,
0x3bfea1ff,0x2fdeffef,0x3fffffe2,0xcfff80ef,0x445ffcaa,0xfeffffff,
0x0007fa84,0x07fdd3fe,0xfeeffa80,0xfff886ff,0x224fefff,0xefffffff,
0x7ffffdc0,0xfff16fff,0x03ffffff,0xeffffd88,0x3dfff903,0xfffc89fb,
0x7e44fd9e,0x84fd9eff,0xfd9efffc,0xff91ff74,0x7fecc1bf,0xf9103fff,
0xdff39fff,0xfbaffec1,0x7ec42fff,0x3a604fff,0x04ffffff,0xfb3dfff5,
0x0009f909,0x0ffba7fc,0xfffff300,0x3fea019f,0x444fd9ef,0x704ffffd,
0xffffffff,0x3ffffe2d,0x2001ffff,0x00260018,0x02600098,0x88001300,
0x40018801,0x10220019,0x00130033,0x00555d4c,0x0a9800cc,0x44266000,
0x99880019,0x00066001,0x00000013,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x10000bf9,0x88004c43,0x26660199,0x80ff7099,0xdddb0019,0x4cc400dd,
0x8004cc41,0x00262098,0x00a0cc00,0x01988035,0x80ccc400,0x0cc000a8,
0x19804c40,0x03300988,0x80004cc4,0x909ff2fe,0x15fb01ff,0xff3003fd,
0x7fffc03d,0xb109fb5f,0xdfffffff,0x0ffffff0,0x107bfe60,0xd1005ffb,
0x401df35f,0x41efffeb,0x0bfb1ff9,0xb75dfff1,0x0001ffa8,0xf505ffd1,
0x409b3bff,0xf9105ffb,0x449f707f,0x4fb83ffc,0x7ffffe44,0xf897fa06,
0xf909ff0f,0xffff301f,0x1bff300b,0x5ffeee80,0xfff983ff,0x06ffffff,
0x37fe6000,0x00bfee00,0x403fffa2,0xffffffe8,0xfe97fd41,0xffecfb86,
0x3ffffe6f,0xfd1000ff,0x3b3b603d,0xbf704fff,0xfdf309fb,0x260ff887,
0x7fc43fef,0x3ffffa20,0x97fa07ff,0x213fe3c8,0xb9300ffc,0x00f2e007,
0x13237fe0,0x2fecbff6,0x65c00100,0x01993003,0x64039910,0x1c99adff,
0x407223b8,0xff82f2a1,0x000fffff,0x5c100795,0x2199103c,0x3fc881cb,
0x7e4417ec,0x3ee17ec3,0xe80a60cf,0x427fc05f,0x00000ffc,0x5ff80008,
0xfd8ffe20,0x7ffecc05,0x00002004,0x7fc40200,0x00000006,0x0001ffa8,
0x00004000,0x5fb8ff20,0x5fb8ff20,0x4000ffd8,0x27fc05fe,0x3fe07fe4,
0x3fe05fff,0x004fffba,0xffa817fe,0xfa817f61,0x5c6ffeff,0x1effd8df,
0x0bfffff0,0x7ffdd7fc,0x8017fd44,0x205fffff,0x505fffff,0x059733ff,
0x817ffffe,0xeffd8dfb,0xfa813fa1,0xff89fe47,0x7c4ff200,0x04ffc80f,
0x3e02ff40,0x40ffc84f,0x205fffff,0xfffffeff,0x40bff004,0x4efec7fb,
0x433fe209,0x3bee3ffa,0x80fffffe,0x205fffff,0xfffffeff,0x4007fee4,
0x205fffff,0x505fffff,0xbffff7ff,0x0bfffff0,0x7fff77dc,0x40bfb0ff,
0xd9fe45fb,0xd9fe402f,0xffff502f,0x0bfd0017,0xffc84ff8,0x2ffcccc0,
0xd15dfff0,0x17fe00ff,0x7fec7fc8,0x03fee4ff,0x7ffdcdfb,0x983ffc9c,
0x3e05ff99,0x7fe8aeff,0x4c00bfea,0x2605ff99,0xf505ff99,0x3fff9fff,
0x05ff9998,0x3273ffee,0x40df93ff,0x17ea04fc,0xc80bf500,0x00dfffff,
0x9ff017fa,0x7c01ff90,0x83ffe05f,0xbff007fb,0x3f63fe40,0x3ff63eef,
0x27fecccc,0x3fe24ffb,0xf02ffc04,0x13fdc1ff,0xff000bff,0x417fe00b,
0xff30fffa,0x702ffc05,0xa7fc49ff,0x23dd17fa,0x1ff103fd,0x007fc400,
0x7ffffecc,0xf80bfd00,0x00ffc84f,0x4ff817fe,0xff80154c,0xfb1ff205,
0x3ffffa0b,0x3ee7ffff,0x2027fc0f,0x13fe05ff,0xdffd8553,0x3e01b989,
0x0bff005f,0xff88bfea,0xb817fe03,0x9a7fc0ff,0xd4ffa8ff,0x22bf605f,
0x32fd8019,0xffb88013,0x80bfd04f,0x0ffc84ff,0xff817fe0,0x2ffc0004,
0x7ec3ff70,0x333dfb05,0x7fdc3333,0x3e027fc0,0x013fe05f,0x7fffff4c,
0x017fe02f,0xffa82ffc,0xf80ffe21,0x03fee05f,0x27fe29ff,0x03ff6ffd,
0xffff3bf5,0x7d57ea01,0xdff3005f,0xff017fa0,0xf80ff909,0x013fe05f,
0x4c0bff00,0x417f63ff,0xfb800ffc,0x2027fc0f,0x13fe05ff,0xdffff700,
0x802ffc03,0x3ff505ff,0xff01ffc4,0x207fdc0b,0x3ebfe4ff,0x40ffafff,
0xfb370ff8,0xf11ff105,0x7fc00bfb,0xf80bfd05,0xdfd1134f,0x3e05ff80,
0x7fc0004f,0x457ff405,0x2a099dfe,0x70440dff,0x04ff81ff,0x9ff02ffc,
0x009fd000,0x7fc017fe,0x443ff505,0x17fe03ff,0x7fc0ffb8,0x337fbfa4,
0x3fc87fdf,0x7e40ff44,0xd8bf3f93,0xffd9899b,0x333dfd04,0x753fe133,
0x7c03ffff,0x013fe05f,0xa80bff00,0xffffffff,0x77ffec6f,0x3fee2ffe,
0x3e027fc0,0x013fe05f,0x2001ff10,0xbff005ff,0xf887fea0,0x817fe03f,
0x27fc0ffb,0xff35fffb,0x445fa8df,0x35fa83fe,0x7c5df9df,0x6fffffff,
0x3fffffa0,0x369ff5ff,0xffb83fff,0x46ffffff,0x7dc004ff,0x6fffffff,
0xfffffd30,0xfff70dff,0x7fdc5fff,0x3ee27fc0,0x6fffffff,0x260027fc,
0x3ffee05f,0x2e6fffff,0xffffffff,0xf887fea6,0x3fffee3f,0x7dc6ffff,
0xf927fc0f,0x97ffe1ff,0x3fe60fe8,0x43fa22ce,0x24fffffa,0xbffffffd,
0x3ffffa00,0x02205fff,0xffffffb8,0x027fc6ff,0x3ffffee0,0x09806fff,
0x404cc400,0x27fc0ffb,0x3fffffee,0x027fc6ff,0xfb802620,0x6fffffff,
0x3fffffee,0x87fea6ff,0x3fee3ff8,0x46ffffff,0x27fc0ffb,0x7fe4bff7,
0xff50ff24,0x81fe4bff,0x133305f8,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x1bbbbb60,
0x004ccccc,0x440d54c4,0x30026209,0xff11ff20,0x88018807,0x98826209,
0x6c06601a,0x3106eeee,0x54000033,0x80000003,0x27fc0ffb,0x44000220,
0x00c40199,0x98000331,0xfff001aa,0x3ffe0fff,0x3fa205ff,0x7441ffff,
0xb80ef9af,0x324fffff,0x81ffc47f,0x00dffffb,0x1df35fd1,0x5c37ffd4,
0xfffff04f,0xffffe88f,0x05fd304f,0xff827fdc,0x307fffff,0x5c1fffd9,
0x827fc0ff,0x004fffec,0x6407bfe6,0x5c0dffff,0xfa8000ff,0xfd31ffff,
0x77740005,0xfff105ff,0xd103fdbd,0xffb01fff,0x7e49fddf,0x6c1ffc47,
0x0effffff,0x81fffd10,0x220fe898,0x220000ff,0x4fffffff,0x2e06ffd8,
0xffff04ff,0xff90ffff,0x7dc1ffff,0x6c27fc0f,0x0efdbbef,0x806ffcc0,
0xfffffffe,0x0003fee1,0x3ddbfff3,0x0081bff6,0x7ec17fe0,0x3322001f,
0x085ff881,0x7ff11ff2,0x3ee4ffa8,0x0732204f,0x3f627fe4,0x2a008802,
0x361ffe60,0x066406ff,0xaaaacff8,0x4d77fe42,0x207fdc19,0x427e44ff,
0x1e5c04fb,0x933bff70,0x07fdcbff,0x403ff600,0x7f5c6ffd,0x7fc00cff,
0x004ff865,0x06ffcc00,0xff88ff90,0x7ec37f43,0x9500800f,0x817ee5fd,
0x0dffffeb,0x440ffc80,0x7c0001dd,0x2ffc402f,0x3e07fdc0,0xdb9be24f,
0x0000fd8d,0x3f61bfe2,0x041ff70f,0xb102ff40,0x7fffec3b,0x3fe00fff,
0x7ff13fbd,0xfffff300,0x7ffc5fff,0x47fc82df,0x3fe23ff8,0x70fffd43,
0x3dffb1bf,0x45fecd4c,0x3ffe00ff,0x400efffe,0x7cc006fd,0x2fffffff,
0xff700bfe,0x81ff7003,0x6cbee4ff,0x24fa8fff,0xfffffff9,0x20ffe62f,
0x1ff72ffa,0x7c03dffb,0x7fd4004f,0x04ffda9d,0x44fffffe,0xff9803ff,
0x22ffffff,0x2fffffe9,0x7ff11ff2,0xff917fcc,0x777dc5ff,0xf70fffff,
0x00bf6bdf,0x42ffb817,0x02ffca98,0x7ffffcc0,0x3bfe2fff,0x7fec0bcd,
0xfb83cdca,0xf927fc0f,0x2213ff31,0x3fffe65f,0x3ea2ffff,0x73ff981f,
0xfffffdff,0x77fd5541,0x7f402aaa,0xf707fe86,0x7fc45dff,0xaaaa8803,
0xc980effc,0xff91fffe,0xf51ffe41,0xf9ffd13f,0x67ffdc7f,0x8263ffc9,
0xf10005fa,0xffffe87f,0xaaa88003,0x3e0effca,0x23ffffff,0xfffffffe,
0xb83fee0e,0x7ddf64ff,0x2aa26f85,0x20effcaa,0xff881ffb,0x939fff74,
0x3ffe27ff,0x07ffffff,0x7fe427fc,0x17fffee0,0x2000ffe2,0xc801ffe8,
0x17ff93ff,0x7d49fff9,0xf89effcf,0x893fee3f,0x1ff104ff,0x3332e200,
0x7f7644ff,0x774c0eff,0x0fff4401,0x3ffb2aaa,0x77dffd1f,0x7fd4dffb,
0x24fffb8c,0xdf0bf77d,0x20fff440,0xff881ffb,0x7c49ff74,0xff99914f,
0xbb89999d,0xfb83ff88,0x3ffbfa1f,0x003ff885,0x0c42ffd8,0xffc97fe4,
0x4ffeefff,0x21bffff3,0x3fee2ff9,0xfd827fc0,0x3f201332,0x04ffffff,
0x3f62ffdc,0x17fec06f,0xfd4ffb80,0x221ffb0d,0xfeffffff,0x3fea3f24,
0x6c0bf11a,0x1ffb82ff,0xff73ff98,0xff04ff81,0x46ffe409,0x0ffb85ff,
0x442ffcb2,0x7dc003ff,0xeeffa84f,0x3ff26fff,0x4ffa8eff,0xfa85fff1,
0xf03fee1f,0x2abf509f,0xdffb85ff,0x804ff999,0x7ffe46fe,0x009ff700,
0x7fdaffc4,0x3ea1ffb8,0x24fd9eff,0x1fffd2fb,0x3fee07f3,0x507ff504,
0x03fee5ff,0x13fe09ff,0xfff7ffe8,0x7fc0ffd0,0x003ff885,0x7cc1bfe6,
0x20cfffff,0x0c408ffc,0x1bf61bfa,0x4ff81ff7,0x6fc47fc4,0x447fd85f,
0x5ff804ff,0xf980ffe8,0x7fd4006f,0xfc83ff94,0xff31980f,0x9b737c43,
0xff301fb1,0x437fc40d,0x1ff70ffd,0x9ff04ff8,0xfc9ffd40,0x4ffc89df,
0x3e217fe0,0xfff1003f,0x1ff98801,0x2e007fc8,0x7ff90cff,0x7fc0ffb8,
0x9fc9fe44,0x31ffd85f,0x30229ffd,0xff907ffb,0x201fff10,0x3ffae618,
0x2a1bff31,0x3fd806ff,0x4fb84fc8,0x400fff88,0xfc99dffc,0xf03fee4f,
0x013fe09f,0x7fffc411,0x3e00efff,0x03ff885f,0x555bffd0,0x20df5035,
0x7f4007fc,0xb85fffff,0x527fc0ff,0x3f3be6bf,0x77ffdc2e,0xff74feff,
0x50bfffff,0xbffd05ff,0x3ea35555,0x43ffffff,0xfffffffd,0x42dff800,
0xfebcefe8,0xadffe80d,0x7f441aaa,0x20efffff,0x27fc0ffb,0x88004ff8,
0xb84ffffd,0xffffffff,0x5007ff16,0xffffffff,0x3207f707,0xffc8007f,
0x1ff704ff,0x1fd14ff8,0x13ffffea,0x367bfff2,0xfffff74f,0x3fffc85d,
0xffffffa8,0xffff53ff,0x3fee03bf,0xf9000dff,0x3fff20ff,0xffff504e,
0xb107ffff,0xf709ffff,0xf04ff81f,0x0980009f,0x3ffffee0,0x7ff16fff,
0xfffff500,0x03107fff,0x10000cc4,0x40ffb801,0x207f94ff,0x004c05f8,
0xcb802662,0xffff500b,0x9987ffff,0x00062000,0x02200d44,0xffffff50,
0x008807ff,0x9ff03fee,0x00013fe0,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x10331000,
0x32a00033,0x882ffc80,0x013305ff,0x00000260,0x3bb60026,0x999986ee,
0x00330009,0x00000000,0x0cc00000,0x77640000,0x00001eee,0x5c27fc00,
0xffd880ff,0x3fea6fff,0x2ffd4001,0x7dc2ffc4,0x3fff622f,0x3ff502ef,
0x7fffffc0,0x01ffa85f,0x87fffff8,0x205fffff,0x44ffffd8,0xfffffff8,
0x3ffa1fff,0x3001deff,0x47ffffff,0xffffffff,0xbffff701,0x3e23fe41,
0xfffd80ff,0x25f901ff,0x02ff47f8,0xffb84ff8,0x7ffffd40,0x07fea7ff,
0x20dff500,0x37f40ffd,0xffddffd1,0x03ff703f,0x7ffffffc,0x001ffb85,
0x3ffbba00,0xfffff105,0x567c4bff,0x1fcaaaaa,0x3ffffffa,0xfffc804f,
0x3ffe3fff,0xc81fffff,0x25ffefff,0x17fec7fc,0x12fd8000,0x005fe8df,
0x1ff709ff,0x44e7ffc4,0x07fea5b9,0x54077200,0x8ffe22ff,0x3fe22ffa,
0x201ffb84,0x5ff99999,0x0001ffb8,0x360bff00,0x3ffb12ff,0x33beabe2,
0x77f43f31,0x02fffb99,0xf827f7fc,0x819999df,0x1910dff8,0x9ff53fe4,
0x8ff40000,0x02ff46f9,0xffb84ff8,0x200bff60,0x00001ffa,0x7fdcbff0,
0x3fa1ff20,0xffffff54,0xff807fff,0xffffff55,0x7fdc7fff,0xff827fc0,
0xf889ff05,0xb935f14f,0x743f33ff,0x03ffc45f,0x209f9df5,0xff5004ff,
0xf17fc805,0x3ffe01df,0xff9905ff,0x259dfb99,0x9ff005fe,0x3e21ff70,
0x3ff5006f,0xff077fd4,0x7e40bfff,0xfa8bfd0f,0x54bfea4f,0xffffffff,
0xaaffc03f,0xffffffff,0xf03fee3f,0x217fe09f,0x5ff84ff8,0x9dfa85f1,
0x3617fa1f,0x97fb01ff,0x013fe09f,0x32007fdc,0x403ffb7f,0xf05fffff,
0xffffffff,0x4017fa9f,0x0ffb84ff,0x4cc47ff3,0x447fea19,0x7ffc0eff,
0x3fe605ff,0xfe82ff9b,0x224ffcef,0x99affb99,0x8affc009,0x99affb99,
0xf03fee09,0x417fe09f,0x16fe86ff,0xf9df885f,0x155dfd51,0x3e20bfee,
0x099dfc8f,0x7dc013fe,0x57fe400f,0x4ccc03ff,0xff5305ff,0x2139fb33,
0x9ff005fe,0x3ea1ff70,0x3ffffa2f,0xfd13ff50,0xff33303f,0xfcefe80b,
0xffffb107,0x00ffdc0b,0x3ee17fe0,0x03fee01f,0x17fe09ff,0x75df7fec,
0x2e5f17ff,0xf1f9afec,0x2a3fffff,0x95fc83ff,0x7fc5ffff,0x227fffff,
0xffffffff,0x37fffe43,0x9817fe00,0xfd0bf66f,0x213fe00b,0x5ff70ffb,
0xa87ffff4,0x01ffd9ff,0x7d405ff8,0xfd304fff,0xcc89ffff,0x03ccdffd,
0xffb85ff8,0xf03fee01,0x417fe09f,0xfffffff8,0x3fa5f16f,0x3fa3f31c,
0xff51eeff,0x3f25ff05,0x3ffe1eef,0x3e27ffff,0x3fffffff,0x0ffeffe4,
0x540bff00,0xfd07f65f,0x213fe00b,0x7ff50ffb,0x3ea1ff70,0xf002ffdf,
0xffff00bf,0x51bff103,0x7ffc7ffd,0x806fffff,0x1ffb85ff,0xff03fee0,
0x7017fe09,0x2bff5999,0xf98bb2f8,0x3ee17fa1,0xf93fd41f,0x2677fe09,
0x0ffb8199,0x7fcffe40,0x217fe006,0xfccefdca,0x017fa4df,0x3fdc27fc,
0xff70bff1,0x3ffffea1,0x00bff001,0x3f20bff9,0xa9bfe20f,0x2aabffca,
0xfb85ff80,0x03fee01f,0x17fe09ff,0x227ff100,0x1f98332f,0x3ff617fa,
0x7f77fec0,0x009ff04f,0xf9003fee,0x4013feef,0xfffc85ff,0x27ffffff,
0xbfd005fe,0xffe8dfb0,0xfa87fdc1,0x800fffaf,0xffc805ff,0xfb0dfd01,
0x005ff50f,0x7d427fc4,0x83fee02f,0xbff04ffb,0x10ffd800,0xf983fe5f,
0xff517fa1,0xfffff88b,0x09ff04ff,0x9003fee0,0x00fff4ff,0x754c2ffc,
0x2affbacf,0x7ec017fa,0x513fea3f,0xf9337fff,0x2a7fea1f,0x5ff806ff,
0xb02ffd40,0x2ffcc5ff,0x2106ffcc,0x5ffb11c8,0x041bff30,0xff719ff5,
0x417fe09f,0xffeba998,0x2374be24,0x27bfa1f9,0x5c0fffca,0xdfd999ef,
0x013fe099,0x2667ff26,0x99ff2099,0x7fc00eff,0x7cc7f605,0x999efe86,
0x7ffc4099,0xc80fffff,0xffffffff,0x3f23ff50,0x42ffc04f,0x00effeda,
0x3fbfffe6,0xfffd01ff,0x3ffe27fd,0x3fa06fff,0x3e23feff,0x4fefffff,
0x3ea0bff0,0x444fffff,0xaaaaaacf,0x3fffa1fc,0xfe81efff,0x27fffe43,
0xff8809ff,0x6fffffff,0x9ff91ff2,0xffffffb8,0x98ff46ff,0xffffe85f,
0xfe985fff,0x2a00dfff,0x24effffe,0x3ffa1ffa,0x3ffffee3,0xfff56fff,
0xffd5001b,0x74c03bff,0xfb13ffff,0x4c019fff,0x543ffffe,0x4fd9efff,
0xfffffff7,0x77ffd4df,0xffff881c,0x21ffffff,0x03defffe,0xffc81ff3,
0x013fe4ff,0xfffffff1,0x23fe4dff,0x3ee2fff8,0x6fffffff,0x85fa87fc,
0xfffffffe,0x40004c05,0x1ffa8099,0x7dc7ffe2,0x6fffffff,0x20003571,
0x4cc40019,0x88001300,0x80660099,0xfffffffb,0x0000006f,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x22000000,0x00000009,0x00000000,0x33000000,0x00000000,
0xe8199800,0x9ffe62ff,0x7fcc3fff,0xffffff10,0x3e03ffff,0x7ffc07ff,
0xf981deff,0x22ffa84f,0x46fd86fd,0x1deffffe,0xffffffe8,0x6ffb86ff,
0xf901ff60,0x907dffff,0x2a0001ff,0x7fe43fff,0xfc83dfff,0x80ceffff,
0x44ffffd9,0xff002ff9,0x7d4ff909,0x3fffffff,0xe8bffffe,0x9fff24ff,
0x7fcc6fff,0xffffff10,0xf303ffff,0x7fc05fff,0x84ffffff,0x37f41ffd,
0x1bf61bf6,0xfffffffd,0xfffffe89,0x3fee6fff,0x1ff606ff,0xffffff90,
0x4ffe41df,0x7ffc4000,0x7fffe43f,0x7fe45fff,0x20ffffff,0xfffffffa,
0x400bfe64,0x27fc84ff,0xfffffffa,0x3eeab63f,0xfe9fffe7,0x8bfffe7f,
0x26660ff9,0x0199bffb,0x409ffff7,0xffb99cff,0x72ffc42f,0x7ffec3ff,
0x6fffffff,0x3ee67bfa,0x2aaaa2ff,0xf95ffbaa,0x6c0dffff,0x3ff20c7f,
0x25ffd999,0xcefffffc,0x7ff7e400,0x5ccffe43,0x9ff21ffe,0x3a23ffd9,
0x0fffa8ad,0x3e005ff3,0x227fc84f,0x99bffb99,0xf0ff9880,0xfbf33fdf,
0x9bfffe1f,0xff300ff9,0xfb9fd005,0x2227fc0f,0x9ffb87ff,0x7fec4ff8,
0xffffffff,0xff117fa6,0x23ff900f,0x06fd8cf9,0x22f55ff6,0x3ff40ffc,
0xfffffff9,0x2bfe601f,0x23fe43ff,0x1ff23ffb,0xb8089ff1,0x05ff32ff,
0x3f213fe0,0x205ff307,0xf0fffffc,0xf7f77f7f,0x3ff7fe1f,0x2601ff32,
0x7fc402ff,0xff01ffba,0xd03ffb09,0x881ff7bf,0xe9999efd,0x217fa0ef,
0x3e201ffd,0x0dfb046f,0x2fff7fec,0xff903ff2,0x2a23ff21,0xbfd05ffd,
0x8ff90ffe,0x1ff23ff9,0xf7007ff3,0x00bfe65f,0x3fe427fc,0xfb82ff98,
0xff11ff1e,0xff1fdbf3,0x57fabfe1,0xff300ff9,0x98ffa805,0x09ff03ff,
0xff505ff7,0x1bf607ff,0xefea9bf6,0x05ff70aa,0xfb017fe4,0x77ffec0d,
0x6c0ffc82,0xf03ff27f,0x21ff70ff,0x13fe43ff,0x7fe41ffd,0x00efea99,
0xff30ffd8,0x3e0dd885,0xfdaaaadf,0x905ff307,0x11ff93bf,0x7d7ffeff,
0xff55ff1f,0xfe81ff33,0xb07fffff,0xf837fcdf,0x03ffa84f,0x7ec0dffd,
0x6fffffff,0x47fffffe,0xff103ffa,0x986fd80d,0x3203fffd,0x97fea0ff,
0x7fe40ffc,0xff8ffe20,0x7ff7fe43,0x7ffe42ff,0xa801ffff,0x0bfe64ff,
0x7ffcdffd,0x07ffffff,0xff305ff3,0xdf31fddf,0x8ffcfff2,0xf39ff2ff,
0xffffe81f,0x49ff07ff,0x4ff80ffc,0x2622ffa8,0x099bffb9,0x7fffffec,
0x3fffa6ff,0x05ff51ee,0xfb00bfee,0x0ffff90d,0xfeeeffc8,0x03ff20ff,
0x46fd8ffb,0x7ffe43ff,0xffc80eff,0x02ffffee,0xf983bfe6,0xf3fffc2f,
0xfdddddff,0x40bfe60f,0x3e6311a8,0x3fa1ff56,0x3fee5ff2,0x5cc40ffa,
0xf9819bff,0x20bfea1f,0x1ffb84ff,0x3fffffea,0x4f7ec3ff,0x746fe999,
0x81ffb85f,0xfd806ff8,0x07fdbc86,0x7fffffe4,0x707fe41d,0x57fd4bff,
0x09cff999,0xdff73ff9,0xff98ff90,0x83ffd107,0x7fe42ff9,0x3f213fe4,
0x305ff307,0x33555555,0xfe97a2df,0x3fe25ff2,0xff300ffd,0x7fffe405,
0xff85ffff,0x220ffd84,0xaacffbaa,0x7ec37ec1,0x7ec2ff46,0x02ffb80f,
0x3f606fd8,0x55ffe407,0xddff901a,0x7e41ffff,0xffffffff,0x7dcff94f,
0x6c3fe42f,0x7ff441ff,0x982ff981,0x7e427fc1,0x905ff307,0x5bffffff,
0xf97f40df,0x3ffff22f,0x405ff300,0xfffffffe,0x544ff87f,0x54cc45ff,
0x6c099bff,0x746fd86f,0x82ffd45f,0xdfb006ff,0x3203fec0,0xffc800ff,
0x640dffff,0xffffffff,0x44ff94ff,0x43fe46ff,0x3fa20ffd,0x05ff301f,
0x3f213fe0,0x305ff307,0x53555555,0xf9ff40df,0x3fffe62f,0x205ff300,
0x9999bff8,0x67fc1ffc,0x40fffca9,0xfffffffa,0x6c37ec3f,0x54f7f46f,
0xfb80fffc,0xd555103f,0xfd8555ff,0x9199999f,0xff9001ff,0x26201357,
0xcff99999,0xfc8ff909,0x267ff22f,0x3a26ffc9,0x2aaaacff,0x33337ff3,
0xf909ff03,0x7fdccc4f,0xf700099b,0xff9fec0b,0x807ffec2,0xff702ff9,
0xf89ff301,0x1effffff,0xdffdcc98,0x437ec1cc,0x7fff46fd,0xff01efff,
0x7fffd40f,0x7ec7ffff,0x97ffffff,0xff9001ff,0x3ff80001,0x3fe63fe4,
0x3fffff26,0x3ff21fff,0x36ffffff,0xffffffff,0xfc84ff83,0x3ffffea7,
0xf7003fff,0xffa7ec0b,0x807ffcc2,0xdfb02ff9,0x3fe37fc0,0x3003deff,
0x37ec05ff,0x3ffa37ec,0x3ee03def,0x3ffea03f,0x6c7fffff,0x7fffffff,
0xf9001ff9,0xff80001f,0x7ec3fe43,0xdffff92f,0xfffc817d,0xf36fffff,
0x3fffffff,0x7fc84ff8,0x3fffffea,0x000003ff,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x640b3000,0x44006602,0x01000000,0x166000c0,
0x08080040,0x2c804040,0x31001000,0x4cc40400,0xffffff90,0x07ff2dff,
0x7fd57fe2,0x321ffe85,0x757ee05f,0x8ffd00ff,0xffffffff,0xffffff12,
0x3e63ffff,0x82ffb84f,0xfd701ff8,0x2e01bfff,0x4c1efffe,0xf704fffd,
0xa809ffff,0xffd705ff,0xffb1019f,0xd85ffd15,0xffeacfff,0xf00fff22,
0x09fff75f,0x5c9ffff5,0x1effd8df,0x7fe4ffea,0x16ffffff,0x1ff90bff,
0xff30ffec,0x2e05fc8b,0x105ff74f,0xffff89ff,0xff12ffff,0xffffffff,
0x6ee7fe43,0xff105ffc,0x3fbffe03,0x3fa20eff,0x2a1fffff,0x46ffefff,
0x4feefffd,0x207bfee0,0xfffffffd,0x77ff7f40,0xdf10ffef,0xffdffffd,
0x813ffa23,0xfffffeff,0x3f77fe64,0xffddf73f,0x3fe61fff,0xd5555532,
0x0ffe49ff,0xff989ff1,0xf703ffa5,0xf9a7e40b,0x42ffb85f,0x99999dff,
0x3fee6660,0xffe8199b,0x100effff,0x702e03ff,0x6ffe45ff,0xff11c99a,
0x44ffea19,0xfb0085ff,0xbff501bf,0x4c9ffb53,0x329ff56f,0x7fcc513f,
0x7ec49fb4,0xefff80df,0x3f27fe8a,0x7fdd7ee4,0x33ffc9cf,0x7fcc05ff,
0xf92ffc46,0x53ffb01f,0x0df709ff,0x0fff27e4,0x09ff0ffb,0x402ff980,
0x6ffbbffc,0x5ffdd554,0x7fc402aa,0xb80dff13,0x9b7ec0ff,0x74400dff,
0x1bfa04ff,0x14fb9ffa,0x813ee5ff,0x90bf51ff,0xfff81dff,0x2fd9fee0,
0x27fddbe6,0x3fe29ff1,0x207ffa01,0x4ff88ffc,0xffddff10,0x364df501,
0x0ffe47f9,0x13fe17fe,0x805ff300,0x83fea2fe,0xfffffffe,0x6665c47f,
0x05ff54ff,0xccccffd8,0x3fffe7fe,0x3ffe982d,0x7e427fc0,0x7fc7f90f,
0x54c5fdcd,0x6fdccffc,0x7c3fff50,0xfb154c4f,0xffbafdc9,0xff8a7fc0,
0x209ff701,0x0ffbcff8,0x0fffff20,0x2ff8b7d4,0x1ffd47fb,0xbff05ff3,
0x20155555,0x3e202ff9,0xb87fe21f,0xccdffccc,0x3fffff24,0x03ff74ff,
0xffffffe8,0x3ffa67ff,0x3fee2fff,0x0ffe201f,0x17e47fee,0x4bffffff,
0xfffffffd,0xffd106ff,0x5c027fc7,0x72ffccff,0x24ff81ff,0x0dff3019,
0x04ffffc8,0x303fffc4,0x6d3feadf,0xf937fc2f,0xfffff01f,0x3e601fff,
0x8bfe202f,0xff100ff8,0x33bff703,0x3fee9ff3,0x4cf7ec02,0xc9819999,
0x3ea1fffe,0xbff102ff,0x3f21ff70,0x2666bfe3,0xff33df70,0xf3013333,
0x04ff85ff,0x47ffffb0,0x27fc0ffb,0x401ffe80,0x400ffff8,0x301ffff9,
0x6dfff6ff,0xe87fec2f,0xddfff06f,0x3e601ddd,0x727f402f,0x0ffc40df,
0x3fe23fec,0xc80bff34,0xf90000ff,0x3ffe987f,0xffd0fff0,0x2ff89fdc,
0x0ffc7fb0,0x207ffea0,0x2a2004ff,0x207fdc0a,0x70bfa4ff,0x3f2009ff,
0xfffe804f,0x3eff105f,0x41fd9fee,0x3ff8affa,0x98009ff0,0x7fe402ff,
0x2204ffce,0x1ffd81ff,0x7f49ffd3,0x51b989df,0x10881bff,0x103ff903,
0xff90bffd,0x49ff913b,0x0bff55fa,0x27fdd3f2,0x00effc82,0x553009ff,
0x3ee35555,0xf8a7fc0f,0x01bfe60f,0x5402ffa8,0x82ffdcff,0xfcbfaff8,
0x7fc41fec,0xff01ffac,0x2ff98009,0x3ffffa20,0x2aa00fff,0xfefffb80,
0x3fe64fef,0x362fffff,0x2ffeefff,0xfffddff5,0x45ffd80d,0xfffffff8,
0x3f7fe20e,0x52ecefef,0xdffdfdff,0x37ff25fb,0x2013fe00,0x5ffffffc,
0x4ff81ff7,0x1ffe89f5,0x00bfea00,0xdff31ffd,0x33fbff10,0xfd01fddf,
0x7fc0dfbf,0x17fcc004,0x5775ffb0,0x64000dff,0x4fd9efff,0x77fffec4,
0x7ffffdc1,0xfffff32f,0x1d70019f,0x9ffffb10,0x26bffea0,0x3f62ffff,
0x5ffff75f,0x3fe013a2,0xaaaa9804,0x81ff71aa,0x5c1314ff,0xaaaaadff,
0x405ff502,0x3ff24ffb,0x3e6fff83,0xffb80fff,0x37fe04ff,0x30099999,
0x3fe605ff,0xf92ffa83,0x9fffffff,0x18800130,0x10099880,0x01000333,
0x02600130,0x31022033,0x00000103,0x3a000000,0xffffffff,0x205ff507,
0x3e20fff8,0x27ffc0ff,0xf301fff9,0x7fc03fff,0x02ffffff,0x1c405ff3,
0x7ffe4170,0x004fffff,0x00000000,0x00000000,0x00000000,0x00000000,
0x3fffffa0,0xff507fff,0x20fff205,0x7ff45ffc,0xe81ffea1,0x7ffc07ff,
0x302fffff,0x000005ff,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0xff701dc0,0x5104ff81,0xf8000015,
0xf985ffff,0x2fffffff,0xff105ff9,0xfa813fab,0xc81fff17,0x203301ff,
0x3fe60ffa,0x0055440e,0x4c004008,0x554c2880,0x8804c401,0x000000aa,
0x9f500000,0x7ff53df7,0xb81ffdc0,0x227fc0ff,0x0dffffd8,0xf00ffc40,
0xf30bffff,0x5fffffff,0x3ee17fe2,0x5c0bfb2f,0xa97fea5f,0x03fe04ff,
0x7fc43fea,0x3fffa20e,0xfb97663f,0x7649f503,0x7441df31,0xfffff32f,
0x84ffea85,0x505ffffc,0x7ffe41df,0x504fffff,0x7d4003ff,0xfffefffe,
0x07ff700f,0x9ff03fee,0xea99bfe8,0x07fe200f,0x85ff9998,0xffcaaaa8,
0xd03ff60e,0x9037e4df,0x8affd89f,0xff0b86fe,0x88ffa8e2,0x77c41ffe,
0xff10fffd,0xf107fee7,0x4c7fea9f,0xffe88eff,0xdff77911,0x227fffd4,
0x4ffccffb,0x3f25ffe8,0x4fffffff,0x400dffd0,0xeff8cffa,0x0ee01fe8,
0x7fc0ffb8,0x3ffe3f24,0x3e205e8e,0x0bff001f,0xa83ffd10,0x8ffe22ff,
0x23dd17fa,0x7ff443fd,0x7fcc1ffd,0x51ffafea,0x03ffb3ff,0x2a0ffc82,
0xc8dfb0ff,0x987ff16f,0x01ffeeff,0xff3b17fa,0x3ee3fd89,0x007ffd86,
0x3fdcfb80,0xf11ff500,0x000ffa5f,0x7fc0ffb8,0x7cdfcfe4,0xff100fa9,
0x017fe003,0x7fc0bff6,0xf983fee5,0xfd4ffa8f,0x7ffff305,0xfffff910,
0x37fea19f,0xff9802ff,0xff16fd86,0x7ec7fe67,0x3ffff306,0x01dffd30,
0x45fd13fe,0x7ff887f9,0x47fc4000,0xfa800ff8,0x9ff43fe6,0xfffffff8,
0x1ff71fff,0x23f14ff8,0x23f35edf,0xfffffff8,0xbff01fff,0x204ffb80,
0x8bfd0ffc,0x6ffd9ff8,0x3ff603ff,0x7fff4407,0x7ffffd41,0x077fcc01,
0x4fe87fdc,0x13fa1ff7,0x4077ff44,0x80effee9,0x92fec4ff,0xb97f60df,
0xeeeeeeee,0xbf91fec3,0x7fcdf500,0x3fe27fd0,0xffffffff,0xff81ff71,
0x3b3e5f14,0x3fe23f33,0xffffffff,0x4c0bff01,0x7fcc06ff,0xff82ff9b,
0xffaffffa,0x3ffff980,0xfffffc88,0xf5ff51df,0x3fea01df,0x92ff980d,
0x9a7f41df,0x7ff441ff,0x3ea00eff,0x544ff82f,0x82ffefff,0x3ff21ffa,
0x24ffffff,0x17fc46f9,0x0ff9bea0,0x4cccc7fd,0x2e199999,0x93fee0ff,
0x71f77f4f,0xffa9998f,0x3fe0199a,0x01fff105,0x0ff9dfd0,0x3f37fbfa,
0xeff887fd,0x7fc41ffe,0x51fe9fe9,0x0dff51ff,0x5dddfff3,0x2ff9a7f4,
0xefc97fcc,0xf33ffd10,0x2eb261df,0x3fba67fd,0x3fea2eff,0x7ffec2ef,
0x4ccccc42,0x0bb20999,0xdf5017aa,0x03fe87fc,0xcffa8022,0x2e4fffb8,
0xfac89c9f,0x007fe204,0xffe82ffc,0xa81aaaad,0xfb04ffff,0xdfff35ff,
0xff33ffb0,0x4fd0a81d,0x7e43fea3,0x7fffd44f,0x6cdf53ff,0x74df904f,
0x4c3ff72f,0xffff73ff,0x7fffcc5d,0x65c003ff,0x0000000b,0x7fcdf500,
0x3ea07fd0,0xffff102f,0xfd89fdff,0x406fb99b,0xff701ff8,0x2dffffff,
0xfffffffa,0x3ffff03f,0x7c3fff20,0x1ffdc5ff,0x7fc0bff7,0x3a0ffa80,
0x266623ff,0x50620999,0x8130a201,0x2a24981c,0x2666601a,0x00000099,
0xa8000000,0x7f43fe6f,0x409ff903,0xfd9efffa,0x3ffffb84,0x701ff880,
0xffffffff,0x3ffffead,0xff903fff,0x92ffdc0d,0x37fcc9ff,0x19817ff4,
0x7c41ff50,0x000001ff,0x00000000,0x00000000,0xfa800000,0x1ff43fe6,
0x9800ee88,0x00044001,0x000002aa,0x00000000,0x00000000,0x001ee980,
0x66666664,0x0004cccc,0x00000000,0x00000000,0x00000000,0x00000000,
0x00998662,0xffffffe8,0x00cc44ff,0x4c009988,0x4c400620,0xddddb019,
0x267ffe8d,0xf2ffffff,0xffffffff,0x00000fff,0x00000000,0x00000000,
0x00000000,0x5c000000,0x24ff89ff,0x3ffa3ffa,0x24ffffff,0x2a0efffa,
0x07ffa62c,0x3ff87fdc,0x80f7fcc0,0x7c7fffff,0x3ffe67ff,0x55552fff,
0x55555555,0x00000000,0x00000000,0x00000000,0x00000000,0x87fdc000,
0x9fffa3ff,0xd9999998,0x3ffffe4f,0xd887fb0e,0x8ffb81ff,0x3e604ff8,
0x222200df,0x1ffdc088,0x15555551,0x00000000,0x00000000,0x00000000,
0x00000000,0xa8000000,0x747ff0ff,0x9f9007ff,0x3fe63fea,0x9700ffef,
0x0b98ae09,0x0000f320,0x00000088,0x00000000,0x00000000,0x00000000,
0x00000000,0x9fea0000,0x0bfe62ff,0x4eaa7e40,0x013fffa2,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x9fe60000,
0x440002fe,0x01ba8009,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x86600000,0x00000018,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
};
static signed short stb__consolas_bold_22_latin_ext_x[560]={ 0,4,2,0,0,0,0,4,2,2,1,0,2,2,
3,0,0,1,1,1,0,1,1,1,1,0,4,2,1,1,2,3,0,0,1,0,0,1,1,0,1,1,1,1,
2,0,1,0,1,0,1,1,0,0,0,0,0,0,1,3,1,2,0,0,0,1,1,1,0,1,0,0,1,1,
1,1,1,0,1,0,1,0,1,1,0,1,0,0,0,0,1,1,4,2,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,0,0,4,1,0,0,0,
4,0,0,0,2,1,1,2,0,0,2,1,2,2,0,1,0,3,4,2,2,1,0,0,0,1,0,0,0,0,
0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,0,
0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,
0,0,0,0,0,1,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,0,0,1,1,1,0,0,2,
1,-3,-2,1,0,0,1,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,-1,0,1,1,-1,0,
0,0,0,0,1,1,0,0,0,0,0,-2,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,
0,0,0,0,0,0,0,2,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,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,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,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,-1,0,-3,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,1,1,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0, };
static signed short stb__consolas_bold_22_latin_ext_y[560]={ 16,0,0,1,-1,0,0,0,-1,-1,0,4,11,8,
12,0,1,1,1,1,1,1,1,1,1,1,4,4,4,6,4,0,0,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,18,0,4,0,4,0,4,0,4,0,0,
0,0,0,4,4,4,4,4,4,4,1,5,5,5,5,5,5,0,-2,0,7,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,16,4,-1,1,2,1,
-2,0,0,1,1,5,9,8,0,1,0,2,0,0,0,5,0,7,16,0,1,5,0,0,0,4,-2,-2,-2,-3,
-3,-3,1,1,-2,-2,-2,-3,-2,-2,-2,-3,1,-3,-2,-2,-2,-3,-3,5,-1,-2,-2,-2,-3,-2,1,0,0,0,
0,0,0,-1,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,2,0,0,0,0,0,0,0,
-2,1,-3,0,1,4,-2,0,-2,0,-3,0,-2,0,-2,0,1,0,-2,1,-3,0,-3,0,1,4,-2,0,-2,0,
-3,0,-3,0,1,0,-2,-3,1,0,-3,0,-2,1,-3,0,1,0,-3,5,1,0,-2,0,1,0,5,-2,-3,1,
0,0,0,1,0,1,0,-2,0,1,4,-2,0,-1,1,4,-2,1,-3,0,-2,0,1,4,-2,0,1,4,-2,0,
-2,0,-2,0,1,4,-2,0,1,1,-2,0,1,1,-3,0,-2,1,-3,0,-3,-1,-2,0,1,5,-2,0,-2,0,
-3,-2,0,-3,0,-2,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,-5,-4,-2,0,-2,-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1, };
static unsigned short stb__consolas_bold_22_latin_ext_w[560]={ 0,4,8,12,12,13,13,4,8,8,10,12,7,8,
6,11,12,10,10,10,12,10,11,10,10,11,4,7,10,10,9,8,12,13,11,11,12,10,10,12,11,10,9,11,
9,12,11,12,11,13,11,10,12,12,13,12,13,12,10,6,11,7,12,13,8,10,11,10,11,10,12,12,10,10,
9,11,10,12,10,12,11,11,11,10,11,10,12,12,12,12,10,9,4,9,12,12,12,12,12,12,12,12,12,12,
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,0,4,9,12,12,12,
4,12,10,12,8,10,10,8,12,10,9,10,8,8,12,11,12,6,4,8,8,10,13,13,13,9,13,13,13,13,
13,13,13,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,10,12,12,12,12,12,12,11,11,11,12,
11,11,11,11,12,10,11,12,11,11,11,12,11,11,12,11,12,12,12,12,12,12,12,11,12,11,11,12,11,12,
13,11,13,11,13,10,12,12,11,11,11,11,11,11,13,14,12,12,11,11,11,11,11,11,10,10,11,11,12,12,
12,12,12,12,12,12,12,11,12,11,11,11,11,11,11,11,10,11,11,10,11,11,10,10,11,11,11,11,11,9,
10,14,15,12,14,11,10,12,12,11,10,12,11,11,11,10,12,12,12,12,13,13,12,12,13,12,11,11,13,12,
11,12,11,11,10,10,11,11,12,11,12,14,12,11,12,11,12,11,12,11,12,11,13,13,12,11,12,12,12,12,
12,11,12,11,11,11,11,10,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
12,12,12,12,12,12,12,12,12,12,13,11,13,12,15,13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
12,12,12,12,12,12,12,12,12,12,10,10,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
12,12,12,12,12,12, };
static unsigned short stb__consolas_bold_22_latin_ext_h[560]={ 0,17,7,15,20,17,17,7,22,22,11,12,9,4,
5,19,16,15,15,16,15,16,16,15,16,15,13,16,13,8,13,17,21,15,15,16,15,15,15,16,15,15,16,15,
15,15,15,16,15,20,15,16,15,16,15,15,15,15,15,21,19,21,8,3,6,13,17,13,17,13,16,17,16,16,
21,16,16,12,12,13,17,17,12,13,16,12,11,11,11,16,11,21,23,21,6,15,15,15,15,15,15,15,15,15,
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0,17,20,15,14,15,
23,19,6,16,12,10,6,4,12,5,9,14,10,10,6,16,19,6,4,10,12,10,16,16,16,17,18,18,18,19,
19,19,15,19,18,18,18,19,18,18,18,19,15,19,19,19,19,20,20,10,20,19,19,19,20,18,15,17,17,17,
17,17,17,18,13,16,17,17,17,17,16,16,16,16,17,16,17,17,17,17,17,12,17,17,17,17,17,21,21,21,
18,16,19,17,20,17,19,17,19,17,20,17,19,17,18,17,15,17,18,16,19,17,19,17,20,17,18,17,19,21,
20,21,20,21,20,21,18,19,15,16,19,16,18,15,19,16,20,21,19,11,16,21,19,21,20,21,11,18,19,20,
21,16,16,15,16,15,16,18,16,20,17,18,16,17,20,17,19,16,20,17,19,17,16,13,18,16,20,17,18,16,
19,17,19,17,19,16,19,17,20,20,18,17,15,16,20,17,19,16,20,17,20,18,19,17,20,16,18,16,18,21,
19,18,16,19,16,18,16,16,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,19,15,15,15,
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
15,15,15,15,15,15,15,15,15,15,21,21,18,17,21,20,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
15,15,15,15,15,15,15,15,15,15,20,17,20,20,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
15,15,15,15,15,15, };
static unsigned short stb__consolas_bold_22_latin_ext_s[560]={ 254,249,64,231,155,127,74,250,11,20,125,
51,218,155,148,171,71,116,200,122,163,153,164,105,63,131,251,133,158,226,208,
247,130,39,188,241,53,66,183,14,224,236,86,207,244,1,14,214,139,42,176,
245,77,1,52,39,25,12,1,217,120,24,237,164,104,114,62,125,79,136,238,
115,227,39,32,27,120,1,239,169,164,152,218,147,96,27,86,99,112,50,75,
14,1,207,91,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,
143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,254,248,145,
194,90,66,6,1,113,188,247,168,80,155,38,137,208,103,148,190,124,59,15,
73,250,199,230,157,231,217,96,246,128,156,183,14,1,186,169,148,197,233,221,
136,1,13,25,28,92,39,160,173,183,48,61,179,123,40,66,93,85,170,151,
50,38,25,13,1,240,90,195,132,190,177,165,153,107,179,214,143,91,192,66,
53,40,27,14,14,1,235,222,210,198,156,182,143,142,110,157,126,220,245,52,
88,65,114,1,61,149,149,114,73,156,101,209,82,125,49,89,37,74,138,102,
186,53,45,69,169,95,224,207,1,226,101,79,167,113,155,175,219,137,28,13,
95,77,64,16,118,28,84,234,237,136,187,196,246,107,1,53,211,226,127,14,
77,94,24,161,213,84,104,36,116,208,1,110,201,106,101,69,182,161,40,98,
140,199,119,225,176,221,217,237,48,213,141,194,182,239,202,26,74,119,128,200,
108,82,189,56,1,79,172,132,176,13,204,26,194,132,39,201,145,141,51,36,
25,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,233,
143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,
143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,
143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,
143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,
143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,
143,143,143,70,58,63,88,29,168,143,143,143,143,143,143,143,143,143,143,143,
143,143,143,143,143,143,143,143,143,143,143,143,143,108,229,194,182,143,143,143,
143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,
143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,
143,143,143,143,143,143,143,143,143, };
static unsigned short stb__consolas_bold_22_latin_ext_t[560]={ 1,1,277,216,25,146,164,249,1,1,265,
265,265,276,276,68,199,233,233,199,233,199,199,233,216,216,199,199,249,265,249,
127,1,233,233,164,233,249,216,216,233,233,216,216,216,233,233,199,233,25,233,
182,249,216,249,249,249,249,249,1,68,25,265,276,277,249,164,249,146,249,199,
164,199,216,25,216,216,265,249,249,164,164,249,249,216,265,265,265,265,216,265,
25,1,1,277,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,1,47,25,
216,249,233,1,68,277,199,233,265,277,276,265,277,265,249,265,265,277,199,88,
277,257,265,249,265,182,182,199,68,108,108,108,68,88,47,216,47,108,108,108,
47,127,127,127,68,233,88,47,47,68,47,47,265,47,68,68,68,47,108,233,
164,164,164,164,164,146,108,249,182,146,146,146,146,182,182,164,182,146,182,146,
146,146,146,146,265,146,127,127,127,127,1,1,1,108,199,68,127,25,108,88,
127,88,127,47,127,88,127,108,127,216,127,108,182,88,127,88,127,47,127,108,
127,68,1,25,1,25,1,25,25,88,88,233,182,88,182,88,216,88,182,47,
1,88,265,182,1,88,1,25,1,265,88,68,25,1,182,182,233,164,233,199,
108,182,47,127,88,199,146,47,146,68,199,47,164,68,164,182,249,88,182,47,
164,88,182,47,164,68,146,47,199,47,146,25,25,88,146,233,216,25,164,47,
216,25,164,25,108,68,127,25,199,108,182,108,1,68,108,199,68,199,108,199,
199,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,68,
216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
216,216,216,1,1,108,164,1,25,216,216,216,216,216,216,216,216,216,216,216,
216,216,216,216,216,216,216,216,216,216,216,216,216,25,146,25,25,216,216,216,
216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,216,
216,216,216,216,216,216,216,216,216, };
static unsigned short stb__consolas_bold_22_latin_ext_a[560]={ 194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,
194,194,194,194,194,194,194,194, };
// Call this function with
// font: NULL or array length
// data: NULL or specified size
// height: STB_FONT_consolas_bold_22_latin_ext_BITMAP_HEIGHT or STB_FONT_consolas_bold_22_latin_ext_BITMAP_HEIGHT_POW2
// return value: spacing between lines
static void stb_font_consolas_bold_22_latin_ext(stb_fontchar font[STB_FONT_consolas_bold_22_latin_ext_NUM_CHARS],
unsigned char data[STB_FONT_consolas_bold_22_latin_ext_BITMAP_HEIGHT][STB_FONT_consolas_bold_22_latin_ext_BITMAP_WIDTH],
int height)
{
int i,j;
if (data != 0) {
unsigned int *bits = stb__consolas_bold_22_latin_ext_pixels;
unsigned int bitpack = *bits++, numbits = 32;
for (i=0; i < STB_FONT_consolas_bold_22_latin_ext_BITMAP_WIDTH*height; ++i)
data[0][i] = 0; // zero entire bitmap
for (j=1; j < STB_FONT_consolas_bold_22_latin_ext_BITMAP_HEIGHT-1; ++j) {
for (i=1; i < STB_FONT_consolas_bold_22_latin_ext_BITMAP_WIDTH-1; ++i) {
unsigned int value;
if (numbits==0) bitpack = *bits++, numbits=32;
value = bitpack & 1;
bitpack >>= 1, --numbits;
if (value) {
if (numbits < 3) bitpack = *bits++, numbits = 32;
data[j][i] = (bitpack & 7) * 0x20 + 0x1f;
bitpack >>= 3, numbits -= 3;
} else {
data[j][i] = 0;
}
}
}
}
// build font description
if (font != 0) {
float recip_width = 1.0f / STB_FONT_consolas_bold_22_latin_ext_BITMAP_WIDTH;
float recip_height = 1.0f / height;
for (i=0; i < STB_FONT_consolas_bold_22_latin_ext_NUM_CHARS; ++i) {
// pad characters so they bilerp from empty space around each character
font[i].s0 = (stb__consolas_bold_22_latin_ext_s[i]) * recip_width;
font[i].t0 = (stb__consolas_bold_22_latin_ext_t[i]) * recip_height;
font[i].s1 = (stb__consolas_bold_22_latin_ext_s[i] + stb__consolas_bold_22_latin_ext_w[i]) * recip_width;
font[i].t1 = (stb__consolas_bold_22_latin_ext_t[i] + stb__consolas_bold_22_latin_ext_h[i]) * recip_height;
font[i].x0 = stb__consolas_bold_22_latin_ext_x[i];
font[i].y0 = stb__consolas_bold_22_latin_ext_y[i];
font[i].x1 = stb__consolas_bold_22_latin_ext_x[i] + stb__consolas_bold_22_latin_ext_w[i];
font[i].y1 = stb__consolas_bold_22_latin_ext_y[i] + stb__consolas_bold_22_latin_ext_h[i];
font[i].advance_int = (stb__consolas_bold_22_latin_ext_a[i]+8)>>4;
font[i].s0f = (stb__consolas_bold_22_latin_ext_s[i] - 0.5f) * recip_width;
font[i].t0f = (stb__consolas_bold_22_latin_ext_t[i] - 0.5f) * recip_height;
font[i].s1f = (stb__consolas_bold_22_latin_ext_s[i] + stb__consolas_bold_22_latin_ext_w[i] + 0.5f) * recip_width;
font[i].t1f = (stb__consolas_bold_22_latin_ext_t[i] + stb__consolas_bold_22_latin_ext_h[i] + 0.5f) * recip_height;
font[i].x0f = stb__consolas_bold_22_latin_ext_x[i] - 0.5f;
font[i].y0f = stb__consolas_bold_22_latin_ext_y[i] - 0.5f;
font[i].x1f = stb__consolas_bold_22_latin_ext_x[i] + stb__consolas_bold_22_latin_ext_w[i] + 0.5f;
font[i].y1f = stb__consolas_bold_22_latin_ext_y[i] + stb__consolas_bold_22_latin_ext_h[i] + 0.5f;
font[i].advance = stb__consolas_bold_22_latin_ext_a[i]/16.0f;
}
}
}
#ifndef STB_SOMEFONT_CREATE
#define STB_SOMEFONT_CREATE stb_font_consolas_bold_22_latin_ext
#define STB_SOMEFONT_BITMAP_WIDTH STB_FONT_consolas_bold_22_latin_ext_BITMAP_WIDTH
#define STB_SOMEFONT_BITMAP_HEIGHT STB_FONT_consolas_bold_22_latin_ext_BITMAP_HEIGHT
#define STB_SOMEFONT_BITMAP_HEIGHT_POW2 STB_FONT_consolas_bold_22_latin_ext_BITMAP_HEIGHT_POW2
#define STB_SOMEFONT_FIRST_CHAR STB_FONT_consolas_bold_22_latin_ext_FIRST_CHAR
#define STB_SOMEFONT_NUM_CHARS STB_FONT_consolas_bold_22_latin_ext_NUM_CHARS
#define STB_SOMEFONT_LINE_SPACING STB_FONT_consolas_bold_22_latin_ext_LINE_SPACING
#endif
| 69.382637 | 137 | 0.792207 | stetre |
83b83caebab3394ba74f0376bb93f29a34852ef6 | 2,502 | cpp | C++ | common/WhirlyGlobeLib/src/Lighting.cpp | uCiC-app/WhirlyGlobe-3 | 399fa89a7c00db3f7fed08968e1c3692bba25d7c | [
"Apache-2.0"
] | 11 | 2020-01-03T09:17:59.000Z | 2020-10-12T21:42:42.000Z | common/WhirlyGlobeLib/src/Lighting.cpp | uCiC-app/WhirlyGlobe-3 | 399fa89a7c00db3f7fed08968e1c3692bba25d7c | [
"Apache-2.0"
] | 36 | 2020-01-08T07:52:20.000Z | 2020-11-16T23:49:39.000Z | common/WhirlyGlobeLib/src/Lighting.cpp | uCiC-app/WhirlyGlobe-3 | 399fa89a7c00db3f7fed08968e1c3692bba25d7c | [
"Apache-2.0"
] | 9 | 2020-01-08T06:04:48.000Z | 2021-07-21T13:14:27.000Z | /*
* Lighting.cpp
* WhirlyGlobeLib
*
* Created by jmnavarro
* Copyright 2011-2019 mousebird consulting.
*
* 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.
*
*/
#import "Lighting.h"
#import "Program.h"
#import "ProgramGLES.h"
using namespace Eigen;
namespace WhirlyKit
{
DirectionalLight::DirectionalLight()
{
viewDependent = true;
pos = Eigen::Vector3f(0,0,0);
ambient = Eigen::Vector4f(1,1,1,1);
diffuse = Eigen::Vector4f(1,1,1,1);
specular = Eigen::Vector4f(0,0,0,0);
}
DirectionalLight::~DirectionalLight()
{
}
bool DirectionalLight::bindToProgram(Program *program, int index, Eigen::Matrix4f modelMat) const
{
Eigen::Vector3f dir = pos.normalized();
Eigen::Vector3f halfPlane = (dir + Eigen::Vector3f(0,0,1)).normalized();
ProgramGLES *programGLES = dynamic_cast<ProgramGLES *>(program);
if (programGLES) {
programGLES->setUniform(lightViewDependNameIDs[index], (viewDependent ? 0.0f : 1.0f));
programGLES->setUniform(lightDirectionNameIDs[index], dir);
programGLES->setUniform(lightHalfplaneNameIDs[index], halfPlane);
programGLES->setUniform(lightAmbientNameIDs[index], ambient);
programGLES->setUniform(lightDiffuseNameIDs[index], diffuse);
programGLES->setUniform(lightSpecularNameIDs[index], specular);
}
return true;
}
Material::Material() :
ambient(Eigen::Vector4f(1,1,1,1)),
diffuse(Eigen::Vector4f(1,1,1,1)),
specular(Eigen::Vector4f(1,1,1,1)),
specularExponent(1)
{
}
Material::~Material()
{
}
bool Material::bindToProgram(Program *program)
{
ProgramGLES *programGLES = dynamic_cast<ProgramGLES *>(program);
if (programGLES) {
programGLES->setUniform(materialAmbientNameID, ambient);
programGLES->setUniform(materialDiffuseNameID, diffuse);
programGLES->setUniform(materialSpecularNameID, specular);
programGLES->setUniform(materialSpecularExponentNameID, specularExponent);
}
return true;
}
}
| 28.431818 | 97 | 0.707834 | uCiC-app |
83b856c745f8d82bb95905b7aceb52824c6b3466 | 9,650 | cpp | C++ | adressing/AddressPool.cpp | d-kozak/isa-proj | 73c525914a985d631d593985d8f1bb4291f072f3 | [
"MIT"
] | null | null | null | adressing/AddressPool.cpp | d-kozak/isa-proj | 73c525914a985d631d593985d8f1bb4291f072f3 | [
"MIT"
] | null | null | null | adressing/AddressPool.cpp | d-kozak/isa-proj | 73c525914a985d631d593985d8f1bb4291f072f3 | [
"MIT"
] | null | null | null | //
// see header file for comments.
//
#include "AddressPool.h"
#include "../exceptions/OutOfAddressException.h"
#include "../exceptions/InvalidArgumentException.h"
#include "IpAddress.h"
#include <sstream>
#include <cmath>
#include <ctgmath>
#include <list>
#include <algorithm>
namespace addressing {
AddressPool::AddressPool(IpAddress &net_address, int prefix, list <IpAddress> &reserved,
map<MacAddress, IpAddress> &direct_mapping) : _reserved(reserved), _addresses(),
_directMapping(direct_mapping) {
if (prefix < 0 || prefix > 32)
throw InvalidArgumentException("Prefix must be a positive number between 0 and 32");
int maxAddrCount = pow(2, 32 - prefix) - 2;
IpAddress lastAddr = net_address.next_addr(maxAddrCount + 1);
net_address = net_address.next_addr(); //skip the net_address one <- that one is for the server itself
for (IpAddress addr = net_address.next_addr(); addr != lastAddr; addr = addr.next_addr()) {
for (auto &item: direct_mapping) {
if (item.second == addr) {
// do not need to store direct mapping in the pool
continue;
}
}
bool isReserved = find(this->_reserved.begin(), this->_reserved.end(), addr) != this->_reserved.end();
if (!isReserved) {
// only store addresses that are not reserved
AddressInfo pair(addr);
this->_addresses.push_back(pair);
}
}
if (DEBUG) {
unsigned long count = _addresses.size();
std::cout << "Allocated " << count << " addresses." << std::endl << "Aproximate size of the pool: "
<< count * sizeof(IpAddress) << " bytes + " << sizeof(AddressPool) << " bytes of address pool"
<< std::endl;
}
}
void AddressPool::clean() {
for (auto &addr : this->_addresses) {
addr.clean();
}
}
IpAddress AddressPool::getAddress(MacAddress &mac) {
// check direct mapping first
auto direct = this->_directMapping.find(mac);
if (direct != this->_directMapping.end()) {
return direct->second;
}
for (auto &item : this->_addresses) {
if (item.getState() == FREE) {
item.markAsToBeBinded(mac);
return item.getAddress();
}
}
// if no addresss is free, lets check to be binded addresses
for (auto &item : this->_addresses) {
if (item.getState() == TO_BE_BINDED) {
// already in the correct state, but we are stealing somebody's ip to be :/
item.markAsToBeBinded(mac);
return item.getAddress();
}
}
// try to find expired address that can be reassigned
for (auto &item : this->_addresses) {
if (item.getState() == EXPIRED) {
item.markAsToBeBinded(mac);
return item.getAddress();
}
}
// no address found what so ever
throw OutOfAddressException("No address is available");
}
AddressInfo AddressPool::confirmBindigFor(addressing::IpAddress &addr, addressing::MacAddress &mac) {
//check static mapping first
auto direct = this->_directMapping.find(mac);
if (direct != this->_directMapping.end()) {
//if it is a direct mapping, simply create a new addressInfo object and return it
AddressInfo info((*direct).second, DIRECT_MAPPING);
info.createTimestamp();
info.setIsSharedInstance(false);
return info;
}
//check whether ip was specified
if (addr != NULL_IP) {
// try to find given addressInfo
for (auto &item : this->_addresses) {
if (item.getAddress() == addr) {
if (item.getState() == TO_BE_BINDED || item.getState() == BINDED || item.getState() == EXPIRED) {
item.bindTheAddress(mac);
return item;
} else {
throw InvalidArgumentException("1 Given address is in invalid state ");
}
}
}
}
// if no ip was specified or given IP is not in the pool, try looking for the mac address
for (auto &item : this->_addresses) {
if (item.getMac() != NULL) {
if (*item.getMac() == mac) {
if (item.getState() == TO_BE_BINDED || item.getState() == BINDED || item.getState() == EXPIRED) {
item.bindTheAddress(mac);
return item;
} else {
throw InvalidArgumentException("2 Given address is in invalid state");
}
}
}
}
// no address found what so ever
throw InvalidArgumentException("Given address is not in the pool " + addr.toString());
}
void AddressPool::releaseAddress(IpAddress &addr) {
for (auto &item : this->_addresses) {
if (item.getAddress() == addr) {
// for further reuse by the same host
item.setState(TO_BE_BINDED);
return;
}
}
// if the address is not found, the operation is empty
}
void AddressPool::releaseAddress(MacAddress &mac) {
for (auto &item : this->_addresses) {
if (item.getMac() != NULL) {
if (*item.getMac() == mac) {
// for further reuse by the same host
item.setState(TO_BE_BINDED);
return;
}
}
}
// if the address is not found, the operation is empty
}
void AddressPool::addressExpired(IpAddress &addr) {
for (auto &item : this->_addresses) {
if (item.getAddress() == addr) {
// for further reuse by the same host
item.setState(EXPIRED);
return;
}
}
throw InvalidArgumentException("This address " + addr.toString() + "is not in the pool");
}
void AddressPool::printCurrentState() {
cout << this->toString();
}
string AddressPool::toString() const {
stringstream ss;
ss << this->_name << " -> " << "(" << endl << "\t{" << std::endl;
for (auto &x : this->_addresses) {
ss << "\t\t" << x.toString() << "," << std::endl;
}
ss << "\t}" << endl;
ss << ", Reserved -> " << endl << "\t{" << std::endl;
for (auto &x : this->_reserved) {
ss << "\t\t" << x.toString() << "," << std::endl;
}
ss << "\t}";
ss << "Static mapping -> {" << endl;
for (auto &elem : this->_directMapping) {
ss << "\t" << constRefToString(elem.first) << " => " << elem.second.asString() << endl;
}
ss << endl << ")" << endl;
return ss.str();
}
string AddressPool::getLoggableName() const { return this->_name; }
////////////////////////////////////////////////////////////////////////////////////////////
void AddressInfo::bindTheAddress(MacAddress &mac) {
if (this->_mac == NULL)
throw InvalidArgumentException("Mac is null in bindTheAdress");
if (*this->_mac != mac) {
throw InvalidArgumentException(
"Mac address set in the discover is different the the on in the request, wierd internal error");
}
this->setState(BINDED);
Timestamp *timestamp = new Timestamp;
if (this->_timestamp != NULL)
delete this->_timestamp;
this->_timestamp = timestamp;
}
void AddressInfo::markAsToBeBinded(MacAddress &mac) {
this->_state = TO_BE_BINDED;
if (this->_mac != NULL)
delete this->_mac;
this->_mac = new MacAddress(mac.getPart(0), mac.getPart(1), mac.getPart(2), mac.getPart(3), mac.getPart(4),
mac.getPart(5));
}
string AddressInfo::toString() const {
stringstream ss;
ss << this->_name << " -> (" << this->_address.toString() << ", ";
switch (_state) {
case FREE:
ss << "FREE";
break;
case TO_BE_BINDED:
ss << "TO_BE_BINDED";
break;
case BINDED:
ss << "BINDED";
break;
case EXPIRED:
ss << "EXPIRED";
break;
case RESERVED:
ss << "RESERVED";
break;
case DIRECT_MAPPING:
ss << "DIRECT_MAPPING";
break;
}
ss << ")";
return ss.str();
}
IpAddress AddressInfo::getAddress() {
return this->_address;
}
string AddressInfo::getLoggableName() const { return this->_name; }
void AddressInfo::clean() {
if (_timestamp != NULL) {
delete _timestamp;
this->_timestamp = NULL;
}
if (_mac != NULL) {
delete _mac;
this->_mac = NULL;
}
}
AddressInfo::~AddressInfo() {
}
MacAddress *AddressInfo::getMac() {
return _mac;
}
Timestamp *AddressInfo::getTimestamp() const {
return _timestamp;
}
}
| 34.341637 | 117 | 0.50342 | d-kozak |
83bb48a30e7293b43c03b7a9c745818326a6611f | 1,834 | cpp | C++ | src/util/crash.cpp | Shillaker/faabric | 40da290179c650d9e285475a1992572dfe1c0b10 | [
"Apache-2.0"
] | 1 | 2020-09-01T13:37:54.000Z | 2020-09-01T13:37:54.000Z | src/util/crash.cpp | Shillaker/faabric | 40da290179c650d9e285475a1992572dfe1c0b10 | [
"Apache-2.0"
] | null | null | null | src/util/crash.cpp | Shillaker/faabric | 40da290179c650d9e285475a1992572dfe1c0b10 | [
"Apache-2.0"
] | 1 | 2020-09-13T15:21:16.000Z | 2020-09-13T15:21:16.000Z | #include <faabric/util/crash.h>
#include <faabric/util/logging.h>
#include <array>
#include <execinfo.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <unistd.h>
const std::string_view ABORT_MSG = "Caught stack backtrace:\n";
constexpr int TEST_SIGNAL = 12341234;
// Must be async-signal-safe - don't call allocating functions
void crashHandler(int sig) noexcept
{
faabric::util::handleCrash(sig);
}
namespace faabric::util {
void handleCrash(int sig)
{
std::array<void*, 32> stackPtrs;
size_t filledStacks = backtrace(stackPtrs.data(), stackPtrs.size());
if (sig != TEST_SIGNAL) {
write(STDERR_FILENO, ABORT_MSG.data(), ABORT_MSG.size());
}
backtrace_symbols_fd(stackPtrs.data(),
std::min(filledStacks, stackPtrs.size()),
STDERR_FILENO);
if (sig != TEST_SIGNAL) {
signal(sig, SIG_DFL);
raise(sig);
exit(1);
}
}
void setUpCrashHandler(int sig)
{
std::vector<int> sigs;
if (sig >= 0) {
sigs = { sig };
} else {
fputs("Testing crash handler backtrace:\n", stderr);
fflush(stderr);
crashHandler(TEST_SIGNAL);
SPDLOG_INFO("Installing crash handler");
// We don't handle SIGSEGV here because segfault handling is
// necessary for dirty tracking and if this handler gets initialised
// after the one for dirty tracking it thinks legitimate dirty tracking
// segfaults are crashes
sigs = { SIGABRT, SIGILL, SIGFPE };
}
for (auto signo : sigs) {
if (signal(signo, &crashHandler) == SIG_ERR) {
SPDLOG_WARN("Couldn't install handler for signal {}", signo);
} else {
SPDLOG_INFO("Installed handler for signal {}", signo);
}
}
}
}
| 26.970588 | 79 | 0.621047 | Shillaker |
83bee7b50861ab838211689007ad8ca46649910e | 326 | cpp | C++ | Dumping.cpp | pOri0n/Astrix3 | 49cf86b3af0fd0116b5cc9f64d8ae9886fcbcecf | [
"MIT"
] | 8 | 2017-06-07T09:55:37.000Z | 2019-01-15T18:59:06.000Z | Dumping.cpp | pOri0n/Astrix3 | 49cf86b3af0fd0116b5cc9f64d8ae9886fcbcecf | [
"MIT"
] | null | null | null | Dumping.cpp | pOri0n/Astrix3 | 49cf86b3af0fd0116b5cc9f64d8ae9886fcbcecf | [
"MIT"
] | 2 | 2017-06-08T22:23:08.000Z | 2019-12-25T00:13:05.000Z |
#include "Dumping.h"
#define DUMPIDTOFILE
void Dump::DumpClassIds()
{
#ifdef DUMPIDTOFILE
Utilities::EnableLogFile("ClassID.txt");
#endif
ClientClass* cClass = Interfaces::Client->GetAllClasses();
while (cClass)
{
Utilities::Log("%s = %d,", cClass->m_pNetworkName, cClass->m_ClassID);
cClass = cClass->m_pNext;
}
} | 19.176471 | 72 | 0.711656 | pOri0n |
83c0ad87bdb0d12683a67e4df21dbaba578e230b | 6,333 | cpp | C++ | src/platform/vulkan/image.cpp | PedroSFreire/LiftPR.Version | 61e8e135335e3c4def80f345548620db95f1662d | [
"BSD-3-Clause"
] | 30 | 2019-07-24T09:58:22.000Z | 2021-09-03T08:20:22.000Z | src/platform/vulkan/image.cpp | PedroSFreire/LiftPR.Version | 61e8e135335e3c4def80f345548620db95f1662d | [
"BSD-3-Clause"
] | 15 | 2020-06-20T13:20:50.000Z | 2021-04-26T16:05:33.000Z | src/platform/vulkan/image.cpp | PedroSFreire/LiftPR.Version | 61e8e135335e3c4def80f345548620db95f1662d | [
"BSD-3-Clause"
] | 5 | 2020-06-17T08:38:34.000Z | 2021-09-08T22:14:02.000Z |
#include "image.h"
#include "buffer.h"
#include "depth_buffer.h"
#include "device.h"
#include "single_time_commands.h"
#include "vulkan/vulkan.hpp"
namespace vulkan {
Image::Image(const class Device& device, const VkExtent2D extent, const VkFormat format) :
Image(device,
extent,
format,
VK_IMAGE_TILING_OPTIMAL,
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT) {
}
Image::Image(const class Device& device,
const VkExtent2D extent,
const VkFormat format,
const VkImageTiling tiling,
const VkImageUsageFlags usage) :
device_(device),
extent_(extent), format_(format), image_layout_(vk::ImageLayout::eUndefined) {
VkImageCreateInfo image_info = {};
image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
image_info.imageType = VK_IMAGE_TYPE_2D;
image_info.extent.width = extent.width;
image_info.extent.height = extent.height;
image_info.extent.depth = 1;
image_info.mipLevels = 1;
image_info.arrayLayers = 1;
image_info.format = format;
image_info.tiling = tiling;
image_info.initialLayout = static_cast<VkImageLayout>(image_layout_);
image_info.usage = usage;
image_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
image_info.samples = VK_SAMPLE_COUNT_1_BIT;
image_info.flags = 0; // Optional
vulkanCheck(vkCreateImage(device.handle(), &image_info, nullptr, &image_), "create image");
}
Image::Image(Image&& other) noexcept :
device_(other.device_), extent_(other.extent_), format_(other.format_), image_layout_(other.image_layout_),
image_(other.image_) {
other.image_ = nullptr;
}
Image::~Image() {
if (image_ != nullptr) {
vkDestroyImage(device_.handle(), image_, nullptr);
image_ = nullptr;
}
}
DeviceMemory Image::allocateMemory(const VkMemoryPropertyFlags properties) const {
const auto requirements = getMemoryRequirements();
DeviceMemory memory(device_, requirements.size, requirements.memoryTypeBits, 0, properties);
vulkanCheck(vkBindImageMemory(device_.handle(), image_, memory.handle(), 0), "bind image memory");
return memory;
}
VkMemoryRequirements Image::getMemoryRequirements() const {
VkMemoryRequirements requirements;
vkGetImageMemoryRequirements(device_.handle(), image_, &requirements);
return requirements;
}
void Image::transitionImageLayout(CommandPool& command_pool, vk::ImageLayout new_layout) {
SingleTimeCommands::submit(command_pool, [&](VkCommandBuffer command_buffer) {
vk::ImageMemoryBarrier barrier;
barrier.oldLayout = image_layout_;
barrier.newLayout = new_layout;
barrier.image = image_;
barrier.setSubresourceRange({vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1});
if (new_layout == vk::ImageLayout::eDepthStencilAttachmentOptimal)
barrier.subresourceRange.aspectMask = vk::ImageAspectFlagBits::eDepth;
barrier.srcAccessMask = accessFlagsForLayout(image_layout_);
barrier.dstAccessMask = accessFlagsForLayout(new_layout);
vk::PipelineStageFlags src_stage_flags = pipelineStageForLayout(image_layout_);
vk::PipelineStageFlags dst_stage_flags = pipelineStageForLayout(new_layout);
vk::CommandBuffer vkCmdBuffer {command_buffer};
vkCmdBuffer.pipelineBarrier(src_stage_flags, dst_stage_flags, vk::DependencyFlags(), nullptr, nullptr, barrier);
});
image_layout_ = new_layout;
}
void Image::copyFromBuffer(CommandPool& command_pool, const vk::Buffer& buffer) {
SingleTimeCommands::submit(command_pool, [&](VkCommandBuffer command_buffer) {
vk::BufferImageCopy region;
region.setImageSubresource({vk::ImageAspectFlagBits::eColor, 0, 0, 1});
region.setImageOffset({0, 0, 0});
region.setImageExtent(vk::Extent3D(extent_, 1));
vk::CommandBuffer cmdBuf {command_buffer};
cmdBuf.copyBufferToImage(buffer, image_, vk::ImageLayout::eTransferDstOptimal, {region});
});
}
void Image::copyToBuffer(CommandPool& command_pool, const vk::Buffer& buffer) {
SingleTimeCommands::submit(command_pool, [&](VkCommandBuffer command_buffer) {
vk::BufferImageCopy region;
region.setImageSubresource({vk::ImageAspectFlagBits::eColor, 0, 0, 1});
region.setImageOffset({0, 0, 0});
region.setImageExtent(vk::Extent3D(extent_, 1));
vk::CommandBuffer cmdBuf {command_buffer};
cmdBuf.copyImageToBuffer(image_, vk::ImageLayout::eTransferSrcOptimal, buffer, {region});
});
}
vk::AccessFlags Image::accessFlagsForLayout(vk::ImageLayout layout) {
switch (layout) {
case vk::ImageLayout::ePreinitialized:
return vk::AccessFlagBits::eHostWrite;
case vk::ImageLayout::eTransferDstOptimal:
return vk::AccessFlagBits::eTransferWrite;
case vk::ImageLayout::eTransferSrcOptimal:
return vk::AccessFlagBits::eTransferRead;
case vk::ImageLayout::eColorAttachmentOptimal:
return vk::AccessFlagBits::eColorAttachmentWrite;
case vk::ImageLayout::eDepthStencilAttachmentOptimal:
return vk::AccessFlagBits::eDepthStencilAttachmentWrite;
case vk::ImageLayout::eShaderReadOnlyOptimal:
return vk::AccessFlagBits::eShaderRead;
default:
return vk::AccessFlags();
}
}
vk::PipelineStageFlags Image::pipelineStageForLayout(vk::ImageLayout layout) {
switch (layout) {
case vk::ImageLayout::eTransferDstOptimal:
case vk::ImageLayout::eTransferSrcOptimal:
return vk::PipelineStageFlagBits::eTransfer;
case vk::ImageLayout::eColorAttachmentOptimal:
return vk::PipelineStageFlagBits::eColorAttachmentOutput;
case vk::ImageLayout::eDepthStencilAttachmentOptimal:
return vk::PipelineStageFlagBits::eEarlyFragmentTests;
case vk::ImageLayout::eShaderReadOnlyOptimal:
return vk::PipelineStageFlagBits::eFragmentShader;
case vk::ImageLayout::ePreinitialized:
return vk::PipelineStageFlagBits::eHost;
case vk::ImageLayout::eUndefined:
return vk::PipelineStageFlagBits::eTopOfPipe;
default:
return vk::PipelineStageFlagBits::eBottomOfPipe;
}
}
} // namespace vulkan
| 38.852761 | 120 | 0.707406 | PedroSFreire |
83c53f0a0aa1ffdae9a53137ba88e36a981d8219 | 1,594 | cc | C++ | chrome/browser/signin/signin_manager_android_factory.cc | chromium/chromium | df46e572c3449a4b108d6e02fbe4f6d24cf98381 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 14,668 | 2015-01-01T01:57:10.000Z | 2022-03-31T23:33:32.000Z | chrome/browser/signin/signin_manager_android_factory.cc | chromium/chromium | df46e572c3449a4b108d6e02fbe4f6d24cf98381 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 86 | 2015-10-21T13:02:42.000Z | 2022-03-14T07:50:50.000Z | chrome/browser/signin/signin_manager_android_factory.cc | chromium/chromium | df46e572c3449a4b108d6e02fbe4f6d24cf98381 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 5,941 | 2015-01-02T11:32:21.000Z | 2022-03-31T16:35:46.000Z | // Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/signin/signin_manager_android_factory.h"
#include "base/no_destructor.h"
#include "chrome/browser/android/signin/signin_manager_android.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
SigninManagerAndroidFactory::SigninManagerAndroidFactory()
: BrowserContextKeyedServiceFactory(
"SigninManagerAndroid",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(IdentityManagerFactory::GetInstance());
}
SigninManagerAndroidFactory::~SigninManagerAndroidFactory() {}
// static
base::android::ScopedJavaLocalRef<jobject>
SigninManagerAndroidFactory::GetJavaObjectForProfile(Profile* profile) {
return static_cast<SigninManagerAndroid*>(
GetInstance()->GetServiceForBrowserContext(profile, true))
->GetJavaObject();
}
// static
SigninManagerAndroidFactory* SigninManagerAndroidFactory::GetInstance() {
static base::NoDestructor<SigninManagerAndroidFactory> instance;
return instance.get();
}
KeyedService* SigninManagerAndroidFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = Profile::FromBrowserContext(context);
auto* identity_manager = IdentityManagerFactory::GetForProfile(profile);
return new SigninManagerAndroid(profile, identity_manager);
}
| 37.069767 | 80 | 0.797992 | chromium |
83cabcb8793c45be6e820790d905f9b5aa7e5339 | 11,520 | cpp | C++ | FlowchartEditor/FlowchartLinkableLineSegment.cpp | pmachapman/Tulip | 54f7bc3e8d5bb452ed8de6e6622e23d5e9be650a | [
"Unlicense"
] | null | null | null | FlowchartEditor/FlowchartLinkableLineSegment.cpp | pmachapman/Tulip | 54f7bc3e8d5bb452ed8de6e6622e23d5e9be650a | [
"Unlicense"
] | 33 | 2018-09-14T21:58:20.000Z | 2022-01-12T21:39:22.000Z | FlowchartEditor/FlowchartLinkableLineSegment.cpp | pmachapman/Tulip | 54f7bc3e8d5bb452ed8de6e6622e23d5e9be650a | [
"Unlicense"
] | null | null | null | /* ==========================================================================
CFlowchartLinkableLineSegment
Author : Johan Rosengren, Abstrakt Mekanik AB
Date : 2004-04-29
Purpose : CFlowchartLinkableLineSegment is a CFlowchartEntity-
derived class, representing a line that can be linked
to other CFlowchartEntity-derived objects.
Description : The implementation is based on CDiagramLine, even though
not derived from it. The class allows two link point,
LINK_START and LINK_END - the top-left and bottom-right
corners.
Usage : Create with CFlowchartControlFactory::CreateFromString
========================================================================*/
#include "stdafx.h"
#include "FlowchartLinkableLineSegment.h"
#include "../DiagramEditor/DiagramLine.h"
//////////////////////////////////////////
// LineDDA callbacks from CDiagramLine
//
VOID CALLBACK HitTest(int X, int Y, LPARAM data);
VOID CALLBACK HitTestRect(int X, int Y, LPARAM data);
CFlowchartLinkableLineSegment::CFlowchartLinkableLineSegment()
/* ============================================================
Function : CFlowchartLinkableLineSegment::CFlowchartLinkableLineSegment
Description : constructor
Return : void
Parameters : none
Usage :
============================================================*/
{
SetMinimumSize(CSize(-1, -1));
SetMaximumSize(CSize(-1, -1));
SetType(_T("flowchart_arrow"));
SetTitle(_T(""));
}
CFlowchartLinkableLineSegment::~CFlowchartLinkableLineSegment()
/* ============================================================
Function : CFlowchartLinkableLineSegment::~CFlowchartLinkableLineSegment
Description : destructor
Return : void
Parameters : none
Usage :
============================================================*/
{
}
CDiagramEntity* CFlowchartLinkableLineSegment::Clone()
/* ============================================================
Function : CFlowchartLinkableLineSegment::Clone
Description : Clone this object to a new object.
Return : CDiagramEntity* - The new object.
Parameters : none
Usage : Call to create a clone of the object. The
caller will have to delete the object.
============================================================*/
{
CFlowchartLinkableLineSegment* obj = new CFlowchartLinkableLineSegment;
obj->Copy(this);
return obj;
}
void CFlowchartLinkableLineSegment::Draw(CDC* dc, CRect rect)
/* ============================================================
Function : CFlowchartLinkableLineSegment::Draw
Description : Draws the object.
Return : void
Parameters : CDC* dc - The CDC to draw to.
CRect rect - The real rectangle of the
object.
Usage : The function should clean up all selected
objects. Note that the CDC is a memory CDC,
so creating a memory CDC in this function
will probably not speed up the function.
============================================================*/
{
dc->SelectStockObject(BLACK_PEN);
dc->SelectStockObject(BLACK_BRUSH);
// Draw line
dc->MoveTo(rect.TopLeft());
dc->LineTo(rect.BottomRight());
// Draw title
CString str = GetTitle();
if (str.GetLength())
{
CFont font;
font.CreateFont(-round(12.0 * GetZoom()), 0, 0, 0, FW_NORMAL, 0, 0, 0, 0, 0, 0, 0, 0, _T("Courier New"));
dc->SelectObject(&font);
int mode = dc->SetBkMode(TRANSPARENT);
CRect rectTemp(rect);
rectTemp.NormalizeRect();
int cy = round(14.0 * GetZoom());
int cut = round((double)GetMarkerSize().cx * GetZoom() / 2);
CRect r(rect.right - cut, rect.top, rect.right - (rectTemp.Width() + cut), rect.bottom);
if (rect.top == rect.bottom)
{
CRect r(rect.left, rect.top - (cy + cut), rect.right, rect.bottom);
r.NormalizeRect();
dc->DrawText(str, r, DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_CENTER);
}
else
{
CRect r(rect.right - cut, rect.top, rect.right - (cy * str.GetLength() + cut), rect.bottom);
r.NormalizeRect();
dc->DrawText(str, r, DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_RIGHT);
}
dc->SelectStockObject(DEFAULT_GUI_FONT);
dc->SetBkMode(mode);
}
}
CDiagramEntity* CFlowchartLinkableLineSegment::CreateFromString(const CString& str)
/* ============================================================
Function : CFlowchartLinkableLineSegment::CreateFromString
Description : Static factory function that creates and
returns an instance of this class if str
is a valid representation.
Return : CDiagramEntity* - The object, or NULL
if str is not a
representation of
this type.
Parameters : const CString& str - The string to create
from.
Usage : Can be used as a factory for text file loads.
Each object type should have its own
version - the default one is a model
implementation.
============================================================*/
{
CFlowchartLinkableLineSegment* obj = new CFlowchartLinkableLineSegment;
if (!obj->FromString(str))
{
delete obj;
obj = NULL;
}
return obj;
}
int CFlowchartLinkableLineSegment::GetHitCode(CPoint point) const
/* ============================================================
Function : CFlowchartLinkableLineSegment::GetHitCode
Description : Returns the hit point constant for point.
Return : int - The hit point,
DEHT_NONE if none.
Parameters : CPoint point - The point to check
Usage : Call to see in what part of the object point
lies.
============================================================*/
{
int result = DEHT_NONE;
CRect rect = GetRect();
hitParams hit;
hit.hit = FALSE;
hit.x = point.x;
hit.y = point.y;
LineDDA((int)GetLeft(),
(int)GetTop(),
(int)GetRight(),
(int)GetBottom(),
HitTest,
(LPARAM)&hit);
if (hit.hit)
result = DEHT_BODY;
CRect rectTest;
rectTest = GetSelectionMarkerRect(DEHT_TOPLEFT, rect);
if (rectTest.PtInRect(point))
result = DEHT_TOPLEFT;
rectTest = GetSelectionMarkerRect(DEHT_BOTTOMRIGHT, rect);
if (rectTest.PtInRect(point))
result = DEHT_BOTTOMRIGHT;
return result;
}
HCURSOR CFlowchartLinkableLineSegment::GetCursor(int hit) const
/* ============================================================
Function : CFlowchartLinkableLineSegment::GetCursor
Description : Returns the cursor for the given hit point.
Return : HCURSOR - The cursor to show
Parameters : int hit - The hit point constant (DEHT_)
to get the cursor for.
Usage : Call to get the cursor for a specific hit
point constant.
============================================================*/
{
HCURSOR cursor = NULL;
switch (hit)
{
case DEHT_BODY:
cursor = LoadCursor(NULL, IDC_SIZEALL);
break;
case DEHT_TOPLEFT:
cursor = LoadCursor(NULL, IDC_SIZEALL);
break;
case DEHT_BOTTOMRIGHT:
cursor = LoadCursor(NULL, IDC_SIZEALL);
break;
}
return cursor;
}
void CFlowchartLinkableLineSegment::DrawSelectionMarkers(CDC* dc, CRect rect) const
/* ============================================================
Function : CFlowchartLinkableLineSegment::DrawSelectionMarkers
Description : Draws the selection markers for the
object.
Return : void
Parameters : CDC* dc - The CDC to draw to
CRect rect - The real object rectangle.
Usage : rect is the true rectangle (zoomed) of the
object.
============================================================*/
{
CRect rectSelect;
dc->SelectStockObject(BLACK_PEN);
CBrush greenBrush;
greenBrush.CreateSolidBrush(RGB(0, 255, 0));
dc->SelectObject(&greenBrush);
rectSelect = GetSelectionMarkerRect(DEHT_TOPLEFT, rect);
dc->Rectangle(rectSelect);
rectSelect = GetSelectionMarkerRect(DEHT_BOTTOMRIGHT, rect);
dc->Rectangle(rectSelect);
dc->SelectStockObject(BLACK_BRUSH);
}
void CFlowchartLinkableLineSegment::SetRect(CRect rect)
/* ============================================================
Function : CFlowchartLinkableLineSegment::SetRect
Description : Sets the rect of the object.
Return : void
Parameters : CRect rect -
Usage : Overriden to avoid normalization.
============================================================*/
{
SetLeft(rect.left);
SetTop(rect.top);
SetRight(rect.right);
SetBottom(rect.bottom);
}
BOOL CFlowchartLinkableLineSegment::BodyInRect(CRect rect) const
/* ============================================================
Function : CFlowchartLinkableLineSegment::BodyInRect
Description : Used to see if any part of the object lies
in rect.
Return : BOOL - TRUE if any part of the
object lies inside rect.
Parameters : CRect rect - The rect to check.
Usage : Call to see if the object overlaps - for
example - a selection rubberband.
============================================================*/
{
BOOL result = FALSE;
hitParamsRect hit;
hit.rect = rect;
hit.hit = FALSE;
LineDDA((int)GetLeft(),
(int)GetTop(),
(int)GetRight(),
(int)GetBottom(),
HitTestRect,
(LPARAM)&hit);
if (hit.hit)
result = TRUE;
return result;
}
CPoint CFlowchartLinkableLineSegment::GetLinkPosition(int type)
/* ============================================================
Function : CFlowchartLinkableLineSegment::GetLinkPosition
Description : Returns the position of a link.
Return : CPoint - The position of the link,
-1, -1 if the link is not
allowed.
Parameters : int type - The type of the link.
Usage : The possible link types are:
LINK_TOP Links are allowed to the
top of the object.
LINK_BOTTOM Links are allowed to the
bottom.
LINK_LEFT Links are allowed to the
left.
LINK_RIGHT Links are allowed to the
right.
LINK_START Links are allowed to the
start of a line (normally
the top-left corner of
the non-normalized bounding
rect).
LINK_END Links are allowed to the
end of a line (normally the
bottom-right corner of the
non-normalized bounding
rect).
============================================================*/
{
CPoint point(-1, -1);
CRect rect = GetRect();
switch (type)
{
case LINK_START:
point.x = rect.left;
point.y = rect.top;
break;
case LINK_END:
point.x = rect.right;
point.y = rect.bottom;
break;
}
return point;
}
int CFlowchartLinkableLineSegment::AllowLink()
/* ============================================================
Function : CFlowchartLinkableLineSegment::AllowLink
Description : Returns the allowed link types for this
object.
Return : int - The allowed link types
Parameters : none
Usage : Call this function to get the link types
allowed for this object. Several link-types
can be ORed together. The possible link
types are:
LINK_TOP Links are allowed to the
top of the object.
LINK_BOTTOM Links are allowed to the
bottom.
LINK_LEFT Links are allowed to the
left.
LINK_RIGHT Links are allowed to the
right.
LINK_ALL Links are allowed to all
of the above.
LINK_START Links are allowed to the
start of a line (normally
the top-left corner of
the non-normalized bounding
rect).
LINK_END Links are allowed to the
end of a line (normally the
bottom-right corner of the
non-normalized bounding
rect).
============================================================*/
{
return LINK_START | LINK_END;
}
| 26.241458 | 107 | 0.59375 | pmachapman |
83cac9e54ed4390788be42e0fc0227378674e68b | 210 | hpp | C++ | source/skyland/opponent/opponent.hpp | evanbowman/skyland | a62827a0dbcab705ba8ddf75cb74e975ceadec39 | [
"MIT"
] | 24 | 2021-07-03T02:27:25.000Z | 2022-03-29T05:21:32.000Z | source/skyland/opponent/opponent.hpp | gbajam21/skyland | 059d9cca67881f04ebb9f51ff2ecac1ca27c93c2 | [
"MIT"
] | 3 | 2021-09-24T18:52:49.000Z | 2021-11-13T00:16:47.000Z | source/skyland/opponent/opponent.hpp | gbajam21/skyland | 059d9cca67881f04ebb9f51ff2ecac1ca27c93c2 | [
"MIT"
] | 1 | 2021-07-11T08:05:59.000Z | 2021-07-11T08:05:59.000Z | #pragma once
#include "skyland/player.hpp"
class Platform;
namespace skyland {
class App;
class Opponent : public Player {
public:
virtual ~Opponent()
{
}
};
} // namespace skyland
| 7 | 32 | 0.628571 | evanbowman |
83cba6e15b084962e05c5549797891c18e752cf0 | 1,075 | hpp | C++ | Hypothesis-checker/argument_handler.hpp | novotnyt94/Hypothesis-checker | 6c539ad748cf8771b9b73943363d6e32232f2df8 | [
"MIT"
] | null | null | null | Hypothesis-checker/argument_handler.hpp | novotnyt94/Hypothesis-checker | 6c539ad748cf8771b9b73943363d6e32232f2df8 | [
"MIT"
] | null | null | null | Hypothesis-checker/argument_handler.hpp | novotnyt94/Hypothesis-checker | 6c539ad748cf8771b9b73943363d6e32232f2df8 | [
"MIT"
] | null | null | null | #ifndef ARGUMENT_HANDLER_
#define ARGUMENT_HANDLER_
#include "errors.hpp"
#include <string>
namespace cube {
/* Parses arguments passed to the program. */
class argument_handler {
public:
/* Parses the arguments. */
static void parse_args(int argc, char ** argv);
//Whether input file was selected
static bool is_input;
//Whether compressed input file was selected
static bool is_comp_input;
//Whether output file for matchings was selected
static bool is_output;
//Whether output file for compressed matchings was selected
static bool is_comp_output;
//Whether output file for paths was selected
static bool is_path_output;
//Input file name
static std::string input_file;
//Compressed input file name
static std::string comp_input_file;
//Matching output file name
static std::string output_file;
//Compressed matching output file name
static std::string comp_output_file;
//Path output file name
static std::string path_output_file;
};
}
#endif //ARGUMENT_HANDLER
| 22.87234 | 62 | 0.717209 | novotnyt94 |
83d1cbe8f1dc8cbdcf2d16d341aa538468ac8594 | 2,045 | cpp | C++ | Game/Source/GDKTestGyms/Private/AsyncPlayerController.cpp | sang-tian/UnrealGDKTestGyms | f68f71c99d35dc2a442845b1bcb84501342d482a | [
"MIT"
] | 9 | 2019-12-06T16:52:16.000Z | 2021-01-04T22:25:46.000Z | Game/Source/GDKTestGyms/Private/AsyncPlayerController.cpp | sang-tian/UnrealGDKTestGyms | f68f71c99d35dc2a442845b1bcb84501342d482a | [
"MIT"
] | 250 | 2019-10-23T13:56:54.000Z | 2021-12-14T17:01:23.000Z | Game/Source/GDKTestGyms/Private/AsyncPlayerController.cpp | sang-tian/UnrealGDKTestGyms | f68f71c99d35dc2a442845b1bcb84501342d482a | [
"MIT"
] | 9 | 2020-01-13T10:54:15.000Z | 2021-12-20T07:28:09.000Z | // Copyright (c) Improbable Worlds Ltd, All Rights Reserved
#include "AsyncPlayerController.h"
#include "EngineUtils.h"
#include "SpatialGDKSettings.h"
#include "AsyncActorSpawner.h"
AAsyncPlayerController::AAsyncPlayerController()
{
}
void AAsyncPlayerController::BeginPlay()
{
Super::BeginPlay();
if (GetWorld()->GetNetMode() == NM_Client)
{
GetWorld()->GetTimerManager().SetTimer(TestCheckTimer, this, &AAsyncPlayerController::CheckTestPassed, 1.0f, false);
}
}
void AAsyncPlayerController::CheckTestPassed()
{
// Check for three statuses on client before reporting successful test;
// 1. AsyncActorSpawner indicates that test setup was correct
// 2. SpatialGDKSettings::bAsyncLoadNewClassesOnEntityCheckout is true
// 3. An instance of AsyncActor exists in the world
bool bAsyncTestCorrectlySetup = false;
bool bAsyncLoad = GetDefault<USpatialGDKSettings>()->bAsyncLoadNewClassesOnEntityCheckout;
bool bAsyncActorExists = false;
for (TActorIterator<AAsyncActorSpawner> It(GetWorld()); It; ++It)
{
AAsyncActorSpawner* AsyncActorSpawner = *It;
bAsyncTestCorrectlySetup = AsyncActorSpawner->bClientTestCorrectSetup;
}
for (TActorIterator<AActor> It(GetWorld()); It; ++It)
{
AActor* Actor = *It;
if (Actor->GetName().Contains(TEXT("AsyncActor_C")))
{
bAsyncActorExists = true;
break;
}
}
if (bAsyncTestCorrectlySetup && bAsyncLoad)
{
if (bAsyncActorExists)
{
UE_LOG(LogTemp, Log, TEXT("Async Test: Test passed."));
UpdateTestPassed(true);
}
else
{
UE_LOG(LogTemp, Log, TEXT("Async Test: Test valid but actor not spawned yet, checking again in 1 second."));
GetWorld()->GetTimerManager().SetTimer(TestCheckTimer, this, &AAsyncPlayerController::CheckTestPassed, 1.0f, false);
}
}
else
{
UE_LOG(LogTemp, Log, TEXT("Async Test: Test invalid on this client - client correctly setup %d, async load on: %d"), bAsyncTestCorrectlySetup, bAsyncLoad);
}
}
void AAsyncPlayerController::UpdateTestPassed_Implementation(bool bInTestPassed)
{
bTestPassed = bInTestPassed;
}
| 27.266667 | 157 | 0.74621 | sang-tian |
83d2cfac3c21be8b58da35c6640d34085576ebff | 503 | cpp | C++ | 2-Structural/11.Flyweight/src/Flyweight/Player.cpp | gfa99/gof_design_patterns | a33ee7f344f8e382bb9fc676b77b22a5a123bca0 | [
"Apache-2.0"
] | 21 | 2017-11-08T11:32:48.000Z | 2021-03-29T08:58:04.000Z | 2-Structural/11.Flyweight/src/Flyweight/Player.cpp | gfa99/gof_design_patterns | a33ee7f344f8e382bb9fc676b77b22a5a123bca0 | [
"Apache-2.0"
] | null | null | null | 2-Structural/11.Flyweight/src/Flyweight/Player.cpp | gfa99/gof_design_patterns | a33ee7f344f8e382bb9fc676b77b22a5a123bca0 | [
"Apache-2.0"
] | 8 | 2017-11-26T13:57:50.000Z | 2021-08-23T06:52:57.000Z | #include <iostream>
#include "Flyweight/Player.h"
namespace GoF {
namespace Flyweight {
Player::Player()
: AbstractItem('$')
{
std::cout << "\nCreating a Player .." << std::endl;
}
void Player::display(const Point & point)
{
std::cout << "displaying Player (" << symbol << ") at "
"Y = " << point.getVerticalAxis() <<
" X = " << point.getVerticalAxis() << std::endl;
}
}
}
| 20.958333 | 67 | 0.465209 | gfa99 |
83d3596a48f906a56f58221491eb23ae1ec96004 | 4,398 | cpp | C++ | keyvi/tests/keyvi/dictionary/fsa/internal/sliding_window_bit_vector_position_tracker_test.cpp | vvucetic/keyvi | e6f02373350fea000aa3d20be9cc1d0ec09441f7 | [
"Apache-2.0"
] | 199 | 2017-12-29T13:36:53.000Z | 2022-03-31T19:38:01.000Z | keyvi/tests/keyvi/dictionary/fsa/internal/sliding_window_bit_vector_position_tracker_test.cpp | vvucetic/keyvi | e6f02373350fea000aa3d20be9cc1d0ec09441f7 | [
"Apache-2.0"
] | 188 | 2017-11-03T18:22:46.000Z | 2022-03-03T17:43:55.000Z | keyvi/tests/keyvi/dictionary/fsa/internal/sliding_window_bit_vector_position_tracker_test.cpp | vvucetic/keyvi | e6f02373350fea000aa3d20be9cc1d0ec09441f7 | [
"Apache-2.0"
] | 35 | 2017-11-02T19:18:34.000Z | 2021-10-05T09:37:22.000Z | //
// keyvi - A key value store.
//
// Copyright 2015 Hendrik Muhs<hendrik.muhs@gmail.com>
//
// 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.
//
/*
* sliding_window_bit_vector_position_tracker_test.cpp
*
* Created on: May 14, 2014
* Author: hendrik
*/
#include <boost/test/unit_test.hpp>
#include "keyvi/dictionary/fsa/internal/bit_vector.h"
#include "keyvi/dictionary/fsa/internal/sliding_window_bit_vector_position_tracker.h"
namespace keyvi {
namespace dictionary {
namespace fsa {
namespace internal {
// The name of the suite must be a different name to your class
BOOST_AUTO_TEST_SUITE(SlidingWindowBitVectorPositionTrackerTests)
BOOST_AUTO_TEST_CASE(nextfreeslot) {
SlidingWindowBitArrayPositionTracker positions;
positions.Set(8);
positions.Set(9);
positions.Set(10);
BOOST_CHECK_EQUAL(11, positions.NextFreeSlot(8));
BOOST_CHECK_EQUAL(12, positions.NextFreeSlot(12));
}
BOOST_AUTO_TEST_CASE(sliding) {
SlidingWindowBitArrayPositionTracker positions;
positions.Set(8);
positions.Set(9);
positions.Set(10);
// trigger switch of the bit vectors
positions.Set(1050);
BOOST_CHECK(positions.IsSet(8));
BOOST_CHECK(positions.IsSet(9));
BOOST_CHECK(positions.IsSet(10));
BOOST_CHECK(!positions.IsSet(1024 + 8));
BOOST_CHECK(!positions.IsSet(1024 + 9));
BOOST_CHECK(!positions.IsSet(1024 + 10));
// trigger switch of the bit vectors and cause slide
positions.Set(2100);
BOOST_CHECK(!positions.IsSet(1024 + 8));
BOOST_CHECK(!positions.IsSet(1024 + 9));
BOOST_CHECK(!positions.IsSet(1024 + 10));
BOOST_CHECK(!positions.IsSet(2048 + 8));
BOOST_CHECK(!positions.IsSet(2048 + 9));
BOOST_CHECK(!positions.IsSet(2048 + 10));
positions.Set(4095);
}
BOOST_AUTO_TEST_CASE(no_integer_overflow) {
SlidingWindowBitArrayPositionTracker positions;
positions.Set(8);
positions.Set(9);
positions.Set(10);
// trigger switch of the bit vectors
uint32_t t = uint32_t(INT_MAX) + 10;
positions.Set(t);
BOOST_CHECK(positions.IsSet(t));
}
BOOST_AUTO_TEST_CASE(set_vector) {
SlidingWindowBitArrayPositionTracker positions;
positions.Set(8);
positions.Set(9);
positions.Set(10);
BitVector<32> a;
a.Set(1);
a.Set(3);
a.Set(25);
a.Set(29);
a.Set(31);
positions.SetVector(a, 2);
BOOST_CHECK(positions.IsSet(3));
BOOST_CHECK(positions.IsSet(5));
BOOST_CHECK(positions.IsSet(27));
}
BOOST_AUTO_TEST_CASE(set_vector_overlap) {
SlidingWindowBitArrayPositionTracker positions;
positions.Set(8);
positions.Set(9);
positions.Set(10);
BitVector<32> a;
a.Set(1);
a.Set(3);
a.Set(25);
a.Set(29);
a.Set(31);
positions.SetVector(a, 1020);
BOOST_CHECK(positions.IsSet(1021));
BOOST_CHECK(positions.IsSet(1023));
BOOST_CHECK(positions.IsSet(1045));
BOOST_CHECK(positions.IsSet(1049));
BOOST_CHECK(positions.IsSet(1051));
}
BOOST_AUTO_TEST_CASE(set_vector_overlap2) {
SlidingWindowBitArrayPositionTracker positions;
positions.Set(8);
positions.Set(9);
positions.Set(10);
BitVector<260> a;
a.Set(119);
a.Set(151);
positions.SetVector(a, 929);
BOOST_CHECK(positions.IsSet(929 + 119));
BOOST_CHECK(positions.IsSet(929 + 151));
positions.SetVector(a, 940);
BOOST_CHECK(positions.IsSet(940 + 119));
BitVector<260> b;
b.Set(100);
positions.SetVector(b, 924);
BOOST_CHECK(positions.IsSet(924 + 100));
}
BOOST_AUTO_TEST_CASE(set_vector_overlap3) {
SlidingWindowBitArrayPositionTracker positions;
positions.Set(8);
positions.Set(9);
positions.Set(10);
BitVector<260> a;
a.Set(256);
a.Set(257);
positions.SetVector(a, 5311);
BOOST_CHECK(positions.IsSet(5311 + 256));
BOOST_CHECK(positions.IsSet(5311 + 257));
positions.Set(5311 + 257);
BOOST_CHECK(positions.IsSet(5311 + 257));
}
BOOST_AUTO_TEST_SUITE_END()
} /* namespace internal */
} /* namespace fsa */
} /* namespace dictionary */
} /* namespace keyvi */
| 23.772973 | 85 | 0.727603 | vvucetic |
83d426a2dedbd53c070f63dccfeec730a35a04da | 13,623 | cpp | C++ | tms_legacy/tms_ss_ods/ods_person_detection/src/ods_person_detection.cpp | robotpilot/ros_tms | 3d6b6579e89aa9cb216cd3cb6157fabc553c18f1 | [
"BSD-3-Clause"
] | 54 | 2015-01-06T06:58:28.000Z | 2021-05-02T07:49:37.000Z | tms_legacy/tms_ss_ods/ods_person_detection/src/ods_person_detection.cpp | robotpilot/ros_tms | 3d6b6579e89aa9cb216cd3cb6157fabc553c18f1 | [
"BSD-3-Clause"
] | 114 | 2015-01-07T06:42:21.000Z | 2022-02-12T05:54:04.000Z | tms_legacy/tms_ss_ods/ods_person_detection/src/ods_person_detection.cpp | robotpilot/ros_tms | 3d6b6579e89aa9cb216cd3cb6157fabc553c18f1 | [
"BSD-3-Clause"
] | 24 | 2015-03-27T08:35:59.000Z | 2020-06-08T13:05:31.000Z | #include <ods_person_detection/person_detection.h>
//*******************************
//**Y軸フィルター
//*******************************
void passfilter(pcl::PointCloud< pcl::PointXYZRGB >& cloud, pcl::PointCloud< pcl::PointXYZRGB >& cloud_out,
std::vector< int >& index)
{
std::cout << "passfilter" << std::endl;
//変数宣言
pcl::PointCloud< pcl::PointXYZRGB >::Ptr tmp_cloud(new pcl::PointCloud< pcl::PointXYZRGB >);
std::vector< int > tmp_index;
// NaN値を除去
pcl::removeNaNFromPointCloud(cloud, *tmp_cloud, tmp_index);
//フィルタリング
for (int i = 0; i < tmp_cloud->size(); i++)
{
if ((-0.20 < tmp_cloud->points[i].y) && (tmp_cloud->points[i].y < 0.30))
{
cloud_out.points.push_back(tmp_cloud->points[i]);
index.push_back(tmp_index[i]);
}
}
return;
}
//*******************************
//**セグメントの端点を求める
//*******************************
Endpoints endpoint(pcl::PointCloud< pcl::PointXYZRGB >& cloud, pcl::PointIndices& inlier)
{
//変数宣言
Endpoints e;
pcl::PointXYZRGB p1, p2; // p1:左側 p2:右側
int inlier1 = 0, inlier2 = 0, count = 0;
double n_x = 0.0, n_y = 0.0, n_z = 0.0, n_c = 0.0;
p1.x = 100.0, p2.x = -100.0;
e.cloud = cloud;
//法線情報を付加
/*pcl::NormalEstimation<pcl::PointXYZRGB, pcl::Normal> ne;
pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>);
pcl::Normal n;
pcl::search::KdTree<pcl::PointXYZRGB>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZRGB> ());
ne.setSearchMethod (tree);
ne.setRadiusSearch (0.03);
ne.compute (*cloud_normals);
for(int i=0;i<cloud_normals->points.size();i++){
if(n_x != 0.0){
n_x += cloud_normals->points[i].normal_x;
n_y += cloud_normals->points[i].normal_y;
n_z += cloud_normals->points[i].normal_z;
n_c += cloud_normals->points[i].curvature;
count++;
}
else{
std::cout << "no normal vector" << std::endl;
}
}
n.normal_x = n_x / (double)count;
n.normal_y = n_y / (double)count;
n.normal_z = n_z / (double)count;
n.curvature = n_c / (double)count;
e.normal = n;*/
//端点を求める
for (int i = 0; i < cloud.points.size(); i++)
{
if (cloud.points[i].x < p1.x)
{
p1 = cloud.points[i];
inlier1 = i;
}
if (p2.x < cloud.points[i].x)
{
p2 = cloud.points[i];
inlier2 = i;
}
}
e.inlier1 = inlier.indices[inlier1];
e.inlier2 = inlier.indices[inlier2];
e.p1 = p1;
e.p2 = p2;
return e;
}
//*******************************
//**オクルージョンの判定
//*******************************
int check_occlusion(pcl::PointCloud< pcl::PointXYZRGB >& cloud, pcl::PointXYZRGB p1, pcl::PointXYZRGB p2, int inlier1,
int inlier2)
{
//変数宣言
double a, b;
int x1, y1, x2, y2;
int count = 0, check = 0; // count:端点間の画素距離,check:端点間の画素で端点より距離値が小さい画素数
//オクルージョン判定
//入力された端点のX(水平方向)が同値の場合
if (p1.x == p2.x)
{
//入力された端点が一致している場合
if (p1.y == p2.y)
{
return 1;
}
//端点間の画素を調べる
else if (p1.y > p2.y)
{
x1 = inlier1 % IMAGE_WIDTH;
y1 = inlier1 / IMAGE_WIDTH;
x2 = inlier2 % IMAGE_WIDTH;
y2 = inlier2 / IMAGE_WIDTH;
while (y1 > y2)
{
count++;
if ((cloud.points[y1 * IMAGE_WIDTH + x1].z <= p1.z) || (cloud.points[y1 * IMAGE_WIDTH + x1].z <= p2.z))
{
check++;
}
y1++;
}
}
else
{
x1 = inlier1 % IMAGE_WIDTH;
y1 = inlier1 / IMAGE_WIDTH;
x2 = inlier2 % IMAGE_WIDTH;
y2 = inlier2 / IMAGE_WIDTH;
while (y1 < y2)
{
count++;
if ((cloud.points[y1 * IMAGE_WIDTH + x1].z <= p1.z) || (cloud.points[y1 * IMAGE_WIDTH + x1].z <= p2.z))
{
check++;
}
y1--;
}
}
}
else
{
a = (p2.y - p1.y) / (p2.x - p1.x);
b = (p2.x * p1.y - p1.x * p2.y) / (p2.x - p1.x);
x1 = inlier1 % IMAGE_WIDTH;
y1 = inlier1 / IMAGE_WIDTH;
x2 = inlier2 % IMAGE_WIDTH;
y2 = inlier2 / IMAGE_WIDTH;
while (x1 <= x2)
{
if ((int)cloud.points[y1 * IMAGE_WIDTH + x1].z >= 0)
{
count++;
if ((cloud.points[y1 * IMAGE_WIDTH + x1].z <= p1.z) || (cloud.points[y1 * IMAGE_WIDTH + x1].z <= p2.z))
{
check++;
}
else
{
std::cout << (double)cloud.points[y1 * IMAGE_WIDTH + x1].z << " " << p1.z << " " << p2.z << std::endl;
}
}
x1++;
y1 += a;
}
}
std::cout << "count : " << count << " check : " << check << std::endl;
if (!count)
{
std::cout << "count is " << count << std::endl;
return 0;
}
else if ((100 * check / count) >= 95)
{
return 1;
}
return 0;
}
std::vector< Endpoints > group_endpoints(std::vector< Endpoints > endpoints_vec,
pcl::PointCloud< pcl::PointXYZRGB >& cloud)
{
std::vector< Endpoints > tmp, fin_e;
std::vector< int > group_number;
return endpoints_vec;
for (int i = 0; i < endpoints_vec.size(); i++)
{
group_number.push_back(i);
tmp.push_back(endpoints_vec[i]);
}
std::cout << "group number : " << group_number.size() << std::endl;
for (int i = 0; i < endpoints_vec.size(); i++)
{
for (int j = 0; j < endpoints_vec.size(); j++)
{
if (i >= j)
continue;
double dis1, dis2;
dis1 = sqrt((tmp[group_number[i]].p1.x - tmp[group_number[j]].p2.x) *
(tmp[group_number[i]].p1.x - tmp[group_number[j]].p2.x) +
(tmp[group_number[i]].p1.z - tmp[group_number[j]].p2.z) *
(tmp[group_number[i]].p1.z - tmp[group_number[j]].p2.z));
dis2 = sqrt((tmp[group_number[i]].p2.x - tmp[group_number[j]].p1.x) *
(tmp[group_number[i]].p2.x - tmp[group_number[j]].p1.x) +
(tmp[group_number[i]].p2.z - tmp[group_number[j]].p1.z) *
(tmp[group_number[i]].p2.z - tmp[group_number[j]].p1.z));
std::cout << "dis1 : " << dis1 << " dis2 : " << dis2 << std::endl;
if ((dis1 < 0.5) || (dis2 < 0.5))
{
if ((dis1 <= dis2))
{
if (check_occlusion(cloud, tmp[group_number[j]].p2, tmp[group_number[i]].p1, tmp[group_number[j]].inlier2,
tmp[group_number[i]].inlier1))
{
tmp[group_number[i]].cloud += tmp[group_number[j]].cloud;
tmp[group_number[i]].inlier1 = tmp[group_number[j]].inlier1;
tmp[group_number[i]].p1 = tmp[group_number[j]].p1;
group_number[j] = group_number[i];
}
}
else if ((dis1 > dis2))
{
if (check_occlusion(cloud, tmp[group_number[i]].p2, tmp[group_number[j]].p1, tmp[group_number[i]].inlier2,
tmp[group_number[j]].inlier1))
{
tmp[group_number[i]].cloud += tmp[group_number[j]].cloud;
tmp[group_number[i]].inlier2 = tmp[group_number[j]].inlier2;
tmp[group_number[i]].p2 = tmp[group_number[j]].p2;
group_number[j] = group_number[i];
}
}
}
}
}
std::cout << "group : ";
for (int j = 0; j < group_number.size(); j++)
{
std::cout << group_number[j] << " ";
}
std::cout << std::endl;
for (int i = 0; i < tmp.size(); i++)
{
for (int j = 0; j < group_number.size(); j++)
{
if (group_number[j] == i)
{
fin_e.push_back(tmp[i]);
break;
}
}
}
return fin_e;
}
//クラスタリング
Endpoints clustering(pcl::PointCloud< pcl::PointXYZRGB >& f_cloud, pcl::PointCloud< pcl::PointXYZRGB >& cloud,
std::vector< int >& index)
{
std::cout << "clustering" << std::endl;
pcl::PointCloud< pcl::PointXYZRGB >::Ptr tmp_cloud(new pcl::PointCloud< pcl::PointXYZRGB >);
pcl::PointCloud< pcl::PointXYZRGB >::Ptr tmp_cloud2(new pcl::PointCloud< pcl::PointXYZRGB >);
std::vector< Endpoints > endpoints_vec;
std::vector< Endpoints > fin_endpoints_vec;
// Creating the KdTree object for the search method of the extraction
pcl::search::KdTree< pcl::PointXYZRGB >::Ptr tree(new pcl::search::KdTree< pcl::PointXYZRGB >);
tree->setInputCloud(f_cloud.makeShared());
std::vector< pcl::PointIndices > cluster_indices;
pcl::EuclideanClusterExtraction< pcl::PointXYZRGB > ec;
ec.setClusterTolerance(0.03);
ec.setMinClusterSize(3000);
ec.setMaxClusterSize(100000);
ec.setSearchMethod(tree);
ec.setInputCloud(f_cloud.makeShared());
ec.extract(cluster_indices);
std::cout << "クラスタリング開始" << std::endl;
int n = 0;
float colors[6][3] = {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}, {255, 255, 0}, {0, 255, 255}, {255, 0, 255}};
for (std::vector< pcl::PointIndices >::const_iterator it = cluster_indices.begin(); it != cluster_indices.end(); ++it)
{
pcl::PointCloud< pcl::PointXYZRGB >::Ptr cloud_cluster(new pcl::PointCloud< pcl::PointXYZRGB >);
pcl::PointIndices::Ptr inlier(new pcl::PointIndices);
for (std::vector< int >::const_iterator pit = it->indices.begin(); pit != it->indices.end(); pit++)
{
cloud_cluster->points.push_back(f_cloud.points[*pit]);
inlier->indices.push_back(index[*pit]);
}
cloud_cluster->width = cloud_cluster->points.size();
cloud_cluster->height = 1;
cloud_cluster->is_dense = true;
std::cout << "クラスタリングaaa" << std::endl;
for (int i = 0; i < cloud_cluster->points.size(); i++)
{
cloud_cluster->points[i].r = colors[n % 6][0];
cloud_cluster->points[i].g = colors[n % 6][1];
cloud_cluster->points[i].b = colors[n % 6][2];
}
*tmp_cloud2 += *cloud_cluster;
std::cout << "part1" << std::endl;
endpoints_vec.push_back(endpoint(*cloud_cluster, *inlier));
n++;
}
std::cout << "part2" << std::endl;
fin_endpoints_vec = group_endpoints(endpoints_vec, cloud);
std::cout << "part3" << std::endl;
double len = 0.0;
int id;
for (int i = 0; i < fin_endpoints_vec.size(); i++)
{
for (int j = 0; j < fin_endpoints_vec[i].cloud.points.size(); j++)
{
fin_endpoints_vec[i].cloud.points[j].r = colors[i % 6][0];
fin_endpoints_vec[i].cloud.points[j].g = colors[i % 6][1];
fin_endpoints_vec[i].cloud.points[j].b = colors[i % 6][2];
}
*tmp_cloud += fin_endpoints_vec[i].cloud;
double l = sqrt((fin_endpoints_vec[i].p1.x - fin_endpoints_vec[i].p2.x) *
(fin_endpoints_vec[i].p1.x - fin_endpoints_vec[i].p2.x) +
(fin_endpoints_vec[i].p1.y - fin_endpoints_vec[i].p2.y) *
(fin_endpoints_vec[i].p1.y - fin_endpoints_vec[i].p2.y) +
(fin_endpoints_vec[i].p1.z - fin_endpoints_vec[i].p2.z) *
(fin_endpoints_vec[i].p1.z - fin_endpoints_vec[i].p2.z));
if (l > len)
{
len = l;
id = i;
}
// std::cout << "\ngroup " << i << std::endl;
// std::cout << "p1 " << fin_endpoints_vec[i].p1.x << " " << fin_endpoints_vec[i].p1.y << " " <<
// fin_endpoints_vec[i].p1.z << std::endl;
// std::cout << "p2 " << fin_endpoints_vec[i].p2.x << " " << fin_endpoints_vec[i].p2.y << " " <<
// fin_endpoints_vec[i].p2.z << std::endl;
}
pcl::io::savePCDFile("src/ods_person_detection/data/person_detection/group_cloud.pcd", *tmp_cloud);
pcl::io::savePCDFile("src/ods_person_detection/data/person_detection/cluster_cloud.pcd", *tmp_cloud2);
return fin_endpoints_vec[id];
}
bool person_detection(tms_msg_ss::ods_person_detection::Request& req, tms_msg_ss::ods_person_detection::Response& res)
{
std::cout << "person_detection" << std::endl;
pcl::PointCloud< pcl::PointXYZRGB >::Ptr cloud(new pcl::PointCloud< pcl::PointXYZRGB >);
Endpoints person;
cv_bridge::CvImagePtr cv_ptr;
tms_msg_ss::ods_pcd srv, srv2;
srv.request.id = 3;
if (commander_to_kinect_capture.call(srv))
{
pcl::fromROSMsg(srv.response.cloud, *cloud);
}
srv2.request.id = 4;
if (commander_to_kinect_capture.call(srv2))
{
cv_ptr = cv_bridge::toCvCopy(srv2.response.image, sensor_msgs::image_encodings::BGR8);
cv::imwrite("src/ods_person_detection/data/person_detection/rgb_image.png", cv_ptr->image);
cv_ptr->toImageMsg(res.image);
std::cout << srv2.response.image.encoding << std::endl;
// cv::imwrite("src/ods_person_detection/data/person_detection/rgb_image.png", rgb_ptr->image);
}
// pcl::io::loadPCDFile("src/ods_person_detection/data/person_detection/input.pcd", *cloud);
pcl::io::savePCDFile("src/ods_person_detection/data/person_detection/input.pcd", *cloud);
pcl::PointCloud< pcl::PointXYZRGB >::Ptr f_cloud(new pcl::PointCloud< pcl::PointXYZRGB >);
std::vector< int > index;
passfilter(*cloud, *f_cloud, index);
person = clustering(*f_cloud, *cloud, index);
/*while(!viewer.wasStopped()){
viewer.showCloud(cloud);
}*/
res.p1_x = person.p1.x * 1000;
res.p1_y = person.p1.y * 1000;
res.p1_z = person.p1.z * 1000;
res.p2_x = person.p2.x * 1000;
res.p2_y = person.p2.y * 1000;
res.p2_z = person.p2.z * 1000;
std::cout << "p1 : " << res.p1_x << " " << res.p1_y << " " << res.p1_z << std::endl;
std::cout << "p2 : " << res.p2_x << " " << res.p2_y << " " << res.p2_z << std::endl;
// pcl::io::savePCDFile("src/ods_person_detection/data/person_detection/filter.pcd", *cloud);
return true;
}
int main(int argc, char** argv)
{
printf("init\n");
ros::init(argc, argv, "ods_person_detection");
ros::NodeHandle n;
service = n.advertiseService("ods_person_detection", person_detection);
commander_to_kinect_capture = n.serviceClient< tms_msg_ss::ods_pcd >("ods_capture");
ros::spin();
return 0;
}
| 30.544843 | 120 | 0.571974 | robotpilot |
83d586446a6b08c9ac94385954f2288c7dad9c95 | 1,098 | hpp | C++ | console/pong/Player.hpp | piotrek-szczygiel/rpi-tetris | 1120b0ac024ef36f48a4fe67087e3e2c78cf83f8 | [
"MIT"
] | 4 | 2019-10-17T20:26:09.000Z | 2019-11-14T12:01:57.000Z | console/pong/Player.hpp | piotrek-szczygiel/rpi-tetris | 1120b0ac024ef36f48a4fe67087e3e2c78cf83f8 | [
"MIT"
] | null | null | null | console/pong/Player.hpp | piotrek-szczygiel/rpi-tetris | 1120b0ac024ef36f48a4fe67087e3e2c78cf83f8 | [
"MIT"
] | null | null | null | #pragma once
#include <raylib.h>
namespace Pong {
constexpr float PLAYER_HEIGHT { 180.0F };
constexpr float PLAYER_POWER_UP_HEIGHT { 300.0F };
constexpr float PLAYER_POWER_UP_DURATION { 10.0F };
struct PlayerControls {
bool up;
bool down;
};
class Player {
public:
int m_score;
float m_power_up_timer;
Vector2 m_speed;
PlayerControls m_controls;
Player()
: m_width { 17.0F }
, m_height { PLAYER_HEIGHT }
, m_speed_factor { 600.0F }
, m_controls {}
, m_score {}
, m_position {}
, m_speed {}
, m_power_up_timer { 0.0F }
, m_offset_y { 0.0F }
{
}
~Player() = default;
void update(float dt, int min_height, int max_height);
void init_round(Vector2 pos);
void draw();
Rectangle get_player_rect()
{
return { m_position.x, m_position.y + m_offset_y, static_cast<float>(m_width),
static_cast<float>(m_height) };
};
private:
float m_speed_factor;
float m_offset_y;
float m_width;
float m_height;
Vector2 m_position;
};
}
| 19.607143 | 86 | 0.614754 | piotrek-szczygiel |
83d5880633fca24815d45aebe820075d1a91666b | 3,217 | cpp | C++ | src/number_conversion_utils.cpp | william01110111/wmwwStatusline | 658ae739e45694bfad201aa33eb2aceecef10195 | [
"WTFPL"
] | 1 | 2021-11-11T03:43:32.000Z | 2021-11-11T03:43:32.000Z | src/number_conversion_utils.cpp | william01110111/wmwwStatusline | 658ae739e45694bfad201aa33eb2aceecef10195 | [
"WTFPL"
] | null | null | null | src/number_conversion_utils.cpp | william01110111/wmwwStatusline | 658ae739e45694bfad201aa33eb2aceecef10195 | [
"WTFPL"
] | null | null | null | #include "number_conversion_utils.h"
#include <math.h>
using std::min;
using std::max;
// const string fixedWidthSpace = "\xe3\x80\x80"; // Full width space
const string fixedWidthSpace = "\x20"; // ASCII space
// const string fixedWidthSpace = "\x20\x20"; // 2 ASCII spaces
string intToString(int in)
{
string out;
bool negative = false;
if (in < 0)
{
negative = true;
in *= -1;
}
do
{
out = (char)((in % 10) + '0') + out;
in /= 10;
}
while (in > 0);
if (negative)
out = "-" + out;
return out;
}
string doubleToString(double in)
{
long long a=in;
long long b=(in-a)*10000000000;
if (b<0)
b*=-1;
if (b%10==9)
b+=1;
while (b>0 && !(b%10))
b/=10;
return intToString(a)+(b ? "."+intToString(b) : "");
}
int stringToInt(string in)
{
int out = 0;
for (int i = 0; i < (int)in.size(); i++)
{
if (in[i] >= '0' && in[i] <= '9')
{
out = out * 10 + in[i] - '0';
}
else if (in[i] == '.')
break;
}
if (in.size() > 0 && in[0] == '-')
out *= -1;
return out;
}
unsigned long long stringToUnsignedLongLong(string in)
{
unsigned long long out = 0;
for (int i = 0; i < (int)in.size(); i++)
{
if (in[i] >= '0' && in[i] <= '9')
{
out = out * 10 + in[i] - '0';
}
else if (in[i] == '.')
break;
}
return out;
}
double stringToDouble(string in)
{
double out = 0;
int divider = 1;
for (int i = 0; i < (int)in.size(); i++)
{
if (divider == 1)
{
if (in[i] >= '0' && in[i] <= '9')
out = out * 10 + in[i] - '0';
else if (in[i] == '.')
divider = 10;
}
else
{
if (in[i] >= '0' && in[i] <= '9')
{
out += (double)(in[i] - '0') / divider;
divider *= 10;
}
}
}
if (in.size() > 0 && in[0] == '-')
out *= -1;
return out;
}
const vector<string> verticalBarStrs = {fixedWidthSpace, "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"};
const vector<string> horizontalBarStrs = {fixedWidthSpace, "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█"};
const vector<string> pieChartStrs = {fixedWidthSpace, "◜", "◠", "◠", "○", "○", "◔", "◑", "◕", "●"};
const vector<string> dotStrs = {fixedWidthSpace, "◌", "○", "◎", "◉", "●"};
const vector<string> circleSpinnerStrs = {"◜", "◝", "◞", " ◟"};
string verticalBar(double val)
{
int i=min(floor(val * verticalBarStrs.size()), (double)verticalBarStrs.size()-1);
return verticalBarStrs[i];
}
string doubleAsPercent(double val)
{
return
(val >= 1 ? intToString(val) : " ") +
(val * 10 >= 1 ? intToString((int)(val*10) % 10) : " ") +
intToString((int)(val*100) % 10) +
"%";
}
string horizontalBar(double val, int charWidth)
{
string out;
int before, after, index;
before = (int)floor(charWidth * val);
index = min(((charWidth * val) - before) * horizontalBarStrs.size(), (double)verticalBarStrs.size()-1);
after = charWidth - before - 1;
for (int i = 0; i < before; i++)
{
out += "█";
}
out += horizontalBarStrs[index];
for (int i = 0; i < after; i++)
{
out += fixedWidthSpace;
}
return out;
}
string pieChart(double val)
{
int i=min(floor(val * pieChartStrs.size()), (double)pieChartStrs.size()-1);
return pieChartStrs[i];
}
string dot(double val)
{
int i=min(floor(val * dotStrs.size()), (double)dotStrs.size()-1);
return dotStrs[i];
}
| 18.703488 | 104 | 0.539633 | william01110111 |
83d8a1e4e797244b84ad7fff3fea86eca617b199 | 339 | hpp | C++ | y2018/filters/mergeFinalWindows.hpp | valkyrierobotics/vision2018 | aa82e936c5481b7cc43a46ff5f6e68702c2166c2 | [
"BSD-2-Clause"
] | 2 | 2016-08-06T06:21:02.000Z | 2017-01-10T05:45:13.000Z | y2018/filters/mergeFinalWindows.hpp | valkyrierobotics/vision2018 | aa82e936c5481b7cc43a46ff5f6e68702c2166c2 | [
"BSD-2-Clause"
] | 1 | 2017-04-15T20:54:59.000Z | 2017-04-15T20:54:59.000Z | y2018/filters/mergeFinalWindows.hpp | valkyrierobotics/vision2018 | aa82e936c5481b7cc43a46ff5f6e68702c2166c2 | [
"BSD-2-Clause"
] | 3 | 2016-07-30T06:19:55.000Z | 2017-02-07T01:55:05.000Z | #ifndef MERGE_FINAL_WINDOWS_HPP
#define MERGE_FINAL_WINDOWS_HPP
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "mergeFinal.hpp"
void mergeFinalWindows(cv::Mat& img1, cv::Mat& img2, int& weight1, int& weight2, int& apply, bool visible, const bool isStreaming);
#endif // MERGE_FINAL_WINDOWS_HPP
| 28.25 | 131 | 0.784661 | valkyrierobotics |
83df05f739587e2a348cdbf36456d819fe161ac0 | 2,132 | cpp | C++ | utilities/seismo-diag/plotter.cpp | sergev/vak-opensource | e1912b83dabdbfab2baee5e7a9a40c3077349381 | [
"Apache-2.0"
] | 34 | 2016-10-29T19:50:34.000Z | 2022-02-12T21:27:43.000Z | utilities/seismo-diag/plotter.cpp | sergev/vak-opensource | e1912b83dabdbfab2baee5e7a9a40c3077349381 | [
"Apache-2.0"
] | null | null | null | utilities/seismo-diag/plotter.cpp | sergev/vak-opensource | e1912b83dabdbfab2baee5e7a9a40c3077349381 | [
"Apache-2.0"
] | 19 | 2017-06-19T23:04:00.000Z | 2021-11-13T15:00:41.000Z | #include <QtGui>
#include "plotter.h"
Plotter::Plotter (QWidget *parent)
: QWidget (parent)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
}
QSize Plotter::sizeHint() const
{
return QSize (500, 150);
}
void Plotter::paintEvent (QPaintEvent * /*event*/)
{
//printf ("paint event()\n");
QPainter paint;
paint.begin (this);
paint.drawPixmap (0, 0, pixmap);
paint.end();
}
void Plotter::resizeEvent (QResizeEvent * /*event*/)
{
//printf ("resize event() width=%d, height=%d\n", width(), height());
pixmap = QPixmap (size());
pixmap.fill (Qt::lightGray);
}
/*
* Рисуем одно измерение из пакета.
* Всего в пакете packet_length измерений.
* Они поступают по одному с номерами n от 0 и дальше.
*/
void Plotter::add_sample (int percent, int n, int packet_length)
{
if (n == 0) {
/* Прокрутка окна. */
// pixmap.scroll (-packet_length, 0, rect());
QPainter painter;
painter.begin (&pixmap);
painter.drawPixmap (-packet_length, 0, pixmap);
painter.fillRect (width() - packet_length, 0,
packet_length, height(), Qt::lightGray);
painter.end();
}
int h = -percent * height() / 200;
int y = height() / 2;
//printf ("%d >> %d %d\n", percent, y, h);
QPainter painter;
painter.begin (&pixmap);
if (h > 0)
painter.fillRect (width() - packet_length + n, y, 1, h, Qt::darkGreen);
else if (h < 0)
painter.fillRect (width() - packet_length + n, y+h, 1, -h, Qt::darkGreen);
painter.end();
update ();
}
/*
* Рисуем ежесекундную метку времени.
*/
void Plotter::draw_label (int n, int packet_length)
{
QPainter painter;
painter.begin (&pixmap);
painter.fillRect (width() - packet_length + n, 0, 1, height(), Qt::yellow);
painter.end();
update ();
}
/*
* Рисуем время начала пакета.
*/
void Plotter::draw_time (double sec)
{
int min = sec / 60;
sec -= min * 60;
QString message;
message.sprintf ("%d:%02d:%02.3f", min / 60, min % 60, sec);
QPainter painter;
painter.begin (&pixmap);
painter.fillRect (width() - 1, 0, 1, height(), Qt::darkRed);
painter.drawText (0, 2, width() - 2, height(),
Qt::AlignRight | Qt::AlignTop, message);
painter.end();
update ();
}
| 22.442105 | 76 | 0.644934 | sergev |
83e148a164441ac3f8147d90b99d9abf2f5de0be | 4,624 | cxx | C++ | Modules/Core/Common/test/otbRGBAPixelConverter.cxx | lfyater/Orfeo | eb3d4d56089065b99641d8ae7338d2ed0358d28a | [
"Apache-2.0"
] | 2 | 2019-02-13T14:48:19.000Z | 2019-12-03T02:54:28.000Z | Modules/Core/Common/test/otbRGBAPixelConverter.cxx | lfyater/Orfeo | eb3d4d56089065b99641d8ae7338d2ed0358d28a | [
"Apache-2.0"
] | 3 | 2015-10-14T10:11:38.000Z | 2015-10-15T08:26:23.000Z | Modules/Core/Common/test/otbRGBAPixelConverter.cxx | CS-SI/OTB | 5926aca233ff8a0fb11af1a342a6f5539cd5e376 | [
"Apache-2.0"
] | 2 | 2015-10-08T12:04:06.000Z | 2018-06-19T08:00:47.000Z | /*
* Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* 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 "itkMacro.h"
#include <cstdlib>
#include <cmath>
#include "otbRGBAPixelConverter.h"
int otbRGBAPixelConverterNew(int itkNotUsed(argc), char * itkNotUsed(argv) [])
{
typedef unsigned char PixelType0;
typedef double PixelType1;
typedef itk::RGBAPixel<unsigned char> PixelType2;
typedef itk::RGBPixel<double> PixelType3;
typedef otb::RGBAPixelConverter<PixelType0, PixelType0> ConverterType0;
typedef otb::RGBAPixelConverter<PixelType1, PixelType1> ConverterType1;
typedef otb::RGBAPixelConverter<PixelType0, PixelType2> ConverterType2;
typedef otb::RGBAPixelConverter<PixelType0, PixelType3> ConverterType3;
// Instantiating object
ConverterType0::Pointer converter0 = ConverterType0::New();
ConverterType1::Pointer converter1 = ConverterType1::New();
ConverterType2::Pointer converter2 = ConverterType2::New();
ConverterType3::Pointer converter3 = ConverterType3::New();
std::cout << converter0 << std::endl;
std::cout << converter1 << std::endl;
std::cout << converter2 << std::endl;
std::cout << converter3 << std::endl;
return EXIT_SUCCESS;
}
int otbRGBAPixelConverter(int itkNotUsed(argc), char * itkNotUsed(argv) [])
{
typedef unsigned int PixelType0;
typedef double PixelType1;
typedef itk::RGBAPixel<unsigned int> PixelType2;
typedef itk::RGBAPixel<double> PixelType3;
typedef itk::RGBPixel<double> PixelType4;
typedef otb::RGBAPixelConverter<PixelType0, PixelType0> ConverterType0;
typedef otb::RGBAPixelConverter<PixelType1, PixelType0> ConverterType1;
typedef otb::RGBAPixelConverter<PixelType0, PixelType3> ConverterType2;
typedef otb::RGBAPixelConverter<PixelType0, PixelType4> ConverterType3;
// Instantiating object
ConverterType0::Pointer converter0 = ConverterType0::New();
ConverterType1::Pointer converter1 = ConverterType1::New();
ConverterType2::Pointer converter2 = ConverterType2::New();
ConverterType3::Pointer converter3 = ConverterType3::New();
PixelType2 pixel0;
pixel0[0] = 125;
pixel0[1] = 105;
pixel0[2] = 145;
pixel0[3] = 0;
ConverterType0::OutputPixelType outputPixel0 = converter0->Convert(pixel0);
std::cout << "outputPixel0: " << outputPixel0 << std::endl;
if(outputPixel0 != 112)
{
itkGenericExceptionMacro(<< "RGBA<unsigned int> 2 unsigned int Failed");
}
PixelType3 pixel1;
pixel1[0] = 125.0;
pixel1[1] = 105.0;
pixel1[2] = 145.0;
pixel1[3] = 191.0;
ConverterType1::OutputPixelType outputPixel1 = converter1->Convert(pixel1);
std::cout << "outputPixel1: " << outputPixel1 << std::endl;
if(outputPixel1 != 112)
{
itkGenericExceptionMacro(<< "RGBA<double> 2 unsigned int Failed");
}
PixelType2 pixel2;
pixel2[0] = 125;
pixel2[1] = 105;
pixel2[2] = 145;
pixel2[3] = 0;
ConverterType2::OutputPixelType outputPixel2 = converter2->Convert(pixel2);
std::cout << "outputPixel2: " << outputPixel2 << std::endl;
if(outputPixel2[0] != 125 || outputPixel2[1] != 105 || outputPixel2[2] != 145 || outputPixel2[3] != 0 )
{
itkGenericExceptionMacro(<< "RGBA<unsigned int> 2 RGBA<double> Failed");
}
PixelType2 pixel3;
pixel3[0] = 125;
pixel3[1] = 105;
pixel3[2] = 145;
pixel3[3] = 0;
ConverterType3::OutputPixelType outputPixel3 = converter3->Convert(pixel3);
std::cout << "outputPixel3: " << outputPixel3 << std::endl;
if(outputPixel3[0] != 125 || outputPixel3[1] != 105 || outputPixel3[2] != 145)
{
itkGenericExceptionMacro(<< "RGBA<unsigned int> 2 RGB<double> Failed");
}
return EXIT_SUCCESS;
}
| 37.593496 | 105 | 0.658737 | lfyater |
83e1993e11177f33b3e723fc85b2e07e8f7cde9d | 10,381 | cpp | C++ | extern/eltopo/common/tunicate/sos_intersection.cpp | wycivil08/blendocv | f6cce83e1f149fef39afa8043aade9c64378f33e | [
"Unlicense"
] | 30 | 2015-01-29T14:06:05.000Z | 2022-01-10T07:47:29.000Z | extern/eltopo/common/tunicate/sos_intersection.cpp | ttagu99/blendocv | f6cce83e1f149fef39afa8043aade9c64378f33e | [
"Unlicense"
] | 1 | 2017-02-20T20:57:48.000Z | 2018-12-19T23:44:38.000Z | extern/eltopo/common/tunicate/sos_intersection.cpp | ttagu99/blendocv | f6cce83e1f149fef39afa8043aade9c64378f33e | [
"Unlicense"
] | 15 | 2015-04-23T02:38:36.000Z | 2021-03-01T20:09:39.000Z | // Released into the public domain by Robert Bridson, 2009.
#include <cassert>
#include "tunicate.h"
//==============================================================================
// Note: it is assumed all arguments are nonzero (have a sign).
static bool
same_sign(double a, double b)
{
return (a<0 && b<0) || (a>0 && b>0);
}
//==============================================================================
int
sos_simplex_intersection1d(int k,
int pri0, const double* x0,
int pri1, const double* x1,
int pri2, const double* x2,
double* alpha0,
double* alpha1,
double* alpha2)
{
assert(1<=k && k<=2);
assert(alpha0 && alpha1 && alpha2);
double sum;
switch(k){
case 1: // point vs. segment
*alpha1=-sos_orientation1d(pri0, x0, pri2, x2);
*alpha2= sos_orientation1d(pri0, x0, pri1, x1);
if(same_sign(*alpha1, *alpha2)){
*alpha0=1;
sum=*alpha1+*alpha2;
*alpha1/=sum;
*alpha2/=sum;
return 1;
}else
return 0;
case 2: // segment vs. point
return sos_simplex_intersection1d(1, pri2, x2,
pri1, x1,
pri0, x0,
alpha2, alpha1, alpha0);
default:
return -1; // should never get here
}
}
//==============================================================================
int
sos_simplex_intersection2d(int k,
int pri0, const double* x0,
int pri1, const double* x1,
int pri2, const double* x2,
int pri3, const double* x3,
double* alpha0,
double* alpha1,
double* alpha2,
double* alpha3)
{
assert(1<=k && k<=3);
double sum1, sum2;
switch(k){
case 1: // point vs. triangle
*alpha1=-sos_orientation2d(pri0, x0, pri2, x2, pri3, x3);
*alpha2= sos_orientation2d(pri0, x0, pri1, x1, pri3, x3);
if(!same_sign(*alpha1, *alpha2)) return 0;
*alpha3=-sos_orientation2d(pri0, x0, pri1, x1, pri2, x2);
if(!same_sign(*alpha1, *alpha3)) return 0;
*alpha0=1;
sum2=*alpha1+*alpha2+*alpha3;
*alpha1/=sum2;
*alpha2/=sum2;
*alpha3/=sum2;
return 1;
case 2: // segment vs. segment
*alpha0= sos_orientation2d(pri1, x1, pri2, x2, pri3, x3);
*alpha1=-sos_orientation2d(pri0, x0, pri2, x2, pri3, x3);
if(!same_sign(*alpha0, *alpha1)) return 0;
*alpha2= sos_orientation2d(pri0, x0, pri1, x1, pri3, x3);
*alpha3=-sos_orientation2d(pri0, x0, pri1, x1, pri2, x2);
if(!same_sign(*alpha2, *alpha3)) return 0;
sum1=*alpha0+*alpha1;
*alpha0/=sum1;
*alpha1/=sum1;
sum2=*alpha2+*alpha3;
*alpha2/=sum2;
*alpha3/=sum2;
return 1;
case 3: // triangle vs. point
return sos_simplex_intersection2d(1, pri3, x3,
pri2, x2,
pri1, x1,
pri0, x0,
alpha3, alpha2, alpha1, alpha0);
default:
return -1; // should never get here
}
}
//==============================================================================
int
sos_simplex_intersection3d(int k,
int pri0, const double* x0,
int pri1, const double* x1,
int pri2, const double* x2,
int pri3, const double* x3,
int pri4, const double* x4,
double* alpha0,
double* alpha1,
double* alpha2,
double* alpha3,
double* alpha4)
{
assert(1<=k && k<=4);
double sum1, sum2;
switch(k){
case 1: // point vs. tetrahedron
*alpha1=-sos_orientation3d(pri0, x0, pri2, x2, pri3, x3, pri4, x4);
*alpha2= sos_orientation3d(pri0, x0, pri1, x1, pri3, x3, pri4, x4);
if(!same_sign(*alpha1, *alpha2)) return 0;
*alpha3=-sos_orientation3d(pri0, x0, pri1, x1, pri2, x2, pri4, x4);
if(!same_sign(*alpha1, *alpha3)) return 0;
*alpha4= sos_orientation3d(pri0, x0, pri1, x1, pri2, x2, pri3, x3);
if(!same_sign(*alpha1, *alpha4)) return 0;
*alpha0=1;
sum2=*alpha1+*alpha2+*alpha3+*alpha4;
*alpha1/=sum2;
*alpha2/=sum2;
*alpha3/=sum2;
*alpha4/=sum2;
return 1;
case 2: // segment vs. triangle
*alpha0= sos_orientation3d(pri1, x1, pri2, x2, pri3, x3, pri4, x4);
*alpha1=-sos_orientation3d(pri0, x0, pri2, x2, pri3, x3, pri4, x4);
if(!same_sign(*alpha0, *alpha1)) return 0;
*alpha2= sos_orientation3d(pri0, x0, pri1, x1, pri3, x3, pri4, x4);
*alpha3=-sos_orientation3d(pri0, x0, pri1, x1, pri2, x2, pri4, x4);
if(!same_sign(*alpha2, *alpha3)) return 0;
*alpha4= sos_orientation3d(pri0, x0, pri1, x1, pri2, x2, pri3, x3);
if(!same_sign(*alpha2, *alpha4)) return 0;
sum1=*alpha0+*alpha1;
*alpha0/=sum1;
*alpha1/=sum1;
sum2=*alpha2+*alpha3+*alpha4;
*alpha2/=sum2;
*alpha3/=sum2;
*alpha4/=sum2;
return 1;
case 3: // triangle vs. segment
case 4: // tetrahedron vs. point
return sos_simplex_intersection3d(5-k, pri4, x4,
pri3, x3,
pri2, x2,
pri1, x1,
pri0, x0,
alpha4, alpha3, alpha2, alpha1, alpha0);
default:
return -1; // should never get here
}
}
//==============================================================================
int
sos_simplex_intersection4d(int k,
int pri0, const double* x0,
int pri1, const double* x1,
int pri2, const double* x2,
int pri3, const double* x3,
int pri4, const double* x4,
int pri5, const double* x5,
double* alpha0,
double* alpha1,
double* alpha2,
double* alpha3,
double* alpha4,
double* alpha5)
{
assert(1<=k && k<=5);
double sum1, sum2;
switch(k){
case 1: // point vs. pentachoron
*alpha1=-sos_orientation4d(pri0,x0,pri2,x2,pri3,x3,pri4,x4,pri5,x5);
*alpha2= sos_orientation4d(pri0,x0,pri1,x1,pri3,x3,pri4,x4,pri5,x5);
if(!same_sign(*alpha1, *alpha2)) return 0;
*alpha3=-sos_orientation4d(pri0,x0,pri1,x1,pri2,x2,pri4,x4,pri5,x5);
if(!same_sign(*alpha1, *alpha3)) return 0;
*alpha4= sos_orientation4d(pri0,x0,pri1,x1,pri2,x2,pri3,x3,pri5,x5);
if(!same_sign(*alpha1, *alpha4)) return 0;
*alpha5=-sos_orientation4d(pri0,x0,pri1,x1,pri2,x2,pri3,x3,pri4,x4);
if(!same_sign(*alpha1, *alpha5)) return 0;
*alpha0=1;
sum2=*alpha1+*alpha2+*alpha3+*alpha4+*alpha5;
*alpha1/=sum2;
*alpha2/=sum2;
*alpha3/=sum2;
*alpha4/=sum2;
*alpha5/=sum2;
return 1;
case 2: // segment vs. tetrahedron
*alpha0= sos_orientation4d(pri1,x1,pri2,x2,pri3,x3,pri4,x4,pri5,x5);
*alpha1=-sos_orientation4d(pri0,x0,pri2,x2,pri3,x3,pri4,x4,pri5,x5);
if(!same_sign(*alpha0, *alpha1)) return 0;
*alpha2= sos_orientation4d(pri0,x0,pri1,x1,pri3,x3,pri4,x4,pri5,x5);
*alpha3=-sos_orientation4d(pri0,x0,pri1,x1,pri2,x2,pri4,x4,pri5,x5);
if(!same_sign(*alpha2, *alpha3)) return 0;
*alpha4= sos_orientation4d(pri0,x0,pri1,x1,pri2,x2,pri3,x3,pri5,x5);
if(!same_sign(*alpha2, *alpha4)) return 0;
*alpha5=-sos_orientation4d(pri0,x0,pri1,x1,pri2,x2,pri3,x3,pri4,x4);
if(!same_sign(*alpha2, *alpha5)) return 0;
sum1=*alpha0+*alpha1;
*alpha0/=sum1;
*alpha1/=sum1;
sum2=*alpha2+*alpha3+*alpha4+*alpha5;
*alpha2/=sum2;
*alpha3/=sum2;
*alpha4/=sum2;
*alpha5/=sum2;
return 1;
case 3: // triangle vs. triangle
*alpha0= sos_orientation4d(pri1,x1,pri2,x2,pri3,x3,pri4,x4,pri5,x5);
*alpha1=-sos_orientation4d(pri0,x0,pri2,x2,pri3,x3,pri4,x4,pri5,x5);
if(!same_sign(*alpha0, *alpha1)) return 0;
*alpha2= sos_orientation4d(pri0,x0,pri1,x1,pri3,x3,pri4,x4,pri5,x5);
if(!same_sign(*alpha0, *alpha2)) return 0;
*alpha3=-sos_orientation4d(pri0,x0,pri1,x1,pri2,x2,pri4,x4,pri5,x5);
*alpha4= sos_orientation4d(pri0,x0,pri1,x1,pri2,x2,pri3,x3,pri5,x5);
if(!same_sign(*alpha3, *alpha4)) return 0;
*alpha5=-sos_orientation4d(pri0,x0,pri1,x1,pri2,x2,pri3,x3,pri4,x4);
if(!same_sign(*alpha3, *alpha5)) return 0;
sum1=*alpha0+*alpha1+*alpha2;
*alpha0/=sum1;
*alpha1/=sum1;
*alpha2/=sum1;
sum2=*alpha3+*alpha4+*alpha5;
*alpha3/=sum2;
*alpha4/=sum2;
*alpha5/=sum2;
return 1;
case 4: // tetrahedron vs. segment
case 5: // pentachoron vs. point
return sos_simplex_intersection4d(6-k, pri5, x5,
pri4, x4,
pri3, x3,
pri2, x2,
pri1, x1,
pri0, x0,
alpha5, alpha4, alpha3, alpha2, alpha1, alpha0);
default:
return -1; // should never get here
}
}
| 41.031621 | 80 | 0.469126 | wycivil08 |
83e4c4f670cddc19f5905c689f507838288a762f | 6,366 | cc | C++ | src/optimizer.cc | RobertBendun/stacky | f61622e35c8bd07533cb198573e355e556cd8057 | [
"BSL-1.0"
] | 3 | 2021-09-14T14:22:00.000Z | 2021-09-29T20:04:40.000Z | src/optimizer.cc | RobertBendun/stacky | f61622e35c8bd07533cb198573e355e556cd8057 | [
"BSL-1.0"
] | 58 | 2021-09-14T22:20:28.000Z | 2021-11-24T17:37:42.000Z | src/optimizer.cc | RobertBendun/stacky | f61622e35c8bd07533cb198573e355e556cd8057 | [
"BSL-1.0"
] | null | null | null | #include "stacky.hh"
#include "utilities.cc"
namespace optimizer
{
auto for_all_functions(Generation_Info &geninfo, auto &&iteration)
{
bool result = callv(iteration, false, geninfo, geninfo.main);
for (auto &[name, word] : geninfo.words)
if (word.kind == Word::Kind::Function)
result |= callv(iteration, false, geninfo, word.function_body);
return result;
}
void remove_unused_words_and_strings(
Generation_Info &geninfo,
std::vector<Operation> const& function_body,
std::unordered_set<std::uint64_t> &used_words,
std::unordered_set<std::uint64_t> &used_strings)
{
for (auto const& op : function_body) {
if (op.kind != Operation::Kind::Push_Symbol && op.kind != Operation::Kind::Call_Symbol)
continue;
if (op.token.kind == Token::Kind::String) {
used_strings.insert(op.token.ival);
} else {
if (used_words.contains(op.ival))
continue;
used_words.insert(op.ival);
auto const word = std::find_if(std::cbegin(geninfo.words), std::cend(geninfo.words), [word_id = op.ival](auto const &entry)
{
return entry.second.id == word_id;
});
assert(word != std::cend(geninfo.words));
if (word->second.kind != Word::Kind::Function)
continue;
remove_unused_words_and_strings(geninfo, word->second.function_body, used_words, used_strings);
}
}
}
auto remove_unused_words_and_strings(Generation_Info &geninfo) -> bool
{
std::unordered_set<std::uint64_t> used_words;
std::unordered_set<std::uint64_t> used_strings;
remove_unused_words_and_strings(geninfo, geninfo.main, used_words, used_strings);
auto const removed_words = std::erase_if(geninfo.words, [&](auto const& entry) {
return (entry.second.kind == Word::Kind::Function || entry.second.kind == Word::Kind::Array) && !used_words.contains(entry.second.id);
});
auto const removed_strings = std::erase_if(geninfo.strings, [&](auto const& entry) {
return !used_strings.contains(entry.second);
});
if (removed_words > 0) verbose("Removed {} functions and arrays"_format(removed_words));
if (removed_strings > 0) verbose("Removed {} strings"_format(removed_strings));
return removed_words + removed_strings;
}
auto optimize_comptime_known_conditions([[maybe_unused]] Generation_Info &geninfo, std::vector<Operation> &function_body) -> bool
{
bool done_something = false;
auto const remap = [&function_body](unsigned start, unsigned end, unsigned amount, auto const& ...msg)
{
for (auto& op : function_body)
if (op.jump >= start && op.jump <= end) {
// (std::cout << ... << msg) << ((sizeof...(msg)==0)+" ") << op.jump << " -> " << (op.jump - amount) << '\n';
op.jump -= amount;
}
};
for (auto branch_op = 1u; branch_op < function_body.size(); ++branch_op) {
auto const condition_op = branch_op - 1;
auto const& condition = function_body[condition_op];
auto const& branch = function_body[branch_op];
if (condition.kind != Operation::Kind::Push_Int || branch.kind != Operation::Kind::Do && branch.kind != Operation::Kind::If)
continue;
done_something = true;
switch (branch.kind) {
case Operation::Kind::Do:
{
auto const condition_ival = condition.ival;
auto const end_op = branch.jump-1;
if (condition.ival != 0) {
assert(function_body[branch.jump-1].kind == Operation::Kind::End);
if (std::cbegin(function_body) + branch.jump + 1 != std::cend(function_body)) {
warning(function_body[branch.jump].location, "Dead code: Loop is infinite");
info(function_body[condition_op-1].location, "Infinite loop introduced here.");
}
function_body.erase(std::cbegin(function_body) + branch.jump, std::end(function_body));
function_body.erase(std::cbegin(function_body) + condition_op, std::cbegin(function_body) + branch_op + 1);
remap(branch_op+1, end_op, 3);
verbose(branch.token, "Optimizing infinite loop (condition is always true)");
} else {
function_body.erase(std::cbegin(function_body) + condition_op, std::cbegin(function_body) + branch.jump);
remap(end_op, -1, end_op - branch_op + 3);
verbose(branch.token, "Optimizing never executing loop (condition is always false)");
}
// find and remove `while`
auto while_op = unsigned(condition_op-1);
while (while_op < function_body.size() &&
function_body[while_op].kind != Operation::Kind::While && function_body[while_op].jump != branch_op)
--while_op;
function_body.erase(std::cbegin(function_body) + while_op);
if (condition_ival == 0)
remap(while_op, branch_op, 1);
}
break;
case Operation::Kind::If:
{
auto const end_or_else = branch.jump-1;
auto const else_op = end_or_else;
auto const end = function_body[end_or_else].kind == Operation::Kind::Else ? function_body[end_or_else].jump-1 : end_or_else;
if (condition.ival != 0) {
// Do `if` has else branch? If yes, remove it. Otherwise remove unnesesary end operation
if (end != else_op) {
function_body.erase(std::cbegin(function_body) + else_op, std::cbegin(function_body) + end + 2);
remap(end, -1, end - else_op + 1);
} else {
function_body.erase(std::cbegin(function_body) + else_op);
remap(end, -1, 1);
}
remap(branch_op, end_or_else, 2); // `if` and condition
function_body.erase(std::cbegin(function_body) + condition_op, std::cbegin(function_body) + branch_op + 1);
verbose(branch.token, "Optimizing always then `if` (conditions is always true)");
} else {
// Do `if` has else branch? If yes, remove `end` operation from it
if (end != else_op) {
function_body.erase(std::cbegin(function_body) + end + 1);
}
// remove then branch and condition
function_body.erase(std::cbegin(function_body) + condition_op, std::cbegin(function_body) + else_op + 1);
remap(end_or_else, -1, 3 + (end_or_else != end));
verbose(branch.token, "Optimizing always else `if` (condition is always false)");
}
}
break;
default:
unreachable("We check earlier for possible values");
}
branch_op -= 1;
}
return done_something;
}
void optimize(Generation_Info &geninfo)
{
while (remove_unused_words_and_strings(geninfo)
|| for_all_functions(geninfo, optimize_comptime_known_conditions))
{
}
}
}
| 37.447059 | 137 | 0.672636 | RobertBendun |
83e79f66ac0b12fe1bae71bf032824027513d05e | 7,371 | cpp | C++ | src/openms/source/ANALYSIS/MAPMATCHING/TransformationModel.cpp | liangoaix/OpenMS | cccbc5d872320f197091596db275f35b4d0458cd | [
"Zlib",
"Apache-2.0"
] | null | null | null | src/openms/source/ANALYSIS/MAPMATCHING/TransformationModel.cpp | liangoaix/OpenMS | cccbc5d872320f197091596db275f35b4d0458cd | [
"Zlib",
"Apache-2.0"
] | null | null | null | src/openms/source/ANALYSIS/MAPMATCHING/TransformationModel.cpp | liangoaix/OpenMS | cccbc5d872320f197091596db275f35b4d0458cd | [
"Zlib",
"Apache-2.0"
] | null | null | null | // --------------------------------------------------------------------------
// OpenMS -- Open-Source Mass Spectrometry
// --------------------------------------------------------------------------
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
//
// This software is released under a three-clause BSD license:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of any author or any participating institution
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
// For a full list of authors, refer to the file AUTHORS.
// --------------------------------------------------------------------------
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// --------------------------------------------------------------------------
// $Maintainer: $
// $Authors: Hendrik Weisser $
// --------------------------------------------------------------------------
#include <OpenMS/ANALYSIS/MAPMATCHING/TransformationModel.h>
#include <OpenMS/MATH/STATISTICS/StatisticFunctions.h>
#include <OpenMS/CONCEPT/LogStream.h>
#include <OpenMS/DATASTRUCTURES/ListUtils.h>
#include "Wm5Vector2.h"
#include "Wm5ApprLineFit2.h"
#include <algorithm>
#include <numeric>
#include <iterator>
using namespace std;
namespace OpenMS
{
TransformationModelLinear::TransformationModelLinear(
const TransformationModel::DataPoints& data, const Param& params)
{
params_ = params;
data_given_ = !data.empty();
if (!data_given_ && params.exists("slope") && (params.exists("intercept")))
{
// don't estimate parameters, use given values
slope_ = params.getValue("slope");
intercept_ = params.getValue("intercept");
}
else // estimate parameters from data
{
Param defaults;
getDefaultParameters(defaults);
params_.setDefaults(defaults);
symmetric_ = params_.getValue("symmetric_regression") == "true";
size_t size = data.size();
std::vector<Wm5::Vector2d> points;
if (size == 0) // no data
{
throw Exception::IllegalArgument(__FILE__, __LINE__, __PRETTY_FUNCTION__,
"no data points for 'linear' model");
}
else if (size == 1) // degenerate case, but we can still do something
{
slope_ = 1.0;
intercept_ = data[0].second - data[0].first;
}
else // compute least-squares fit
{
for (size_t i = 0; i < size; ++i)
{
points.push_back(Wm5::Vector2d(data.at(i).first, data.at(i).second));
}
if (!Wm5::HeightLineFit2<double>(size, &points.front(), slope_, intercept_))
throw std::runtime_error("could not fit");
}
}
}
TransformationModelLinear::~TransformationModelLinear()
{
}
double TransformationModelLinear::evaluate(const double value) const
{
return slope_ * value + intercept_;
}
void TransformationModelLinear::invert()
{
if (slope_ == 0)
throw Exception::DivisionByZero(__FILE__, __LINE__,
__PRETTY_FUNCTION__);
intercept_ = -intercept_ / slope_;
slope_ = 1.0 / slope_;
// update parameters:
if (params_.exists("slope") && (params_.exists("intercept")))
{
params_.setValue("slope", slope_, params_.getDescription("slope"));
params_.setValue("intercept", intercept_,
params_.getDescription("intercept"));
}
}
void TransformationModelLinear::getParameters(double& slope,
double& intercept) const
{
slope = slope_;
intercept = intercept_;
}
void TransformationModelLinear::getDefaultParameters(Param& params)
{
params.clear();
params.setValue("symmetric_regression", "false", "Perform linear regression"
" on 'y - x' vs. 'y + x', instead of on 'y' vs. 'x'.");
params.setValidStrings("symmetric_regression",
ListUtils::create<String>("true,false"));
}
TransformationModelInterpolated::TransformationModelInterpolated(
const TransformationModel::DataPoints& data, const Param& params)
{
params_ = params;
Param defaults;
getDefaultParameters(defaults);
params_.setDefaults(defaults);
// need monotonically increasing x values (can't have the same value twice):
map<double, vector<double> > mapping;
for (TransformationModel::DataPoints::const_iterator it = data.begin();
it != data.end(); ++it)
{
mapping[it->first].push_back(it->second);
}
x_.resize(mapping.size());
y_.resize(mapping.size());
size_t i = 0;
for (map<double, vector<double> >::const_iterator it =
mapping.begin(); it != mapping.end(); ++it, ++i)
{
x_[i] = it->first;
// use average y value:
y_[i] = accumulate(it->second.begin(), it->second.end(), 0.0) /
it->second.size();
}
if (x_.size() < 3)
{
throw Exception::IllegalArgument(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Cubic spline model needs at least 3 data points (with unique x values)");
}
interp_ = new Spline2d<double>(3, x_, y_);
// linear model for extrapolation:
TransformationModel::DataPoints lm_data(2);
lm_data[0] = make_pair(x_.front(), y_.front());
lm_data[1] = make_pair(x_.back(), y_.back());
lm_ = new TransformationModelLinear(lm_data, Param());
}
TransformationModelInterpolated::~TransformationModelInterpolated()
{
delete interp_;
delete lm_;
}
double TransformationModelInterpolated::evaluate(const double value)
const
{
if ((value < x_.front()) || (value > x_.back())) // extrapolate
{
return lm_->evaluate(value);
}
// interpolate:
return interp_->eval(value);
}
void TransformationModelInterpolated::getDefaultParameters(Param& params)
{
params.clear();
params.setValue("interpolation_type", "cspline",
"Type of interpolation to apply.");
StringList types = ListUtils::create<String>("linear,polynomial,cspline,akima");
params.setValidStrings("interpolation_type", types);
}
}
| 36.671642 | 154 | 0.625017 | liangoaix |
83e942a3070b9a42cce922527ab8e45882cc245a | 774 | hpp | C++ | libs/fnd/units/include/bksge/fnd/units/luminance.hpp | myoukaku/bksge | 0f8b60e475a3f1709723906e4796b5e60decf06e | [
"MIT"
] | 4 | 2018-06-10T13:35:32.000Z | 2021-06-03T14:27:41.000Z | libs/fnd/units/include/bksge/fnd/units/luminance.hpp | myoukaku/bksge | 0f8b60e475a3f1709723906e4796b5e60decf06e | [
"MIT"
] | 566 | 2017-01-31T05:36:09.000Z | 2022-02-09T05:04:37.000Z | libs/fnd/units/include/bksge/fnd/units/luminance.hpp | myoukaku/bksge | 0f8b60e475a3f1709723906e4796b5e60decf06e | [
"MIT"
] | 1 | 2018-07-05T04:40:53.000Z | 2018-07-05T04:40:53.000Z | /**
* @file luminance.hpp
*
* @brief luminance の定義
*
* @author myoukaku
*/
#ifndef BKSGE_FND_UNITS_LUMINANCE_HPP
#define BKSGE_FND_UNITS_LUMINANCE_HPP
#include <bksge/fnd/units/candela.hpp>
#include <bksge/fnd/units/metre.hpp>
namespace bksge
{
namespace units
{
// カンデラ毎平方メートル(輝度の単位)
template <typename T> using candela_per_square_metre = decltype(candela<T>() / metre<T>() / metre<T>());
template <typename T> using candelas_per_square_metre = candela_per_square_metre<T>;
template <typename T> using candela_per_square_meter = candela_per_square_metre<T>;
template <typename T> using candelas_per_square_meter = candela_per_square_metre<T>;
} // namespace units
} // namespace bksge
#endif // BKSGE_FND_UNITS_LUMINANCE_HPP
| 24.1875 | 106 | 0.736434 | myoukaku |
83ea7200763af9ed99e49f10e502767a9429f83e | 562 | tpp | C++ | src/algorithms/rem_factorial.tpp | adienes/remainder-tree | 0aa76214ab6f2a4389ec45a239ea660749989a90 | [
"MIT"
] | null | null | null | src/algorithms/rem_factorial.tpp | adienes/remainder-tree | 0aa76214ab6f2a4389ec45a239ea660749989a90 | [
"MIT"
] | null | null | null | src/algorithms/rem_factorial.tpp | adienes/remainder-tree | 0aa76214ab6f2a4389ec45a239ea660749989a90 | [
"MIT"
] | null | null | null | #include "intermediate_computation.hpp"
#include "utils.hpp"
#include <NTL/ZZ_pX.h>
#include <NTL/matrix.h>
#include "../elements/element.hpp"
template <typename T, typename U>
T calculate_factorial(long n, const U& m, const std::function<std::vector<T> (long, long)>& get_A, const PolyMatrix& formula) {
// return compute_product_node<T, U>(get_A(0, n), m, 1);
if (n == 0) {
return T(1)%m;
}
(void)formula; //just to silence unused variable warning
return compute_product_node<T,U>(get_A(0,n), m, 1);
}
//#include "rem_factorial_custom.tpp"
| 24.434783 | 127 | 0.690391 | adienes |
83eec4770542a055d63bb60ca0403230a41a7179 | 496 | cpp | C++ | platforms/gfg/0141_minimum_number_deletions_make_sorted_sequence.cpp | idfumg/algorithms | 06f85c5a1d07a965df44219b5a6bf0d43a129256 | [
"MIT"
] | 2 | 2020-09-17T09:04:00.000Z | 2020-11-20T19:43:18.000Z | platforms/gfg/0141_minimum_number_deletions_make_sorted_sequence.cpp | idfumg/algorithms | 06f85c5a1d07a965df44219b5a6bf0d43a129256 | [
"MIT"
] | null | null | null | platforms/gfg/0141_minimum_number_deletions_make_sorted_sequence.cpp | idfumg/algorithms | 06f85c5a1d07a965df44219b5a6bf0d43a129256 | [
"MIT"
] | null | null | null | #include "../../template.hpp"
int tab(vi& arr) {
int n = arr.size(), maxi = 0;
vi dp(n, 1);
for (int i = 1; i < n; ++i) {
for (int j = 0; j < i; ++j) {
dp[i] = max(dp[i], (arr[i] > arr[j]) * dp[j] + 1);
}
maxi = max(maxi, dp[i]);
}
return n - maxi;
}
int main() { TimeMeasure _; __x();
vi arr1 = {5, 6, 1, 7, 4};
vi arr2 = {30, 40, 2, 5, 1, 7, 45, 50, 8};
cout << tab(arr1) << endl; // 2
cout << tab(arr2) << endl; // 4
}
| 23.619048 | 62 | 0.409274 | idfumg |
83ef47cb67d5d2858e9270db4657e948d7c23a43 | 4,676 | cpp | C++ | applications/RANSApplication/tests/cpp/test_incompressible_potential_flow_elements.cpp | Rodrigo-Flo/Kratos | f718cae5d1618e9c0e7ed1da9e95b7a853e62b1b | [
"BSD-4-Clause"
] | null | null | null | applications/RANSApplication/tests/cpp/test_incompressible_potential_flow_elements.cpp | Rodrigo-Flo/Kratos | f718cae5d1618e9c0e7ed1da9e95b7a853e62b1b | [
"BSD-4-Clause"
] | null | null | null | applications/RANSApplication/tests/cpp/test_incompressible_potential_flow_elements.cpp | Rodrigo-Flo/Kratos | f718cae5d1618e9c0e7ed1da9e95b7a853e62b1b | [
"BSD-4-Clause"
] | null | null | null | // | / |
// ' / __| _` | __| _ \ __|
// . \ | ( | | ( |\__ `
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Suneth Warnakulasuriya
//
// System includes
// External includes
// Project includes
#include "containers/model.h"
#include "testing/testing.h"
// Application includes
#include "custom_utilities/test_utilities.h"
#include "includes/cfd_variables.h"
#include "rans_application_variables.h"
namespace Kratos
{
namespace Testing
{
namespace
{
ModelPart& RansIncompressiblePotentialFlowVelocity2D3NSetUp(
Model& rModel)
{
const auto add_variables_function = [](ModelPart& rModelPart) {
rModelPart.AddNodalSolutionStepVariable(VELOCITY_POTENTIAL);
};
using namespace RansApplicationTestUtilities;
auto& r_model_part = CreateScalarVariableTestModelPart(
rModel, "RansIncompressiblePotentialFlowVelocity2D3N",
"LineCondition2D2N", add_variables_function, VELOCITY_POTENTIAL, 1);
// set nodal historical variables
RandomFillNodalHistoricalVariable(r_model_part, VELOCITY_POTENTIAL, -10.0, 10.0);
return r_model_part;
}
} // namespace
KRATOS_TEST_CASE_IN_SUITE(RansIncompressiblePotentialFlowVelocity2D3N_EquationIdVector, KratosRansFastSuite)
{
// Setup:
Model model;
auto& r_model_part = RansIncompressiblePotentialFlowVelocity2D3NSetUp(model);
// Test:
RansApplicationTestUtilities::TestEquationIdVector<ModelPart::ElementsContainerType>(r_model_part);
}
KRATOS_TEST_CASE_IN_SUITE(RansIncompressiblePotentialFlowVelocity2D3N_GetDofList, KratosRansFastSuite)
{
// Setup:
Model model;
auto& r_model_part = RansIncompressiblePotentialFlowVelocity2D3NSetUp(model);
// Test:
RansApplicationTestUtilities::TestGetDofList<ModelPart::ElementsContainerType>(
r_model_part, VELOCITY_POTENTIAL);
}
KRATOS_TEST_CASE_IN_SUITE(RansIncompressiblePotentialFlowVelocity2D3N_CalculateLocalSystem,
KratosRansFastSuite)
{
// Setup:
Model model;
auto& r_model_part = RansIncompressiblePotentialFlowVelocity2D3NSetUp(model);
// Test:
Matrix LHS, ref_LHS(3, 3, 0.0);
Vector RHS, ref_RHS(3);
auto& r_element = r_model_part.Elements().front();
r_element.CalculateLocalSystem(
LHS, RHS, static_cast<const ProcessInfo&>(r_model_part.GetProcessInfo()));
// setting reference values
ref_RHS[0] = -5.1041666666666670e+00;
ref_RHS[1] = 1.2165570175438596e+01;
ref_RHS[2] = -7.0614035087719298e+00;
ref_LHS(0, 0) = 5.0000000000000000e-01;
ref_LHS(0, 1) = -5.0000000000000000e-01;
ref_LHS(1, 0) = -5.0000000000000000e-01;
ref_LHS(1, 1) = 1.0000000000000000e+00;
ref_LHS(1, 2) = -5.0000000000000000e-01;
ref_LHS(2, 1) = -5.0000000000000000e-01;
ref_LHS(2, 2) = 5.0000000000000000e-01;
KRATOS_CHECK_VECTOR_NEAR(RHS, ref_RHS, 1e-12);
KRATOS_CHECK_MATRIX_NEAR(LHS, ref_LHS, 1e-12);
}
KRATOS_TEST_CASE_IN_SUITE(RansIncompressiblePotentialFlowVelocity2D3N_CalculateLeftHandSide,
KratosRansFastSuite)
{
// Setup:
Model model;
auto& r_model_part = RansIncompressiblePotentialFlowVelocity2D3NSetUp(model);
// Test:
Matrix LHS, ref_LHS(3, 3, 0.0);
auto& r_element = r_model_part.Elements().front();
r_element.CalculateLeftHandSide(
LHS, static_cast<const ProcessInfo&>(r_model_part.GetProcessInfo()));
// setting reference values
ref_LHS(0, 0) = 5.0000000000000000e-01;
ref_LHS(0, 1) = -5.0000000000000000e-01;
ref_LHS(1, 0) = -5.0000000000000000e-01;
ref_LHS(1, 1) = 1.0000000000000000e+00;
ref_LHS(1, 2) = -5.0000000000000000e-01;
ref_LHS(2, 1) = -5.0000000000000000e-01;
ref_LHS(2, 2) = 5.0000000000000000e-01;
KRATOS_CHECK_MATRIX_NEAR(LHS, ref_LHS, 1e-12);
}
KRATOS_TEST_CASE_IN_SUITE(RansIncompressiblePotentialFlowVelocity2D3N_CalculateRightHandSide,
KratosRansFastSuite)
{
// Setup:
Model model;
auto& r_model_part = RansIncompressiblePotentialFlowVelocity2D3NSetUp(model);
// Test:
Vector RHS, ref_RHS(3);
auto& r_element = r_model_part.Elements().front();
r_element.CalculateRightHandSide(
RHS, static_cast<const ProcessInfo&>(r_model_part.GetProcessInfo()));
// setting reference values
ref_RHS[0] = -5.1041666666666670e+00;
ref_RHS[1] = 1.2165570175438596e+01;
ref_RHS[2] = -7.0614035087719298e+00;
KRATOS_CHECK_VECTOR_NEAR(RHS, ref_RHS, 1e-12);
}
} // namespace Testing
} // namespace Kratos.
| 30.763158 | 108 | 0.705731 | Rodrigo-Flo |
83f0d45d0ba843ab8068a5b4a75942ed18d3f1d4 | 979 | cpp | C++ | lib/IR/Compute/Constant.cpp | LiuLeif/onnc | 3f69e46172a9c33cc04541ff7fd78d5d7b6bdbba | [
"BSD-3-Clause"
] | 450 | 2018-08-03T08:17:03.000Z | 2022-03-17T17:21:06.000Z | lib/IR/Compute/Constant.cpp | LiuLeif/onnc | 3f69e46172a9c33cc04541ff7fd78d5d7b6bdbba | [
"BSD-3-Clause"
] | 104 | 2018-08-13T07:31:50.000Z | 2021-08-24T11:24:40.000Z | lib/IR/Compute/Constant.cpp | LiuLeif/onnc | 3f69e46172a9c33cc04541ff7fd78d5d7b6bdbba | [
"BSD-3-Clause"
] | 100 | 2018-08-12T04:27:39.000Z | 2022-03-11T04:17:42.000Z | //===- Constant.cpp -------------------------------------------------------===//
//
// The ONNC Project
//
// See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <onnc/IR/Compute/Constant.h>
using namespace onnc;
char Constant::ID = 0;
//===----------------------------------------------------------------------===//
// Constant
//===----------------------------------------------------------------------===//
Constant::Constant(const TensorAttr& pValue)
: ComputeOperator("Constant", ID),
m_Value(pValue) {
}
Constant::Constant(const Constant& pCopy)
: ComputeOperator(pCopy) /* shallow copy */,
m_Value(pCopy.getValue()) {
}
void Constant::printAttributes(std::ostream& pOS) const
{
pOS << '<' << "value: " << getValue()<< '>';
}
bool Constant::classof(const ComputeOperator* pOp)
{
if (nullptr == pOp)
return false;
return (pOp->getID() == &ID);
}
| 24.475 | 80 | 0.429009 | LiuLeif |
83f1bbda5b6d73285b93073a25e76de4ca321814 | 15,696 | cpp | C++ | examples/laikago_opengl_example.cpp | sgillen/tiny-differentiable-simulator | 142f3b9e9b7e042c9298bc83ebbc08a9df7527af | [
"Apache-2.0"
] | 862 | 2020-05-14T19:22:27.000Z | 2022-03-20T20:23:24.000Z | examples/laikago_opengl_example.cpp | sgillen/tiny-differentiable-simulator | 142f3b9e9b7e042c9298bc83ebbc08a9df7527af | [
"Apache-2.0"
] | 82 | 2020-05-26T11:41:33.000Z | 2022-03-15T16:46:00.000Z | examples/laikago_opengl_example.cpp | sgillen/tiny-differentiable-simulator | 142f3b9e9b7e042c9298bc83ebbc08a9df7527af | [
"Apache-2.0"
] | 93 | 2020-05-15T05:37:59.000Z | 2022-03-03T09:09:50.000Z | // Copyright 2020 Google LLC
//
// 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 <chrono>
#include <fstream>
#include <iostream>
#include <streambuf>
#include <string>
#include <thread>
std::string LAIKAGO_URDF_NAME="laikago/laikago_toes_zup_chassis_collision.urdf";
//std::string LAIKAGO_URDF_NAME="laikago/laikago_toes_zup.urdf";
//#include "meshcat_urdf_visualizer.h"
#include "opengl_urdf_visualizer.h"
#include "math/tiny/tiny_double_utils.h"
#include "utils/file_utils.hpp"
#include "urdf/urdf_parser.hpp"
#include "urdf/urdf_to_multi_body.hpp"
#include "dynamics/forward_dynamics.hpp"
#include "dynamics/integrator.hpp"
#include "urdf/urdf_cache.hpp"
#include "tiny_visual_instance_generator.h"
using namespace tds;
using namespace TINY;
#include "math/tiny/tiny_algebra.hpp"
#ifdef USE_TINY
typedef double TinyDualScalar;
typedef double MyScalar;
typedef ::TINY::DoubleUtils MyTinyConstants;
typedef TinyVector3<double, DoubleUtils> Vector3;
typedef TinyQuaternion<double, DoubleUtils> Quaternion;
typedef TinyAlgebra<double, MyTinyConstants> MyAlgebra;
#else
#include "math/eigen_algebra.hpp"
typedef EigenAlgebra MyAlgebra;
typedef typename MyAlgebra::Scalar MyScalar;
typedef typename MyAlgebra::Vector3 Vector3;
typedef typename MyAlgebra::Quaternion Quarternion;
typedef typename MyAlgebra::VectorX VectorX;
typedef typename MyAlgebra::Matrix3 Matrix3;
typedef typename MyAlgebra::Matrix3X Matrix3X;
typedef typename MyAlgebra::MatrixX MatrixX;
#endif
#ifdef _DEBUG
int frameskip_gfx_sync = 1; // don't skip, we are debugging
#else
int frameskip_gfx_sync = 10; // only sync every 10 frames (sim at 1000 Hz, gfx at ~60hz)
#endif
bool do_sim = true;
TinyKeyboardCallback prev_keyboard_callback = 0;
void my_keyboard_callback(int keycode, int state)
{
if (keycode == 's')
do_sim = state;
prev_keyboard_callback(keycode, state);
}
double knee_angle = -0.5;
double abduction_angle = 0.2;
double initial_poses[] = {
abduction_angle, 0., knee_angle, abduction_angle, 0., knee_angle,
abduction_angle, 0., knee_angle, abduction_angle, 0., knee_angle,
};
template <typename Algebra>
struct LaikagoSimulation {
using Scalar = typename Algebra::Scalar;
tds::UrdfCache<Algebra> cache;
std::string m_urdf_filename;
tds::World<Algebra> world;
tds::MultiBody<Algebra>* system = nullptr;
int num_timesteps{ 1 };
Scalar dt{ Algebra::from_double(1e-3) };
int input_dim() const { return system->dof() + system->dof_qd(); }
int state_dim() const {
return system->dof() + system->dof_qd() + system->num_links() * 7;
}
int output_dim() const { return num_timesteps * state_dim(); }
LaikagoSimulation() {
std::string plane_filename;
tds::FileUtils::find_file("plane_implicit.urdf", plane_filename);
cache.construct(plane_filename, world, false, false);
tds::FileUtils::find_file(LAIKAGO_URDF_NAME, m_urdf_filename);
system = cache.construct(m_urdf_filename, world, false, true);
system->base_X_world().translation = Algebra::unit3_z();
}
std::vector<Scalar> operator()(const std::vector<Scalar>& v) {
assert(static_cast<int>(v.size()) == input_dim());
system->initialize();
//copy input into q, qd
for (int i = 0; i < system->dof(); ++i) {
system->q(i) = v[i];
}
for (int i = 0; i < system->dof_qd(); ++i) {
system->qd(i) = v[i + system->dof()];
}
std::vector<Scalar> result(output_dim());
for (int t = 0; t < num_timesteps; ++t) {
#if 1
// pd control
if (1) {
// use PD controller to compute tau
int qd_offset = system->is_floating() ? 6 : 0;
int q_offset = system->is_floating() ? 7 : 0;
int num_targets = system->tau_.size() - qd_offset;
std::vector<double> q_targets;
q_targets.resize(system->tau_.size());
Scalar kp = 150;
Scalar kd = 3;
Scalar max_force = 550;
int param_index = 0;
for (int i = 0; i < system->tau_.size(); i++) {
system->tau_[i] = 0;
}
int tau_index = 0;
int pose_index = 0;
for (int i = 0; i < system->links_.size(); i++) {
if (system->links_[i].joint_type != tds::JOINT_FIXED) {
Scalar q_desired = initial_poses[pose_index++];
Scalar q_actual = system->q_[q_offset];
Scalar qd_actual = system->qd_[qd_offset];
Scalar position_error = (q_desired - q_actual);
Scalar desired_velocity = 0;
Scalar velocity_error = (desired_velocity - qd_actual);
Scalar force = kp * position_error + kd * velocity_error;
force = Algebra::max(force, -max_force);
force = Algebra::min(force, max_force);
system->tau_[tau_index] = force;
q_offset++;
qd_offset++;
param_index++;
tau_index++;
}
}
}
#endif
tds::forward_dynamics(*system, world.get_gravity());
system->clear_forces();
integrate_euler_qdd(*system, dt);
world.step(dt);
tds::integrate_euler(*system, dt);
//copy q, qd, link world poses (for rendering) to output
int j = 0;
for (int i = 0; i < system->dof(); ++i, ++j) {
result[j] = system->q(i);
}
for (int i = 0; i < system->dof_qd(); ++i, ++j) {
result[j] = system->qd(i);
}
for (const auto link : *system) {
if (link.X_visuals.size())
{
tds::Transform visual_X_world = link.X_world * link.X_visuals[0];
result[j++] = visual_X_world.translation[0];
result[j++] = visual_X_world.translation[1];
result[j++] = visual_X_world.translation[2];
auto orn = Algebra::matrix_to_quat(visual_X_world.rotation);
result[j++] = orn.x();
result[j++] = orn.y();
result[j++] = orn.z();
result[j++] = orn.w();
}
else
{
//check if we have links without visuals
assert(0);
j += 7;
}
}
}
return result;
}
};
int main(int argc, char* argv[]) {
int sync_counter = 0;
int frame = 0;
UrdfParser<MyAlgebra> parser;
// create graphics
OpenGLUrdfVisualizer<MyAlgebra> visualizer;
visualizer.delete_all();
LaikagoSimulation<MyAlgebra> contact_sim;
int input_dim = contact_sim.input_dim();
std::vector<MyAlgebra::Scalar> prep_inputs;
std::vector<MyAlgebra::Scalar> prep_outputs;
prep_inputs.resize(input_dim);
//quaternion 'w' = 1
prep_inputs[3] = 1;
//start height at 0.7
prep_inputs[6] = 0.7;
//int sphere_shape = visualizer.m_opengl_app.register_graphics_unit_sphere_shape(SPHERE_LOD_LOW);
{
std::vector<int> shape_ids;
std::string plane_filename;
FileUtils::find_file("plane100.obj", plane_filename);
TinyVector3f pos(0, 0, 0);
TinyQuaternionf orn(0, 0, 0, 1);
TinyVector3f scaling(1, 1, 1);
visualizer.load_obj(plane_filename, pos, orn, scaling, shape_ids);
}
//int sphere_shape = shape_ids[0];
//TinyVector3f color = colors[0];
// typedef tds::Conversion<DiffAlgebra, tds::TinyAlgebraf> Conversion;
bool create_instances = false;
char search_path[TINY_MAX_EXE_PATH_LEN];
std::string texture_path = "";
std::string file_and_path;
tds::FileUtils::find_file(LAIKAGO_URDF_NAME, file_and_path);
auto urdf_structures = contact_sim.cache.retrieve(file_and_path);// contact_sim.m_urdf_filename);
FileUtils::extract_path(file_and_path.c_str(), search_path,
TINY_MAX_EXE_PATH_LEN);
visualizer.m_path_prefix = search_path;
visualizer.convert_visuals(urdf_structures, texture_path);
int num_total_threads = 10;
std::vector<int> visual_instances;
std::vector<int> num_instances;
int num_base_instances = 0;
for (int t = 0;t< num_total_threads;t++)
{
TinyVector3f pos(0, 0, 0);
TinyQuaternionf orn(0, 0, 0, 1);
TinyVector3f scaling(1, 1, 1);
int uid = urdf_structures.base_links[0].urdf_visual_shapes[0].visual_shape_uid;
OpenGLUrdfVisualizer<MyAlgebra>::TinyVisualLinkInfo& vis_link = visualizer.m_b2vis[uid];
int instance = -1;
int num_instances_per_link = 0;
for (int v = 0; v < vis_link.visual_shape_uids.size(); v++)
{
int sphere_shape = vis_link.visual_shape_uids[v];
::TINY::TinyVector3f color(1, 1, 1);
//visualizer.m_b2vis
instance = visualizer.m_opengl_app.m_renderer->register_graphics_instance(
sphere_shape, pos, orn, color, scaling);
visual_instances.push_back(instance);
num_instances_per_link++;
contact_sim.system->visual_instance_uids().push_back(instance);
}
num_base_instances = num_instances_per_link;
for (int i = 0; i < contact_sim.system->num_links(); ++i) {
int uid = urdf_structures.links[i].urdf_visual_shapes[0].visual_shape_uid;
OpenGLUrdfVisualizer<MyAlgebra>::TinyVisualLinkInfo& vis_link = visualizer.m_b2vis[uid];
int instance = -1;
int num_instances_per_link = 0;
for (int v = 0; v < vis_link.visual_shape_uids.size(); v++)
{
int sphere_shape = vis_link.visual_shape_uids[v];
::TINY::TinyVector3f color(1, 1, 1);
//visualizer.m_b2vis
instance = visualizer.m_opengl_app.m_renderer->register_graphics_instance(
sphere_shape, pos, orn, color, scaling);
visual_instances.push_back(instance);
num_instances_per_link++;
contact_sim.system->links_[i].visual_instance_uids.push_back(instance);
}
num_instances.push_back(num_instances_per_link);
}
}
//app.m_renderer->write_single_instance_transform_to_cpu(pos, orn, sphereId);
std::vector<std::vector<MyScalar>> parallel_outputs(
num_total_threads, std::vector<MyScalar>(contact_sim.output_dim()));
std::vector<std::vector<MyScalar>> parallel_inputs(num_total_threads);
for (int i = 0; i < num_total_threads; ++i) {
//auto quat = MyAlgebra::quat_from_euler_rpy(MyAlgebra::Vector3(0.5,1.3,i*0.3));
auto quat = MyAlgebra::quat_from_euler_rpy(MyAlgebra::Vector3(0,0,i*0.3));
parallel_inputs[i] = std::vector<MyScalar>(contact_sim.input_dim(), MyScalar(0));
parallel_inputs[i][0] = quat.x();
parallel_inputs[i][1] = quat.y();
parallel_inputs[i][2] = quat.z();
parallel_inputs[i][3] = quat.w();
//start height at 0.7
parallel_inputs[i][6] = 0.7;
}
while (!visualizer.m_opengl_app.m_window->requested_exit()) {
for (int i = 0; i < num_total_threads; ++i) {
parallel_outputs[i] = contact_sim(parallel_inputs[i]);
for (int j = 0; j < contact_sim.input_dim(); ++j) {
parallel_inputs[i][j] = parallel_outputs[i][j];
}
}
sync_counter++;
frame += 1;
if (sync_counter > frameskip_gfx_sync) {
sync_counter = 0;
if (1) {
bool manual_sync = false;
if (manual_sync)
{
//visualizer.sync_visual_transforms(contact_sim.system);
}
else
{
float sim_spacing = 2;
const int square_id = (int)std::sqrt((double)num_total_threads);
int instance_index = 0;
int offset = contact_sim.system->dof() + contact_sim.system->dof_qd();
for (int s = 0; s < num_total_threads; s++)
{
for (int v = 0; v < num_base_instances; v++)
{
int visual_instance_id = visual_instances[instance_index++];
if (visual_instance_id >= 0)
{
::TINY::TinyVector3f pos(parallel_outputs[s][4 + 0],
parallel_outputs[s][4 + 1],
parallel_outputs[s][4 + 2]);
::TINY::TinyQuaternionf orn(parallel_outputs[s][0],
parallel_outputs[s][1],
parallel_outputs[s][2],
parallel_outputs[s][3]);
pos[0] += sim_spacing * (s % square_id) - square_id * sim_spacing / 2;
pos[1] += sim_spacing * (s / square_id) - square_id * sim_spacing / 2;
visualizer.m_opengl_app.m_renderer->write_single_instance_transform_to_cpu(pos, orn, visual_instance_id);
}
}
for (int l = 0; l < contact_sim.system->links_.size(); l++) {
for (int v = 0; v < num_instances[l]; v++)
{
int visual_instance_id = visual_instances[instance_index++];
if (visual_instance_id >= 0)
{
::TINY::TinyVector3f pos(parallel_outputs[s][offset + l * 7 + 0],
parallel_outputs[s][offset + l * 7 + 1],
parallel_outputs[s][offset + l * 7 + 2]);
::TINY::TinyQuaternionf orn(parallel_outputs[s][offset + l * 7 + 3],
parallel_outputs[s][offset + l * 7 + 4],
parallel_outputs[s][offset + l * 7 + 5],
parallel_outputs[s][offset + l * 7 + 6]);
pos[0] += sim_spacing * (s % square_id) - square_id * sim_spacing / 2;
pos[1] += sim_spacing * (s / square_id) - square_id * sim_spacing / 2;
visualizer.m_opengl_app.m_renderer->write_single_instance_transform_to_cpu(pos, orn, visual_instance_id);
}
}
}
}
}
}
visualizer.render();
//std::this_thread::sleep_for(std::chrono::duration<double>(frameskip_gfx_sync* contact_sim.dt));
}
}
printf("finished\n");
return EXIT_SUCCESS;
}
| 36.417633 | 139 | 0.56696 | sgillen |
83f847fa7fe4024bdecfb4935a3d5009c54a99bd | 2,398 | cpp | C++ | code/source/visual/model.cpp | crafn/clover | 586acdbcdb34c3550858af125e9bb4a6300343fe | [
"MIT"
] | 12 | 2015-01-12T00:19:20.000Z | 2021-08-05T10:47:20.000Z | code/source/visual/model.cpp | crafn/clover | 586acdbcdb34c3550858af125e9bb4a6300343fe | [
"MIT"
] | null | null | null | code/source/visual/model.cpp | crafn/clover | 586acdbcdb34c3550858af125e9bb4a6300343fe | [
"MIT"
] | null | null | null | #include "global/env.hpp"
#include "model.hpp"
#include "resources/cache.hpp"
#include "visual/material.hpp"
#include "visual/mesh.hpp"
namespace clover {
namespace visual {
Model::Model():
material(0),
mesh(0),
INIT_RESOURCE_ATTRIBUTE(nameAttribute, "name", ""),
INIT_RESOURCE_ATTRIBUTE(materialAttribute, "material", ""),
INIT_RESOURCE_ATTRIBUTE(meshAttribute, "mesh", ""){
materialAttribute.setOnChangeCallback([=] (){
if (materialAttribute.get().empty())
material= 0;
else
material= &global::g_env.resCache->getResource<visual::Material>(materialAttribute.get());
});
meshAttribute.setOnChangeCallback([=] (){
if (meshAttribute.get().empty())
mesh= 0;
else
mesh= &global::g_env.resCache->getResource<visual::TriMesh>(meshAttribute.get());
});
}
void Model::setMaterial(const util::Str8& name){
material= &global::g_env.resCache->getResource<visual::Material>(name);
}
void Model::setMesh(const BaseMesh& m){
mesh= &m;
}
void Model::setMesh(const util::Str8& name){
mesh= &global::g_env.resCache->getResource<visual::TriMesh>(name);
}
util::BoundingBox<util::Vec3f> Model::getBoundingBox() const {
if(!mesh)
return util::BoundingBox<util::Vec3f>();
return mesh->getBoundingBox();
}
void Model::resourceUpdate(bool load, bool force){
materialChangeListener.clear();
meshChangeListener.clear();
if (load || getResourceState() == State::Uninit){
material= &global::g_env.resCache->getResource<Material>(materialAttribute.get());
mesh= &global::g_env.resCache->getResource<TriMesh>(meshAttribute.get());
materialChangeListener.listen(*material, [=] (){ util::OnChangeCb::trigger(); });
const visual::TriMesh* trimesh= dynamic_cast<const visual::TriMesh*>(mesh);
if (trimesh)
meshChangeListener.listen(*trimesh, [=] (){ util::OnChangeCb::trigger(); });
setResourceState(State::Loaded);
}
else {
setResourceState(State::Unloaded);
}
}
void Model::createErrorResource(){
setResourceState(State::Error);
material= &global::g_env.resCache->getErrorResource<Material>();
mesh= &global::g_env.resCache->getErrorResource<TriMesh>();
}
uint32 Model::getContentHash() const {
if (!mesh || !material)
return 0;
else
return getBatchCompatibilityHash() + mesh->getContentHash();
}
uint32 Model::getBatchCompatibilityHash() const {
return material ? material->getContentHash() : 0;
}
} // visual
} // clover
| 26.065217 | 93 | 0.711843 | crafn |
83fbbad58034f4b910dff971d6f581e666fca7c1 | 7,883 | cpp | C++ | code_reading/oceanbase-master/src/observer/virtual_table/ob_tenant_show_tables.cpp | wangcy6/weekly_read | 3a8837ee9cd957787ee1785e4066dd623e02e13a | [
"Apache-2.0"
] | null | null | null | code_reading/oceanbase-master/src/observer/virtual_table/ob_tenant_show_tables.cpp | wangcy6/weekly_read | 3a8837ee9cd957787ee1785e4066dd623e02e13a | [
"Apache-2.0"
] | null | null | null | code_reading/oceanbase-master/src/observer/virtual_table/ob_tenant_show_tables.cpp | wangcy6/weekly_read | 3a8837ee9cd957787ee1785e4066dd623e02e13a | [
"Apache-2.0"
] | 1 | 2020-10-18T12:59:31.000Z | 2020-10-18T12:59:31.000Z | /**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#include "observer/virtual_table/ob_tenant_show_tables.h"
#include "lib/mysqlclient/ob_mysql_proxy.h"
#include "share/schema/ob_schema_getter_guard.h"
#include "sql/session/ob_sql_session_info.h"
using namespace oceanbase::common;
using namespace oceanbase::share;
using namespace oceanbase::share::schema;
namespace oceanbase {
namespace observer {
ObTenantShowTables::ObTenantShowTables()
: ObVirtualTableIterator(),
tenant_id_(OB_INVALID_ID),
database_id_(OB_INVALID_ID),
table_schemas_(),
table_schema_idx_(0)
{}
ObTenantShowTables::~ObTenantShowTables()
{}
int ObTenantShowTables::inner_open()
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(NULL == schema_guard_ || OB_INVALID_ID == tenant_id_ || NULL == allocator_)) {
ret = OB_NOT_INIT;
SERVER_LOG(WARN, "data member doesn't init", K(ret), K(schema_guard_), K(tenant_id_), K(allocator_));
} else {
// get database_id
ObRowkey start_key;
ObRowkey end_key;
for (int64_t i = 0; OB_SUCC(ret) && !is_valid_id(database_id_) && i < key_ranges_.count(); ++i) {
start_key.reset();
end_key.reset();
start_key = key_ranges_.at(i).start_key_;
end_key = key_ranges_.at(i).end_key_;
const ObObj* start_key_obj_ptr = start_key.get_obj_ptr();
const ObObj* end_key_obj_ptr = end_key.get_obj_ptr();
if (start_key.get_obj_cnt() > 0 && start_key.get_obj_cnt() == end_key.get_obj_cnt()) {
if (OB_UNLIKELY(NULL == start_key_obj_ptr || NULL == end_key_obj_ptr)) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(ERROR, "key obj ptr is NULL", K(ret), K(start_key_obj_ptr), K(end_key_obj_ptr));
} else if (start_key_obj_ptr[0] == end_key_obj_ptr[0] && ObIntType == start_key_obj_ptr[0].get_type()) {
database_id_ = start_key_obj_ptr[0].get_int();
}
}
}
if (OB_SUCC(ret)) {
if (OB_UNLIKELY(!is_valid_id(database_id_))) {
// FIXME: we should find a better way to handle this in the future
ret = OB_ERR_UNEXPECTED;
LOG_USER_ERROR(OB_ERR_UNEXPECTED, "this table is used for show clause, can't be selected");
} else {
if (OB_FAIL(schema_guard_->get_table_schemas_in_database(tenant_id_, database_id_, table_schemas_))) {
SERVER_LOG(WARN, "fail to get table schemas in database", K(ret), K(tenant_id_), K(database_id_));
}
}
}
}
return ret;
}
void ObTenantShowTables::reset()
{
session_ = NULL;
tenant_id_ = OB_INVALID_ID;
database_id_ = OB_INVALID_ID;
table_schemas_.reset();
table_schema_idx_ = 0;
ObVirtualTableIterator::reset();
}
int ObTenantShowTables::inner_get_next_row(common::ObNewRow*& row)
{
int ret = OB_SUCCESS;
if (OB_FAIL(inner_get_next_row())) {
if (OB_ITER_END != ret) {
SERVER_LOG(WARN, "fail to get next row", K(ret), K(cur_row_));
}
} else {
row = &cur_row_;
}
return ret;
}
int ObTenantShowTables::inner_get_next_row()
{
int ret = OB_SUCCESS;
const ObSimpleTableSchemaV2* table_schema = NULL;
ObObj* cells = NULL;
const int64_t col_count = output_column_ids_.count();
ObString database_name;
if (OB_UNLIKELY(NULL == allocator_ || NULL == schema_guard_ || NULL == session_ ||
NULL == (cells = cur_row_.cells_) || !is_valid_id(tenant_id_) || !is_valid_id(database_id_))) {
ret = OB_NOT_INIT;
SERVER_LOG(WARN,
"data member dosen't init",
K(ret),
K(allocator_),
K(schema_guard_),
K(session_),
K(cells),
K(tenant_id_),
K(database_id_));
} else {
const ObDatabaseSchema* db_schema = NULL;
if (OB_FAIL(schema_guard_->get_database_schema(database_id_, db_schema))) {
SERVER_LOG(WARN, "Failed to get database schema", K(ret));
} else if (OB_ISNULL(db_schema)) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN, "db_schema should not be null", K(ret), K_(database_id));
} else {
database_name = db_schema->get_database_name_str();
bool is_allow = false;
ObSessionPrivInfo priv_info;
do {
is_allow = true;
if (OB_UNLIKELY(table_schema_idx_ < 0)) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN, "invalid table_schema_idx_", K(ret), K(table_schema_idx_));
} else if (table_schema_idx_ >= table_schemas_.count()) {
ret = OB_ITER_END;
table_schema_idx_ = 0;
} else {
if (OB_ISNULL(table_schema = table_schemas_.at(table_schema_idx_))) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN, "table schema is NULL", K(ret), K(table_schema_idx_), K(tenant_id_), K(database_id_));
} else if (table_schema->is_dropped_schema()) {
// skip
} else {
uint64_t cell_idx = 0;
for (int64_t j = 0; OB_SUCC(ret) && j < col_count; ++j) {
uint64_t col_id = output_column_ids_.at(j);
switch (col_id) {
case DATABASE_ID: {
cells[cell_idx].set_int(database_id_);
break;
}
case TABLE_NAME: {
cells[cell_idx].set_varchar(table_schema->get_table_name_str());
cells[cell_idx].set_collation_type(
ObCharset::get_default_collation(ObCharset::get_default_charset()));
break;
}
case TABLE_TYPE: {
if (OB_MYSQL_SCHEMA_ID == extract_pure_id(table_schema->get_database_id())) {
cells[cell_idx].set_varchar(ObString::make_string("BASE TABLE"));
} else {
cells[cell_idx].set_varchar(
ObString::make_string(ob_mysql_table_type_str(table_schema->get_table_type())));
}
cells[cell_idx].set_collation_type(
ObCharset::get_default_collation(ObCharset::get_default_charset()));
break;
}
default: {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN, "invalid column id", K(ret), K(cell_idx), K(j), K(output_column_ids_), K(col_id));
break;
}
}
if (OB_SUCC(ret)) {
cell_idx++;
}
}
if (OB_SUCC(ret)) {
// skip table that is neither normal table, system table nor view table
if (!table_schema->is_user_table() && !table_schema->is_sys_table() && !table_schema->is_view_table() &&
OB_INFORMATION_SCHEMA_ID != extract_pure_id(table_schema->get_database_id()) &&
OB_MYSQL_SCHEMA_ID != extract_pure_id(table_schema->get_database_id())) {
is_allow = false;
} else {
priv_info.reset();
session_->get_session_priv_info(priv_info);
if (OB_FAIL(schema_guard_->check_table_show(
priv_info, database_name, table_schema->get_table_name_str(), is_allow))) {
SERVER_LOG(WARN, "check show table priv failed", K(ret));
}
}
}
}
table_schema_idx_++;
}
} while (!is_allow && OB_SUCCESS == ret);
}
}
return ret;
}
} // namespace observer
} // namespace oceanbase
| 38.453659 | 118 | 0.611189 | wangcy6 |
83fcd2d527818526288762d92bd540fac0a5db71 | 2,116 | cpp | C++ | src/asynclock/asynclock.cpp | Damdoshi/LibLapin | 800e0f17ed8f3c47797c48feea4c280bb0e4bdc9 | [
"BSD-3-Clause"
] | 38 | 2016-07-30T09:35:19.000Z | 2022-03-04T10:13:48.000Z | src/asynclock/asynclock.cpp | Elania-Marvers/LibLapin | 800e0f17ed8f3c47797c48feea4c280bb0e4bdc9 | [
"BSD-3-Clause"
] | 15 | 2017-02-12T19:20:52.000Z | 2021-06-09T09:30:52.000Z | src/asynclock/asynclock.cpp | Elania-Marvers/LibLapin | 800e0f17ed8f3c47797c48feea4c280bb0e4bdc9 | [
"BSD-3-Clause"
] | 12 | 2016-10-06T09:06:59.000Z | 2022-03-04T10:14:00.000Z | // Jason Brillante "Damdoshi"
// Hanged Bunny Studio 2014-2018
//
// Lapin library
#include "lapin_private.h"
static int remove_dead_trap(struct bunny_trap **trap,
t_bunny_call_order order)
{
struct bunny_trap *lst;
struct bunny_trap *nxt;
int cnt;
cnt = 0;
for (lst = *trap; lst != NULL; )
if (lst->remove_it)
{
nxt = lst->next;
__bunny_delete_trap(lst, order);
lst = nxt;
}
else
{
cnt += 1;
lst = lst->next;
}
return (cnt);
}
static void asyncall(double elapsed,
struct bunny_trap *lst,
double now)
{
// Call the function between time A and B
if (lst->duration > 0.001)
{
if (lst->start_time < now && lst->start_time + lst->duration > now)
lst->func(elapsed, (t_bunny_trap*)lst, lst->param);
else if (lst->start_time + lst->duration < now)
lst->remove_it = true;
}
// Call the function every duration -seconds
else if (lst->duration < -0.001)
{
if (lst->start_time < now && lst->start_time - lst->duration > now)
{
lst->func(elapsed, (t_bunny_trap*)lst, lst->param);
lst->start_time -= lst->duration;
}
else if (lst->start_time - lst->duration < now)
lst->start_time -= lst->duration;
}
// Call the function one single time at start_time
else
{
if (lst->start_time > now - elapsed &&
lst->start_time <= now)
{
lst->func(elapsed, (t_bunny_trap*)lst, lst->param);
lst->remove_it = true;
}
}
}
static int asynclock(double elapsed,
struct bunny_trap **trap,
t_bunny_call_order order)
{
struct bunny_trap *lst;
double now;
now = bunny_get_current_time();
for (lst = *trap; lst != NULL; lst = lst->next)
if (lst->start_time > 0)
asyncall(elapsed, lst, now);
else if (lst == *trap)
asyncall(elapsed, lst, now);
return (remove_dead_trap(trap, order));
}
int bunny_asynclock(double elapsed,
t_bunny_call_order order)
{
if (order == BCO_BEFORE_LOOP_MAIN_FUNCTION)
return (asynclock(elapsed, &gl_bunny_trap_head[0], order));
return (asynclock(elapsed, &gl_bunny_trap_head[2], order));
}
| 23.511111 | 73 | 0.628544 | Damdoshi |
86057acac80e6b3404e3ddfc8c6e42b5d1840db2 | 2,608 | cpp | C++ | apps/oskar_convert_geodetic_to_ecef_main.cpp | i4Ds/OSKAR | 70bab06fd63729608420e29dc18512c954126bf0 | [
"BSD-3-Clause"
] | 46 | 2015-12-15T14:24:16.000Z | 2022-01-24T16:54:49.000Z | apps/oskar_convert_geodetic_to_ecef_main.cpp | i4Ds/OSKAR | 70bab06fd63729608420e29dc18512c954126bf0 | [
"BSD-3-Clause"
] | 37 | 2016-08-04T17:53:03.000Z | 2022-03-10T10:22:01.000Z | apps/oskar_convert_geodetic_to_ecef_main.cpp | i4Ds/OSKAR | 70bab06fd63729608420e29dc18512c954126bf0 | [
"BSD-3-Clause"
] | 32 | 2016-05-09T10:30:11.000Z | 2022-01-26T07:55:27.000Z | /*
* Copyright (c) 2015-2021, The OSKAR Developers.
* See the LICENSE file at the top-level directory of this distribution.
*/
#include "convert/oskar_convert_geodetic_spherical_to_ecef.h"
#include "log/oskar_log.h"
#include "math/oskar_cmath.h"
#include "mem/oskar_mem.h"
#include "settings/oskar_option_parser.h"
#include "utility/oskar_get_error_string.h"
#include "utility/oskar_version_string.h"
#include <cstdio>
#include <cstdlib>
#include <string>
int main(int argc, char** argv)
{
int status = 0;
oskar::OptionParser opt("oskar_convert_geodetic_to_ecef",
oskar_version_string());
opt.set_description("Converts geodetic longitude/latitude/altitude to "
"Cartesian ECEF coordinates. Assumes WGS84 ellipsoid.");
opt.add_required("input file", "Path to file containing input coordinates. "
"Angles must be in degrees.");
if (!opt.check_options(argc, argv)) return EXIT_FAILURE;
const char* filename = opt.get_arg();
// Load the input file.
oskar_Mem *lon = oskar_mem_create(OSKAR_DOUBLE, OSKAR_CPU, 0, &status);
oskar_Mem *lat = oskar_mem_create(OSKAR_DOUBLE, OSKAR_CPU, 0, &status);
oskar_Mem *alt = oskar_mem_create(OSKAR_DOUBLE, OSKAR_CPU, 0, &status);
size_t num_points = oskar_mem_load_ascii(filename, 3, &status,
lon, "", lat, "", alt, "0.0");
oskar_mem_scale_real(lon, M_PI / 180.0, 0, num_points, &status);
oskar_mem_scale_real(lat, M_PI / 180.0, 0, num_points, &status);
// Convert coordinates.
oskar_Mem *x = oskar_mem_create(OSKAR_DOUBLE, OSKAR_CPU,
num_points, &status);
oskar_Mem *y = oskar_mem_create(OSKAR_DOUBLE, OSKAR_CPU,
num_points, &status);
oskar_Mem *z = oskar_mem_create(OSKAR_DOUBLE, OSKAR_CPU,
num_points, &status);
oskar_convert_geodetic_spherical_to_ecef((int)num_points,
oskar_mem_double_const(lon, &status),
oskar_mem_double_const(lat, &status),
oskar_mem_double_const(alt, &status),
oskar_mem_double(x, &status),
oskar_mem_double(y, &status),
oskar_mem_double(z, &status));
// Print converted coordinates.
oskar_mem_save_ascii(stdout, 3, 0, num_points, &status, x, y, z);
// Clean up.
oskar_mem_free(lon, &status);
oskar_mem_free(lat, &status);
oskar_mem_free(alt, &status);
oskar_mem_free(x, &status);
oskar_mem_free(y, &status);
oskar_mem_free(z, &status);
if (status)
{
oskar_log_error(0, oskar_get_error_string(status));
}
return status ? EXIT_FAILURE : EXIT_SUCCESS;
}
| 36.732394 | 80 | 0.682899 | i4Ds |
860912780dafac7e599e64c1bdc2b78ef10a30f6 | 245 | cpp | C++ | libxmlrip/porting.cpp | gazzyt/xmlrip | 32f25cb0729a91c7c1a7f211b0490b72e4c8b741 | [
"MIT"
] | 1 | 2020-04-19T18:55:06.000Z | 2020-04-19T18:55:06.000Z | libxmlrip/porting.cpp | gazzyt/xmlrip | 32f25cb0729a91c7c1a7f211b0490b72e4c8b741 | [
"MIT"
] | null | null | null | libxmlrip/porting.cpp | gazzyt/xmlrip | 32f25cb0729a91c7c1a7f211b0490b72e4c8b741 | [
"MIT"
] | null | null | null | #include "porting.h"
#ifdef WIN32
#include <stdio.h>
#else
#include <unistd.h>
#endif // WIN32
using namespace std;
int Porting::StdOutFileNo()
{
#ifdef WIN32
return _fileno(stdout);
#else
return STDOUT_FILENO;
#endif // WIN32
}
| 12.25 | 27 | 0.681633 | gazzyt |
86095945974baa5f69a7b38ae4c98482661e19a7 | 3,512 | cxx | C++ | main/ucb/source/ucp/file/filcmd.cxx | Grosskopf/openoffice | 93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7 | [
"Apache-2.0"
] | 679 | 2015-01-06T06:34:58.000Z | 2022-03-30T01:06:03.000Z | main/ucb/source/ucp/file/filcmd.cxx | Grosskopf/openoffice | 93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7 | [
"Apache-2.0"
] | 102 | 2017-11-07T08:51:31.000Z | 2022-03-17T12:13:49.000Z | main/ucb/source/ucp/file/filcmd.cxx | Grosskopf/openoffice | 93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7 | [
"Apache-2.0"
] | 331 | 2015-01-06T11:40:55.000Z | 2022-03-14T04:07:51.000Z | /**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*
*************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_file.hxx"
#include "filcmd.hxx"
#include "shell.hxx"
#include "prov.hxx"
using namespace fileaccess;
using namespace com::sun::star;
using namespace com::sun::star::ucb;
XCommandInfo_impl::XCommandInfo_impl( shell* pMyShell )
: m_pMyShell( pMyShell ),
m_xProvider( pMyShell->m_pProvider )
{
}
XCommandInfo_impl::~XCommandInfo_impl()
{
}
void SAL_CALL
XCommandInfo_impl::acquire(
void )
throw()
{
OWeakObject::acquire();
}
void SAL_CALL
XCommandInfo_impl::release(
void )
throw()
{
OWeakObject::release();
}
uno::Any SAL_CALL
XCommandInfo_impl::queryInterface(
const uno::Type& rType )
throw( uno::RuntimeException )
{
uno::Any aRet = cppu::queryInterface( rType,
SAL_STATIC_CAST( XCommandInfo*,this) );
return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
}
uno::Sequence< CommandInfo > SAL_CALL
XCommandInfo_impl::getCommands(
void )
throw( uno::RuntimeException )
{
return m_pMyShell->m_sCommandInfo;
}
CommandInfo SAL_CALL
XCommandInfo_impl::getCommandInfoByName(
const rtl::OUString& aName )
throw( UnsupportedCommandException,
uno::RuntimeException)
{
for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); i++ )
if( m_pMyShell->m_sCommandInfo[i].Name == aName )
return m_pMyShell->m_sCommandInfo[i];
throw UnsupportedCommandException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
CommandInfo SAL_CALL
XCommandInfo_impl::getCommandInfoByHandle(
sal_Int32 Handle )
throw( UnsupportedCommandException,
uno::RuntimeException )
{
for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); ++i )
if( m_pMyShell->m_sCommandInfo[i].Handle == Handle )
return m_pMyShell->m_sCommandInfo[i];
throw UnsupportedCommandException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
sal_Bool SAL_CALL
XCommandInfo_impl::hasCommandByName(
const rtl::OUString& aName )
throw( uno::RuntimeException )
{
for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); ++i )
if( m_pMyShell->m_sCommandInfo[i].Name == aName )
return true;
return false;
}
sal_Bool SAL_CALL
XCommandInfo_impl::hasCommandByHandle(
sal_Int32 Handle )
throw( uno::RuntimeException )
{
for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); ++i )
if( m_pMyShell->m_sCommandInfo[i].Handle == Handle )
return true;
return false;
}
| 25.449275 | 140 | 0.707859 | Grosskopf |
860e1cc06467099493d564854fe7a31e7945a20d | 20,277 | cpp | C++ | src/idocr.cpp | najlepsiwebdesigner/opencv-lab | 397711129c675958c3d612a8213b53b74e909702 | [
"Unlicense"
] | null | null | null | src/idocr.cpp | najlepsiwebdesigner/opencv-lab | 397711129c675958c3d612a8213b53b74e909702 | [
"Unlicense"
] | null | null | null | src/idocr.cpp | najlepsiwebdesigner/opencv-lab | 397711129c675958c3d612a8213b53b74e909702 | [
"Unlicense"
] | null | null | null | #include "idocr.h"
using namespace cv;
using namespace std;
string idOCR::cutoutPath = "";
idOCR::idOCR()
{
tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
}
idOCR::~idOCR()
{
}
void idOCR::saveImage(string fileName, const Mat & image){
if (fileName.length() < 1) return;
imwrite(fileName, image);
cout << "File saved!" << endl;
}
void idOCR::fitImage(const Mat& src,Mat& dst, float destWidth, float destHeight) {
int srcWidth = src.cols;
int srcHeight = src.rows;
float srcRatio = (float) srcWidth / (float) srcHeight;
float widthRatio = destWidth / srcWidth;
float heightRatio = destHeight / srcHeight;
float newWidth = 0;
float newHeight = 0;
if (srcWidth > srcHeight) {
destHeight = destWidth / srcRatio;
} else {
destWidth = destHeight * srcRatio;
}
cv::resize(src, dst,Size((int)round(destWidth), (int)round(destHeight)),0,0);
}
void idOCR::process(Mat & image) {
// for id filtering, we need only small version of image
Mat image_vga(Size(640,480),CV_8UC3,Scalar(0));
fitImage(image, image_vga, 640, 480);
Mat image_big(Size(1920,1440),CV_8UC3,Scalar(0));
fitImage(image, image_big, 1920, 1440);
Mat image_vga_backup = image_vga.clone();
// filtering
cv::GaussianBlur(image_vga, image_vga, Size( 7, 7) ,7,7);
Mat small;
cv::resize(image_vga, small,Size(320,240),0,0);
cv::medianBlur(small, small, 9);
cv::resize(small, image_vga, Size(image_vga.cols,image_vga.rows));
cv::resize(image_vga, small,Size(320,240),0,0);
cv::medianBlur(small, small, 9);
cv::resize(small, image_vga, Size(image_vga.cols,image_vga.rows));
cv::Mat const shape = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(5, 5));
cv::dilate(image_vga, image_vga, Mat(), Point(-1, -1), 3, 1, 1);
cv::erode(image_vga, image_vga, shape, Point(-1,-1), 1);
cv::dilate(image_vga, image_vga, Mat(), Point(-1, -1), 1, 1, 1);
cv::erode(image_vga, image_vga, shape, Point(-1,-1), 1);
cv::dilate(image_vga, image_vga, Mat(), Point(-1, -1), 1, 1, 1);
cv::erode(image_vga, image_vga, shape, Point(-1,-1), 1);
cv::GaussianBlur( image_vga, image_vga, Size(3,3), 0, 0, BORDER_DEFAULT );
// sobel
Mat grad, src_gray;
int scale = 1;
int delta = 0;
int ddepth = CV_16S;
/// Convert it to gray
cvtColor( image_vga, src_gray, COLOR_RGB2GRAY );
/// Generate grad_x and grad_y
Mat grad_x, grad_y;
Mat abs_grad_x, abs_grad_y;
/// Gradient X
//Scharr( src_gray, grad_x, ddepth, 1, 0, scale, delta, BORDER_DEFAULT );
Sobel( src_gray, grad_x, ddepth, 1, 0, 3, scale, delta, BORDER_DEFAULT );
convertScaleAbs( grad_x, abs_grad_x );
/// Gradient Y
//Scharr( src_gray, grad_y, ddepth, 0, 1, scale, delta, BORDER_DEFAULT );
Sobel( src_gray, grad_y, ddepth, 0, 1, 3, scale, delta, BORDER_DEFAULT );
convertScaleAbs( grad_y, abs_grad_y );
/// Total Gradient (approximate)
addWeighted( abs_grad_x, 0.5, abs_grad_y, 0.5, 0, grad );
cvtColor( grad, image_vga, COLOR_GRAY2RGB );
// now threshold
cv::cvtColor(image_vga,image_vga, CV_RGB2GRAY);
cv::threshold(image_vga,image_vga,0,255,THRESH_BINARY + CV_THRESH_OTSU);
cv::dilate(image_vga, image_vga, Mat(), Point(-1, -1), 3, 1, 1);
cv::erode(image_vga, image_vga, shape, Point(-1,-1), 1);
cv::dilate(image_vga, image_vga, Mat(), Point(-1, -1), 1, 1, 1);
cv::erode(image_vga, image_vga, shape, Point(-1,-1), 1);
cv::dilate(image_vga, image_vga, Mat(), Point(-1, -1), 1, 1, 1);
cv::erode(image_vga, image_vga, shape, Point(-1,-1), 1);
// keep only filled biggest contour in the image to get rid of rest of structures inside
int largest_area=0;
int largest_contour_index=0;
vector<vector<Point>> contours;
vector<Vec4i> hierarchy;
findContours( image_vga, contours, hierarchy,CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE ); // Find the contours in the image
for( int i = 0; i< contours.size(); i++ )
{
double a=contourArea( contours[i],false);
if(a>largest_area){
largest_area=a;
largest_contour_index=i;
}
}
Mat temp(Size(image_vga.cols,image_vga.rows),CV_8UC3,Scalar(0));
drawContours( temp, contours,largest_contour_index, Scalar(255,0,0), -1, 8, hierarchy, 0);
image_vga = temp;
cv::Canny(image_vga, image_vga, 30, 90);
cv::dilate(image_vga, image_vga, Mat(), Point(1,-1));
// detect lines in this binary image
std::vector<cv::Vec4i> lines;
cv::HoughLinesP(image_vga, lines, 1, CV_PI/360,50,50, 10);
cvtColor( image_vga, image_vga, COLOR_GRAY2RGB);
// clusterize lines
// define lines around image
std::vector<cv::Vec4i> myLines;
cv::Vec4i leftLine;leftLine[0] = 0;leftLine[1] = 0;leftLine[2] = 0;leftLine[3] = image_vga.rows;
myLines.push_back(leftLine);
cv::Vec4i rightLine;
rightLine[0] = image_vga.cols;rightLine[1] = 0;rightLine[2] = image_vga.cols;rightLine[3] = image_vga.rows;
myLines.push_back(rightLine);
cv::Vec4i topLine;
topLine[0] = image_vga.cols;topLine[1] = 0;topLine[2] = 0;topLine[3] = 0;
myLines.push_back(topLine);
cv::Vec4i bottomLine;
bottomLine[0] = image_vga.cols;bottomLine[1] = image_vga.rows;bottomLine[2] = 0;bottomLine[3] = image_vga.rows;
myLines.push_back(bottomLine);
// expand lines to borders of the image - we will get intersections with image borders easily
for (int i = 0; i < lines.size(); i++)
{
std::vector<cv::Point2f> lineIntersections;
for (int j = 0; j < myLines.size(); j++)
{
cv::Vec4i v = lines[i];
Point2f intersection;
bool has_intersection = idOCR::getIntersectionPoint(
Point(lines[i][0],lines[i][1]),
Point(lines[i][2], lines[i][3]),
Point(myLines[j][0],myLines[j][1]),
Point(myLines[j][2], myLines[j][3]),
intersection);
if (has_intersection
&& intersection.x >= 0
&& intersection.y >= 0
&& intersection.x <= image_vga.cols
&& intersection.y <= image_vga.rows){
lineIntersections.push_back(intersection);
}
}
if (lineIntersections.size() > 0) {
lines[i][0] = lineIntersections[0].x;
lines[i][1] = lineIntersections[0].y;
lines[i][2] = lineIntersections[1].x;
lines[i][3] = lineIntersections[1].y;
}
}
if (lines.size() > 3){
// clusterization params
int distanceThreshold = round(image.cols/15);
double angleThreshold = 0.50;
struct LineCluster {
int sumX1;
int sumY1;
int sumX2;
int sumY2;
int count;
};
vector<LineCluster> clusters;
// create first group
LineCluster cluster;
cluster.sumX1 = lines[0][0];
cluster.sumY1 = lines[0][1];
cluster.sumX2 = lines[0][2];
cluster.sumY2 = lines[0][3];
cluster.count = 1;
clusters.push_back(cluster);
// loop through rest of groups
for (int i = 1; i < lines.size(); i++) {
bool in_some_cluster = false;
for (int j = 0; j < clusters.size(); j++) {
int cluster_x1 = clusters[j].sumX1/clusters[j].count;
int cluster_y1 = clusters[j].sumY1/clusters[j].count;
int cluster_x2 = clusters[j].sumX2/clusters[j].count;
int cluster_y2 = clusters[j].sumY2/clusters[j].count;
double angle1 = atan2((double)lines[i][3] - lines[i][1], (double)lines[i][2] - lines[i][0]);
double angle2 = atan2((double)cluster_y2 - cluster_y1, (double)cluster_x2 - cluster_x1);
float distance_cluster1_to_line1 = sqrt(((cluster_x1 - lines[i][0])*(cluster_x1 - lines[i][0])) + (cluster_y1 - lines[i][1])*(cluster_y1 - lines[i][1]));
float distance_cluster1_to_line2 = sqrt(((cluster_x1 - lines[i][2])*(cluster_x1 - lines[i][2])) + (cluster_y1 - lines[i][3])*(cluster_y1 - lines[i][3]));
float distance_cluster2_to_line1 = sqrt(((cluster_x2 - lines[i][0])*(cluster_x2 - lines[i][0])) + (cluster_y2 - lines[i][1])*(cluster_y2 - lines[i][1]));
float distance_cluster2_to_line2 = sqrt(((cluster_x2 - lines[i][2])*(cluster_x2 - lines[i][2])) + (cluster_y2 - lines[i][3])*(cluster_y2 - lines[i][3]));
if (((distance_cluster1_to_line1 < distanceThreshold) &&
(distance_cluster2_to_line2 < distanceThreshold || abs(angle1 - angle2) < angleThreshold)) ||
((distance_cluster1_to_line2 < distanceThreshold) &&
(distance_cluster2_to_line1 < distanceThreshold || abs(angle1 - angle2) < angleThreshold))){
clusters[j].sumX1 += lines[i][0];
clusters[j].sumY1 += lines[i][1];
clusters[j].sumX2 += lines[i][2];
clusters[j].sumY2 += lines[i][3];
clusters[j].count += 1;
in_some_cluster = true;
}
}
// if point doesnt fit, create new group for it
if (in_some_cluster == false){
LineCluster cluster;
cluster.sumX1 = lines[i][0];
cluster.sumY1 = lines[i][1];
cluster.sumX2 = lines[i][2];
cluster.sumY2 = lines[i][3];
cluster.count = 1;
clusters.push_back(cluster);
}
}
if (clusters.size() == 4) {
std::vector<cv::Vec4i> clusteredLines;
// approx clusters and define clustered lines
for (int i = 0; i < clusters.size(); i++){
circle(image_vga, Point(clusters[i].sumX1/clusters[i].count, clusters[i].sumY1/clusters[i].count), 5, Scalar(0,0,255),-1);
circle(image_vga, Point(clusters[i].sumX2/clusters[i].count, clusters[i].sumY2/clusters[i].count), 5, Scalar(0,0,255),-1);
cv::line(image_vga, Point(clusters[i].sumX1/clusters[i].count, clusters[i].sumY1/clusters[i].count), Point(clusters[i].sumX2/clusters[i].count, clusters[i].sumY2/clusters[i].count), CV_RGB(255,0,0), 1);
cv::Vec4i line;
line[0] = clusters[i].sumX1/clusters[i].count;
line[1] = clusters[i].sumY1/clusters[i].count;
line[2] = clusters[i].sumX2/clusters[i].count;
line[3] = clusters[i].sumY2/clusters[i].count;
clusteredLines.push_back(line);
}
// compute intersections between approximated lines
std::vector<cv::Point2f> corners;
for (int i = 0; i < clusteredLines.size(); i++)
{
for (int j = i+1; j < clusteredLines.size(); j++)
{
cv::Vec4i v = clusteredLines[i];
Point2f intersection;
bool has_intersection = idOCR::getIntersectionPoint(
Point(clusteredLines[i][0],clusteredLines[i][1]),
Point(clusteredLines[i][2], clusteredLines[i][3]),
Point(clusteredLines[j][0],clusteredLines[j][1]),
Point(clusteredLines[j][2], clusteredLines[j][3]),
intersection);
if (has_intersection
&& intersection.x > 0
&& intersection.y > 0
&& intersection.x < image_vga.cols
&& intersection.y < image_vga.rows){
corners.push_back(intersection);
cv::circle(image_vga, intersection, 3, CV_RGB(0,0,255), 2);
}
}
}
if (corners.size() == 4) {
cv::Point2f center(0,0);
for (int i = 0; i < corners.size(); i++) {
center.x += corners[i].x;
center.y += corners[i].y;
}
center *= (1. / corners.size());
for (int i = 0; i < corners.size(); i++) {
cv::circle(image_vga, corners[i], 3, CV_RGB(0,0,255), 2);
}
idOCR::sortCorners(corners, center);
// Define the destination image
cv::Mat quad = cv::Mat::zeros(510, 800, CV_8UC3);
// Corners of the destination image
std::vector<cv::Point2f> quad_pts;
quad_pts.push_back(cv::Point2f(0, 0));
quad_pts.push_back(cv::Point2f(quad.cols, 0));
quad_pts.push_back(cv::Point2f(quad.cols, quad.rows));
quad_pts.push_back(cv::Point2f(0, quad.rows));
double ratio_x = round(static_cast<double>(image_big.cols) / image_vga_backup.cols);
double ratio_y = round(static_cast<double>(image_big.rows) / image_vga_backup.rows);
for (int i = 0; i < corners.size(); i++) {
corners[i].x *= ratio_x;
corners[i].y *= ratio_y;
}
try {
// Get transformation matrix
cv::Mat transmtx = cv::getPerspectiveTransform(corners, quad_pts);
// Apply perspective transformation
cv::warpPerspective(image_big, quad, transmtx, quad.size(),INTER_LINEAR,BORDER_TRANSPARENT);
}
catch (cv::Exception e) {
// qDebug << "error in warp" << endl;
}
cv::Mat newImage = cv::Mat::zeros(600, 800, CV_8UC3);
cv::Mat tempImage = cv::Mat::zeros(600, 800, CV_8UC3);
quad.copyTo(newImage.rowRange(0,quad.rows).colRange(0,quad.cols));
cv::GaussianBlur(newImage, tempImage, cv::Size(0, 0),5);
cv::addWeighted(newImage, 1.5, tempImage, -0.5, 0, newImage);
image = newImage.clone();
return;
}
}
}
double alpha = 0.5; double beta;
beta = ( 1.0 - alpha );
addWeighted(image_vga_backup , alpha, image_vga, beta, 0.0, image_vga);
image = image_vga.clone();
}
bool idOCR::getIntersectionPoint(cv::Point a1, cv::Point a2, cv::Point b1, cv::Point b2, cv::Point2f & intPnt){
Point p = a1;
Point q = b1;
Point r(a2-a1);
Point s(b2-b1);
if(cross(r,s) == 0) {return false;}
double t = cross(q-p,s)/cross(r,s);
intPnt = p + t*r;
return true;
}
double idOCR::cross(Point v1,Point v2){
return v1.x*v2.y - v1.y*v2.x;
}
void idOCR::sortCorners(std::vector<cv::Point2f>& corners,
cv::Point2f center)
{
std::vector<cv::Point2f> top, bot;
for (int i = 0; i < corners.size(); i++)
{
if (corners[i].y < center.y)
top.push_back(corners[i]);
else
bot.push_back(corners[i]);
}
corners.clear();
if (top.size() == 2 && bot.size() == 2){
cv::Point2f tl = top[0].x > top[1].x ? top[1] : top[0];
cv::Point2f tr = top[0].x > top[1].x ? top[0] : top[1];
cv::Point2f bl = bot[0].x > bot[1].x ? bot[1] : bot[0];
cv::Point2f br = bot[0].x > bot[1].x ? bot[0] : bot[1];
corners.push_back(tl);
corners.push_back(tr);
corners.push_back(br);
corners.push_back(bl);
}
}
vector<Rect> idOCR::getRectanglesFromMask(Mat & mask) {
Mat canny;
Mat image_gray;
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
cvtColor( mask, image_gray, CV_RGB2GRAY );
Canny( image_gray, canny, 30, 90);
findContours( canny, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
vector<Rect> boundRect( contours.size() );
for( int i = 0; i< contours.size(); i++ )
{
boundRect[i] = boundingRect( Mat(contours[i]) );
}
return boundRect;
}
void idOCR::maskCutOut(Mat & image, string maskFilename) {
if ( !boost::filesystem::exists( maskFilename ) )
{
std::cout << "Can't find mask file!" << std::endl;
boost::filesystem::path full_path( boost::filesystem::current_path() );
std::cout << "Current path is : " << full_path << std::endl;
return;
}
Mat mask = imread(maskFilename);
fitImage(image, image, 800, 600);
vector<Rect> rectangles = getRectanglesFromMask(mask);
for( int i = 0; i< rectangles.size(); i++ )
{
Mat roi(image, rectangles[i]);
cv::cvtColor(roi,roi, CV_RGB2GRAY);
cv::threshold(roi,roi,0,255,THRESH_BINARY + CV_THRESH_OTSU);
cv::cvtColor(roi,roi, CV_GRAY2RGB);
string path = getCutoutPath();
if (path.length() > 0) {
path = path + "/";
}
processField(roi);
saveImage(path + to_string(i) + ".jpg", roi);
}
double alpha = 0.5; double beta;
beta = ( 1.0 - alpha );
addWeighted(image , alpha, mask, beta, 0.0, image);
}
void idOCR::processField(Mat & image) {
Mat original = image.clone();
cv::Mat const shape = cv::getStructuringElement(
cv::MORPH_RECT, cv::Size(3, 1));
cvtColor(image, image, CV_RGB2GRAY);
cv::erode(image, image, shape);
cv::GaussianBlur(image, image, Size( 5, 5) ,5,5);
Size ksize(200,1);
blur(image, image, ksize,Point(-1,-1) );
// blur(image, image, ksize,Point(-1,-1) );
// blur(image, image, ksize,Point(-1,-1) );
// cv::erode(image, image, shape);
// cv::dilate(image,image,shape);
cv::threshold(image,image,250,255,THRESH_BINARY);
//return;
int largest_area=0;
int largest_contour_index=0;
vector<vector<Point>> contours;
vector<Vec4i> hierarchy;
// invert image
bitwise_not ( image, image );
findContours( image, contours, hierarchy,CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE ); // Find the contours in the image
cvtColor(image, image, CV_GRAY2RGB);
for( int i = 0; i< contours.size(); i++ )
{
double a=contourArea( contours[i],false);
if(a>largest_area){
largest_area=a;
largest_contour_index=i;
}
}
for( int i = 0; i< contours.size(); i++ )
{
if (i == largest_contour_index){
cv::Rect r;
r = boundingRect(contours[i]);
r.width = image.cols;
if (((image.rows - r.y) - r.height) > round(image.rows/2)) {
r.height = image.rows - r.y;
}
if (r.y + r.height > round(image.rows/2)) {
r.y = 0;
r.height = r.height + 2;
}
Mat mask(image.rows, image.cols, CV_8UC1);
mask.setTo(0);
rectangle(mask, r, Scalar(255, 255, 255), -1);
image.setTo(255);
original.copyTo(image, mask);
return;
// imshow("", mask);
}
}
image = original.clone();
}
void idOCR::setCutoutPath(string path) {
cutoutPath = path;
}
string idOCR::getCutoutPath() {
return cutoutPath;
}
| 33.132353 | 218 | 0.532179 | najlepsiwebdesigner |
86137e5b7b498285a0bd2b289263849584c247b2 | 1,545 | hpp | C++ | Source/ImGui DirectX 11 Kiero Hook/cfg.hpp | 1hAck-0/UE4-Cheat-Source-Code | 7686193399158a0daab8ae07332451cc674a33c6 | [
"CC0-1.0"
] | 17 | 2022-01-08T20:26:30.000Z | 2022-03-21T14:09:42.000Z | Source/ImGui DirectX 11 Kiero Hook/cfg.hpp | 1hAck-0/UE4-Cheat-Source-Code | 7686193399158a0daab8ae07332451cc674a33c6 | [
"CC0-1.0"
] | 1 | 2022-01-11T21:53:16.000Z | 2022-02-15T16:33:37.000Z | Source/ImGui DirectX 11 Kiero Hook/cfg.hpp | 1hAck-0/UE4-Cheat-Source-Code | 7686193399158a0daab8ae07332451cc674a33c6 | [
"CC0-1.0"
] | 2 | 2022-01-09T11:12:07.000Z | 2022-01-14T17:27:45.000Z | #include <Windows.h>
struct cfg_Exploits_t
{
bool bInfiniteHealth = false;
bool bInfiniteAmmo = false;
bool bNoSpread = false;
bool bNoClip = false;
USHORT noClipKey = 0;
bool bFlyHack = false;
USHORT flyKey = 0;
bool bSpeedHack = false;
float speed = 3000.f;
bool bSuperJump = false;
float jumpHeight = 500.f;
bool bModGravity = false;
float modGravity = 1.f;
__forceinline cfg_Exploits_t* operator->() { return this; }
};
struct cfg_Triggerbot_t
{
bool bEnabled = false;
USHORT key = 'F';
bool bDelay = false;
int delayMode = 0;
int customDelay = 100; // in ms
int minRanDelay = 100; // in ms
int maxRanDelay = 300; // in ms
__forceinline cfg_Triggerbot_t* operator->() { return this; }
};
struct cfg_Aimbot_t
{
bool bEnabled = false;
float smoothness = 1.f;
bool bVisibleOnly = true;
bool bFOV = true;
int FOV = 150;
bool bFOVCircle = true;
USHORT aimKey = 'J';
bool bSilentAim = false;
__forceinline cfg_Aimbot_t* operator->() { return this; }
};
struct cfg_ESP_t
{
bool bBoxes = false;
int boxType = 0;
bool bSnaplines = false;
bool bSkeleton = false;
__forceinline cfg_ESP_t* operator->() { return this; }
};
struct cfg_Menu_t
{
bool bInit = false;
bool bShowMenu = true;
bool bShutdown = false;
USHORT ToggleKey = VK_F1;
__forceinline cfg_Menu_t* operator->() { return this; }
};
struct cfg_t
{
cfg_Menu_t menu;
cfg_ESP_t esp;
cfg_Aimbot_t aimbot;
cfg_Triggerbot_t trg;
cfg_Exploits_t exploit;
__forceinline cfg_t* operator->() { return this; }
};
inline cfg_t cfg;
| 16.612903 | 62 | 0.697087 | 1hAck-0 |
8613a2b81fe12ed11027efc280867acab4e4a2dd | 51,987 | cpp | C++ | android/android_9/frameworks/ml/nn/runtime/test/TestPartitioningRandom.cpp | yakuizhao/intel-vaapi-driver | b2bb0383352694941826543a171b557efac2219b | [
"MIT"
] | null | null | null | android/android_9/frameworks/ml/nn/runtime/test/TestPartitioningRandom.cpp | yakuizhao/intel-vaapi-driver | b2bb0383352694941826543a171b557efac2219b | [
"MIT"
] | null | null | null | android/android_9/frameworks/ml/nn/runtime/test/TestPartitioningRandom.cpp | yakuizhao/intel-vaapi-driver | b2bb0383352694941826543a171b557efac2219b | [
"MIT"
] | null | null | null | /*
* Copyright (C) 2017 The Android Open Source Project
*
* 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.
*/
#undef NDEBUG
#include "Bridge.h"
#include "CompilationBuilder.h"
#include "Manager.h"
#include "ModelBuilder.h"
#include "NeuralNetworks.h"
#include "NeuralNetworksWrapper.h"
#include "SampleDriver.h"
#include "Utils.h"
#include "ValidateHal.h"
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <random>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
#include <unistd.h>
#include <android-base/logging.h>
#include <android/sharedmem.h>
#include <gtest/gtest.h>
// Uncomment the following line to generate some debugging output that
// may be useful when analyzing failures:
//
// #define VERBOSE VERBOSE
// Uncomment the following line to generate graphs from models:
//
// #define GRAPH GRAPH
// We randomly generate tests (model + input data) at runtime, and verify
// that we get the same results whether we do partitioned compilation/execution
// or non partitioned compilation/execution. We perform a test as follows:
//
// (1) Randomly generate a model (graph and weights), randomly generate input
// data, randomly assign inputs and outputs to CPU memory or to shared
// memory.
//
// Randomly leaves dimensions unset for intermediate operands.
//
// (2) Randomly generate drivers based on the sample driver, each of which
// executes models on the CPU. They differ according to which operations
// they support.
//
// (3) Compile and execute without partitioning, saving off the results.
//
// (4) Compile and execute with partitioning.
//
// (5) Verify that the saved results from (3) match the results from (4).
//
// For simplicity, all data (model inputs, model outputs, weights,
// temps) are of the same type: a 2-D TENSOR_FLOAT32 where the two
// dimensions are fixed throughout a particular test case (and
// randomly determined). This prevents us from having to find a
// mechanism to "resize" data (e.g., if ADD#a operates on data of size
// 2x2, ADD#b operates on data of size 3x3, and the outputs of ADD#a
// and ADD#b become inputs of ADD#c, do we need to insert one or more
// operations between (say) ADD#a and ADD#c to convert ADD#2's data
// from size 2x2 to size 3x3 in order to match ADD#b). In the few
// cases where an operand cannot be of this type, it is a constant
// (e.g., activation functions and RNN bias).
//
// Each operation we generate has a signature (described in more
// detail later). The randomly generated drivers decide which
// operations they can execute by checking operation signatures. Once
// we have built the model and know the set of signatures, we randomly
// assign each signature to a driver. No signature is supported by
// multiple drivers -- we're not testing the logic that the
// partitioning algorithm uses to select the best driver for an
// operation.
namespace android {
using CompilationBuilder = nn::CompilationBuilder;
using Device = nn::Device;
using DeviceManager = nn::DeviceManager;
using ExecutionPlan = nn::ExecutionPlan;
using HidlModel = hardware::neuralnetworks::V1_1::Model;
using MemoryBuilder = nn::Memory;
using ModelBuilder = nn::ModelBuilder;
using Result = nn::wrapper::Result;
using SampleDriver = nn::sample_driver::SampleDriver;
using WrapperCompilation = nn::wrapper::Compilation;
using WrapperExecution = nn::wrapper::Execution;
using WrapperMemory = nn::wrapper::Memory;
using WrapperModel = nn::wrapper::Model;
using WrapperOperandType = nn::wrapper::OperandType;
using WrapperType = nn::wrapper::Type;
namespace {
/// Configure test size //////////////////////////////////////////////////////////
// We may exceed this in order to connect otherwise disjoint subgraphs.
static const unsigned kMaxNumOperations = 100;
// We build models to process 2-D square tensors up to this size in each dimension;
// note that the API promotes by-value weights larger than 128 to by-reference,
// so we want to ensure that we can pick both types that exceed and types that do
// not exceed this size.
static const unsigned kMaxProblemSize = 8;
// First seed for pseudorandom test generation.
static const unsigned kFirstSeed = 0;
// Number of test cases.
static const unsigned kNumTestCases = 225;
// Force all graph weights into a single pool (as we recommend to users)
// or allow them to be distributed across multiple pools (more stress
// on the partitioning algorithm and the rest of the runtime)?
// Forcing all graph weights into a single pool may be necessary to
// prevent large graphs from running up against http://b/70302693
// "NNAPI overuses (?) fds".
static const bool kAllWeightsInOnePool = false;
//////////////////////////////////////////////////////////////////////////////////
// The signature of an operation consists of the operation type (e.g.,
// ADD) and the activation function (use -1 in the case of an
// operation type for which the activation function is inapplicable).
typedef std::pair<ANeuralNetworksOperationType, int> Signature;
// This class adds some simple utilities on top of
// ::android::nn::wrapper::Model. For example, it provides access to
// certain features from ModelBuilder that are not exposed by the base
// class (such as inputCount() and operation index).
class TestModel : public WrapperModel {
public:
uint32_t addOperation(ANeuralNetworksOperationType type, const std::vector<uint32_t>& inputs,
const std::vector<uint32_t>& outputs) {
const uint32_t operationIndex = operationCount();
mOperations.push_back(outputs);
WrapperModel::addOperation(type, inputs, outputs);
return operationIndex;
}
uint32_t operationCount() const {
return mOperations.size();
}
uint32_t inputCount() const {
return builder()->inputCount();
}
uint32_t outputCount() const {
return builder()->outputCount();
}
const std::vector<uint32_t>& getOperationOutputs(uint32_t index) const {
assert(index < mOperations.size());
return mOperations[index];
}
// All values are immediately copied into the model (we need to do
// this ourselves in cases where the underlying NNAPI does not).
void setOperandValue(uint32_t index, const std::vector<float>& value) {
const size_t length = value.size() * sizeof(float);
if (length <= ANEURALNETWORKS_MAX_SIZE_OF_IMMEDIATELY_COPIED_VALUES) {
WrapperModel::setOperandValue(index, value.data(), length);
} else {
mOperandValues.push_back(value);
WrapperModel::setOperandValue(index, mOperandValues.back().data(), length);
}
}
void setOperandValue(uint32_t index, int32_t value) {
assert(sizeof(value) <= ANEURALNETWORKS_MAX_SIZE_OF_IMMEDIATELY_COPIED_VALUES);
WrapperModel::setOperandValue(index, &value, sizeof(value));
}
private:
const ModelBuilder* builder() const {
return reinterpret_cast<const ModelBuilder*>(getHandle());
}
// Representation of operations: vector index is operation number,
// vector value is operation's output operands.
std::vector<std::vector<uint32_t>> mOperations;
// Large operand values -- not immediately copied into the
// WrapperModel, so remembered here instead.
std::vector<std::vector<float>> mOperandValues;
};
// This class adds some simple utilities on top of
// ::android::nn::wrapper::Compilation in order to provide access to
// certain features from CompilationBuilder that are not exposed by
// the base class.
class TestCompilation : public WrapperCompilation {
public:
TestCompilation(const WrapperModel* model) : WrapperCompilation(model) {}
Result setPartitioning(uint32_t partitioning) {
return static_cast<Result>(builder()->setPartitioning(partitioning));
}
using WrapperCompilation::finish;
Result finish(const std::vector<std::shared_ptr<Device>>& devices) {
return static_cast<Result>(builder()->finish(devices));
}
const ExecutionPlan& getExecutionPlan() const {
return builder()->forTest_getExecutionPlan();
}
private:
const CompilationBuilder* builder() const {
return reinterpret_cast<const CompilationBuilder*>(getHandle());
}
CompilationBuilder* builder() {
return reinterpret_cast<CompilationBuilder*>(getHandle());
}
};
// This class is used to manage a collection of memory regions,
// disjoint windows onto a set of Memory instances, each of which is
// associated with a single shared memory region. Each region and
// Memory instance is assigned a number. The usage pattern is as
// follows:
// - Call addMemory() and addRegion() as many times as needed to
// declare (but not define) Memory instances and declare region
// instances.
// - Call layout() to define the Memory instances.
// - Call getRegion() as many times as needed to get the details
// of memory regions (such as address, or Memory/offset/length).
// The Memory instances created by layout() are owned by the
// TestMemories instance, and are destroyed when the TestMemories
// instance is destroyed.
class TestMemories {
public:
TestMemories() = default;
~TestMemories();
TestMemories(const TestMemories&) = delete;
TestMemories& operator=(const TestMemories&) = delete;
unsigned addMemory() {
assert(!mLayoutDone);
mMemorySizes.push_back(0);
return memoryCount() - 1;
}
unsigned memoryCount() const {
return mMemorySizes.size();
}
unsigned addRegion(unsigned memoryIndex, uint32_t length) {
assert(!mLayoutDone);
assert(memoryIndex < memoryCount());
uint32_t& memorySize = mMemorySizes[memoryIndex];
auto desc = std::make_tuple(memoryIndex, (uint32_t)memorySize, length);
mRegions.push_back(desc);
memorySize += length;
return regionCount() - 1;
}
unsigned regionCount() const {
return mRegions.size();
}
void layout();
void* getRegion(unsigned regionIndex,
const WrapperMemory** pMemory, uint32_t* pOffset, uint32_t* pLength) {
assert(mLayoutDone);
assert(regionIndex < regionCount());
const auto& regionDescriptor = mRegions[regionIndex];
const WrapperMemory* memory = &mMemorys[std::get<0>(regionDescriptor)];
uint32_t offset = std::get<1>(regionDescriptor);
uint32_t length = std::get<2>(regionDescriptor);
uint8_t* buffer;
if (reinterpret_cast<MemoryBuilder*>(memory->get())->getPointer(&buffer) !=
ANEURALNETWORKS_NO_ERROR) {
assert(0);
}
if (pMemory) *pMemory = memory;
if (pOffset) *pOffset = offset;
if (pLength) *pLength = length;
return buffer + offset;
}
void* getRegion(unsigned regionIndex) {
return getRegion(regionIndex, nullptr, nullptr, nullptr);
}
private:
// Index is the memory index; value is the size of the memory
// (aggregate size of all regions in the memory).
std::vector<uint32_t> mMemorySizes;
// Index is the memory index.
std::vector<WrapperMemory> mMemorys;
std::vector<int> mFDs;
// Index is the region index; tuple represents memory index,
// region offset within memory, region length.
std::vector<std::tuple<unsigned, uint32_t, uint32_t>> mRegions;
// For sanity checking.
bool mLayoutDone = false;
};
void TestMemories::layout() {
assert(!mLayoutDone);
for (uint32_t memorySize : mMemorySizes) {
const int fd = ASharedMemory_create(nullptr, memorySize);
assert(fd >= 0);
mMemorys.emplace_back(memorySize, PROT_READ | PROT_WRITE, fd, 0);
mFDs.push_back(fd);
}
mLayoutDone = true;
}
TestMemories::~TestMemories() {
for (int fd : mFDs) {
close(fd);
}
}
class RandomPartitioningTest : public ::testing::TestWithParam<unsigned> {
public:
RandomPartitioningTest() : mRandNumEng(GetParam() /* seed */), mRandNumUnitDist(0.0, 1.0) {}
static Signature getSignature(const HidlModel& model, const Operation& operation);
protected:
void graphDump(const WrapperModel& model);
bool randBool() {
return randUInt(2) == 1;
}
double randFrac() { // [0.0, 1.0)
return mRandNumUnitDist(mRandNumEng);
}
unsigned randUInt(unsigned limit) { // [0, limit)
return unsigned(randFrac() * limit);
}
// Represents an operation in which every input and output operand
// is a TENSOR_FLOAT32 of dimensions [problemSize, problemSize] except:
// - One input operand may be an activation function.
// - Any number of input operands may be "special" in some other way
// (and in this implementation, not produced by any other operation).
// We require that:
// - There be at least one input operand that is neither an
// activation function nor "special".
struct OperationPattern {
int mOperationType;
unsigned mNumInputs;
unsigned mNumOutputs;
int mActivationFunctionInputIndex; // <0 if none
// Returns operand index, or <0 if input is normal (must not
// be called for an activation function operand). Function
// should have the following prototype:
//
// int makeSpecialInput(unsigned problemSize, TestModel* model, unsigned inputIndex);
//
int (RandomPartitioningTest::*mMakeSpecialInput)(unsigned, TestModel*, unsigned);
};
static const OperationPattern kOperationPatterns[];
int makeRnnSpecialInput(unsigned problemSize, TestModel* model, unsigned inputIndex) {
if (inputIndex != 3) {
return -1;
}
// input operand 3 is bias, a 1-D tensor
const WrapperOperandType biasType(WrapperType::TENSOR_FLOAT32, { problemSize });
const uint32_t operandIndex = model->addOperand(&biasType);
std::vector<float> biasValue(problemSize);
std::generate(biasValue.begin(), biasValue.end(),
[this]{ return randFrac(); });
model->setOperandValue(operandIndex, biasValue);
return int(operandIndex);
}
#ifdef VERBOSE
class ModelStats {
public:
ModelStats(const ModelBuilder* model) :
mBuilder(model) { }
ModelStats(const WrapperModel* model) :
mBuilder(reinterpret_cast<const ModelBuilder*>(model->getHandle())) { }
friend std::ostream& operator<<(std::ostream& out, const ModelStats& stats) {
const uint32_t operandCount = stats.mBuilder->operandCount();
const uint32_t inputCount = stats.mBuilder->inputCount();
const uint32_t outputCount = stats.mBuilder->outputCount();
out << "operationCount = " << stats.mBuilder->operationCount()
<< ", operandCount = " << operandCount
<< ", inputCount = " << inputCount
<< " (" << (double(inputCount) / operandCount) << ")"
<< ", outputCount = " << outputCount
<< " (" << (double(outputCount) / operandCount) << ")";
return out;
}
private:
const ModelBuilder* mBuilder;
};
#endif
private:
std::mt19937 mRandNumEng;
std::uniform_real_distribution<double> mRandNumUnitDist;
};
const RandomPartitioningTest::OperationPattern RandomPartitioningTest::kOperationPatterns[] = {
{ ANEURALNETWORKS_ADD, 3, 1, 2, nullptr },
{ ANEURALNETWORKS_LOGISTIC, 1, 1, -1, nullptr },
{ ANEURALNETWORKS_MUL, 3, 1, 2, nullptr },
{ ANEURALNETWORKS_RNN, 6, 2, 5, &RandomPartitioningTest::makeRnnSpecialInput },
{ ANEURALNETWORKS_TANH, 1, 1, -1, nullptr },
};
Signature RandomPartitioningTest::getSignature(const HidlModel& model, const Operation& operation) {
static const std::map<ANeuralNetworksOperationType, int> kOperationToActivation = []() {
std::map<ANeuralNetworksOperationType, int> result;
for (const auto& pattern : kOperationPatterns) {
result[pattern.mOperationType] = pattern.mActivationFunctionInputIndex;
}
return result;
}();
const ANeuralNetworksOperationType operationType =
static_cast<ANeuralNetworksOperationType>(operation.type);
const int activationFunctionInputIndex = kOperationToActivation.at(operationType);
if (activationFunctionInputIndex < 0) {
return Signature(operationType, -1);
}
const Operand& operand = model.operands[operation.inputs[activationFunctionInputIndex]];
assert(operand.lifetime == OperandLifeTime::CONSTANT_COPY);
assert(operand.type == OperandType::INT32);
int32_t value;
memcpy(&value,
&model.operandValues[operand.location.offset],
operand.location.length);
return Signature(operationType, value);
}
void RandomPartitioningTest::graphDump([[maybe_unused]] const WrapperModel& model) {
#ifdef GRAPH
const std::string name = "Test-" + std::to_string(GetParam());
nn::bridge_tests::graphDump(name.c_str(),
reinterpret_cast<const ModelBuilder*>(model.getHandle()));
#endif
}
class TestDriver : public SampleDriver {
public:
// Behaves like SampleDriver, except that it only supports
// operations with the specified signatures.
TestDriver(const char* name, std::set<Signature> signatures) :
SampleDriver(name), mSignatures(std::move(signatures)) { }
Return<void> getCapabilities_1_1(getCapabilities_1_1_cb _hidl_cb) override {
android::nn::initVLogMask();
Capabilities capabilities =
{.float32Performance = {.execTime = 0.75f, .powerUsage = 0.75f},
.quantized8Performance = {.execTime = 0.75f, .powerUsage = 0.75f},
.relaxedFloat32toFloat16Performance = {.execTime = 0.75f, .powerUsage = 0.75f}};
_hidl_cb(ErrorStatus::NONE, capabilities);
return Void();
}
Return<void> getSupportedOperations_1_1(const HidlModel& model,
getSupportedOperations_cb cb) override {
if (nn::validateModel(model)) {
const size_t count = model.operations.size();
std::vector<bool> supported(count);
for (size_t i = 0; i < count; i++) {
supported[i] =
(mSignatures.count(
RandomPartitioningTest::getSignature(
model,
model.operations[i])) != 0);
}
cb(ErrorStatus::NONE, supported);
} else {
std::vector<bool> supported;
cb(ErrorStatus::INVALID_ARGUMENT, supported);
}
return Void();
}
Return<ErrorStatus> prepareModel_1_1(const HidlModel& model, ExecutionPreference preference,
const sp<IPreparedModelCallback>& callback) override {
// NOTE: We verify that all operations in the model are supported.
ErrorStatus outStatus = ErrorStatus::INVALID_ARGUMENT;
auto ret = getSupportedOperations_1_1(
model,
[&outStatus](ErrorStatus inStatus, const hidl_vec<bool>& supportedOperations) {
if (inStatus == ErrorStatus::NONE) {
if (std::all_of(supportedOperations.begin(), supportedOperations.end(),
[](bool v){ return v; })) {
outStatus = ErrorStatus::NONE;
}
}
});
if (ret.isOk() && (outStatus == ErrorStatus::NONE)) {
return SampleDriver::prepareModel_1_1(model, preference, callback);
} else {
callback->notify(ErrorStatus::INVALID_ARGUMENT, nullptr);
return ErrorStatus::INVALID_ARGUMENT;
}
}
private:
const std::set<Signature> mSignatures;
};
INSTANTIATE_TEST_CASE_P(Seed, RandomPartitioningTest,
::testing::Range(kFirstSeed, kFirstSeed + kNumTestCases));
TEST_P(RandomPartitioningTest, Test) {
LOG(INFO) << "RandomPartitioningTest: GetParam() = " << GetParam();
#ifdef VERBOSE
std::cout << std::setprecision(2) << std::fixed << std::setw(4);
#endif
const unsigned problemSize = 1+randUInt(kMaxProblemSize);
const WrapperOperandType problemType(WrapperType::TENSOR_FLOAT32, { problemSize, problemSize });
const WrapperOperandType unknownDimensionsType(WrapperType::TENSOR_FLOAT32, { 0, 0 });
static const WrapperOperandType activationFunctionType(WrapperType::INT32, { });
const unsigned numOperations = 2+randUInt(kMaxNumOperations-1);
const bool allowDeadOperations = (randFrac() < 0.2);
const bool allowUnknownDimensions = (randFrac() < 0.25);
// TODO: The current algorithm builds the graph in a forward
// direction (i.e., later-generated operations consume outputs
// from earlier-generated operations). In order to get more
// variation in graph topology, perhaps we should also create an
// algorithm to build the graph in a backward direction (i.e.,
// later-generated operations produce outputs to be consumed by
// earlier-generated operations).
[[maybe_unused]] const bool buildForward = randBool();
// TODO: Add a form of forced connectivity that operates by
// joining disjoint subgraphs rather than by forcing a root.
const bool forceCommonRoot = (randFrac() < 0.75);
TestModel model;
std::vector<uint32_t> modelInputs;
std::vector<uint32_t> modelOutputs;
// Each region in weights is a problem-sized 2-D TENSOR_FLOAT32.
TestMemories weights;
// Keep track of all normal (i.e., not activation function and not
// "special") operands that are values (from setOperandValue*()).
// .first: operand index
// .second: if the operand is already defined (via setOperandValue*()) then ~0U;
// otherwise, the operand has yet to be defined, and this is the corresponding
// region index in "weights"
std::vector<std::pair<uint32_t, unsigned>> valueOperands;
// An operand is "dead" if it is not consumed by another operation
// and is not a model output. Key is operand index; value is
// operation index.
std::map<uint32_t, uint32_t> deadOperands;
// An operation is "dead" if all of its outputs are dead.
std::set<uint32_t> deadOperations;
// Collect the signatures of operations in this model.
std::set<Signature> signatures;
// For reporting purposes, keep track of the number of root
// operations (those that do not consume results produced by other
// operations).
unsigned rootOperationCount = 0;
// Track if we added operands with unknown dimensions. In this case,
// partitioned compilation will fail if such an operand is read in a
// different partition than it is written.
bool hasUnknownDimensions = false;
// Generate operations.
for (unsigned i = 0; i < numOperations; i++) {
const unsigned operationPatternIndex =
randUInt(sizeof(kOperationPatterns)/sizeof(kOperationPatterns[0]));
const auto& operationPattern = kOperationPatterns[operationPatternIndex];
// INPUTS //////////////////////////////////////////////////////////////////////////////////
std::vector<uint32_t> operationInputs(operationPattern.mNumInputs, ~0U);
// First, process activation function and special inputs, and
// keep track of which inputs remain.
std::vector<uint32_t> normalOperationInputIndexes;
int32_t activationFunction = -1;
for (unsigned operationInputIndex = 0; operationInputIndex < operationPattern.mNumInputs;
operationInputIndex++) {
if (int(operationInputIndex) == operationPattern.mActivationFunctionInputIndex) {
const uint32_t operandIndex = model.addOperand(&activationFunctionType);
activationFunction = randUInt(4);
if (activationFunction == ANEURALNETWORKS_FUSED_RELU1) {
// workaround for http://b/69011131
activationFunction = ANEURALNETWORKS_FUSED_NONE;
}
model.setOperandValue(operandIndex, activationFunction);
operationInputs[operationInputIndex] = operandIndex;
continue;
}
if (operationPattern.mMakeSpecialInput != nullptr) {
const int operandIndex = (this->*(operationPattern.mMakeSpecialInput))(
problemSize, &model, operationInputIndex);
if (operandIndex >= 0) {
operationInputs[operationInputIndex] = operandIndex;
continue;
}
}
normalOperationInputIndexes.push_back(operationInputIndex);
}
assert(!normalOperationInputIndexes.empty());
signatures.insert(Signature(operationPattern.mOperationType, activationFunction));
// A (normal) operation input can be one of:
// - a new or existing model input
// - an output of an existing operation
// - an OperandValue
// - an OperandValueFromMemory
// Some guidelines:
// - We generally don't want all of an operation's inputs to be values (constants)
const unsigned normalOperationInputCount = normalOperationInputIndexes.size();
// How many of this operation's inputs are constants?
unsigned normalOperationInputConstantCount = 0;
// How many of this operation's inputs are model inputs?
unsigned normalOperationInputModelInputCount = 0;
// We begin by deciding what kind of input each (normal) operation will be; we don't
// actually pick input operand indexes at this time, because we might override this
// decision later.
enum InputKind { IK_MODEL_INPUT, IK_OPERATION_OUTPUT, IK_VALUE };
std::vector<InputKind> normalOperationInputKinds(normalOperationInputCount);
std::generate(normalOperationInputKinds.begin(), normalOperationInputKinds.end(),
[this, &model,
numOperations,
normalOperationInputCount,
&normalOperationInputConstantCount,
&normalOperationInputModelInputCount]() -> InputKind {
// Constant? Becomes less likely the more
// constants we already have as inputs to
// this operation.
if (randFrac() < 0.3 * (1 - double(normalOperationInputConstantCount) /
normalOperationInputCount)) {
normalOperationInputConstantCount++;
return IK_VALUE;
}
// Model input? Becomes less likely the
// more model inputs we already have as
// inputs to this operation, and the further
// along we are in generating this model
// (i.e., the more operations we have
// generated).
if ((model.operationCount() == 0) ||
(randFrac() < 0.5 *
(1 - double(normalOperationInputModelInputCount) /
normalOperationInputCount) *
std::min(0.3, (1 - double(model.operationCount()) /
numOperations)))) {
normalOperationInputModelInputCount++;
return IK_MODEL_INPUT;
}
// Else output of an existing operation.
return IK_OPERATION_OUTPUT;
});
// Now force common root or model input, if necessary. (A
// model must have at least one input.)
auto force =
[this, &normalOperationInputKinds, normalOperationInputCount](InputKind forceKind){
if (std::none_of(normalOperationInputKinds.begin(),
normalOperationInputKinds.end(),
[forceKind](InputKind kind){ return kind == forceKind; })) {
normalOperationInputKinds[randUInt(normalOperationInputCount)] = forceKind;
}
};
if (forceCommonRoot && (model.operationCount() != 0)) {
force(IK_OPERATION_OUTPUT);
}
if (modelInputs.empty()) {
assert(model.operationCount() == 0);
force(IK_MODEL_INPUT);
}
// Finally create the normal inputs.
bool isRootOperation = true;
for (unsigned i = 0; i < normalOperationInputCount; i++) {
uint32_t operandIndex = ~0U;
switch (normalOperationInputKinds[i]) {
case IK_MODEL_INPUT: {
if (!modelInputs.empty() && (randFrac() < 0.5)) {
operandIndex = modelInputs[randUInt(modelInputs.size())];
} else {
operandIndex = model.addOperand(&problemType);
modelInputs.push_back(operandIndex);
}
break;
}
case IK_OPERATION_OUTPUT: {
decltype(deadOperands.begin()) deadOperandI;
if (!deadOperands.empty() && (randFrac() < 0.5)) {
deadOperandI = deadOperands.begin();
std::advance(deadOperandI, randUInt(deadOperands.size()));
operandIndex = deadOperandI->first;
} else {
const uint32_t existingOperationIndex = randUInt(model.operationCount());
const auto& existingOperationOutputs =
model.getOperationOutputs(existingOperationIndex);
operandIndex =
existingOperationOutputs[randUInt(existingOperationOutputs.size())];
deadOperandI = deadOperands.find(operandIndex);
assert(deadOperandI == deadOperands.end() ||
deadOperandI->second == existingOperationIndex);
}
if (deadOperandI != deadOperands.end()) {
const uint32_t correspondingOperation = deadOperandI->second;
deadOperands.erase(deadOperandI);
auto deadOperationI = deadOperations.find(correspondingOperation);
if (deadOperationI != deadOperations.end()) {
deadOperations.erase(deadOperationI);
}
}
isRootOperation = false;
break;
}
case IK_VALUE: {
if (!valueOperands.empty() && (randFrac() < 0.25)) {
operandIndex = valueOperands[randUInt(valueOperands.size())].first;
} else {
operandIndex = model.addOperand(&problemType);
if (randFrac() < 0.5) {
std::vector<float> value(problemSize * problemSize);
std::generate(value.begin(), value.end(), [this]{ return randFrac(); });
model.setOperandValue(operandIndex, value);
valueOperands.push_back(std::make_pair(operandIndex, ~0U));
} else {
unsigned memoryIndex = ~0U;
if ((weights.memoryCount() != 0) &&
(kAllWeightsInOnePool || (randFrac() < 0.5))) {
memoryIndex = randUInt(weights.memoryCount());
} else {
memoryIndex = weights.addMemory();
}
const size_t length = problemSize * problemSize * sizeof(float);
const unsigned regionIndex = weights.addRegion(memoryIndex, length);
valueOperands.push_back(std::make_pair(operandIndex, regionIndex));
}
}
break;
}
default:
FAIL();
}
operationInputs[normalOperationInputIndexes[i]] = operandIndex;
}
if (isRootOperation) {
rootOperationCount++;
}
// OUTPUTS /////////////////////////////////////////////////////////////////////////////////
std::vector<uint32_t> operationOutputs(operationPattern.mNumOutputs);
std::generate(operationOutputs.begin(), operationOutputs.end(),
[&model, &problemType, &unknownDimensionsType, &hasUnknownDimensions,
allowUnknownDimensions, this]{
// 3% unknowns causes ~35% of partitionings to fail
// (determined by commenting out the fallback code,
// running tests and noting number of failures).
if (allowUnknownDimensions && randFrac() < 0.03) {
hasUnknownDimensions = true;
return model.addOperand(&unknownDimensionsType);
} else {
return model.addOperand(&problemType);
}
});
// OPERATION ///////////////////////////////////////////////////////////////////////////////
const uint32_t operationIndex =
model.addOperation(operationPattern.mOperationType,
operationInputs, operationOutputs);
deadOperations.insert(operationIndex);
std::for_each(operationOutputs.begin(), operationOutputs.end(),
[&deadOperands, operationIndex](uint32_t operandIndex) {
deadOperands.insert(std::make_pair(operandIndex, operationIndex));
});
}
// Now finalize the weights.
weights.layout();
for (const auto& valueOperand : valueOperands) {
const uint32_t operandIndex = valueOperand.first;
const unsigned regionIndex = valueOperand.second;
if (regionIndex == ~0U) {
continue;
}
const WrapperMemory* memory;
uint32_t offset, length;
float* region =
static_cast<float*>(weights.getRegion(regionIndex, &memory, &offset, &length));
assert(length == problemSize * problemSize * sizeof(float));
std::generate(region, region + problemSize * problemSize, [this]{ return randFrac(); });
model.setOperandValueFromMemory(operandIndex, memory, offset, length);
}
// Now select model outputs.
for (uint32_t operationIdx = 0, operationCount = model.operationCount();
operationIdx < operationCount; operationIdx++) {
const auto& outputs = model.getOperationOutputs(operationIdx);
for (uint32_t outputIdx = 0, outputCount = outputs.size(); outputIdx < outputCount;
outputIdx++) {
bool modelOutput = false;
const uint32_t operandIndex = outputs[outputIdx];
const auto deadOperandI = deadOperands.find(operandIndex);
if (deadOperandI != deadOperands.end()) {
// This is not consumed within the model, so unless we
// make it an output of the model, it's dead. The
// further along we are in generating this model
// (i.e., the more operations we have generated), the
// more likely we are to classify this operation
// output as a model output.
const double probabilityOfModelOutput =
0.50 * [](double x){ return x*x; }((operationIdx + 1) / operationCount);
modelOutput = (randFrac() < probabilityOfModelOutput);
} else {
// This is consumed within the model, so we'll rarely
// make it an output of the model.
modelOutput = (randFrac() < 0.05);
}
if (!modelOutput) {
continue;
}
modelOutputs.push_back(operandIndex);
if (deadOperandI != deadOperands.end()) {
deadOperands.erase(deadOperandI);
const auto deadOperationI = deadOperations.find(operationIdx);
if (deadOperationI != deadOperations.end()) {
deadOperations.erase(deadOperationI);
}
}
}
}
if (!allowDeadOperations) {
// For each dead operation, pick a random output to become a model output.
for (uint32_t deadOperationIndex : deadOperations) {
const auto& deadOperationOutputs = model.getOperationOutputs(deadOperationIndex);
const uint32_t deadOperandIndex =
deadOperationOutputs[randUInt(deadOperationOutputs.size())];
modelOutputs.push_back(deadOperandIndex);
}
}
// A model must have at least one output.
if (modelOutputs.empty()) {
const auto& outputs = model.getOperationOutputs(randUInt(model.operationCount()));
modelOutputs.push_back(outputs[randUInt(outputs.size())]);
}
model.identifyInputsAndOutputs(modelInputs, modelOutputs);
#ifdef VERBOSE
{
std::cout << "Original model: " << ModelStats(&model) << std::endl;
std::cout << "rootOperationCount = " << rootOperationCount
<< ", deadOperations = ";
if (allowDeadOperations) {
std::cout << deadOperations.size();
} else {
std::cout << "forbidden (converted " << deadOperations.size() << ")";
}
std::cout << std::endl;
}
#endif
ASSERT_EQ(model.finish(), Result::NO_ERROR);
graphDump(model);
// Non-partitioned compilation.
TestCompilation c(&model);
ASSERT_EQ(c.setPartitioning(DeviceManager::kPartitioningNo), Result::NO_ERROR);
ASSERT_EQ(c.finish(), Result::NO_ERROR);
// Create some drivers for partitioned compilation.
assert(!signatures.empty());
std::vector<std::set<Signature>> signaturesForDriver(signatures.size());
// First assign each signature to a random driver (a driver is
// just represented as an entry in the signaturesForDriver
// vector).
for (Signature signature : signatures) {
signaturesForDriver[randUInt(signatures.size())].insert(signature);
}
// Now remove each entry that has no signatures.
auto firstExtra =
std::remove_if(signaturesForDriver.begin(), signaturesForDriver.end(),
[](const std::set<Signature>& sigSet) { return sigSet.empty(); });
if (firstExtra != signaturesForDriver.end()) {
signaturesForDriver.erase(firstExtra, signaturesForDriver.end());
}
// Now actually create the drivers.
std::vector<std::shared_ptr<Device>> devices;
for (unsigned i = 0; i < signaturesForDriver.size(); i++) {
const std::string name = "TestDriver(" + std::to_string(i) + ")";
devices.push_back(std::make_shared<Device>(
name, new TestDriver(name.c_str(), signaturesForDriver[i])));
ASSERT_TRUE(devices.back()->initialize());
}
// Partitioned compilation.
// For test cases without unknown intermediate operand sizes we require the
// partitioning to succeed without CPU fallback. With unknown sizes we
// retry with a fallback if the non-fallback partitioning fails and require
// the fallback to succeed.
TestCompilation cNoFallback(&model);
TestCompilation cWithFallback(&model);
TestCompilation *c2 = nullptr;
ASSERT_EQ(cNoFallback.setPartitioning(DeviceManager::kPartitioningWithoutFallback),
Result::NO_ERROR);
auto compilationResult = cNoFallback.finish(devices);
if (hasUnknownDimensions && compilationResult == Result::OP_FAILED &&
cNoFallback.getExecutionPlan().forTest_hasSubModelOutputsOfUnknownSize()) {
ASSERT_EQ(cWithFallback.setPartitioning(DeviceManager::kPartitioningWithFallback),
Result::NO_ERROR);
ASSERT_EQ(cWithFallback.finish(devices), Result::NO_ERROR);
c2 = &cWithFallback;
} else {
ASSERT_EQ(compilationResult, Result::NO_ERROR);
c2 = &cNoFallback;
}
#ifdef VERBOSE
{
std::cout << "signatures = " << signatures.size()
<< ", devices = " << devices.size() << std::endl;
const ExecutionPlan& plan = c2->getExecutionPlan();
switch (plan.forTest_getKind()) {
case ExecutionPlan::Kind::SIMPLE:
std::cout << "plan: simple" << std::endl;
break;
case ExecutionPlan::Kind::COMPOUND: {
const auto& steps = plan.forTest_compoundGetSteps();
std::set<const Device*> devicesInPlan;
for (const auto& step : steps) {
devicesInPlan.insert(step->getDevice().get());
}
std::cout << "plan: compound, " << steps.size() << " steps over "
<< devicesInPlan.size() << " devices" << std::endl;
for (unsigned i = 0; i < steps.size(); i++) {
std::cout << "Step " << i << ": "
<< ModelStats(steps[i]->getSubModel()) << std::endl;
}
break;
}
default:
std::cout << "Unexpected plan kind: "
<< static_cast<unsigned>(plan.forTest_getKind());
break;
}
}
#endif
// For execution:
// - create master inputs (one long vector) and master output value
// - master inputs will be copied to actual inputs before each
// of the two executions
// - master output will be used to fill actual outputs before each
// of the two executions
// - create actual inputs and outputs
// - first execution (non-partitioned)
// - initialize inputs and (to avoid unrelated oddities) outputs
// - execute
// - copy outputs to a save area (one long vector)
// - second execution (partitioned)
// - (to avoid unrelated oddities) initialize inputs and outputs
// - execute
// - compare outputs to save area
// If the runtime and drivers are working properly, execution
// should not change the inputs. Nonetheless, we reinitialize the
// inputs for each execution, so as to avoid unrelated problems
// appearing to be problems related to unpartitioned execution
// versus partitioned execution. Similarly, execution behavior
// should not be dependent on the outputs; but we'll initialize the
// outputs anyway.
std::vector<float> masterInputs(problemSize * problemSize * model.inputCount());
std::generate(masterInputs.begin(), masterInputs.end(), [this]{ return randFrac(); });
const float masterOutput = randFrac();
// Create the memory for the actual inputs and outputs.
struct InputOutputDescriptor {
enum Kind { INPUT, OUTPUT };
Kind mKind;
// The input or output either resides in a local buffer
// (mVector, in which case mMemoryRegion is ignored); or in a
// shared memory region within a TestMemories instance
// (mMemoryRegion, in which case mVector is ignored).
enum Location { VECTOR, REGION };
Location getLocation() const { return !mVector.empty() ? VECTOR : REGION; }
std::vector<float> mVector;
unsigned mMemoryRegion;
};
std::vector<InputOutputDescriptor> ioDescriptors(model.inputCount() + model.outputCount());
for (unsigned i = 0; i < ioDescriptors.size(); i++) {
ioDescriptors[i].mKind = (i < model.inputCount()
? InputOutputDescriptor::INPUT
: InputOutputDescriptor::OUTPUT);
}
// We randomly interleave inputs and outputs in creation
// order, because when we we create memory regions in a
// TestMemories instance, the order in which regions are
// created within a single Memory is the order they'll be laid
// out in that memory; and when we have inputs and outputs
// within the same Memory, we want the possibility that
// they'll be interleaved.
std::random_shuffle(ioDescriptors.begin(), ioDescriptors.end(),
[this](unsigned n) { return randUInt(n); });
TestMemories ioMemories;
for (auto &desc : ioDescriptors) {
if (randFrac() < 0.5) {
desc.mVector.resize(problemSize * problemSize);
} else {
// TODO: common this with the way we create IK_VALUE inputs?
unsigned memoryIndex = ~0U;
if ((ioMemories.memoryCount() != 0) && (randFrac() < 0.5)) {
memoryIndex = randUInt(ioMemories.memoryCount());
} else {
memoryIndex = ioMemories.addMemory();
}
const size_t length = problemSize * problemSize * sizeof(float);
desc.mMemoryRegion = ioMemories.addRegion(memoryIndex, length);
}
}
ioMemories.layout();
// Function to set up actual inputs and outputs (initializing them
// and telling the WrapperExecution about them).
auto prepareForExecution =
[&model, &ioDescriptors, &ioMemories,
&masterInputs, &masterOutput, problemSize, &problemType](WrapperExecution *e) {
uint32_t inputIndex = 0, outputIndex = 0;
for (auto &desc : ioDescriptors) {
if (desc.getLocation() == InputOutputDescriptor::VECTOR) {
if (desc.mKind == InputOutputDescriptor::INPUT) {
const size_t inputOffset = inputIndex * problemSize * problemSize;
std::copy(masterInputs.begin() + inputOffset,
masterInputs.begin() + inputOffset + problemSize * problemSize,
desc.mVector.begin());
e->setInput(inputIndex++, desc.mVector.data(),
desc.mVector.size() * sizeof(float));
} else {
std::fill(desc.mVector.begin(),
desc.mVector.begin() + problemSize * problemSize,
masterOutput);
e->setOutput(outputIndex++, desc.mVector.data(),
desc.mVector.size() * sizeof(float),
&problemType.operandType);
}
} else {
const WrapperMemory* memory;
uint32_t offset, length;
float* region =
static_cast<float*>(ioMemories.getRegion(desc.mMemoryRegion,
&memory, &offset, &length));
assert(length == problemSize * problemSize * sizeof(float));
if (desc.mKind == InputOutputDescriptor::INPUT) {
const size_t inputOffset = inputIndex * problemSize * problemSize;
std::copy(masterInputs.begin() + inputOffset,
masterInputs.begin() + inputOffset + problemSize * problemSize,
region);
e->setInputFromMemory(inputIndex++, memory, offset, length);
} else {
std::fill(region,
region + problemSize * problemSize,
masterOutput);
e->setOutputFromMemory(outputIndex++, memory, offset, length,
&problemType.operandType);
}
}
};
assert(inputIndex == model.inputCount());
assert(outputIndex == model.outputCount());
};
// Non-partitioned execution.
WrapperExecution e(&c);
ASSERT_NO_FATAL_FAILURE(prepareForExecution(&e));
ASSERT_EQ(e.compute(), Result::NO_ERROR);
// Copy the outputs of the non-partitioned execution to a save area.
std::vector<float> nonPartitionedOutputs(problemSize * problemSize * model.outputCount());
{
uint32_t outputIndex = 0;
for (const auto& desc : ioDescriptors) {
if (desc.mKind != InputOutputDescriptor::OUTPUT) {
continue;
}
const size_t outputOffset = outputIndex * problemSize * problemSize;
if (desc.getLocation() == InputOutputDescriptor::VECTOR) {
std::copy(desc.mVector.begin(),
desc.mVector.end(),
nonPartitionedOutputs.begin() + outputOffset);
} else {
float* region = static_cast<float*>(ioMemories.getRegion(desc.mMemoryRegion));
std::copy(region,
region + problemSize * problemSize,
nonPartitionedOutputs.begin() + outputOffset);
}
#ifdef VERBOSE
{
std::cout << "output[" << outputIndex << "] = {";
for (auto I = nonPartitionedOutputs.begin() + outputOffset,
E = nonPartitionedOutputs.begin() +
outputOffset + problemSize * problemSize;
I != E; I++) {
std::cout << " " << *I;
}
std::cout << " }" << std::endl;
}
#endif
outputIndex++;
}
}
// Partitioned execution.
WrapperExecution e2(c2);
ASSERT_NO_FATAL_FAILURE(prepareForExecution(&e2));
ASSERT_EQ(e2.compute(), Result::NO_ERROR);
// Compare the outputs of the partitioned execution to the save
// area containing the outpus of the non-partitioned execution.
{
uint32_t outputIndex = 0;
for (const auto& desc : ioDescriptors) {
if (desc.mKind != InputOutputDescriptor::OUTPUT) {
continue;
}
SCOPED_TRACE(outputIndex);
const size_t outputOffset = outputIndex * problemSize * problemSize;
if (desc.getLocation() == InputOutputDescriptor::VECTOR) {
ASSERT_TRUE(std::equal(desc.mVector.begin(),
desc.mVector.end(),
nonPartitionedOutputs.begin() + outputOffset));
} else {
float* region = static_cast<float*>(ioMemories.getRegion(desc.mMemoryRegion));
ASSERT_TRUE(std::equal(region,
region + problemSize * problemSize,
nonPartitionedOutputs.begin() + outputOffset));
}
outputIndex++;
}
}
}
} // namespace
} // namespace android
| 43.613255 | 100 | 0.603593 | yakuizhao |
861c0afd7637ac2c073fea8bbd099c9490acb861 | 878 | cc | C++ | stage2/tareeq/control/test/unicycle_driver_test.cc | aboarya/unicyle-kinematics | dfbb1090bf112079d0a1b5c629718999681515bb | [
"MIT"
] | null | null | null | stage2/tareeq/control/test/unicycle_driver_test.cc | aboarya/unicyle-kinematics | dfbb1090bf112079d0a1b5c629718999681515bb | [
"MIT"
] | null | null | null | stage2/tareeq/control/test/unicycle_driver_test.cc | aboarya/unicyle-kinematics | dfbb1090bf112079d0a1b5c629718999681515bb | [
"MIT"
] | null | null | null | #include <string>
#include <unordered_map>
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "../unicycle_driver.h"
#include "tareeq/mocks/motor.h"
#include "tareeq/mocks/sensor.h"
#include "tareeq/mocks/state.h"
namespace tareeq {
namespace control {
using namespace tareeq::mocks;
class UniCDriverTest : public testing::Test
{
public:
void SetUp() override {
//m["w_r"] = 1.5;
//m["w_l"] = 1.5;
//s = MockState(m);
}
MockSensor s;
MockState st;
MockMotor r;
MockMotor l;
UniCycleDriver driver{r, l};
std::unordered_map<std::string, double> m;
};
TEST_F(UniCDriverTest, CheckValidConstruction) {
EXPECT_EQ(true, driver.Start());
EXPECT_EQ(true, driver.Apply(st));
EXPECT_EQ(true, driver.Stop());
}
} // end namespace control
} // end namespace tareeq
| 19.086957 | 52 | 0.627563 | aboarya |
86235a2414943f958ca76cb1112d7ecded975981 | 1,677 | cpp | C++ | apps/rrGUI/rrLogFileReader.cpp | gregmedlock/roadrunnerwork | 11f18f78ef3e381bc59c546a8d5e3ed46d8ab596 | [
"Apache-2.0"
] | null | null | null | apps/rrGUI/rrLogFileReader.cpp | gregmedlock/roadrunnerwork | 11f18f78ef3e381bc59c546a8d5e3ed46d8ab596 | [
"Apache-2.0"
] | null | null | null | apps/rrGUI/rrLogFileReader.cpp | gregmedlock/roadrunnerwork | 11f18f78ef3e381bc59c546a8d5e3ed46d8ab596 | [
"Apache-2.0"
] | null | null | null | #ifdef MTK_PCH
#include "mtk_pch.h"
#endif
#pragma hdrstop
#include <Classes.hpp>
#include "rrLogFileReader.h"
#include "rrLogger.h"
#include "MainForm.h"
//---------------------------------------------------------------------------
namespace rr
{
LogFileReader::LogFileReader(const string& file, TMForm* mainForm)
:
mFileName(file),
mMainForm(mainForm)
{
if(FileExists(mFileName.c_str()))
{
mFS.open(file.c_str());
}
}
void LogFileReader::SetFileName(const string& fName)
{
mFileName = fName;
}
void LogFileReader::Worker()
{
mIsRunning = true;
mIsFinished = false;
//First advance to end
if(!mFS.is_open())
{
mFS.open(mFileName.c_str());
if(!mFS)
{
mIsTimeToDie = true;
}
}
mFS.seekg (0, ios::end);
streampos pos = mFS.tellg();
streampos lastPosition = pos;
while(!mIsTimeToDie)
{
//Read until end of file
while(!mFS.eof())
{
char* data = new char[2048];
mFS.getline(data, 2048);
if(strlen(data) > 1)
{
if(mMainForm)
{
while(mMainForm->mLogString)
{
;
}
mMainForm->mLogString = new string(data);
TThread::Synchronize(NULL, mMainForm->LogMessage);
}
}
delete [] data;
}
if(mFS.fail())
{
mFS.clear();
}
pos = mFS.tellg();
Sleep(100);
}
mIsRunning = false;
mIsFinished = true;
}
}
| 19.5 | 78 | 0.462731 | gregmedlock |
8629734fcfd04b2f01c228d0e80973ce1f4cf90d | 323 | cpp | C++ | Codeforces/A/Fox And Snake.cpp | AkibHossainOmi/Solving-Online-Judge-Problem | ae2f7685f7a0df3438607498c38de01742fe7240 | [
"MIT"
] | 1 | 2022-01-30T05:20:36.000Z | 2022-01-30T05:20:36.000Z | Codeforces/A/Fox And Snake.cpp | AkibHossainOmi/Solving-Online-Judge-Problem | ae2f7685f7a0df3438607498c38de01742fe7240 | [
"MIT"
] | null | null | null | Codeforces/A/Fox And Snake.cpp | AkibHossainOmi/Solving-Online-Judge-Problem | ae2f7685f7a0df3438607498c38de01742fe7240 | [
"MIT"
] | null | null | null | #include<stdio.h>
int main()
{
int m,n,i,j,r;
scanf("%d %d",&m,&n);
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
if(i%2==0&&i%4!=0&&j!=n) printf(".");
else if(i%4==0&&j!=1) printf(".");
else printf("#");
}
printf("\n");
}
}
| 19 | 50 | 0.318885 | AkibHossainOmi |
862b99290af45091242ded696c17606cc1c6de99 | 21,710 | cpp | C++ | source/view/qrserverwidget.cpp | c6supper/json_serialize_deserialize_qt | c70e89056900835221309f7c54dcca2e9fefe498 | [
"Apache-2.0"
] | null | null | null | source/view/qrserverwidget.cpp | c6supper/json_serialize_deserialize_qt | c70e89056900835221309f7c54dcca2e9fefe498 | [
"Apache-2.0"
] | null | null | null | source/view/qrserverwidget.cpp | c6supper/json_serialize_deserialize_qt | c70e89056900835221309f7c54dcca2e9fefe498 | [
"Apache-2.0"
] | null | null | null | #include "qrserverwidget.h"
#include "qprofile_debug.h"
#include "qrserverstrtable.h"
#include "qrservermodel.h"
#include "qmodelfactory.h"
#include "qrservermessagebox.h"
#include "qrserverdevicetype.h"
#include "qautocheckevent.h"
#include "qrserverenvironment.h"
#include "qgenericcommand.h"
#include "qgenericstatus.h"
#include <QFileInfo>
#include "qadminsettingprofile.h"
#include "qrservercompatibility518.h"
using namespace QRserver;
#define RIGHT_TOOL_WIDTH (139)
const qint32 QRserverWidget::CheckRegistrationBombInterval = 10 * 60 * 1000;
QRserverWidget::QRserverWidget(QWidget *parent, const QString &tagName)
: QRserverContainerWidget(parent),
m_vconnectModel(nullptr),
m_uploadTabCurrentIdx(QUploadWidget::RserverTabUploadResult)
{
setObjectName("QRserverWidget");
setTagName(tagName);
setFixedSize(parent->width(), parent->height());
//load admin setting from json file..
QAdminSettingProfile::Instance()->loadProfile();
QHBoxLayout *pMainLayout = new QHBoxLayout(this);
pMainLayout->setMargin(0);
pMainLayout->setSpacing(0);
QHBoxLayout *pTabLayout = new QHBoxLayout;
pTabLayout->setAlignment(Qt::AlignLeft);
pTabLayout->setMargin(0);
pTabLayout->setSpacing(0);
m_ptab = new QTabWidget(this);
m_ptab->setObjectName("QRserverQTab");
m_ptab->setFixedSize(width() - RIGHT_TOOL_WIDTH, height());
m_pRegister = new QRegisterWidget(m_ptab);
m_pUploadWidget = new QUploadWidget(m_ptab);
m_pDownloadWidget = new QDownloadWidget(m_ptab);
m_pSoftwareWidget = new QSoftwareWidget(m_ptab);
m_ptab->addTab(m_pRegister, TRANSLATE_STR_RSERVER_TAB_REGISTER);
m_ptab->addTab(m_pUploadWidget, TRANSLATE_STR_RSERVER_TAB_UPLOAD);
m_ptab->addTab(m_pDownloadWidget, TRANSLATE_STR_RSERVER_TAB_DOWNLOAD);
m_ptab->addTab(m_pSoftwareWidget, TRANSLATE_STR_RSERVER_TAB_SOFTWARE);
QWidget *pWidget = new QWidget(this);
pWidget->setObjectName("ToolboxBtnWidget");
pWidget->setFixedSize(RIGHT_TOOL_WIDTH, height());
m_pBtnRegister = new QPushButton(this);
m_pBtnRegister->setText(TRANSLATE_STR_RSERVER_BTN_REGISTER);
m_pBtnUnRegister = new QPushButton(this);
m_pBtnUnRegister->setText(TRANSLATE_STR_RSERVER_BTN_UNREGISTER);
m_pBtnCheck = new QPushButton(this);
m_pBtnCheck->setText(TRANSLATE_STR_RSERVER_BTN_CHECK);
m_pBtnRServerMode = new QPushButton(this);
m_pBtnRServerMode->setText(TRANSLATE_STR_RSERVER_BTN_MODE_VCONNECT);
m_pBtnRServerMode->hide();
m_pBtnUpload = new QPushButton(this);
m_pBtnUpload->setText(TRANSLATE_STR_RSERVER_BTN_UPLOAD);
m_pBtnUpload->hide();
m_pBtnJob = new QPushButton(this);
m_pBtnJob->setText(TRANSLATE_STR_RSERVER_BTN_JOB);
m_pBtnJob->hide();
m_pBtnUploadAndDel = new QPushButton(this);
m_pBtnUploadAndDel->setText(TRANSLATE_STR_RSERVER_BTN_UPLOAD_DEL);
m_pBtnUploadAndDel->hide();
m_pBtnDownload = new QPushButton(this);
m_pBtnDownload->setText(TRANSLATE_STR_RSERVER_BTN_DOWNLOAD);
m_pBtnDownload->hide();
m_pBtnUpgrade = new QPushButton(this);
m_pBtnUpgrade->setText(TRANSLATE_STR_RSERVER_BTN_UPGRADE);
m_pBtnUpgrade->hide();
m_pBtnUpdate = new QPushButton(this);
m_pBtnUpdate->setText(TRANSLATE_STR_RSERVER_BTN_UPDATE);
m_pBtnUpdate->hide();
m_pBtLayout = new QVBoxLayout(pWidget);
m_pBtLayout->setAlignment(Qt::AlignHCenter);
m_pBtLayout->setMargin(0);
m_pBtLayout->addSpacing(30);
m_pBtLayout->addWidget(m_pBtnRegister);
m_pBtLayout->addWidget(m_pBtnUnRegister);
m_pBtLayout->addWidget(m_pBtnCheck);
m_pBtLayout->addWidget(m_pBtnUpload);
m_pBtLayout->addWidget(m_pBtnJob);
m_pBtLayout->addWidget(m_pBtnUploadAndDel);
m_pBtLayout->addWidget(m_pBtnDownload);
m_pBtLayout->addWidget(m_pBtnUpgrade);
m_pBtLayout->addWidget(m_pBtnUpdate);
m_pBtLayout->addSpacing(30);
m_pBtLayout->addWidget(m_pBtnRServerMode);
m_pBtLayout->addStretch();
pTabLayout->addWidget(m_ptab);
pMainLayout->addLayout(pTabLayout);
pMainLayout->addWidget(pWidget);
connect(m_ptab, SIGNAL(currentChanged(int)), this, SLOT(onTabChange(int)));
connect(m_pBtnUnRegister, SIGNAL(clicked(bool)), this,
SLOT(onUnregister()));
connect(m_pBtnUpload, SIGNAL(clicked(bool)), m_pUploadWidget,
SIGNAL(onUploadBtnClicked()));
connect(m_pBtnJob, SIGNAL(clicked(bool)), m_pUploadWidget,
SIGNAL(onJobBtnClicked()));
connect(m_pBtnUploadAndDel, SIGNAL(clicked(bool)), m_pUploadWidget,
SIGNAL(onUploadAndDelBtnClicked()));
connect(m_pBtnDownload, SIGNAL(clicked(bool)), m_pDownloadWidget,
SLOT(onDownloadAll()));
connect(m_pBtnUpgrade, SIGNAL(clicked(bool)), m_pSoftwareWidget,
SLOT(onUpgrade()));
connect(this, SIGNAL(registrationBombExpired()), m_pRegister,
SLOT(onRegistrationBombExpired()));
connect(m_pRegister, SIGNAL(serverAddressChanged()), this,
SLOT(onRestoreDefault()));
connect(m_pRegister, SIGNAL(upateDeviceInfoSucceed()), this,
SLOT(onUpateDeviceInfoSucceed()));
connect(m_pBtnUpdate, SIGNAL(clicked(bool)), m_pRegister,
SLOT(onUpdate()));
connect(m_pUploadWidget, SIGNAL(currentTabChanged(int)), this,
SLOT(onUploadWidgetTabChanged(int)));
connect(this, SIGNAL(lockUploadProfileTab(bool)), m_pUploadWidget,
SLOT(onSetTab(bool)));
connect(m_pRegister, SIGNAL(checkDeviceSucceed()), m_pUploadWidget,
SIGNAL(checkDeviceSucceed()));
connect(m_pRegister, SIGNAL(checkDeviceSucceed()), this,
SLOT(onCheckDeviceSucceed()));
connect(m_pBtnRServerMode, SIGNAL(clicked(bool)), this,
SLOT(onRServerModeChanged()));
connect(m_pRegister, SIGNAL(checkDeviceSucceed()), m_pDownloadWidget,
SLOT(onCheckDeviceSucceed()));
connect(m_pRegister, SIGNAL(getProfileInfoList()), m_pUploadWidget,
SIGNAL(getProfileInfoList()));
//
QFileInfo vconncetServerConfig(QRserverEnvironment::VConncetServerConfig());
m_fileSystemWatcher.addPath(vconncetServerConfig.absolutePath());
connect(&m_fileSystemWatcher, SIGNAL(directoryChanged(const QString)), this,
SLOT(onDirectoryChanged(const QString)));
lockTab(true);
//check registrationBomb
m_registrationBombTimer.setSingleShot(false);
m_registrationBombTimer.setInterval(CheckRegistrationBombInterval);
connect(&m_registrationBombTimer, SIGNAL(timeout()), this,
SLOT(onCheckRegistrationBomb()));
m_registrationBombTimer.start();
#ifdef BUILD_X86
setEnabled(false);
#endif
}
void QRserverWidget::onCheckRegistrationBomb()
{
if (QAdminSettingProfile::Instance()->isRegistrationBombExpired()) {
m_registrationBombTimer.stop();
onRestoreDefault();
m_pBtnRegister->hide();
m_pBtnUnRegister->hide();
m_pBtnCheck->hide();
m_pBtnUpdate->show();
emit registrationBombExpired();
}
}
void QRserverWidget::onRestoreDefault()
{
lockTab();
QRserverModel *rserverModel = qobject_cast<QRserverModel *>(model());
rserverModel->initialDeviceStatus();
}
void QRserverWidget::onUpateDeviceInfoSucceed()
{
m_pBtnRegister->show();
m_pBtnUnRegister->show();
m_pBtnCheck->show();
m_pBtnUpdate->hide();
m_registrationBombTimer.start();
}
void QRserverWidget::onCheckDeviceSucceed()
{
lockTab(false);
if (m_pDownloadWidget != nullptr
&& QAdminSettingProfile::Instance()->isLockDown()) {
m_ptab->setCurrentIndex(RserverTabDownload);
}
}
void QRserverWidget::lockTab(bool lock)
{
for (int tabIdx = 1; tabIdx < m_ptab->count(); tabIdx++) {
m_ptab->setTabEnabled(tabIdx, !lock);
}
emit lockUploadProfileTab((
QAdminSettingProfile::Instance()->isBlockProfileUpload()) || lock);
if (lock) {
m_uploadTabCurrentIdx = m_pUploadWidget->currentTabIndex();
}
if ((m_vconnectModel != nullptr) && (m_vconnectModel->isValid())
&& (m_vconnectModel->rserverMode() == QVConnectModel::ModeVConnect)) {
m_ptab->setTabEnabled(m_ptab->indexOf(m_pUploadWidget), true);
}
if (lock) {
m_ptab->setCurrentIndex(0);
}
}
void QRserverWidget::customEvent(QEvent *event)
{
if (QAutoCheckEvent::EventType() == event->type()) {
onLoadVConncetServerConfig();
if (m_vconnectModel->isVConnectValid()) {
return setEnabled(true);
} else {
return onAutoCheck();
}
}
return QRserverContainerWidget::customEvent(event);
}
void QRserverWidget::onAutoCheck()
{
if (!isVisible()) {
qprofileDebug(QtWarningMsg) << "QRserverWidget is not visible";
return;
}
if (QAdminSettingProfile::Instance()->isRegistrationBombExpired()) {
onCheckRegistrationBomb();
} else {
lockTab(true);
const QRegisterModel *registerModel =
QModelFactory::constModel<QRegisterModel>(this);
if (!registerModel->serverUrl().isEmpty()) {
QTimer::singleShot(0, model(), SLOT(initialDeviceStatus()));
QTimer::singleShot(0, m_pRegister, SLOT(onCheck()));
}
}
setEnabled(true);
}
void QRserverWidget::onUnregister()
{
if (QMessageBox::Ok != QRserverMessageBox::Information(this,
TRANSLATE_STR_RSERVER_INFORMATION,
TRANSLATE_STR_RSERVER_REGISTER_UNREGISTER_CONFIRM,
QMessageBox::Ok | QMessageBox::Cancel)) {
return ;
}
//registration lock.
QAdminSettingProfileProperties profileProperties;
profileProperties.fromVariant(m_registerModel->adminSettingProfile());
if (profileProperties.lockRegistration()) {
QRserverMessageBox::Information(this, TRANSLATE_STR_RSERVER_INFORMATION,
TRANSLATE_STR_RSERVER_REGISTER_REGISTRATION_LOCK, QMessageBox::Ok);
return ;
}
onRestoreDefault();
QTimer::singleShot(0, m_pRegister, SLOT(onUnregister()));
}
void QRserverWidget::allocModel()
{
setModel(QModelFactory::construct<QRserverModel>(this));
connect(m_pBtnRegister, SIGNAL(clicked(bool)), this,
SLOT(onRegisterButtonClicked()));
connect(this, SIGNAL(registerRserver()), m_pRegister, SLOT(onRegister()));
connect(this, SIGNAL(updateTechName()), m_pRegister,
SLOT(onUpdateTechName()));
connect(m_pBtnCheck, SIGNAL(clicked(bool)), model(),
SLOT(initialDeviceStatus()));
connect(m_pBtnCheck, SIGNAL(clicked(bool)), this, SLOT(lockTab()));
connect(m_pBtnCheck, SIGNAL(clicked(bool)), m_pRegister, SLOT(onCheck()));
connect(model(), SIGNAL(modelChangedByOthers()), this,
SLOT(onRserverModelChanged()));
//
m_vconnectModel = QModelFactory::construct<QVConnectModel>(this);
connect(m_vconnectModel, SIGNAL(rserverModeChanged(qint32)), m_pRegister,
SLOT(onRServerModeChanged(qint32)));
connect(m_vconnectModel, SIGNAL(propertyChanged()), this,
SLOT(onVConnectModelChanged()));
m_registerModel = QModelFactory::constModel<QRegisterModel>(this);
connect(m_registerModel, SIGNAL(propertyChanged()), this,
SLOT(onRegisterModelChanged()));
//
m_loadVConncetServerConfigTimer.setInterval(1000);
m_loadVConncetServerConfigTimer.setSingleShot(true);
connect(&m_loadVConncetServerConfigTimer, SIGNAL(timeout()), this,
SLOT(onLoadVConncetServerConfig()));
}
void QRserverWidget::onVConnectModelChanged()
{
QGenericCommand genericCommand(this, QVConnectModel::CommandUpdateVConnectInfo,
"", QVariant(m_vconnectModel->toVariant()));
QVariant statusVar = issueCommand(genericCommand.toVariant(),
QVConnectModel::UpdateVConnectInfoTimeout * 2, "");
if (!statusVar.isNull()) {
QGenericStatus status(statusVar);
switch (status.commandStatus()) {
case QAbstractStatus::Succeed:
qprofileDebug(QtWarningMsg) <<
"update V-Connect info to engine successfully...";
break;
default:
break;
}
} else {
QTimer::singleShot(3000, this, SLOT(onVConnectModelChanged()));
}
}
void QRserverWidget::onRServerModeChanged()
{
lockTab(true);
QRserverModel *rserverModel = qobject_cast<QRserverModel *>(model());
rserverModel->initialDeviceStatus();
if (m_pBtnRServerMode->text() == TRANSLATE_STR_RSERVER_BTN_MODE_VCONNECT) {
/* ModeVConnect */
m_vconnectModel->setRserverMode(QVConnectModel::ModeVConnect);
m_pBtnRServerMode->setText(TRANSLATE_STR_RSERVER_BTN_MODE_RSERVER);
m_ptab->setTabEnabled(m_ptab->indexOf(m_pUploadWidget), true);
} else {
/* ModeRServer */
m_vconnectModel->setRserverMode(QVConnectModel::ModeRServer);
m_pBtnRServerMode->setText(TRANSLATE_STR_RSERVER_BTN_MODE_VCONNECT);
m_ptab->setTabEnabled(m_ptab->indexOf(m_pUploadWidget),
m_ptab->isTabEnabled(m_ptab->indexOf(m_pSoftwareWidget)));
//when bluetooth disconnected, lockTab was called first but ModeVConnect has not been changed.
}
}
void QRserverWidget::onRegisterModelChanged()
{
bool lastStatus = false;
QVConnectModel::RServerMode mode = m_vconnectModel->rserverMode();
if (mode == QVConnectModel::ModeRServer) {
lastStatus = m_vconnectModel->blockNotify(true);
}
m_vconnectModel->fromVariant(m_registerModel->toVariant());
if (mode == QVConnectModel::ModeRServer) {
m_vconnectModel->blockNotify(lastStatus);
}
}
void QRserverWidget::onDirectoryChanged(const QString &path)
{
QFileInfo vconncetServerConfig(QRserverEnvironment::VConncetServerConfig());
if (vconncetServerConfig.absolutePath() == path) {
qprofileDebug(QtWarningMsg) << "directory Changed.";
m_loadVConncetServerConfigTimer.start();
}
}
void QRserverWidget::onLoadVConncetServerConfig()
{
QBaseProgress *backProgress = getBackProgress();
if ((nullptr != backProgress && backProgress->isActive())
|| m_vconnectModel->serialNumber().isEmpty()) {
m_loadVConncetServerConfigTimer.start();
return;
}
qprofileDebug(QtWarningMsg) << "load V-Conncet Server Config";
static bool isVConnectValid = false;
QFileInfo vconncetServerConfig(QRserverEnvironment::VConncetServerConfig());
if (vconncetServerConfig.exists()) {
m_vconnectModel->fromFile(vconncetServerConfig.absoluteFilePath());
} else {
m_vconnectModel->setVconnectServerIp(QRegisterModel::InvalidIpAddress);
}
if (isVConnectValid != m_vconnectModel->isVConnectValid()) {
// TODO: hide for now
// m_pBtnRServerMode->setVisible(m_vconnectModel->isVConnectValid());
isVConnectValid = m_vconnectModel->isVConnectValid();
if (isVConnectValid) {
m_pBtnRServerMode->setText(TRANSLATE_STR_RSERVER_BTN_MODE_VCONNECT);
} else {
m_pBtnRServerMode->setText(TRANSLATE_STR_RSERVER_BTN_MODE_RSERVER);
}
QTimer::singleShot(0, this, SLOT(onRServerModeChanged()));
}
}
void QRserverWidget::onUploadWidgetTabChanged(int idx)
{
m_pBtnJob->setVisible(idx == QUploadWidget::RserverTabUploadResult);
m_pBtnUploadAndDel->setVisible(idx == QUploadWidget::RserverTabUploadResult);
m_uploadTabCurrentIdx = idx;
}
void QRserverWidget::onTabChange(int idx)
{
m_pBtnRegister->hide();
m_pBtnUnRegister->hide();
m_pBtnCheck->hide();
m_pBtnRServerMode->hide();
m_pBtnUpload->hide();
m_pBtnJob->hide();
m_pBtnUploadAndDel->hide();
m_pBtnDownload->hide();
m_pBtnUpgrade->hide();
m_pBtnUpdate->hide();
QRserverContainerWidget *tabWidget = dynamic_cast<QRserverContainerWidget *>
(m_ptab->widget(idx));
if (tabWidget == m_pRegister) {
m_pBtnRegister->show();
m_pBtnUnRegister->show();
m_pBtnCheck->show();
// TODO: hide for now
//m_pBtnRServerMode->setVisible(m_vconnectModel->isVConnectValid());
} else if (tabWidget == m_pUploadWidget) {
m_pBtnUpload->show();
const QRserverModel *rserverModel = QModelFactory::constModel<QRserverModel>
(this);
if (rserverModel->getChassis().isValid() && !rserverModel->supportProfile()) {
m_pBtnJob->setVisible(true);
m_pBtnUploadAndDel->setVisible(true);
} else {
m_pBtnJob->setVisible(m_uploadTabCurrentIdx ==
QUploadWidget::RserverTabUploadResult);
m_pBtnUploadAndDel->setVisible(m_uploadTabCurrentIdx ==
QUploadWidget::RserverTabUploadResult);
}
} else if (tabWidget == m_pDownloadWidget) {
m_pBtnDownload->show();
} else if (tabWidget == m_pSoftwareWidget) {
m_pBtnUpgrade->show();
}
}
void QRserverWidget::onIpcDisconnected()
{
lockTab(true);
QRserverMessageBox::Show(this, TRANSLATE_STR_RSERVER_WARNING,
TRANSLATE_STR_RSERVER_REGISTER_NETWORK_ERROR, QMessageBox::Ok);
QRserverContainerWidget::onIpcDisconnected();
}
void QRserverWidget::onNetworkError()
{
lockTab(true);
QRserverContainerWidget::onNetworkError();
QRserverModel *rserverModel = qobject_cast<QRserverModel *>(model());
rserverModel->initialDeviceStatus();
}
void QRserverWidget::translate(const QFont &font)
{
m_ptab->setTabText(m_ptab->indexOf(m_pRegister),
TRANSLATE_STR_RSERVER_TAB_REGISTER);
m_ptab->setTabText(m_ptab->indexOf(m_pUploadWidget),
TRANSLATE_STR_RSERVER_TAB_UPLOAD);
m_ptab->setTabText(m_ptab->indexOf(m_pSoftwareWidget),
TRANSLATE_STR_RSERVER_TAB_SOFTWARE);
m_pBtnRegister->setText(TRANSLATE_STR_RSERVER_BTN_REGISTER);
m_pBtnUnRegister->setText(TRANSLATE_STR_RSERVER_BTN_UNREGISTER);
m_pBtnCheck->setText(TRANSLATE_STR_RSERVER_BTN_CHECK);
if (m_vconnectModel->rserverMode() == QVConnectModel::ModeRServer) {
m_pBtnRServerMode->setText(TRANSLATE_STR_RSERVER_BTN_MODE_VCONNECT);
} else {
m_pBtnRServerMode->setText(TRANSLATE_STR_RSERVER_BTN_MODE_RSERVER);
}
m_pBtnUpload->setText(TRANSLATE_STR_RSERVER_BTN_UPLOAD);
m_pBtnJob->setText(TRANSLATE_STR_RSERVER_BTN_JOB);
m_pBtnUploadAndDel->setText(TRANSLATE_STR_RSERVER_BTN_UPLOAD_DEL);
m_pBtnDownload->setText(TRANSLATE_STR_RSERVER_BTN_DOWNLOAD);
m_pBtnUpgrade->setText(TRANSLATE_STR_RSERVER_BTN_UPGRADE);
m_pBtnUpdate->setText(TRANSLATE_STR_RSERVER_BTN_UPDATE);
m_pRegister->translate(font);
m_pUploadWidget->translate(font);
m_pSoftwareWidget->translate(font);
if (m_pDownloadWidget != nullptr) {
m_ptab->setTabText(m_ptab->indexOf(m_pDownloadWidget),
TRANSLATE_STR_RSERVER_TAB_DOWNLOAD);
m_pDownloadWidget->translate(font);
}
//
m_ptab->setFont(font);
m_pBtnRegister->setFont(font);
m_pBtnUnRegister->setFont(font);
m_pBtnCheck->setFont(font);
m_pBtnUpload->setFont(font);
m_pBtnJob->setFont(font);
m_pBtnUploadAndDel->setFont(font);
m_pBtnDownload->setFont(font);
m_pBtnUpgrade->setFont(font);
m_pBtnUpdate->setFont(font);
}
void QRserverWidget::onRserverModelChanged()
{
QRserverModel *rserverModel = qobject_cast<QRserverModel *>(model());
if (rserverModel->getChassis().isValid()) {
if (!rserverModel->supportProfile()) {
m_ptab->removeTab(m_ptab->indexOf(m_pDownloadWidget));
delete m_pDownloadWidget;
m_pDownloadWidget = nullptr;
}
m_ptab->setStyleSheet(QString("QTabBar::tab{width:%1px;}").arg(
m_ptab->width() / m_ptab->count()));
QDeviceInfo::Style style = rserverModel->getStyle();
static QDeviceInfo::Style lastStyle = QDeviceInfo::DefaultStyle;
if ((QDeviceInfo::FX150LStyle == style) && (lastStyle != style)) {
m_pBtLayout->insertSpacing(0, 50);
}
lastStyle = style;
disconnect(rserverModel, SIGNAL(propertyChanged()), this,
SLOT(onRserverModelChanged()));
//
bool lastStatus = m_vconnectModel->blockNotify(true);
m_vconnectModel->fromVariant(rserverModel->getChassis());
m_vconnectModel->blockNotify(lastStatus);
//
QFileInfo vconncetServerConfig(QRserverEnvironment::VConncetServerConfig());
if (vconncetServerConfig.exists()
&& !m_loadVConncetServerConfigTimer.isActive()) {
m_loadVConncetServerConfigTimer.start();
}
}
}
bool QRserverWidget::isTopWidget()
{
return true;
}
void QRserverWidget::onRegisterButtonClicked()
{
if (isTechNameCanBeChanged()) {
emit updateTechName();
} else {
lockTab();
QRserverModel *rserverModel = qobject_cast<QRserverModel *>(model());
rserverModel->initialDeviceStatus();
emit registerRserver();
}
}
bool QRserverWidget::isTechNameCanBeChanged()
{
QRserverModel *rserverModel = qobject_cast<QRserverModel *>(model());
return (isCompatible(QRserverCompatibility518::FeatureUpdateTechName) &&
QAdminSettingProfile::Instance()->isTechNameCanBeChanged() &&
(QDeviceInfo::RegisteredAuthorized ==
QRserverModel::GetDeviceStatus(*rserverModel))
);
}
QRserverWidget::~QRserverWidget()
{
}
| 36.734349 | 107 | 0.690327 | c6supper |