blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 905
values | visit_date timestamp[us]date 2015-08-09 11:21:18 2023-09-06 10:45:07 | revision_date timestamp[us]date 1997-09-14 05:04:47 2023-09-17 19:19:19 | committer_date timestamp[us]date 1997-09-14 05:04:47 2023-09-06 06:22:19 | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us]date 2012-06-07 00:51:45 2023-09-14 21:58:39 ⌀ | gha_created_at timestamp[us]date 2008-03-27 23:40:48 2023-08-21 23:17:38 ⌀ | gha_language stringclasses 141
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 10.4M | extension stringclasses 115
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f5fd7a6b7c0c7621ae9bb5627850dc9ab41d5021 | 19f93e66f97eb6f3387a38505119f8a7c87e2361 | /Trabalho/Processo.cpp | b85f0ad6f81b12a7e368c039b9727de655962faf | [] | no_license | juliamellolopes/Problema11 | 22d04a10fc044dc9af50d1f7b072a1a14e792bde | 8af08e509e69159c8776c4c55fef9a1ecd920f9d | refs/heads/main | 2023-06-18T02:55:36.793813 | 2021-07-11T16:03:18 | 2021-07-11T16:03:18 | 377,811,574 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 400 | cpp | #include "Processo.hpp"
Processo::Processo(){
setId(0);
setPage(0);
setValor(-1);
}
void Processo::setId(int id){
this->id = id;
}
void Processo::setPage(int page){
this->page = page;
}
void Processo::setValor(int valor){
this->valor = valor;
}
int Processo::getId(){
return this->id;
}
int Processo::getPage(){
return this->page;
}
int Processo::getValor(){
return this->valor;
}
| [
"juliamellolopesgoncalves@gmail.com"
] | juliamellolopesgoncalves@gmail.com |
6674d6b5047ce1a2e4d387c912adb5daa8841a8f | 5a216ce02d3618fe6d527856b61b09bd135bf193 | /Voxel-Trace/Source/Voxtrace.h | af67a5adc39d6173c2177d6e81a1dd1c46d97984 | [
"MIT"
] | permissive | JuanDiegoMontoya/Voxel-Trace | e99aeaa224b6e7dee021bb6d91a1080c151a2dae | ea4c80c8a33698269b84b6332ab78694b8d262be | refs/heads/master | 2023-06-22T03:30:31.284549 | 2023-06-14T11:21:50 | 2023-06-14T11:21:50 | 247,860,347 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 526 | h | #pragma once
namespace Voxels
{
void Init();
void InitGLStuff();
void InitBlocks();
void Render();
void CameraRaySnapshot();
int& ShadowRays();
struct Block
{
Block() = default;
Block(glm::vec3 d, float a, float in)
: diffuse(d), alpha(a), n(in) {}
glm::vec3 diffuse = { 1, 1, 1 };
float alpha = 0;
float n = 1.5f; // index of refraction
bool reflect = false;
bool refract = false;
};
struct Light
{
glm::vec3 position{ -10, 5, 5 };
float radius{ .5f };
};
} | [
"jake.ryan@digipen.edu"
] | jake.ryan@digipen.edu |
51e1d0fb76d0faefb821bfbbff5276a91252230c | 4f379408fc94e7bea37c8ed47b991ed1d627b9e2 | /kml.hpp | 2fe1cb3c6d02928445c0a9f82dae454126452108 | [] | no_license | joongsim/Image-Mapper | 69fe1de385001089e0f46ecac98eabe0f22b38ca | eec09a1b02457fa9e2ea2a1a3578839709ea2f1a | refs/heads/master | 2020-12-02T19:28:18.932171 | 2017-09-21T16:41:25 | 2017-09-21T16:41:25 | 96,346,592 | 0 | 0 | null | 2017-09-21T01:02:20 | 2017-07-05T17:54:30 | C++ | UTF-8 | C++ | false | false | 264 | hpp | //
// kml.hpp
// proj
//
// Created by Andrey Losev on 7/25/17.
// Copyright © 2017 Andrey Losev. All rights reserved.
//
#ifndef kml_h
#define kml_h
#include <string>
#include "linklt.hpp"
void writekml(const std::string&, listnode*);
#endif /* kml_h */
| [
"andreylosev@gmail.com"
] | andreylosev@gmail.com |
275f0766b9d2a1801b3320b6ddac68f4db3dfdd2 | 4cfffadf68a2b9b7bddba042c7afee49a2bb0ebd | /src/qt/optionsmodel.cpp | ab388856f22a328221e404553814f51b9fe1ed09 | [
"MIT"
] | permissive | plusevcoin/plusevcoin | 9885bf1a6a77c07ce0b69a96e7351ace15fb5b9d | 857d92913b34d36359af3f601e3ff56b2532cc02 | refs/heads/master | 2020-05-19T19:52:03.686282 | 2014-04-15T18:58:29 | 2014-04-17T22:40:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,521 | cpp | #include "optionsmodel.h"
#include "bitcoinunits.h"
#include <QSettings>
#include "init.h"
#include "walletdb.h"
#include "guiutil.h"
OptionsModel::OptionsModel(QObject *parent) :
QAbstractListModel(parent)
{
Init();
}
bool static ApplyProxySettings()
{
QSettings settings;
CService addrProxy(settings.value("addrProxy", "127.0.0.1:9050").toString().toStdString());
int nSocksVersion(settings.value("nSocksVersion", 5).toInt());
if (!settings.value("fUseProxy", false).toBool()) {
addrProxy = CService();
nSocksVersion = 0;
return false;
}
if (nSocksVersion && !addrProxy.IsValid())
return false;
if (!IsLimited(NET_IPV4))
SetProxy(NET_IPV4, addrProxy, nSocksVersion);
if (nSocksVersion > 4) {
#ifdef USE_IPV6
if (!IsLimited(NET_IPV6))
SetProxy(NET_IPV6, addrProxy, nSocksVersion);
#endif
SetNameProxy(addrProxy, nSocksVersion);
}
return true;
}
void OptionsModel::Init()
{
QSettings settings;
// These are Qt-only settings:
nDisplayUnit = settings.value("nDisplayUnit", BitcoinUnits::PEV).toInt();
bDisplayAddresses = settings.value("bDisplayAddresses", false).toBool();
fMinimizeToTray = settings.value("fMinimizeToTray", false).toBool();
fMinimizeOnClose = settings.value("fMinimizeOnClose", false).toBool();
nTransactionFee = settings.value("nTransactionFee").toLongLong();
language = settings.value("language", "").toString();
// These are shared with core Bitcoin; we want
// command-line options to override the GUI settings:
if (settings.contains("addrProxy") && settings.value("fUseProxy").toBool())
SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString());
if (settings.contains("nSocksVersion") && settings.value("fUseProxy").toBool())
SoftSetArg("-socks", settings.value("nSocksVersion").toString().toStdString());
if (settings.contains("detachDB"))
SoftSetBoolArg("-detachdb", settings.value("detachDB").toBool());
if (!language.isEmpty())
SoftSetArg("-lang", language.toStdString());
}
bool OptionsModel::Upgrade()
{
QSettings settings;
if (settings.contains("bImportFinished"))
return false; // Already upgraded
settings.setValue("bImportFinished", true);
// Move settings from old wallet.dat (if any):
CWalletDB walletdb("wallet.dat");
QList<QString> intOptions;
intOptions << "nDisplayUnit" << "nTransactionFee";
foreach(QString key, intOptions)
{
int value = 0;
if (walletdb.ReadSetting(key.toStdString(), value))
{
settings.setValue(key, value);
walletdb.EraseSetting(key.toStdString());
}
}
QList<QString> boolOptions;
boolOptions << "bDisplayAddresses" << "fMinimizeToTray" << "fMinimizeOnClose" << "fUseProxy" ;
foreach(QString key, boolOptions)
{
bool value = false;
if (walletdb.ReadSetting(key.toStdString(), value))
{
settings.setValue(key, value);
walletdb.EraseSetting(key.toStdString());
}
}
try
{
CAddress addrProxyAddress;
if (walletdb.ReadSetting("addrProxy", addrProxyAddress))
{
settings.setValue("addrProxy", addrProxyAddress.ToStringIPPort().c_str());
walletdb.EraseSetting("addrProxy");
}
}
catch (std::ios_base::failure &e)
{
// 0.6.0rc1 saved this as a CService, which causes failure when parsing as a CAddress
CService addrProxy;
if (walletdb.ReadSetting("addrProxy", addrProxy))
{
settings.setValue("addrProxy", addrProxy.ToStringIPPort().c_str());
walletdb.EraseSetting("addrProxy");
}
}
ApplyProxySettings();
Init();
return true;
}
int OptionsModel::rowCount(const QModelIndex & parent) const
{
return OptionIDRowCount;
}
QVariant OptionsModel::data(const QModelIndex & index, int role) const
{
if(role == Qt::EditRole)
{
QSettings settings;
switch(index.row())
{
case StartAtStartup:
return QVariant(GUIUtil::GetStartOnSystemStartup());
case MinimizeToTray:
return QVariant(fMinimizeToTray);
case MinimizeOnClose:
return QVariant(fMinimizeOnClose);
case ProxyUse:
return settings.value("fUseProxy", false);
case ProxyIP: {
CService addrProxy;
if (GetProxy(NET_IPV4, addrProxy))
return QVariant(QString::fromStdString(addrProxy.ToStringIP()));
else
return QVariant(QString::fromStdString("127.0.0.1"));
}
case ProxyPort: {
CService addrProxy;
if (GetProxy(NET_IPV4, addrProxy))
return QVariant(addrProxy.GetPort());
else
return 9050;
}
case ProxySocksVersion:
return settings.value("nSocksVersion", 5);
case Fee:
return QVariant(nTransactionFee);
case DisplayUnit:
return QVariant(nDisplayUnit);
case DisplayAddresses:
return QVariant(bDisplayAddresses);
case DetachDatabases:
return QVariant(bitdb.GetDetach());
case Language:
return settings.value("language", "");
default:
return QVariant();
}
}
return QVariant();
}
bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role)
{
bool successful = true; /* set to false on parse error */
if(role == Qt::EditRole)
{
QSettings settings;
switch(index.row())
{
case StartAtStartup:
successful = GUIUtil::SetStartOnSystemStartup(value.toBool());
break;
case MinimizeToTray:
fMinimizeToTray = value.toBool();
settings.setValue("fMinimizeToTray", fMinimizeToTray);
break;
case MinimizeOnClose:
fMinimizeOnClose = value.toBool();
settings.setValue("fMinimizeOnClose", fMinimizeOnClose);
break;
case ProxyUse:
settings.setValue("fUseProxy", value.toBool());
ApplyProxySettings();
break;
case ProxyIP:
{
CService addrProxy("127.0.0.1", 9050);
GetProxy(NET_IPV4, addrProxy);
CNetAddr addr(value.toString().toStdString());
addrProxy.SetIP(addr);
settings.setValue("addrProxy", addrProxy.ToStringIPPort().c_str());
successful = ApplyProxySettings();
}
break;
case ProxyPort:
{
CService addrProxy("127.0.0.1", 9050);
GetProxy(NET_IPV4, addrProxy);
addrProxy.SetPort(value.toInt());
settings.setValue("addrProxy", addrProxy.ToStringIPPort().c_str());
successful = ApplyProxySettings();
}
break;
case ProxySocksVersion:
settings.setValue("nSocksVersion", value.toInt());
ApplyProxySettings();
break;
case Fee:
nTransactionFee = value.toLongLong();
settings.setValue("nTransactionFee", nTransactionFee);
break;
case DisplayUnit:
nDisplayUnit = value.toInt();
settings.setValue("nDisplayUnit", nDisplayUnit);
emit displayUnitChanged(nDisplayUnit);
break;
case DisplayAddresses:
bDisplayAddresses = value.toBool();
settings.setValue("bDisplayAddresses", bDisplayAddresses);
break;
case DetachDatabases: {
bool fDetachDB = value.toBool();
bitdb.SetDetach(fDetachDB);
settings.setValue("detachDB", fDetachDB);
}
break;
case Language:
settings.setValue("language", value);
break;
default:
break;
}
}
emit dataChanged(index, index);
return successful;
}
qint64 OptionsModel::getTransactionFee()
{
return nTransactionFee;
}
bool OptionsModel::getMinimizeToTray()
{
return fMinimizeToTray;
}
bool OptionsModel::getMinimizeOnClose()
{
return fMinimizeOnClose;
}
int OptionsModel::getDisplayUnit()
{
return nDisplayUnit;
}
bool OptionsModel::getDisplayAddresses()
{
return bDisplayAddresses;
}
| [
"plusevcoindev@gmail.com"
] | plusevcoindev@gmail.com |
49c7e145557779933374047d5bad6898791d85e3 | aa3c9133e336aabfc9d94f6d3cba45f166a2b702 | /src/emulation/Operations/NOP.cpp | fc9ba8e1cea466045af410f2244d32f1d5c7d501 | [
"Unlicense"
] | permissive | ZachClayburn/Zemu2 | 525aca9e09b9c0d5cd1d5e84f383191932c0bfa6 | 1548366e8ff92fb698344c93f3f7664d22a2a95e | refs/heads/master | 2023-01-20T10:29:44.274791 | 2020-11-28T23:31:07 | 2020-11-28T23:31:07 | 260,224,181 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 123 | cpp | #include "NOP.h"
NOP::NOP() : Operation(LENGTH) {}
interimValue_t NOP::operator()(interimValue_t value) { return value; }
| [
"zachclayburn@gmail.com"
] | zachclayburn@gmail.com |
3f4d1d68fcf82d3242ff503a7f8c6969b1f43e77 | 73fada0864303e0872d9bac93d8c63de0914b085 | /testes_merge.cpp | 9a9f4466e4a039b8f80d7b54512c2604272a5a3d | [] | no_license | 1ELE705-UEL-2018/Lab8_Testes | e6bc81f4ce8c00dbc9e310d473a95e542e09a294 | e8623cf02937aab3763a6d038820625865f22176 | refs/heads/master | 2020-04-07T17:30:17.788028 | 2018-11-21T15:51:07 | 2018-11-21T15:51:07 | 158,572,050 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,114 | cpp | #include "gtest/gtest.h"
#include "aux_test_functions.h"
extern "C"
{
#include "lab8.h"
}
TEST(merge, A_B_Vazios)
{
merge(NULL, NULL, 0, NULL, 0);
}
TEST(merge, A_UmElemento_B_Vazio)
{
int A[1] = { 0 };
int C_depois[1] = { 0 };
int C[sizeof(C_depois)/sizeof(int)];
merge(C, A, sizeof(A)/sizeof(int), NULL, 0);
ASSERT_TRUE(ArraysMatch(C_depois, C));
}
TEST(merge, A_DoisElementos_B_Vazio)
{
int A[2] = { 0, 1 };
int C_depois[2] = { 0, 1 };
int C[sizeof(C_depois)/sizeof(int)];
merge(C, A, sizeof(A)/sizeof(int), NULL, 0);
ASSERT_TRUE(ArraysMatch(C_depois, C));
}
TEST(merge, A_Vazio_B_UmElemento)
{
int B[1] = { 0 };
int C_depois[1] = { 0 };
int C[sizeof(C_depois)/sizeof(int)];
merge(C, NULL, 0, B, sizeof(B)/sizeof(int));
ASSERT_TRUE(ArraysMatch(C_depois, C));
}
TEST(merge, A_Vazio_B_DoisElementos)
{
int B[2] = { 0, 1 };
int C_depois[2] = { 0, 1 };
int C[sizeof(C_depois)/sizeof(int)];
merge(C, NULL, 0, B, sizeof(B)/sizeof(int));
ASSERT_TRUE(ArraysMatch(C_depois, C));
}
TEST(merge, A_UmElemento_B_UmElemento_A0B0)
{
int A[1] = { 0 };
int B[1] = { 1 };
int C_depois[(sizeof(A)+sizeof(B))/sizeof(int)] = { 0, 1 };
int C[sizeof(C_depois)/sizeof(int)];
merge(C, A, sizeof(A)/sizeof(int), B, sizeof(B)/sizeof(int));
ASSERT_TRUE(ArraysMatch(C_depois, C));
}
TEST(merge, A_UmElemento_B_UmElemento_B0A0)
{
int A[1] = { 1 };
int B[1] = { 0 };
int C_depois[(sizeof(A)+sizeof(B))/sizeof(int)] = { 0, 1 };
int C[sizeof(C_depois)/sizeof(int)];
merge(C, A, sizeof(A)/sizeof(int), B, sizeof(B)/sizeof(int));
ASSERT_TRUE(ArraysMatch(C_depois, C));
}
TEST(merge, A_DoisElementos_B_UmElemento_A0B0A1)
{
int A[2] = { 0, 2 };
int B[1] = { 1 };
int C_depois[(sizeof(A)+sizeof(B))/sizeof(int)] = { 0, 1, 2 };
int C[sizeof(C_depois)/sizeof(int)];
merge(C, A, sizeof(A)/sizeof(int), B, sizeof(B)/sizeof(int));
ASSERT_TRUE(ArraysMatch(C_depois, C));
}
TEST(merge, A_DoisElementos_B_UmElemento_A0A1B0)
{
int A[2] = { 0, 1 };
int B[1] = { 2 };
int C_depois[(sizeof(A)+sizeof(B))/sizeof(int)] = { 0, 1, 2 };
int C[sizeof(C_depois)/sizeof(int)];
merge(C, A, sizeof(A)/sizeof(int), B, sizeof(B)/sizeof(int));
ASSERT_TRUE(ArraysMatch(C_depois, C));
}
TEST(merge, A_UmElemento_B_DoisElementos_B0A0B1)
{
int A[1] = { 1 };
int B[2] = { 0, 2 };
int C_depois[(sizeof(A)+sizeof(B))/sizeof(int)] = { 0, 1, 2 };
int C[sizeof(C_depois)/sizeof(int)];
merge(C, A, sizeof(A)/sizeof(int), B, sizeof(B)/sizeof(int));
ASSERT_TRUE(ArraysMatch(C_depois, C));
}
TEST(merge, A_UmElemento_B_DoisElementos_B0B1A0A0)
{
int A[1] = { 2 };
int B[2] = { 0, 1 };
int C_depois[(sizeof(A)+sizeof(B))/sizeof(int)] = { 0, 1, 2 };
int C[sizeof(C_depois)/sizeof(int)];
merge(C, A, sizeof(A)/sizeof(int), B, sizeof(B)/sizeof(int));
ASSERT_TRUE(ArraysMatch(C_depois, C));
}
TEST(merge, A_DoisElementos_B_DoisElementos_A0B0B1A1)
{
int A[2] = { 0, 3 };
int B[2] = { 1, 2 };
int C_depois[(sizeof(A)+sizeof(B))/sizeof(int)] = { 0, 1, 2, 3 };
int C[sizeof(C_depois)/sizeof(int)];
merge(C, A, sizeof(A)/sizeof(int), B, sizeof(B)/sizeof(int));
ASSERT_TRUE(ArraysMatch(C_depois, C));
} | [
"decio@decpp.net"
] | decio@decpp.net |
5d5bf98c04174b02976e0438e7258c5a47f568fd | 35ea42225d973e7d79a28b3a3147611d61dbeffd | /Assignment2/Assignment2/main.cpp | 61c5d2960af11337abc69ca8d4261a0fb06ff430 | [] | no_license | Nathan-Dunne/Console-Based-Shooter | 83b87c8bb8c0c89e24db4f7846c14a0c559b8005 | 18222e0ecb5c7a3d3ed41d973f57ca5e574327f4 | refs/heads/master | 2020-05-29T10:13:09.939156 | 2019-05-28T19:23:19 | 2019-05-28T19:23:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,619 | cpp | #define _CRT_SECURE_NO_WARNINGS
#include "Game.h"
#include "SDL.h"
#include "SoundManager.h"
#include <Windows.h>
using namespace std;
const int FPS = 10;
const int DELAY_TIME = 1000.0f / FPS;
int main(int argc, char **argv)
{
srand(time(NULL)); // Seed random.
SDL_Init(SDL_INIT_EVERYTHING); // Initialise all of the SDL components
std::cout << "Attempting to init simulation...\n";
Uint32 frameStart, frameTime;
if (TheGame::Instance()->init())
{
while (TheGame::Instance()->isRunning()) // While the game state is in active play.
{
frameStart = SDL_GetTicks();
TheGame::Instance()->update(); // Update the entities of the world
TheGame::Instance()->battle(); // Resolve battle between enemy and player
TheGame::Instance()->clean(); // Clean up anything that has died
frameTime = SDL_GetTicks() - frameStart;
// If we haven't travelled far through the sands of time
if (frameTime < DELAY_TIME)
{
SDL_Delay((int)(DELAY_TIME - frameTime));
}
}
string repeatPlayInput = "";
}
else
{
std::cout << "game init failure - " << "\n";
return -1;
}
std::cout << "\n Game closing...\n";
TheGame::Instance()->clean(); // Clean up any remaining objects.
cout << "\n\n\tPlease press Start to exit..." << endl;
cout << "\t";
// Wait until the player has pressed start.
while (!TheInputHandler::Instance()->isButtonDown(SDL_CONTROLLER_BUTTON_START))
{
TheInputHandler::Instance()->update();
}
cout << "\n\t\tThanks for playing!\n\n" << endl;
cout << "\nExiting Z++ Industries Simulation Program..." << endl;
Sleep(3400);
return 0;
} | [
"1nathandunne1@gmail.com"
] | 1nathandunne1@gmail.com |
e2f8407e25f61dc5f5e62a6dfc7c2aafa1743a1a | 836a1641cd140a114687c8fb3517c18d001e6894 | /src/server/game/Entities/Creature/GossipDef.cpp | 0233eb746462a621854ba8998429bd84b677a440 | [] | no_license | Abyssking/AtomicCore-3.3.5a | 01dac623e253c32a9c07e252c30a1fb33e5d125a | 12e48b4dd68c672356d00e993605f8a84298a13a | refs/heads/master | 2021-01-15T23:21:04.432359 | 2013-05-16T01:03:45 | 2013-05-16T01:03:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 27,607 | cpp | /*
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "QuestDef.h"
#include "GossipDef.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "Formulas.h"
GossipMenu::GossipMenu()
{
_menuId = 0;
}
GossipMenu::~GossipMenu()
{
ClearMenu();
}
void GossipMenu::AddMenuItem(int32 menuItemId, uint8 icon, std::string const& message, uint32 sender, uint32 action, std::string const& boxMessage, uint32 boxMoney, bool coded /*= false*/)
{
ASSERT(_menuItems.size() <= GOSSIP_MAX_MENU_ITEMS);
// Find a free new id - script case
if (menuItemId == -1)
{
menuItemId = 0;
if (!_menuItems.empty())
{
for (GossipMenuItemContainer::const_iterator itr = _menuItems.begin(); itr != _menuItems.end(); ++itr)
{
if (int32(itr->first) > menuItemId)
break;
menuItemId = itr->first + 1;
}
}
}
GossipMenuItem& menuItem = _menuItems[menuItemId];
menuItem.MenuItemIcon = icon;
menuItem.Message = message;
menuItem.IsCoded = coded;
menuItem.Sender = sender;
menuItem.OptionType = action;
menuItem.BoxMessage = boxMessage;
menuItem.BoxMoney = boxMoney;
}
void GossipMenu::AddGossipMenuItemData(uint32 menuItemId, uint32 gossipActionMenuId, uint32 gossipActionPoi)
{
GossipMenuItemData& itemData = _menuItemData[menuItemId];
itemData.GossipActionMenuId = gossipActionMenuId;
itemData.GossipActionPoi = gossipActionPoi;
}
uint32 GossipMenu::GetMenuItemSender(uint32 menuItemId) const
{
GossipMenuItemContainer::const_iterator itr = _menuItems.find(menuItemId);
if (itr == _menuItems.end())
return 0;
return itr->second.Sender;
}
uint32 GossipMenu::GetMenuItemAction(uint32 menuItemId) const
{
GossipMenuItemContainer::const_iterator itr = _menuItems.find(menuItemId);
if (itr == _menuItems.end())
return 0;
return itr->second.OptionType;
}
bool GossipMenu::IsMenuItemCoded(uint32 menuItemId) const
{
GossipMenuItemContainer::const_iterator itr = _menuItems.find(menuItemId);
if (itr == _menuItems.end())
return false;
return itr->second.IsCoded;
}
void GossipMenu::ClearMenu()
{
_menuItems.clear();
_menuItemData.clear();
}
PlayerMenu::PlayerMenu(WorldSession* session) : _session(session)
{
}
PlayerMenu::~PlayerMenu()
{
ClearMenus();
}
void PlayerMenu::ClearMenus()
{
_gossipMenu.ClearMenu();
_questMenu.ClearMenu();
}
void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
{
WorldPacket data(SMSG_GOSSIP_MESSAGE, 100); // guess size
data << uint64(objectGUID);
data << uint32(_gossipMenu.GetMenuId()); // new 2.4.0
data << uint32(titleTextId);
data << uint32(_gossipMenu.GetMenuItemCount()); // max count 0x10
for (GossipMenuItemContainer::const_iterator itr = _gossipMenu.GetMenuItems().begin(); itr != _gossipMenu.GetMenuItems().end(); ++itr)
{
GossipMenuItem const& item = itr->second;
data << uint32(itr->first);
data << uint8(item.MenuItemIcon);
data << uint8(item.IsCoded); // makes pop up box password
data << uint32(item.BoxMoney); // money required to open menu, 2.0.3
data << item.Message; // text for gossip item
data << item.BoxMessage; // accept text (related to money) pop up box, 2.0.3
}
data << uint32(_questMenu.GetMenuItemCount()); // max count 0x20
for (uint32 iI = 0; iI < _questMenu.GetMenuItemCount(); ++iI)
{
QuestMenuItem const& item = _questMenu.GetItem(iI);
uint32 questID = item.QuestId;
Quest const* quest = sObjectMgr->GetQuestTemplate(questID);
data << uint32(questID);
data << uint32(item.QuestIcon);
data << int32(quest->GetQuestLevel());
data << uint32(quest->GetFlags()); // 3.3.3 quest flags
data << uint8(0); // 3.3.3 changes icon: blue question or yellow exclamation
std::string title = quest->GetTitle();
int locale = _session->GetSessionDbLocaleIndex();
if (locale >= 0)
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID))
ObjectMgr::GetLocaleString(localeData->Title, locale, title);
data << title; // max 0x200
}
_session->SendPacket(&data);
}
void PlayerMenu::SendCloseGossip() const
{
WorldPacket data(SMSG_GOSSIP_COMPLETE, 0);
_session->SendPacket(&data);
}
void PlayerMenu::SendPointOfInterest(uint32 poiId) const
{
PointOfInterest const* poi = sObjectMgr->GetPointOfInterest(poiId);
if (!poi)
{
sLog->outErrorDb("Request to send non-existing POI (Id: %u), ignored.", poiId);
return;
}
std::string iconText = poi->icon_name;
int32 locale = _session->GetSessionDbLocaleIndex();
if (locale >= 0)
if (PointOfInterestLocale const* localeData = sObjectMgr->GetPointOfInterestLocale(poiId))
ObjectMgr::GetLocaleString(localeData->IconName, locale, iconText);
WorldPacket data(SMSG_GOSSIP_POI, 4 + 4 + 4 + 4 + 4 + 10); // guess size
data << uint32(poi->flags);
data << float(poi->x);
data << float(poi->y);
data << uint32(poi->icon);
data << uint32(poi->data);
data << iconText;
_session->SendPacket(&data);
}
/*********************************************************/
/*** QUEST SYSTEM ***/
/*********************************************************/
QuestMenu::QuestMenu()
{
_questMenuItems.reserve(16); // can be set for max from most often sizes to speedup push_back and less memory use
}
QuestMenu::~QuestMenu()
{
ClearMenu();
}
void QuestMenu::AddMenuItem(uint32 QuestId, uint8 Icon)
{
if (!sObjectMgr->GetQuestTemplate(QuestId))
return;
ASSERT(_questMenuItems.size() <= GOSSIP_MAX_MENU_ITEMS);
QuestMenuItem questMenuItem;
questMenuItem.QuestId = QuestId;
questMenuItem.QuestIcon = Icon;
_questMenuItems.push_back(questMenuItem);
}
bool QuestMenu::HasItem(uint32 questId) const
{
for (QuestMenuItemList::const_iterator i = _questMenuItems.begin(); i != _questMenuItems.end(); ++i)
if (i->QuestId == questId)
return true;
return false;
}
void QuestMenu::ClearMenu()
{
_questMenuItems.clear();
}
void PlayerMenu::SendQuestGiverQuestList(QEmote eEmote, const std::string& Title, uint64 npcGUID)
{
WorldPacket data(SMSG_QUESTGIVER_QUEST_LIST, 100); // guess size
data << uint64(npcGUID);
data << Title;
data << uint32(eEmote._Delay); // player emote
data << uint32(eEmote._Emote); // NPC emote
size_t count_pos = data.wpos();
data << uint8 (_questMenu.GetMenuItemCount());
uint32 count = 0;
for (; count < _questMenu.GetMenuItemCount(); ++count)
{
QuestMenuItem const& qmi = _questMenu.GetItem(count);
uint32 questID = qmi.QuestId;
if (Quest const* quest = sObjectMgr->GetQuestTemplate(questID))
{
std::string title = quest->GetTitle();
int loc_idx = _session->GetSessionDbLocaleIndex();
if (loc_idx >= 0)
if (QuestLocale const* ql = sObjectMgr->GetQuestLocale(questID))
ObjectMgr::GetLocaleString(ql->Title, loc_idx, title);
data << uint32(questID);
data << uint32(qmi.QuestIcon);
data << int32(quest->GetQuestLevel());
data << uint32(quest->GetFlags()); // 3.3.3 quest flags
data << uint8(0); // 3.3.3 changes icon: blue question or yellow exclamation
data << title;
}
}
data.put<uint8>(count_pos, count);
_session->SendPacket(&data);
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u", GUID_LOPART(npcGUID));
}
void PlayerMenu::SendQuestGiverStatus(uint8 questStatus, uint64 npcGUID) const
{
WorldPacket data(SMSG_QUESTGIVER_STATUS, 9);
data << uint64(npcGUID);
data << uint8(questStatus);
_session->SendPacket(&data);
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u", GUID_LOPART(npcGUID), questStatus);
}
void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, bool activateAccept) const
{
std::string questTitle = quest->GetTitle();
std::string questDetails = quest->GetDetails();
std::string questObjectives = quest->GetObjectives();
std::string questEndText = quest->GetEndText();
int32 locale = _session->GetSessionDbLocaleIndex();
if (locale >= 0)
{
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
{
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails);
ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives);
ObjectMgr::GetLocaleString(localeData->EndText, locale, questEndText);
}
}
WorldPacket data(SMSG_QUESTGIVER_QUEST_DETAILS, 100); // guess size
data << uint64(npcGUID);
data << uint64(0); // wotlk, something todo with quest sharing?
data << uint32(quest->GetQuestId());
data << questTitle;
data << questDetails;
data << questObjectives;
data << uint8(activateAccept ? 1 : 0); // auto finish
data << uint32(quest->GetFlags()); // 3.3.3 questFlags
data << uint32(quest->GetSuggestedPlayers());
data << uint8(0); // IsFinished? value is sent back to server in quest accept packet
if (quest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS))
{
data << uint32(0); // Rewarded chosen items hidden
data << uint32(0); // Rewarded items hidden
data << uint32(0); // Rewarded money hidden
data << uint32(0); // Rewarded XP hidden
}
else
{
data << uint32(quest->GetRewChoiceItemsCount());
for (uint32 i=0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
{
if (!quest->RewardChoiceItemId[i])
continue;
data << uint32(quest->RewardChoiceItemId[i]);
data << uint32(quest->RewardChoiceItemCount[i]);
if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[i]))
data << uint32(itemTemplate->DisplayInfoID);
else
data << uint32(0x00);
}
data << uint32(quest->GetRewItemsCount());
for (uint32 i=0; i < QUEST_REWARDS_COUNT; ++i)
{
if (!quest->RewardItemId[i])
continue;
data << uint32(quest->RewardItemId[i]);
data << uint32(quest->RewardItemIdCount[i]);
if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardItemId[i]))
data << uint32(itemTemplate->DisplayInfoID);
else
data << uint32(0);
}
data << uint32(quest->GetRewOrReqMoney());
data << uint32(quest->XPValue(_session->GetPlayer()) * sWorld->getRate(RATE_XP_QUEST) * (IsEventActive(sWorld->getIntConfig(CONFIG_RATE_XP_WEEKEND_EVID)) ? sWorld->getRate(RATE_XP_WEEKEND_QUEST) : 1.0f));
}
// rewarded honor points. Multiply with 10 to satisfy client
data << 10 * Trinity::Honor::hk_honor_at_level(_session->GetPlayer()->getLevel(), quest->GetRewHonorMultiplier());
data << float(0.0f); // new 3.3.0, honor multiplier?
data << uint32(quest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast == 0)
data << int32(quest->GetRewSpellCast()); // casted spell
data << uint32(quest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
data << uint32(quest->GetBonusTalents()); // bonus talents
data << uint32(quest->GetRewArenaPoints()); // reward arena points
data << uint32(0); // unk
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
data << uint32(quest->RewardFactionId[i]);
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
data << int32(quest->RewardFactionValueId[i]);
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
data << int32(quest->RewardFactionValueIdOverride[i]);
data << uint32(QUEST_EMOTE_COUNT);
for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i)
{
data << uint32(quest->DetailsEmote[i]);
data << uint32(quest->DetailsEmoteDelay[i]); // DetailsEmoteDelay (in ms)
}
_session->SendPacket(&data);
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId());
}
void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
{
std::string questTitle = quest->GetTitle();
std::string questDetails = quest->GetDetails();
std::string questObjectives = quest->GetObjectives();
std::string questEndText = quest->GetEndText();
std::string questCompletedText = quest->GetCompletedText();
std::string questObjectiveText[QUEST_OBJECTIVES_COUNT];
for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
questObjectiveText[i] = quest->ObjectiveText[i];
int32 locale = _session->GetSessionDbLocaleIndex();
if (locale >= 0)
{
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
{
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails);
ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives);
ObjectMgr::GetLocaleString(localeData->EndText, locale, questEndText);
ObjectMgr::GetLocaleString(localeData->CompletedText, locale, questCompletedText);
for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
ObjectMgr::GetLocaleString(localeData->ObjectiveText[i], locale, questObjectiveText[i]);
}
}
WorldPacket data(SMSG_QUEST_QUERY_RESPONSE, 100); // guess size
data << uint32(quest->GetQuestId()); // quest id
data << uint32(quest->GetQuestMethod()); // Accepted values: 0, 1 or 2. 0 == IsAutoComplete() (skip objectives/details)
data << uint32(quest->GetQuestLevel()); // may be -1, static data, in other cases must be used dynamic level: Player::GetQuestLevel (0 is not known, but assuming this is no longer valid for quest intended for client)
data << uint32(quest->GetMinLevel()); // min level
data << uint32(quest->GetZoneOrSort()); // zone or sort to display in quest log
data << uint32(quest->GetType()); // quest type
data << uint32(quest->GetSuggestedPlayers()); // suggested players count
data << uint32(quest->GetRepObjectiveFaction()); // shown in quest log as part of quest objective
data << uint32(quest->GetRepObjectiveValue()); // shown in quest log as part of quest objective
data << uint32(quest->GetRepObjectiveFaction2()); // shown in quest log as part of quest objective OPPOSITE faction
data << uint32(quest->GetRepObjectiveValue2()); // shown in quest log as part of quest objective OPPOSITE faction
data << uint32(quest->GetNextQuestInChain()); // client will request this quest from NPC, if not 0
data << uint32(quest->GetXPId()); // used for calculating rewarded experience
if (quest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS))
data << uint32(0); // Hide money rewarded
else
data << uint32(quest->GetRewOrReqMoney()); // reward money (below max lvl)
data << uint32(quest->GetRewMoneyMaxLevel()); // used in XP calculation at client
data << uint32(quest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast == 0)
data << int32(quest->GetRewSpellCast()); // casted spell
// rewarded honor points
data << Trinity::Honor::hk_honor_at_level(_session->GetPlayer()->getLevel(), quest->GetRewHonorMultiplier());
data << float(0); // new reward honor (multipled by ~62 at client side)
data << uint32(quest->GetSrcItemId()); // source item id
data << uint32(quest->GetFlags() & 0xFFFF); // quest flags
data << uint32(quest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
data << uint32(quest->GetPlayersSlain()); // players slain
data << uint32(quest->GetBonusTalents()); // bonus talents
data << uint32(quest->GetRewArenaPoints()); // bonus arena points
data << uint32(0); // review rep show mask
if (quest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS))
{
for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i)
data << uint32(0) << uint32(0);
for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
data << uint32(0) << uint32(0);
}
else
{
for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i)
{
data << uint32(quest->RewardItemId[i]);
data << uint32(quest->RewardItemIdCount[i]);
}
for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
{
data << uint32(quest->RewardChoiceItemId[i]);
data << uint32(quest->RewardChoiceItemCount[i]);
}
}
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids
data << uint32(quest->RewardFactionId[i]);
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid+1 QuestFactionReward.dbc?
data << int32(quest->RewardFactionValueId[i]);
for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // unk (0)
data << int32(quest->RewardFactionValueIdOverride[i]);
data << quest->GetPointMapId();
data << quest->GetPointX();
data << quest->GetPointY();
data << quest->GetPointOpt();
data << questTitle;
data << questObjectives;
data << questDetails;
data << questEndText;
data << questCompletedText; // display in quest objectives window once all objectives are completed
for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
{
if (quest->RequiredNpcOrGo[i] < 0)
data << uint32((quest->RequiredNpcOrGo[i] * (-1)) | 0x80000000); // client expects gameobject template id in form (id|0x80000000)
else
data << uint32(quest->RequiredNpcOrGo[i]);
data << uint32(quest->RequiredNpcOrGoCount[i]);
data << uint32(quest->RequiredSourceItemId[i]);
data << uint32(0); // req source count?
}
for (uint32 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
data << uint32(quest->RequiredItemId[i]);
data << uint32(quest->RequiredItemCount[i]);
}
for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
data << questObjectiveText[i];
_session->SendPacket(&data);
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", quest->GetQuestId());
}
void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, bool enableNext) const
{
std::string questTitle = quest->GetTitle();
std::string questOfferRewardText = quest->GetOfferRewardText();
int locale = _session->GetSessionDbLocaleIndex();
if (locale >= 0)
{
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
{
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
ObjectMgr::GetLocaleString(localeData->OfferRewardText, locale, questOfferRewardText);
}
}
WorldPacket data(SMSG_QUESTGIVER_OFFER_REWARD, 50); // guess size
data << uint64(npcGUID);
data << uint32(quest->GetQuestId());
data << questTitle;
data << questOfferRewardText;
data << uint8(enableNext ? 1 : 0); // Auto Finish
data << uint32(quest->GetFlags()); // 3.3.3 questFlags
data << uint32(quest->GetSuggestedPlayers()); // SuggestedGroupNum
uint32 emoteCount = 0;
for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i)
{
if (quest->OfferRewardEmote[i] <= 0)
break;
++emoteCount;
}
data << emoteCount; // Emote Count
for (uint32 i = 0; i < emoteCount; ++i)
{
data << uint32(quest->OfferRewardEmoteDelay[i]); // Delay Emote
data << uint32(quest->OfferRewardEmote[i]);
}
data << uint32(quest->GetRewChoiceItemsCount());
for (uint32 i=0; i < quest->GetRewChoiceItemsCount(); ++i)
{
data << uint32(quest->RewardChoiceItemId[i]);
data << uint32(quest->RewardChoiceItemCount[i]);
if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[i]))
data << uint32(itemTemplate->DisplayInfoID);
else
data << uint32(0);
}
data << uint32(quest->GetRewItemsCount());
for (uint32 i = 0; i < quest->GetRewItemsCount(); ++i)
{
data << uint32(quest->RewardItemId[i]);
data << uint32(quest->RewardItemIdCount[i]);
if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardItemId[i]))
data << uint32(itemTemplate->DisplayInfoID);
else
data << uint32(0);
}
data << uint32(quest->GetRewOrReqMoney());
data << uint32(quest->XPValue(_session->GetPlayer()) * sWorld->getRate(RATE_XP_QUEST) * (IsEventActive(sWorld->getIntConfig(CONFIG_RATE_XP_WEEKEND_EVID)) ? sWorld->getRate(RATE_XP_WEEKEND_QUEST) : 1.0f));
// rewarded honor points. Multiply with 10 to satisfy client
data << 10 * Trinity::Honor::hk_honor_at_level(_session->GetPlayer()->getLevel(), quest->GetRewHonorMultiplier());
data << float(0); // unk, honor multiplier?
data << uint32(0x08); // unused by client?
data << uint32(quest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast == 0)
data << int32(quest->GetRewSpellCast()); // casted spell
data << uint32(0); // unknown
data << uint32(quest->GetBonusTalents()); // bonus talents
data << uint32(quest->GetRewArenaPoints()); // arena points
data << uint32(0);
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids
data << uint32(quest->RewardFactionId[i]);
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (zero based)?
data << int32(quest->RewardFactionValueId[i]);
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override?
data << uint32(quest->RewardFactionValueIdOverride[i]);
_session->SendPacket(&data);
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId());
}
void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, bool canComplete, bool closeOnCancel) const
{
// We can always call to RequestItems, but this packet only goes out if there are actually
// items. Otherwise, we'll skip straight to the OfferReward
std::string questTitle = quest->GetTitle();
std::string requestItemsText = quest->GetRequestItemsText();
int32 locale = _session->GetSessionDbLocaleIndex();
if (locale >= 0)
{
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
{
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
ObjectMgr::GetLocaleString(localeData->RequestItemsText, locale, requestItemsText);
}
}
if (!quest->GetReqItemsCount() && canComplete)
{
SendQuestGiverOfferReward(quest, npcGUID, true);
return;
}
WorldPacket data(SMSG_QUESTGIVER_REQUEST_ITEMS, 50); // guess size
data << uint64(npcGUID);
data << uint32(quest->GetQuestId());
data << questTitle;
data << requestItemsText;
data << uint32(0x00); // unknown
if (canComplete)
data << quest->GetCompleteEmote();
else
data << quest->GetIncompleteEmote();
// Close Window after cancel
if (closeOnCancel)
data << uint32(0x01);
else
data << uint32(0x00);
data << uint32(quest->GetFlags()); // 3.3.3 questFlags
data << uint32(quest->GetSuggestedPlayers()); // SuggestedGroupNum
// Required Money
data << uint32(quest->GetRewOrReqMoney() < 0 ? -quest->GetRewOrReqMoney() : 0);
data << uint32(quest->GetReqItemsCount());
for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
if (!quest->RequiredItemId[i])
continue;
data << uint32(quest->RequiredItemId[i]);
data << uint32(quest->RequiredItemCount[i]);
if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RequiredItemId[i]))
data << uint32(itemTemplate->DisplayInfoID);
else
data << uint32(0);
}
if (!canComplete)
data << uint32(0x00);
else
data << uint32(0x03);
data << uint32(0x04);
data << uint32(0x08);
data << uint32(0x10);
_session->SendPacket(&data);
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId());
}
| [
"ano.fk@gmx.de"
] | ano.fk@gmx.de |
02c2be5e53f07a8f55eedb918d78e5097055ef49 | ba37f5ccb316cbacfe24aa68d3e680947370ffbd | /src/fileInput/readerHelper.cpp | 3eaff5fc0dd7daf423ba84b5e1e0d8daa8904323 | [
"BSD-3-Clause"
] | permissive | nightlark/GridDyn | e6fe9ab0251b10d86f269b8951ab1e1dd8b56508 | bfcef303c85c5b66bc26e5d16e4df0a07977e594 | refs/heads/helics_updates | 2021-01-24T06:12:32.115450 | 2019-07-19T18:12:34 | 2019-07-19T18:12:34 | 202,812,824 | 0 | 0 | NOASSERTION | 2019-08-17T00:22:00 | 2019-08-16T23:43:07 | C++ | UTF-8 | C++ | false | false | 1,100 | cpp | /*
* LLNS Copyright Start
* Copyright (c) 2014-2018, Lawrence Livermore National Security
* This work was performed under the auspices of the U.S. Department
* of Energy by Lawrence Livermore National Laboratory in part under
* Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
* Produced at the Lawrence Livermore National Laboratory.
* All rights reserved.
* For details, see the LICENSE file.
* LLNS Copyright End
*/
#include "readerHelper.h"
#include "fileInput.h"
#include <boost/filesystem.hpp>
// library for printf debug statements
#include <cmath>
namespace griddyn
{
using namespace readerConfig;
void paramStringProcess (gridParameter ¶m, readerInfo &ri)
{
if (!param.stringType)
{
return;
}
double val = interpretString (param.strVal, ri);
if (!(std::isnan (val)))
{
param.value = val;
param.stringType = false;
}
else // can't be interpreted as a number so do a last check for string redefinitions
{
param.strVal = ri.checkDefines (param.strVal);
}
}
} // namespace griddyn
| [
"top1@llnl.gov"
] | top1@llnl.gov |
244264d49ae7f6111df5ef27d86ac46b91de234c | 4bea57e631734f8cb1c230f521fd523a63c1ff23 | /projects/openfoam/rarefied-flows/impingment/sims/test/nozzle1/4.4/grad(rho) | bb613f4e3b5fb3ab6c6afb1eda93d8fcd0877028 | [] | no_license | andytorrestb/cfal | 76217f77dd43474f6b0a7eb430887e8775b78d7f | 730fb66a3070ccb3e0c52c03417e3b09140f3605 | refs/heads/master | 2023-07-04T01:22:01.990628 | 2021-08-01T15:36:17 | 2021-08-01T15:36:17 | 294,183,829 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 46,192 | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "4.4";
object grad(rho);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -4 0 0 0 0 0];
internalField nonuniform List<vector>
1900
(
(149759 -0.129701 0)
(-121739 0.772952 0)
(-15568 0.378128 0)
(-3012.58 0.34292 0)
(-2197.77 1.42761 0)
(-1988.05 2.42358 0)
(-2041.51 8.29225 0)
(-2158.24 22.9184 0)
(-2058.03 -21.9572 0)
(-1355.52 -112.957 0)
(149759 -0.0808529 0)
(-121738 1.33929 0)
(-15568.5 0.772547 0)
(-3011.53 0.526107 0)
(-2195.69 0.687891 0)
(-1981.18 -2.47571 0)
(-2021.02 -3.43151 0)
(-2188.49 3.1117 0)
(-2193.91 -52.7262 0)
(-1991.77 -144.734 0)
(149760 2.41585e-08 0)
(-121738 -3.55271e-10 0)
(-15568.8 1.47438e-09 0)
(-3012.67 8.06466e-09 0)
(-2200.78 9.7522e-09 0)
(-1992.17 5.06262e-09 0)
(-2035.92 -7.63833e-10 0)
(-2207.53 -2.34479e-09 0)
(-2205.88 -2.84217e-09 0)
(-2015.97 7.10543e-11 0)
(149759 0.0808529 0)
(-121738 -1.33929 0)
(-15568.5 -0.772547 0)
(-3011.53 -0.526107 0)
(-2195.69 -0.687891 0)
(-1981.18 2.47571 0)
(-2021.02 3.43151 0)
(-2188.49 -3.1117 0)
(-2193.91 52.7262 0)
(-1991.77 144.734 0)
(149759 0.129701 0)
(-121739 -0.772952 0)
(-15568 -0.378128 0)
(-3012.58 -0.34292 0)
(-2197.77 -1.42761 0)
(-1988.05 -2.42358 0)
(-2041.51 -8.29225 0)
(-2158.24 -22.9184 0)
(-2058.03 21.9572 0)
(-1355.52 112.957 0)
(-690.333 -591.757 1.35489e-11)
(-334.029 -885.081 -1.61772e-11)
(55.762 -1247.59 -2.04617e-11)
(1471.15 -1556.54 0)
(-3936.92 -6827.69 -8.89963e-11)
(-1459.98 -646.247 1.3442e-11)
(-676.689 -912.722 1.61772e-11)
(30.8207 -1366.39 2.04617e-11)
(-194.646 -1714.74 0)
(-3557.59 -6079.35 0)
(-1668.16 1.76992e-09 0)
(-1053.07 1.20761e-09 0)
(-540.994 -3.306e-09 0)
(-382.219 -5.45019e-09 0)
(-6002.57 -8.24737e-09 0)
(-1459.98 646.247 1.3442e-11)
(-676.689 912.722 1.61772e-11)
(30.8207 1366.39 2.04617e-11)
(-194.646 1714.74 0)
(-3557.59 6079.35 0)
(-690.333 591.757 -4.04328e-11)
(-334.029 885.081 -1.61772e-11)
(55.762 1247.59 -2.04617e-11)
(1471.15 1556.54 -5.59311e-11)
(-3936.92 6827.69 8.89963e-11)
(-12646.2 4657.14 3.32627e-11)
(-6123.15 1745.68 -2.69183e-11)
(-7672.39 765.783 0)
(-9505.35 878.999 1.81199e-11)
(-13672.4 556.354 -7.34384e-12)
(-9842.58 4850.78 -1.67015e-11)
(-6995.89 1330.21 1.34854e-11)
(-7832.36 668.488 0)
(-9538.91 591.375 -1.13459e-11)
(-13680.2 -239.347 1.83835e-12)
(-10523.6 -5.56233e-09 0)
(-7188.25 -3.18833e-09 0)
(-7881.47 2.36848e-09 0)
(-9913.34 -3.36695e-09 4.5455e-12)
(-13586.4 -9.34925e-09 -3.67669e-12)
(-9842.58 -4850.78 -1.67015e-11)
(-6995.89 -1330.21 1.34854e-11)
(-7832.36 -668.488 0)
(-9538.91 -591.375 -1.13459e-11)
(-13680.2 239.347 1.83835e-12)
(-12646.2 -4657.14 1.67015e-11)
(-6123.15 -1745.68 -5.25743e-14)
(-7672.39 -765.783 0)
(-9505.35 -878.999 2.64726e-14)
(-13672.4 -556.354 7.34384e-12)
(-17618.1 -4467.15 0)
(-8332.23 3496.61 0)
(1659.82 2828.07 0)
(82.7171 1996.27 0)
(-1387.08 1000.07 0)
(-1534.18 451.169 0)
(-1780.48 288.472 0)
(-1873.64 176.786 0)
(-1629.07 101.055 0)
(-1183.68 37.967 0)
(-693.221 12.311 0)
(-450.263 8.76222 0)
(-347.061 8.96337 0)
(-287.53 7.49169 0)
(-238.186 5.61747 0)
(-195.234 4.16736 0)
(-159.744 3.2299 0)
(-130.545 2.64962 0)
(-107.521 2.25009 0)
(-88.2855 1.9484 0)
(-70.7177 1.69164 0)
(-57.3956 1.49179 0)
(-46.0351 1.36665 0)
(-35.082 1.29587 0)
(-25.3496 1.29047 0)
(-16.363 1.34209 0)
(-8.63906 1.45766 0)
(-3.48568 1.51794 0)
(0.114733 1.62635 0)
(0.920071 1.22446 0)
(12.8132 1.22252 0)
(30.0941 1.14542 0)
(67.3742 1.39856 0)
(93.652 4.5125 0)
(115.774 5.6919 0)
(118.216 12.3444 0)
(91.8057 10.5408 0)
(3148.76 18.4933 0)
(65906.3 -66.2459 0)
(-71920.5 -4388.78 0)
(-17199.4 1060.37 0)
(-8407.56 5570.53 0)
(1278.61 3282.12 0)
(38.3269 1571.78 0)
(-1511.89 711.647 0)
(-1621.54 244.052 0)
(-1811.87 145.393 0)
(-1898.41 81.3799 0)
(-1643.86 24.5583 0)
(-1187.44 10.2319 0)
(-695.311 3.28947 0)
(-450.384 1.78264 0)
(-346.991 2.21011 0)
(-287.712 1.84812 0)
(-238.402 1.24267 0)
(-195.385 0.786137 0)
(-159.834 0.516046 0)
(-130.601 0.366798 0)
(-107.563 0.262796 0)
(-88.3236 0.167523 0)
(-70.7517 0.0769313 0)
(-57.4247 -0.00129371 0)
(-46.0623 -0.0695063 0)
(-35.1096 -0.140013 0)
(-25.3777 -0.208844 0)
(-16.3909 -0.273953 0)
(-8.6766 -0.324058 0)
(-3.52747 -0.392518 0)
(0.0345435 -0.39796 0)
(0.836104 -0.518224 0)
(12.7722 -0.350262 0)
(30.0799 0.0716126 0)
(67.6736 1.11264 0)
(94.2 4.19423 0)
(116.916 8.69364 0)
(119.215 18.1582 0)
(92.4899 27.3476 0)
(3137.52 39.8695 0)
(65832.1 -29.2226 0)
(-71870.9 2032.62 0)
(-15850.1 -2.10902e-08 0)
(-7685.91 5.37752e-09 0)
(496.543 2.4223e-10 0)
(-665.056 3.71582e-08 0)
(-1773.33 -8.38117e-09 0)
(-1698.91 -3.89184e-09 0)
(-1827.81 -7.62219e-09 0)
(-1908.8 -5.26609e-08 0)
(-1649.77 -4.45866e-08 0)
(-1189.87 -5.12075e-08 0)
(-695.679 -9.15631e-09 0)
(-450.577 -2.13163e-09 0)
(-347.042 -4.66697e-09 0)
(-287.811 -7.41225e-09 0)
(-238.495 -1.93784e-09 0)
(-195.445 5.15143e-09 0)
(-159.866 1.28544e-08 0)
(-130.619 5.36137e-09 0)
(-107.579 -1.07389e-08 0)
(-88.3395 -2.04927e-08 0)
(-70.7669 -2.17361e-08 0)
(-57.4382 -2.59994e-09 0)
(-46.0754 1.09811e-08 0)
(-35.1226 1.63102e-08 0)
(-25.3886 3.32179e-08 0)
(-16.3965 5.62621e-08 0)
(-8.67355 6.64842e-08 0)
(-3.50718 4.95604e-08 0)
(0.078164 2.11063e-08 0)
(0.933946 -3.61085e-08 0)
(12.9848 -7.87249e-08 0)
(30.5196 -4.78809e-08 0)
(68.5735 2.09933e-10 0)
(95.8574 9.21929e-08 0)
(119.836 1.43465e-07 0)
(123.643 1.79622e-07 0)
(98.1217 4.71381e-08 0)
(3132.3 1.40364e-07 0)
(66486 -1.12944e-07 0)
(-72634.2 -5.28256e-07 0)
(-17199.4 -1060.37 0)
(-8407.56 -5570.53 0)
(1278.61 -3282.12 0)
(38.3269 -1571.78 0)
(-1511.89 -711.647 0)
(-1621.54 -244.052 0)
(-1811.87 -145.393 0)
(-1898.41 -81.3799 0)
(-1643.86 -24.5583 0)
(-1187.44 -10.2319 0)
(-695.311 -3.28947 0)
(-450.384 -1.78264 0)
(-346.991 -2.21011 0)
(-287.712 -1.84812 0)
(-238.402 -1.24267 0)
(-195.385 -0.786137 0)
(-159.834 -0.516046 0)
(-130.601 -0.366798 0)
(-107.563 -0.262796 0)
(-88.3236 -0.167523 0)
(-70.7517 -0.0769314 0)
(-57.4247 0.00129362 0)
(-46.0623 0.0695061 0)
(-35.1096 0.140013 0)
(-25.3777 0.208844 0)
(-16.3909 0.273953 0)
(-8.6766 0.324058 0)
(-3.52747 0.392517 0)
(0.0345434 0.397959 0)
(0.836104 0.518224 0)
(12.7722 0.350262 0)
(30.0799 -0.0716128 0)
(67.6736 -1.11264 0)
(94.2 -4.19423 0)
(116.916 -8.69364 0)
(119.215 -18.1582 0)
(92.4899 -27.3476 0)
(3137.52 -39.8695 0)
(65832.1 29.2226 0)
(-71870.9 -2032.62 0)
(-17618.1 4467.15 0)
(-8332.23 -3496.61 0)
(1659.82 -2828.07 0)
(82.7171 -1996.27 0)
(-1387.08 -1000.07 0)
(-1534.18 -451.169 0)
(-1780.48 -288.472 0)
(-1873.64 -176.786 0)
(-1629.07 -101.055 0)
(-1183.68 -37.967 0)
(-693.221 -12.311 0)
(-450.263 -8.76222 0)
(-347.061 -8.96337 0)
(-287.53 -7.49169 0)
(-238.186 -5.61747 0)
(-195.234 -4.16736 0)
(-159.744 -3.2299 0)
(-130.545 -2.64962 0)
(-107.521 -2.25009 0)
(-88.2855 -1.9484 0)
(-70.7177 -1.69164 0)
(-57.3956 -1.49179 0)
(-46.0351 -1.36665 0)
(-35.082 -1.29587 0)
(-25.3496 -1.29047 0)
(-16.363 -1.34209 0)
(-8.63906 -1.45766 0)
(-3.48568 -1.51794 0)
(0.114733 -1.62635 0)
(0.920071 -1.22446 0)
(12.8132 -1.22252 0)
(30.0941 -1.14542 0)
(67.3742 -1.39856 0)
(93.652 -4.5125 0)
(115.774 -5.6919 0)
(118.216 -12.3444 0)
(91.8057 -10.5408 0)
(3148.76 -18.4933 0)
(65906.3 66.2459 0)
(-71920.5 4388.78 0)
(29427.3 14851.8 0)
(-13070.7 -3430.05 0)
(1778.97 -3673.95 0)
(1133.65 -2693.71 0)
(-687.002 -1402.15 0)
(-1276.18 -778.925 0)
(-1676.04 -514.214 0)
(-1809.49 -324.298 0)
(-1573.89 -229.404 0)
(-1136.11 -80.1116 0)
(-679.408 -31.5402 0)
(-448.424 -21.2228 0)
(-346.112 -19.3813 0)
(-285.824 -15.9868 0)
(-236.566 -12.2997 0)
(-194.063 -9.48361 0)
(-158.986 -7.66163 0)
(-130.05 -6.51706 0)
(-107.173 -5.71941 0)
(-88.0173 -5.12373 0)
(-70.5045 -4.61013 0)
(-57.2545 -4.20423 0)
(-45.9709 -3.95504 0)
(-35.0936 -3.83104 0)
(-25.4391 -3.86466 0)
(-16.5281 -4.04308 0)
(-8.83032 -4.37016 0)
(-3.6816 -4.64526 0)
(0.125916 -4.95179 0)
(0.992333 -4.43958 0)
(12.7743 -4.44985 0)
(29.9531 -4.30688 0)
(65.9078 -5.00757 0)
(92.1405 -9.79282 0)
(113.324 -11.233 0)
(117.329 -19.7754 0)
(89.4239 -17.2717 0)
(3172.7 -31.058 0)
(68510.9 -94.0131 0)
(-74796.6 525.031 0)
(32841.8 16319 0)
(-23643.4 -2775.45 0)
(2305.49 -2105.15 0)
(1708.36 -2166.73 0)
(82.6724 -1478.24 0)
(-816.879 -1024.48 0)
(-1398.39 -755.141 0)
(-1633.59 -492.355 0)
(-1423.36 -318.291 0)
(-1018.52 -134.071 0)
(-643.88 -57.3885 0)
(-439.533 -36.7197 0)
(-342.525 -30.0511 0)
(-281.62 -24.0754 0)
(-232.788 -18.4435 0)
(-191.392 -14.2891 0)
(-157.292 -11.615 0)
(-128.94 -9.90389 0)
(-106.365 -8.67165 0)
(-87.3603 -7.72912 0)
(-69.946 -6.90264 0)
(-56.84 -6.23698 0)
(-45.7099 -5.80929 0)
(-34.9887 -5.5662 0)
(-25.506 -5.56867 0)
(-16.7616 -5.80045 0)
(-9.11678 -6.27269 0)
(-3.94111 -6.63761 0)
(0.306941 -7.03817 0)
(1.36501 -6.25136 0)
(12.962 -6.16254 0)
(29.6322 -6.02357 0)
(62.8741 -7.31032 0)
(88.4635 -14.0795 0)
(107.468 -16.9285 0)
(112.873 -28.8291 0)
(82.2106 -29.4717 0)
(3061.97 -47.347 0)
(65045.4 -285.19 0)
(-70907.2 -4979.53 0)
(37063.3 10090.5 0)
(-30824.9 -1178.57 0)
(2365.55 -1125.77 0)
(1737.77 -1449.83 0)
(413.711 -1243.69 0)
(-579.377 -1057.78 0)
(-1163.27 -884.553 0)
(-1388.53 -596.228 0)
(-1228.63 -371.084 0)
(-884.697 -177.876 0)
(-585.597 -86.0478 0)
(-422.081 -55.2284 0)
(-333.928 -41.9503 0)
(-274.638 -32.3182 0)
(-227.136 -24.4283 0)
(-187.483 -18.8628 0)
(-154.76 -15.2432 0)
(-127.214 -12.825 0)
(-105.077 -11.0163 0)
(-86.3126 -9.62258 0)
(-69.0666 -8.41547 0)
(-56.2009 -7.4613 0)
(-45.3245 -6.87307 0)
(-34.8618 -6.56856 0)
(-25.6649 -6.63985 0)
(-17.2065 -7.05641 0)
(-9.63704 -7.83618 0)
(-4.41924 -8.39216 0)
(0.498125 -9.02823 0)
(1.83612 -7.99326 0)
(12.9938 -7.91741 0)
(28.847 -8.01863 0)
(58.1447 -10.0728 0)
(82.8721 -18.9593 0)
(99.111 -22.9808 0)
(105.242 -37.1477 0)
(71.5794 -40.6684 0)
(2926.28 -55.1071 0)
(63758.1 -224.443 0)
(-69484.2 -2667.33 0)
(39811.3 6276.71 0)
(-34451.8 -271.999 0)
(2044.1 -605.215 0)
(1594.73 -1024.82 0)
(460.463 -1066.05 0)
(-470.799 -1034.58 0)
(-953.621 -893.937 0)
(-1138.79 -623.847 0)
(-1020.22 -384.92 0)
(-743.849 -195.835 0)
(-525.693 -107.263 0)
(-397.039 -70.3392 0)
(-320.447 -51.3012 0)
(-264.736 -38.0537 0)
(-219.822 -28.2016 0)
(-182.541 -21.493 0)
(-151.474 -17.0454 0)
(-124.866 -13.918 0)
(-103.279 -11.4894 0)
(-84.854 -9.60871 0)
(-67.8634 -8.00444 0)
(-55.3537 -6.76694 0)
(-44.8496 -6.04802 0)
(-34.764 -5.73115 0)
(-25.9761 -5.94035 0)
(-17.9144 -6.60644 0)
(-10.4039 -7.75501 0)
(-5.08982 -8.4986 0)
(0.691331 -9.41427 0)
(2.43544 -8.24198 0)
(12.9376 -8.26797 0)
(27.5552 -8.85476 0)
(52.3313 -11.978 0)
(76.0249 -22.4794 0)
(89.9406 -28.0227 0)
(95.8283 -42.7894 0)
(64.9042 -50.2148 0)
(2884.88 -55.9333 0)
(62528.2 -175.834 0)
(-68158.5 -2631.02 0)
(42674.1 5336.01 0)
(-37456.6 -27.246 0)
(1640.11 -401.539 0)
(1293.69 -840.975 0)
(404.304 -953.709 0)
(-413.521 -964.332 0)
(-767.469 -818.712 0)
(-898.022 -593.216 0)
(-816.182 -358.225 0)
(-617.137 -198.787 0)
(-464.665 -117.398 0)
(-368.153 -79.1034 0)
(-302.816 -56.5099 0)
(-252.379 -40.8995 0)
(-211.177 -29.8942 0)
(-176.732 -22.4546 0)
(-147.46 -17.334 0)
(-121.86 -13.5248 0)
(-100.924 -10.4613 0)
(-82.9544 -8.07755 0)
(-66.3282 -6.06876 0)
(-54.3156 -4.54828 0)
(-44.3264 -3.6937 0)
(-34.758 -3.37524 0)
(-26.5083 -3.72548 0)
(-18.9551 -4.59666 0)
(-11.4604 -6.02158 0)
(-6.01817 -6.63723 0)
(0.745412 -7.47144 0)
(2.94074 -5.66041 0)
(12.4033 -5.26973 0)
(25.2719 -5.80717 0)
(45.0156 -9.00131 0)
(67.4109 -19.768 0)
(79.5395 -25.3738 0)
(83.8565 -38.0514 0)
(58.9135 -45.7197 0)
(2805.23 -44.119 0)
(61276.6 -179.909 0)
(-66777.7 -3081.5 0)
(45090.6 5996.18 0)
(-39980.7 -15.6079 0)
(1259.96 -412.929 0)
(1062.64 -728.88 0)
(341.593 -880.152 0)
(-340.711 -864.814 0)
(-596 -714.777 0)
(-695.051 -526.282 0)
(-640.135 -325.419 0)
(-511.779 -193.133 0)
(-410.362 -122.744 0)
(-338.365 -83.9903 0)
(-283.633 -59.383 0)
(-239.088 -42.4886 0)
(-202.048 -30.904 0)
(-170.438 -22.9329 0)
(-142.869 -17.1797 0)
(-118.244 -12.6822 0)
(-98.0299 -8.96959 0)
(-80.6212 -6.07788 0)
(-64.4624 -3.67545 0)
(-53.065 -1.89176 0)
(-43.7192 -0.940087 0)
(-34.7946 -0.647657 0)
(-27.1531 -1.1507 0)
(-20.127 -2.20599 0)
(-12.3703 -3.89843 0)
(-6.48695 -4.34826 0)
(1.63264 -5.1983 0)
(4.55708 -3.19625 0)
(12.7961 -2.91544 0)
(23.9593 -3.95034 0)
(38.8781 -7.578 0)
(60.2477 -18.8787 0)
(72.3221 -25.5524 0)
(76.2223 -35.9864 0)
(59.0572 -42.6532 0)
(2755.57 -33.164 0)
(59601.3 -197.831 0)
(-65002.6 -3419.4 0)
(48852.7 1651.9 0)
(-43632.7 -125.93 0)
(952.77 -417.709 0)
(843.458 -660.398 0)
(273.313 -814.564 0)
(-254.159 -750.454 0)
(-441.247 -608.402 0)
(-522.823 -442.058 0)
(-495.148 -280.281 0)
(-421.832 -174.705 0)
(-359.491 -115.565 0)
(-307.096 -79.7587 0)
(-262.824 -56.4955 0)
(-224.935 -40.8943 0)
(-192.333 -30.3389 0)
(-163.507 -22.7967 0)
(-137.583 -17.0126 0)
(-113.948 -12.2054 0)
(-94.5602 -8.06321 0)
(-77.8528 -4.77282 0)
(-62.2943 -2.0022 0)
(-51.6797 0.0924787 0)
(-43.1275 1.24326 0)
(-34.961 1.77895 0)
(-28.01 1.5778 0)
(-21.6029 1.02522 0)
(-13.5248 0.0497319 0)
(-7.27076 1.07848 0)
(1.85553 1.47562 0)
(5.14059 4.50887 0)
(11.6766 5.45499 0)
(20.7789 4.6052 0)
(30.6301 0.899123 0)
(50.0901 -10.8172 0)
(63.0539 -19.8397 0)
(67.3776 -29.1359 0)
(61.6332 -35.6444 0)
(2655.69 -26.3543 0)
(58013.5 -279.241 0)
(-63307.3 -3908.77 0)
(46612.9 -2859.18 0)
(-41975 -242.177 0)
(744.924 -415.024 0)
(680.212 -592.41 0)
(254.812 -714.81 0)
(-142.046 -623.936 0)
(-298.819 -506.289 0)
(-378.861 -364.307 0)
(-382.504 -239.778 0)
(-353.053 -158.201 0)
(-318.868 -108.956 0)
(-281.443 -76.7222 0)
(-246.182 -55.882 0)
(-213.882 -42.0075 0)
(-184.608 -32.54 0)
(-157.596 -25.3741 0)
(-132.662 -19.5331 0)
(-109.62 -14.4075 0)
(-90.8676 -9.83042 0)
(-74.7806 -6.14243 0)
(-59.7741 -3.00575 0)
(-49.9375 -0.587671 0)
(-42.0941 0.817027 0)
(-34.4722 1.6256 0)
(-27.8794 1.70969 0)
(-21.5995 1.60903 0)
(-12.319 1.22147 0)
(-5.11291 3.56156 0)
(4.93828 5.02981 0)
(8.39174 8.79847 0)
(12.889 9.87638 0)
(19.5691 8.66304 0)
(24.0166 4.20266 0)
(40.263 -8.30191 0)
(54.6695 -21.619 0)
(60.9923 -30.5812 0)
(61.7377 -37.9009 0)
(2520.83 -29.0081 0)
(55860.1 -365.218 0)
(-61022.7 -4496.78 0)
(45601.2 -2199.9 0)
(-41277.4 -245.086 0)
(615.274 -379.239 0)
(554.573 -511.548 0)
(242.933 -598.173 0)
(-53.2214 -515.609 0)
(-191.059 -422.943 0)
(-266.003 -303.35 0)
(-296.537 -208.869 0)
(-295.767 -142.521 0)
(-280.975 -99.2759 0)
(-255.952 -69.3416 0)
(-229.371 -50.9364 0)
(-202.442 -39.0215 0)
(-176.304 -31.2501 0)
(-150.973 -25.3354 0)
(-127.015 -20.3677 0)
(-104.598 -15.6646 0)
(-86.5957 -11.1851 0)
(-71.2763 -7.39102 0)
(-56.9415 -3.86187 0)
(-47.9959 -0.765124 0)
(-40.9947 1.48424 0)
(-34.1008 3.22725 0)
(-28.0259 4.25351 0)
(-22.0734 5.26678 0)
(-11.6432 5.89392 0)
(-3.60091 9.32075 0)
(6.902 11.1669 0)
(9.81092 14.7975 0)
(11.5461 15.2259 0)
(15.3115 13.0341 0)
(14.2821 7.16558 0)
(25.2075 -6.31919 0)
(41.5847 -24.8068 0)
(51.6878 -33.4883 0)
(63.1491 -41.5436 0)
(2340.28 -37.8306 0)
(53708.2 -545.092 0)
(-58717.1 -5158.21 0)
(44209.8 -2679.69 0)
(-40220.6 -211.079 0)
(488.151 -331.001 0)
(469.239 -437.794 0)
(250.899 -485.646 0)
(26.8122 -428.717 0)
(-94.2779 -346.231 0)
(-172.572 -256.759 0)
(-227.524 -186.045 0)
(-247.445 -131.118 0)
(-248.349 -93.4935 0)
(-234.861 -65.9889 0)
(-216.964 -49.9923 0)
(-194.912 -39.1899 0)
(-171.42 -32.0926 0)
(-147.109 -26.3705 0)
(-123.343 -21.3366 0)
(-100.771 -16.5889 0)
(-82.8949 -12.0648 0)
(-67.7237 -8.26464 0)
(-53.3891 -4.60371 0)
(-44.7858 -1.23999 0)
(-38.2469 1.30486 0)
(-31.8037 3.40939 0)
(-25.914 4.74333 0)
(-20.0188 6.26309 0)
(-8.41244 6.9988 0)
(-0.0316728 10.2735 0)
(10.2158 11.3874 0)
(12.3031 13.7584 0)
(11.1897 12.3955 0)
(11.8019 8.6861 0)
(5.36701 0.939476 0)
(9.45319 -13.7793 0)
(28.4883 -34.2849 0)
(44.8642 -41.1281 0)
(57.5533 -45.5111 0)
(2035.59 -46.0869 0)
(50925.9 -730.013 0)
(-55645.1 -5947.66 0)
(42738.1 -3218.17 0)
(-39014.1 -220.03 0)
(396.803 -302.632 0)
(405.552 -380.339 0)
(251.68 -394.598 0)
(81.1245 -366.771 0)
(-25.3539 -293.196 0)
(-111.643 -230.981 0)
(-175.465 -174.764 0)
(-206.581 -125.748 0)
(-218.214 -90.9333 0)
(-214.032 -63.3071 0)
(-203.547 -47.2566 0)
(-185.193 -34.576 0)
(-163.951 -25.1268 0)
(-140.608 -16.7493 0)
(-117.589 -9.61756 0)
(-95.6635 -3.50686 0)
(-78.5742 1.84486 0)
(-64.0865 5.99524 0)
(-50.1723 9.77374 0)
(-42.3022 13.0234 0)
(-36.5144 15.0876 0)
(-30.7873 16.444 0)
(-25.276 16.5677 0)
(-19.9 16.5863 0)
(-7.77866 14.8824 0)
(0.628154 15.4032 0)
(10.2602 13.573 0)
(10.7824 12.7303 0)
(6.65819 7.35084 0)
(4.272 -0.22787 0)
(-7.36646 -13.7981 0)
(-8.73602 -34.945 0)
(15.2305 -62.4132 0)
(40.8697 -75.5998 0)
(58.3706 -80.8465 0)
(1680.67 -93.0077 0)
(48021.2 -931.481 0)
(-52401.2 -6542.69 0)
(40849 -4145.13 0)
(-37411.1 -255.175 0)
(333.67 -305.737 0)
(380.618 -348.089 0)
(263.974 -330.384 0)
(124.527 -313.362 0)
(36.5735 -251.691 0)
(-58.4471 -202.638 0)
(-126.117 -158.855 0)
(-166.663 -110.921 0)
(-188.179 -78.2197 0)
(-192.773 -50.8383 0)
(-189.278 -35.7013 0)
(-173.587 -21.4605 0)
(-154.241 -10.3622 0)
(-132.164 -0.227879 0)
(-110.582 8.38977 0)
(-89.7254 15.9158 0)
(-73.7383 22.3614 0)
(-60.0832 27.0188 0)
(-46.6165 31.0191 0)
(-39.6652 34.3151 0)
(-34.9507 35.9627 0)
(-30.3773 36.4947 0)
(-25.7769 35.3467 0)
(-21.6428 33.9439 0)
(-9.55247 30.1116 0)
(-1.29344 28.6866 0)
(7.64009 24.7364 0)
(6.30719 21.5668 0)
(-1.29721 12.129 0)
(-8.578 -1.5549 0)
(-28.0877 -21.7152 0)
(-37.394 -49.7648 0)
(-10.6881 -83.4619 0)
(27.1011 -103.2 0)
(40.7785 -106.19 0)
(1215.89 -132.964 0)
(44710.7 -992.034 0)
(-48568.9 -7322.47 0)
(38464.3 -5035.05 0)
(-35314.3 -263.234 0)
(307.267 -283.1 0)
(381.801 -290.909 0)
(285.144 -301.803 0)
(156.956 -288.872 0)
(81.3438 -234.487 0)
(-22.1818 -191.32 0)
(-87.0827 -146.56 0)
(-128.878 -100.265 0)
(-160.316 -70.035 0)
(-173.06 -41.2713 0)
(-175.237 -24.6249 0)
(-160.776 -6.11661 0)
(-143.49 8.92263 0)
(-122.538 23.5415 0)
(-102.032 37.0106 0)
(-82.2 49.3006 0)
(-67.8749 59.6301 0)
(-55.7436 66.5227 0)
(-43.1414 70.9224 0)
(-37.5384 72.7276 0)
(-34.414 71.1629 0)
(-31.381 67.584 0)
(-27.7341 61.8439 0)
(-24.9447 56.3072 0)
(-12.8449 47.6982 0)
(-4.55158 41.4936 0)
(3.39938 32.3826 0)
(-1.36662 24.5299 0)
(-15.6227 10.488 0)
(-28.3415 -8.17174 0)
(-53.8232 -32.7314 0)
(-68.2374 -65.381 0)
(-36.2616 -104.841 0)
(18.9677 -138.533 0)
(29.6889 -149.214 0)
(827.035 -176.143 0)
(41093.2 -866.157 0)
(-44491.9 -8029.73 0)
(35735.2 -5770.67 0)
(-32831.9 -292.579 0)
(307.002 -305.2 0)
(362.594 -262.188 0)
(265.937 -285.31 0)
(189.395 -258.578 0)
(130.578 -207.494 0)
(26.2834 -173.713 0)
(-38.373 -124.006 0)
(-92.9208 -80.1763 0)
(-131.331 -47.6518 0)
(-149.014 -19.3668 0)
(-155.401 -4.06372 0)
(-141.259 14.7867 0)
(-125.662 30.1697 0)
(-105.097 46.4803 0)
(-85.76 61.4379 0)
(-67.9284 74.6873 0)
(-57.1425 85.6842 0)
(-49.2015 92.9344 0)
(-40.6372 97.654 0)
(-39.4334 99.7904 0)
(-39.9072 98.09 0)
(-39.3574 93.9903 0)
(-36.6437 87.3025 0)
(-35.2741 81.2658 0)
(-23.8274 71.7616 0)
(-16.0521 64.1053 0)
(-8.70669 51.1105 0)
(-14.7912 38.372 0)
(-32.8097 20.0252 0)
(-50.2258 -5.07804 0)
(-83.2166 -34.2878 0)
(-106.881 -73.3508 0)
(-81.1797 -115.896 0)
(-15.6586 -157.252 0)
(4.53548 -190.23 0)
(525.017 -214.583 0)
(37142.7 -695.933 0)
(-40084.9 -8630.78 0)
(32629.5 -6425.57 0)
(-30047.6 -277.945 0)
(336.553 -284.612 0)
(400.968 -234.224 0)
(288.623 -243.308 0)
(231.941 -177.867 0)
(163.123 -149.763 0)
(58.2703 -129.45 0)
(3.05231 -71.9335 0)
(-55.3003 -44.7568 0)
(-101.718 -25.071 0)
(-131.057 -3.85498 0)
(-142.326 9.54301 0)
(-127.787 28.0401 0)
(-112.949 43.7941 0)
(-92.4069 61.8515 0)
(-74.851 78.9989 0)
(-58.8353 94.5049 0)
(-50.2913 107.45 0)
(-44.2091 115.022 0)
(-36.5346 118.617 0)
(-37.1182 118.658 0)
(-40.0032 114.153 0)
(-41.7761 107.53 0)
(-39.9958 98.8618 0)
(-39.9205 92.4727 0)
(-29.3814 83.978 0)
(-24.4518 78.2895 0)
(-21.3981 67.4729 0)
(-31.3216 57.6598 0)
(-57.4928 45.696 0)
(-80.6795 24.2944 0)
(-119.613 4.07181 0)
(-146.878 -35.1434 0)
(-117.112 -70.3881 0)
(-52.663 -127.507 0)
(-25.5574 -166.16 0)
(339.72 -179.467 0)
(32983 -456.24 0)
(-35572.2 -9010.56 0)
(29315.4 -5813.32 0)
(-26914.3 -116.66 0)
(349.132 -128.395 0)
(402.396 -127.565 0)
(320.245 -122.608 0)
(279.538 -42.0743 0)
(177.234 -53.8496 0)
(101.283 -44.2887 0)
(43.2409 27.5747 0)
(-47.7623 3.65869 0)
(-91.9164 14.4625 0)
(-115.659 21.2936 0)
(-124.666 24.5031 0)
(-108.254 36.9545 0)
(-93.0799 49.9495 0)
(-71.1727 69.5267 0)
(-54.2939 88.5675 0)
(-40.512 105.127 0)
(-37.3717 116.688 0)
(-38.4404 124.439 0)
(-37.1332 130.026 0)
(-43.7356 129.797 0)
(-50.6308 123.471 0)
(-54.0922 114.473 0)
(-51.1532 102.575 0)
(-49.6167 94.4094 0)
(-37.4949 85.216 0)
(-31.9571 79.7796 0)
(-28.5862 70.7601 0)
(-35.7762 63.5553 0)
(-64.9618 59.7294 0)
(-90.3364 44.4105 0)
(-140.493 37.8123 0)
(-178.633 5.53439 0)
(-170.184 -20.8024 0)
(-107.948 -75.1881 0)
(-45.5357 -103.819 0)
(245.486 -99.2565 0)
(28632.7 -209.986 0)
(-31065.4 -7884.06 0)
(27100.9 -5718.74 0)
(-24569.4 83.1287 0)
(326.045 35.6288 0)
(406.544 -36.8243 0)
(371.005 -41.0307 0)
(298.2 -5.38343 0)
(160.989 -18.9397 0)
(136.734 23.9968 0)
(49.2562 47.2527 0)
(-67.9356 23.4842 0)
(-84.7243 38.5079 0)
(-121.382 29.4663 0)
(-127.234 24.795 0)
(-103.266 28.1474 0)
(-81.5614 33.0107 0)
(-55.1931 48.8543 0)
(-40.5453 65.1355 0)
(-31.7377 81.5627 0)
(-31.6815 94.5342 0)
(-31.356 102.079 0)
(-31.3716 105.002 0)
(-43.4351 102.932 0)
(-54.7699 95.8915 0)
(-61.9124 89.4439 0)
(-59.3298 81.8674 0)
(-56.6478 80.483 0)
(-43.4791 80.7444 0)
(-38.382 78.7905 0)
(-37.0325 78.3461 0)
(-41.9512 70.1491 0)
(-75.9413 71.8516 0)
(-101.8 50.6325 0)
(-157.076 41.5434 0)
(-203.361 11.1553 0)
(-194.899 -18.8389 0)
(-132.661 -39.8439 0)
(-48.7505 -44.8285 0)
(237.414 -26.041 0)
(25481.3 3.66251 0)
(-28046.9 -7618.83 0)
(24408.6 29522.5 0)
(-21369.1 2466.33 0)
(233.541 865.661 0)
(328.524 589.929 0)
(350.543 561.197 0)
(300.826 696.012 0)
(205.546 1002.44 0)
(165.068 1496.27 0)
(42.747 1922.78 0)
(-56.1892 2353.46 0)
(-86.1519 2696.27 0)
(-128.873 2931.1 0)
(-125.937 3113.91 0)
(-100.337 3230.41 0)
(-73.1259 3312.38 0)
(-40.2161 3358.1 0)
(-22.775 3400.63 0)
(-12.1824 3380.08 0)
(-17.6014 3397.64 0)
(-28.3528 3323.19 0)
(-36.3117 3321.47 0)
(-52.5152 3400.78 0)
(-63.628 3387.87 0)
(-67.6063 3432.5 0)
(-59.7882 3379.4 0)
(-50.6988 3351.34 0)
(-39.1259 3261.41 0)
(-34.2682 3147.47 0)
(-36.9134 2989.2 0)
(-42.0346 2725.68 0)
(-83.7688 2445.97 0)
(-119.542 1962.03 0)
(-178.535 1511.25 0)
(-236.82 1054.87 0)
(-219.329 715.309 0)
(-132.992 485.497 0)
(-32.2347 402.818 0)
(292.213 431.429 0)
(21316.1 2022.32 0)
(-24355.9 26067 0)
(56519.2 645378 0)
(-52184.1 57504.7 0)
(-1482.13 26928.7 0)
(113.152 31318.1 0)
(473.23 34686.6 0)
(723.394 39089 0)
(932.144 43068.1 0)
(1023.61 46915.1 0)
(875.279 50229.4 0)
(677.424 53413.4 0)
(471.914 56309.6 0)
(281.08 58790.6 0)
(161.191 61082.2 0)
(87.9809 63030.4 0)
(41.4792 64713.6 0)
(29.8546 66141.7 0)
(-19.3638 67377.9 0)
(-34.6235 68403.4 0)
(-86.5056 68839.9 0)
(-104.758 69059 0)
(43.4013 69019.5 0)
(20.5568 68645.5 0)
(-24.207 68226.7 0)
(-70.0797 66884.5 0)
(-137.539 65657.9 0)
(-170.347 63766.4 0)
(-239.929 61975.1 0)
(-300.693 59570 0)
(-443.488 57162.8 0)
(-565.431 54040.1 0)
(-811.822 50872.5 0)
(-1002.52 47247.8 0)
(-1031.25 43427.5 0)
(-970.364 39304.1 0)
(-743.568 34998.1 0)
(-433.788 30384.4 0)
(-100.853 26964.7 0)
(1798.03 22315.1 0)
(50184.7 50659.9 0)
(-53652.8 589520 0)
(696212 -720013 0)
(-617329 -61573.1 0)
(-25000.8 -31673.2 0)
(7804.37 -35811.5 0)
(7838.89 -39300.1 0)
(8377.49 -44145.9 0)
(7747.08 -48551.1 0)
(7065.99 -52967.2 0)
(6304.69 -56734.6 0)
(5802.88 -60174.7 0)
(5095.51 -63233.1 0)
(4470.23 -65728.6 0)
(3959.74 -67958.7 0)
(3399 -69844.8 0)
(2924.97 -71456.1 0)
(2527.15 -72837.2 0)
(2156.72 -74056.7 0)
(1396.64 -75051.4 0)
(614.104 -75471.2 0)
(144.734 -75605.4 0)
(-434.701 -75527.8 0)
(-816.513 -75155.9 0)
(-1760.65 -74683.7 0)
(-2542.91 -73273.9 0)
(-3064.52 -71950.8 0)
(-3599.63 -69957 0)
(-4082.87 -68054 0)
(-4671.6 -65523.4 0)
(-5365.77 -62971.3 0)
(-6103.53 -59588.1 0)
(-6629.1 -56152.6 0)
(-7293.82 -51982.6 0)
(-7833.33 -47648.5 0)
(-8359.73 -42893.5 0)
(-8814.72 -38065.5 0)
(-7874.23 -33105.1 0)
(-7808.01 -29736.1 0)
(23125.7 -25561.8 0)
(567895 -54133 0)
(-635257 -660777 0)
(696212 720013 0)
(-617329 61573.1 0)
(-25000.8 31673.2 0)
(7804.37 35811.5 0)
(7838.89 39300.1 0)
(8377.49 44145.9 0)
(7747.08 48551.1 0)
(7065.99 52967.2 0)
(6304.69 56734.6 0)
(5802.88 60174.7 0)
(5095.51 63233.1 0)
(4470.23 65728.6 0)
(3959.74 67958.7 0)
(3399 69844.8 0)
(2924.97 71456.1 0)
(2527.15 72837.2 0)
(2156.72 74056.7 0)
(1396.64 75051.4 0)
(614.103 75471.2 0)
(144.734 75605.4 0)
(-434.701 75527.8 0)
(-816.513 75155.9 0)
(-1760.65 74683.7 0)
(-2542.91 73273.9 0)
(-3064.52 71950.8 0)
(-3599.63 69957 0)
(-4082.87 68054 0)
(-4671.6 65523.4 0)
(-5365.77 62971.3 0)
(-6103.53 59588.1 0)
(-6629.1 56152.6 0)
(-7293.82 51982.6 0)
(-7833.33 47648.5 0)
(-8359.73 42893.5 0)
(-8814.72 38065.5 0)
(-7874.23 33105.1 0)
(-7808.01 29736.1 0)
(23125.7 25561.8 0)
(567895 54133 0)
(-635257 660777 0)
(56519.2 -645378 0)
(-52184.1 -57504.7 0)
(-1482.13 -26928.7 0)
(113.152 -31318.1 0)
(473.23 -34686.6 0)
(723.394 -39089 0)
(932.144 -43068.1 0)
(1023.61 -46915.1 0)
(875.279 -50229.4 0)
(677.424 -53413.4 0)
(471.914 -56309.6 0)
(281.08 -58790.6 0)
(161.191 -61082.2 0)
(87.9809 -63030.4 0)
(41.4792 -64713.6 0)
(29.8546 -66141.7 0)
(-19.3638 -67377.9 0)
(-34.6235 -68403.4 0)
(-86.5056 -68839.9 0)
(-104.758 -69059 0)
(43.4013 -69019.5 0)
(20.5568 -68645.5 0)
(-24.207 -68226.7 0)
(-70.0797 -66884.5 0)
(-137.539 -65657.9 0)
(-170.347 -63766.4 0)
(-239.929 -61975.1 0)
(-300.693 -59570 0)
(-443.488 -57162.8 0)
(-565.431 -54040.1 0)
(-811.822 -50872.5 0)
(-1002.52 -47247.8 0)
(-1031.25 -43427.5 0)
(-970.364 -39304.1 0)
(-743.568 -34998.1 0)
(-433.788 -30384.4 0)
(-100.853 -26964.7 0)
(1798.03 -22315.1 0)
(50184.7 -50659.9 0)
(-53652.8 -589520 0)
(24408.6 -29522.5 0)
(-21369.1 -2466.33 0)
(233.541 -865.661 0)
(328.524 -589.929 0)
(350.543 -561.197 0)
(300.826 -696.012 0)
(205.546 -1002.44 0)
(165.068 -1496.27 0)
(42.747 -1922.78 0)
(-56.1892 -2353.46 0)
(-86.1519 -2696.27 0)
(-128.873 -2931.1 0)
(-125.937 -3113.91 0)
(-100.337 -3230.41 0)
(-73.1259 -3312.38 0)
(-40.2161 -3358.1 0)
(-22.775 -3400.63 0)
(-12.1824 -3380.08 0)
(-17.6014 -3397.64 0)
(-28.3528 -3323.19 0)
(-36.3117 -3321.47 0)
(-52.5152 -3400.78 0)
(-63.628 -3387.87 0)
(-67.6063 -3432.5 0)
(-59.7882 -3379.4 0)
(-50.6988 -3351.34 0)
(-39.1259 -3261.41 0)
(-34.2682 -3147.47 0)
(-36.9134 -2989.2 0)
(-42.0346 -2725.68 0)
(-83.7688 -2445.97 0)
(-119.542 -1962.03 0)
(-178.535 -1511.25 0)
(-236.82 -1054.87 0)
(-219.329 -715.309 0)
(-132.992 -485.497 0)
(-32.2347 -402.818 0)
(292.213 -431.429 0)
(21316.1 -2022.32 0)
(-24355.9 -26067 0)
(27100.9 5718.74 0)
(-24569.4 -83.1287 0)
(326.045 -35.6288 0)
(406.544 36.8243 0)
(371.005 41.0307 0)
(298.2 5.38343 0)
(160.989 18.9397 0)
(136.734 -23.9968 0)
(49.2562 -47.2527 0)
(-67.9356 -23.4842 0)
(-84.7243 -38.5079 0)
(-121.382 -29.4663 0)
(-127.234 -24.795 0)
(-103.266 -28.1474 0)
(-81.5614 -33.0107 0)
(-55.1931 -48.8543 0)
(-40.5453 -65.1355 0)
(-31.7377 -81.5627 0)
(-31.6815 -94.5342 0)
(-31.356 -102.079 0)
(-31.3716 -105.002 0)
(-43.4351 -102.932 0)
(-54.7699 -95.8915 0)
(-61.9124 -89.4439 0)
(-59.3298 -81.8674 0)
(-56.6478 -80.483 0)
(-43.4791 -80.7444 0)
(-38.382 -78.7905 0)
(-37.0325 -78.3461 0)
(-41.9512 -70.1491 0)
(-75.9413 -71.8516 0)
(-101.8 -50.6325 0)
(-157.076 -41.5434 0)
(-203.361 -11.1553 0)
(-194.899 18.8389 0)
(-132.661 39.8439 0)
(-48.7505 44.8285 0)
(237.414 26.041 0)
(25481.3 -3.66251 0)
(-28046.9 7618.83 0)
(29315.4 5813.32 0)
(-26914.3 116.66 0)
(349.132 128.395 0)
(402.396 127.565 0)
(320.245 122.608 0)
(279.538 42.0743 0)
(177.234 53.8496 0)
(101.283 44.2887 0)
(43.2409 -27.5747 0)
(-47.7623 -3.65869 0)
(-91.9164 -14.4625 0)
(-115.659 -21.2936 0)
(-124.666 -24.5031 0)
(-108.254 -36.9545 0)
(-93.0799 -49.9495 0)
(-71.1727 -69.5267 0)
(-54.2939 -88.5675 0)
(-40.512 -105.127 0)
(-37.3717 -116.688 0)
(-38.4404 -124.439 0)
(-37.1332 -130.026 0)
(-43.7356 -129.797 0)
(-50.6308 -123.471 0)
(-54.0922 -114.473 0)
(-51.1532 -102.575 0)
(-49.6167 -94.4094 0)
(-37.4949 -85.216 0)
(-31.9571 -79.7796 0)
(-28.5862 -70.7601 0)
(-35.7762 -63.5553 0)
(-64.9618 -59.7294 0)
(-90.3364 -44.4105 0)
(-140.493 -37.8123 0)
(-178.633 -5.53439 0)
(-170.184 20.8024 0)
(-107.948 75.1881 0)
(-45.5357 103.819 0)
(245.486 99.2565 0)
(28632.7 209.986 0)
(-31065.4 7884.06 0)
(32629.5 6425.57 0)
(-30047.6 277.945 0)
(336.553 284.612 0)
(400.968 234.224 0)
(288.623 243.308 0)
(231.941 177.867 0)
(163.123 149.763 0)
(58.2703 129.45 0)
(3.05231 71.9335 0)
(-55.3003 44.7568 0)
(-101.718 25.071 0)
(-131.057 3.85498 0)
(-142.326 -9.54301 0)
(-127.787 -28.0401 0)
(-112.949 -43.7941 0)
(-92.4069 -61.8515 0)
(-74.851 -78.9989 0)
(-58.8353 -94.5049 0)
(-50.2913 -107.45 0)
(-44.2091 -115.022 0)
(-36.5346 -118.617 0)
(-37.1182 -118.658 0)
(-40.0032 -114.153 0)
(-41.7761 -107.53 0)
(-39.9958 -98.8618 0)
(-39.9205 -92.4727 0)
(-29.3814 -83.978 0)
(-24.4518 -78.2895 0)
(-21.3981 -67.4729 0)
(-31.3216 -57.6598 0)
(-57.4928 -45.696 0)
(-80.6795 -24.2944 0)
(-119.613 -4.07181 0)
(-146.878 35.1434 0)
(-117.112 70.3881 0)
(-52.663 127.507 0)
(-25.5574 166.16 0)
(339.72 179.467 0)
(32983 456.24 0)
(-35572.2 9010.56 0)
(35735.2 5770.67 0)
(-32831.9 292.579 0)
(307.002 305.2 0)
(362.594 262.188 0)
(265.937 285.31 0)
(189.395 258.578 0)
(130.578 207.494 0)
(26.2834 173.713 0)
(-38.373 124.006 0)
(-92.9208 80.1763 0)
(-131.331 47.6518 0)
(-149.014 19.3668 0)
(-155.401 4.06372 0)
(-141.259 -14.7867 0)
(-125.662 -30.1697 0)
(-105.097 -46.4803 0)
(-85.76 -61.4379 0)
(-67.9284 -74.6873 0)
(-57.1425 -85.6842 0)
(-49.2015 -92.9344 0)
(-40.6372 -97.654 0)
(-39.4334 -99.7904 0)
(-39.9072 -98.09 0)
(-39.3574 -93.9903 0)
(-36.6437 -87.3025 0)
(-35.2741 -81.2658 0)
(-23.8274 -71.7616 0)
(-16.0521 -64.1053 0)
(-8.70669 -51.1105 0)
(-14.7912 -38.372 0)
(-32.8097 -20.0252 0)
(-50.2258 5.07804 0)
(-83.2166 34.2878 0)
(-106.881 73.3508 0)
(-81.1797 115.896 0)
(-15.6586 157.252 0)
(4.53548 190.23 0)
(525.017 214.583 0)
(37142.7 695.933 0)
(-40084.9 8630.78 0)
(38464.3 5035.05 0)
(-35314.3 263.234 0)
(307.267 283.1 0)
(381.801 290.909 0)
(285.144 301.803 0)
(156.956 288.872 0)
(81.3438 234.487 0)
(-22.1818 191.32 0)
(-87.0827 146.56 0)
(-128.878 100.265 0)
(-160.316 70.035 0)
(-173.06 41.2713 0)
(-175.237 24.6249 0)
(-160.776 6.11661 0)
(-143.49 -8.92263 0)
(-122.538 -23.5415 0)
(-102.032 -37.0106 0)
(-82.2 -49.3006 0)
(-67.8749 -59.6301 0)
(-55.7436 -66.5227 0)
(-43.1414 -70.9224 0)
(-37.5384 -72.7276 0)
(-34.414 -71.1629 0)
(-31.381 -67.584 0)
(-27.7341 -61.8439 0)
(-24.9447 -56.3072 0)
(-12.8449 -47.6982 0)
(-4.55158 -41.4936 0)
(3.39938 -32.3826 0)
(-1.36662 -24.5299 0)
(-15.6227 -10.488 0)
(-28.3415 8.17174 0)
(-53.8232 32.7314 0)
(-68.2374 65.381 0)
(-36.2616 104.841 0)
(18.9677 138.533 0)
(29.6889 149.214 0)
(827.035 176.143 0)
(41093.2 866.157 0)
(-44491.9 8029.73 0)
(40849 4145.13 0)
(-37411.1 255.175 0)
(333.67 305.737 0)
(380.618 348.089 0)
(263.974 330.384 0)
(124.527 313.362 0)
(36.5735 251.691 0)
(-58.4471 202.638 0)
(-126.117 158.855 0)
(-166.663 110.921 0)
(-188.179 78.2197 0)
(-192.773 50.8383 0)
(-189.278 35.7013 0)
(-173.587 21.4605 0)
(-154.241 10.3622 0)
(-132.164 0.227879 0)
(-110.582 -8.38977 0)
(-89.7254 -15.9158 0)
(-73.7383 -22.3614 0)
(-60.0832 -27.0188 0)
(-46.6165 -31.0191 0)
(-39.6652 -34.3151 0)
(-34.9507 -35.9627 0)
(-30.3773 -36.4947 0)
(-25.7769 -35.3467 0)
(-21.6428 -33.9439 0)
(-9.55247 -30.1116 0)
(-1.29344 -28.6866 0)
(7.64008 -24.7364 0)
(6.30719 -21.5668 0)
(-1.29721 -12.129 0)
(-8.578 1.5549 0)
(-28.0877 21.7152 0)
(-37.394 49.7648 0)
(-10.6881 83.4619 0)
(27.1011 103.2 0)
(40.7785 106.19 0)
(1215.89 132.964 0)
(44710.7 992.034 0)
(-48568.9 7322.47 0)
(42738.1 3218.17 0)
(-39014.1 220.03 0)
(396.803 302.632 0)
(405.552 380.339 0)
(251.68 394.598 0)
(81.1245 366.771 0)
(-25.3539 293.196 0)
(-111.643 230.981 0)
(-175.465 174.764 0)
(-206.581 125.748 0)
(-218.214 90.9333 0)
(-214.032 63.3071 0)
(-203.547 47.2566 0)
(-185.193 34.576 0)
(-163.951 25.1268 0)
(-140.608 16.7493 0)
(-117.589 9.61756 0)
(-95.6635 3.50686 0)
(-78.5742 -1.84486 0)
(-64.0865 -5.99524 0)
(-50.1723 -9.77374 0)
(-42.3022 -13.0234 0)
(-36.5144 -15.0876 0)
(-30.7873 -16.444 0)
(-25.276 -16.5677 0)
(-19.9 -16.5863 0)
(-7.77866 -14.8824 0)
(0.628154 -15.4032 0)
(10.2602 -13.573 0)
(10.7824 -12.7303 0)
(6.65819 -7.35084 0)
(4.272 0.22787 0)
(-7.36645 13.7981 0)
(-8.73602 34.945 0)
(15.2305 62.4132 0)
(40.8697 75.5998 0)
(58.3706 80.8465 0)
(1680.67 93.0077 0)
(48021.2 931.481 0)
(-52401.2 6542.69 0)
(44209.8 2679.69 0)
(-40220.6 211.079 0)
(488.151 331.001 0)
(469.239 437.794 0)
(250.899 485.646 0)
(26.8122 428.717 0)
(-94.2779 346.231 0)
(-172.572 256.759 0)
(-227.524 186.045 0)
(-247.445 131.118 0)
(-248.349 93.4935 0)
(-234.861 65.9889 0)
(-216.964 49.9923 0)
(-194.912 39.1899 0)
(-171.42 32.0926 0)
(-147.109 26.3705 0)
(-123.343 21.3366 0)
(-100.771 16.5889 0)
(-82.8949 12.0648 0)
(-67.7237 8.26464 0)
(-53.3891 4.60371 0)
(-44.7858 1.23999 0)
(-38.2469 -1.30486 0)
(-31.8037 -3.40939 0)
(-25.914 -4.74333 0)
(-20.0188 -6.26309 0)
(-8.41244 -6.9988 0)
(-0.0316728 -10.2735 0)
(10.2158 -11.3874 0)
(12.3031 -13.7584 0)
(11.1897 -12.3955 0)
(11.8019 -8.6861 0)
(5.36701 -0.939476 0)
(9.45319 13.7793 0)
(28.4883 34.2849 0)
(44.8642 41.1281 0)
(57.5533 45.5111 0)
(2035.59 46.0869 0)
(50925.9 730.013 0)
(-55645.1 5947.66 0)
(45601.2 2199.9 0)
(-41277.4 245.086 0)
(615.274 379.239 0)
(554.573 511.548 0)
(242.933 598.173 0)
(-53.2214 515.609 0)
(-191.059 422.943 0)
(-266.003 303.35 0)
(-296.537 208.869 0)
(-295.767 142.521 0)
(-280.975 99.2759 0)
(-255.952 69.3416 0)
(-229.371 50.9364 0)
(-202.442 39.0215 0)
(-176.304 31.2501 0)
(-150.973 25.3354 0)
(-127.015 20.3677 0)
(-104.598 15.6646 0)
(-86.5957 11.1851 0)
(-71.2763 7.39102 0)
(-56.9415 3.86187 0)
(-47.9959 0.765124 0)
(-40.9947 -1.48424 0)
(-34.1008 -3.22725 0)
(-28.0259 -4.25351 0)
(-22.0734 -5.26678 0)
(-11.6432 -5.89392 0)
(-3.60091 -9.32075 0)
(6.902 -11.1669 0)
(9.81092 -14.7975 0)
(11.5461 -15.2259 0)
(15.3115 -13.0341 0)
(14.2821 -7.16558 0)
(25.2075 6.31919 0)
(41.5847 24.8068 0)
(51.6878 33.4883 0)
(63.1491 41.5436 0)
(2340.28 37.8306 0)
(53708.2 545.092 0)
(-58717.1 5158.21 0)
(46612.9 2859.18 0)
(-41975 242.177 0)
(744.924 415.024 0)
(680.212 592.41 0)
(254.812 714.81 0)
(-142.046 623.936 0)
(-298.819 506.289 0)
(-378.861 364.307 0)
(-382.504 239.778 0)
(-353.053 158.201 0)
(-318.868 108.956 0)
(-281.443 76.7222 0)
(-246.182 55.882 0)
(-213.882 42.0075 0)
(-184.608 32.54 0)
(-157.596 25.3741 0)
(-132.662 19.5331 0)
(-109.62 14.4075 0)
(-90.8676 9.83042 0)
(-74.7806 6.14243 0)
(-59.7741 3.00575 0)
(-49.9375 0.587671 0)
(-42.0941 -0.817027 0)
(-34.4722 -1.6256 0)
(-27.8794 -1.70969 0)
(-21.5995 -1.60903 0)
(-12.319 -1.22147 0)
(-5.11291 -3.56156 0)
(4.93828 -5.02981 0)
(8.39174 -8.79847 0)
(12.889 -9.87638 0)
(19.5691 -8.66304 0)
(24.0166 -4.20266 0)
(40.263 8.30191 0)
(54.6695 21.619 0)
(60.9923 30.5812 0)
(61.7377 37.9009 0)
(2520.83 29.0081 0)
(55860.1 365.218 0)
(-61022.7 4496.78 0)
(48852.7 -1651.9 0)
(-43632.7 125.93 0)
(952.77 417.709 0)
(843.458 660.398 0)
(273.313 814.564 0)
(-254.159 750.454 0)
(-441.247 608.402 0)
(-522.823 442.058 0)
(-495.148 280.281 0)
(-421.832 174.705 0)
(-359.491 115.565 0)
(-307.096 79.7587 0)
(-262.824 56.4955 0)
(-224.935 40.8943 0)
(-192.333 30.3389 0)
(-163.507 22.7967 0)
(-137.583 17.0126 0)
(-113.948 12.2054 0)
(-94.5602 8.06321 0)
(-77.8528 4.77282 0)
(-62.2943 2.0022 0)
(-51.6797 -0.0924787 0)
(-43.1275 -1.24326 0)
(-34.961 -1.77895 0)
(-28.01 -1.5778 0)
(-21.6029 -1.02522 0)
(-13.5248 -0.049732 0)
(-7.27076 -1.07848 0)
(1.85553 -1.47562 0)
(5.14059 -4.50887 0)
(11.6766 -5.45499 0)
(20.7789 -4.6052 0)
(30.6301 -0.899123 0)
(50.0901 10.8172 0)
(63.0539 19.8397 0)
(67.3776 29.1359 0)
(61.6332 35.6444 0)
(2655.69 26.3543 0)
(58013.5 279.241 0)
(-63307.3 3908.77 0)
(45090.6 -5996.18 0)
(-39980.7 15.6079 0)
(1259.96 412.929 0)
(1062.64 728.88 0)
(341.593 880.152 0)
(-340.711 864.814 0)
(-596 714.777 0)
(-695.051 526.282 0)
(-640.135 325.419 0)
(-511.779 193.133 0)
(-410.362 122.744 0)
(-338.365 83.9903 0)
(-283.633 59.383 0)
(-239.088 42.4886 0)
(-202.048 30.904 0)
(-170.438 22.9329 0)
(-142.869 17.1797 0)
(-118.244 12.6822 0)
(-98.0299 8.96959 0)
(-80.6212 6.07788 0)
(-64.4624 3.67545 0)
(-53.065 1.89176 0)
(-43.7192 0.940087 0)
(-34.7946 0.647657 0)
(-27.1531 1.1507 0)
(-20.127 2.20599 0)
(-12.3703 3.89843 0)
(-6.48695 4.34826 0)
(1.63264 5.1983 0)
(4.55708 3.19625 0)
(12.7961 2.91544 0)
(23.9593 3.95034 0)
(38.8781 7.578 0)
(60.2477 18.8787 0)
(72.3221 25.5524 0)
(76.2223 35.9864 0)
(59.0572 42.6532 0)
(2755.57 33.164 0)
(59601.3 197.831 0)
(-65002.6 3419.4 0)
(42674.1 -5336.01 0)
(-37456.6 27.246 0)
(1640.11 401.539 0)
(1293.69 840.975 0)
(404.304 953.709 0)
(-413.521 964.332 0)
(-767.469 818.712 0)
(-898.022 593.216 0)
(-816.182 358.225 0)
(-617.137 198.787 0)
(-464.665 117.398 0)
(-368.153 79.1034 0)
(-302.816 56.5099 0)
(-252.379 40.8995 0)
(-211.177 29.8942 0)
(-176.732 22.4546 0)
(-147.46 17.334 0)
(-121.86 13.5248 0)
(-100.924 10.4613 0)
(-82.9544 8.07755 0)
(-66.3282 6.06876 0)
(-54.3156 4.54828 0)
(-44.3264 3.6937 0)
(-34.758 3.37524 0)
(-26.5083 3.72548 0)
(-18.9551 4.59666 0)
(-11.4604 6.02158 0)
(-6.01817 6.63723 0)
(0.745412 7.47144 0)
(2.94074 5.66041 0)
(12.4033 5.26973 0)
(25.2719 5.80717 0)
(45.0156 9.00131 0)
(67.4109 19.768 0)
(79.5395 25.3738 0)
(83.8565 38.0514 0)
(58.9135 45.7197 0)
(2805.23 44.119 0)
(61276.6 179.909 0)
(-66777.7 3081.5 0)
(39811.3 -6276.71 0)
(-34451.8 271.999 0)
(2044.1 605.215 0)
(1594.73 1024.82 0)
(460.463 1066.05 0)
(-470.799 1034.58 0)
(-953.621 893.937 0)
(-1138.79 623.847 0)
(-1020.22 384.92 0)
(-743.849 195.835 0)
(-525.693 107.263 0)
(-397.039 70.3392 0)
(-320.447 51.3012 0)
(-264.736 38.0537 0)
(-219.822 28.2016 0)
(-182.541 21.493 0)
(-151.474 17.0454 0)
(-124.866 13.918 0)
(-103.279 11.4894 0)
(-84.854 9.60871 0)
(-67.8634 8.00444 0)
(-55.3537 6.76694 0)
(-44.8496 6.04802 0)
(-34.764 5.73115 0)
(-25.9761 5.94035 0)
(-17.9144 6.60644 0)
(-10.4039 7.75501 0)
(-5.08982 8.4986 0)
(0.691331 9.41427 0)
(2.43544 8.24198 0)
(12.9376 8.26797 0)
(27.5552 8.85476 0)
(52.3313 11.978 0)
(76.0249 22.4794 0)
(89.9406 28.0227 0)
(95.8283 42.7894 0)
(64.9042 50.2148 0)
(2884.88 55.9333 0)
(62528.2 175.834 0)
(-68158.5 2631.02 0)
(37063.3 -10090.5 0)
(-30824.9 1178.57 0)
(2365.55 1125.77 0)
(1737.77 1449.83 0)
(413.711 1243.69 0)
(-579.377 1057.78 0)
(-1163.27 884.553 0)
(-1388.53 596.228 0)
(-1228.63 371.084 0)
(-884.697 177.876 0)
(-585.597 86.0478 0)
(-422.081 55.2284 0)
(-333.928 41.9503 0)
(-274.638 32.3182 0)
(-227.136 24.4283 0)
(-187.483 18.8628 0)
(-154.76 15.2432 0)
(-127.214 12.825 0)
(-105.077 11.0163 0)
(-86.3126 9.62258 0)
(-69.0666 8.41547 0)
(-56.2009 7.4613 0)
(-45.3245 6.87307 0)
(-34.8618 6.56856 0)
(-25.6649 6.63985 0)
(-17.2065 7.05642 0)
(-9.63704 7.83618 0)
(-4.41924 8.39216 0)
(0.498125 9.02823 0)
(1.83612 7.99326 0)
(12.9938 7.91741 0)
(28.847 8.01863 0)
(58.1447 10.0728 0)
(82.8721 18.9593 0)
(99.111 22.9808 0)
(105.242 37.1477 0)
(71.5794 40.6684 0)
(2926.28 55.1071 0)
(63758.1 224.443 0)
(-69484.2 2667.33 0)
(32841.8 -16319 0)
(-23643.4 2775.45 0)
(2305.49 2105.15 0)
(1708.36 2166.73 0)
(82.6724 1478.24 0)
(-816.879 1024.48 0)
(-1398.39 755.141 0)
(-1633.59 492.355 0)
(-1423.36 318.291 0)
(-1018.52 134.071 0)
(-643.88 57.3885 0)
(-439.533 36.7197 0)
(-342.525 30.0511 0)
(-281.62 24.0754 0)
(-232.788 18.4435 0)
(-191.392 14.2891 0)
(-157.292 11.615 0)
(-128.94 9.90389 0)
(-106.365 8.67165 0)
(-87.3603 7.72912 0)
(-69.946 6.90264 0)
(-56.84 6.23698 0)
(-45.7099 5.80929 0)
(-34.9887 5.5662 0)
(-25.506 5.56867 0)
(-16.7616 5.80045 0)
(-9.11678 6.27269 0)
(-3.94111 6.63761 0)
(0.306941 7.03817 0)
(1.36501 6.25136 0)
(12.962 6.16254 0)
(29.6322 6.02357 0)
(62.8741 7.31032 0)
(88.4635 14.0795 0)
(107.468 16.9285 0)
(112.873 28.8291 0)
(82.2106 29.4717 0)
(3061.97 47.347 0)
(65045.4 285.19 0)
(-70907.2 4979.53 0)
(29427.3 -14851.8 0)
(-13070.7 3430.05 0)
(1778.97 3673.95 0)
(1133.65 2693.71 0)
(-687.002 1402.15 0)
(-1276.18 778.925 0)
(-1676.04 514.214 0)
(-1809.49 324.298 0)
(-1573.89 229.404 0)
(-1136.11 80.1116 0)
(-679.408 31.5402 0)
(-448.424 21.2228 0)
(-346.112 19.3813 0)
(-285.824 15.9868 0)
(-236.566 12.2997 0)
(-194.063 9.48361 0)
(-158.986 7.66163 0)
(-130.05 6.51706 0)
(-107.173 5.71941 0)
(-88.0173 5.12373 0)
(-70.5045 4.61013 0)
(-57.2545 4.20423 0)
(-45.9709 3.95504 0)
(-35.0936 3.83104 0)
(-25.4391 3.86466 0)
(-16.5281 4.04308 0)
(-8.83032 4.37016 0)
(-3.6816 4.64526 0)
(0.125916 4.95179 0)
(0.992333 4.43958 0)
(12.7743 4.44985 0)
(29.9531 4.30688 0)
(65.9078 5.00757 0)
(92.1405 9.79282 0)
(113.324 11.233 0)
(117.329 19.7754 0)
(89.4239 17.2717 0)
(3172.7 31.058 0)
(68510.9 94.0131 0)
(-74796.6 -525.031 0)
)
;
boundaryField
{
inlet
{
type extrapolatedCalculated;
value nonuniform List<vector> 5((515530 -0.129701 0) (515529 -0.0808529 0) (515529 2.41585e-08 0) (515529 0.0808529 0) (515530 0.129701 0));
}
outlet
{
type extrapolatedCalculated;
value nonuniform List<vector>
165
(
(86014.3 14851.8 0)
(114839 16319 0)
(138086 10090.5 0)
(150496 6276.71 0)
(161929 5336.01 0)
(171391 5996.18 0)
(185873 1651.9 0)
(177862 -2859.18 0)
(174326 -2199.9 0)
(169288 -2679.69 0)
(163842 -3218.17 0)
(156789 -4145.13 0)
(147798 -5035.05 0)
(137364 -5770.67 0)
(125570 -6425.57 0)
(112677 -5813.32 0)
(103534 -5718.74 0)
(91681.5 29522.5 0)
(214515 645378 0)
(2.56828e+06 -720013 0)
(696212 -2.6652e+06 0)
(-617329 -233395 0)
(-25000.8 -115575 0)
(7804.37 -133060 0)
(7838.89 -146791 0)
(8377.49 -165016 0)
(7747.08 -181179 0)
(7065.99 -196802 0)
(6304.69 -210087 0)
(5802.88 -222486 0)
(5095.51 -233722 0)
(4470.23 -243190 0)
(3959.74 -251867 0)
(3399 -259306 0)
(2924.97 -265734 0)
(2527.15 -271275 0)
(2156.72 -276118 0)
(1396.64 -280220 0)
(614.104 -281918 0)
(144.734 -282782 0)
(-434.701 -282549 0)
(-816.513 -280891 0)
(-1760.65 -279123 0)
(-2542.91 -273523 0)
(-3064.52 -268525 0)
(-3599.63 -260815 0)
(-4082.87 -253614 0)
(-4671.6 -243971 0)
(-5365.77 -234377 0)
(-6103.53 -221885 0)
(-6629.1 -209246 0)
(-7293.82 -194600 0)
(-7833.33 -179180 0)
(-8359.73 -162305 0)
(-8814.72 -144678 0)
(-7874.23 -125976 0)
(-7808.01 -112576 0)
(23125.7 -94893.7 0)
(567895 -205635 0)
(-635257 -2.43982e+06 0)
(-280354 525.031 0)
(-265851 -4979.53 0)
(-260682 -2667.33 0)
(-255645 -2631.02 0)
(-250537 -3081.5 0)
(-243741 -3419.4 0)
(-237387 -3908.77 0)
(-228786 -4496.78 0)
(-220244 -5158.21 0)
(-209140 -5947.66 0)
(-197557 -6542.69 0)
(-184174 -7322.47 0)
(-169538 -8029.73 0)
(-153399 -8630.78 0)
(-136406 -9010.56 0)
(-118874 -7884.06 0)
(-106565 -7618.83 0)
(-90764.2 26067 0)
(-204117 589520 0)
(-2.3511e+06 -660777 0)
(-269448 -4388.78 0)
(-269224 2032.62 0)
(-272075 -5.28256e-07 0)
(-269224 -2032.62 0)
(-269448 4388.78 0)
(-2.3511e+06 660777 0)
(-204117 -589520 0)
(-90764.2 -26067 0)
(-106565 7618.83 0)
(-118874 7884.06 0)
(-136406 9010.56 0)
(-153399 8630.78 0)
(-169538 8029.73 0)
(-184174 7322.47 0)
(-197557 6542.69 0)
(-209140 5947.66 0)
(-220244 5158.21 0)
(-228786 4496.78 0)
(-237387 3908.77 0)
(-243741 3419.4 0)
(-250537 3081.5 0)
(-255645 2631.02 0)
(-260682 2667.33 0)
(-265851 4979.53 0)
(-280354 -525.031 0)
(696212 2.6652e+06 0)
(-617329 233395 0)
(-25000.8 115575 0)
(7804.37 133060 0)
(7838.89 146791 0)
(8377.49 165016 0)
(7747.08 181179 0)
(7065.99 196802 0)
(6304.69 210087 0)
(5802.88 222486 0)
(5095.51 233722 0)
(4470.23 243190 0)
(3959.74 251867 0)
(3399 259306 0)
(2924.97 265734 0)
(2527.15 271275 0)
(2156.72 276118 0)
(1396.64 280220 0)
(614.103 281918 0)
(144.734 282782 0)
(-434.701 282549 0)
(-816.513 280891 0)
(-1760.65 279123 0)
(-2542.91 273523 0)
(-3064.52 268525 0)
(-3599.63 260815 0)
(-4082.87 253614 0)
(-4671.6 243971 0)
(-5365.77 234377 0)
(-6103.53 221885 0)
(-6629.1 209246 0)
(-7293.82 194600 0)
(-7833.33 179180 0)
(-8359.73 162305 0)
(-8814.72 144678 0)
(-7874.23 125976 0)
(-7808.01 112576 0)
(23125.7 94893.7 0)
(567895 205635 0)
(-635257 2.43982e+06 0)
(2.56828e+06 720013 0)
(214515 -645378 0)
(91681.5 -29522.5 0)
(103534 5718.74 0)
(112677 5813.32 0)
(125570 6425.57 0)
(137364 5770.67 0)
(147798 5035.05 0)
(156789 4145.13 0)
(163842 3218.17 0)
(169288 2679.69 0)
(174326 2199.9 0)
(177862 2859.18 0)
(185873 -1651.9 0)
(171391 -5996.18 0)
(161929 -5336.01 0)
(150496 -6276.71 0)
(138086 -10090.5 0)
(114839 -16319 0)
(86014.3 -14851.8 0)
)
;
}
obstacle
{
type extrapolatedCalculated;
value nonuniform List<vector>
40
(
(149759 0 0)
(-121739 0 0)
(-15568 0 0)
(-3012.58 0 0)
(-2197.77 0 0)
(-1988.05 0 0)
(-2041.51 0 0)
(-2158.24 0 0)
(-2058.03 0 0)
(-1355.52 0 0)
(149759 0 0)
(-121739 0 0)
(-15568 0 0)
(-3012.58 0 0)
(-2197.77 0 0)
(-1988.05 3.63798e-11 0)
(-2041.51 0 0)
(-2158.24 0 0)
(-2058.03 3.63798e-11 0)
(-1355.52 0 0)
(-751.042 -500.695 1.35324e-11)
(-639.75 -426.5 -1.61772e-11)
(-537.207 -358.138 -2.04617e-11)
(300.084 200.056 0)
(-5876.8 -3917.86 -8.84705e-11)
(-751.042 500.695 -4.04164e-11)
(-639.75 426.5 -1.61772e-11)
(-537.207 358.138 -2.04617e-11)
(300.084 -200.056 -5.56137e-11)
(-5876.8 3917.86 8.84705e-11)
(-13003.1 -1444.79 1.67015e-11)
(-6240.07 -693.341 -2.08812e-14)
(-7662.87 -851.43 0)
(-9485.91 -1053.99 3.17427e-14)
(-13566.8 -1507.42 7.3152e-12)
(-13003.1 1444.79 3.33594e-11)
(-6240.07 693.341 -2.695e-11)
(-7662.87 851.43 0)
(-9485.91 1053.99 1.81146e-11)
(-13566.8 1507.42 -7.3152e-12)
)
;
}
empty
{
type empty;
}
}
// ************************************************************************* //
| [
"andytorrestb@gmail.com"
] | andytorrestb@gmail.com | |
891c1ec5b8554fa59b043ad6ad2271e300cca0eb | 6bdc21906afc40a9b9e2359dd7833df6e5eb1b2a | /pegasus_x64/emulator.cpp | 9be28ff2ce99663f7d151fc9cce8553d3567aa11 | [] | no_license | idkwim/pegasus | 69c283f6e2b53409160f2a6076f37728987304ff | 8269104660a6ae4f26bbc2b430bdb89cd6670364 | refs/heads/master | 2021-01-01T17:53:20.588941 | 2017-07-22T05:01:55 | 2017-07-22T05:01:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,135 | cpp | #define _CRT_SECURE_NO_WARNINGS
#include <unicorn/unicorn.h>
#include <distorm/include/distorm.h>
#include <distorm/include/mnemonics.h>
#include <list>
#include <memory>
#include <winternl.h>
#include <Psapi.h>
#include "interface.h"
#pragma comment(lib, "unicorn_static_x64.lib")
Wow64EmulationDebugger::Wow64EmulationDebugger() : emulator_x86_(nullptr), emulator_x64_(nullptr), teb_address_(0), peb_address_(0), gdt_base_(0), x64_flag_(0)
{
}
Wow64EmulationDebugger::~Wow64EmulationDebugger()
{
}
///
///
///
size_t __stdcall Wow64EmulationDebugger::alignment(size_t region_size, unsigned long image_aligin)
{
size_t alignment = region_size;
while (1)
{
if (alignment > image_aligin)
alignment -= image_aligin;
else
break;
}
alignment = image_aligin - alignment;
return alignment += region_size;
}
bool __stdcall Wow64EmulationDebugger::load(unsigned long long load_address, size_t load_size, void *dump, size_t write_size)
{
void *engine = nullptr;
if (x64_flag_)
engine = emulator_x64_;
else
engine = emulator_x86_;
if (!engine)
return false;
uc_err err;
if ((err = uc_mem_map((uc_engine *)engine, load_address, load_size, UC_PROT_ALL)) != 0 || (err = uc_mem_write((uc_engine *)engine, load_address, dump, write_size)) != 0)
{
if (err != UC_ERR_MAP)
return false;
}
return true;
}
bool __stdcall Wow64EmulationDebugger::load_ex(std::shared_ptr<binary::linker> windbg_linker)
{
std::list<MEMORY_BASIC_INFORMATION64> memory_list;
uint64_t address = 0;
MEMORY_BASIC_INFORMATION64 mbi = { 0, };
unsigned int count_begin = 0;
unsigned int count_end = 0;
do
{
ZeroMemory(&mbi, sizeof(mbi));
if (windbg_linker->virtual_query(address, &mbi))
{
if (mbi.BaseAddress > address)
{
address = mbi.BaseAddress;
continue;
}
if (mbi.State == MEM_COMMIT)
{
memory_list.push_back(mbi);
++count_begin;
}
address += mbi.RegionSize;
}
else
break;
} while (true);
///
///
///
std::list<MEMORY_BASIC_INFORMATION64>::iterator it;
for (it = memory_list.begin(); it != memory_list.end(); ++it)
{
unsigned char *dump = (unsigned char *)malloc((size_t)it->RegionSize);
if (!dump)
continue;
std::shared_ptr<void> dump_closer(dump, free);
memset(dump, 0, (size_t)it->RegionSize);
unsigned long readn = 0;
if (!windbg_linker->read_memory(it->BaseAddress, dump, (size_t)it->RegionSize))
continue;
if (!load((uint64_t)it->BaseAddress, (size_t)it->RegionSize, dump, (size_t)it->RegionSize))
continue;
++count_end;
}
if (count_begin != count_end)
return false;
return true;
}
bool __stdcall Wow64EmulationDebugger::link(unsigned long long address)
{
address += 0x10;
size_t resize = alignment((size_t)address, 0x1000);
void *engine = nullptr;
if (x64_flag_)
engine = emulator_x64_;
else
engine = emulator_x86_;
if (!engine)
return false;
uc_engine *uc = (uc_engine *)engine;
uc_mem_region *um = nullptr;
uint32_t count = 0;
if (uc_mem_regions(uc, &um, &count) != 0)
return false;
uc_mem_region b = { 0, };
for (unsigned int i = 0; i < count; ++i)
{
if (um[i].end < resize && um[i+1].begin >= resize)
{
b.begin = um[i].begin;
b.end = um[i].end;
}
}
unsigned long long base = b.end + 1;
size_t size = resize - base;
uc_err err;
if((err = uc_mem_map(uc, base, size, UC_PROT_ALL)) != 0)
return false;
return true;
}
///
/// segmentation
///
void __stdcall Wow64EmulationDebugger::set_global_descriptor(SegmentDescriptor *desc, uint32_t base, uint32_t limit, uint8_t is_code)
{
desc->descriptor = 0;
desc->base_low = base & 0xffff;
desc->base_mid = (base >> 16) & 0xff;
desc->base_hi = base >> 24;
if (limit > 0xfffff)
{
limit >>= 12;
desc->granularity = 1;
}
desc->limit_low = limit & 0xffff;
desc->limit_hi = limit >> 16;
desc->dpl = 3;
desc->present = 1;
desc->db = 1;
desc->type = is_code ? 0xb : 3;
desc->system = 1;
}
bool __stdcall Wow64EmulationDebugger::create_global_descriptor_table(void *engine, void *context, size_t context_size)
{
NT_TIB64 tib;
uc_engine *uc = (uc_engine *)engine;
SegmentDescriptor global_descriptor[31];
CONTEXT *ctx = (CONTEXT *)context;
uc_x86_mmr gdtr;
memset(&tib, 0, sizeof(tib));
if (context_size != sizeof(CONTEXT))
return false;
if (!read(teb_address_, &tib, sizeof(tib)))
return false;
memset(&gdtr, 0, sizeof(gdtr));
memset(global_descriptor, 0, sizeof(global_descriptor));
gdtr.base = gdt_base_;
gdtr.limit = sizeof(global_descriptor) - 1;
uc_err err;
if ((err = uc_mem_map(uc, gdt_base_, 0x10000, UC_PROT_WRITE | UC_PROT_READ)) != 0)
{
if (err != UC_ERR_MAP)
return false;
}
if (uc_reg_write(uc, UC_X86_REG_GDTR, &gdtr) != 0)
return false;
if (ctx->SegDs == ctx->SegSs)
ctx->SegSs = 0x88; // rpl = 0
ctx->SegGs = 0x63;
set_global_descriptor(&global_descriptor[0x33 >> 3], 0, 0xfffff000, 1); // 64 code
set_global_descriptor(&global_descriptor[ctx->SegCs >> 3], 0, 0xfffff000, 1);
set_global_descriptor(&global_descriptor[ctx->SegDs >> 3], 0, 0xfffff000, 0);
set_global_descriptor(&global_descriptor[ctx->SegFs >> 3], (uint32_t)tib.ExceptionList, 0xfff, 0);
set_global_descriptor(&global_descriptor[ctx->SegGs >> 3], (uint32_t)tib.Self, 0xfffff000, 0);
set_global_descriptor(&global_descriptor[ctx->SegSs >> 3], 0, 0xfffff000, 0);
global_descriptor[ctx->SegSs >> 3].dpl = 0; // dpl = 0, cpl = 0
if (uc_mem_write(uc, gdt_base_, &global_descriptor, sizeof(global_descriptor)) != 0)
return false;
return true;
}
///
///
///
bool __stdcall Wow64EmulationDebugger::disasm(void *code, size_t size, uint32_t dt, void *out)
{
return false;
}
///
///
///
bool __stdcall Wow64EmulationDebugger::check(unsigned long long address)
{
void *engine = nullptr;
if (x64_flag_)
engine = emulator_x64_;
else
engine = emulator_x86_;
unsigned char dump[16];
if (!engine)
return false;
uc_engine *uc = (uc_engine *)engine;
if (uc_mem_read(uc, address, dump, sizeof(dump) != 0))
return false;
return true;
}
bool __stdcall Wow64EmulationDebugger::read(unsigned long long address, void *dump, size_t dump_size)
{
void *engine = nullptr;
if (x64_flag_)
engine = emulator_x64_;
else
engine = emulator_x86_;
if (!engine)
return false;
uc_engine *uc = (uc_engine *)engine;
if (uc_mem_read(uc, address, dump, dump_size) != 0)
return false;
return true;
}
bool __stdcall Wow64EmulationDebugger::write(unsigned long long address, void *dump, size_t dump_size)
{
void *engine = nullptr;
if (x64_flag_)
engine = emulator_x64_;
else
engine = emulator_x86_;
if (!engine)
return false;
uc_engine *uc = (uc_engine *)engine;
if (uc_mem_write(uc, address, dump, dump_size) != 0)
return false;
return true;
}
bool __stdcall Wow64EmulationDebugger::read_register(char *mask, unsigned long long *value)
{
void *engine = nullptr;
if (x64_flag_)
engine = emulator_x64_;
else
engine = emulator_x86_;
if (!engine)
return false;
unsigned long register_id = 0;
if (strstr(mask, "eax"))
register_id = UC_X86_REG_EAX;
else if (strstr(mask, "ebx"))
register_id = UC_X86_REG_EBX;
else if (strstr(mask, "ecx"))
register_id = UC_X86_REG_ECX;
else if (strstr(mask, "edx"))
register_id = UC_X86_REG_EDX;
else if (strstr(mask, "esi"))
register_id = UC_X86_REG_ESI;
else if (strstr(mask, "edi"))
register_id = UC_X86_REG_EDI;
else if (strstr(mask, "esp"))
register_id = UC_X86_REG_ESP;
else if (strstr(mask, "ebp"))
register_id = UC_X86_REG_EBP;
else if (strstr(mask, "eip"))
register_id = UC_X86_REG_EIP;
///
else if (strstr(mask, "rax"))
register_id = UC_X86_REG_RAX;
else if (strstr(mask, "rbx"))
register_id = UC_X86_REG_RBX;
else if (strstr(mask, "rcx"))
register_id = UC_X86_REG_RCX;
else if (strstr(mask, "rdx"))
register_id = UC_X86_REG_RDX;
else if (strstr(mask, "rsi"))
register_id = UC_X86_REG_RSI;
else if (strstr(mask, "rdi"))
register_id = UC_X86_REG_RDI;
else if (strstr(mask, "rsp"))
register_id = UC_X86_REG_RSP;
else if (strstr(mask, "rbp"))
register_id = UC_X86_REG_RBP;
else if (strstr(mask, "rip"))
register_id = UC_X86_REG_RIP;
///
else if (strstr(mask, "r8"))
register_id = UC_X86_REG_R8;
else if (strstr(mask, "r9"))
register_id = UC_X86_REG_R9;
else if (strstr(mask, "r10"))
register_id = UC_X86_REG_R10;
else if (strstr(mask, "r11"))
register_id = UC_X86_REG_R11;
else if (strstr(mask, "r12"))
register_id = UC_X86_REG_R12;
else if (strstr(mask, "r13"))
register_id = UC_X86_REG_R13;
else if (strstr(mask, "r14"))
register_id = UC_X86_REG_R14;
else if (strstr(mask, "r15"))
register_id = UC_X86_REG_R15;
///
else if (strstr(mask, "cs"))
register_id = UC_X86_REG_CS;
else if (strstr(mask, "ds"))
register_id = UC_X86_REG_DS;
else if (strstr(mask, "es"))
register_id = UC_X86_REG_ES;
else if (strstr(mask, "fs"))
register_id = UC_X86_REG_FS;
else if (strstr(mask, "gs"))
register_id = UC_X86_REG_GS;
else if (strstr(mask, "ss"))
register_id = UC_X86_REG_SS;
uc_engine *uc = (uc_engine *)engine;
if (uc_reg_read(uc, register_id, value) != 0)
return false;
return true;
}
bool __stdcall Wow64EmulationDebugger::write_register(char *mask, unsigned long long value)
{
void *engine = nullptr;
if (x64_flag_)
engine = emulator_x64_;
else
engine = emulator_x86_;
if (!engine)
return false;
unsigned long register_id = 0;
if (strstr(mask, "eax"))
register_id = UC_X86_REG_EAX;
else if (strstr(mask, "ebx"))
register_id = UC_X86_REG_EBX;
else if (strstr(mask, "ecx"))
register_id = UC_X86_REG_ECX;
else if (strstr(mask, "edx"))
register_id = UC_X86_REG_EDX;
else if (strstr(mask, "esi"))
register_id = UC_X86_REG_ESI;
else if (strstr(mask, "edi"))
register_id = UC_X86_REG_EDI;
else if (strstr(mask, "esp"))
register_id = UC_X86_REG_ESP;
else if (strstr(mask, "ebp"))
register_id = UC_X86_REG_EBP;
else if (strstr(mask, "eip"))
register_id = UC_X86_REG_EIP;
///
else if (strstr(mask, "rax"))
register_id = UC_X86_REG_RAX;
else if (strstr(mask, "rbx"))
register_id = UC_X86_REG_RBX;
else if (strstr(mask, "rcx"))
register_id = UC_X86_REG_RCX;
else if (strstr(mask, "rdx"))
register_id = UC_X86_REG_RDX;
else if (strstr(mask, "rsi"))
register_id = UC_X86_REG_RSI;
else if (strstr(mask, "rdi"))
register_id = UC_X86_REG_RDI;
else if (strstr(mask, "rsp"))
register_id = UC_X86_REG_RSP;
else if (strstr(mask, "rbp"))
register_id = UC_X86_REG_RBP;
else if (strstr(mask, "rip"))
register_id = UC_X86_REG_RIP;
///
else if (strstr(mask, "r8"))
register_id = UC_X86_REG_R8;
else if (strstr(mask, "r9"))
register_id = UC_X86_REG_R9;
else if (strstr(mask, "r10"))
register_id = UC_X86_REG_R10;
else if (strstr(mask, "r11"))
register_id = UC_X86_REG_R11;
else if (strstr(mask, "r12"))
register_id = UC_X86_REG_R12;
else if (strstr(mask, "r13"))
register_id = UC_X86_REG_R13;
else if (strstr(mask, "r14"))
register_id = UC_X86_REG_R14;
else if (strstr(mask, "r15"))
register_id = UC_X86_REG_R15;
///
else if (strstr(mask, "cs"))
register_id = UC_X86_REG_CS;
else if (strstr(mask, "ds"))
register_id = UC_X86_REG_DS;
else if (strstr(mask, "es"))
register_id = UC_X86_REG_ES;
else if (strstr(mask, "fs"))
register_id = UC_X86_REG_FS;
else if (strstr(mask, "gs"))
register_id = UC_X86_REG_GS;
else if (strstr(mask, "ss"))
register_id = UC_X86_REG_SS;
uc_engine *uc = (uc_engine *)engine;
if (uc_reg_write(uc, register_id, &value) != 0)
return false;
return true;
}
bool __stdcall Wow64EmulationDebugger::read_context(void *context, size_t context_size)
{
if (x64_flag_)
return read_context_x64((CONTEXT *)context);
return read_context_x86((CONTEXT *)context);
}
///
///
///
bool __stdcall Wow64EmulationDebugger::is_64()
{
if (x64_flag_)
return true;
return false;
}
///
///
///
bool __stdcall Wow64EmulationDebugger::attach()
{
return attach_x86();
}
bool __stdcall Wow64EmulationDebugger::trace()
{
if (x64_flag_)
return trace_x64();
return trace_x86();
}
bool __stdcall Wow64EmulationDebugger::cpu_switch()
{
if (x64_flag_)
return switch_x86();
return switch_x64();
} | [
"0a777h@gmail.com"
] | 0a777h@gmail.com |
d52df934276a489a84fe300d0480e517a990b9fc | d2650b73a3d64ec4c0614b08a4b0ba7370b7327a | /cpp/coding-test/beads.cpp | f63e27c9a8056f5ad2b082d2beb387793b8ee0d9 | [] | no_license | jodnddus/nojam | 1fdf90805be8ea8bdfad5030f5ac39bc5b08d89f | a2e646ab06bc81f89bd451faea1da6231547de05 | refs/heads/master | 2020-05-18T07:57:21.808166 | 2019-08-15T10:05:53 | 2019-08-15T10:05:53 | 184,280,261 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 641 | cpp | #include <stdio.h>
#include <vector>
using namespace std;
vector<int> beads;
vector<int> flag;
int a(int index, int step, int start)
{
if (index == beads[index]) return 0;
else if (beads[index] == start) return step;
else return a(beads[index], ++step, start);
}
int solution(vector<int> &A)
{
beads = A;
int N = A.size();
int h=0, max=0;
for (int i=0; i<N; i++)
{
h = a(i, 1, i);
if (max < h) max = h;
}
return max;
}
int main()
{
int input, N;
vector<int> beadsss;
scanf("%d", &N);
for (int i=0; i<N; i++)
{
scanf("%d", &input);
beadsss.push_back(input);
}
printf("%d\n", solution(beadsss));
return 0;
}
| [
"lockhost23@gmail.com"
] | lockhost23@gmail.com |
d1266a023aee645ad1e575a8cbca037de513f345 | 4ec56d3dfec333815d4cccb194d94b0911c66f65 | /HttpLib/SocketClient.h | 28f2588a02535a01ae2cde3545a7c39dda49b529 | [] | no_license | imcooder/SimpleHttpServer | 86991661af22a05be4175f7fab2484a6d26aac63 | 8d7a6d983cdf8e49bd775b3dbce0ae46c2a19604 | refs/heads/master | 2022-04-22T09:49:32.516802 | 2020-04-25T08:34:51 | 2020-04-25T08:34:51 | 258,722,850 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,092 | h | #include <iostream>
#include <istream>
#include <ostream>
#include <string>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/enable_shared_from_this.hpp>
using boost::asio::ip::tcp;
class SocketClient : public boost::enable_shared_from_this<SocketClient>
{
public:
SocketClient(boost::asio::io_service& io_service, const std::string& server, const std::string& path, int nPort =5808);
public:
void Init();
private:
void handle_resolve(const boost::system::error_code& err, tcp::resolver::iterator endpoint_iterator);
void handle_connect(const boost::system::error_code& err);
void handle_write_request(const boost::system::error_code& err);
void handle_read_status_line(const boost::system::error_code& err);
void handle_read_headers(const boost::system::error_code& err);
void handle_read_content(const boost::system::error_code& err);
void timeout() ;
public:
boost::asio::streambuf response_;
private:
tcp::resolver resolver_;
tcp::socket socket_;
boost::asio::streambuf request_;
boost::asio::deadline_timer t ;
std::string m_strServer;
int m_nPort;
}; | [
"imcooder@gmail.com"
] | imcooder@gmail.com |
858ca1d3f03cb9abb940e8eb8a962e39efa2e974 | 29b276cbb2c038c4a701839219b35635103c48a8 | /include/UWUEngine/GamePlay/PlayerController.h | 29b14bb440b370a882060692cf8d2e7666745965 | [] | no_license | digipen-team-uwu/uwu-engine | af0f9c40809d18750db916b4f1b08a16a606ff44 | 1610fdd23d52e16839d5d432223c39fd709b4eee | refs/heads/master | 2020-12-05T18:03:48.416178 | 2020-02-07T02:08:19 | 2020-02-07T02:08:19 | 232,198,651 | 3 | 0 | null | 2020-02-12T01:21:05 | 2020-01-06T22:44:02 | C++ | UTF-8 | C++ | false | false | 3,005 | h | /******************************************************************************/
/*!
\par Project Umbra
\file PlayerController.h
\author Yi Qian
\date 2019/12/05
\brief Player Behavior,I hate file header comments
Copyright 2019 DigiPen, All rights reserved.
*/
/******************************************************************************/
#pragma once
#include <UWUEngine/Component/BehaviorComponentManager.h>
#include <UWUEngine/statemachine.hpp>
#include <UWUEngine/Timer.h>
#include <UWUEngine/Physics/Colliders/Collider.h>
#include <UWUEngine/Event/Type/Collision.h>
StateMachine(Player, false, StartUp, Grounded, Airborne, Dash, Hurt, Death)
class PlayerData
{
public:
static void InitPlayer();
//Player Helpers
static void Hurt(size_t damage);
static void LoseEnergy(size_t energy_);
static void GainEnergy(size_t energy_);
static void SetLastSafePos(glm::vec4 pos);
static glm::vec4 const& GetLastSafePos();
static void ResetPlayerPos();
//Getters
static EntityID GetPlayerID();
static size_t GetHealth();
static size_t GetEnergy();
static PlayerStateMachine::_PlayerStateMachinestate GetCurrentState();
static bool FacingRight();
static float GetTopXSpeed();
static float GetTopYSpeed();
static float GetGravity();
static float GetJumpLaunchSpeed();
friend Behavior<EntityManager::Type::Player>;
friend PlayerStateMachine;
private:
//TODO::Deserialize Player Data
static EntityID playerID;
static size_t health;
static size_t energy;
//Hurt Data
static bool HurtFromRight;
static float HurtSpeed;
static float HurtTime;
static float HurtDir;
static Timer HurtTimer;
static Timer DashCooldown;
static PlayerStateMachine::_PlayerStateMachinestate currState;
static float TopXSpeed;
static float TopYSpeed;
static float JumpLaunchSpeed;
static float Gravity;
// Last safe position for hazard damage reset
static glm::vec4 lastSafePos;
//Cheats
static bool isInvincible;
};
template<>
class Behavior<EntityManager::Type::Player> : public BaseBehavior
{
public:
Behavior(EntityID id);
~Behavior() override;
void Update() override;
void Serialize(std::ofstream& stream) override;
void Deserialize(rapidjson::Value& object, EntityID ID, const char* filePath) override;
void OnCollide(const Event<EventType::Collision>& info);
EventListener<EventType::Collision> listener;
private:
// State machine
PlayerStateMachine player_state_;
// State OnCollide event
//TODO: event system
void OnCollideGrounded(const Event<EventType::Collision>& info);
void OnCollideAirborne(const Event<EventType::Collision>& info);
void OnCollideDash(const Event<EventType::Collision>& info);
enum class ABSTRACT_DIR
{
TOP,
LEFT,
RIGHT,
BOTTOM,
INVALID
};
glm::vec2 CalculateResolveAngle(const Event<EventType::Collision>& info) const;
ABSTRACT_DIR GetAbstractDirection(float angle) const;
bool IsDirectionRight(float angle) const;
};
| [
"tony.qian@digipen.edu"
] | tony.qian@digipen.edu |
14f47d8b3ef53016eced8791467a92eee5949c3b | 56dc83b864de250b0b0fde6892d934dae0900fb2 | /OneSolution/RollerBlind/Adafruit_NeoPixel.h | 4f88b95039388fc7af7e2d0f2aa3b4e1ff157843 | [] | no_license | timdows/AMD | 192b2aa4b4e481229d563487a4c41717d5f8c954 | 11577e2a7b0d93bd6745d99af430483e97ad3a50 | refs/heads/master | 2020-04-07T04:49:26.500401 | 2018-12-21T15:54:18 | 2018-12-21T15:54:18 | 41,149,960 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,924 | h | /*--------------------------------------------------------------------
This file is part of the Adafruit NeoPixel library.
NeoPixel is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
NeoPixel 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with NeoPixel. If not, see
<http://www.gnu.org/licenses/>.
--------------------------------------------------------------------*/
#ifndef ADAFRUIT_NEOPIXEL_H
#define ADAFRUIT_NEOPIXEL_H
#if (ARDUINO >= 100)
#include <Arduino.h>
#else
#include <WProgram.h>
#include <pins_arduino.h>
#endif
// 'type' flags for LED pixels (third parameter to constructor):
#define NEO_RGB 0x00 // Wired for RGB data order
#define NEO_GRB 0x01 // Wired for GRB data order
#define NEO_BRG 0x04
#define NEO_COLMASK 0x01
#define NEO_KHZ800 0x02 // 800 KHz datastream
#define NEO_SPDMASK 0x02
// Trinket flash space is tight, v1 NeoPixels aren't handled by default.
// Remove the ifndef/endif to add support -- but code will be bigger.
// Conversely, can comment out the #defines to save space on other MCUs.
#ifndef __AVR_ATtiny85__
#define NEO_KHZ400 0x00 // 400 KHz datastream
#endif
class Adafruit_NeoPixel {
public:
// Constructor: number of LEDs, pin number, LED type
Adafruit_NeoPixel(uint16_t n, uint8_t p = 6, uint8_t t = NEO_GRB + NEO_KHZ800);
~Adafruit_NeoPixel();
void
begin(void),
show(void),
setPin(uint8_t p),
setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b),
setPixelColor(uint16_t n, uint32_t c),
setBrightness(uint8_t),
clear();
uint8_t
*getPixels(void) const,
getBrightness(void) const;
uint16_t
numPixels(void) const;
static uint32_t
Color(uint8_t r, uint8_t g, uint8_t b);
uint32_t
getPixelColor(uint16_t n) const;
inline bool
canShow(void) { return (micros() - endTime) >= 50L; }
private:
const uint16_t
numLEDs, // Number of RGB LEDs in strip
numBytes; // Size of 'pixels' buffer below
uint8_t
pin, // Output pin number
brightness,
*pixels, // Holds LED color values (3 bytes each)
rOffset, // Index of red byte within each 3-byte pixel
gOffset, // Index of green byte
bOffset; // Index of blue byte
const uint8_t
type; // Pixel flags (400 vs 800 KHz, RGB vs GRB color)
uint32_t
endTime; // Latch timing reference
#ifdef __AVR__
const volatile uint8_t
*port; // Output PORT register
uint8_t
pinMask; // Output PORT bitmask
#endif
};
#endif // ADAFRUIT_NEOPIXEL_H
| [
"tim@inexpro.nl"
] | tim@inexpro.nl |
40ee09493fb78dbd81e2c9ae500b11afc5e4034f | 30773b649ebd89ffadd16d30fd62740b77ca7865 | /SDK/wld_shp_rocks_cluster_02_parameters.h | ffa6dcd007a513f858aca35c586df82ae96ca37b | [] | no_license | The-Jani/Sot-SDK | 7f2772fb5df421e02b8fec237248af407cb2540b | 2a158a461c697cca8db67aa28ffe3e43677dcf11 | refs/heads/main | 2023-07-09T07:17:56.972569 | 2021-08-18T23:45:06 | 2021-08-18T23:45:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 563 | h | #pragma once
// Name: SoT, Version: 2.1.1
#include "../SDK.h"
/*!!DEFINE!!*/
/*!!HELPER_DEF!!*/
/*!!HELPER_INC!!*/
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
namespace CG
{
//---------------------------------------------------------------------------
// Parameters
//---------------------------------------------------------------------------
// Function wld_shp_rocks_cluster_02.wld_shp_rocks_cluster_02_C.UserConstructionScript
struct Awld_shp_rocks_cluster_02_C_UserConstructionScript_Params
{
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"ploszjanos9844@gmail.com"
] | ploszjanos9844@gmail.com |
14836b9543722c6578c09fb598a72a79c0cc9e96 | 9559a97171cf993e7bf665c6f3532b5ecc71e666 | /图论/欧拉回路/pku2513并查集+字典树+欧拉回路.cpp | af9eb572b9bec401d49200641bb0ea4056534ad5 | [] | no_license | cslilong/Algorithm | 8090be3bcc9d7dd28dd6048f34093c30a721cdbc | 5131388c4dd054420860024ef7a1745204dba4d4 | refs/heads/master | 2016-09-15T21:24:22.656535 | 2013-10-07T09:18:32 | 2013-10-07T09:18:32 | 12,647,284 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,253 | cpp | /*
http://poj.org/problem?id=2513
*/
#include<iostream>
using namespace std;
const int maxn=500100;
struct node
{
int key;
node *nxt[26];
}*root;
int nodenum;
int f[maxn],a[maxn];
void new_node(node* &x)
{
x = new node;
memset(x,0,sizeof(node));
x->key = -1;
}
int getnum(char *x)
{
node *ptr=root;
for(int i=0;x[i];++i)
{
int k = x[i]-'a';
if(ptr->nxt[k]==0) new_node(ptr->nxt[k]);
ptr = ptr->nxt[k];
}
if(ptr->key == -1) ptr->key = nodenum++;
return ptr->key;
}
int find_set(int k)
{
int root = k;
while (f[root] != root) root = f[root];
while (k != root)
{
int t = f[k];
f[k] = root;
k = t;
}
return root;
}
int main()
{
char s1[20],s2[20];
nodenum=0;
new_node(root);
int u,v,i,e = 0;
for(i=0;i<maxn;++i) f[i]=i;
freopen("pku2513in.txt","r",stdin);
freopen("pku2513out.txt","w",stdout);
while(scanf("%s%s",s1,s2)!=EOF)
{
u = getnum(s1);
v = getnum(s2);
//cout<<u<<" "<<v<<endl;
++a[u]; ++a[v];
f[find_set(u)]=find_set(v);
}
e = find_set(0);
for(i=1;i<nodenum;++i)
{
if(e!=find_set(i)) { printf("Impossible\n"); return 0; }
}
e = 0;
for(i=0;i<nodenum;++i) if(a[i]&1) ++e;
if(e<=2) printf("Possible\n");
else printf("Impossible\n");
return 0;
}
| [
"cslilong@gmail.com"
] | cslilong@gmail.com |
f9721a37ebe4b1c98b5a2d838d63ca5a42dad4ba | bf7f6fc3bde32862d3f4dffa1dae57f299a66d2a | /game_school/server/pwconnsrv/pw_connsrv_listener.h | ea271f5e3c43d8e510c1a2860845798d03b3cb73 | [] | no_license | luoxz-ai/H5Game | 0c795c4f075d7073f29c1e8c012d592500a0fcd0 | f292af19874dc0d7396fc8084c8ef1ab391201a3 | refs/heads/master | 2023-06-20T03:58:24.199939 | 2019-07-02T07:22:33 | 2019-07-02T07:22:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,048 | h |
#ifndef _pw_connsrv_listener_
#define _pw_connsrv_listener_
#include "pw_def.h"
#include "pwdist_port_generic.h"
#include "gdb/pw_gdb_socket_listener.h"
#include "gdb/pw_gdb_socket_reactor_win32.h"
#include "gdb/pw_gdb_socket_reactor_linux.h"
#include "pw_web_socket_listener.h"
namespace pwconnsrv
{
class SImplListener : public pwdist::Port
{
public:
class TcpListener : public gdb::SocketListener
{
public:
TcpListener(SImplListener* port);
public:
virtual int OnAccept(int sock,sockaddr_in* addr);
public:
virtual int doref() { return 0; }
virtual int unref() { return 0; }
protected:
SImplListener* m_pPort;
};
public:
SImplListener();
public:
int InitialRpcs(pwdist::Port* port);
public:
void _rpc_call_Enable(bool value);
void _rpc_call_Exit();
public:
void _rpc_call_EnableMsgid(int32 msgid,bool enable);
void _rpc_call_GetDisabledMsgids();
public:
virtual int Startup(const_char_ptr name,pwdist::Node* node, int port);
virtual int InternalUpdate();
protected:
virtual int OnThreadStarted();
virtual int OnThreadStopped();
protected:
TcpListener m_objListener;
gdb::SocketReactorDefaultImpl m_objReactor;
bool m_bEnableAccept;
};
extern bool IsMessageDisabled(int32 msgid);
class SImplWebsocketListener : public pwdist::Port
{
public:
class WebsocketTcpListener : public gdb::WebsocketListener
{
public:
WebsocketTcpListener(SImplWebsocketListener* port);
public:
virtual int OnAccept(int sock, sockaddr_in* addr);
public:
virtual int doref() { return 0; }
virtual int unref() { return 0; }
protected:
SImplWebsocketListener* m_pPort;
};
public:
SImplWebsocketListener();
public:
virtual int Startup(const_char_ptr name, pwdist::Node* node, int port);
virtual int InternalUpdate();
protected:
virtual int OnThreadStarted();
virtual int OnThreadStopped();
protected:
WebsocketTcpListener m_objWebsocketListener;
gdb::SocketReactorDefaultImpl m_objWebsocketReactor;
bool m_bWebsocketEnableAccept;
};
}
#endif
| [
"821153923@qq.com"
] | 821153923@qq.com |
067515b4ff86c377ee313e8fc644fae9a21bfca5 | a7338d8b9074ed062b62fcbd980a306be7f89ac7 | /ToDoC++FactoryMethod/src/Application.h | 809d8570347737f6756f76b3ca7e81f99164b297 | [] | no_license | takepu/dpp | 5152b1225d83fe34b58dc695e0ca861bc73dc316 | df24332235e4b60c598690723156805227c76e83 | refs/heads/master | 2016-09-02T04:04:45.626415 | 2012-12-24T05:09:14 | 2012-12-24T05:09:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,543 | h | /*
* application.h
*
* Created on: 2012/12/02
* Author: takepu
*/
#ifndef APPLICATION_H_
#define APPLICATION_H_
#include "StringList.h"
namespace std{
//---------------------------------------------------------------------------
// アプリケーション実行本体
// @note 下記順番でコールすること
// Initial()
// Run()
// Exit()
//---------------------------------------------------------------------------
class Application {
public:
//-----------------------------------------------------------------------
// コンストラクタ
//-----------------------------------------------------------------------
Application();
//-----------------------------------------------------------------------
// デストラクタ
//-----------------------------------------------------------------------
virtual ~Application();
//-----------------------------------------------------------------------
// 初期化
//-----------------------------------------------------------------------
virtual void Initial();
//-----------------------------------------------------------------------
// 実行
//-----------------------------------------------------------------------
virtual void Run();
//-----------------------------------------------------------------------
// 終了
//-----------------------------------------------------------------------
virtual void Exit();
protected:
StringList* PStrList;
};
}
#endif /* APPLICATION_H_ */
| [
"takepuxp@gmail.com"
] | takepuxp@gmail.com |
8823b050e35f6de3a67a1bcf1cfa250dc386c8fb | a269d13042a659e0e54f5692833254f129a6c41f | /Shop/Shop/Gamer.h | fc702481f855ca7a02fabc0b78aab128527a96cf | [] | no_license | ren232010/Test | e2ac56cf69f3b8d64a14952edab8508a13718f27 | 72848c684f9025ff90d62606afe6d7259dd47fae | refs/heads/master | 2020-03-30T23:19:35.493785 | 2018-10-18T10:05:05 | 2018-10-18T10:05:05 | 151,697,451 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 467 | h | #pragma once
#include <iostream>
class Gamer
{
public:
Gamer();
~Gamer();
void InstallGamer();
bool AddItem(class Item*);
/*bool AddItemTool(class Item*);//装备物品*/
Item* ChangeItem(class Item*);//换装备
void UpdatedAttribute(class Item*);//更新属性
public:
std::string Name;
int ATK;
int Def;
int Hp;
int Mp;
int Money;
class Item **Backpack;
int Size;
class Item**ItemTooltip;//装备栏
int TooSize; //装备栏大小
};
| [
"648315326@qq.com"
] | 648315326@qq.com |
9c1ecd51ffa28380761eeb7c5c1de86cd7113b63 | 2561d4be89aaa8612eae00c0464e48f3e62e3ad8 | /workspace/ABC154/D.cpp | 013f92988dc63b6d9edf86a424e8a2de64e4dd28 | [] | no_license | oirom/atcoder | c9e6791236a75b0efc83868f3356dd4d6768a726 | acba483a55451a8bd9808dbe4188ee12fdd1e374 | refs/heads/master | 2022-03-05T07:30:58.897174 | 2022-02-20T11:42:13 | 2022-02-20T11:42:13 | 249,957,741 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 799 | cpp | #include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLD = vector<PLD>;
const int INF = numeric_limits<int>::max();
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
VLD e(n+1, 0.0);
REP(i,n) {
LD temp;
cin >> temp;
e[i+1] = e[i] + temp*(temp+1.0)/2.0/temp;
}
LD ans = 0.0;
for (int i=k; i<=n; i++) {
ans = max(ans, e[i]-e[i-k]);
}
cout << fixed << setprecision(15) << ans << endl;
return 0;
} | [
"yamauchi.morio853@mail.kyutech.jp"
] | yamauchi.morio853@mail.kyutech.jp |
7498bd897c9881331761ac7d97c00edbaf91d536 | 322d037d769811162b77a3367d16e6924e47c81b | /tcp_connection.cpp | 9233f37c8c22a9e3bf0c7ffe9dd86123c64c5302 | [] | no_license | rrrbatman2020/lruc | 7949fd9410140967c23dfa83d885f1ba1364aae7 | 4f5d44360e2a195611fed1b097784787dbfada37 | refs/heads/master | 2020-09-25T15:40:28.437671 | 2019-12-05T07:52:40 | 2019-12-05T07:52:40 | 226,036,213 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,203 | cpp | #include "tcp_connection.h"
#include "error.h"
#include <arpa/inet.h>
#include <cstring>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
TTcpConnection::TTcpConnection(const std::string& host, const std::string& port) {
Establish(host, port);
}
TTcpConnection::~TTcpConnection() {
Close();
}
void TTcpConnection::Send(const std::string& data) {
CheckConnectionIsGood();
int totalBytesSended = 0;
while (totalBytesSended < data.size()) {
const int bytesSended = send(SocketDecriptor, data.c_str(), data.size(), 0);
if (bytesSended < 0) {
Good = false;
throw TError("Cannot send data", true);
}
totalBytesSended += bytesSended;
}
}
int TTcpConnection::ReceiveChunk(void* result, const int estimatedSize) {
CheckConnectionIsGood();
const int bytesReceived = recv(SocketDecriptor, result, estimatedSize, 0);
if (bytesReceived < 0) {
Good = false;
throw TError("Cannot receive data", true);
}
return bytesReceived;
}
int TTcpConnection::PeekChunk(void* result, const int estimatedSize) {
CheckConnectionIsGood();
const int bytesReceived = recv(SocketDecriptor, result, estimatedSize, MSG_PEEK);
if (bytesReceived < 0) {
Good = false;
throw TError("Cannot peek data", true);
}
return bytesReceived;
}
bool TTcpConnection::IsGood() const {
return Good;
}
void TTcpConnection::Establish(const std::string& host, const std::string& port) {
struct addrinfo* result = nullptr;
try {
struct addrinfo addressHints;
{
memset(&addressHints, 0, sizeof(struct addrinfo));
addressHints.ai_family = AF_UNSPEC;
addressHints.ai_socktype = SOCK_STREAM;
addressHints.ai_flags = 0;
addressHints.ai_protocol = IPPROTO_TCP;
}
const int getAddrInfoResult = getaddrinfo(host.c_str(), port.c_str(), &addressHints, &result);
if (getAddrInfoResult != 0) {
std::string errorText;
{
errorText.append("getaddrinfo: ");
errorText.append(gai_strerror(getAddrInfoResult));
}
throw TError(errorText, false);
}
struct addrinfo* address;
for (address = result; address; address = address->ai_next) {
SocketDecriptor = socket(address->ai_family, address->ai_socktype, address->ai_protocol);
if (SocketDecriptor == -1) {
continue;
}
if (connect(SocketDecriptor, address->ai_addr, address->ai_addrlen) != -1) {
break;
}
close(SocketDecriptor);
}
if (!address) {
throw TError("Could not connect", false);
}
} catch (...) {
if (result) {
freeaddrinfo(result);
}
throw;
}
}
void TTcpConnection::Close() {
close(SocketDecriptor);
Good = false;
}
void TTcpConnection::CheckConnectionIsGood() const {
if (!IsGood()) {
throw TError("Attempt to use bad connection", true);
}
}
| [
"ponomarev.ca@gmail.com"
] | ponomarev.ca@gmail.com |
e4e37ca78ed657df5024c07dd53a739d9048c744 | dce708c0a4caf2ed2bb4985f8eae1e069dd69408 | /BoardDisplayWindow.h | 311adee21914799e052f09b6cf8c6eb9baf26794 | [] | no_license | Tuyixiang/2018.8-Practice-2 | aaa96578b99bef54197c11fa3f14c68589415a28 | 658c003ec4c1e711f6de09dbd3d6ec3fd90d70fc | refs/heads/master | 2020-03-28T19:49:57.464452 | 2018-09-16T16:31:39 | 2018-09-16T16:31:39 | 149,013,728 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,837 | h | //
// Created by Yixiang Tu on 04/09/2018.
//
#ifndef CHINESE_CHESS_BOARDDISPLAY_H
#define CHINESE_CHESS_BOARDDISPLAY_H
#include <Qt3DWindow>
#include <QOpenGLFunctions>
#include "declarations.h"
#include "PieceEntity.h"
class Tile;
struct Piece;
class BoardDisplayWindow : public Qt3DExtras::Qt3DWindow {
Q_OBJECT
Q_PROPERTY(float gameStartFactor
WRITE
setGameStartFactor)
public:
BoardDisplayWindow();
bool gameStarted = false;
signals:
void movePiece(int, int, int, int);
void ok();
public slots:
void movePieceEntity(PieceEntity* target, int x, int y);
void destroyPieceEntity(PieceEntity* target);
void gameReady();
void startGame();
void moveReady();
void readPiecePositions();
void stop() {
state = stopped;
}
protected:
Camera* cameraEntity = nullptr;
Tile* tiles[9][10];
/// the tile at which cursor points, recorded even when not displayed (e.g. once selected)
Tile* hoverTile = nullptr;
Piece* selectedPiece = nullptr;
enum State {
stopped,
selecting,
selected
} state = stopped;
void mouseMoveEvent(QMouseEvent* ev) override;
void mousePressEvent(QMouseEvent* ev) override;
void mouseReleaseEvent(QMouseEvent* ev) override;
void wheelEvent(QWheelEvent* ev) override;
void resetTiles();
Tile* getTileFromPos(const QPoint& position);
void setGameStartFactor(float factor);
void updateCamera();
/// record mouse position when right button pressed
QPoint mousePosition;
float cameraRotate = 0;
float cameraLift = 60.0f;
float cameraDistance = 12;
float cameraDistanceTarget = 12;
bool rotatingCamera = false;
bool cameraChanged = true;
float gameStartFactor = 0;
Entity* rootEntity = nullptr;
public:
void initialize();
};
#endif //CHINESE_CHESS_BOARDDISPLAY_H
| [
"tu.yixiang@icloud.com"
] | tu.yixiang@icloud.com |
21ade5437d3cdf73104fde9fcc07b82c257595a3 | cc7ea7d3af5afdfab52c4ade486f2b733147415b | /folly/executors/task_queue/PriorityLifoSemMPMCQueue.h | cf17cf04d7e50a0b96ad91054b700c9cfd7c1386 | [
"MIT",
"Apache-2.0"
] | permissive | couchbasedeps/folly | f2d70e1b2c629761e40e15248ea17335e651fc40 | 99a218de8a87c48f8164afb614401717c58cce8a | refs/heads/master | 2022-09-09T08:32:46.196956 | 2021-02-26T21:43:46 | 2021-02-26T21:45:23 | 152,815,030 | 1 | 3 | Apache-2.0 | 2022-08-22T12:19:33 | 2018-10-12T22:48:10 | C++ | UTF-8 | C++ | false | false | 3,558 | h | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* 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.
*/
#pragma once
#include <glog/logging.h>
#include <folly/Executor.h>
#include <folly/MPMCQueue.h>
#include <folly/Range.h>
#include <folly/executors/task_queue/BlockingQueue.h>
#include <folly/synchronization/LifoSem.h>
namespace folly {
template <class T, QueueBehaviorIfFull kBehavior = QueueBehaviorIfFull::THROW>
class PriorityLifoSemMPMCQueue : public BlockingQueue<T> {
public:
// Note A: The queue pre-allocates all memory for max_capacity
// Note B: To use folly::Executor::*_PRI, for numPriorities == 2
// MID_PRI and HI_PRI are treated at the same priority level.
PriorityLifoSemMPMCQueue(uint8_t numPriorities, size_t max_capacity) {
queues_.reserve(numPriorities);
for (int8_t i = 0; i < numPriorities; i++) {
queues_.emplace_back(max_capacity);
}
}
PriorityLifoSemMPMCQueue(folly::Range<const size_t*> capacities) {
CHECK_LT(capacities.size(), 256) << "At most 255 priorities supported";
queues_.reserve(capacities.size());
for (auto capacity : capacities) {
queues_.emplace_back(capacity);
}
}
uint8_t getNumPriorities() override { return queues_.size(); }
// Add at medium priority by default
BlockingQueueAddResult add(T item) override {
return addWithPriority(std::move(item), folly::Executor::MID_PRI);
}
BlockingQueueAddResult addWithPriority(T item, int8_t priority) override {
int mid = getNumPriorities() / 2;
size_t queue = priority < 0
? std::max(0, mid + priority)
: std::min(getNumPriorities() - 1, mid + priority);
CHECK_LT(queue, queues_.size());
switch (kBehavior) { // static
case QueueBehaviorIfFull::THROW:
if (!queues_[queue].writeIfNotFull(std::move(item))) {
throw QueueFullException("LifoSemMPMCQueue full, can't add item");
}
break;
case QueueBehaviorIfFull::BLOCK:
queues_[queue].blockingWrite(std::move(item));
break;
}
return sem_.post();
}
T take() override {
T item;
while (true) {
if (nonBlockingTake(item)) {
return item;
}
sem_.wait();
}
}
folly::Optional<T> try_take_for(std::chrono::milliseconds time) override {
T item;
while (true) {
if (nonBlockingTake(item)) {
return item;
}
if (!sem_.try_wait_for(time)) {
return folly::none;
}
}
}
bool nonBlockingTake(T& item) {
for (auto it = queues_.rbegin(); it != queues_.rend(); it++) {
if (it->readIfNotEmpty(item)) {
return true;
}
}
return false;
}
size_t size() override {
size_t size = 0;
for (auto& q : queues_) {
size += q.size();
}
return size;
}
size_t sizeGuess() const {
size_t size = 0;
for (auto& q : queues_) {
size += q.sizeGuess();
}
return size;
}
private:
folly::LifoSem sem_;
std::vector<folly::MPMCQueue<T>> queues_;
};
} // namespace folly
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
718aed8440eec30a798b202baafef83659554ef5 | 04e06ad381075fa9321fb5c5451bea6b681468b6 | /source/game/world/biome.cpp | c107cf98bfc07793c178c75aae83ac329b832924 | [] | no_license | filux/Mandate | 645b0bd6327c7c93a7950c1d98770a404914d792 | a0e22ecf01588ab4d85611fee22055ab80dea79d | refs/heads/master | 2020-12-11T05:38:26.865784 | 2014-06-12T22:19:00 | 2014-06-12T22:19:00 | null | 0 | 0 | null | null | null | null | ISO-8859-10 | C++ | false | false | 2,243 | cpp | // ==============================================================
// This file is part of Glest (www.glest.org)
//
// Copyright (C) 2001-2008 Martiņo Figueroa,
// 2008 Jaagup Repän <jrepan@gmail.com>,
// 2008 Daniel Santos <daniel.santos@pobox.com>
// 2009-2010 James McCulloch <silnarm@gmail.com>
//
// You can redistribute this code 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
// ==============================================================
#include "pch.h"
#include "biome.h"
#include <cassert>
#include "map.h"
#include "world.h"
#include "tileset.h"
#include "logger.h"
#include "tech_tree.h"
#include "leak_dumper.h"
#include "fixed.h"
#include "sim_interface.h"
using namespace Shared::Graphics;
using namespace Shared::Util;
using namespace Shared::Math;
namespace Glest { namespace Sim {
using Main::Program;
using Search::Cartographer;
using Gui::Selection;
// =====================================================
// class Biome
// =====================================================
bool Biome::load(const XmlNode *baseNode, const string &dir, const TechTree *tt, const FactionType *ft) {
bool loadOk = true;
name = baseNode->getAttribute("name")->getRestrictedValue();
tempMin = baseNode->getAttribute("min-temp")->getIntValue();
tempMax = baseNode->getAttribute("max-temp")->getIntValue();
moistureLevel = baseNode->getAttribute("moisture")->getIntValue();
altitudeMin = baseNode->getAttribute("min-alt")->getIntValue();
altitudeMax = baseNode->getAttribute("max-alt")->getIntValue();
tileset.load(dir, g_world.getTechTree());
const XmlNode *emanationsNode = baseNode->getChild("emanations", 0, false);
if (emanationsNode) {
emanations.resize(emanationsNode->getChildCount());
for (int i = 0; i < emanationsNode->getChildCount(); ++i) {
const XmlNode *emanationNode = emanationsNode->getChild("emanation", i);
if (!emanations[i]->load(emanationNode, dir)) {
loadOk = false;
}
}
}
return loadOk;
}
}}//end namespace
| [
"taomastercu@yahoo.com"
] | taomastercu@yahoo.com |
d4dc1ff47376ae9a98e72b4b8c4381f08ea6ae0f | 077b52d6bf4438d2e0172531ba6acb27b1aaf8dd | /A composition in classes/8/time.cpp | 525800b9f3258beca82f75aca0ef0c624bda0422 | [] | no_license | bmvskii/OOP | a41ccf5a9862f6f112e8a82a25462bac4c605a64 | 810ad97eb418024cfac7beb66a8fff76cae73b90 | refs/heads/master | 2020-03-25T02:03:42.824530 | 2019-08-01T13:31:00 | 2019-08-01T13:31:00 | 143,271,973 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,333 | cpp | // (C) 2013-2016, Sergei Zaychenko, KNURE, Kharkiv, Ukraine
/*****************************************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include "time.hpp"
#include "messages.hpp"
#include <ctime>
#include <cassert>
#include <cstdio>
#include <stdexcept>
/*****************************************************************************/
Time::Time()
{
time_t currentTime = time( nullptr );
tm* currentTM = gmtime( ¤tTime );
m_hours = currentTM->tm_hour;
m_minutes = currentTM->tm_min;
m_seconds = currentTM->tm_sec;
}
/*****************************************************************************/
Time::Time( int _hours, int _minutes, int _seconds )
: m_hours( _hours ), m_minutes( _minutes ), m_seconds( _seconds )
{
if ( !isValid() )
throw std::logic_error( Messages::InvalidDateTime );
}
/*****************************************************************************/
Time::Time( const char * _time, char _timesep )
{
char sep1, sep2;
int nMatched = sscanf(
_time
, "%d%c%d%c%d"
, &m_hours, &sep1, &m_minutes, &sep2, &m_seconds
);
if ( nMatched != 5 || sep1 != _timesep || sep2 != _timesep )
throw std::logic_error( Messages::InvalidDateTimeFormat );
if ( !isValid() )
throw std::logic_error( Messages::InvalidDateTime );
}
/*****************************************************************************/
int
Time::getHours() const
{
return m_hours;
}
/*****************************************************************************/
int
Time::getMinutes() const
{
return m_minutes;
}
/*****************************************************************************/
int
Time::getSeconds() const
{
return m_seconds;
}
/*****************************************************************************/
bool
Time::isValid() const
{
if ( m_hours < 0 || m_hours > 24 )
return false;
else if ( m_minutes < 0 || m_minutes > 60 )
return false;
else if ( m_seconds < 0 || m_seconds > 60 )
return false;
return true;
}
/*****************************************************************************/
bool
Time::operator == ( Time t ) const
{
return m_hours == t.getHours()
&& m_minutes == t.getMinutes()
&& m_seconds == t.getSeconds();
}
/*****************************************************************************/
bool
Time::operator != ( Time t ) const
{
return !( *this == t );
}
/*****************************************************************************/
bool
Time::operator < ( Time t ) const
{
if ( m_hours < t.getHours() )
return true;
else if ( m_hours == t.getHours() )
{
if ( m_minutes < t.getMinutes() )
return true;
else if ( m_minutes == t.getMinutes() )
return m_seconds < t.getSeconds();
}
return false;
}
/*****************************************************************************/
bool
Time::operator > ( Time t ) const
{
return t < *this;
}
/*****************************************************************************/
bool
Time::operator <= ( Time t ) const
{
return ( *this < t ) || ( *this == t );
}
/*****************************************************************************/
bool
Time::operator >= ( Time t ) const
{
return ( t < *this ) || ( *this == t );
}
/*****************************************************************************/
| [
"evg.rogovoy@gmail.com"
] | evg.rogovoy@gmail.com |
18b087d0459294c6e18e9e4fd66a8e1f570d410a | 0cac0f3314ea1534b70b792e9f7fd7837217459c | /SingleNumber2.cpp | 028e42a95772a78a119eb3d59e73703377a9a420 | [] | no_license | wengbinbin/leetcood | 610b68e677b85dea6f18f9061429fb98251e7e00 | a5d22d56310d920ec2ec25d6083eb157f80fcd9c | refs/heads/master | 2021-05-27T10:23:21.973715 | 2014-05-13T07:04:47 | 2014-05-13T07:04:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 632 | cpp | #include<iostream>
#include<string>
using namespace std;
class Solution {
public:
int singleNumber(int A[], int n) {
int w=sizeof(int)*8;
int count[w];
int result=0;
memset(count,0,sizeof(int)*w);//initial wrong
for(int i=0;i<w;i++){
cout<<count[i]<<" ";
count[i]=0;
}
for(int i=0;i<n;i++){
for(int j=0;j<w;j++){
cout<<A[i]<<endl;
count[j]+=((A[i]>>j)&1);
count[j]=count[j]%3;
cout<<"j="<<j<<"+"<<count[j]<<endl;
}
}
for(int i=0;i<w;i++){
result+=(count[i]<<i);
}
return result;
}
};
int main(){
int a[1]={
1
};
Solution object;
cout<<object.singleNumber(a,1);
}
| [
"2008shdjc@163.com"
] | 2008shdjc@163.com |
3048914032b8410a8af4a77265991ce78258fe30 | ace7469476607a58aa83cef8bac8934543eb9458 | /cpp/boost/bimap/student/main.cpp | e16c64655ded7919295c37e94a2e02b694704fac | [
"MIT"
] | permissive | 307509256/learning-c-cpp | 0fde4f5bc7a8e862f5b23ad76043eb39fcaa76ca | 998370e4fdd59c867f3b1e2b8840f38500c5c634 | refs/heads/master | 2022-12-25T00:42:30.314218 | 2018-05-11T05:58:25 | 2018-05-11T05:58:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 810 | cpp | #include <string>
#include <iostream>
#include <boost/bimap.hpp>
int main() {
boost::bimap<boost::bimaps::tagged<int, struct id>, boost::bimaps::tagged<std::string, struct name>> students;
int student_id = 1;
students.by<id>().insert(std::make_pair(student_id++, "Jeff"));
students.by<id>().insert(std::make_pair(student_id++, "Tom"));
students.by<name>().insert(std::make_pair("Ying", student_id++));
students.by<name>().insert(std::make_pair("Shabby", student_id++));
students.by<name>().insert(std::make_pair("Tom", student_id++));
for (const auto& iter: students) {
std::cout << iter.left << "->" << iter.right << std::endl;
}
std::cout << students.by<id>().find(3)->second << std::endl; // Ying
std::cout << students.by<name>().count("Tom") << std::endl; // 2
return 0;
} | [
"akagi201@gmail.com"
] | akagi201@gmail.com |
46252326752d6053cb69b91cfd1667d8c3f48155 | 00aeccd23bcba53f5dbdc4c71fafda194edb8058 | /tutorial/BaseApplication.cpp | e930d06b15e79d6976a33587f960179b561d0472 | [] | no_license | hef/ogre3dTutorials | 601ec06e3421ea21c68eda80ab94369df18e6ebf | c72140b8c1b163292dd384ef67f0f36ed7327723 | refs/heads/master | 2021-01-19T03:17:56.971765 | 2010-07-07T05:17:29 | 2010-07-07T05:17:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,514 | cpp | /*
-----------------------------------------------------------------------------
Filename: BaseApplication.cpp
-----------------------------------------------------------------------------
This source file is part of the
___ __ __ _ _ _
/___\__ _ _ __ ___ / / /\ \ (_) | _(_)
// // _` | '__/ _ \ \ \/ \/ / | |/ / |
/ \_// (_| | | | __/ \ /\ /| | <| |
\___/ \__, |_| \___| \/ \/ |_|_|\_\_|
|___/
Tutorial Framework
http://www.ogre3d.org/tikiwiki/
-----------------------------------------------------------------------------
*/
#include "BaseApplication.h"
//-------------------------------------------------------------------------------------
BaseApplication::BaseApplication(void)
: mRoot(0),
mCamera(0),
mSceneMgr(0),
mWindow(0),
mResourcesCfg(Ogre::StringUtil::BLANK),
mPluginsCfg(Ogre::StringUtil::BLANK),
mTrayMgr(0),
mCameraMan(0),
mDetailsPanel(0),
mCursorWasVisible(false),
mShutDown(false),
mInputManager(0),
mMouse(0),
mKeyboard(0)
{
}
//-------------------------------------------------------------------------------------
BaseApplication::~BaseApplication(void)
{
if (mTrayMgr) delete mTrayMgr;
if (mCameraMan) delete mCameraMan;
//Remove ourself as a Window listener
Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this);
windowClosed(mWindow);
delete mRoot;
}
//-------------------------------------------------------------------------------------
bool BaseApplication::configure(void)
{
// Show the configuration dialog and initialise the system
// You can skip this and use root.restoreConfig() to load configuration
// settings if you were sure there are valid ones saved in ogre.cfg
if(mRoot->showConfigDialog())
{
// If returned true, user clicked OK so initialise
// Here we choose to let the system create a default rendering window by passing 'true'
mWindow = mRoot->initialise(true, "TutorialApplication Render Window");
return true;
}
else
{
return false;
}
}
//-------------------------------------------------------------------------------------
void BaseApplication::chooseSceneManager(void)
{
// Get the SceneManager, in this case a generic one
mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
}
//-------------------------------------------------------------------------------------
void BaseApplication::createCamera(void)
{
// Create the camera
mCamera = mSceneMgr->createCamera("PlayerCam");
// Position it at 500 in Z direction
mCamera->setPosition(Ogre::Vector3(0,0,80));
// Look back along -Z
mCamera->lookAt(Ogre::Vector3(0,0,-300));
mCamera->setNearClipDistance(5);
mCameraMan = new OgreBites::SdkCameraMan(mCamera); // create a default camera controller
}
//-------------------------------------------------------------------------------------
void BaseApplication::createFrameListener(void)
{
Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
OIS::ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;
mWindow->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
mInputManager = OIS::InputManager::createInputSystem( pl );
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));
mMouse->setEventCallback(this);
mKeyboard->setEventCallback(this);
//Set initial mouse clipping size
windowResized(mWindow);
//Register as a Window listener
Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);
mTrayMgr = new OgreBites::SdkTrayManager("InterfaceName", mWindow, mMouse, this);
mTrayMgr->showFrameStats(OgreBites::TL_BOTTOMLEFT);
mTrayMgr->showLogo(OgreBites::TL_BOTTOMRIGHT);
mTrayMgr->hideCursor();
// create a params panel for displaying sample details
Ogre::StringVector items;
items.push_back("cam.pX");
items.push_back("cam.pY");
items.push_back("cam.pZ");
items.push_back("");
items.push_back("cam.oW");
items.push_back("cam.oX");
items.push_back("cam.oY");
items.push_back("cam.oZ");
items.push_back("");
items.push_back("Filtering");
items.push_back("Poly Mode");
mDetailsPanel = mTrayMgr->createParamsPanel(OgreBites::TL_NONE, "DetailsPanel", 200, items);
mDetailsPanel->setParamValue(9, "Bilinear");
mDetailsPanel->setParamValue(10, "Solid");
mDetailsPanel->hide();
mRoot->addFrameListener(this);
}
//-------------------------------------------------------------------------------------
void BaseApplication::destroyScene(void)
{
}
//-------------------------------------------------------------------------------------
void BaseApplication::createViewports(void)
{
// Create one viewport, entire window
Ogre::Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(
Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
}
//-------------------------------------------------------------------------------------
void BaseApplication::setupResources(void)
{
// Load resource paths from config file
Ogre::ConfigFile cf;
cf.load(mResourcesCfg);
// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
Ogre::String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
}
//-------------------------------------------------------------------------------------
void BaseApplication::createResourceListener(void)
{
}
//-------------------------------------------------------------------------------------
void BaseApplication::loadResources(void)
{
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
}
//-------------------------------------------------------------------------------------
void BaseApplication::go(void)
{
//#ifdef _DEBUG
// mResourcesCfg = "resources_d.cfg";
// mPluginsCfg = "plugins_d.cfg";
//#else
mResourcesCfg = "resources.cfg";
mPluginsCfg = "plugins.cfg";
//#endif
if (!setup())
return;
mRoot->startRendering();
// clean up
destroyScene();
}
//-------------------------------------------------------------------------------------
bool BaseApplication::setup(void)
{
mRoot = new Ogre::Root(mPluginsCfg);
setupResources();
bool carryOn = configure();
if (!carryOn) return false;
chooseSceneManager();
createCamera();
createViewports();
// Set default mipmap level (NB some APIs ignore this)
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
// Create any resource listeners (for loading screens)
createResourceListener();
// Load resources
loadResources();
// Create the scene
createScene();
createFrameListener();
return true;
};
//-------------------------------------------------------------------------------------
bool BaseApplication::frameRenderingQueued(const Ogre::FrameEvent& evt)
{
if(mWindow->isClosed())
return false;
if(mShutDown)
return false;
//Need to capture/update each device
mKeyboard->capture();
mMouse->capture();
mTrayMgr->frameRenderingQueued(evt);
if (!mTrayMgr->isDialogVisible())
{
mCameraMan->frameRenderingQueued(evt); // if dialog isn't up, then update the camera
if (mDetailsPanel->isVisible()) // if details panel is visible, then update its contents
{
mDetailsPanel->setParamValue(0, Ogre::StringConverter::toString(mCamera->getDerivedPosition().x));
mDetailsPanel->setParamValue(1, Ogre::StringConverter::toString(mCamera->getDerivedPosition().y));
mDetailsPanel->setParamValue(2, Ogre::StringConverter::toString(mCamera->getDerivedPosition().z));
mDetailsPanel->setParamValue(4, Ogre::StringConverter::toString(mCamera->getDerivedOrientation().w));
mDetailsPanel->setParamValue(5, Ogre::StringConverter::toString(mCamera->getDerivedOrientation().x));
mDetailsPanel->setParamValue(6, Ogre::StringConverter::toString(mCamera->getDerivedOrientation().y));
mDetailsPanel->setParamValue(7, Ogre::StringConverter::toString(mCamera->getDerivedOrientation().z));
}
}
return true;
}
//-------------------------------------------------------------------------------------
bool BaseApplication::keyPressed( const OIS::KeyEvent &arg )
{
if (mTrayMgr->isDialogVisible()) return true; // don't process any more keys if dialog is up
if (arg.key == OIS::KC_F) // toggle visibility of advanced frame stats
{
mTrayMgr->toggleAdvancedFrameStats();
}
else if (arg.key == OIS::KC_G) // toggle visibility of even rarer debugging details
{
if (mDetailsPanel->getTrayLocation() == OgreBites::TL_NONE)
{
mTrayMgr->moveWidgetToTray(mDetailsPanel, OgreBites::TL_TOPRIGHT, 0);
mDetailsPanel->show();
}
else
{
mTrayMgr->removeWidgetFromTray(mDetailsPanel);
mDetailsPanel->hide();
}
}
else if (arg.key == OIS::KC_T) // cycle polygon rendering mode
{
Ogre::String newVal;
Ogre::TextureFilterOptions tfo;
unsigned int aniso;
switch (mDetailsPanel->getParamValue(9).asUTF8()[0])
{
case 'B':
newVal = "Trilinear";
tfo = Ogre::TFO_TRILINEAR;
aniso = 1;
break;
case 'T':
newVal = "Anisotropic";
tfo = Ogre::TFO_ANISOTROPIC;
aniso = 8;
break;
case 'A':
newVal = "None";
tfo = Ogre::TFO_NONE;
aniso = 1;
break;
default:
newVal = "Bilinear";
tfo = Ogre::TFO_BILINEAR;
aniso = 1;
}
Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(tfo);
Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(aniso);
mDetailsPanel->setParamValue(9, newVal);
}
else if (arg.key == OIS::KC_R) // cycle polygon rendering mode
{
Ogre::String newVal;
Ogre::PolygonMode pm;
switch (mCamera->getPolygonMode())
{
case Ogre::PM_SOLID:
newVal = "Wireframe";
pm = Ogre::PM_WIREFRAME;
break;
case Ogre::PM_WIREFRAME:
newVal = "Points";
pm = Ogre::PM_POINTS;
break;
default:
newVal = "Solid";
pm = Ogre::PM_SOLID;
}
mCamera->setPolygonMode(pm);
mDetailsPanel->setParamValue(10, newVal);
}
else if(arg.key == OIS::KC_F5) // refresh all textures
{
Ogre::TextureManager::getSingleton().reloadAll();
}
else if (arg.key == OIS::KC_SYSRQ) // take a screenshot
{
mWindow->writeContentsToTimestampedFile("screenshot", ".jpg");
}
else if (arg.key == OIS::KC_ESCAPE)
{
mShutDown = true;
}
mCameraMan->injectKeyDown(arg);
return true;
}
bool BaseApplication::keyReleased( const OIS::KeyEvent &arg )
{
mCameraMan->injectKeyUp(arg);
return true;
}
bool BaseApplication::mouseMoved( const OIS::MouseEvent &arg )
{
if (mTrayMgr->injectMouseMove(arg)) return true;
mCameraMan->injectMouseMove(arg);
return true;
}
bool BaseApplication::mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
if (mTrayMgr->injectMouseDown(arg, id)) return true;
mCameraMan->injectMouseDown(arg, id);
return true;
}
bool BaseApplication::mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
if (mTrayMgr->injectMouseUp(arg, id)) return true;
mCameraMan->injectMouseUp(arg, id);
return true;
}
//Adjust mouse clipping area
void BaseApplication::windowResized(Ogre::RenderWindow* rw)
{
unsigned int width, height, depth;
int left, top;
rw->getMetrics(width, height, depth, left, top);
const OIS::MouseState &ms = mMouse->getMouseState();
ms.width = width;
ms.height = height;
}
//Unattach OIS before window shutdown (very important under Linux)
void BaseApplication::windowClosed(Ogre::RenderWindow* rw)
{
//Only close for window that created OIS (the main window in these demos)
if( rw == mWindow )
{
if( mInputManager )
{
mInputManager->destroyInputObject( mMouse );
mInputManager->destroyInputObject( mKeyboard );
OIS::InputManager::destroyInputSystem(mInputManager);
mInputManager = 0;
}
}
}
| [
"hef@pbrfrat.com"
] | hef@pbrfrat.com |
d1fff79d3c2c14de9c05d4aef0e3a0ba91f7c60f | 6839540003c9a7e6fd122dc361215859fc95643f | /cpp/MCMC/cppa/include/cppa/detail/projection.hpp | 2e4233e155663b8ce8406598cb82c169acbc39af | [] | no_license | vkramanuj/willow | 2ba355fd9d4539f51470491ff9ce1d2276f333c0 | a36246b3e986d2cef89c61a43d005bb91e105ce9 | refs/heads/master | 2021-09-13T03:56:00.220700 | 2018-04-24T18:05:11 | 2018-04-24T18:05:11 | 110,746,080 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 7,150 | hpp | /******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa 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 Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_PROJECTION_HPP
#define CPPA_PROJECTION_HPP
#include "cppa/optional.hpp"
#include "cppa/guard_expr.hpp"
#include "cppa/util/call.hpp"
#include "cppa/util/int_list.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/util/left_or_right.hpp"
#include "cppa/detail/tdata.hpp"
namespace cppa { namespace detail {
template<typename Fun, typename Tuple, long... Is>
inline bool is_defined_at(Fun& f, Tuple& tup, util::int_list<Is...>) {
return f.defined_at(get_cv_aware<Is>(tup)...);
}
template<typename ProjectionFuns, typename... Ts>
struct collected_args_tuple {
typedef typename tdata_from_type_list<
typename util::tl_zip<
typename util::tl_map<
ProjectionFuns,
util::map_to_result_type,
util::rm_optional
>::type,
typename util::tl_map<
util::type_list<Ts...>,
mutable_gref_wrapped
>::type,
util::left_or_right
>::type
>::type
type;
};
template<typename Fun>
struct is_void_fun {
static constexpr bool value = std::is_same<typename Fun::result_type, void>::value;
};
/**
* @brief Projection implemented by a set of functors.
*/
template<class ProjectionFuns, typename... Ts>
class projection {
public:
typedef typename tdata_from_type_list<ProjectionFuns>::type fun_container;
typedef util::type_list<typename util::rm_const_and_ref<Ts>::type...> arg_types;
projection() = default;
projection(fun_container&& args) : m_funs(std::move(args)) { }
projection(const fun_container& args) : m_funs(args) { }
projection(const projection&) = default;
/**
* @brief Invokes @p fun with a projection of <tt>args...</tt> and stores
* the result of @p fun in @p result.
*/
/*
template<class PartFun>
bool invoke(PartFun& fun, typename PartFun::result_type& result, Ts... args) const {
typename collected_args_tuple<ProjectionFuns, Ts...>::type pargs;
if (collect(pargs, m_funs, std::forward<Ts>(args)...)) {
auto indices = util::get_indices(pargs);
if (is_defined_at(fun, pargs, indices)) {
result = util::apply_args(fun, pargs, indices);
return true;
}
}
return false;
}
*/
/**
* @brief Invokes @p fun with a projection of <tt>args...</tt>.
*/
template<class PartFun>
optional<typename PartFun::result_type> operator()(PartFun& fun, Ts... args) const {
typename collected_args_tuple<ProjectionFuns, Ts...>::type pargs;
auto indices = util::get_indices(pargs);
if (collect(pargs, m_funs, std::forward<Ts>(args)...)) {
if (is_defined_at(fun, pargs, indices)) {
return util::apply_args(fun, pargs, indices);
}
}
return none;
}
private:
template<typename Storage, typename T>
static inline bool store(Storage& storage, T&& value) {
storage = std::forward<T>(value);
return true;
}
template<class Storage>
static inline bool store(Storage& storage, optional<Storage>&& value) {
if (value) {
storage = std::move(*value);
return true;
}
return false;
}
template<typename T>
static inline auto fetch(const unit_t&, T&& arg)
-> decltype(std::forward<T>(arg)) {
return std::forward<T>(arg);
}
template<typename Fun, typename T>
static inline auto fetch(const Fun& fun, T&& arg)
-> decltype(fun(std::forward<T>(arg))) {
return fun(std::forward<T>(arg));
}
static inline bool collect(tdata<>&, const tdata<>&) {
return true;
}
template<class TData, class Trans, typename U, typename... Us>
static inline bool collect(TData& td, const Trans& tr,
U&& arg, Us&&... args) {
return store(td.head, fetch(tr.head, std::forward<U>(arg)))
&& collect(td.tail(), tr.tail(), std::forward<Us>(args)...);
}
fun_container m_funs;
};
template<>
class projection<util::empty_type_list> {
public:
projection() = default;
projection(const tdata<>&) { }
projection(const projection&) = default;
template<class PartFun>
optional<typename PartFun::result_type> operator()(PartFun& fun) const {
if (fun.defined_at()) {
return fun();
}
return none;
}
};
template<class ProjectionFuns, class List>
struct projection_from_type_list;
template<class ProjectionFuns, typename... Ts>
struct projection_from_type_list<ProjectionFuns, util::type_list<Ts...> > {
typedef projection<ProjectionFuns, Ts...> type;
};
} } // namespace cppa::detail
#endif // CPPA_PROJECTION_HPP
| [
"bsheeran@cs.brown.edu"
] | bsheeran@cs.brown.edu |
494b3ab03d6901a4602cac45a5ca784b25824f4b | efc0082ab67ab6ddab06c869fd0c2e661de0df74 | /src/borderwall.cpp | f277b5b16bc11d28693fd7620248620b03430668 | [] | no_license | josephjamiell/SnakeGame | e8e80655a1054c09d5c2a24321212f59389c0c8b | 2ce9a1a484763d2b9d376b320095d346119cacdf | refs/heads/master | 2023-01-01T07:24:20.607143 | 2020-10-25T03:33:32 | 2020-10-25T03:33:32 | 306,982,543 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 945 | cpp | #include <vector>
#include "borderwall.h"
#include <iostream>
BorderWall::BorderWall()
{
_objectType = GameObjectType::wallObject;
}
void BorderWall::CreateWall()
{
// top wall points
for(int i = 0; i < _gSize; ++i){
SDL_Point pnt {i * _bSize, 0};
_topBorder.emplace_back(pnt);
}
// left wall points
for(int i = 1; i < _gSize - 1; ++i){
SDL_Point pnt {0, i * _bSize};
_leftBorder.emplace_back(pnt);
}
// bottom wall points
for(int i = 0; i < _gSize; ++i){
SDL_Point pnt {i * _bSize, (_gSize - 1) * _bSize};
_bottomBorder.emplace_back(pnt);
}
// right wall points
for(int i = 1; i < _gSize - 1; ++i){
SDL_Point pnt {(_gSize - 1) * _bSize, i * _bSize};
_rightBorder.emplace_back(pnt);
}
}
void BorderWall::DestroyWall()
{
_topBorder.clear();
_leftBorder.clear();
_rightBorder.clear();
_bottomBorder.clear();
} | [
"jamielljoseph@Jamiells-MBP.fios-router.home"
] | jamielljoseph@Jamiells-MBP.fios-router.home |
54fd86d5c586bcf44d07ed97e8835a35233476d9 | b7a1dc7128f09cbe4a3f3136c8b57ee996cac536 | /notes/7.1.15.cpp | e7762904f401cc78916f133e74ed073a07a2a40c | [] | no_license | jerryweb/OS | ff2f46b56887c7ada6840410127801011ed560f9 | 848389f0243f718ee6a0fad5e2de08105210cf0d | refs/heads/master | 2021-01-10T09:03:52.211994 | 2015-07-26T06:58:20 | 2015-07-26T06:58:20 | 36,947,191 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,777 | cpp | Project 3 -3 parts
parts 1 & 2 - Demand Page virtual memory //dont preload anything (no bitmap finds in the constructor; also we
//can no longer do a new page table each time)
part 3 - networking - client server //should work even if parts 1 & 2 are not
distributed locks/CVs
An Approach to Parts 1 & 2
* compile and run in VM directory //may make changes to the files in the other directories (user programs still go into test)
- until part 3 is ready //you could do part 3 with project 2 code
-move to network directory
VM directory Makefile //when running from userprog, nachos used the page table
* nachos will now use the TLB not the page table //no bitmap finds for the page table
-> page fault exception // need to add an else if(page fault exception) in the exception.cc file around the switch case
if(which === SyscallException){
}
//add this statement
else if(which == PageFaultException){
//part 1 and 2 code; suggest using a seperate function so that this is not 100s of lines long
}
else{
}
* anywhere you see:
1. machine->pageTable = pageTable; //comment this out (should be the first thing you do)
Step 1 - Populate the TLB from the pageTable
Project 2: Infinite memory
Still preload
On a page fault exception: use the page table to Populate the TLB
1. what is the vpn containing the needed virtual address?
* the needed address is in register 39 - Bad vAddrReg
- divided by PageSize => page table index
currentThread->space->pageTable
* copy the pageTable data into TLB //TLB is an array based entry table just like the pagetable
2. Where to copy into the TLB? //Lock doesn't work very well here
machine->TLB
* array of TranslationEntry
* size 4
* Method: treat it like a circular 'queue'
* Create a variable - int currentTLB = 0; //this is going to be a system variable located in system.h
- wrtie to the index
currentTLB = (currentTLB++) % TLBSize; //When you copy to the entry to the TLB, you must copy the parameters NOT the pointer
/*anytime you do anything with the TLB, disable interrupts*/
disable interrupts
// populate TLB
restore interrupts
On a context switch
- invalidate the TLB //throw out the TLB info
* set the valid bit to false
//this can go in the one of the following four places; if put in one of the first two, put it below the existing code
//Don't put a lock here
for(int i = 0; i <TLBSize; i++){
machine->TLB[i].valid = false;
}
//AddrSpace
SaveState
RestoreState
//Thread
SaveUserState
RestoreUserState
Step 2 - Implement IPT //essentially a map of physical pages
Can be an array //more realistically you may want to use the stl hash map
* have numPhysPages entries
Still project 2 assumptions
Add IPT population code to where pagetable is set
* where ever you do a memMap->Find //index to IPT
- AddrSpace constructor
- Fork Syscall
- Exit
* on a clear, set the valid bit to false in the IPT
On a Page Fault Exception (PFE);, use IPT
Issue /*when using array*/: on a PFE, we have VPN, IPT needed by PPN
Do a sequential search of 3 values
- valid bit is True
- match the vpn
- match AddrSpace* //AddrSpace pointer is useful here if you don't have a unique number. Need to match all three
//This doesn't exist
If all 3 match, copy that index location to TLB //Restart the same command because we haven't run the instruction yet
Two Choices //Because you CAN'T change TranslationEntry
1. Create a new Class that inherits from TranslationEntry
* add AddrSpace* and Process ID
2. Copy/Paste TranslationEntry code to a new CLass and then add the AddrSpace* and Process ID
/**/
Result: all the project 2 code should run
//MAKE SURE YOU RUN YOUR TESTS AFTER EVERY STEP TO MAKE SURE EVERYTHING WORKS!!!!
Step 3 - Do not preload anything
still lots of memory
//any place you were previously doing a find(), comment this out
Can now get an IPT miss
Solution: move the preloading code & IPT population code from step 2 => into P.F.E. handling code
AddrSpace constructor
for(i = 0 to numPhysPages){
int ppn = bitMap->Find() //Comment this out
.
.
.
pageTable[i].valid = false;
.
.
.
//executable->ReadAt()
}
Similar Changes in Fork IF you are making a new pageTable each time
On a PFE from step 2 //This is from step 2
int ppn = 1;
for (i =0 to numPhysPages){
if(/*check 3 values */){
ppn = i;
break;
}
}
/*Step 3 goes here*/
if (ppn == 1){
ppn = handleIPTMiss(vpn);
}
Populate the TLB from IPT //also from step 2
Handling an IPT Miss
- allocate 1 memory pageTable
- Copy from executable (if needed);
- Update page table
* valid bit = true
* physicalPage
- populate IPT from page table
Issue 1: We do not have header info!
2: delete executable; //will need to comment this out
/*File I/O is the slowest thign in an operating system; so we
want to avoid it*/
#1: Must keep executable open until process is done
- move executable variable into AddrSpace
- comment out the delete executable
#2: noffH.code.inFileAddr + (i * PageSize)
Solution: Add data to page table
Need another new CLass //inheritance is the best way
- byte offset //take the thrid arguement and store it in the field
- in executable, or not, or swapfile //can use an int or booleans /*1 one means swap, 2 means neither*/
_____________
|Code |
|-----------|
|I.data |
|-----------|
|-----------| int inExec = divRoundUp(code & initData);
|U.data |
| |
| |
|___________|
//in AddrSpace Constructor
for(){
set not inExec //as a default, you can set everything to not be in the executable
if(i < inExec){
set byte offset
set in executable
}
}
Step 4 - D.P.V.M.
Set numPhysPages to 32 //do not try and run your airport at this point; nachos will page fault too
//fast and too often
* memory will fill up
On a P.F.E., on an IPT miss, bitMap->Find(); will return -1 //this means there is nothing left
You select a page to replace //need a page replacement policy
* 2 polices
-PRAND /*add this test to be able to run from command line*/
- random
-PFIFO /*add this test to be able to run from command line*/
- FIFO - must use a queue
anytime on a Find(not -1);
append ppn to queue
on Find of -1, take from entry
@ end of IPTMiss - add to queue
Selected page may be dirty //means page may have been modified
- must be saved to swapfile
Only 1 swapfile for entire O.S.
-system.h/.cc //stays open for the entire process once opened
-open in Initialize
On IPTMiss:
int ppn = bitMap->Find();
if(ppn == -1){
ppn = handleMemoryFull( );
}
//Rest of step
matmult -> value to exit 7220
//if you get a value between 0 and 7220, it is most likely an issue with the swapfile
//try making the numPhysPages big and see if it actually works. If it does, then you know that the 1st three steps may
//be correct
sort -> value to exit 1023 //sort can take much longer than matmult
//You should just print the value sent to exit when running these tests to make sure they work; start without -rs
nachos -x ../test/matmult
Final Test: //these are 2 seperate tests
fork 2 matmult/sort
exec 2 matmult/sort
How to handle swapfile
Cache of dirty, evicted memory pages
Create a swapfile bitMap - 5000 //check for -1; if it is -1, just print out an error message
outside of nachos
* create swapfile & open
//make sure that the name of the swapfile already exists in the directory... can just make something up in notepad???
Dirty Bits
Nachos only sets TLB dirty bits
anytime you change TLB - propagate dirty bit to TLB
if valid is true
disable interrupts
if(machine->TLB[currentTLB].valid){
//copy dirty bit to IPT
machine->TLB[currentTLB]->_______ = IPT[ppn]._______;
}
currentTLB = _____
R.I.
Start on parts 1 and 2 over the weekend, and get this working.
for networking you can use:
on X11, you can use xterm&
nachos -m 0 -o 1 //the -m is the machine id 0 and it will send and listen for machine 1
You need to type://These are on the 2 seperate shells
nachos -m 0 -o 1
nachos -m 1 -o 0 | [
"jerryweb@usc.edu"
] | jerryweb@usc.edu |
f299332c1671fc7aefef65e0ea836ef5c5c42cb8 | 0cd8bbc974b822c46b64712d3be53e9808a5c246 | /686.cpp | 36def0166e4146f77acc9f7d377030c698769c02 | [] | no_license | limon2009/ACM-UVA-Online-Judge-solution | b78e8f709c88e5db6fdac83a7bd5ec71f7ab00b0 | 0f86718d3c609e654a3c16a29e0f91620ac40cd1 | refs/heads/master | 2021-08-11T04:58:42.829356 | 2017-11-13T06:14:09 | 2017-11-13T06:14:09 | 110,505,263 | 1 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 665 | cpp | #include<stdio.h>
#include<math.h>
int p[32772];
void compute_prime_table()
{
long i,j;
p[0] = p[1] = 0;
for (i=2; i<=32768; i++) p[i]=1;
for (i=2; i<=181;)
{
for (j=i+i; j<=32768; j+=i) p[j]=0;
for (i++; !p[i]; i++);
}
}
main()
{
long n,i,j,count;
compute_prime_table();
while(scanf("%ld",&n)&&n)
{
if(n==4) { printf("1\n"); continue;}
count=0;
for(i=3;i<=16384;i+=2)
{
if(p[i])
{
for(j=n-3;j>=i;j-=2)
{
if(p[j])
{
if(i+j==n)
{
count++;
if((i+j)<n)
break;
}
}
}
}
}
printf("%ld\n",count);
}
return 0;
}
| [
"md.moniruzzaman@bjitgroup.com"
] | md.moniruzzaman@bjitgroup.com |
47974885849556f6d10cae1865230776beb69069 | 29512b1284ec9539164b93023a30f515fed96975 | /Platformer/Background.hpp | 4e26f597c283b1329935471cb032fd6772ff67d9 | [] | no_license | PrzemyslawBanasiak/SFML-Platformer | cb694f4f172a8836bb7aab063307538c9ca37bb8 | 0f31bfddd8b4fd902ad299351982f056ffa09622 | refs/heads/master | 2021-09-03T19:29:35.274848 | 2018-01-11T12:24:02 | 2018-01-11T12:24:02 | 116,832,547 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 249 | hpp | #pragma once
#include <SFML\Graphics.hpp>
struct Managers;
class GameMap;
class Background {
public:
Background(Managers& managers);
void Draw();
private:
Managers& _managers;
sf::Sprite _background;
sf::Vector2f _offset;
};
| [
"200299@student.pwr.edu.pl"
] | 200299@student.pwr.edu.pl |
03cf91bc6525c7a68f33acabbade460d10cd61b4 | 7a20a5c9bd2b9f87b02f545f9e756ea35a8188dd | /Audio Manager/autil_stringlist_private.hpp | e89be0303b2cf7484e5dc8818d736df1c3d0189b | [] | no_license | lukehabermehl/blockdsp | 885ccaefea319f811c21418e5f59471b29ae433e | e0a24632415a5821dfbb3a285128824ec95c4cbc | refs/heads/master | 2020-04-12T05:43:29.324992 | 2017-02-18T22:59:00 | 2017-02-18T22:59:00 | 64,621,055 | 1 | 0 | null | 2016-12-06T03:05:14 | 2016-07-31T23:31:45 | C++ | UTF-8 | C++ | false | false | 410 | hpp | //
// autil_stringlist_private.hpp
// libblockdsp
//
// Created by Luke on 9/8/16.
// Copyright © 2016 Luke Habermehl. All rights reserved.
//
#ifndef autil_stringlist_private_h
#define autil_stringlist_private_h
#include "autil_stringlist.hpp"
#include <vector>
#include <string>
class APUStringList::Pimpl
{
public:
std::vector<std::string> vStrings;
};
#endif /* autil_stringlist_private_h */
| [
"luke.habermehl@gmail.com"
] | luke.habermehl@gmail.com |
2ddadf40b22183348beeddc2765feaf93d2681b8 | 3448a43cf0635866b25e5d513dd60fb003f47e29 | /src/xrGame/Script_SchemeSRNoWeapon.h | f617ace4a1194cc418d045e796d85ff8bda0e9e5 | [
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause"
] | permissive | xrLil-Batya/cordisproject | 49632acc5e68bea9847d001d82fb049703d223c2 | 24275a382fec62a4e58d11579bf497b894f220ba | refs/heads/master | 2023-03-19T01:17:25.170059 | 2020-11-17T14:22:06 | 2020-11-17T14:22:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,977 | h | #pragma once
namespace Cordis
{
namespace Scripts
{
class Script_SchemeSRNoWeapon : public Script_ISchemeEntity
{
using inherited_scheme = Script_ISchemeEntity;
public:
Script_SchemeSRNoWeapon(void) = delete;
Script_SchemeSRNoWeapon(CScriptGameObject* const p_client_object, DataBase::Script_ComponentScheme_SRNoWeapon* storage);
~Script_SchemeSRNoWeapon(void);
virtual void reset_scheme(const bool value, CScriptGameObject* const p_client_object);
virtual void update(const float delta);
// @ PRIVATE uses, in XR_LOGIC
static inline void add_to_binder(CScriptGameObject* const p_client_object, CScriptIniFile* const p_ini,
const xr_string& scheme_name, const xr_string& section_name, DataBase::Script_IComponentScheme* storage)
{
if (!p_client_object)
{
R_ASSERT2(false, "object is null!");
return;
}
if (!p_ini)
{
R_ASSERT2(false, "object is null!");
return;
}
MESSAGEI("added scheme to binder, name=%s scheme=%s section=%s",
p_client_object->Name(), scheme_name.c_str(), section_name.c_str());
Script_ISchemeEntity* p_scheme = new Script_SchemeSRNoWeapon(p_client_object, reinterpret_cast<DataBase::Script_ComponentScheme_SRNoWeapon*>(storage));
DataBase::Storage::getInstance().setStorageSchemesActions(p_client_object->ID(), scheme_name, p_scheme);
}
// @ PRIVATE, uses in XR_LOGIC
static void set_scheme(CScriptGameObject* const p_client_object, CScriptIniFile* const p_ini,
const xr_string& scheme_name, const xr_string& section_name, const xr_string& gulag_name);
private:
void zone_enter(void);
void zone_leave(void);
void switch_state(CScriptGameObject* const p_client_actor);
private:
std::uint32_t m_state;
DataBase::Script_ComponentScheme_SRNoWeapon* m_p_storage;
xrTime m_inited_time;
};
} // namespace Scripts
} // namespace Cordis
| [
"phantom1020@yandex.ru"
] | phantom1020@yandex.ru |
aea09ecea242a285886bd8a8852bd60ce0dbd8d0 | 8b7639352a922a39874cfd006c8213381b1dca13 | /searchMatrix.cpp | 640a6ffd23a3a8b01e8fcf892934e885d25217ac | [] | no_license | Boomshakalak/leetCodePractice | 3cabdec4341e3525a9bcbf20851e45c46de83e6f | bd616240015a094e3303afa7865a1a54e1720128 | refs/heads/master | 2020-07-02T14:13:45.190585 | 2017-08-17T02:20:38 | 2017-08-17T02:20:38 | 74,304,042 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 705 | cpp | class Solution {
public:
bool searchMatrix(vector<vector<int>>& matrix, int target) {
int m = matrix.size();
if (m == 0) return false;
int n = matrix[0].size();
if (n==0) return false;
int l = 0 ;
int r = m ;
while (l < r){
int med = (r+l)>>1;
if (matrix[med][0] <= target) l = med+1;
else r = med;
}
l = l?l-1:0;
int sl = 0;
int sr = n;
while(sl < sr){
int med = (sl+sr)>>1;
if (matrix[l][med]== target) return true;
else if (matrix[l][med] < target) sl = med+1;
else sr = med;
}
return false;
}
};
| [
"soarer@vip.qq.com"
] | soarer@vip.qq.com |
13cc55085d783927351a36782d6f3d3005927d27 | 9f973dea9a0c316db78fd4aa910ab9399c308af4 | /Tutorials-master/KinectSDK/4_SkeletalTracking/main.cpp | 2295ffe399bc1593644b4cdd8cfe17901609c4ef | [] | no_license | VCunhaJ/softkinetic_interactive_Gesture_Camera | 82a15ea7ca65554e4fe21c24b8c924cd9ad5eced | 84b8dd13370171d3f77f84733ef5c46003f33771 | refs/heads/master | 2021-03-12T22:21:00.515486 | 2014-10-24T04:45:11 | 2014-10-24T04:45:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,616 | cpp | #include "main.h"
#include "glut.h"
#include <cmath>
#include <cstdio>
#include <Windows.h>
#include <Ole2.h>
#include <NuiApi.h>
#include <NuiImageCamera.h>
#include <NuiSensor.h>
// OpenGL Variables
long depthToRgbMap[width*height*2];
// We'll be using buffer objects to store the kinect point cloud
GLuint vboId;
GLuint cboId;
// Kinect variables
HANDLE depthStream;
HANDLE rgbStream;
INuiSensor* sensor;
// Stores the coordinates of each joint
Vector4 skeletonPosition[NUI_SKELETON_POSITION_COUNT];
bool initKinect() {
// Get a working kinect sensor
int numSensors;
if (NuiGetSensorCount(&numSensors) < 0 || numSensors < 1) return false;
if (NuiCreateSensorByIndex(0, &sensor) < 0) return false;
// Initialize sensor
sensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX | NUI_INITIALIZE_FLAG_USES_COLOR | NUI_INITIALIZE_FLAG_USES_SKELETON);
sensor->NuiImageStreamOpen(NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX, // Depth camera or rgb camera?
NUI_IMAGE_RESOLUTION_640x480, // Image resolution
0, // Image stream flags, e.g. near mode
2, // Number of frames to buffer
NULL, // Event handle
&depthStream);
sensor->NuiImageStreamOpen(NUI_IMAGE_TYPE_COLOR, // Depth camera or rgb camera?
NUI_IMAGE_RESOLUTION_640x480, // Image resolution
0, // Image stream flags, e.g. near mode
2, // Number of frames to buffer
NULL, // Event handle
&rgbStream);
sensor->NuiSkeletonTrackingEnable(NULL, 0); // NUI_SKELETON_TRACKING_FLAG_ENABLE_SEATED_SUPPORT for only upper body
return sensor;
}
void getDepthData(GLubyte* dest) {
float* fdest = (float*) dest;
long* depth2rgb = (long*) depthToRgbMap;
NUI_IMAGE_FRAME imageFrame;
NUI_LOCKED_RECT LockedRect;
if (sensor->NuiImageStreamGetNextFrame(depthStream, 0, &imageFrame) < 0) return;
INuiFrameTexture* texture = imageFrame.pFrameTexture;
texture->LockRect(0, &LockedRect, NULL, 0);
if (LockedRect.Pitch != 0) {
const USHORT* curr = (const USHORT*) LockedRect.pBits;
for (int j = 0; j < height; ++j) {
for (int i = 0; i < width; ++i) {
// Get depth of pixel in millimeters
USHORT depth = NuiDepthPixelToDepth(*curr++);
// Store coordinates of the point corresponding to this pixel
Vector4 pos = NuiTransformDepthImageToSkeleton(i, j, depth<<3, NUI_IMAGE_RESOLUTION_640x480);
*fdest++ = pos.x/pos.w;
*fdest++ = pos.y/pos.w;
*fdest++ = pos.z/pos.w;
// Store the index into the color array corresponding to this pixel
NuiImageGetColorPixelCoordinatesFromDepthPixelAtResolution(
NUI_IMAGE_RESOLUTION_640x480, NUI_IMAGE_RESOLUTION_640x480, NULL,
i, j, depth<<3, depth2rgb, depth2rgb+1);
depth2rgb += 2;
}
}
}
texture->UnlockRect(0);
sensor->NuiImageStreamReleaseFrame(depthStream, &imageFrame);
}
void getRgbData(GLubyte* dest) {
float* fdest = (float*) dest;
long* depth2rgb = (long*) depthToRgbMap;
NUI_IMAGE_FRAME imageFrame;
NUI_LOCKED_RECT LockedRect;
if (sensor->NuiImageStreamGetNextFrame(rgbStream, 0, &imageFrame) < 0) return;
INuiFrameTexture* texture = imageFrame.pFrameTexture;
texture->LockRect(0, &LockedRect, NULL, 0);
if (LockedRect.Pitch != 0) {
const BYTE* start = (const BYTE*) LockedRect.pBits;
for (int j = 0; j < height; ++j) {
for (int i = 0; i < width; ++i) {
// Determine rgb color for each depth pixel
long x = *depth2rgb++;
long y = *depth2rgb++;
// If out of bounds, then don't color it at all
if (x < 0 || y < 0 || x > width || y > height) {
for (int n = 0; n < 3; ++n) *(fdest++) = 0.0f;
}
else {
const BYTE* curr = start + (x + width*y)*4;
for (int n = 0; n < 3; ++n) *(fdest++) = curr[2-n]/255.0f;
}
}
}
}
texture->UnlockRect(0);
sensor->NuiImageStreamReleaseFrame(rgbStream, &imageFrame);
}
void getSkeletalData() {
NUI_SKELETON_FRAME skeletonFrame = {0};
if (sensor->NuiSkeletonGetNextFrame(0, &skeletonFrame) >= 0) {
sensor->NuiTransformSmooth(&skeletonFrame, NULL);
// Loop over all sensed skeletons
for (int z = 0; z < NUI_SKELETON_COUNT; ++z) {
const NUI_SKELETON_DATA& skeleton = skeletonFrame.SkeletonData[z];
// Check the state of the skeleton
if (skeleton.eTrackingState == NUI_SKELETON_TRACKED) {
// Copy the joint positions into our array
for (int i = 0; i < NUI_SKELETON_POSITION_COUNT; ++i) {
skeletonPosition[i] = skeleton.SkeletonPositions[i];
if (skeleton.eSkeletonPositionTrackingState[i] == NUI_SKELETON_POSITION_NOT_TRACKED) {
skeletonPosition[i].w = 0;
}
}
return; // Only take the data for one skeleton
}
}
}
}
void getKinectData() {
const int dataSize = width*height*3*4;
GLubyte* ptr;
glBindBuffer(GL_ARRAY_BUFFER, vboId);
glBufferData(GL_ARRAY_BUFFER, dataSize, 0, GL_DYNAMIC_DRAW);
ptr = (GLubyte*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
if (ptr) {
getDepthData(ptr);
}
glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, cboId);
glBufferData(GL_ARRAY_BUFFER, dataSize, 0, GL_DYNAMIC_DRAW);
ptr = (GLubyte*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
if (ptr) {
getRgbData(ptr);
}
glUnmapBuffer(GL_ARRAY_BUFFER);
getSkeletalData();
}
void rotateCamera() {
static double angle = 0.;
static double radius = 3.;
double x = radius*sin(angle);
double z = radius*(1-cos(angle)) - radius/2;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(x,0,z,0,0,radius/2,0,1,0);
angle += 0.05;
}
void drawKinectData() {
getKinectData();
rotateCamera();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, vboId);
glVertexPointer(3, GL_FLOAT, 0, NULL);
glBindBuffer(GL_ARRAY_BUFFER, cboId);
glColorPointer(3, GL_FLOAT, 0, NULL);
glPointSize(1.f);
glDrawArrays(GL_POINTS, 0, width*height);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
// Draw some arms
const Vector4& lh = skeletonPosition[NUI_SKELETON_POSITION_HAND_LEFT];
const Vector4& le = skeletonPosition[NUI_SKELETON_POSITION_ELBOW_LEFT];
const Vector4& ls = skeletonPosition[NUI_SKELETON_POSITION_SHOULDER_LEFT];
const Vector4& rh = skeletonPosition[NUI_SKELETON_POSITION_HAND_RIGHT];
const Vector4& re = skeletonPosition[NUI_SKELETON_POSITION_ELBOW_RIGHT];
const Vector4& rs = skeletonPosition[NUI_SKELETON_POSITION_SHOULDER_RIGHT];
glBegin(GL_LINES);
glColor3f(1.f, 0.f, 0.f);
if (lh.w > 0 && le.w > 0 && ls.w > 0) {
glVertex3f(lh.x, lh.y, lh.z);
glVertex3f(le.x, le.y, le.z);
glVertex3f(le.x, le.y, le.z);
glVertex3f(ls.x, ls.y, ls.z);
}
if (rh.w > 0 && re.w > 0 && rs.w > 0) {
glVertex3f(rh.x, rh.y, rh.z);
glVertex3f(re.x, re.y, re.z);
glVertex3f(re.x, re.y, re.z);
glVertex3f(rs.x, rs.y, rs.z);
}
glEnd();
}
int main(int argc, char* argv[]) {
if (!init(argc, argv)) return 1;
if (!initKinect()) return 1;
// OpenGL setup
glClearColor(0,0,0,0);
glClearDepth(1.0f);
// Set up array buffers
glGenBuffers(1, &vboId);
glBindBuffer(GL_ARRAY_BUFFER, vboId);
glGenBuffers(1, &cboId);
glBindBuffer(GL_ARRAY_BUFFER, cboId);
// Camera setup
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, width /(GLdouble) height, 0.1, 1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,0,0,0,1,0,1,0);
// Main loop
execute();
return 0;
}
| [
"Junior@vcunha.wifi.wpi.edu"
] | Junior@vcunha.wifi.wpi.edu |
ce684a91b8d96f0ae090d4faebefcbe87a8aa164 | d2532fef27934284f9f0d932931999825128da5a | /4-Algorithms on strings/Programming-Assignment-1/trie_matching/trie_matching.cpp | c621cf925f27ce6f8829cbda7c1dae52da0f3294 | [] | no_license | mohamedabdelhakem1/UCSD-data-structures-and-algorithms-specialization | f57f3418f82906894641d53f9e2234932d9f554e | 2e31939f561a60ed829e5e5f663dcd06c645c644 | refs/heads/master | 2020-07-03T21:18:18.895700 | 2019-08-13T02:00:21 | 2019-08-13T02:00:21 | 202,052,423 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,450 | cpp | #include <bits/stdc++.h>
using namespace std;
struct edge {
int from;
int to;
char label;
};
struct vertex {
int index;
unordered_map <char, edge> out_edges;
};
class trie {
public:
vertex *root = new vertex();
unordered_map <int, vertex*> vertices;
trie() {
root->index = 0;
vertices[0] = root;
}
vector<edge> edges;
int size() {
return static_cast<int>(edges.size());
}
};
trie* build_trie(vector<string> & patterns) {
trie *t = new trie();
int c = 1;
for(int i = 0 ; i < patterns.size() ; i++) {
vertex *v = t->root;
for(int j = 0 ; j < static_cast<int>(patterns[i].size()) ; j++) {
if( v->out_edges.find(patterns[i][j]) != v->out_edges.end()) {
int num = v->out_edges[patterns[i][j]].to;
v = t->vertices[num];
} else {
vertex* new_vertex = new vertex();
new_vertex->index = c;
t->vertices[c] = new_vertex ;
v->out_edges[patterns[i][j]] = {v->index, c, patterns[i][j] } ;
t->edges.push_back( v->out_edges[patterns[i][j]]);
v = new_vertex;
c++;
}
}
}
return t;
}
vector <int> solve (const string& text, int n, vector <string>& patterns)
{ trie *t = build_trie(patterns);
vector <int> result;
for(int i = 0 ; i < text.size(); i++){
int j = i;
vertex *v = t->root;
while(j < text.size()){
if(v->out_edges.size() == 0){ // leaf
result.push_back(i);
break;
} else if(v->out_edges.find(text[j]) != v->out_edges.end()){
int v_num= v->out_edges[text[j]].to;
v = t->vertices[v_num];
j++;
}else{
break;
}
}
if(j == text.size() && v->out_edges.size() == 0){ // leaf
result.push_back(i);
}
}
sort(result.begin() , result.end());
return result;
}
int main (void)
{
string t;
cin >> t;
int n;
cin >> n;
vector <string> patterns (n);
for (int i = 0; i < n; i++)
{
cin >> patterns[i];
}
vector <int> ans;
ans = solve (t, n, patterns);
for (int i = 0; i < (int) ans.size (); i++)
{
cout << ans[i];
if (i + 1 < (int) ans.size ())
{
cout << " ";
}
else
{
cout << endl;
}
}
return 0;
}
| [
"mohamedabdelhakem99@yahoo.com"
] | mohamedabdelhakem99@yahoo.com |
92bc8e8bc53d89498e8bda68f597a86a93d6feea | fe06abf8fd1ef60e28d2d41a0120b31f91844099 | /5.1D/Vector.h | af408d4b9b1e32cd440e4849379f5b2a5e87de28 | [] | no_license | Korovytskyi/5.1.4 | 0873bdfc68236e5d89e0d5dc46463c721a9ff8b2 | 62cda6153f01e3d90c9675ba0bb287aa415bdc0f | refs/heads/master | 2023-04-08T02:25:58.784804 | 2021-04-25T12:38:05 | 2021-04-25T12:38:05 | 361,424,522 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 804 | h | #pragma once
#include <iostream>
#include "Exception.h"
using namespace std;
class Vector
{
private:
double x, y, z;
public:
Vector();
Vector(double x, double y, double z) ;
Vector(const Vector&);
void setX(double value) { x = value; }
void setY(double value) { y = value; }
void setZ(double value) { z = value; }
double getX() const { return x; }
double getY() const { return y; }
double getZ() const { return z; }
friend bool operator ==(const Vector& t1, const Vector& t2);
friend bool operator >(const Vector& t1, const Vector& t2);
friend bool operator <(const Vector& t1, const Vector& t2);
friend bool operator >=(const Vector& t1, const Vector& t2);
friend bool operator <=(const Vector& t1, const Vector& t2);
friend bool operator !=(const Vector& t1, const Vector& t2);
};
| [
"taras.korovytskyi.itis.2020@lpnu.ua"
] | taras.korovytskyi.itis.2020@lpnu.ua |
81607040f08a087ba3b8091f1b2ccd1937f5d36a | 9987a33adf46172cf5352b57e2e1319955dd75ab | /SongInfoEditor/VarietyButton.cpp | 9a7ce4ab3ebffec0c8b38df3a0f82421eb717ef4 | [] | no_license | lilinayuy/SongInfo | ce4cb73c7d4b394abf1f063939d758cbef79743c | d02929c16f5144a542093b88be02118e9d54f20b | refs/heads/master | 2016-09-10T18:24:53.640838 | 2015-03-24T01:53:41 | 2015-03-24T01:53:41 | 32,769,729 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 18,743 | cpp | // VarietyButton.cpp : implementation file
//
#include "stdafx.h"
#include "VarietyButton.h"
//#include "DCPlus.h"
// CVarietyButton
IMPLEMENT_DYNAMIC(CVarietyButton, CBitmapButton)
CVarietyButton::CVarietyButton()
{
m_bTracking = FALSE;
m_bSelected = FALSE;
m_cColorTransparent = 0;
m_bDoubleClick = FALSE;
m_bMovable = FALSE;
m_nButtonMode = 1;
m_pBitmap = NULL;
m_pBitmapSel = NULL;
m_pBitmapHighLight = NULL;
m_pBitmapSelHighLight = NULL;
m_pBitmapDisabled = NULL;
m_pBitmapRegion = NULL;
m_cFontColor = 0;
m_cFontColorSel = 0;
m_cFontColorHighLight = 0;
m_cFontColorSelHighLight = 0;
m_cFontColorDisabled = 0;
m_cColorTransparent = 0;
m_pImage = NULL;
m_pImageSel = NULL;
m_pImageHighLight = NULL;
m_pImageSelHighLight = NULL;
m_pImageDisabled = NULL;
m_pImageRegion = NULL;
}
CVarietyButton::~CVarietyButton()
{
if (m_pBitmap){
m_pBitmap->DeleteObject();
delete m_pBitmap;
m_pBitmap = NULL;
}
if (m_pBitmapSel){
m_pBitmapSel->DeleteObject();
delete m_pBitmapSel;
m_pBitmapSel = NULL;
}
if (m_pBitmapHighLight){
m_pBitmapHighLight->DeleteObject();
delete m_pBitmapHighLight;
m_pBitmapHighLight = NULL;
}
if (m_pBitmapSelHighLight){
m_pBitmapSelHighLight->DeleteObject();
delete m_pBitmapSelHighLight;
m_pBitmapSelHighLight = NULL;
}
if (m_pBitmapDisabled){
m_pBitmapDisabled->DeleteObject();
delete m_pBitmapDisabled;
m_pBitmapDisabled = NULL;
}
if (m_pBitmapRegion){
m_pBitmapRegion->DeleteObject();
delete m_pBitmapRegion;
m_pBitmapRegion = NULL;
}
ClearImage();
}
BEGIN_MESSAGE_MAP(CVarietyButton, CBitmapButton)
ON_WM_MOUSEMOVE()
ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
ON_MESSAGE(WM_MOUSEHOVER, OnMouseHover)
ON_WM_ERASEBKGND()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
END_MESSAGE_MAP()
// CVarietyButton message handlers
void CVarietyButton::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
CBitmapButton::PreSubclassWindow();
ModifyStyle(0, BS_OWNERDRAW);
m_pDC = GetDC();
m_pDC->SetBkMode(TRANSPARENT);
m_hBtnDC = m_pDC->GetSafeHdc();
//m_pBackground = &Graphics(m_pDC->GetSafeHdc());
CRect rc;
GetClientRect(&rc);
m_nWidth = rc.Width();
m_nHeight = rc.Height();
ModifyStyleEx(0, WS_EX_TRANSPARENT);
}
void CVarietyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)//*lpDrawItemStruct*/)
{
if (m_nButtonMode == 3) {
return;
}
UINT uStyle = DFCS_BUTTONPUSH;
ASSERT(lpDrawItemStruct->CtlType == ODT_BUTTON);
// If drawing selected, add the pushed style to DrawFrameControl.
// m_pDC->Draw3dRect(0, 0, m_nWidth, m_nHeight, RGB(220, 220, 220), RGB(100, 100, 100));
// ShowWindow(SW_HIDE);
m_pDC->BitBlt(0, 0, m_nWidth, m_nHeight, m_pParentDC, rcWindow.left, rcWindow.top, SRCCOPY);
// ShowWindow(SW_SHOW);
if (lpDrawItemStruct->itemState & ODS_SELECTED){
//点中
// m_pDC->Draw3dRect(0, 0, m_nWidth, m_nHeight, RGB(100, 100, 100), RGB(100, 100, 100));
uStyle |= DFCS_BUTTONPUSH;
if (m_bSelected){
if (m_pImageSelHighLight != 0){
m_pImageSelHighLight->Draw(m_hBtnDC, 0, 0, m_nWidth, m_nHeight);
}
}else{
if (m_pImageHighLight != 0){
m_pImageHighLight->Draw(m_hBtnDC, 0, 0, m_nWidth, m_nHeight);
}
}
CString strText;
GetWindowText(strText);
if (!m_bSelected){
m_pDC->SetTextColor(m_cFontColorSelHighLight);
}else{
m_pDC->SetTextColor(m_cFontColorHighLight);
}
m_pDC->DrawText(strText, strText.GetLength(), CRect(0, 0, m_nWidth, m_nHeight), DT_SINGLELINE|DT_VCENTER|DT_CENTER); //重绘文字
// m_bTracking = 1;
}else if (lpDrawItemStruct->itemState & ODS_DISABLED){
//无效化
m_pImageDisabled->Draw(m_hBtnDC, 0, 0, m_nWidth, m_nHeight);
CString strText;
GetWindowText(strText);
m_pDC->SetTextColor(m_cFontColorDisabled);
m_pDC->DrawText(strText, strText.GetLength(), CRect(0, 0, m_nWidth, m_nHeight), DT_SINGLELINE|DT_VCENTER|DT_CENTER); //重绘文字
}else if (lpDrawItemStruct->itemState & ODS_FOCUS){
//键盘焦点
if (m_bSelected){
if (m_pImageSelHighLight != 0){
m_pImageSelHighLight->Draw(m_hBtnDC, 0, 0, m_nWidth, m_nHeight);
}
}else{
if (m_pImageHighLight != 0){
m_pImageHighLight->Draw(m_hBtnDC, 0, 0, m_nWidth, m_nHeight);
}
}
CString strText;
GetWindowText(strText);
if (!m_bSelected){
m_pDC->SetTextColor(m_cFontColorSelHighLight);
}else{
m_pDC->SetTextColor(m_cFontColorHighLight);
}
m_pDC->DrawText(strText, strText.GetLength(), CRect(0, 0, m_nWidth, m_nHeight), DT_SINGLELINE|DT_VCENTER|DT_CENTER); //重绘文字
}else if (lpDrawItemStruct->itemState & ODS_HOTLIGHT){
//只在XP有用 高亮
if (m_bSelected){
if (m_pImageSelHighLight != 0){
m_pImageSelHighLight->Draw(m_hBtnDC, 0, 0, m_nWidth, m_nHeight);
}
}else{
if (m_pImageHighLight != 0){
m_pImageHighLight->Draw(m_hBtnDC, 0, 0, m_nWidth, m_nHeight);
}
}
CString strText;
GetWindowText(strText);
if (m_bSelected){
m_pDC->SetTextColor(m_cFontColorSelHighLight);
}else{
m_pDC->SetTextColor(m_cFontColorHighLight);
}
m_pDC->DrawText(strText, strText.GetLength(), CRect(0, 0, m_nWidth, m_nHeight), DT_SINGLELINE|DT_VCENTER|DT_CENTER); //重绘文字
}else{
//一般状态
if (m_pImage == 0){
return;
}
m_pImage->Draw(m_hBtnDC, 0, 0, m_nWidth, m_nHeight);
CString strText;
GetWindowText(strText);
m_pDC->SetTextColor(m_cFontColor);
m_pDC->DrawText(strText, strText.GetLength(), CRect(0, 0, m_nWidth, m_nHeight), DT_SINGLELINE|DT_VCENTER|DT_CENTER); //重绘文字
}
// CButton::DrawItem(lpDrawItemStruct);
}
void CVarietyButton::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (m_bMovable){
CDialog* pDlg = (CDialog*)m_pParentWnd;
if (HIBYTE(GetKeyState(VK_LCONTROL)) || HIBYTE(GetKeyState(VK_RCONTROL))){
point.x += rcWindow.left;
point.y += rcWindow.top;
ButtonMoveWindow(this, m_pParentWnd, point);
}else{
m_bMovable = FALSE;
}
}else if (!m_bTracking){
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = m_hWnd;
tme.dwFlags = TME_LEAVE | TME_HOVER;
tme.dwHoverTime = 1;
m_bTracking = _TrackMouseEvent(&tme);
}else{
}
CBitmapButton::OnMouseMove(nFlags, point);
}
LRESULT CVarietyButton::OnMouseLeave(WPARAM wParam, LPARAM lParam)
{
if (m_bMovable) return 0;
// ShowWindow(SW_HIDE);
m_pDC->BitBlt(0, 0, m_nWidth, m_nHeight, m_pParentDC, rcWindow.left, rcWindow.top, SRCCOPY);
// ShowWindow(SW_SHOW);
if (m_bSelected){
// m_pDC->Draw3dRect(0, 0, m_nWidth, m_nHeight, RGB(100, 100, 100), RGB(100, 100, 100));
if (m_pImageSel != 0){
m_pImageSel->Draw(m_hBtnDC, 0, 0, m_nWidth, m_nHeight);
}
}else{
if (m_pImage != 0){
m_pImage->Draw(m_hBtnDC, 0, 0, m_nWidth, m_nHeight);
}
}
CString strText;
GetWindowText(strText);
if (m_bSelected){
m_pDC->SetTextColor(m_cFontColorSel);
}else{
m_pDC->SetTextColor(m_cFontColor);
}
m_pDC->DrawText(strText, strText.GetLength(), CRect(0, 0, m_nWidth, m_nHeight), DT_SINGLELINE|DT_VCENTER|DT_CENTER); //重绘文字
m_bTracking = 0;
return 0;
}
LRESULT CVarietyButton::OnMouseHover(WPARAM wParam, LPARAM lParam)
{
// ShowWindow(SW_HIDE);
m_pDC->BitBlt(0, 0, m_nWidth, m_nHeight, m_pParentDC, rcWindow.left, rcWindow.top, SRCCOPY);
// ShowWindow(SW_SHOW);
if (m_bSelected){
// m_pDC->Draw3dRect(0, 0, m_nWidth, m_nHeight, RGB(100, 100, 100), RGB(100, 100, 100));
if (m_pImageSelHighLight != 0){
m_pImageSelHighLight->Draw(m_hBtnDC, 0, 0, m_nWidth, m_nHeight);
}
}else{
// m_pDC->BitBlt(0, 0, m_nWidth, m_nHeight, m_pParentWnd->GetDC(), m_nLeft, m_nTop, SRCCOPY);
// m_pDC->Draw3dRect(0, 0, m_nWidth, m_nHeight, RGB(220, 220, 220), RGB(100, 100, 100));
if (m_pImageHighLight != 0){
m_pImageHighLight->Draw(m_hBtnDC, 0, 0, m_nWidth, m_nHeight);
}
// dcTemp.SelectObject(m_pBitmapHighLight);
}
CString strText;
GetWindowText(strText);
if (m_bSelected){
m_pDC->SetTextColor(m_cFontColorSelHighLight);
}else{
m_pDC->SetTextColor(m_cFontColorHighLight);
}
m_pDC->DrawText(strText, strText.GetLength(), CRect(0, 0, m_nWidth, m_nHeight), DT_SINGLELINE|DT_VCENTER|DT_CENTER); //重绘文字
return 0;
}
BOOL CVarietyButton::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return FALSE;
// return CBitmapButton::OnEraseBkgnd(pDC);
}
BOOL CVarietyButton::LoadBitmaps(UINT nIDBitmapResource,
UINT nIDBitmapResourceSel,
UINT nIDBitmapResourceHighLight,
UINT nIDBitmapResourceDisabled,
UINT nIDBitmapResourceSelHighLight,
UINT nIDBitmapResourceRegion)
{
/* m_pBitmap = new CBitmap();
m_pBitmap->LoadBitmap(nIDBitmapResource);
m_pBitmapSel = new CBitmap();
m_pBitmapSel->LoadBitmap(nIDBitmapResourceSel);
m_pBitmapHighLight = new CBitmap();
m_pBitmapHighLight->LoadBitmap(nIDBitmapResourceHighLight);
m_pBitmapDisabled = new CBitmap();
m_pBitmapDisabled->LoadBitmap(nIDBitmapResourceDisabled);
m_pBitmapSelHighLight = new CBitmap();
m_pBitmapSelHighLight->LoadBitmap(nIDBitmapResourceSelHighLight);
m_pBitmapRegion = new CBitmap();
m_pBitmapRegion->LoadBitmap(nIDBitmapResourceRegion);*/
m_pImage = new CImage();
ImageFromIDResource(nIDBitmapResource, _T("PNG"), m_pImage);
m_pImageSel = new CImage();
ImageFromIDResource(nIDBitmapResourceSel, _T("PNG"), m_pImageSel);
m_pImageHighLight = new CImage();
ImageFromIDResource(nIDBitmapResourceHighLight, _T("PNG"), m_pImageHighLight);
m_pImageDisabled = new CImage();
ImageFromIDResource(nIDBitmapResourceDisabled, _T("PNG"), m_pImageDisabled);
m_pImageSelHighLight = new CImage();
ImageFromIDResource(nIDBitmapResourceSelHighLight, _T("PNG"), m_pImageSelHighLight);
m_pImageRegion = new CImage();
ImageFromIDResource(nIDBitmapResourceRegion, _T("PNG"), m_pImageRegion);
return TRUE;
}
void CVarietyButton::InitButton(CWnd* pWnd, int nLeft, int nTop, int nWidth, int nHeight, COLORREF nColorTransparent, UINT nIDBitmapResource, COLORREF nColor, UINT nIDBitmapResourceSel, COLORREF nColorSel,
UINT nIDBitmapResourceHighLight, COLORREF nColorHighLight, UINT nIDBitmapResourceDisabled, COLORREF nColorDisabled,
UINT nIDBitmapResourceSelHighLight, COLORREF nColorSelHighLight, UINT nIDBitmapResourceRegion, COLORREF nColorRegion)
{
m_pParentWnd = pWnd;
m_pParentDC = m_pParentWnd->GetDC();
m_nLeft = nLeft;
m_nTop = nTop;
m_nWidth = nWidth;
m_nHeight = nHeight;
rcWindow = CRect(nLeft, nTop, nLeft + nWidth, nTop + nHeight);
MoveWindow(&rcWindow);
ClearImage();
LoadBitmaps(nIDBitmapResource, nIDBitmapResourceSel, nIDBitmapResourceHighLight, nIDBitmapResourceDisabled, nIDBitmapResourceSelHighLight, nIDBitmapResourceRegion);
m_cFontColor = nColor;
if (nColorSel <= 16777215){
m_cFontColorSel = nColorSel;
}else{
m_cFontColorSel = m_cFontColor;
}
if (nColorHighLight <= 16777215){
m_cFontColorHighLight = nColorHighLight;
}else{
m_cFontColorHighLight = m_cFontColorSel;
}
if (nColorSelHighLight <= 16777215){
m_cFontColorSelHighLight = nColorSelHighLight;
}else{
m_cFontColorSelHighLight = m_cFontColorSel;
}
if (nColorDisabled <= 16777215){
m_cFontColorDisabled = nColorDisabled;
}else{
m_cFontColorDisabled = RGB(200, 200, 200);
}
m_cColorTransparent = nColorTransparent;
if (m_pImageRegion){
m_pImageRegion->SetTransparentColor(nColorRegion);
SetupRegion(m_pImageRegion, nColorRegion);
}
}
BOOL CVarietyButton::LoadBitmaps(LPCTSTR lpszBitmapResource,
LPCTSTR lpszBitmapResourceSel,
LPCTSTR lpszBitmapResourceHighLight,
LPCTSTR lpszBitmapResourceDisabled,
LPCTSTR lpszBitmapResourceSelHighLight,
LPCTSTR lpszBitmapResourceRegion)
{
m_pImage = new CImage();
m_pImage->Load(lpszBitmapResource);
m_pImageSel = new CImage();
m_pImageSel->Load(lpszBitmapResourceSel);
m_pImageHighLight = new CImage();
m_pImageHighLight->Load(lpszBitmapResourceHighLight);
m_pImageDisabled = new CImage();
m_pImageDisabled->Load(lpszBitmapResourceDisabled);
m_pImageSelHighLight = new CImage();
m_pImageSelHighLight->Load(lpszBitmapResourceSelHighLight);
m_pImageRegion = new CImage();
m_pImageRegion->Load(lpszBitmapResourceRegion);
return TRUE;
}
void CVarietyButton::InitButton(CWnd* pWnd, int nLeft, int nTop, int nWidth, int nHeight, COLORREF nColorTransparent, CString strImage, COLORREF nColor, CString strImageSel, COLORREF nColorSel,
CString strImageHighLight, COLORREF nColorHighLight, CString strImageDisabled, COLORREF nColorDisabled,
CString strImageSelHighLight, COLORREF nColorSelHighLight, CString strImageRegion, COLORREF nColorRegion)
{
m_pParentWnd = pWnd;
m_pParentDC = m_pParentWnd->GetDC();
m_nLeft = nLeft;
m_nTop = nTop;
m_nWidth = nWidth;
m_nHeight = nHeight;
rcWindow = CRect(nLeft, nTop, nLeft + nWidth, nTop + nHeight);
MoveWindow(&rcWindow);
ClearImage();
LoadBitmaps(strImage.GetBuffer(), strImageSel.GetBuffer(), strImageHighLight.GetBuffer(), strImageDisabled.GetBuffer(), strImageSelHighLight.GetBuffer(), strImageRegion.GetBuffer());
m_cFontColor = nColor;
if (nColorSel <= 16777215){
m_cFontColorSel = nColorSel;
}else{
m_cFontColorSel = m_cFontColor;
}
if (nColorHighLight <= 16777215){
m_cFontColorHighLight = nColorHighLight;
}else{
m_cFontColorHighLight = m_cFontColorSel;
}
if (nColorSelHighLight <= 16777215){
m_cFontColorSelHighLight = nColorSelHighLight;
}else{
m_cFontColorSelHighLight = m_cFontColorSel;
}
if (nColorDisabled <= 16777215){
m_cFontColorDisabled = nColorDisabled;
}else{
m_cFontColorDisabled = RGB(200, 200, 200);
}
m_cColorTransparent = nColorTransparent;
if (m_pImageRegion){
m_pImageRegion->SetTransparentColor(nColorRegion);
SetupRegion(m_pImageRegion, nColorRegion);
}
}
void CVarietyButton::SetSelected(BOOL bSelected)
{
m_bSelected = bSelected;
m_bTracking = 0;
}
void CVarietyButton::SetupRegion(CImage* pImage, COLORREF TransparentColor)
{
CRgn wndRgn;
//创建总的窗体区域,初始region为0
wndRgn.CreateRectRgn(0,0,0,0);
int nWidth = pImage->GetWidth();
int nHeight = pImage->GetHeight();
int nX, nY;
for(nY = 0; nY < nHeight; nY++){
CRgn rgnTemp;//保存临时region
nX = 0;
do{
//跳过透明色找到下一个非透明色的点.
while (nX < nWidth && pImage->GetPixel(nX, nY) == TransparentColor){
nX ++;
}
int nLeft = nX;
//寻找下个透明色的点
while (nX < nWidth && pImage->GetPixel(nX, nY) != TransparentColor){
nX ++;
}
//创建一个包含起点与重点间高为1像素的临时“region”
rgnTemp.CreateRectRgn(nLeft, nY, nX, nY+1);
//合并到主 "region ".
wndRgn.CombineRgn(&wndRgn, &rgnTemp, RGN_OR);
//删除临时 "region ",否则下次创建时和出错
rgnTemp.DeleteObject();
}while(nX < nWidth);
}
SetWindowRgn(wndRgn,TRUE);
wndRgn.DeleteObject();
}
void CVarietyButton::SetButtonFont(CString strFont, int nFontSize)
{
m_cFont.DeleteObject();
m_cFont.CreateFont(nFontSize, nFontSize / 2, 0, 0, FW_DONTCARE, FALSE, FALSE, 0, GB2312_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
m_pDC->SelectObject(&m_cFont);
}
LRESULT CVarietyButton::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
if (!m_bDoubleClick){
if (message == WM_LBUTTONDBLCLK){
message = WM_LBUTTONDOWN;
}
}
return CBitmapButton::DefWindowProc(message, wParam, lParam);
}
BOOL CVarietyButton::GetSelected()
{
return m_bSelected;
}
BOOL CVarietyButton::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message == WM_LBUTTONUP){
m_bTracking = 0;
}else if(pMsg->message == WM_LBUTTONDOWN){
}
return CBitmapButton::PreTranslateMessage(pMsg);
}
void CVarietyButton::EnableDoubleClick(BOOL bEnable)
{
m_bDoubleClick = bEnable;
}
void CVarietyButton::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (HIBYTE(GetKeyState(VK_LCONTROL)) || HIBYTE(GetKeyState(VK_RCONTROL))){
//按下开始移动
m_bMovable = TRUE;
point.x += rcWindow.left;
point.y += rcWindow.top;
m_ptStart = point;
// TRACE2(_T("按钮坐标%d,%d\r\n"), point.x, point.y);
return;
}
if (m_nButtonMode == 1){
m_bSelected = !m_bSelected;
}
CBitmapButton::OnLButtonDown(nFlags, point);
}
void CVarietyButton::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_bMovable = FALSE;
CBitmapButton::OnLButtonUp(nFlags, point);
}
void CVarietyButton::ButtonMoveWindow(CWnd* pWnd, CWnd* pParentWnd, CPoint point)
{
if (m_bMovable && (HIBYTE(GetKeyState(VK_LCONTROL))) || (HIBYTE(GetKeyState(VK_RCONTROL)))){
rcWindow.left += (point.x - m_ptStart.x);
rcWindow.right += (point.x - m_ptStart.x);
rcWindow.top += (point.y - m_ptStart.y);
rcWindow.bottom += (point.y - m_ptStart.y);
if (rcWindow.left < 0) rcWindow.left = 0;
rcWindow.right = rcWindow.left + m_nWidth;
if (rcWindow.top < 0) rcWindow.top = 0;
rcWindow.bottom = rcWindow.top + m_nHeight;
// TRACE2(_T("按钮位置坐标%d,%d**\r\n"), rcWindow.left, rcWindow.top);
MoveWindow(&rcWindow, 1);
m_ptStart = point;
// TRACE2(_T("按钮位置坐标%d,%d//\r\n"), point.x, point.y);
// }else{
// m_bMovable = FALSE;
// }
}
}
BOOL CVarietyButton::ImageFromIDResource(UINT nID, LPCTSTR szType, CImage* pImg)
{
HINSTANCE hInst = AfxGetResourceHandle();
HRSRC hRsrc = ::FindResource(hInst,MAKEINTRESOURCE(nID), szType); // type
if (!hRsrc) return FALSE;
// load resource into memory
DWORD len = SizeofResource(hInst, hRsrc);
BYTE* lpRsrc = (BYTE*)LoadResource(hInst, hRsrc);
if (!lpRsrc)
return FALSE;
// Allocate global memory on which to create stream
HGLOBAL m_hMem = GlobalAlloc(GMEM_FIXED, len);
BYTE* pmem = (BYTE*)GlobalLock(m_hMem);
memcpy(pmem,lpRsrc,len);
IStream* pstm;
CreateStreamOnHGlobal(m_hMem,FALSE,&pstm);
// load from stream
pImg->Load(pstm);
// free/release stuff
GlobalUnlock(m_hMem);
pstm->Release();
FreeResource(lpRsrc);
return TRUE;
}
void CVarietyButton::ClearImage()
{
if (m_pImage){
m_pImage->Destroy();
delete m_pImage;
m_pImage = NULL;
}
if (m_pImageSel){
m_pImageSel->Destroy();
delete m_pImageSel;
m_pImageSel = NULL;
}
if (m_pImageHighLight){
m_pImageHighLight->Destroy();
delete m_pImageHighLight;
m_pImageHighLight = NULL;
}
if (m_pImageSelHighLight){
m_pImageSelHighLight->Destroy();
delete m_pImageSelHighLight;
m_pImageSelHighLight = NULL;
}
if (m_pImageDisabled){
m_pImageDisabled->Destroy();
delete m_pImageDisabled;
m_pImageDisabled = NULL;
}
if (m_pImageRegion){
m_pImageRegion->Destroy();
delete m_pImageRegion;
m_pImageRegion = NULL;
}
} | [
"heeroyuy1982@163.com"
] | heeroyuy1982@163.com |
b3520ad42a107882dee9aebd02fd367bf943020d | 4d408971c07fcc1bec5e3120109713bf4da11581 | /EntryData/EntryData.h | 612da3e0f2ee32ec5e609408edd8a255aae76d25 | [] | no_license | chulchultrain/FactoryHead | c108f3dcda4ed44a7b74b32ffcf4ba1fdbab1353 | 01362c1cc41a73156e9e896df848eb70ad295675 | refs/heads/master | 2020-05-21T23:51:44.620899 | 2018-01-04T05:47:14 | 2018-01-04T05:47:14 | 63,737,643 | 2 | 0 | null | 2017-05-25T18:27:32 | 2016-07-20T00:44:32 | C++ | UTF-8 | C++ | false | false | 446 | h | #ifndef __ENTRYDATA_H_INCLUDED__
#define __ENTRYDATA_H_INCLUDED__
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
struct EntryData {
string ID;
string DexID;
vector<string> moveID;
string item;
string nature;
vector<int> EV;
EntryData(string x1, string x2, vector<string> &x3, string x4, string x5, vector<int> &x6);
EntryData();
};
bool operator == (const EntryData &lhs, const EntryData &rhs);
#endif
| [
"yangchulmin0@gmail.com"
] | yangchulmin0@gmail.com |
84c3f4726d62b045e733ff4c5a5f633a753ec8eb | fa2250779a2eb0b3155f8a9912b9b08caeba0cbe | /OpenGL/instances_tests/3.plain_quads/main.cpp | f81198859a8fbe5aff37a40613fe8b811e01a9af | [
"MIT"
] | permissive | on62/daft-lib | 33b3d00fe3520b9ce78ddcbd7a814ed78c1bf254 | 7890fdba0aab800022ab9afb958946bd06779f33 | refs/heads/master | 2022-11-14T23:08:13.978445 | 2020-07-08T13:33:09 | 2020-07-08T13:33:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,288 | cpp | //----------------------------------------------------------------------------
//
// file: main.cpp
//
// Общий буфер атрибутов + индексный буфер
//
//----------------------------------------------------------------------------
#include "tools.hpp"
#include "texture.hpp"
// VBO массив из 6 точек для создания прямоугольника из 2-х треугольников:
// 4 координаты 3D, 4 значения цвета RGBA, 4 координаты нормали, UV - текстуры
GLfloat points[] = {
//|--pos3d------------------| |--color---------------| |--normal--------------| |--tex2d---------|
-0.49f, 0.0f, 0.49f, 1.0f, 0.6f, 0.9f, 0.6f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.1250f, 0.1250f,
0.49f, 0.0f, 0.49f, 1.0f, 0.6f, 0.9f, 0.6f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.1875f, 0.1250f,
0.49f, 0.0f, -0.49f, 1.0f, 0.6f, 0.9f, 0.6f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.1875f, 0.1875f,
-0.49f, 0.0f, -0.49f, 1.0f, 0.6f, 0.9f, 0.6f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.1250f, 0.1875f,
};
GLuint idx[] = { 0, 1, 2, 2, 3, 0 };
float x_i = 25.f;
float z_i = 25.f;
GLuint vbo = 0;
GLuint vao = 0;
GLuint vbo_id = 0;
GLuint render_points = 0;
//## Настройка текстурного буфера
//
void init_texture_buffer(void)
{
GLuint m_textureObj;
glGenTextures(1, &m_textureObj);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_textureObj);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width, image.height,
0, GL_RGBA, GL_UNSIGNED_BYTE, image.data);
// Установка опций отрисовки текстур
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
return;
}
//## Пересчет массива вершин по координатам центральной точки
//
void setup_quad(float x, float z)
{
points[0] = x - 0.45f; points[2] = z + 0.45f;
points[14] = x + 0.45f; points[16] = z + 0.45f;
points[28] = x + 0.45f; points[30] = z - 0.45f;
points[42] = x - 0.45f; points[44] = z - 0.45f;
return;
}
//## заполнение буфера данными
//
void fill_buffer()
{
size_t count = sizeof(points);
size_t position = 0;
size_t count_idx = sizeof(idx);
size_t pos_id = 0;
// обход от -_i до +_i
for (float z = 0.f - z_i; z < z_i; z += 1.0f)
for (float x = 0.f - x_i; x < x_i; x += 1.0f)
{
setup_quad(x, z);
glBufferSubData(GL_ARRAY_BUFFER, position, count, points);
position += count;
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, pos_id, count_idx, idx);
pos_id += count_idx;
for (auto i = 0; i < 6; ++i) idx[i] += 4;
render_points += 6;
}
return;
}
void start_application(void)
{
glClearColor(0.4f, 0.6f, 0.9f, 1.0f);
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
// Вычисление размера буфера
auto digits =
static_cast<size_t>(x_i) * 2 *
static_cast<size_t>(z_i) * 2 *
56 * sizeof(float);
// Выделить память под буфер атрибутов
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, digits, 0, GL_STATIC_DRAW);
// Выделить память под индексный буфер
glGenBuffers(1, &vbo_id);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo_id);
digits = static_cast<size_t>(x_i) * 2 *
static_cast<size_t>(z_i) * 2 * 6 * sizeof(float);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, digits, 0, GL_STATIC_DRAW);
// заполнить буфер данными
fill_buffer();
init_texture_buffer();
GLint posAttrib = glGetAttribLocation(shaderProgram, "pos3d");
GLint colAttrib = glGetAttribLocation(shaderProgram, "color");
GLint norAttrib = glGetAttribLocation(shaderProgram, "normal");
GLint texAttrib = glGetAttribLocation(shaderProgram, "tex2d");
glEnableVertexAttribArray(posAttrib);
glEnableVertexAttribArray(colAttrib);
glEnableVertexAttribArray(norAttrib);
glEnableVertexAttribArray(texAttrib);
glVertexAttribPointer(posAttrib, 4, GL_FLOAT, GL_FALSE,
14 * sizeof(GLfloat), 0);
glVertexAttribPointer(colAttrib, 4, GL_FLOAT, GL_FALSE,
14 * sizeof(GLfloat), (void*)(4 * sizeof(GLfloat)));
glVertexAttribPointer(norAttrib, 4, GL_FLOAT, GL_FALSE,
14 * sizeof(GLfloat), (void*)(8 * sizeof(GLfloat)));
glVertexAttribPointer(texAttrib, 2, GL_FLOAT, GL_FALSE,
14 * sizeof(GLfloat), (void*)(12 * sizeof(GLfloat)));
glm::vec3 vecUp = {0.0f, 1.0f, 0.0f};
glm::mat4 view = glm::lookAt(
glm::vec3(0.0f, 2.0f, 0.0f),glm::vec3(0.0f, 1.6f, 1.0f), vecUp
);
glm::mat4 proj = glm::perspective(glm::radians(64.0f), 800.0f / 600.0f, 0.1f, 5000.0f);
GLint uniMvp = glGetUniformLocation(shaderProgram, "mvp");
//----------------------------------------------------------------------------
glDisable(GL_CULL_FACE);
glm::mat4 model = {};
int fps = 0;
float time = 0.f, dTime = 0.f;
auto t_start = std::chrono::high_resolution_clock::now();
auto t_now = std::chrono::high_resolution_clock::now();
std::string win_title = "FPS: ";
while (!glfwWindowShouldClose(pWin))
{
t_now = std::chrono::high_resolution_clock::now();
dTime = std::chrono::duration_cast<std::chrono::duration<float>>
(t_now - t_start).count();
time += dTime; // для расчета FPS
t_start = t_now;
model = glm::rotate(model, 0.2f * dTime, vecUp);
glUniformMatrix4fv(uniMvp, 1, GL_FALSE, glm::value_ptr(proj * view * model));
glClear(GL_COLOR_BUFFER_BIT);
glDrawElements(GL_TRIANGLES, render_points, GL_UNSIGNED_INT, NULL);
//glDrawArrays(GL_TRIANGLES, 0, render_points);
glfwSwapBuffers(pWin);
glfwPollEvents();
++fps;
if (time >= 1.0f)
{
glfwSetWindowTitle(pWin, (win_title + std::to_string(fps)).c_str());
fps = 0;
time = 0.f;
}
}
glfwDestroyWindow(pWin);
return;
}
//###
int main()
{
try {
init_opengl_content();
start_application();
} catch(std::exception & e) {
std::cout << e.what() << '\n';;
return EXIT_FAILURE;
}
catch(...)
{
std::cout << "FAILURE: undefined exception.\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
| [
"balezin@yandex.ru"
] | balezin@yandex.ru |
da155cdcada82eceac1fa041a4ffff3f976cdf98 | 4c8ac4263cb05df2c7ba2abd2eacfd4640ad7ba1 | /CocosProject/Classes/TutorialScene.h | b348bc13826fe002a515ba8d5c7e94ae1ea25a22 | [] | no_license | rbkloss/GraxaSoftware | 44ad82641a9a2623b4e1e7ffa83da34eb6ce140d | c82cd421dff37435be4bd842af62d3c746b2defb | refs/heads/master | 2016-09-06T18:38:23.824006 | 2015-06-23T02:43:08 | 2015-06-23T02:43:08 | 34,749,703 | 3 | 1 | null | 2015-06-16T20:54:02 | 2015-04-28T18:55:49 | C++ | UTF-8 | C++ | false | false | 643 | h | #ifndef _TUTORIAl_SCENE_H_
#define _TUTORIAl_SCENE_H_
#include <memory>
#include "cocos2d.h"
#include "ui/CocosGUI.h"
class Hero;
class TutorialScene : public cocos2d::Layer {
int state_;
std::vector<std::string> texts_;
cocos2d::ui::Button* button_;
cocos2d::ui::Text* textLabel_;
public:
// Creates An auto-release scene object for the first stage
static cocos2d::Scene* createScene();
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init() override;
// implement the "static create()" method manually
CREATE_FUNC(TutorialScene);
};
#endif | [
"klossricardo@gmail.com"
] | klossricardo@gmail.com |
cf6cfc783068c63d03dbe5d3c3bd262543631632 | c1d39d3b0bcafbb48ba2514afbbbd6d94cb7ffe1 | /source/Pictus/dlg_cache.h | 9f03e84d3c976aa57a1fe614762fdc9f66e18012 | [
"MIT",
"libtiff",
"BSL-1.0",
"IJG",
"LicenseRef-scancode-warranty-disclaimer",
"Zlib",
"Libpng"
] | permissive | P4ll/Pictus | c6bb6fbc8014c7de5116380f48f8c1c4016a2c43 | 0e58285b89292d0b221ab4d09911ef439711cc59 | refs/heads/master | 2023-03-16T06:42:12.293939 | 2018-09-13T18:19:30 | 2018-09-13T18:19:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 678 | h | #ifndef DLG_CACHE_H
#define DLG_CACHE_H
#include "settings_page.h"
#include <wx/checkbox.h>
#include <wx/textctrl.h>
namespace App
{
class SetPageCache : public App::SettingsPage
{
public:
bool IsRootPage() const override;
std::string Caption() override;
SetPageCache(wxWindow* parent);
private:
void PerformUpdateFromSettings(const Reg::Settings &settings) override;
void onWriteSettings(Reg::Settings &settings) override;
void UpdateControls();
void OnAutoLimitChanged(wxCommandEvent& event);
enum {
AutoLimitId = wxID_HIGHEST + 1,
CacheSizeId
};
wxTextCtrl* m_cacheSize;
wxCheckBox* m_autoLimit;
DECLARE_EVENT_TABLE()
};
}
#endif
| [
"pontus@mardnas.se"
] | pontus@mardnas.se |
f4b20f9dfacfa0588d0b7783f8b9308249885b85 | b3c5f5fb77cae11339140d9e267816607a95151b | /src/util/random.cpp | 0ffba764654c539fcddfb36cf67999739c9f3ed2 | [] | no_license | imasuke/Geno | 39253034b913ab049baa511c10f078034446e13b | f7f017f09f4c7188889fb7b70ee67ffda1178905 | refs/heads/master | 2023-07-12T16:30:52.925138 | 2021-08-15T14:37:51 | 2021-08-15T14:37:51 | 391,097,967 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 736 | cpp | // random.cpp
#include "Geno/util/random.h"
namespace Geno{
Randomizer::Randomizer(){
init();
}
Randomizer::~Randomizer(){
delete mt;
}
void Randomizer::init(){
std::random_device rd;
mt = new std::mt19937(rd());
}
int Randomizer::randomInt(int min, int max){
std::uniform_int_distribution<int> gen(min, max);
return gen(*mt);
}
int Randomizer::randomInt(int max){
return randomInt(0, max);
}
double Randomizer::randomDouble(double min, double max){
std::uniform_real_distribution<double> gen(min, max);
return gen(*mt);
}
double Randomizer::randomDouble(double max){
return randomDouble(0.0, max);
}
bool Randomizer::randomBool(void){
return (randomDouble(1.0) > 0.5) ? true : false;
}
}
| [
"imasuke.cg.i312y@gmail.com"
] | imasuke.cg.i312y@gmail.com |
5a1de63104e30f455d49a4d7c98fdbdbbe6cc5b6 | d7f99d6073d4e3d6a9c08dda59448dc041d5663f | /138-copy list with random pointer.cpp | d13cbb7155315440d4e02eda42f018ac7af74e01 | [] | no_license | tangsancai/algorithm | 55ea70117dcf11e51771d662c17b46b8fa69bae3 | e09ddc4106b007aad0da23ee5bd263d2f8e34367 | refs/heads/master | 2021-04-29T04:19:40.747430 | 2017-01-04T14:27:46 | 2017-01-04T14:27:46 | 77,998,418 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 746 | cpp | #include<iostream>
#include<map>
using namespace std;
struct RandomListNode
{
int label;
RandomListNode *next, *random;
RandomListNode(int x) : label(x), next(NULL), random(NULL) {}
};
RandomListNode *copyRandomList(RandomListNode *head)
{
if(head==NULL)
return NULL;
map<RandomListNode* ,RandomListNode*> m;
RandomListNode *p=head;
RandomListNode *newlisthead=new RandomListNode(p->label);
RandomListNode *q2=newlisthead;
m[p]=newlisthead;
p=p->next;
while(p!=NULL)
{
RandomListNode *q=new RandomListNode(p->label);
m[p]=q;
q2->next=q;
q2=q;
p=p->next;
}
p=head;
q2=newlisthead;
while(p!=NULL)
{
q2->random=m[p->random];
p=p->next;
q2=q2->next;
}
return newlisthead;
} | [
"jiabinluo@yeah.net"
] | jiabinluo@yeah.net |
d46eb13181a676b7e01bdf368c9c797db40c206e | 635877894a1cf9a08fbd18c9c6979edbd84b5f66 | /ESP-sc-gway/_loraFiles.ino | d0854aee3240c0fe2ec0a5abdcc5dfbc3cc243ee | [
"MIT",
"LicenseRef-scancode-philippe-de-muyter"
] | permissive | markoceri/ESP-1ch-Gateway-v6.0 | 8b362fae26c8ee157d31be65c36f77aa485f5667 | e59a219ed7ca5a0496d577c5e81e5ac7a599ec31 | refs/heads/master | 2020-12-21T05:36:40.704827 | 2020-01-22T12:36:22 | 2020-01-22T12:36:22 | 236,325,596 | 0 | 0 | null | 2020-01-26T14:44:39 | 2020-01-26T14:44:38 | null | UTF-8 | C++ | false | false | 21,259 | ino | // 1-channel LoRa Gateway for ESP8266
// Copyright (c) 2016-2020 Maarten Westenberg version for ESP8266
//
// based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
// and many others.
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the MIT License
// which accompanies this distribution, and is available at
// https://opensource.org/licenses/mit-license.php
//
// NO WARRANTY OF ANY KIND IS PROVIDED
//
// Author: Maarten Westenberg (mw12554@hotmail.com)
//
// This file contains the LoRa filesystem specific code
#if _MONITOR>=1
// ----------------------------------------------------------------------------
// LoRa Monitor logging code.
// Define one print function and depending on the loggin parameter output
// to _USB of to the www screen function
// ----------------------------------------------------------------------------
int initMonitor(struct moniLine *monitor)
{
for (int i=0; i< _MAXMONITOR; i++) {
monitor[i].txt="";
}
return(1);
}
#endif //_MONITOR
// ============================================================================
// LORA SPIFFS FILESYSTEM FUNCTIONS
//
// The LoRa supporting functions are in the section below
// ----------------------------------------------------------------------------
// Supporting function to readConfig
// ----------------------------------------------------------------------------
void id_print (String id, String val)
{
#if _MONITOR>=1
if (( debug>=0 ) && ( pdebug & P_MAIN )) {
Serial.print(id);
Serial.print(F("=\t"));
Serial.println(val);
}
#endif //_MONITOR
}
// ----------------------------------------------------------------------------
// INITCONFIG; Init the gateway configuration file
// Espcecially when calling SPIFFS.format() the gateway is left in an init state
// which is not very well defined. This function will init some of the settings
// to well known settings.
// ----------------------------------------------------------------------------
int initConfig(struct espGwayConfig *c)
{
(*c).ch = 0;
(*c).sf = _SPREADING;
(*c).debug = 1; // debug level is 1
(*c).pdebug = P_GUI | P_MAIN;
(*c).cad = _CAD;
(*c).hop = false;
(*c).seen = true; // Seen interface is ON
(*c).expert = false; // Expert interface is OFF
(*c).monitor = true; // Monitoring is ON
(*c).trusted = 1;
(*c).txDelay = 0; // First Value without saving is 0;
}
// ----------------------------------------------------------------------------
// Read the config file and fill the (copied) variables
// ----------------------------------------------------------------------------
int readGwayCfg(const char *fn, struct espGwayConfig *c)
{
if (readConfig(fn, c)<0) {
# if _MONITOR>=1
mPrint("readConfig:: Error reading config file");
return 0;
# endif //_MONITOR
}
if (gwayConfig.sf != (uint8_t) 0) {
sf = (sf_t) gwayConfig.sf;
}
debug = (*c).debug;
pdebug = (*c).pdebug;
# if _GATEWAYNODE==1
if (gwayConfig.fcnt != (uint8_t) 0) {
frameCount = gwayConfig.fcnt+10;
}
# endif
return 1;
}
// ----------------------------------------------------------------------------
// Read the gateway configuration file
// ----------------------------------------------------------------------------
int readConfig(const char *fn, struct espGwayConfig *c)
{
int tries = 0;
if (!SPIFFS.exists(fn)) {
# if _MONITOR>=1
mPrint("readConfig ERR:: file="+String(fn)+" does not exist ..");
# endif //_MONITOR
initConfig(c); // If we cannot read the config, at least init known values
return(-1);
}
File f = SPIFFS.open(fn, "r");
if (!f) {
# if _MONITOR>=1
Serial.println(F("ERROR:: SPIFFS open failed"));
# endif //_MONITOR
return(-1);
}
while (f.available()) {
# if _MONITOR>=1
if (( debug>=0 ) && ( pdebug & P_MAIN )) {
Serial.print('.');
}
# endif //_MONITOR
// If we wait for more than 15 times, reformat the filesystem
// We do this so that the system will be responsive (over OTA for example).
//
if (tries >= 15) {
f.close();
# if _MONITOR>=1
if (debug>=0) {
mPrint("readConfig:: Formatting");
}
# endif //_MONITOR
SPIFFS.format();
f = SPIFFS.open(fn, "r");
tries = 0;
initSeen(listSeen);
}
initConfig(c); // Even if we do not read a value, give a default
String id =f.readStringUntil('='); // Read keyword until '=', C++ thing
String val=f.readStringUntil('\n'); // Read value until End of Line (EOL)
if (id == "MONITOR") { // MONITOR button setting
id_print(id, val);
(*c).monitor = (bool) val.toInt();
}
else if (id == "CH") { // Frequency Channel
id_print(id,val);
(*c).ch = (uint8_t) val.toInt();
}
else if (id == "SF") { // Spreading Factor
id_print(id, val);
(*c).sf = (uint8_t) val.toInt();
}
else if (id == "FCNT") { // Frame Counter
id_print(id, val);
(*c).fcnt = (uint16_t) val.toInt();
}
else if (id == "DEBUG") { // Debug Level
id_print(id, val);
(*c).debug = (uint8_t) val.toInt();
}
else if (id == "PDEBUG") { // pDebug Pattern
id_print(id, val);
(*c).pdebug = (uint8_t) val.toInt();
}
else if (id == "CAD") { // CAD setting
id_print(id, val);
(*c).cad = (bool) val.toInt();
}
else if (id == "HOP") { // HOP setting
id_print(id, val);
(*c).hop = (bool) val.toInt();
}
else if (id == "BOOTS") { // BOOTS setting
id_print(id, val);
(*c).boots = (uint16_t) val.toInt();
}
else if (id == "RESETS") { // RESET setting
id_print(id, val);
(*c).resets = (uint16_t) val.toInt();
}
else if (id == "WIFIS") { // WIFIS setting
id_print(id, val);
(*c).wifis = (uint16_t) val.toInt();
}
else if (id == "VIEWS") { // VIEWS setting
id_print(id, val);
(*c).views = (uint16_t) val.toInt();
}
else if (id == "NODE") { // NODE setting
id_print(id, val);
(*c).isNode = (bool) val.toInt();
}
else if (id == "REFR") { // REFR setting
id_print(id, val);
(*c).refresh = (bool) val.toInt();
}
else if (id == "REENTS") { // REENTS setting
id_print(id, val);
(*c).reents = (uint16_t) val.toInt();
}
else if (id == "NTPERR") { // NTPERR setting
id_print(id, val);
(*c).ntpErr = (uint16_t) val.toInt();
}
else if (id == "NTPETIM") { // NTPERR setting
id_print(id, val);
(*c).ntpErrTime = (uint32_t) val.toInt();
}
else if (id == "NTPS") { // NTPS setting
id_print(id, val);
(*c).ntps = (uint16_t) val.toInt();
}
else if (id == "FILENO") { // FILENO setting
id_print(id, val);
(*c).logFileNo = (uint16_t) val.toInt();
}
else if (id == "FILEREC") { // FILEREC setting
id_print(id, val);
(*c).logFileRec = (uint16_t) val.toInt();
}
else if (id == "FILENUM") { // FILEREC setting
id_print(id, val);
(*c).logFileNum = (uint16_t) val.toInt();
}
else if (id == "EXPERT") { // EXPERT button setting
id_print(id, val);
(*c).expert = (bool) val.toInt();
}
else if (id == "SEEN") { // SEEN button setting
id_print(id, val);
(*c).seen = (bool) val.toInt();
}
else if (id == "DELAY") { // DELAY setting
id_print(id, val);
(*c).txDelay = (int32_t) val.toInt();
}
else if (id == "TRUSTED") { // TRUSTED setting
id_print(id, val);
(*c).trusted= (int8_t) val.toInt();
}
else {
# if _MONITOR>=1
mPrint(F("readConfig:: tries++"));
# endif //_MONITOR
tries++;
}
}
f.close();
return(1);
}//readConfig
// ----------------------------------------------------------------------------
// Write the current gateway configuration to SPIFFS. First copy all the
// separate data items to the gwayConfig structure
//
// Note: gwayConfig.expert contains the expert setting already
// gwayConfig.txDelay
// ----------------------------------------------------------------------------
int writeGwayCfg(const char *fn, struct espGwayConfig *c)
{
(*c).sf = (uint8_t) sf; // Spreading Factor
(*c).debug = debug;
(*c).pdebug = pdebug;
# if _GATEWAYNODE==1
(*c).fcnt = frameCount;
# endif //_GATEWAYNODE
return(writeConfig(fn, c));
}
// ----------------------------------------------------------------------------
// Write the configuration as found in the espGwayConfig structure
// to SPIFFS
// Parameters:
// fn; Filename
// c; struct config
// Returns:
// 1 when successful, -1 on error
// ----------------------------------------------------------------------------
int writeConfig(const char *fn, struct espGwayConfig *c)
{
// Assuming the config file is the first we write...
File f = SPIFFS.open(fn, "w");
if (!f) {
#if _MONITOR>=1
mPrint("writeConfig: ERROR open file="+String(fn));
#endif //_MONITOR
return(-1);
}
f.print("CH"); f.print('='); f.print((*c).ch); f.print('\n');
f.print("SF"); f.print('='); f.print((*c).sf); f.print('\n');
f.print("FCNT"); f.print('='); f.print((*c).fcnt); f.print('\n');
f.print("DEBUG"); f.print('='); f.print((*c).debug); f.print('\n');
f.print("PDEBUG"); f.print('='); f.print((*c).pdebug); f.print('\n');
f.print("CAD"); f.print('='); f.print((*c).cad); f.print('\n');
f.print("HOP"); f.print('='); f.print((*c).hop); f.print('\n');
f.print("NODE"); f.print('='); f.print((*c).isNode); f.print('\n');
f.print("BOOTS"); f.print('='); f.print((*c).boots); f.print('\n');
f.print("RESETS"); f.print('='); f.print((*c).resets); f.print('\n');
f.print("WIFIS"); f.print('='); f.print((*c).wifis); f.print('\n');
f.print("VIEWS"); f.print('='); f.print((*c).views); f.print('\n');
f.print("REFR"); f.print('='); f.print((*c).refresh); f.print('\n');
f.print("REENTS"); f.print('='); f.print((*c).reents); f.print('\n');
f.print("NTPETIM"); f.print('='); f.print((*c).ntpErrTime); f.print('\n');
f.print("NTPERR"); f.print('='); f.print((*c).ntpErr); f.print('\n');
f.print("NTPS"); f.print('='); f.print((*c).ntps); f.print('\n');
f.print("FILEREC"); f.print('='); f.print((*c).logFileRec); f.print('\n');
f.print("FILENO"); f.print('='); f.print((*c).logFileNo); f.print('\n');
f.print("FILENUM"); f.print('='); f.print((*c).logFileNum); f.print('\n');
f.print("DELAY"); f.print('='); f.print((*c).txDelay); f.print('\n');
f.print("TRUSTED"); f.print('='); f.print((*c).trusted); f.print('\n');
f.print("EXPERT"); f.print('='); f.print((*c).expert); f.print('\n');
f.print("SEEN"); f.print('='); f.print((*c).seen); f.print('\n');
f.print("MONITOR"); f.print('='); f.print((*c).monitor); f.print('\n');
f.close();
return(1);
}
// ----------------------------------------------------------------------------
// Add a line with statistics to the log.
//
// We put the check in the function to protect against calling
// the function without _STAT_LOG being proper defined
// ToDo: Store the fileNo and the fileRec in the status file to save for
// restarts
//
// Parameters:
// line; char array with characters to write to log
// cnt;
// Returns:
// <none>
// ----------------------------------------------------------------------------
int addLog(const unsigned char * line, int cnt)
{
# if _STAT_LOG==1
char fn[16];
if (gwayConfig.logFileRec > LOGFILEREC) { // Have to make define for this
gwayConfig.logFileRec = 0; // In new logFile start with record 0
gwayConfig.logFileNo++; // Increase file ID
gwayConfig.logFileNum++; // Increase number of log files
}
gwayConfig.logFileRec++;
// If we have too many logfies, delete the oldest
//
if (gwayConfig.logFileNum > LOGFILEMAX){
sprintf(fn,"/log-%d", gwayConfig.logFileNo - LOGFILEMAX);
# if _MONITOR>=1
if (( debug>=2 ) && ( pdebug & P_GUI )) {
mPrint("addLog:: Too many logfiles, deleting="+String(fn));
}
# endif //_MONITOR
SPIFFS.remove(fn);
gwayConfig.logFileNum--;
}
// Make sure we have the right fileno
sprintf(fn,"/log-%d", gwayConfig.logFileNo);
// If there is no SPIFFS, Error
// Make sure to write the config record/line also
if (!SPIFFS.exists(fn)) {
# if _MONITOR>=1
if (( debug >= 2 ) && ( pdebug & P_GUI )) {
mPrint("addLog:: WARNING file="+String(fn)+" does not exist .. rec="+String(gwayConfig.logFileRec) );
}
# endif //_MONITOR
}
File f = SPIFFS.open(fn, "a");
if (!f) {
# if _MONITOR>=1
if (( debug>=1 ) && ( pdebug & P_GUI )) {
mPrint("addLOG:: ERROR file open failed="+String(fn));
}
# endif //_MONITOR
return(0); // If file open failed, return
}
int i;
#if _MONITOR>=1
if (( debug>=2 ) && ( pdebug & P_GUI )) {
Serial.print(F("addLog:: fileno="));
Serial.print(gwayConfig.logFileNo);
Serial.print(F(", rec="));
Serial.print(gwayConfig.logFileRec);
Serial.print(F(": "));
# if _DUSB>=2
for (i=0; i< 12; i++) { // The first 12 bytes contain non printable characters
Serial.print(line[i],HEX);
Serial.print(' ');
}
# else //_DUSB>=2
i+=12;
# endif //_DUSB>=2
Serial.print((char *) &line[i]); // The rest if the buffer contains ascii
Serial.println();
}
#endif //_MONITOR
for (i=0; i< 12; i++) { // The first 12 bytes contain non printable characters
// f.print(line[i],HEX);
f.print('*');
}
f.write(&(line[i]), cnt-12); // write/append the line to the file
f.print('\n');
f.close(); // Close the file after appending to it
# endif //_STAT_LOG
return(1);
} //addLog
// ----------------------------------------------------------------------------
// Print (all) logfiles
// Return:
// <none>
// Parameters:
// <none>
// ----------------------------------------------------------------------------
void printLog()
{
#if _STAT_LOG==1
char fn[16];
#if _DUSB>=1
for (int i=0; i< LOGFILEMAX; i++ ) {
sprintf(fn,"/log-%d", gwayConfig.logFileNo - i);
if (!SPIFFS.exists(fn)) break; // break the loop
// Open the file for reading
File f = SPIFFS.open(fn, "r");
int j;
for (j=0; j<LOGFILEREC; j++) {
String s=f.readStringUntil('\n');
if (s.length() == 0) break;
Serial.println(s.substring(12)); // Skip the first 12 Gateway specific binary characters
yield();
}
}
#endif //_DUSB
#endif //_STAT_LOG
} //printLog
#if _MAXSEEN >= 1
// ----------------------------------------------------------------------------
// initSeen
// Init the lisrScreen array
// Return:
// 1: Success
// Parameters:
// listSeen: array of Seen data
// ----------------------------------------------------------------------------
int initSeen(struct nodeSeen *listSeen)
{
for (int i=0; i< _MAXSEEN; i++) {
listSeen[i].idSeen=0;
listSeen[i].sfSeen=0;
listSeen[i].cntSeen=0;
listSeen[i].chnSeen=0;
listSeen[i].timSeen=(time_t) 0; // 1 jan 1970 0:00:00 hrs
}
iSeen= 0; // Init index to 0
return(1);
}
// ----------------------------------------------------------------------------
// readSeen
// This function read the information stored by writeSeen from the file.
// The file is read as String() values and converted to int after.
// Parameters:
// fn: Filename
// listSeen: Array of all last seen nodes on the LoRa network
// Return:
// 1: When successful
// ----------------------------------------------------------------------------
int readSeen(const char *fn, struct nodeSeen *listSeen)
{
int i;
iSeen= 0; // Init the index at 0
if (!SPIFFS.exists(fn)) { // Does listSeen file exist
# if _MONITOR>=1
mPrint("WARNING:: readSeen, history file not exists "+String(fn) );
# endif //_MONITOR
initSeen(listSeen); // XXX make all initial declarations here if config vars need to have a value
return(-1);
}
File f = SPIFFS.open(fn, "r");
if (!f) {
# if _MONITOR>=1
mPrint("readSeen:: ERROR open file=" + String(fn));
# endif //_MONITOR
return(-1);
}
delay(1000);
for (i=0; i<_MAXSEEN; i++) {
delay(200);
String val="";
if (!f.available()) {
# if _MONITOR>=1
String response="readSeen:: No more info left in file, i=";
response += i;
mPrint(response);
# endif //_MONITOR
break;
}
val=f.readStringUntil('\t'); listSeen[i].timSeen = (time_t) val.toInt();
val=f.readStringUntil('\t'); listSeen[i].idSeen = (int64_t) val.toInt();
val=f.readStringUntil('\t'); listSeen[i].cntSeen = (uint32_t) val.toInt();
val=f.readStringUntil('\t'); listSeen[i].chnSeen = (uint8_t) val.toInt();
val=f.readStringUntil('\n'); listSeen[i].sfSeen = (uint8_t) val.toInt();
# if _MONITOR>=1
if ((debug>=2) && (pdebug & P_MAIN)) {
mPrint("readSeen:: idSeen ="+String(listSeen[i].idSeen,HEX)+", i="+String(i));
}
# endif
iSeen++; // Increase index, new record read
}
f.close();
# if _MONITOR>=1
if ((debug >= 2) && (pdebug & P_MAIN)) {
Serial.print("readSeen:: ");
printSeen(listSeen);
}
# endif //_MONITOR
// So we read iSeen records
return 1;
}
// ----------------------------------------------------------------------------
// writeSeen
// Once every few messages, update the SPIFFS file and write the array.
// Parameters:
// - fn contains the filename to write
// - listSeen contains the _MAXSEEN array of list structures
// Return values:
// - return 1 on success
// ----------------------------------------------------------------------------
int writeSeen(const char *fn, struct nodeSeen *listSeen)
{
int i;
if (!SPIFFS.exists(fn)) {
# if _MONITOR>=1
mPrint("WARNING:: writeSeen, file not exists, initSeen");
# endif //_MONITOR
//initSeen(listSeen); // XXX make all initial declarations here if config vars need to have a value
}
File f = SPIFFS.open(fn, "w");
if (!f) {
# if _MONITOR>=1
mPrint("writeConfig:: ERROR open file="+String(fn));
# endif //_MONITOR
return(-1);
}
delay(500);
for (i=0; i<iSeen; i++) { // For all records indexed
f.print((time_t)listSeen[i].timSeen); f.print('\t');
f.print((int32_t)listSeen[i].idSeen); f.print('\t'); // Typecast to avoid errors in unsigned conversion!
f.print((uint32_t)listSeen[i].cntSeen); f.print('\t');
f.print((uint8_t)listSeen[i].chnSeen); f.print('\t');
f.print((uint8_t)listSeen[i].sfSeen); f.print('\n');
}
f.close();
# if _DUSB>=1
if ((debug >= 2) && (pdebug & P_MAIN)) {
Serial.print("writeSeen:: ");
printSeen(listSeen);
}
# endif //_DUSB
return(1);
}
// ----------------------------------------------------------------------------
// printSeen
// - This function writes the last seen array to the USB !!
// ----------------------------------------------------------------------------
int printSeen(struct nodeSeen *listSeen) {
# if _DUSB>=1
int i;
if (( debug>=2 ) && ( pdebug & P_MAIN )) {
Serial.println(F("printSeen:: "));
for (i=0; i<iSeen; i++) {
if (listSeen[i].idSeen != 0) {
String response;
response = i;
response += ", Tim=";
stringTime(listSeen[i].timSeen, response);
response += ", addr=0x";
printHex(listSeen[i].idSeen,' ', response);
response += ", SF=0x";
response += listSeen[i].sfSeen;
Serial.println(response);
}
}
}
# endif //_DUSB
return(1);
}
// ----------------------------------------------------------------------------
// addSeen
// With every message received:
// - Look whether message is already in the array, if so update existing message.
// - If not, create new record.
// - With this record, update the SF settings
//
// Parameters:
// listSeen: The array of records of nodes we have seen
// stat: one record
// Returns:
// 1 when successful
// ----------------------------------------------------------------------------
int addSeen(struct nodeSeen *listSeen, struct stat_t stat)
{
int i=0;
for (i=0; i<iSeen; i++) { // For all known records
if (listSeen[i].idSeen==stat.node) {
listSeen[i].timSeen = (time_t)stat.tmst;
listSeen[i].cntSeen++; // Not included on function para
listSeen[i].idSeen = stat.node;
listSeen[i].chnSeen = stat.ch;
listSeen[i].sfSeen |= stat.sf; // Or the argument
writeSeen(_SEENFILE, listSeen);
return 1;
}
}
// Else: We did not find the current record so make a new Seen entry
if ((i>=iSeen) && (i<_MAXSEEN)) {
listSeen[i].idSeen = stat.node;
listSeen[i].chnSeen = stat.ch;
listSeen[i].sfSeen = stat.sf; // Or the argument
listSeen[i].timSeen = (time_t)stat.tmst;
listSeen[i].cntSeen = 1; // Not included on function para
iSeen++;
//return(1);
}
# if _MONITOR>=2
if ((debug>=1) && (pdebug & P_MAIN)) {
String response= "addSeen:: New i=";
response += i;
response += ", tim=";
stringTime(stat.tmst, response);
response += ", iSeen=";
response += String(iSeen,HEX);
response += ", node=";
response += String(stat.node,HEX);
response += ", listSeen[0]=";
printHex(listSeen[0].idSeen,' ',response);
Serial.print("<"); Serial.print(listSeen[0].idSeen, HEX); Serial.print(">");
mPrint(response);
response += ", listSeen[0]=";
printHex(listSeen[0].idSeen,' ',response);
mPrint(response);
}
# endif
// USB Only
# if _DUSB>=2
if ((debug>=2) && (pdebug & P_MAIN)) {
Serial.print("addSeen i=");
Serial.print(i);
Serial.print(", id=");
Serial.print(listSeen[i].idSeen,HEX);
Serial.println();
}
# endif // _DUSB
return 1;
}
#endif //_MAXSEEN>=1 End of File
| [
"mw12554@hotmail.com"
] | mw12554@hotmail.com |
55c82c0a4a0bb06b98058c2e7a4e1593b14c24cb | 0fdb72063e4fe31fec88d2f9917620c3aa31cf56 | /src/file.cc | 45dbfa3a1ef55a0b5a36ad580f1f0415d69321d2 | [] | no_license | bndbsh/stormpp | 4b33bebd41fc9efba1cd38570069c0ec74f579ab | 3db297ee2471019d4941e971d0ebf312c83a551d | refs/heads/master | 2021-05-27T06:53:42.095854 | 2010-06-28T17:46:19 | 2010-06-28T17:46:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,844 | cc | #include "file.hh"
#include "archive.hh"
#include <iostream>
#include <StormLib.h>
namespace storm {
File::File() : mode(Invalid), ioMode(Closed), open(false) {
}
File::File(const File& file) {
mode = file.mode;
ioMode = file.ioMode;
archive = file.archive;
filename = file.filename;
fileHandle = file.fileHandle;
open = file.open;
}
File::File(const std::string& filename, ArchiveHandle archive) : mode(MPQ), ioMode(Closed), archive(archive), filename(filename), open(false) {
}
File::File(const std::string& filename) : mode(Disk), ioMode(Closed), filename(filename), open(false) {
}
File::~File() {
close();
}
File& File::operator=(const File& file) {
if (mode == MPQ) {
} else if (mode == Invalid) {
mode = file.mode;
ioMode = file.ioMode;
archive = file.archive;
filename = file.filename;
fileHandle = file.fileHandle;
open = file.open;
}
return *this;
}
// bool WINAPI SFileWriteFile(
// HANDLE hFile, // Handle to the file
// const void * pvData, // Pointer to data to be written
// DWORD dwSize, // Size of the data pointed by pvData
// DWORD dwCompression // Specifies compression of the data block
// );
unsigned int File::write(const char* data, unsigned int count) throw(InvalidOperation, MPQError) {
if (mode == Invalid) throw InvalidOperation("Cannot write to an invalid file.");
if (ioMode == Read) throw InvalidOperation("Cannot write to a read-mode file.");
if (!SFileWriteFile(fileHandle, data, count, MPQ_COMPRESSION_ZLIB)) throw MPQError("Error while writing to file.");
return 0;
}
unsigned int File::read(char* data, unsigned int count) throw(InvalidOperation, MPQError) {
if (mode == Invalid) throw InvalidOperation("Cannot read from an invalid file.");
if (ioMode == Write) throw InvalidOperation("Cannot read from a write-mode file.");
if (mode == MPQ) {
HANDLE mpqHandle = archive->getHandle();
if (mpqHandle == 0) throw InvalidOperation("Invalid MPQ handle. Was the archive closed prematurely?");
unsigned int actualCount = 0;
if (!SFileReadFile(fileHandle, data, count, &actualCount, 0)) {
throw MPQError("Error while reading from file " + filename);
}
return actualCount;
}
return 0;
}
File& File::openRead() throw (InvalidOperation, MPQError, FileNotFound) {
if (mode == Invalid) throw InvalidOperation("Cannot open an invalid file.");
if (mode == MPQ) {
if (ioMode != Closed) throw InvalidOperation("Cannot open a file that is already open.");
HANDLE mpqHandle = archive->getHandle();
if (mpqHandle == 0) throw InvalidOperation("Invalid MPQ handle. Was the archive closed prematurely?");
if (!SFileOpenFileEx(mpqHandle, filename.c_str(), 0, &fileHandle)) throw MPQError("Error opening file for reading: " + filename);
open = true;
ioMode = Read;
} else throw InvalidOperation("Opening Disk files is not yet implemented.");
return *this;
}
// bool WINAPI SFileCreateFile(
// HANDLE hMpq, // Handle to the MPQ
// const char * szArchivedName, // The name under which the file will be stored
// TMPQFileTime * pFT // Specifies the date and file time
// DWORD dwFileSize // Specifies the size of the file
// LCID lcLocale // Specifies the file locale
// DWORD dwFlags // Specifies archive flags for the file
// HANDLE * phFile // Returned file handle
// );
File& File::openWrite(unsigned int fileSize) throw (InvalidOperation, MPQError) {
if (mode == Invalid) throw InvalidOperation("Cannot open an invalid file.");
if (mode == Disk) throw InvalidOperation("Not yet implemented.");
if (mode == MPQ) {
if (ioMode != Closed) throw InvalidOperation("Cannot open a file that is already open.");
HANDLE mpqHandle = archive->getHandle();
if (mpqHandle == 0) throw InvalidOperation("Invalid MPQ handle. Was the archive closed prematurely?");
if (!SFileCreateFile(mpqHandle, filename.c_str(), 0, fileSize, 0, 0, &fileHandle)) throw MPQError("Error opening file for writing: " + filename);
open = true;
ioMode = Write;
}
return *this;
}
void File::close() {
if (open) {
if (mode == MPQ) {
if (ioMode == Read) {
HANDLE mpqHandle = archive->getHandle();
if (mpqHandle == 0) throw InvalidOperation("Invalid MPQ handle. Was the archive closed prematurely?");
SFileCloseFile(fileHandle);
} else if (ioMode == Write) {
if (!SFileFinishFile(fileHandle)) {
if (GetLastError() == ERROR_CAN_NOT_COMPLETE) throw MPQError("Amount of bytes written to file exceeds size declared in call to openWrite.");
else throw MPQError("Error finalizing file.");
}
}
}
else throw InvalidOperation("File operations not yet implemented for Disk");
}
}
bool File::isOpen() const {
return open;
}
}
| [
"amro256@gmail.com"
] | amro256@gmail.com |
a6d664d2e1e5e34111dda3833dfc500afc9a2f84 | cde13cbd8341c3820c5ac46ef763036a31d028d6 | /11.27/guangliangda02.cpp | 6aadb6830db80757953bfd920adeb67c14b4063c | [] | no_license | Gongyihang/cpp | 11d6b4d2cd2a2592e2ea09ff0c062651bd188ad5 | e3d8314f2de064d03f8536ce7f85e098ed1e0ffc | refs/heads/master | 2023-01-31T19:31:12.028787 | 2020-12-17T01:59:11 | 2020-12-17T01:59:11 | 256,767,005 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 775 | cpp | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
vector<ll> v(4, 0);
bool func(ll x)
{
ll p = 0, q = 0;
for (auto num : v) {
if (num - x >= 0) {
p += num - x;
} else {
q += num - x;
}
}
return p + 2 * q >= 0;
}
int main()
{
while(cin >> v[0] >> v[1] >> v[2] >> v[3]){
ll r = v[0] + v[1] + v[2] + v[3];
ll l = 0;
while (l < r) {
ll m = l + (r - l) / 2;
if (func(m)) {
l = m + 1;
} else {
r = m;
}
}
cout << 4 * (l - 1) << endl;
}
return 0;
} | [
"474356284@qq.com"
] | 474356284@qq.com |
e8c96592428a4e0529954457800ed19fc240fc86 | 3fee62a27cffa0853e019a3352ac4fc0e0496a3d | /zCleanupCamSpace/ZenGin/Gothic_II_Addon/API/zGameInfo.h | 140885c49cb641f873101d65bdc2851238bb9076 | [] | no_license | Gratt-5r2/zCleanupCamSpace | f4efcafe95e8a19744347ac40b5b721ddbd73227 | 77daffabac84c8e8bc45e0d7bcd7289520766068 | refs/heads/master | 2023-08-20T15:22:49.382145 | 2021-10-30T12:27:17 | 2021-10-30T12:27:17 | 422,874,598 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,043 | h | // Supported with union (c) 2018-2021 Union team
#ifndef __ZGAME_INFO_H__VER3__
#define __ZGAME_INFO_H__VER3__
#include "zBuffer.h"
#include "zVob.h"
#include "zNet_Win32.h"
namespace Gothic_II_Addon {
const int zMAX_PLAYER = 20;
const int zPCK_GAMEINFO_INFO = 1;
const int zPCK_GAMEINFO_PLAYER = 2;
const int zPCK_GAMEINFO_ALL = 255;
// sizeof 18h
class zCGameInfo {
public:
zSTRING name; // sizeof 14h offset 04h
void zCGameInfo_OnInit() zCall( 0x0044FE20 );
zCGameInfo() zInit( zCGameInfo_OnInit() );
void PackToBuffer( zCBuffer&, unsigned char ) zCall( 0x00450070 );
int GetNumPlayers() zCall( 0x004500A0 );
static zCGameInfo* CreateFromBuffer( zCBuffer& ) zCall( 0x00450080 );
virtual ~zCGameInfo() zCall( 0x0044FF90 );
virtual void Init() zCall( 0x0044FFE0 );
virtual void Reset() zCall( 0x0044FFF0 );
virtual void SetName( zSTRING const& ) zCall( 0x00423E50 );
virtual zSTRING GetName() const zCall( 0x00423F90 );
virtual int AddPlayer( zCPlayerInfo* ) zCall( 0x00450000 );
virtual int RemPlayer( zCPlayerInfo* ) zCall( 0x00450010 );
virtual zCPlayerInfo* GetPlayerByID( int ) zCall( 0x00450020 );
virtual zCPlayerInfo* GetPlayerByVobID( unsigned long ) zCall( 0x00450030 );
virtual zCPlayerInfo* GetPlayerByNetAddress( zTNetAddress& ) zCall( 0x00450350 );
virtual void Pack( zCBuffer&, unsigned char ) zCall( 0x004500C0 );
virtual void Unpack( zCBuffer& ) zCall( 0x00450160 );
// user API
#include "zCGameInfo.inl"
};
} // namespace Gothic_II_Addon
#endif // __ZGAME_INFO_H__VER3__ | [
"amax96@yandex.ru"
] | amax96@yandex.ru |
2e97d7116a5b59348c3a996ddcb30028e1aa23f2 | fc3cb4f2d5afe9b7093a3c6f9f1cd95211ccf7b8 | /L03S05.AddFunction2Header/addfunction2.cpp | 4cbcab86f0f5de3749271679af00adc5bad604c9 | [] | no_license | CPSC-2377-UALR/CPSC.2377.Code.Examples | a8967a9aac7feac1a73b0f625f590959f3323c25 | 80318fe1e395c8e4eb8cfe032b4607260c2988f7 | refs/heads/master | 2022-02-19T04:25:46.417542 | 2019-09-11T17:50:10 | 2019-09-11T17:50:10 | 127,178,682 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 374 | cpp | /*
* File: addfunction2.cpp
* Author: Keith Bush (2013)
*/
#include<iostream>
#include "functions.h"
using namespace std;
int main(){
int sum=0, n1=0, n2=0;
while( !(sum==7 || sum==11) ){
cout << "Enter two numbers on the range [0,6]: ";
cin >> n1 >> n2;
sum = addTwoNumbers(n1%7,n2%7);
}
cout << "Craps!" << endl;
system("PAUSE");
return 0;
}
| [
"smorme@ualr.edu"
] | smorme@ualr.edu |
74a690fffc808c3429a97feede6dbb11e3deda0c | 0f054d3440d94f27bc61c2b69c46d250fd1400a8 | /cppp/CPlusPlusAdvanced/06_Evald/CodeFromOthers/registry_tal_yiftach/conf.h | fcc068544153f1479599ba73ae75610235a80e8e | [] | no_license | Tomerder/Cpp | db73f34e58ff36e145af619f03c2f4d19d44dc5d | 18bfef5a571a74ea44e480bd085b4b789839f90d | refs/heads/master | 2020-04-13T21:37:06.400580 | 2018-12-29T02:35:50 | 2018-12-29T02:35:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,908 | h | /*************************************************
Author: Yiftach Ariel
Creation date : 9.12.13
Last modified date: 10.12.13
Description : conf h-file.
CONF_VAL is a macro to load a value from configuration file.
1'st parameter is the type of the variable.
2'nd parameter is the name of the variable.
3'rd parameter is the default value of the variable, and is used in case that the value isn't found in the configuration file.
4'th parameter is boolean that tell if we want to save the def_value in the configuration file in case it doesn't exist there.
Usage: To load a value named VAL then put in the h-file CONF_VAL(int, VAL, 5);
If VAL doesn't exist in the configuration file then it will get the value '5', the default value.
Supported types: int, string
**************************************************/
#ifndef __CONF_H__
#define __CONF_H__
#ifndef KEY_PATH
#define KEY_PATH "Software\\Experis"
#endif
#define CONF_VAL(TYPE, NAME, DEF_VALUE, SAVE) static const TYPE NAME = m7::ReadVal<TYPE>(#NAME, DEF_VALUE, SAVE)
//=================================================================================================
namespace m7
{
template <class T>
T ReadVal(const std::string& _valName, T _defVal, bool _shouldSaveDefVal);
// Decleration of ReadVal function
template <>
int ReadVal<int>(const std::string& _valName, int _defVal, bool _shouldSaveDefVal);
template <>
std::string ReadVal<std::string>(const std::string& _valName, std::string _defVal, bool _shouldSaveDefVal);
//=================================================================================================
template <class T>
T ReadVal<T>(const std::string& _valName, T _defVal, bool _shouldSaveDefVal)
{
ThereIsNoSupport x1; // If you got a compilation error here that's because you've tried to declare an object with no support
}
} // namespace m7
#endif // #define __CONF_H__ | [
"tomerder@gmail.com"
] | tomerder@gmail.com |
da2542d8ca92358502af90256debbd8f67eb2634 | 19a8bdb4fac11ea31b8b4f642d209e0a9f075d1b | /coder/visual studio 2017/oop/bt li thuyet/sinh vien/sinh vien/QuanLi.cpp | a7f56ccef70ca9e1ae0bff0ce59fba7d23ac19b3 | [] | no_license | HuyKhoi-code/C- | 049727c5ba792a9e24f945522f8e2aaed7360650 | 57ea096681fc8db7470445f46c317c325900e9cb | refs/heads/master | 2023-06-02T03:11:03.793539 | 2021-06-17T07:50:22 | 2021-06-17T07:50:22 | 377,746,797 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,139 | cpp | #include"QuanLi.h"
#include"CaoDang.h"
#include"DaiHoc.h"
#include"SinhVien.h"
QuanLiSV::QuanLiSV() {
a = new SinhVien*[SoLuong];
}
QuanLiSV::~QuanLiSV(){}
void QuanLiSV::nhap() {
int t;
cout << "nhap so luong sinh vien: ";
cin >> SoLuong;
cout << "1-Sinh vien dai hoc/ 2-Sinh vien cao dang";
for (int i = 0; i < SoLuong; i++) {
cin >> t;
if (t == 1) {
a[i] = new DaiHoc;
}
if (t == 2)
a[i] = new CaoDang;
a[i]->nhap();
}
}
void QuanLiSV::xuat() {
for (int i = 0; i < SoLuong; i++)
a[i]->xuat();
}
void QuanLiSV::SoSVTotNghiep() {
int dem = 0;
for (int i = 0; i < SoLuong; i++) {
if (a[i]->Totnghiep() == true)
dem++;
}
cout << "\n---------------------------------------";
cout << "\nso sinh vien tot nghiep: " << dem;
}
void QuanLiSV::DiemTBCaoNhat() {
float max = a[0]->DiemTB();
for (int i = 0; i < SoLuong; i++) {
if (a[i]->DiemTB() && a[i]->SVDaiHoc() == true)
max = a[i]->DiemTB();
}
for (int i = 0; i < SoLuong; i++) {
if (a[i]->DiemTB() == max) {
cout << "\n-------------------------------------";
cout << "\nsinh vien co diem trung binh cao nhat: ";
a[i]->xuat();
}
}
}
| [
"18520949@gm.uit.edu.vn.com"
] | 18520949@gm.uit.edu.vn.com |
74788a5fe8f8d8581b8a69e37ead3da83fde97a8 | 4ba0b403637e7aa3e18c9bafae32034e3c394fe4 | /cplusplus/sage/compile/builtins.cc | ec1f0ab44ee9f0632cc16881fa7f734afa0018f0 | [] | no_license | ASMlover/study | 3767868ddae63ac996e91b73700d40595dd1450f | 1331c8861fcefbef2813a2bdd1ee09c1f1ee46d6 | refs/heads/master | 2023-09-06T06:45:45.596981 | 2023-09-01T08:19:49 | 2023-09-01T08:19:49 | 7,519,677 | 23 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 1,838 | cc | // Copyright (c) 2019 ASMlover. 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 ofconditions 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 materialsprovided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT 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 <chrono>
#include "builtins.hh"
namespace sage {
Value NatClock::call(
const InterpreterPtr& interp, const std::vector<Value>& arguments) {
// return seconds of now
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch()).count() / 1000.0;
}
std::size_t NatClock::arity(void) const {
return 0;
}
std::string NatClock::to_string(void) const {
return "<native fn: `clock`>";
}
}
| [
"asmlover@126.com"
] | asmlover@126.com |
6b6a75b90dfda3c5348d1a100d5290c578a2b10d | bf007dec921b84d205bffd2527e376bb60424f4c | /Codeforces_Submissions/664A.cpp | c7cce94030e56893280bc2f1724c6b7618753aaf | [] | no_license | Suvrojyoti/APS-2020 | 257e4a94f52f5fe8adcac1ba4038cc66e81d9d26 | d4de0ef098e7ce9bb40036ef55616fa1f159f7a5 | refs/heads/master | 2020-12-21T19:27:59.955338 | 2020-04-22T13:27:49 | 2020-04-22T13:27:49 | 236,534,218 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 371 | cpp | #include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input1.txt", "r", stdin);
// for writing output to output.txt
freopen("output1.txt", "w", stdout);
#endif
string a,b;
cin>>a>>b;
if(a==b)
cout<<a;
else
cout<<1;
return 0;
} | [
"suvrojyoti.mandal@theatom.app"
] | suvrojyoti.mandal@theatom.app |
1068cf2b37284c4f6ee63aba24564bc6027adc8c | 5c4d0acf680da3a0c2f9a58923d3d9a91f2ea84c | /JustATempProject/JustATempProject/Player.cpp | 248e58268d90dbe258c0fe4c0fe9f3c072d440bd | [] | no_license | ARAMODODRAGON/JustATempProject | 8a620dc7ad674c59166229285cf9541a8936a9d7 | 4cbf57a7b70bdc8b3c564c2b35cff26194301e3c | refs/heads/master | 2020-08-29T22:34:16.693694 | 2019-10-29T03:54:45 | 2019-10-29T03:54:45 | 218,191,015 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 629 | cpp | #include "Player.h"
#include <stdio.h>
#include "Parts.h"
#include "Transform.h"
Player::Player(std::string name) : GameObject(name), box(nullptr), rb(nullptr), timer(0.0f) {}
int Player::Init() {
rb = CreatePart<RigidBody>();
box = CreatePart<Box>();
rb->acceleration.Y = -9.8f;
return GameObject::Init();
}
int Player::Exit() {
return GameObject::Exit();
}
void Player::Update(const float delta) {
GameObject::Update(delta);
timer += delta;
if(timer > 0.2f) {
timer -= 0.2f;
Vector3 pos = GetTransform()->position;
printf("[Player pos]: {%f, %f, %f}\n", pos.X, pos.Y, pos.Z);
}
}
void Player::Render() {}
| [
"domara2000@gmail.com"
] | domara2000@gmail.com |
cbfc2483b153d6027e01dd87f806be834c79aa00 | b97c163e22163b9b27c9276ea2ba43d91a8982b3 | /src/qt/peertablemodel.cpp | 8e979ae5223f7a7715e0763b349cb71a77490677 | [
"MIT"
] | permissive | Olliecad1/CLEO-Global | 956c259fc6318049a444cfdd36923a682f924c46 | 2629afb1a3dfacec499b7a3e6b326c5d923cfea9 | refs/heads/master | 2020-05-04T13:14:55.691925 | 2019-07-10T18:23:53 | 2019-07-10T18:23:53 | 179,152,891 | 2 | 2 | MIT | 2019-06-07T18:05:33 | 2019-04-02T20:23:17 | C | UTF-8 | C++ | false | false | 6,367 | cpp | // Copyright (c) 2011-2013 The Bitcoin Core developers
// Copyright (c) 2018 The Denarius Developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "peertablemodel.h"
#include "clientmodel.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "net.h"
#include "sync.h"
#include <QDebug>
#include <QList>
#include <QTimer>
bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const
{
const CNodeStats *pLeft = &(left.nodeStats);
const CNodeStats *pRight = &(right.nodeStats);
if (order == Qt::DescendingOrder)
std::swap(pLeft, pRight);
switch(column)
{
case PeerTableModel::Address:
return pLeft->addrName.compare(pRight->addrName) < 0;
case PeerTableModel::Subversion:
return pLeft->strSubVer.compare(pRight->strSubVer) < 0;
case PeerTableModel::Ping:
return pLeft->dPingTime < pRight->dPingTime;
}
return false;
}
// private implementation
class PeerTablePriv
{
public:
/** Local cache of peer information */
QList<CNodeCombinedStats> cachedNodeStats;
/** Column to sort nodes by */
int sortColumn;
/** Order (ascending or descending) to sort nodes by */
Qt::SortOrder sortOrder;
/** Index of rows by node ID */
std::map<NodeId, int> mapNodeRows;
/** Pull a full list of peers from vNodes into our cache */
void refreshPeers()
{
{
TRY_LOCK(cs_vNodes, lockNodes);
if (!lockNodes)
{
// skip the refresh if we can't immediately get the lock
return;
}
cachedNodeStats.clear();
#if QT_VERSION >= 0x040700
cachedNodeStats.reserve(vNodes.size());
#endif
BOOST_FOREACH(CNode* pnode, vNodes)
{
CNodeCombinedStats stats;
stats.nodeStateStats.nMisbehavior = 0;
stats.nodeStateStats.nSyncHeight = -1;
stats.fNodeStateStatsAvailable = false;
pnode->copyStats(stats.nodeStats);
cachedNodeStats.append(stats);
}
}
// Try to retrieve the CNodeStateStats for each node.
{
TRY_LOCK(cs_main, lockMain);
if (lockMain)
{
BOOST_FOREACH(CNodeCombinedStats &stats, cachedNodeStats)
stats.fNodeStateStatsAvailable = GetNodeStateStats(stats.nodeStats.nodeid, stats.nodeStateStats);
}
}
if (sortColumn >= 0)
// sort cacheNodeStats (use stable sort to prevent rows jumping around unneceesarily)
qStableSort(cachedNodeStats.begin(), cachedNodeStats.end(), NodeLessThan(sortColumn, sortOrder));
// build index map
mapNodeRows.clear();
int row = 0;
BOOST_FOREACH(CNodeCombinedStats &stats, cachedNodeStats)
mapNodeRows.insert(std::pair<NodeId, int>(stats.nodeStats.nodeid, row++));
}
int size()
{
return cachedNodeStats.size();
}
CNodeCombinedStats *index(int idx)
{
if(idx >= 0 && idx < cachedNodeStats.size()) {
return &cachedNodeStats[idx];
} else {
return 0;
}
}
};
PeerTableModel::PeerTableModel(ClientModel *parent) :
QAbstractTableModel(parent),
clientModel(parent),
timer(5)
{
columns << tr("Address/Hostname") << tr("User Agent") << tr("Ping Time");
priv = new PeerTablePriv();
// default to unsorted
priv->sortColumn = -1;
// set up timer for auto refresh
timer = new QTimer();
connect(timer, SIGNAL(timeout()), SLOT(refresh()));
timer->start(5000); //Just auto refresh every 5 secs by itself without waiting for rpcconsole
// load initial data
refresh();
}
void PeerTableModel::startAutoRefresh()
{
timer->start();
}
void PeerTableModel::stopAutoRefresh()
{
timer->stop();
}
int PeerTableModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return priv->size();
}
int PeerTableModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return columns.length();;
}
QVariant PeerTableModel::data(const QModelIndex &index, int role) const
{
if(!index.isValid())
return QVariant();
CNodeCombinedStats *rec = static_cast<CNodeCombinedStats*>(index.internalPointer());
if (role == Qt::DisplayRole) {
switch(index.column())
{
case Address:
return QString::fromStdString(rec->nodeStats.addrName);
case Subversion:
return QString::fromStdString(rec->nodeStats.strSubVer);
case Ping:
return GUIUtil::formatPingTime(rec->nodeStats.dPingTime);
}
} else if (role == Qt::TextAlignmentRole) {
if (index.column() == Ping)
return (int)(Qt::AlignRight | Qt::AlignVCenter);
}
return QVariant();
}
QVariant PeerTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(orientation == Qt::Horizontal)
{
if(role == Qt::DisplayRole && section < columns.size())
{
return columns[section];
}
}
return QVariant();
}
Qt::ItemFlags PeerTableModel::flags(const QModelIndex &index) const
{
if(!index.isValid())
return 0;
Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
return retval;
}
QModelIndex PeerTableModel::index(int row, int column, const QModelIndex &parent) const
{
Q_UNUSED(parent);
CNodeCombinedStats *data = priv->index(row);
if (data)
{
return createIndex(row, column, data);
}
else
{
return QModelIndex();
}
}
const CNodeCombinedStats *PeerTableModel::getNodeStats(int idx)
{
return priv->index(idx);
}
void PeerTableModel::refresh()
{
emit layoutAboutToBeChanged();
priv->refreshPeers();
emit layoutChanged();
}
int PeerTableModel::getRowByNodeId(NodeId nodeid)
{
std::map<NodeId, int>::iterator it = priv->mapNodeRows.find(nodeid);
if (it == priv->mapNodeRows.end())
return -1;
return it->second;
}
void PeerTableModel::sort(int column, Qt::SortOrder order)
{
priv->sortColumn = column;
priv->sortOrder = order;
refresh();
}
| [
"officialgamermorris@gmail.com"
] | officialgamermorris@gmail.com |
24c97e9ffd81b0f4fad1628c405077223d28bf00 | 3642077326d9776d53b7a4e9e0cbebbea9c230e2 | /Advanced Game Programming/Advanced Game Programming/Source/ContactListener.cpp | 99326539476fec5bcd88895e55037e588ee12788 | [] | no_license | Nokondi/GameProgrammingSample | 40e8105edf0710f7e99395e7b04d81f1f4a319dc | 4b271df67ed8012d9cd18fa53dc7199588202d64 | refs/heads/master | 2021-05-15T02:52:49.155011 | 2020-03-26T20:52:06 | 2020-03-26T20:52:06 | 250,368,250 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,200 | cpp | #include "ContactListener.h"
#include "Object.h"
#include "Components.h"
#include "Library.h"
#include "BodyComponent.h"
void ContactListener::PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
{
//Grab the two Physics Bodies involved in the Contact
b2Body* bodyA = contact->GetFixtureA()->GetBody();
b2Body* bodyB = contact->GetFixtureB()->GetBody();
//Cast them to object pointers
BodyComponent* objectA = static_cast<BodyComponent*>(bodyA->GetUserData());
BodyComponent* objectB = static_cast<BodyComponent*>(bodyB->GetUserData());
if (objectA->getOwner()->getType() == ObjectType::bullet ||
objectA->getOwner()->getType() == ObjectType::arrow) {
objectA->getOwner()->setIsDead(true);
}
if (objectB->getOwner()->getType() == ObjectType::bullet ||
objectB->getOwner()->getType() == ObjectType::arrow) {
objectB->getOwner()->setIsDead(true);
}
if (objectA->getOwner()->getType() == ObjectType::bullet &&
objectB->getOwner()->getType() == ObjectType::enemy) {
objectB->getOwner()->setIsDead(true);
}
if (objectB->getOwner()->getType() == ObjectType::bullet &&
objectA->getOwner()->getType() == ObjectType::enemy) {
objectA->getOwner()->setIsDead(true);
}
} | [
"msbarnes@ualr.edu"
] | msbarnes@ualr.edu |
d1c784f087dd4e93e38632f8dd9ae4f1459ff19e | c73c7edb59359556375602acdb2b27d886c8125b | /Theon's Answer.cpp | c954ddf1707054353e3ed9680398f5bdb87f10bf | [] | no_license | galloska/URI | 14e43bb4e7083ae2d517afe0e62b46e17b7cac91 | 86648676d417a6a452019e731c58ba25d5742fe3 | refs/heads/master | 2021-01-10T11:14:09.819072 | 2016-01-26T21:58:53 | 2016-01-26T21:58:53 | 50,080,447 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 339 | cpp | #include <bits/stdc++.h>
#define lli long long int
#define pii pair<int,int>
using namespace std;
const int INF = 1e8;
const int MAXN = 100005;
int main(){
int n;
scanf("%d",&n);
int id=-1,a;
int mini = INF;
for(int i=0;i<n;i++){
scanf("%d",&a);
if(a<mini){
mini = a;
id = i;
}
}
printf("%d\n",id+1);
return 0;
}
| [
"skap19952008@hotmail.com"
] | skap19952008@hotmail.com |
f708d35687bdd9581bdbb5248af338926bb1f75a | 5f46975fc7a0b309bbc40f8d16ea12043025c057 | /Programmers/두 정수 사이의 합.cpp | 40b8ac53a00959d5e2c1f9d7d4ea342ae9db749a | [] | no_license | HyeranShin/algorithm | b7814a57bd7e94e8b07fbc870295e5024b4182d5 | dbe6dc747030be03c3bb913358a9b238dcecfcc4 | refs/heads/master | 2021-08-18T04:10:10.039487 | 2020-05-01T07:23:46 | 2020-05-01T07:23:46 | 174,467,552 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 852 | cpp | /*
https://www.welcomekakao.com/learn/courses/30/lessons/1291
<문제 설명>
두 정수 a, b가 주어졌을 때 a와 b 사이에 속한 모든 정수의 합을 리턴하는 함수, solution을 완성하세요.
예를 들어 a = 3, b = 5인 경우, 3 + 4 + 5 = 12이므로 12를 리턴합니다.
<제한 조건>
- a와 b가 같은 경우는 둘 중 아무 수나 리턴하세요.
- a와 b는 -10,000,000 이상 10,000,000 이하인 정수입니다.
- a와 b의 대소관계는 정해져있지 않습니다.
*/
#include <string>
#include <vector>
using namespace std;
long long solution(int a, int b) {
long long answer = 0;
if (a>=b) {
for (int i = b; i <=a; i++) {
answer += i;
}
}
else if (a<b) {
for (int i = a; i <= b; i++) {
answer += i;
}
}
return answer;
}
| [
"hyeran9712@naver.com"
] | hyeran9712@naver.com |
2dca74bb98b576f7ae5bfa138e04157b1585984a | a0ca4b308a3f3882dc5052a402c9e740187e8286 | /include/Controls.h | 120da5e5845d4521677f3dfa6cdf01de639449df | [] | no_license | shtein/arduinolib | 2052c81ac03ba832f5a6dafa595d1a2bc136a348 | fc8b4538b29786857dd3ab2b5071ba19093799e6 | refs/heads/master | 2023-05-12T23:24:51.385972 | 2023-05-02T02:45:24 | 2023-05-02T02:45:24 | 122,542,842 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,255 | h | #ifndef __CONTROLS_H
#define __CONTROLS_H
#include "ControlCtx.h"
#include "AnalogInput.h"
#include "utils.h"
#include "CmdParser.h"
//Change commands
#define EEMC_NONE 0x00 //Nothing changed
#define EEMC_ERROR 0xFF //Input error
///////////////////////////////////
// Control flags
#define CTF_NONE 0x00 //Nothing
#define CTF_VAL_ABS 0x01 //Absolute number
#define CTF_VAL_BOOL 0x02 //Value is bool
#define CTF_VAL_DELTA 0x03 //Value is delta
#define CTF_VAL_NEXT 0x04 //Go next - in cycles
#define CTF_VAL_PREV 0x05 //Go previous - in cycles
#define CTF_VAL_STRING 0x06 //Value is string
#define CTF_VAL_OBJECT 0x07 //Value is object
#if defined(ESP8266) || defined(ESP32)
#define MAX_STR_VALUE 256
#else
#define MAX_STR_VALUE 16
#endif
////////////////////////////////////
// Control queue data
struct CtrlQueueData{
uint8_t flag; //Flag that shows how to interpret the value: absolute number, inrement, etc
union{
int value; //integer value
char str[MAX_STR_VALUE]; //string value or packed object
};
int min; //Value minimum
int max; //Value maximum
CtrlQueueData(){
flag = CTF_NONE;
value = 0;
min = 0;
max = 0;
}
void setValue(int n){
flag = CTF_VAL_ABS;
value = n;
}
void setValue(const char *p){
flag = CTF_VAL_STRING;
strncpy(str, p, MAX_STR_VALUE);
}
void setValue(char *p){
flag = CTF_VAL_STRING;
strncpy(str, p, MAX_STR_VALUE);
}
template<typename T>
void setValue(const T &t){
flag = CTF_VAL_OBJECT;
memcpy((void *)str, &t, (sizeof(T) < MAX_STR_VALUE) ? sizeof(T) : MAX_STR_VALUE);
}
int translate(int base, int vmin, int vmax) const{
switch(flag){
case CTF_VAL_ABS: //Absolute value
base = min == max ? value : map(value, min, max, vmin, vmax);
if(base < vmin) base = vmin;
else if(base > vmax) base = vmax;
break;
case CTF_VAL_NEXT: //Go next
base ++;
if(base > vmax) base = vmin;
break;
case CTF_VAL_PREV: //Go Prev
base --;
if(base < vmin) base = vmax;
break;
case CTF_VAL_DELTA://Delta
base += value;
if(base < vmin) base = vmin;
else if(base > vmax) base = vmax;
break;
}
return base;
}
};
////////////////////////////////////
// Control queue element
struct CtrlQueueItem {
uint8_t cmd; // Command
CtrlQueueData data; // Data
CtrlQueueItem(){
cmd = 0;
}
};
//////////////////////////////////////////
// ProcessControl - base class
class CtrlItem{
public:
CtrlItem(uint8_t cmd, BaseInput *input);
~CtrlItem();
void loop(CtrlQueueItem &itm);
BaseInput *getInput() const;
protected:
virtual bool triggered() const = 0;
virtual void getData(CtrlQueueData &data) = 0;
protected:
uint8_t _cmd; //Command
BaseInput *_input; //Analog input to retrieve control data
};
////////////////////////////////
// Push button control, reacts on either short click, long click or long push
template <const uint8_t CTRL = PB_CONTROL_CLICK, const uint8_t FLAG = CTF_VAL_NEXT, const uint8_t VALUE = 0>
class CtrlItemPb: public CtrlItem{
public:
CtrlItemPb(uint8_t cmd, PushButton *input):
CtrlItem(cmd, input){
}
protected:
bool triggered() const{
return ((PushButton *)getInput())->value(CTRL);
}
void getData(CtrlQueueData &data){
data.flag = FLAG;
data.value = VALUE;
data.min = 0;
data.max = 0;
}
};
////////////////////////////////
// CtrlItemPtmtr - analog input is Potentiometer - AnalogInput
template <const uint16_t NOISE_THRESHOLD = POT_NOISE_THRESHOLD,
const uint16_t LOWER_MARGIN = POT_LOWER_MARGIN,
const uint16_t UPPER_MARGIN = POT_UPPER_MARGIN >
class CtrlItemPtmtr: public CtrlItem{
public:
CtrlItemPtmtr(uint8_t cmd, AnalogInput *ptn):
CtrlItem(cmd, ptn){
_value = POT_MAX; //just to make sure it is different from what we read
}
protected:
bool triggered() const{
int16_t value = (int16_t)getValue();
return (abs(value - (int16_t)_value) > min(NOISE_THRESHOLD,
(uint16_t)min(value - POT_MIN + LOWER_MARGIN, POT_MAX - UPPER_MARGIN - value)
)
);
}
void getData(CtrlQueueData &data){
_value = getValue();
data.flag = CTF_VAL_ABS;
data.min = POT_MIN + LOWER_MARGIN;
data.max = POT_MAX - UPPER_MARGIN;
data.value = _value;
}
uint16_t getValue() const{
uint16_t value = ( _value + ((AnalogInput *)getInput())->value() ) / 2;
if(_value > value && value > 0)
value -= 1;
else if(_value < value)
value += 1;
return value < POT_MIN + LOWER_MARGIN ?
POT_MIN + LOWER_MARGIN : value > POT_MAX - UPPER_MARGIN ?
POT_MAX - UPPER_MARGIN : value;
}
protected:
uint16_t _value;
};
///////////////////////////////
// CtrlSwicth2Pos - two position swicth - digital input
class CtrlSwicth2Pos: public CtrlItem{
public:
CtrlSwicth2Pos(uint8_t cmd, Switch2Pos *sw):
CtrlItem(cmd, sw){
//Make sure first trigger works
_value = !((Switch2Pos *)getInput())->value();
}
protected:
bool triggered() const{
return _value != ((Switch2Pos *)getInput())->value();
}
void getData(CtrlQueueData &data){
_value = ((Switch2Pos *)getInput())->value();
data.flag = CTF_VAL_ABS;
data.value = _value;
data.min = 0;
data.max = 0;
}
protected:
bool _value;
};
#ifdef USE_IR_REMOTE
//////////////////////////////
// CtrlItemIRBtn - analog input is one IR remote buttons
// Returns returns delta
// dir - direction (true is positive, false is negative)
// repeat - button repeat limit, 0 = single push, same as next or prev
template<const unsigned long BTN, const bool DIR = true, const uint8_t REPEAT = 0>
class CtrlItemIRBtn: public CtrlItem{
public:
CtrlItemIRBtn(uint8_t cmd, IRRemoteRecv *ir):
CtrlItem(cmd, ir){
}
~CtrlItemIRBtn();
protected:
bool triggered() const{
int n = ((IRRemoteRecv *)getInput())->pushed(BTN);
//Not pushed
if(n == 0) {
return false;
}
//Single click button
if(n > 1 && REPEAT == 0){
return false;
}
//Pushed
return true;
}
void getData(CtrlQueueData &data){
data.flag = REPEAT > 0 ? CTF_VAL_DELTA : (DIR ? CTF_VAL_NEXT: CTF_VAL_PREV );
data.value = (DIR ? 1 : -1) * powInt(2, ((IRRemoteRecv *)getInput())->pushed(BTN) - 1, REPEAT);
data.min = 0;
data.max = 0;
}
};
#endif //USE_IR_REMOTE
////////////////////////////////////////
// Rotary encoder control
// Always returns incremental/decremental value
#define ROTECT_DEFAULT_INC 10 //Default incremement value
template <const uint8_t INC = ROTECT_DEFAULT_INC>
class CtrlItemRotEnc: public CtrlItem{
public:
CtrlItemRotEnc(uint8_t cmd, RotaryEncoder *re):
CtrlItem(cmd, re){
}
protected:
bool triggered() const{
return ((RotaryEncoder *)getInput())->value() != 0;
}
void getData(CtrlQueueData &data){
data.flag = CTF_VAL_DELTA;
data.value = ((RotaryEncoder *)getInput())->value() * INC;
data.min = 0;
data.max = 0;
}
};
/////////////////////////////////////////
// Multi-command interface
#if defined(ESP8266) || defined(ESP32)
#define MAX_TOKENS 16
#define MAX_COMMAND_LEN 128
#else
#define MAX_TOKENS 8
#define MAX_COMMAND_LEN 32
#endif
template<class INP, class NTF, uint8_t (*PARSER) (const char * tokens[], CtrlQueueData &data)>
class CtrlItemMultiCommand: public CtrlItem, public NTF{
public:
CtrlItemMultiCommand(INP *input):
CtrlItem(EEMC_NONE, input){
}
protected:
// CtrlItem functions
bool triggered() const{
return ((INP *)_input)->isReady();
}
void getData(CtrlQueueData &data){
const char *tokens[MAX_TOKENS + 1];
memset(&tokens, 0, sizeof(tokens));
if(!((INP *)_input)->getTokens(tokens, MAX_TOKENS) ){
_cmd = EEMC_ERROR;
}
else if( tokens[0] != NULL){
_cmd = PARSER(tokens, data);
}
else {
_cmd = EEMC_NONE;
}
}
};
////////////////////////////////////////
// EffectControlPanel
#ifndef MAX_CONTROLS
#define MAX_CONTROLS 20
#endif
#ifndef MAX_INPUTS
#define MAX_INPUTS 10
#endif
class CtrlPanel{
public:
CtrlPanel();
~CtrlPanel();
void addControl(CtrlItem *ctrl);
void loop(CtrlQueueItem &itm);
protected:
CtrlItem *_controls[MAX_CONTROLS]; //Controls
uint8_t _numControls; //Number of controls
uint8_t _controlNum; //Last processed control
BaseInput *_inputs[MAX_INPUTS]; //Analog inputs
uint8_t _numInputs;
};
#endif //__CONTROLS_H
| [
"shtein@gmail.com"
] | shtein@gmail.com |
28f339371705c7ce22be7c6c17069038ff8c97d0 | bfe6956c470da766ed7e8fbb6d72848a95372def | /Labs/lab7/lab7/Source.cpp | aaab47d55a691c97311487766b3b2343868b6a95 | [] | no_license | matthew-bahloul/2019-Spring-CS211 | 685160145d7761a3086a24cb50e2a614d8533c67 | c3c47f4218bcf7d8eb8034029be18248a69339e3 | refs/heads/master | 2020-04-19T07:06:21.824802 | 2019-04-21T21:13:12 | 2019-04-21T21:13:12 | 168,037,386 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,372 | cpp | #include "BinarySearchTree.h"
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
BinarySearchTree<int> tree{};
tree.addElement(100);
tree.addElement(75);
tree.addElement(125);
cout << "Is AVL: " << tree.isAvl() << " (expected true)" << endl;
cout << "Common ancestor of 75 and 125: " << tree.commonAncestor(75, 125) << " (expected 100)" << endl;
tree.addElement(25);
tree.addElement(10);
tree.addElement(50);
tree.addElement(125);
tree.addElement(111);
tree.addElement(150);
tree.addElement(145);
tree.addElement(155);
cout << "Is AVL: " << tree.isAvl() << " (expected false)" << endl;
cout << "Common ancestor of 150 and 111: " << tree.commonAncestor(150, 111) << " (expected 125)" << endl;
cout << "Common ancestor of 10 and 111: " << tree.commonAncestor(10, 111) << " (expected 100)" << endl;
BinarySearchTree<int> tree2{};
tree2.addElement(117);
tree2.addElement(110);
tree2.addElement(112);
tree2.addElement(115);
tree2.addElement(114);
tree2.addElement(120);
tree2.addElement(116);
tree2.addElement(118);
tree.mergeTree(tree2);
cout << "Is AVL: " << tree.isAvl() << " (expected ???)" << endl;
cout << "Common ancestor of 118 and 25: " << tree.commonAncestor(118, 25) << " (expected ???)" << endl;
cout << "Common ancestor of 115 and 111: " << tree.commonAncestor(115, 111) << " (expected ???)" << endl;
} | [
"matthew.bahloul@gmail.com"
] | matthew.bahloul@gmail.com |
533e03ef517178bd9beafeebd944d5302d895d55 | 1acbf36d67ab3cad2e1234029e7fff62816c5d72 | /src/dalsa_win_buffer_processing.h | e04ab2d902a0fb8c3d54f785d177869721e89777 | [] | no_license | maximMalofeev/media_provider | 419337c631b02bcbc61a6c5335c19c65afca50d2 | 4d46c4714e30954bb10811b39673d2417ac43f36 | refs/heads/master | 2020-07-28T05:29:22.137235 | 2020-02-07T15:02:46 | 2020-02-07T15:02:46 | 209,323,686 | 8 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 514 | h | #ifndef SAPBUFFERPROCESSING_H
#define SAPBUFFERPROCESSING_H
#include <SapClassBasic.h>
#include <QImage>
#include <QObject>
namespace MediaProvider {
class DalsaBufferProcessing : public QObject, public SapProcessing {
Q_OBJECT
public:
DalsaBufferProcessing(SapBuffer* sapBuffer, QObject* parent = nullptr);
signals:
void newFrame(QImage frame, qlonglong timestamp);
protected:
BOOL Run() override;
private:
int frameSize{};
};
} // namespace MediaProvider
#endif // SAPBUFFERPROCESSING_H
| [
"maximMalofeev@bk.ru"
] | maximMalofeev@bk.ru |
16e1a375c81c4b4631030725e1f01ae27ff7090c | 3eef636ad6039f8218473ee783b2d6957ea2bc8d | /MonitorInfoServer/MonitorInfoServer/MessageHandler.h | acdd9e7c8c9957433907031ae9de6b613fbcae95 | [] | no_license | nicktsai1988/windows | 7f5b737c94f0fef941fac7abdbd1a412207d5a93 | d99b6b6e09a72fbd0c51e8f2886dd46326c4d40a | refs/heads/master | 2020-04-06T05:36:00.302227 | 2014-06-20T11:19:27 | 2014-06-20T11:19:36 | 20,987,594 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 468 | h | #pragma once
#include "MessageTypeUtils.h"
class CMessageHandler
{
public:
CMessageHandler(void);
void Init(SOCKET fd,const void* pData);
int DealMessage();
~CMessageHandler(void);
private:
int RecvRequest(RequestMessageType* message,const timeval* tmval);
int CreateResponse(const RequestMessageType* request,ResponseMessageType* response);
int SendResponse(const ResponseMessageType* message,const timeval* tmval);
SOCKET m_sockFd;
const void* m_pData;
};
| [
"nicktsai@163.com"
] | nicktsai@163.com |
79c83a8e88a24f30cf8bb4f3fac42bbc85340af1 | d6723b2e1547d1eddd5a120c8fa4edbf4cddbacb | /silkopter/fc/src/MPL_Helper.h | c33333af6f816494a57b862bb60d63a6f58d96c0 | [
"BSD-3-Clause"
] | permissive | gonzodepedro/silkopter | 2d16e10bd46affe4ca319e3db3f7dbc54283ca23 | cdbc67ee2c85f5c95eb4f52e2e0ba24514962dd8 | refs/heads/master | 2022-01-04T20:46:51.893287 | 2019-01-07T22:43:40 | 2019-01-07T22:43:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,400 | h | #pragma once
namespace silk
{
namespace detail
{
template<int...> struct index_tuple{};
template<int I, typename IndexTuple, typename... Types>
struct make_indexes_impl;
template<int I, int... Indexes, typename T, typename ... Types>
struct make_indexes_impl<I, index_tuple<Indexes...>, T, Types...>
{
typedef typename make_indexes_impl<I + 1, index_tuple<Indexes..., I>, Types...>::type type;
};
template<int I, int... Indexes>
struct make_indexes_impl<I, index_tuple<Indexes...> >
{
typedef index_tuple<Indexes...> type;
};
template<typename ... Types>
struct make_indexes : make_indexes_impl<0, index_tuple<>, Types...>
{};
//create object from tuple arguments
template<class T, class... Args, int... Indexes >
T* create_helper(index_tuple< Indexes... >, std::tuple<Args...>&& tup)
{
return new T( std::forward<Args>( std::get<Indexes>(tup))... );
}
template<class T, class ... Args>
T* create(const std::tuple<Args...>& tup)
{
return create_helper<T>(typename make_indexes<Args...>::type(), std::tuple<Args...>(tup));
}
template<class T, class ... Args>
T* create(std::tuple<Args...>&& tup)
{
return create_helper<T>(typename make_indexes<Args...>::type(), std::forward<std::tuple<Args...>>(tup));
}
template<class Base>
class Ctor_Helper_Base
{
public:
virtual ~Ctor_Helper_Base() {}
virtual auto create() -> Base* = 0;
};
template<class Base, class T, typename... Params>
class Ctor_Helper : public Ctor_Helper_Base<Base>
{
public:
Ctor_Helper(Params&&... params)
: tuple(params...)
{
}
auto create() -> Base*
{
return detail::create<T>(tuple);
}
std::tuple<Params...> tuple;
};
//call function with tuple arguments
template<class Ret, class... Args, int... Indexes >
Ret call_helper(std::function<Ret(Args...)> const& func, index_tuple< Indexes... >, std::tuple<Args...>&& tup)
{
return func( std::forward<Args>( std::get<Indexes>(tup))... );
}
template<class Ret, class ... Args>
Ret call(std::function<Ret(Args...)> const& func, const std::tuple<Args...>& tup)
{
return call_helper(func, typename make_indexes<Args...>::type(), std::tuple<Args...>(tup));
}
template<class Ret, class ... Args>
Ret call(std::function<Ret(Args...)> const& func, std::tuple<Args...>&& tup)
{
return call_helper(func, typename make_indexes<Args...>::type(), std::forward<std::tuple<Args...>>(tup));
}
}
}
| [
"catalin.vasile@gmail.com"
] | catalin.vasile@gmail.com |
5d9d54ab3abecffba1786c6886cc41e3e7cc959f | eff3b95b4f27aead25dba7e093c46a79aabe58ec | /turma.h | a7c5e83373f3d4efe303a727cd35f7e75f319cca | [] | no_license | walcker/Alunos-da-Turma | 322be9bd2020e2587090e7341299e6cd7c675b63 | eef87f591ede66c06f51fc7a7f751a41b18de8cc | refs/heads/master | 2022-12-14T11:31:03.418323 | 2020-03-12T22:13:54 | 2020-03-12T22:13:54 | 293,941,859 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 559 | h | #ifndef TURMA_H
#define TURMA_H
#include <iostream>
#include "aluno.h"
using namespace std;
class Turma
{
private:
string codigo;
string descricao;
short capacidade;
Aluno* participantes;
int lotacao;
public:
// get & set
void setCodigo(string cd);
string getCodigo();
void setDescricao(string ds);
string getDescricao();
void setCapacidade(short cp);
short getCapacidade();
// void setParticipantes();
void addParticipantes(Aluno umAluno);
void mostrarAlunos();
Turma();
Turma(string cod,string desc, short cap);
~Turma();
};
#endif | [
"walckergomes@gmail.com"
] | walckergomes@gmail.com |
f0f028318b7adaf86f7e14f55ceee1d24a1dde4c | ba02c94e1d558c1f0cb3f6dc9e66e36d40fcea91 | /Singly linked list/CreateNewAddheadAddtail.cpp | 6e24ea4a44cceff5af680b6c156f9cf2be03b9e4 | [] | no_license | Hieu1011/DSA | 2138131efdac57b33cbe5515a3816089b6abfc68 | 6f9031cbd3e12da42035ba85ba3e6d0e98838b10 | refs/heads/main | 2023-06-14T07:40:28.635752 | 2021-07-05T17:11:23 | 2021-07-05T17:11:23 | 383,007,670 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,084 | cpp | #include <iostream>
using namespace std;
struct NODE
{
int info;
NODE* pNext;
};
struct LIST
{
NODE* pHead, * pTail;
};
void CreateEmptyList(LIST& L)
{
L.pHead = L.pTail = NULL;
}
void Addhead(LIST& L, int x)
{
NODE* p = new NODE;
p->info = x;
p->pNext = NULL;
if (L.pHead == NULL)
{
L.pHead = p;
L.pTail = L.pHead;
}
else
{
p->pNext = L.pHead;
L.pHead = p;
}
}
void AddTail(LIST& L, int x)
{
NODE* p = new NODE;
p->info = x;
p->pNext = NULL;
if (L.pHead == NULL)
{
L.pHead = p;
L.pTail = L.pHead;
}
else
{
L.pTail->pNext = p;
L.pTail = p;
}
}
void CreateList(LIST& L)
{
int x;
cin >> x;
while (x != -1)
{
if (x == 0)
{
cin >> x;
Addhead(L, x);
}
else if (x == 1)
{
cin >> x;
AddTail(L, x);
}
cin >> x;
}
}
void PrintList(LIST L)
{
if (L.pHead == NULL)
{
cout << "Empty List.";
return;
}
NODE* P = L.pHead;
NODE* T = new NODE;
do
{
cout << P->info << " ";
T = P;
P = P->pNext;
} while (T->pNext != NULL);
}
int main() {
LIST L;
CreateEmptyList(L);
CreateList(L);
PrintList(L);
return 0;
}
| [
"20520994@gm.uit.edu.vn"
] | 20520994@gm.uit.edu.vn |
97d067cc235c9a4938fe42b4c0943fe76b28f5a5 | ce4a3f0f6fad075b6bd2fe7d84fd9b76b9622394 | /include/EMaterialFlags.h | f016c81e4a21d9c71179a8a1659f357bb92ca475 | [] | no_license | codetiger/IrrNacl | c630187dfca857c15ebfa3b73fd271ef6bad310f | dd0bda2fb1c2ff46813fac5e11190dc87f83add7 | refs/heads/master | 2021-01-13T02:10:24.919588 | 2012-07-22T06:27:29 | 2012-07-22T06:27:29 | 4,461,459 | 5 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,752 | h | // Copyright (C) 2002-2011 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_MATERIAL_FLAGS_H_INCLUDED__
#define __E_MATERIAL_FLAGS_H_INCLUDED__
namespace irr
{
namespace video
{
//! Material flags
enum E_MATERIAL_FLAG
{
//! Draw as wireframe or filled triangles? Default: false
EMF_WIREFRAME = 0x1,
//! Draw as point cloud or filled triangles? Default: false
EMF_POINTCLOUD = 0x2,
//! Flat or Gouraud shading? Default: true
EMF_GOURAUD_SHADING = 0x4,
//! Will this material be lighted? Default: true
EMF_LIGHTING = 0x8,
//! Is the ZBuffer enabled? Default: true
EMF_ZBUFFER = 0x10,
//! May be written to the zbuffer or is it readonly. Default: true
/** This flag is ignored, if the material type is a transparent type. */
EMF_ZWRITE_ENABLE = 0x20,
//! Is backface culling enabled? Default: true
EMF_BACK_FACE_CULLING = 0x40,
//! Is frontface culling enabled? Default: false
/** Overrides EMF_BACK_FACE_CULLING if both are enabled. */
EMF_FRONT_FACE_CULLING = 0x80,
//! Is bilinear filtering enabled? Default: true
EMF_BILINEAR_FILTER = 0x100,
//! Is trilinear filtering enabled? Default: false
/** If the trilinear filter flag is enabled,
the bilinear filtering flag is ignored. */
EMF_TRILINEAR_FILTER = 0x200,
//! Is anisotropic filtering? Default: false
/** In Irrlicht you can use anisotropic texture filtering in
conjunction with bilinear or trilinear texture filtering
to improve rendering results. Primitives will look less
blurry with this flag switched on. */
EMF_ANISOTROPIC_FILTER = 0x400,
//! Is fog enabled? Default: false
EMF_FOG_ENABLE = 0x800,
//! Normalizes normals. Default: false
/** You can enable this if you need to scale a dynamic lighted
model. Usually, its normals will get scaled too then and it
will get darker. If you enable the EMF_NORMALIZE_NORMALS flag,
the normals will be normalized again, and the model will look
as bright as it should. */
EMF_NORMALIZE_NORMALS = 0x1000,
//! Access to all layers texture wrap settings. Overwrites separate layer settings.
EMF_TEXTURE_WRAP = 0x2000,
//! AntiAliasing mode
EMF_ANTI_ALIASING = 0x4000,
//! ColorMask bits, for enabling the color planes
EMF_COLOR_MASK = 0x8000,
//! ColorMaterial enum for vertex color interpretation
EMF_COLOR_MATERIAL = 0x10000,
//! Flag for enabling/disabling mipmap usage
EMF_USE_MIP_MAPS = 0x20000,
//! Flag for blend operation
EMF_BLEND_OPERATION = 0x40000,
//! Flag for polygon offset
EMF_POLYGON_OFFSET = 0x80000
};
} // end namespace video
} // end namespace irr
#endif // __E_MATERIAL_FLAGS_H_INCLUDED__
| [
"smackallgames@smackall-2bbd93.(none)"
] | smackallgames@smackall-2bbd93.(none) |
a2e324bc0b1f0906e665665953ddc34ae8a86d0c | b7f3edb5b7c62174bed808079c3b21fb9ea51d52 | /base/win/embedded_i18n/language_selector.cc | fde6a282b0f29580d4e2bd46efd7e9da09208a4c | [
"BSD-3-Clause"
] | permissive | otcshare/chromium-src | 26a7372773b53b236784c51677c566dc0ad839e4 | 64bee65c921db7e78e25d08f1e98da2668b57be5 | refs/heads/webml | 2023-03-21T03:20:15.377034 | 2020-11-16T01:40:14 | 2020-11-16T01:40:14 | 209,262,645 | 18 | 21 | BSD-3-Clause | 2023-03-23T06:20:07 | 2019-09-18T08:52:07 | null | UTF-8 | C++ | false | false | 14,014 | cc | // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This file defines a helper class for selecting a supported language from a
// set of candidates. It is used to get localized strings that are directly
// embedded into the executable / library instead of stored in external
// .pak files.
#include "base/win/embedded_i18n/language_selector.h"
#include <algorithm>
#include <functional>
#include "base/check_op.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/i18n.h"
namespace base {
namespace win {
namespace i18n {
namespace {
using LangToOffset = LanguageSelector::LangToOffset;
// Holds pointers to LangToOffset pairs for specific languages that are the
// targets of exceptions (where one language is mapped to another) or wildcards
// (where a raw language identifier is mapped to a specific localization).
struct AvailableLanguageAliases {
const LangToOffset* en_gb_language_offset;
const LangToOffset* en_us_language_offset;
const LangToOffset* es_language_offset;
const LangToOffset* es_419_language_offset;
const LangToOffset* fil_language_offset;
const LangToOffset* iw_language_offset;
const LangToOffset* no_language_offset;
const LangToOffset* pt_br_language_offset;
const LangToOffset* zh_cn_language_offset;
const LangToOffset* zh_tw_language_offset;
};
#if DCHECK_IS_ON()
// Returns true if the items in the given range are sorted and lower cased.
bool IsArraySortedAndLowerCased(span<const LangToOffset> languages_to_offset) {
return std::is_sorted(languages_to_offset.begin(),
languages_to_offset.end()) &&
std::all_of(languages_to_offset.begin(), languages_to_offset.end(),
[](const auto& lang) {
auto language = AsStringPiece16(lang.first);
return ToLowerASCII(language) == language;
});
}
#endif // DCHECK_IS_ON()
// Determines the availability of all languages that may be used as aliases in
// GetAliasedLanguageOffset or GetCompatibleNeutralLanguageOffset
AvailableLanguageAliases DetermineAvailableAliases(
span<const LangToOffset> languages_to_offset) {
AvailableLanguageAliases available_aliases = {};
for (const LangToOffset& lang_to_offset : languages_to_offset) {
if (lang_to_offset.first == L"en-gb")
available_aliases.en_gb_language_offset = &lang_to_offset;
else if (lang_to_offset.first == L"en-us")
available_aliases.en_us_language_offset = &lang_to_offset;
else if (lang_to_offset.first == L"es")
available_aliases.es_language_offset = &lang_to_offset;
else if (lang_to_offset.first == L"es-419")
available_aliases.es_419_language_offset = &lang_to_offset;
else if (lang_to_offset.first == L"fil")
available_aliases.fil_language_offset = &lang_to_offset;
else if (lang_to_offset.first == L"iw")
available_aliases.iw_language_offset = &lang_to_offset;
else if (lang_to_offset.first == L"no")
available_aliases.no_language_offset = &lang_to_offset;
else if (lang_to_offset.first == L"pt-br")
available_aliases.pt_br_language_offset = &lang_to_offset;
else if (lang_to_offset.first == L"zh-cn")
available_aliases.zh_cn_language_offset = &lang_to_offset;
else if (lang_to_offset.first == L"zh-tw")
available_aliases.zh_tw_language_offset = &lang_to_offset;
}
// Fallback language must exist.
DCHECK(available_aliases.en_us_language_offset);
return available_aliases;
}
// Returns true if a LangToOffset entry can be found in |languages_to_offset|
// that matches the |language| exactly. |offset| will store the offset of the
// language that matches if any. |languages_to_offset| must be sorted by
// language and all languages must lower case.
bool GetExactLanguageOffset(span<const LangToOffset> languages_to_offset,
const std::wstring& language,
const LangToOffset** matched_language_to_offset) {
DCHECK(matched_language_to_offset);
// Binary search in the sorted arrays to find the offset corresponding
// to a given language |name|.
auto search_result = std::lower_bound(
languages_to_offset.begin(), languages_to_offset.end(), language,
[](const LangToOffset& left, const std::wstring& to_find) {
return left.first < to_find;
});
if (languages_to_offset.end() != search_result &&
search_result->first == language) {
*matched_language_to_offset = &*search_result;
return true;
}
return false;
}
// Returns true if the current language can be aliased to another language.
bool GetAliasedLanguageOffset(const AvailableLanguageAliases& available_aliases,
const std::wstring& language,
const LangToOffset** matched_language_to_offset) {
DCHECK(matched_language_to_offset);
// Alias some English variants to British English (all others wildcard to
// US).
if (available_aliases.en_gb_language_offset &&
(language == L"en-au" || language == L"en-ca" || language == L"en-nz" ||
language == L"en-za")) {
*matched_language_to_offset = available_aliases.en_gb_language_offset;
return true;
}
// Alias es-es to es (all others wildcard to es-419).
if (available_aliases.es_language_offset && language == L"es-es") {
*matched_language_to_offset = available_aliases.es_language_offset;
return true;
}
// Google web properties use iw for he. Handle both just to be safe.
if (available_aliases.iw_language_offset && language == L"he") {
*matched_language_to_offset = available_aliases.iw_language_offset;
return true;
}
// Google web properties use no for nb. Handle both just to be safe.
if (available_aliases.no_language_offset && language == L"nb") {
*matched_language_to_offset = available_aliases.no_language_offset;
return true;
}
// Some Google web properties use tl for fil. Handle both just to be safe.
// They're not completely identical, but alias it here.
if (available_aliases.fil_language_offset && language == L"tl") {
*matched_language_to_offset = available_aliases.fil_language_offset;
return true;
}
if (available_aliases.zh_cn_language_offset &&
// Pre-Vista alias for Chinese w/ script subtag.
(language == L"zh-chs" ||
// Vista+ alias for Chinese w/ script subtag.
language == L"zh-hans" ||
// Although the wildcard entry for zh would result in this, alias zh-sg
// so that it will win if it precedes another valid tag in a list of
// candidates.
language == L"zh-sg")) {
*matched_language_to_offset = available_aliases.zh_cn_language_offset;
return true;
}
if (available_aliases.zh_tw_language_offset &&
// Pre-Vista alias for Chinese w/ script subtag.
(language == L"zh-cht" ||
// Vista+ alias for Chinese w/ script subtag.
language == L"zh-hant" ||
// Alias Hong Kong and Macau to Taiwan.
language == L"zh-hk" || language == L"zh-mo")) {
*matched_language_to_offset = available_aliases.zh_tw_language_offset;
return true;
}
return false;
}
// Returns true if the current neutral language can be aliased to another
// language.
bool GetCompatibleNeutralLanguageOffset(
const AvailableLanguageAliases& available_aliases,
const std::wstring& neutral_language,
const LangToOffset** matched_language_to_offset) {
DCHECK(matched_language_to_offset);
if (available_aliases.en_us_language_offset && neutral_language == L"en") {
// Use the U.S. region for anything English.
*matched_language_to_offset = available_aliases.en_us_language_offset;
return true;
}
if (available_aliases.es_419_language_offset && neutral_language == L"es") {
// Use the Latin American region for anything Spanish.
*matched_language_to_offset = available_aliases.es_419_language_offset;
return true;
}
if (available_aliases.pt_br_language_offset && neutral_language == L"pt") {
// Use the Brazil region for anything Portugese.
*matched_language_to_offset = available_aliases.pt_br_language_offset;
return true;
}
if (available_aliases.zh_cn_language_offset && neutral_language == L"zh") {
// Use the P.R.C. region for anything Chinese.
*matched_language_to_offset = available_aliases.zh_cn_language_offset;
return true;
}
return false;
}
// Runs through the set of candidates, sending their downcased representation
// through |select_predicate|. Returns true if the predicate selects a
// candidate, in which case |matched_name| is assigned the value of the
// candidate and |matched_offset| is assigned the language offset of the
// selected translation.
// static
bool SelectIf(const std::vector<std::wstring>& candidates,
span<const LangToOffset> languages_to_offset,
const AvailableLanguageAliases& available_aliases,
const LangToOffset** matched_language_to_offset,
std::wstring* matched_name) {
DCHECK(matched_language_to_offset);
DCHECK(matched_name);
// Note: always perform the exact match first so that an alias is never
// selected in place of a future translation.
// An earlier candidate entry matching on an exact match or alias match takes
// precedence over a later candidate entry matching on an exact match.
for (const std::wstring& scan : candidates) {
std::wstring lower_case_candidate =
AsWString(ToLowerASCII(AsStringPiece16(scan)));
if (GetExactLanguageOffset(languages_to_offset, lower_case_candidate,
matched_language_to_offset) ||
GetAliasedLanguageOffset(available_aliases, lower_case_candidate,
matched_language_to_offset)) {
matched_name->assign(scan);
return true;
}
}
// If no candidate matches exactly or by alias, try to match by locale neutral
// language.
for (const std::wstring& scan : candidates) {
std::wstring lower_case_candidate =
AsWString(ToLowerASCII(AsStringPiece16(scan)));
// Extract the locale neutral language from the language to search and try
// to find an exact match for that language in the provided table.
std::wstring neutral_language =
lower_case_candidate.substr(0, lower_case_candidate.find(L'-'));
if (GetCompatibleNeutralLanguageOffset(available_aliases, neutral_language,
matched_language_to_offset)) {
matched_name->assign(scan);
return true;
}
}
return false;
}
void SelectLanguageMatchingCandidate(
const std::vector<std::wstring>& candidates,
span<const LangToOffset> languages_to_offset,
int* selected_offset,
std::wstring* matched_candidate,
std::wstring* selected_language) {
DCHECK(selected_offset);
DCHECK(matched_candidate);
DCHECK(selected_language);
DCHECK(!languages_to_offset.empty());
DCHECK_EQ(size_t{*selected_offset}, languages_to_offset.size());
DCHECK(matched_candidate->empty());
DCHECK(selected_language->empty());
// Note: While DCHECK_IS_ON() seems redundant here, this is required to avoid
// compilation errors, since IsArraySortedAndLowerCased is not defined
// otherwise.
#if DCHECK_IS_ON()
DCHECK(IsArraySortedAndLowerCased(languages_to_offset))
<< "languages_to_offset is not sorted and lower cased";
#endif // DCHECK_IS_ON()
// Get which languages that are commonly used as aliases and wildcards are
// available for use to match candidates.
AvailableLanguageAliases available_aliases =
DetermineAvailableAliases(languages_to_offset);
// The fallback must exist.
DCHECK(available_aliases.en_us_language_offset);
// Try to find the first matching candidate from all the language mappings
// that are given. Failing that, used en-us as the fallback language.
const LangToOffset* matched_language_to_offset = nullptr;
if (!SelectIf(candidates, languages_to_offset, available_aliases,
&matched_language_to_offset, matched_candidate)) {
matched_language_to_offset = available_aliases.en_us_language_offset;
*matched_candidate =
std::wstring(available_aliases.en_us_language_offset->first);
}
DCHECK(matched_language_to_offset);
// Get the real language being used for the matched candidate.
*selected_language = std::wstring(matched_language_to_offset->first);
*selected_offset = matched_language_to_offset->second;
}
std::vector<std::wstring> GetCandidatesFromSystem(
WStringPiece preferred_language) {
std::vector<std::wstring> candidates;
// Get the intitial candidate list for this particular implementation (if
// applicable).
if (!preferred_language.empty())
candidates.emplace_back(preferred_language);
// Now try the UI languages. Use the thread preferred ones since that will
// kindly return us a list of all kinds of fallbacks.
win::i18n::GetThreadPreferredUILanguageList(&candidates);
return candidates;
}
} // namespace
LanguageSelector::LanguageSelector(WStringPiece preferred_language,
span<const LangToOffset> languages_to_offset)
: LanguageSelector(GetCandidatesFromSystem(preferred_language),
languages_to_offset) {}
LanguageSelector::LanguageSelector(const std::vector<std::wstring>& candidates,
span<const LangToOffset> languages_to_offset)
: selected_offset_(languages_to_offset.size()) {
SelectLanguageMatchingCandidate(candidates, languages_to_offset,
&selected_offset_, &matched_candidate_,
&selected_language_);
}
LanguageSelector::~LanguageSelector() = default;
} // namespace i18n
} // namespace win
} // namespace base
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
2c9ee9af44b0a9e1e3763f2d607b353edf86cfee | 600df3590cce1fe49b9a96e9ca5b5242884a2a70 | /base/containers/linked_list_unittest.cc | f4ecc71066fe777bcd1879b47037ca18422be3f9 | [
"BSD-3-Clause"
] | permissive | metux/chromium-suckless | efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a | 72a05af97787001756bae2511b7985e61498c965 | refs/heads/orig | 2022-12-04T23:53:58.681218 | 2017-04-30T10:59:06 | 2017-04-30T23:35:58 | 89,884,931 | 5 | 3 | BSD-3-Clause | 2022-11-23T20:52:53 | 2017-05-01T00:09:08 | null | UTF-8 | C++ | false | false | 6,677 | cc | // Copyright (c) 2009 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 "base/containers/linked_list.h"
#include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
namespace {
class Node : public LinkNode<Node> {
public:
explicit Node(int id) : id_(id) {}
int id() const { return id_; }
private:
int id_;
};
class MultipleInheritanceNodeBase {
public:
MultipleInheritanceNodeBase() : field_taking_up_space_(0) {}
int field_taking_up_space_;
};
class MultipleInheritanceNode : public MultipleInheritanceNodeBase,
public LinkNode<MultipleInheritanceNode> {
public:
MultipleInheritanceNode() {}
};
// Checks that when iterating |list| (either from head to tail, or from
// tail to head, as determined by |forward|), we get back |node_ids|,
// which is an array of size |num_nodes|.
void ExpectListContentsForDirection(const LinkedList<Node>& list,
int num_nodes, const int* node_ids, bool forward) {
int i = 0;
for (const LinkNode<Node>* node = (forward ? list.head() : list.tail());
node != list.end();
node = (forward ? node->next() : node->previous())) {
ASSERT_LT(i, num_nodes);
int index_of_id = forward ? i : num_nodes - i - 1;
EXPECT_EQ(node_ids[index_of_id], node->value()->id());
++i;
}
EXPECT_EQ(num_nodes, i);
}
void ExpectListContents(const LinkedList<Node>& list,
int num_nodes,
const int* node_ids) {
{
SCOPED_TRACE("Iterating forward (from head to tail)");
ExpectListContentsForDirection(list, num_nodes, node_ids, true);
}
{
SCOPED_TRACE("Iterating backward (from tail to head)");
ExpectListContentsForDirection(list, num_nodes, node_ids, false);
}
}
TEST(LinkedList, Empty) {
LinkedList<Node> list;
EXPECT_EQ(list.end(), list.head());
EXPECT_EQ(list.end(), list.tail());
ExpectListContents(list, 0, NULL);
}
TEST(LinkedList, Append) {
LinkedList<Node> list;
ExpectListContents(list, 0, NULL);
Node n1(1);
list.Append(&n1);
EXPECT_EQ(&n1, list.head());
EXPECT_EQ(&n1, list.tail());
{
const int expected[] = {1};
ExpectListContents(list, arraysize(expected), expected);
}
Node n2(2);
list.Append(&n2);
EXPECT_EQ(&n1, list.head());
EXPECT_EQ(&n2, list.tail());
{
const int expected[] = {1, 2};
ExpectListContents(list, arraysize(expected), expected);
}
Node n3(3);
list.Append(&n3);
EXPECT_EQ(&n1, list.head());
EXPECT_EQ(&n3, list.tail());
{
const int expected[] = {1, 2, 3};
ExpectListContents(list, arraysize(expected), expected);
}
}
TEST(LinkedList, RemoveFromList) {
LinkedList<Node> list;
Node n1(1);
Node n2(2);
Node n3(3);
Node n4(4);
Node n5(5);
list.Append(&n1);
list.Append(&n2);
list.Append(&n3);
list.Append(&n4);
list.Append(&n5);
EXPECT_EQ(&n1, list.head());
EXPECT_EQ(&n5, list.tail());
{
const int expected[] = {1, 2, 3, 4, 5};
ExpectListContents(list, arraysize(expected), expected);
}
// Remove from the middle.
n3.RemoveFromList();
EXPECT_EQ(&n1, list.head());
EXPECT_EQ(&n5, list.tail());
{
const int expected[] = {1, 2, 4, 5};
ExpectListContents(list, arraysize(expected), expected);
}
// Remove from the tail.
n5.RemoveFromList();
EXPECT_EQ(&n1, list.head());
EXPECT_EQ(&n4, list.tail());
{
const int expected[] = {1, 2, 4};
ExpectListContents(list, arraysize(expected), expected);
}
// Remove from the head.
n1.RemoveFromList();
EXPECT_EQ(&n2, list.head());
EXPECT_EQ(&n4, list.tail());
{
const int expected[] = {2, 4};
ExpectListContents(list, arraysize(expected), expected);
}
// Empty the list.
n2.RemoveFromList();
n4.RemoveFromList();
ExpectListContents(list, 0, NULL);
EXPECT_EQ(list.end(), list.head());
EXPECT_EQ(list.end(), list.tail());
// Fill the list once again.
list.Append(&n1);
list.Append(&n2);
list.Append(&n3);
list.Append(&n4);
list.Append(&n5);
EXPECT_EQ(&n1, list.head());
EXPECT_EQ(&n5, list.tail());
{
const int expected[] = {1, 2, 3, 4, 5};
ExpectListContents(list, arraysize(expected), expected);
}
}
TEST(LinkedList, InsertBefore) {
LinkedList<Node> list;
Node n1(1);
Node n2(2);
Node n3(3);
Node n4(4);
list.Append(&n1);
list.Append(&n2);
EXPECT_EQ(&n1, list.head());
EXPECT_EQ(&n2, list.tail());
{
const int expected[] = {1, 2};
ExpectListContents(list, arraysize(expected), expected);
}
n3.InsertBefore(&n2);
EXPECT_EQ(&n1, list.head());
EXPECT_EQ(&n2, list.tail());
{
const int expected[] = {1, 3, 2};
ExpectListContents(list, arraysize(expected), expected);
}
n4.InsertBefore(&n1);
EXPECT_EQ(&n4, list.head());
EXPECT_EQ(&n2, list.tail());
{
const int expected[] = {4, 1, 3, 2};
ExpectListContents(list, arraysize(expected), expected);
}
}
TEST(LinkedList, InsertAfter) {
LinkedList<Node> list;
Node n1(1);
Node n2(2);
Node n3(3);
Node n4(4);
list.Append(&n1);
list.Append(&n2);
EXPECT_EQ(&n1, list.head());
EXPECT_EQ(&n2, list.tail());
{
const int expected[] = {1, 2};
ExpectListContents(list, arraysize(expected), expected);
}
n3.InsertAfter(&n2);
EXPECT_EQ(&n1, list.head());
EXPECT_EQ(&n3, list.tail());
{
const int expected[] = {1, 2, 3};
ExpectListContents(list, arraysize(expected), expected);
}
n4.InsertAfter(&n1);
EXPECT_EQ(&n1, list.head());
EXPECT_EQ(&n3, list.tail());
{
const int expected[] = {1, 4, 2, 3};
ExpectListContents(list, arraysize(expected), expected);
}
}
TEST(LinkedList, MultipleInheritanceNode) {
MultipleInheritanceNode node;
EXPECT_EQ(&node, node.value());
}
TEST(LinkedList, EmptyListIsEmpty) {
LinkedList<Node> list;
EXPECT_TRUE(list.empty());
}
TEST(LinkedList, NonEmptyListIsNotEmpty) {
LinkedList<Node> list;
Node n(1);
list.Append(&n);
EXPECT_FALSE(list.empty());
}
TEST(LinkedList, EmptiedListIsEmptyAgain) {
LinkedList<Node> list;
Node n(1);
list.Append(&n);
n.RemoveFromList();
EXPECT_TRUE(list.empty());
}
TEST(LinkedList, NodesCanBeReused) {
LinkedList<Node> list1;
LinkedList<Node> list2;
Node n(1);
list1.Append(&n);
n.RemoveFromList();
list2.Append(&n);
EXPECT_EQ(list2.head()->value(), &n);
}
TEST(LinkedList, RemovedNodeHasNullNextPrevious) {
LinkedList<Node> list;
Node n(1);
list.Append(&n);
n.RemoveFromList();
EXPECT_EQ(NULL, n.next());
EXPECT_EQ(NULL, n.previous());
}
} // namespace
} // namespace base
| [
"enrico.weigelt@gr13.net"
] | enrico.weigelt@gr13.net |
1c4adf3e6f548b98ba57f93e18c565ed554c2d80 | 18b8d3d283dca9072c802206cadcf779db192bf9 | /PWMODEL/src/CpSNR.cpp | 5ac6be7f8343302456c02cf7950f9b9a08bd2fe9 | [
"Apache-2.0"
] | permissive | wanming2008/Rositaplusplus | 76f4457f0972f6ede818772921522d2f72342e0a | d4ec705b200dfbb26e54d379fd45373e34a20f47 | refs/heads/master | 2023-07-28T06:05:08.221484 | 2021-09-13T15:04:44 | 2021-09-13T15:04:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,885 | cpp | // Copyright 2021 University of Adelaide
//
// 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 "CpSNR.h"
#include "SNRAnalysis.h"
#include "AnalysisOuput.h"
#include "WorkContext.h"
#include "PWFactory.h"
#include "TraceReader.h"
struct cp_snr_priv_t
{
snr_analysis_t snr;
analysis_output_t ao;
std::string ext;
std::string filename;
tracereader_t* reader;
traceinfo_t traceinfo;
traceinfo_t winti;
};
cp_snr_t::cp_snr_t()
{
pimpl.init();
}
void cp_snr_t::init(const traceinfo_t *traceinfo, pwtermset_mode_t mode)
{
std::string outfilepath = wc_generate_path(traceinfo->title.c_str(), "snr.npy");
pimpl.get()->ao.init(outfilepath.c_str(),"numpy");
//pimpl.get()->snr.init(traceinfo, &pimpl.get()->ao, {{"at_each_ntraces","500"}});
pimpl.get()->winti = *traceinfo;
pimpl.get()->winti.nsamples = 1000;
pimpl.get()->winti.nterms = 1;
//pimpl.get()->corr.init(&pimpl.get()->winti, &pimpl.get()->ao, {{"at_each_ntraces","500"}});
pimpl.get()->snr.init(traceinfo, &pimpl.get()->ao, {{"at_each_ntraces","10000"}});
traceinfo_print("", traceinfo);
}
void cp_snr_t::init(const char* filename)
{
}
void cp_snr_t::process()
{
}
void cp_snr_t::process(const trace_t* trace)
{
pimpl.get()->snr.trace_submit(trace);
}
void cp_snr_t::finit()
{
pimpl.get()->snr.finit();
}
cp_snr_t::~cp_snr_t()
{}
| [
"madura.shelton@adelaide.edu.au"
] | madura.shelton@adelaide.edu.au |
87e5615c298be034b2fa8e730aeead1b33de34c5 | 727c574f0b5d84ae485b852ccf318063cc51772e | /ZOJ/ACM answer/ZJU Online Judge/1985/ZJU_1985.CPP | d25865fe33524f48623528f4f8e699084269a4dc | [] | no_license | cowtony/ACM | 36cf2202e3878a3dac1f15265ba8f902f9f67ac8 | 307707b2b2a37c58bc2632ef872dfccdee3264ce | refs/heads/master | 2023-09-01T01:21:28.777542 | 2023-08-04T03:10:23 | 2023-08-04T03:10:23 | 245,681,952 | 7 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 971 | cpp | #include <stdio.h>
#include <string.h>
#define maxn 100010
int n;
double list[maxn];
int prev[maxn] , next[maxn];
void init()
{
int i , key;
for(i=1; i<=n; i++)
{
scanf("%d" , &key);
list[i] = key;
}
}
void predoing()
{
int i , k;
list[0] = list[n+1] = -1;
prev[1] = 1;
for(i=2; i<=n; i++)
{
if(list[i - 1] < list[i])
{
prev[i] = i;
}
else
{
k = i;
while(list[k - 1] >= list[i])
{
k = prev[k - 1];
}
prev[i] = k;
}
}
next[n] = n;
for(i=n-1; i; i--)
{
if(list[i + 1] < list[i])
{
next[i] = i;
}
else
{
k = i;
while(list[k + 1] >= list[i])
{
k = next[k + 1];
}
next[i] = k;
}
}
}
void solve()
{
double max = 0;
double tmp;
int i;
for(i=1; i<=n; i++)
{
tmp = list[i] * ((i + 1 - prev[i]) + (next[i] - i + 1) - 1);
if(tmp > max) max = tmp;
}
printf("%0.lf\n" , max);
}
int main()
{
while(scanf("%d" , &n) , n)
{
init();
predoing();
solve();
}
return 0;
}
| [
"cowtony@163.com"
] | cowtony@163.com |
ffcd932373c2fc3c734c7796224b9b77c77e0c5a | 8a5a67fdf382f43477f3849daf2f0372be134e5b | /Algorithms/Graph/Bellman Ford Algorithm.cpp | 10821b86716e594d4edb664966153bfc8ff47560 | [] | no_license | akhilsaini678/All-Codes | bd57171bbf08e721c32f8fd30c26e05a02b6fd9f | 6c7c7fc345d9fbe68e78723d1703f618941aefb3 | refs/heads/master | 2023-07-12T08:50:44.918801 | 2021-08-22T05:31:30 | 2021-08-22T05:31:30 | 398,625,962 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,086 | cpp | #include<bits/stdc++.h>
using namespace std;
struct node {
int u;
int v;
int wt;
node(int first,int second,int third)
{
u=first;
v=second;
wt=third;
}
};
void solve()
{
int vertices,edge,u,v,count=0,weight;
cin>>vertices>>edge;
vector<node> graph;
vector<int> distance(vertices+1,1e9);
for(int i=0;i<edge;i++)
{
cin>>u>>v>>weight;
graph.push_back(node(u,v,weight));
}
for(int i=1;i<vertices;i++)
{
for(auto it:graph)
{
if(distance[it.u]+it.wt<distance[it.v])
{
distance[it.u]=it.wt+distance[it.v];
}
}
}
int flag=0;
for(auto it:graph)
{
if(distance[it.u]+it.wt<distance[it.v])
{
flag=1;
break;
}
}
if(flag==1)
cout<<"There is a negative edge cycle.";
else
cout<<"There is no negative edge cycle.";
}
void fast()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("D:\\Online\\Coding\\Contest\\input.txt","r",stdin);
freopen("D:\\Online\\Coding\\Contest\\output.txt","w",stdout);
#endif
}
int main()
{
fast();
int t=1;
cin>>t;
while(t--) solve();
return 0;
} | [
"akhilsaini678@gmail.com"
] | akhilsaini678@gmail.com |
1a24d6578ea280528171bf1f310073d07e114c9e | 6ef34eb0f4df4ac17bf4a38ff50640087e1137e6 | /src/shaka_scheme/runtime/stdproc/pairs_and_lists.cpp | 431778d42823834e131c1d765b96b96c82e3770b | [] | no_license | 1010jms/shaka-scheme | c1dcb37600d5ba2a9bf58c4bd5d4aed1a504d043 | da8525fa28819eaec3ed88cc2215d4c8d3b162a8 | refs/heads/master | 2021-04-30T16:34:24.519330 | 2018-04-28T02:03:32 | 2018-04-28T02:03:32 | 80,072,898 | 0 | 0 | null | 2017-01-26T00:40:37 | 2017-01-26T00:40:37 | null | UTF-8 | C++ | false | false | 14,328 | cpp | //
// Created by Kayla Kwock on 3/26/2018.
//
#include "shaka_scheme/runtime/stdproc/pairs_and_lists.hpp"
namespace shaka {
namespace stdproc {
namespace impl {
//(pair? ...)
Args is_pair(Args args) {
if (args.size() != 1) {
throw InvalidInputException(1,
"pair?: Invalid number of arguments for "
"procedure");
}
return {create_node(Data(Boolean(
args[0]->get_type() == Data::Type::DATA_PAIR)))};
}
//(cons ...)
Args cons(Args args) {
if (args.size() != 2) {
throw InvalidInputException(2,
"cons: Invalid number of arguments for "
"procedure");
}
return {create_node(Data(DataPair(Data(*args[0]),
Data(*args[1]))))
};
}
//(car ...)
Args car(Args args) {
if (args[0]->get_type() != Data::Type::DATA_PAIR) {
throw InvalidInputException(3,
"car: Type of given argument is not "
"DATA_PAIR");
}
if (args[0]->get_type() == Data::Type::NULL_LIST) {
throw InvalidInputException(4,
"car: Cannot return the car of"
"an empty list");
}
return {create_node(*args[0]->get<DataPair>().car())};
}
//(cdr ...)
Args cdr(Args args) {
if (args[0]->get_type() != Data::Type::DATA_PAIR) {
throw InvalidInputException(5,
"cdr: Type of given argument is not "
"DATA_PAIR");
}
if (args[0]->get_type() == Data::Type::NULL_LIST) {
throw InvalidInputException(6,
"cdr: Cannot return the cdr of"
"an empty list");
}
return {create_node(*args[0]->get<DataPair>().cdr())};
}
//(set-car! ...)
Args set_car(Args args) {
if (args[0]->get_type() != Data::Type::DATA_PAIR) {
throw InvalidInputException(10,
"set-car!: Type of given argument is not "
"DATA_PAIR");
}
if (args.size() != 2) {
throw InvalidInputException(11,
"set-car!: Invalid number of arguments given");
}
args[0]->get<DataPair>().set_car(args[1]);
return {create_unspecified()};
}
//(set-cdr! ...)
Args set_cdr(Args args) {
if (args[0]->get_type() != Data::Type::DATA_PAIR) {
throw InvalidInputException(12,
"set-cdr!: Type of given argument is not "
"DATA_PAIR");
}
if (args.size() != 2) {
throw InvalidInputException(13,
"set-cdr!: Invalid number of arguments given");
}
args[0]->get<DataPair>().set_cdr(args[1]);
return {create_unspecified()};
}
//(null? ...)
Args is_null(Args args) {
if (args.size() != 1) {
throw InvalidInputException(7,
"null?: Invalid number of arguments for "
"procedure");
}
return {create_node(Data(Boolean(
args[0]->get_type() == Data::Type::NULL_LIST)
))};
}
//(list? ...)
Args is_list(Args args) {
if (args.size() != 1) {
throw InvalidInputException(8,
"list?: Invalid number of arguments for "
"procedure");
}
if (args[0]->get_type() != Data::Type::DATA_PAIR) {
throw InvalidInputException(27,
"list?: Invalid number of arguments for "
"procedure");
}
return {create_node(Data(Boolean(core::is_proper_list(args[0]))))};
}
//(make-list ...)
Args make_list(Args args) {
// If the args given are either empty or have too many arguments
// Throw an error
if (args.size() > 2 || args.empty()) {
throw InvalidInputException(9,
"make-list: Invalid number of arguments for"
" procedure");
}
// Create an args to hold arguments for list
Args list_args;
// If a single argument is given
if (args.size() == 1) {
// If the type of the given argument is not a number
// Throw an error
if (args[0]->get_type() != Data::Type::NUMBER) {
throw InvalidInputException(15,
"make-list: Given argument is not of type "
"NUMBER");
}
// For the value of the given number
// Add a null list at the end
for (int i = 0; i < args[0]->get<Number>(); i++) {
list_args.push_back(create_node(Data()));
}
}
// Else when 2 arguments are given
else {
// Set the list head to the second argument given
// For the value of the first argument
// Append the value of the second argument
for (int i = 0; i < args[0]->get<Number>(); i++) {
list_args.push_back(args[1]);
}
}
// Return the resulting list as type Args
Args result{list(list_args)};
return result;
}
//(list ...)
Args list(Args args) {
// If the amount of given arguments exeedes the maximum capacity
// Throw an error
if (args.size() == sizeof(std::size_t)) {
throw InvalidInputException(14,
"list: Size of given argument exceeds "
"maximum size");
}
// If args is empty, return null list
if (args.size() == 0) {
return {create_node(Data())};
}
// Otherwise, args is not empty
else {
// Starting from the end, for each item in the args, the accumulated list
// starting as a null list
NodePtr list = core::list();
for (std::size_t i = args.size(); i > 0; i--) {
// Take the item, cons it with the accumulated list
list = core::cons(args[i - 1], list);
// Iterate
}
// Result: the args turned into a list
Args result{list};
// Then, return the list
return result;
}
}
//(length ...)
Args length(Args args) {
// If the given argument isn't a list
// Throw an error
if (args[0]->get_type() != Data::Type::DATA_PAIR) {
throw InvalidInputException(15,
"length:Type of given argument is "
"not DATA_PAIR");
}
// Create a variable set to the head of the given list
NodePtr head = create_node(*args[0]);
// Call (length) on list
std::size_t length = core::length(head);
// Create a variable of type Args to hold the length of the list
Args result{create_node(Number(Integer(length)))};
// Return the Args variable
return result;
}
//(append ...)
Args append(Args args) {
// Create a NodePtr at the given list
NodePtr list;
// If no args are given
if (args.empty()) {
// Set the list to an empty list
list = core::append();
}
// Else if one arg is given
else if (args.size() == 1) {
// Set the list to itself
list = core::append(args[0]);
}
// Else
else {
// Set list to the list provided
list = args[0];
// For each item given in the argument
for (std::size_t i = 1; i < args.size(); i++) {
// Add the item as a data pair at the end of the list
list = core::append(list, core::list(args[i]));
}
}
Args result{list};
// Return the new list
return result;
}
//(reverse ...)
Args reverse(Args args) {
// If anything but a single argument is given
// Throw an error
if(args.size() != 1){
throw InvalidInputException(17,
"reverse: Invalid number of arguments given");
}
// If the argument is not of type DATA_PAIR
// Throw an error
if(args[0]->get_type() != Data::Type::DATA_PAIR){
throw InvalidInputException(18,
"reverse: Given argument is not of type "
"DATA_PAIR");
}
// Return the reverse of the list
return {core::reverse(args[0])};
}
//(list-tail ...)
Args list_tail(Args args) {
// If exactly 2 arguments are not given
// Throw an error
if (args.size() != 2) {
throw InvalidInputException(19,
"list_tail: Invalid number of arguments given");
}
// If the first argument is not a DataPair
// Throw an error
if (args[0]->get_type() != Data::Type::DATA_PAIR){
throw InvalidInputException(20,
"list_tail: First argument must be of type "
"DATA_PAIR");
}
// If the second argument is not a number
// Throw an error
if (args[1]->get_type() != Data::Type::NUMBER){
throw InvalidInputException(21,
"list_tail: Second argument must be of type "
"NUMBER");
}
//if the second argument is not an integer or above 0 throw error
// Create a node at the head of the list
NodePtr list {args[0]};
// For the number of times given by the second argument
for(int i = 0; i < args[1]->get<Number>(); i++){
// If the number argument's value exceeds the length of the list argument
// Throw an error
if(list->get<DataPair>().cdr()->get_type() == Data::Type::NULL_LIST)
throw InvalidInputException(22,
"list_tail: Given index is not within "
"bounds of the list");
// Set the head to the rhs of the DataPair
list = list->get<DataPair>().cdr();
}
// Return the new head of the list
Args result {list};
return result;
}
//(list-ref ...)
Args list_ref(Args args) {
if(args.size() > 2 || args.empty()){
throw InvalidInputException(16,
"list-ref: Invalid number of arguments");
}
NodePtr place = args[0];
for(int i = 0; i < args[1]->get<Number>(); i++){
place = place->get<DataPair>().cdr();
}
Args result {place->get<DataPair>().car()};
return result;
}
//(list-set! ...)
Args list_set(Args args) {
// If exactly 3 arguments are not given
// Throw an error
if (args.size() != 3) {
throw InvalidInputException(23,
"list_set: Invalid number of arguments given");
}
// If the first argument is not a DataPair
// Throw an error
if (args[0]->get_type() != Data::Type::DATA_PAIR){
throw InvalidInputException(24,
"list_set: First argument must be of type "
"DATA_PAIR");
}
// If the second argument is not a number
// Throw an error
if (args[1]->get_type() != Data::Type::NUMBER){
throw InvalidInputException(25,
"list_set: Second argument must be of type "
"NUMBER");
}
//if the second argument is not an integer or above 0 throw error
// Create a node at the head of the list
NodePtr list {args[0]};
// For the number of times given by the second argument
for(int i = 0; i < args[1]->get<Number>() - 1; i++){
// If the number argument's value exceeds the length of the list argument
// Throw an error
if(list->get<DataPair>().cdr()->get_type() == Data::Type::NULL_LIST)
throw InvalidInputException(26,
"list_set: Given index is not within "
"bounds of the list");
// Set the head to the rhs of the DataPair
list = list->get<DataPair>().cdr();
}
// Set the car of the head to the desired value given in args
list->get<DataPair>().set_car(args[2]);
// Return the new list
Args result {args[0]};
return result;
}
/*
//(memq ...)
Args memq(Args args) {}
//(memv ...)
Args memv(Args args) {}
//(member ...)
Args member(Args args) {}
//(assq ...)
Args assq(Args args) {}
//(assv ...)
Args assv(Args args) {}
//(assoc ...)
Args assoc(Args args) {}
*/
//(list-copy ...)
Args list_copy(Args args) {
/**
* implement circular list error handling
*/
// If something else besides a list is given
// Return a copy of the argument given
if(args[0]->get_type() != Data::Type::DATA_PAIR){
Args result {shaka::create_node(*args[0])};
return result;
}
// Create a variable at the head of the list and an Args list
NodePtr head {args[0]};
Args list_args;
// While the cdr of the head is a DataPair
// Push a copy of the car value of head onto the Args list
// Set the new head to the cdr of the current head
while (head->get<DataPair>().cdr()->get_type() == Data::Type::DATA_PAIR) {
list_args.push_back(create_node(Data(*head->get<DataPair>().car())));
head = head->get<DataPair>().cdr();
}
// If the final cdr is a NullList (proper list)
// Push a copy of the car value of head onto the Args list
if(head->get<DataPair>().cdr()->get_type() == Data::Type::NULL_LIST){
list_args.push_back(create_node(Data(*head->get<DataPair>().car())));
}
// Else push a copy of the head onto the Args list (improper list)
else {
list_args.push_back(create_node(Data(*head)));
}
// Return a list of the Args list
return {stdproc::list(list_args)};
}
} // namespace impl
Callable is_pair = impl::is_pair;
Callable cons = impl::cons;
Callable car = impl::car;
Callable cdr = impl::cdr;
Callable set_car = impl::set_car;
Callable set_cdr = impl::set_cdr;
Callable is_null = impl::is_null;
Callable is_list = impl::is_list;
Callable make_list = impl::make_list;
Callable list = impl::list;
Callable length = impl::length;
Callable append = impl::append;
Callable reverse = impl::reverse;
Callable list_tail = impl::list_tail;
Callable list_ref = impl::list_ref;
Callable list_set = impl::list_set;
//Callable memq = impl::memq;
//Callable memv = impl::memv;
//Callable member = impl::member;
//Callable assq = impl::assq;
//Callable assv = impl::assv;
//Callable assoc = impl::assoc;
Callable list_copy = impl::list_copy;
} // namespace stdproc
} // namespace shaka | [
"VermillionAzure@users.noreply.github.com"
] | VermillionAzure@users.noreply.github.com |
5667bdea104bf27231f33b2e86a8c8ff1b27202c | 3ad985b16910bab038a57291782d16f290e4a004 | /Week_05/leetcode/052.n-queens.cc | 290b99105eb64d72d0310b4988851408a16ba1a3 | [] | no_license | osvimer/AlgorithmCHUNZHAO | 754c23855dd03c6d2ea260b55eed27c9b2fba1b6 | 650b3a833df99d400a59d55a33174e9639d5d16c | refs/heads/main | 2023-03-29T17:03:21.362666 | 2021-03-21T15:22:46 | 2021-03-21T15:22:46 | 330,702,738 | 0 | 0 | null | 2021-01-18T15:07:24 | 2021-01-18T15:07:23 | null | UTF-8 | C++ | false | false | 1,202 | cc | // n 皇后问题 研究的是如何将 n 个皇后放置在 n×n 的棋盘上,并且使皇后彼此之间不能相互攻击。
// 给你一个整数 n ,返回 n 皇后问题 不同的解决方案的数量。
// https://leetcode-cn.com/problems/n-queens-ii
// 思路:DFS + 位运算
// 三个整数 col_bits, pie_bits, naa_bits 记录列、撇、捺方向上皇后出现的情况。
class Solution {
public:
int totalNQueens(int n) {
dfs(n, 0);
return result;
}
void dfs(int n, int row) {
if (row >= n) {
result++;
return;
}
for (int col = 0; col < n; ++col) {
int pie = row - col + n - 1;
int naa = row + col;
if (((col_bits >> col) | (pie_bits >> pie) | (naa_bits >> naa)) & 1) {
continue;
}
col_bits |= (1 << col);
pie_bits |= (1 << pie);
naa_bits |= (1 << naa);
dfs(n, row + 1);
col_bits ^= (1 << col);
pie_bits ^= (1 << pie);
naa_bits ^= (1 << naa);
}
}
private:
int result = 0;
int col_bits = 0;
int pie_bits = 0;
int naa_bits = 0;
};
| [
"acmhjj@gmail.com"
] | acmhjj@gmail.com |
dbd6d85d4ec85fb2b7ffe405540bbd267794e6ea | 7ef7382554531e48bfcebe8f91d4f7bfee06de10 | /pikoc/samples/reyesPipe/sceneParser/sceneParser.cpp | ed1792692a30f9ad02416285944e54f22a7fe49d | [] | no_license | cwz920716/piko-public | 87ee4eba277294f9b388dcdbbbc564b24e5be37e | 02369208632d6a1183bdbfe7b2e96cbf0ba1e156 | refs/heads/master | 2021-05-15T12:39:56.156006 | 2018-02-18T04:27:20 | 2018-02-18T04:27:20 | 108,474,933 | 0 | 0 | null | 2017-10-26T23:07:32 | 2017-10-26T23:07:32 | null | UTF-8 | C++ | false | false | 12,811 | cpp | #ifdef WIN32
typedef unsigned int uint;
#endif
#include "sceneParser.h"
template<typename to, typename from>
inline to lexical_cast(from const &x) {
std::stringstream os;
to ret;
os << x;
os >> ret;
return ret;
}
inline void chompString(std::string& str){
std::string::size_type pos = str.find_last_not_of("\n\r");
if(pos != std::string::npos) {
str.erase(pos + 1);
pos = str.find_first_not_of("\n\r");
if(pos != std::string::npos) str.erase(0, pos);
}
else str.erase(str.begin(), str.end());
}
inline void trimString(std::string& str){
std::string::size_type pos = str.find_last_not_of(' ');
if(pos != std::string::npos) {
str.erase(pos + 1);
pos = str.find_first_not_of(' ');
if(pos != std::string::npos) str.erase(0, pos);
}
else str.erase(str.begin(), str.end());
}
// tokenize a string based on a set of single-char delimiters
inline void ltokenize(const std::string& str,const std::string& delimiters, std::list<std::string> &tokens)
{
tokens.clear();
// if empty, return empty
if(str=="") return;
// skip delimiters at beginning.
std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
// find first "non-delimiter".
std::string::size_type pos = str.find_first_of(delimiters, lastPos);
while (std::string::npos != pos || std::string::npos != lastPos)
{
// found a token, add it to the vector.
tokens.push_back(str.substr(lastPos, pos - lastPos));
// skip delimiters. Note the "not_of"
lastPos = str.find_first_not_of(delimiters, pos);
// find next "non-delimiter"
pos = str.find_first_of(delimiters, lastPos);
}
}
inline void vtokenize_degen(const std::string& str,const std::string& delimiters, std::vector<std::string> &tokens)
{
using namespace std;
tokens.clear();
string::size_type delimPos = 0, tokenPos = 0, pos = 0;
if(str.length()<1) return;
while(1){
delimPos = str.find_first_of(delimiters, pos);
tokenPos = str.find_first_not_of(delimiters, pos);
if(string::npos != delimPos){
if(string::npos != tokenPos){
if(tokenPos<delimPos){
tokens.push_back(str.substr(pos,delimPos-pos));
}else{
tokens.push_back("");
}
}else{
tokens.push_back("");
}
pos = delimPos+1;
} else {
if(string::npos != tokenPos){
tokens.push_back(str.substr(pos));
} else {
tokens.push_back("");
}
break;
}
}
}
// tokenize a string based on a set of single-char delimiters
inline void vtokenize(const std::string& str,const std::string& delimiters, std::vector<std::string> &tokens)
{
tokens.clear();
// if empty, return empty
if(str=="") return;
// skip delimiters at beginning.
std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
// find first "non-delimiter".
std::string::size_type pos = str.find_first_of(delimiters, lastPos);
while (std::string::npos != pos || std::string::npos != lastPos)
{
// found a token, add it to the vector.
tokens.push_back(str.substr(lastPos, pos - lastPos));
// skip delimiters. Note the "not_of"
lastPos = str.find_first_not_of(delimiters, pos);
// find next "non-delimiter"
pos = str.find_first_of(delimiters, lastPos);
}
}
bool sceneParser::fetchLine(){
if(sceneFile.good()){
getline(sceneFile, curLine);
return true;
}else
return false;
}
void sceneParser::processLine()
{
// process a line freshly
// trim any extra spaces
trimString(curLine);
// eliminate comments
string::size_type pos = curLine.find_first_of('#');
string noCommentsLine = curLine.substr(0, pos);
// tokenize
ltokenize(noCommentsLine, " \t", curTokens);
//test
//if(curTokens.size()>0) printf("Line: {%s}\n", noCommentsLine.c_str());
}
bool sceneParser::fetchNextToken(string& token){
// if you don't have any tokens,
// fetch next line
while(1){
if(curTokens.size()>0){
break;
}else{
if(fetchLine()) processLine();
else return false;
}
}
// the first token should be the command
token = curTokens.front();
curTokens.pop_front();
//printf("fetched %s\n", token.c_str());
return true;
}
bool sceneParser::fetchLeftBrace(){
string b;
if(fetchNextToken(b) && b=="["){
return true;
}else{
printf("\tCannot fetch '['\n");
return false;
}
}
bool sceneParser::fetchRightBrace(){
string b;
if(fetchNextToken(b) && b=="]"){
return true;
}else{
printf("\tCannot fetch ']'\n");
return false;
}
}
bool sceneParser::fetchString(string& s){
if(fetchNextToken(s)){
return true;
}else{
return false;
}
}
bool sceneParser::fetch1f(float& x){
string sx;
if(fetchNextToken(sx)){
x = lexical_cast<float, string>(sx);
return true;
}else{
printf("\tCannot fetch 1f\n");
return false;
}
}
bool sceneParser::fetch2f(float& x, float& y){
if( fetchLeftBrace() && fetch1f(x) && fetch1f(y) && fetchRightBrace()){
return true;
}else{
printf("\tCannot fetch 2f\n");
return false;
}
}
bool sceneParser::fetch3f(float& x, float& y, float& z){
if( fetchLeftBrace() && fetch1f(x) && fetch1f(y) && fetch1f(z) && fetchRightBrace()){
return true;
}else{
printf("\tCannot fetch 3f\n");
return false;
}
}
bool sceneParser::fetchCamera(){
float ex, ey, ez;
float ox, oy, oz;
float ux, uy, uz;
printf("[camera]\n"); //fflush(stdout);
if( fetch3f(ex, ey, ez) && fetch3f(ox, oy, oz) && fetch3f(ux, uy, uz) ){
curScene->cam().updateCam(gencvec3f(ex, ey, ez), gencvec3f(ox, oy, oz), gencvec3f(ux, uy, uz), PI/3.0f, 1.0f);
// fetch aperture etc:
float aperture, foc_length, foc_plane;
if( fetch3f(aperture, foc_length, foc_plane) ){
curScene->cam().aperture() = aperture;
curScene->cam().focallength() = foc_length;
curScene->cam().focalplane() = foc_plane;
}else{
printf("\t[pinhole]\n"); //fflush(stdout);
curScene->cam().aperture() = 0.0f;
curScene->cam().focallength() = 1.0f;
curScene->cam().focalplane() = 1.0f;
}
return true;
}else return false;
}
bool sceneParser::fetchLight(){
float px, py, pz;
float dr, dg, db;
float sr, sg, sb, sn;
printf("[light]\n"); //fflush(stdout);
if( fetch3f(px, py, pz) && fetch3f(dr, dg, db) && fetch3f(sr, sg, sb) && fetch1f(sn))
{
curScene->lights().push_back(light(gencvec3f(px,py,pz),gencvec3f(dr,dg,db),gencvec3f(0.0f,0.0f,0.0f),gencvec3f(sr,sg,sb),sn));
return true;
}else
return false;
}
bool sceneParser::fetchMaterial(){
float ar, ag, ab;
float dr, dg, db;
float sr, sg, sb, sn;
printf("[material]\n"); //fflush(stdout);
if( fetch3f(ar, ag, ab) && fetch3f(dr, dg, db) && fetch3f(sr, sg, sb) && fetch1f(sn)){
curMat = material(MAT_DIFFUSE, gencvec3f(dr,dg,db), gencvec3f(ar,ag,ab), gencvec3f(sr,sg,sb), sn);
curScene->mats().push_back(curMat);
return true;
}else return false;
}
bool sceneParser::fetchMeshAttribute(){
string attrname;
float attrval;
if( fetchString(attrname) && fetch1f(attrval)){
//printf("[attribute] %s\n",attrname.c_str());
curAttrs[attrname] = (int)attrval;
return true;
} else {
//printf("[attribute]\n"); fflush(stdout);
return false;
}
}
bool sceneParser::fetchTranslate(){
//printf("[translate]\n"); fflush(stdout);
float tx, ty, tz;
if( fetch3f(tx, ty, tz) ){
glTranslatef(tx, ty, tz);
return true;
}else return false;
}
bool sceneParser::fetchRotate(){
//printf("[rotate]\n"); fflush(stdout);
float rx, ry, rz, rt;
if( fetch3f(rx, ry, rz) && fetch1f(rt) ){
glRotatef(rt, rx, ry, rz);
return true;
}else return false;
}
bool sceneParser::fetchScale(){
//printf("[scale]\n"); fflush(stdout);
float sx, sy, sz;
if( fetch3f(sx, sy, sz) ){
glScalef(sx,sy,sz);
return true;
}else return false;
}
bool sceneParser::fetchTexture(){
//printf("[texture]\n"); fflush(stdout);
string texfile;
if( fetchString(texfile)){
//curScene->addTexture("textures/" + texfile);
return true;
}else return false;
}
bool sceneParser::fetchLoadbez()
{
printf("[loadbez]\n"); fflush(stdout);
string meshfile;
if( fetchString(meshfile)){
meshfile = basepath_ + "/meshes/" + meshfile;
bezmesh *m = new bezmesh(meshfile);
if(curScene->mats().size()==0)
curScene->mats().push_back(curMat);
m->matID() = curScene->mats().size()-1;
m->attributes() = curAttrs;
//apply current transformation to m
float viewmat[16], invviewmat[16];
glGetFloatv(GL_MODELVIEW_MATRIX, viewmat);
GenerateInverseMatrix4f(invviewmat, viewmat);
m->applyTransformation(viewmat, invviewmat);
curScene->addBezmesh(m);
return true;
}
return false;
}
bool sceneParser::fetchLoadmesh(){
printf("\t[loadmesh]\n"); fflush(stdout);
string meshfile;
if( fetchString(meshfile)){
meshfile = basepath_ + "/meshes/" + meshfile;
trimesh *m = new trimesh(meshfile);
//printf("loading %s\n", meshfile.c_str());
if(curScene->mats().size()==0)
curScene->mats().push_back(curMat);
m->matID() = curScene->mats().size()-1;
m->attributes() = curAttrs;
//apply current transformation to m
float viewmat[16], invviewmat[16];
glGetFloatv(GL_MODELVIEW_MATRIX, viewmat);
GenerateInverseMatrix4f(invviewmat, viewmat);
m->applyTransformation(viewmat, invviewmat);
curScene->addMesh(m);
return true;
}else return false;
}
bool sceneParser::fetchReset(){
//printf("[reset]\n"); fflush(stdout);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
return true;
}
bool sceneParser::fetchCommand(){
string cmd;
if(!fetchNextToken(cmd)){
return false;
}
if (cmd == "camera"){ return fetchCamera();
}else if(cmd == "camera_fov"){ return fetchCameraFov();
}else if(cmd == "zNear"){ return fetchZnear();
}else if(cmd == "zFar"){ return fetchZfar();
}else if(cmd == "light"){ return fetchLight();
}else if(cmd == "material"){ return fetchMaterial();
}else if(cmd == "translate"){ return fetchTranslate();
}else if(cmd == "rotate"){ return fetchRotate();
}else if(cmd == "scale"){ return fetchScale();
}else if(cmd == "loadmesh"){ return fetchLoadmesh();
}else if(cmd == "loadbez"){ return fetchLoadbez();
}else if(cmd == "reset"){ return fetchReset();
}else if(cmd == "meshAttribute"){ return fetchMeshAttribute();
}else if(cmd == "texture"){ return fetchTexture();
}else{
printf("Found dangling %s\n",cmd.c_str());
return false;
}
curTokens.clear();
return true;
}
bool sceneParser::fetchCameraFov(){
float fov;
printf("[camera_fov]\n"); //fflush(stdout);
if(fetch1f(fov)){
curScene->cam()._fovy = fov * PI/180.0f;
return true;
}else{
printf("\tCannot fetch fov\n");
return false;
}
}
bool sceneParser::fetchZnear(){
float znear; printf("[znear]\n");
if(fetch1f(znear)){ curScene->cam().zNear() = znear;
return true;
}else{
printf("\tCannot fetch znear\n");
return false;
}
}
bool sceneParser::fetchZfar(){
float zfar; printf("[zfar]\n");
if(fetch1f(zfar)){ curScene->cam().zFar() = zfar;
return true;
}else{
printf("\tCannot fetch zfar\n");
return false;
}
}
void sceneParser::parseFile(string basepath, string filename, scene* sc)
{
basepath_ = basepath;
filename = basepath_ + "/scenes/" + filename;
printf("Reading %s\n",filename.c_str());
sceneFile.open(filename.c_str());
if(!sceneFile.is_open()){
printf("Cannot open %s\n", filename.c_str());
return;
}
curScene = sc;
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
while(fetchCommand());
glPopMatrix();
printf("\n");
}
| [
"anonymous"
] | anonymous |
cb7057e6c9bc33546b0f0ea45d94b70419d4a80b | c1f89beed3118eed786415e2a6d378c28ecbf6bb | /src/inc/holderinst.h | 952a91d8070acd5213cfc97b61f6b1e483c493b9 | [
"MIT"
] | permissive | mono/coreclr | 0d85c616ffc8db17f9a588e0448f6b8547324015 | 90f7060935732bb624e1f325d23f63072433725f | refs/heads/mono | 2023-08-23T10:17:23.811021 | 2019-03-05T18:50:49 | 2019-03-05T18:50:49 | 45,067,402 | 10 | 4 | NOASSERTION | 2019-03-05T18:50:51 | 2015-10-27T20:15:09 | C# | UTF-8 | C++ | false | false | 902 | h | //
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
#ifndef __HOLDERINST_H_
#define __HOLDERINST_H_
// This file contains holder instantiations which we can't put in holder.h because
// the instantiations require _ASSERTE to be defined, which is not always the case
// for placed that include holder.h.
FORCEINLINE void SafeArrayRelease(SAFEARRAY* p)
{
SafeArrayDestroy(p);
}
class SafeArrayHolder : public Wrapper<SAFEARRAY*, SafeArrayDoNothing, SafeArrayRelease, NULL>
{
public:
SafeArrayHolder(SAFEARRAY* p = NULL)
: Wrapper<SAFEARRAY*, SafeArrayDoNothing, SafeArrayRelease, NULL>(p)
{
}
FORCEINLINE void operator=(SAFEARRAY* p)
{
Wrapper<SAFEARRAY*, SafeArrayDoNothing, SafeArrayRelease, NULL>::operator=(p);
}
};
#endif // __HOLDERINST_H_
| [
"dotnet-bot@microsoft.com"
] | dotnet-bot@microsoft.com |
2535ecdc265061456a06882825aca3c8e0c96d2e | ad33f4f862f94cdeb9ac7223f19046c3e956dceb | /Lista5/exe1.cpp | 32d996e0a4dfa2ef55315cdd971d7a7ca31edc8d | [
"MIT"
] | permissive | nathalyoliveira/LG1-IFSP | 3cbe0b30a35f298cec7e088ca6ecd06db879b474 | b072c916f71a8b5924a766d8b6fa4e0a481faa64 | refs/heads/main | 2023-02-28T21:52:15.214172 | 2021-02-03T18:15:02 | 2021-02-03T18:15:02 | 335,711,706 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 382 | cpp | #include<stdio.h>
#include<conio.h>
int main()
{
int a[12],i, j,x;
for (i=0;i<12;++i)
{puts("DIGITE OS VALORES DO VETOR A:");
scanf("%d", &a[i]);}
for(i=0;i<12;++i)
for(j=i+1;j<12;++j)
if(a[i]<a[j])
{x=a[i];
a[i]=a[j];
a[j]=x;}
for(i=0;i<12;++i)
{ printf("MATRIZ DECRESCENTE: %d\n", a[i]);}
getch ();
return 0;
}
| [
"73591609+nathalyoliveira@users.noreply.github.com"
] | 73591609+nathalyoliveira@users.noreply.github.com |
203705e60e19ddd68c3d8a201dc6a093147992ff | 70f46db7f53566a63063356386bcc1f7ff88309c | /include/JavaScriptCore/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h | 220fff3e3bf54341e961c82df8c4e8c9000734be | [
"Apache-2.0"
] | permissive | openkraken/jsc | 79510114c028f98912e0021c27081ae98c660f27 | 05f661f9b44ad655486c9a1d61f50eb958eb2c89 | refs/heads/master | 2023-05-27T20:24:59.730326 | 2021-06-01T12:55:44 | 2021-06-01T12:55:44 | 356,278,322 | 4 | 1 | Apache-2.0 | 2021-04-30T07:54:54 | 2021-04-09T13:20:25 | C++ | UTF-8 | C++ | false | false | 2,205 | h | /*
* Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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.
*/
#pragma once
#include "BytecodeStructs.h"
#include "CodeBlock.h"
#include "ObjectPropertyCondition.h"
#include "PackedCellPtr.h"
#include "Watchpoint.h"
namespace JSC {
class LLIntPrototypeLoadAdaptiveStructureWatchpoint final : public Watchpoint {
public:
LLIntPrototypeLoadAdaptiveStructureWatchpoint(CodeBlock*, const ObjectPropertyCondition&, unsigned bytecodeOffset);
void install(VM&);
static void clearLLIntGetByIdCache(OpGetById::Metadata&);
const ObjectPropertyCondition& key() const { return m_key; }
void fireInternal(VM&, const FireDetail&);
private:
// Own destructor may not be called. Keep members trivially destructible.
JSC_WATCHPOINT_FIELD(PackedCellPtr<CodeBlock>, m_owner);
JSC_WATCHPOINT_FIELD(Packed<unsigned>, m_bytecodeOffset);
JSC_WATCHPOINT_FIELD(ObjectPropertyCondition, m_key);
};
} // namespace JSC
| [
"chenghuai.dtc@alibaba-inc.com"
] | chenghuai.dtc@alibaba-inc.com |
7bae0901499902d7c191d5b02a0fd980c0f7947b | 12a9a9112f2edd055a74efe915c6a50e856f3b55 | /9-Palindrome-Number/solution.cpp | 28b4404cfb37bdff467c5d90f7e2fbdc89eea5ef | [] | no_license | kid7st/Leetcode | e97e2df3f7fe3adb689a5151fc0f61030bcd7616 | a35cd5749992394b14e498445743921712367543 | refs/heads/master | 2021-06-01T04:36:40.691835 | 2016-07-25T17:12:12 | 2016-07-25T17:12:12 | 54,577,596 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 381 | cpp | class Solution {
public:
bool isPalindrome(int x) {
if(x < 0) return false;
int size = log10(x);
int max = pow(10, size);
int offset = 1;
for(int i = 0; i < (size + 1)/2; i++){
if((x % (10*offset) / offset) != (x / (max / offset) % 10)) return false;
offset *= 10;
}
return true;
}
}; | [
"kid7st@gmail.com"
] | kid7st@gmail.com |
e8eee3936a7df3057b0f4a26f860fb301cb2c5ce | f495530040281b02a9e7caed48b89123c45a2edb | /SDK/progressivePhotonMap/PpmObjLoader.cpp | ba8b7a29c1f97e46a590b44e17bbca04a0b16963 | [] | no_license | zengxinlu/chip | 680655d0759852839ed25e324093ffd09218bee7 | 0c86ff6a3e7be49c9787f122b58c6f08b9cc54a2 | refs/heads/master | 2021-01-18T03:53:42.633847 | 2017-04-24T11:45:40 | 2017-04-24T11:45:40 | 85,775,844 | 0 | 1 | null | 2017-04-24T11:45:41 | 2017-03-22T02:25:50 | C | GB18030 | C++ | false | false | 18,951 | cpp |
/*
* Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property and proprietary
* rights in and to this software, related documentation and any modifications thereto.
* Any use, reproduction, disclosure or distribution of this software and related
* documentation without an express license agreement from NVIDIA Corporation is strictly
* prohibited.
*
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
* INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
* SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
* BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
* INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES
*/
#include <ImageLoader.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cassert>
#include <string.h>
#include <set>
#include <map>
#include "PpmObjLoader.h"
using namespace optix;
//------------------------------------------------------------------------------
//
// Helper functions
//
//------------------------------------------------------------------------------
namespace
{
std::string getExtension( const std::string& filename )
{
// Get the filename extension
std::string::size_type extension_index = filename.find_last_of( "." );
return extension_index != std::string::npos ?
filename.substr( extension_index+1 ) :
std::string();
}
}
//------------------------------------------------------------------------------
//
// PpmObjLoader class definition
//
//------------------------------------------------------------------------------
void PpmObjLoader::initialization()
{
useTriangleTopology = true;
m_pathname = m_filename.substr(0,m_filename.find_last_of("/\\")+1);
}
PpmObjLoader::PpmObjLoader( const std::string& filename,
Context context,
GeometryGroup geometrygroup,
Material material )
: m_filename( filename ),
m_context( context ),
m_geometrygroup( geometrygroup ),
m_vbuffer( 0 ),
m_nbuffer( 0 ),
m_tbuffer( 0 ),
m_material( material ),
m_have_default_material( true ),
m_aabb()
{
initialization();
}
PpmObjLoader::PpmObjLoader( const std::string& filename,
Context context,
GeometryGroup geometrygroup )
: m_filename( filename ),
m_context( context ),
m_geometrygroup( geometrygroup ),
m_vbuffer( 0 ),
m_nbuffer( 0 ),
m_tbuffer( 0 ),
m_material( 0 ),
m_have_default_material( false ),
m_aabb()
{
initialization();
}
void PpmObjLoader::unload()
{
glmDelete( model );
delete vertexIndexTablePtr;
delete triangleIndexTablePtr;
delete pointsTriangleMap;
}
void PpmObjLoader::buildVertexIndex()
{
// For glmModel index 0 is null as index starts from 1 not 0
vertexIndexTablePtr = new std::vector<std::vector<int>>(model->numvertices, std::vector<int>());
std::vector<std::vector<int>>& vertexIndexTable = *vertexIndexTablePtr;
int max_edge_num = 1;
for (int i = 0;i < model->numtriangles;i ++)
{
unsigned int v_index = model->triangles[i].vindices[0] - 1;
vertexIndexTable[v_index].push_back(i);
if (vertexIndexTable[v_index].size() > max_edge_num) max_edge_num = vertexIndexTable[v_index].size();
v_index = model->triangles[i].vindices[1] - 1;
vertexIndexTable[v_index].push_back(i);
if (vertexIndexTable[v_index].size() > max_edge_num) max_edge_num = vertexIndexTable[v_index].size();
v_index = model->triangles[i].vindices[2] - 1;
vertexIndexTable[v_index].push_back(i);
if (vertexIndexTable[v_index].size() > max_edge_num) max_edge_num = vertexIndexTable[v_index].size();
}
}
void PpmObjLoader::depthFirstSearchTriangle(int curTriangle, std::set<int> &curSet, std::vector<int> &curIndexTable, int m_depth)
{
for (int ipass = 0;ipass < 3;ipass ++)
{
std::vector<int> &aVertexTable = vertexIndexTablePtr->at(model->triangles[curTriangle].vindices[ipass] - 1);
for (int i = 0;i < aVertexTable.size();i ++)
{
// First nearby
int tempTriangleIndexFirst = aVertexTable[i];
if (curSet.find(tempTriangleIndexFirst) != curSet.end())
continue;
curSet.insert(tempTriangleIndexFirst);
curIndexTable.push_back(tempTriangleIndexFirst);
if (m_depth > 1)
depthFirstSearchTriangle(tempTriangleIndexFirst, curSet, curIndexTable, m_depth - 1);
}
}
}
void PpmObjLoader::buildTriangleIndexTable()
{
triangleIndexTablePtr = new std::vector<std::vector<int>>(model->numtriangles, std::vector<int>());
pointsTriangleMap = new std::map<StructTriangleIndex3, int>();
std::vector<std::set<int>> triangleIndexSet(model->numtriangles, std::set<int>());
for (int curTriangle = 0;curTriangle < model->numtriangles;curTriangle ++)
{
StructTriangleIndex3 pointsIndex = make_STI3(model->triangles[curTriangle].vindices[0] - 1,
model->triangles[curTriangle].vindices[1] - 1,
model->triangles[curTriangle].vindices[2] - 1);
if (pointsTriangleMap->find(pointsIndex) != pointsTriangleMap->end())
int my_debug = 0;
pointsTriangleMap->insert(std::pair<StructTriangleIndex3, int>(pointsIndex, curTriangle));
std::set<int> &curSet = triangleIndexSet[curTriangle];
std::vector<int> &curIndexTable = triangleIndexTablePtr->at(curTriangle);
depthFirstSearchTriangle(curTriangle, curSet, curIndexTable, 1);
}
delete vertexIndexTablePtr;
}
void PpmObjLoader::load(int Myron_PPM, int Neighbor_2)
{
m_neighbor = Neighbor_2;
// parse the OBJ file
model = glmReadOBJ( m_filename.c_str() );
if (useUnitization)
glmUnitize(model);
if ( !model ) {
std::stringstream ss;
ss << "PpmObjLoader::loadImpl - glmReadOBJ( '" << m_filename << "' ) failed" << std::endl;
throw Exception( ss.str() );
}
if (Myron_PPM)
{
double t0, t1, s_myron, e_myron;
sutilCurrentTime( &s_myron );
/// 建立从顶点到其相邻三角面的索引
buildVertexIndex();
/// 建立从三角面到其邻域三角面的索引
if (useTriangleTopology)
buildTriangleIndexTable();
sutilCurrentTime( &e_myron );
printf("total %lf\n\n", e_myron - s_myron);
}
// Create a single material to be shared by all GeometryInstances
createMaterial();
// Create vertex data buffers to be shared by all Geometries
loadVertexData( model );
// Load triange_mesh programs
std::string path = std::string(sutilSamplesPtxDir()) + "/progressivePhotonMap_generated_triangle_mesh.cu.ptx";
Program mesh_intersect = m_context->createProgramFromPTXFile( path, "mesh_intersect" );
Program mesh_bbox = m_context->createProgramFromPTXFile( path, "mesh_bounds" );
// Create a GeometryInstance and Geometry for each obj group
createMaterialParams( model );
createGeometryInstances( model, mesh_intersect, mesh_bbox );
return;
}
void PpmObjLoader::createMaterial()
{
if ( m_have_default_material ) return;
std::string path1 = std::string(sutilSamplesPtxDir()) + "/progressivePhotonMap_generated_ppm_rtpass.cu.ptx";
std::string path2 = std::string(sutilSamplesPtxDir()) + "/progressivePhotonMap_generated_ppm_ppass.cu.ptx";
std::string path3 = std::string(sutilSamplesPtxDir()) + "/progressivePhotonMap_generated_ppm_gather.cu.ptx";
Program closest_hit1 = m_context->createProgramFromPTXFile( path1, "rtpass_closest_hit" );
Program closest_hit2 = m_context->createProgramFromPTXFile( path2, "global_ppass_closest_hit" );
Program closest_hit3 = m_context->createProgramFromPTXFile( path2, "caustics_ppass_closest_hit" );
Program any_hit = m_context->createProgramFromPTXFile( path3, "gather_any_hit" );
m_material = m_context->createMaterial();
/*RayTypeShadowRay = 0,
RayTypeRayTrace,
RayTypeCausticsPass,
RayTypeGlobalPass,
RayTypeNum*/
m_material->setClosestHitProgram( 1u, closest_hit1 );
m_material->setClosestHitProgram( 3u, closest_hit2 );
m_material->setClosestHitProgram( 2u, closest_hit3 );
m_material->setAnyHitProgram( 0u, any_hit );
}
void PpmObjLoader::loadVertexData( GLMmodel* model )
{
unsigned int num_vertices = model->numvertices;
unsigned int num_texcoords = model->numtexcoords;
unsigned int num_normals = model->numnormals;
// Create vertex buffer
m_vbuffer = m_context->createBuffer( RT_BUFFER_INPUT, RT_FORMAT_FLOAT3, num_vertices );
float3* vbuffer_data = static_cast<float3*>( m_vbuffer->map() );
// Create normal buffer
m_nbuffer = m_context->createBuffer( RT_BUFFER_INPUT, RT_FORMAT_FLOAT3, num_normals );
float3* nbuffer_data = static_cast<float3*>( m_nbuffer->map() );
// Create texcoord buffer
m_tbuffer = m_context->createBuffer( RT_BUFFER_INPUT, RT_FORMAT_FLOAT2, num_texcoords );
float2* tbuffer_data = static_cast<float2*>( m_tbuffer->map() );
// Copy vertex, normal and texcoord arrays into buffers
memcpy( static_cast<void*>( vbuffer_data ),
static_cast<void*>( &(model->vertices[3]) ),
sizeof( float )*num_vertices*3 );
memcpy( static_cast<void*>( nbuffer_data ),
static_cast<void*>( &(model->normals[3]) ),
sizeof( float )*num_normals*3 );
memcpy( static_cast<void*>( tbuffer_data ),
static_cast<void*>( &(model->texcoords[2]) ),
sizeof( float )*num_texcoords*2 );
m_vbuffer->unmap();
m_nbuffer->unmap();
m_tbuffer->unmap();
// Calculate bbox of model
for ( unsigned int i = 1u; i <= num_vertices; ++i )
{
unsigned int index = i*3u;
float3 t;
t.x = model->vertices[ index + 0u ];
t.y = model->vertices[ index + 1u ];
t.z = model->vertices[ index + 2u ];
m_aabb.include( t );
}
}
void PpmObjLoader::get_triangle_aabb(GLMmodel* model, optix::int3& vindices, optix::float3& m_max, optix::float3& m_min) {
float* point_start = &(model->vertices[3]);
float3 p1 = make_float3(point_start[vindices.x*3], point_start[vindices.x*3+1], point_start[vindices.x*3+2]);
float3 p2 = make_float3(point_start[vindices.y*3], point_start[vindices.y*3+1], point_start[vindices.y*3+2]);
float3 p3 = make_float3(point_start[vindices.z*3], point_start[vindices.z*3+1], point_start[vindices.z*3+2]);
m_max = fmaxf(p1, p2);
m_min = fminf(p1, p2);
m_max = fmaxf(m_max, p3);
m_min = fminf(m_min, p3);
}
void PpmObjLoader::createGeometryInstances( GLMmodel* model,
Program mesh_intersect,
Program mesh_bbox )
{
std::vector<GeometryInstance> instances;
// Loop over all groups -- grab the triangles and material props from each group
unsigned int triangle_count = 0u;
unsigned int group_count = 0u;
for ( GLMgroup* obj_group = model->groups;
obj_group != 0;
obj_group = obj_group->next, group_count++ ) {
unsigned int num_triangles = obj_group->numtriangles;
if ( num_triangles == 0 ) continue;
// Create vertex index buffers
Buffer vindex_buffer = m_context->createBuffer( RT_BUFFER_INPUT, RT_FORMAT_INT3, num_triangles );
int3* vindex_buffer_data = static_cast<int3*>( vindex_buffer->map() );
Buffer tindex_buffer = m_context->createBuffer( RT_BUFFER_INPUT, RT_FORMAT_INT3, num_triangles );
int3* tindex_buffer_data = static_cast<int3*>( tindex_buffer->map() );
Buffer nindex_buffer = m_context->createBuffer( RT_BUFFER_INPUT, RT_FORMAT_INT3, num_triangles );
int3* nindex_buffer_data = static_cast<int3*>( nindex_buffer->map() );
Buffer tagindex_buffer = m_context->createBuffer( RT_BUFFER_INPUT, RT_FORMAT_INT, num_triangles );
int* tagindex_buffer_data = static_cast<int*>( tagindex_buffer->map() );
// TODO: Create empty buffer for mat indices, have obj_material check for zero length
Buffer mbuffer = m_context->createBuffer( RT_BUFFER_INPUT, RT_FORMAT_UNSIGNED_INT, num_triangles );
uint* mbuffer_data = static_cast<uint*>( mbuffer->map() );
// Create the mesh object
Geometry mesh = m_context->createGeometry();
mesh->setPrimitiveCount( num_triangles );
mesh->setIntersectionProgram( mesh_intersect);
mesh->setBoundingBoxProgram( mesh_bbox );
mesh[ "vertex_buffer" ]->setBuffer( m_vbuffer );
mesh[ "normal_buffer" ]->setBuffer( m_nbuffer );
mesh[ "texcoord_buffer" ]->setBuffer( m_tbuffer );
mesh[ "vindex_buffer" ]->setBuffer( vindex_buffer );
mesh[ "tindex_buffer" ]->setBuffer( tindex_buffer );
mesh[ "nindex_buffer" ]->setBuffer( nindex_buffer );
mesh[ "tagindex_buffer" ]->setBuffer( tagindex_buffer );
mesh[ "material_buffer" ]->setBuffer( mbuffer );
// Create the geom instance to hold mesh and material params
GeometryInstance instance = m_context->createGeometryInstance( mesh, &m_material, &m_material+1 );
mesh[ "need_unsurface" ]->setUint( loadMaterialParams( instance, obj_group->material ) );
instances.push_back( instance );
float3 m_Obj_max = m_aabb.m_min, m_Obj_min = m_aabb.m_max;
for ( unsigned int i = 0; i < obj_group->numtriangles; ++i, ++triangle_count ) {
unsigned int tindex = obj_group->triangles[i];
int3 vindices;
vindices.x = model->triangles[ tindex ].vindices[0] - 1;
vindices.y = model->triangles[ tindex ].vindices[1] - 1;
vindices.z = model->triangles[ tindex ].vindices[2] - 1;
float3 temp_max, temp_min;
get_triangle_aabb(model, vindices, temp_max, temp_min);
m_Obj_max = fmaxf(m_Obj_max, temp_max);
m_Obj_min = fminf(m_Obj_min, temp_min);
int3 nindices;
nindices.x = model->triangles[ tindex ].nindices[0] - 1;
nindices.y = model->triangles[ tindex ].nindices[1] - 1;
nindices.z = model->triangles[ tindex ].nindices[2] - 1;
int3 tindices;
tindices.x = model->triangles[ tindex ].tindices[0] - 1;
tindices.y = model->triangles[ tindex ].tindices[1] - 1;
tindices.z = model->triangles[ tindex ].tindices[2] - 1;
vindex_buffer_data[ i ] = vindices;
nindex_buffer_data[ i ] = nindices;
tindex_buffer_data[ i ] = tindices;
tagindex_buffer_data[i] = tindex;
mbuffer_data[ i ] = 0; // See above TODO
}
MatParams& mp = m_material_params[obj_group->material];
if (mp.alpha < 1.f || fmaxf(mp.Ks) > 0.1f || mp.Kf > 1.0f) // Refract or reflect
//if (mp.name == "glass")
{
m_Caustics_Max.push_back(m_Obj_max);
m_Caustics_Min.push_back(m_Obj_min);
float3 boxSide = m_Obj_max - m_Obj_min;
volumeArray.push_back(
// boxSide.x*boxSide.y + boxSide.x*boxSide.z + boxSide.y*boxSide.z
double(m_Obj_max.x - m_Obj_min.x)*(m_Obj_max.y - m_Obj_min.y)*(m_Obj_max.z - m_Obj_min.z)
);
}
vindex_buffer->unmap();
tindex_buffer->unmap();
nindex_buffer->unmap();
tagindex_buffer->unmap();
mbuffer->unmap();
}
volumeSum = 0;
for (std::vector<float>::iterator it = volumeArray.begin();it!=volumeArray.end();it++)
volumeSum += *it;
assert( triangle_count == model->numtriangles );
// Set up group
Acceleration acceleration = m_context->createAcceleration("Sbvh","Bvh");
acceleration->setProperty( "vertex_buffer_name", "vertex_buffer" );
acceleration->setProperty( "index_buffer_name", "vindex_buffer" );
m_geometrygroup->setAcceleration( acceleration );
acceleration->markDirty();
unsigned int total_instances_num = static_cast<unsigned int>(instances.size());
if (m_light_instance.get() != 0)
total_instances_num ++;
m_geometrygroup->setChildCount( total_instances_num );
for ( unsigned int i = 0; i < instances.size(); ++i )
m_geometrygroup->setChild( i, instances[i] );
if (m_light_instance.get() != 0)
m_geometrygroup->setChild( instances.size(), m_light_instance );
}
bool PpmObjLoader::isMyFile( const std::string& filename )
{
return getExtension( filename ) == "obj";
}
int PpmObjLoader::loadMaterialParams( GeometryInstance gi, unsigned int index )
{
// We dont need any material params if we have default material
if ( m_have_default_material ) {
return 0;
}
// If no materials were given in model use reasonable defaults
if ( m_material_params.empty() ) {
std::cout << " PpmPpmObjLoader not setup to use material override yet! " << std::endl;
gi[ "emissive" ]->setFloat( 0.0f, 0.0f, 0.0f );
gi[ "phong_exp" ]->setFloat( 32.0f );
gi[ "reflectivity" ]->setFloat( 0.3f, 0.3f, 0.3f );
gi[ "illum" ]->setInt( 2 );
gi[ "Alpha" ]->setFloat( 1 );
gi["ambient_map"]->setTextureSampler( loadTexture( m_context, "", make_float3( 0.2f, 0.2f, 0.2f ) ) );
gi["diffuse_map"]->setTextureSampler( loadTexture( m_context, "", make_float3( 0.8f, 0.8f, 0.8f ) ) );
gi["specular_map"]->setTextureSampler( loadTexture( m_context, "", make_float3( 0.0f, 0.0f, 0.0f ) ) );
return 0;
}
// Load params from this material into the GI
if ( index < m_material_params.size() ) {
MatParams& mp = m_material_params[index];
gi["ambient_map"]->setTextureSampler( mp.ambient_map );
gi["diffuse_map"]->setTextureSampler( mp.diffuse_map );
gi["specular_map"]->setTextureSampler( mp.specular_map );
gi[ "emitted" ]->setFloat( 0.0f, 0.0f, 0.0f );
gi[ "Alpha" ]->setFloat( mp.alpha );
gi[ "Kd" ]->setFloat( mp.Kd );
gi[ "Ks" ]->setFloat( mp.Ks );
gi[ "grid_color" ]->setFloat( 0.5f, 0.5f, 0.5f );
gi[ "use_grid" ]->setUint( mp.name == "01_-_Default" ? 1u : 0 );
// Need to be un surface
if (mp.Ka.x > 0.f && fabs(mp.Ka.y) < 0.0001f && fabs(mp.Ka.z) < 0.0001f)
return 1;
return 0;
}
// Should never reach this point
std::cout << "WARNING -- PpmObjLoader::loadMaterialParams given index out of range: "
<< index << std::endl;
return 0;
}
void PpmObjLoader::createMaterialParams( GLMmodel* model )
{
m_material_params.resize( model->nummaterials );
for ( unsigned int i = 0; i < model->nummaterials; ++i ) {
GLMmaterial& mat = model->materials[i];
MatParams& params = m_material_params[i];
/*
params.emissive = make_float3( mat.emmissive[0], mat.emmissive[1], mat.emmissive[2] );
params.reflectivity = make_float3( mat.specular[0], mat.specular[1], mat.specular[2] );
params.phong_exp = mat.shininess;
params.illum = ( (mat.shader > 3) ? 2 : mat.shader ); // use 2 as default if out-of-range
*/
float3 Kd = make_float3( mat.diffuse[0],
mat.diffuse[1],
mat.diffuse[2] );
float3 Ka = make_float3( mat.ambient[0],
mat.ambient[1],
mat.ambient[2] );
float3 Ks = make_float3( mat.specular[0],
mat.specular[1],
mat.specular[2] );
params.Ka = Ka;
params.Kd = Kd;
params.Ks = Ks;
params.Kf = mat.refraction;
params.name = mat.name;
params.alpha = mat.alpha;
// load textures relatively to OBJ main file
std::string ambient_map = strlen(mat.ambient_map) ? m_pathname + mat.ambient_map : "";
std::string diffuse_map = strlen(mat.diffuse_map) ? m_pathname + mat.diffuse_map : "";
std::string specular_map = strlen(mat.specular_map) ? m_pathname + mat.specular_map : "";
params.ambient_map = loadTexture( m_context, ambient_map, Ka );
params.diffuse_map = loadTexture( m_context, diffuse_map, Kd );
params.specular_map = loadTexture( m_context, specular_map, Ks );
}
}
| [
"lovevvcy@163.com"
] | lovevvcy@163.com |
41b6e0b352cfdc63409d01c3a70270125c66d58f | 5db5a5a053ef2c572c115f4ac36bfefa00e28379 | /POJ/POJ1422.cpp | 55f234ddf85cf18ef18808c9a27e4e6ff4514ef2 | [] | no_license | CaptainSlowWZY/OI-Code | 4491dfa40aae4af148db2dd529556a229a1e76af | be470914186b27d8b24177fb9b5d01d4ac55cd51 | refs/heads/master | 2020-03-22T08:36:19.753282 | 2019-12-19T08:22:51 | 2019-12-19T08:22:51 | 139,777,376 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,142 | cpp | // POJ 1422
#include <cstdio>
#include <cstring>
#ifdef DEBUG_MD
#define debug(format, ...) fprintf(stderr, format, __VA_ARGS__)
#else
#define debug(format, ...) 0
#endif
const int MAXN = 125;
const int MAXE = 60 * 119 + 10;
struct Edge {
int to, next;
} E[MAXE];
int N, M, tote, last[MAXN], match[MAXN], vis[MAXN];
void solve();
int main() {
int t;
for (scanf("%d", &t); t--; ) solve();
return 0;
}
bool dfs(int u) {
for (int v, e = last[u]; e; e = E[e].next) {
if (vis[v = E[e].to]) continue;
vis[v] = 1;
if (match[v] == -1 || dfs(match[v])) {
match[v] = u;
return true;
}
}
return false;
}
inline void add_edge(int u, int v) {
E[++tote] = (Edge){v, last[u]}, last[u] = tote;
}
void solve() {
tote = 0;
memset(last, 0, sizeof last);
memset(match, 0xff, sizeof match);
scanf("%d%d", &N, &M);
for (int i = 0, xi, yi; i < M; i++) {
scanf("%d%d", &xi, &yi);
add_edge(xi, yi);
}
int ans = N;
for (int i = 1; i <= N; i++) {
memset(vis, 0, sizeof vis);
if (dfs(i)) --ans;
}
#ifdef DEBUG_MD
for (int i = 1; i <= N; i++) debug(" %d --match-> %d\n", i, match[i]);
#endif
printf("%d\n", ans);
}
| [
"CaptainSlowWZY@163.com"
] | CaptainSlowWZY@163.com |
336a16ee5c93899eba9dd47be826c27db34df1f2 | d8c56ab76e74824ecff46e2508db490e35ad6076 | /ZETLAB/ZETTools/Interface2012/ZetLab/Panel.h | 517ad2c5618767532b9f84e03fb2a2476a34b83b | [] | no_license | KqSMea8/UtilsDir | b717116d9112ec9f6ee41f4882ad3f52ebb2e84b | 14720766a2a60368495681d09676f860ea501df2 | refs/heads/master | 2020-04-25T17:21:39.538945 | 2019-02-27T14:36:32 | 2019-02-27T14:36:32 | null | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 2,875 | h | //------------------------------------------------------------------------------
// Panel.h : файл заголовка
//------------------------------------------------------------------------------
// Класс элемента Panel
//------------------------------------------------------------------------------
#pragma once
#include "C:\ZETTools\Interface2012\Custom\CustomContainer.h"
#include "C:\ZETTools\Interface2012\Draw\DPanel.h"
//------------------------------------------------------------------------------
class CPanel : public CCustomContainer
{
public:
CPanel(CCustomContainer *owner, CRect rect);
virtual ~CPanel();
private:
CDPanel *m_pDPanel;
protected:
public:
// функции параметров отображения
int GetBorderHeight() { return m_pDPanel->GetBorderHeight(); }
void SetBorderHeight(int val) { m_pDPanel->SetBorderHeight(val); }
int GetBorderRadius() { return m_pDPanel->GetBorderRadius(); }
void SetBorderRadius(int val) { m_pDPanel->SetBorderRadius(val); }
PanelFillType GetPanelFillType() { return m_pDPanel->GetPanelFillType(); }
void SetBorderFillType(PanelFillType val) { m_pDPanel->SetBorderFillType(val); }
COLORREF GetBorderSolidColor() { return m_pDPanel->GetBorderSolidColor(); }
void SetBorderSolidColor(COLORREF val) { m_pDPanel->SetBorderSolidColor(val); }
COLORREF GetBorderGradientColorStart() { return m_pDPanel->GetBorderGradientColorStart(); }
void SetBorderGradientColorStart(COLORREF val) { m_pDPanel->SetBorderGradientColorStart(val); }
COLORREF GetBorderGradientColorEnd() { return m_pDPanel->GetBorderGradientColorEnd(); }
void SetBorderGradientColorEnd(COLORREF val) { m_pDPanel->SetBorderGradientColorEnd(val); }
#ifdef _GDIPLUS
LinearGradientMode GetBorderGradientMode() { return m_pDPanel->GetBorderGradientMode(); }
void SetBorderGradientMode(LinearGradientMode val) { m_pDPanel->SetBorderGradientMode(val); }
#endif
PanelFillType GetFieldFillType() { return m_pDPanel->GetFieldFillType(); }
void SetFieldFillType(PanelFillType val) { m_pDPanel->SetFieldFillType(val); }
int GetFieldRadius() { return m_pDPanel->GetFieldRadius(); }
void SetFieldRadius(int val) { m_pDPanel->SetFieldRadius(val); }
COLORREF GetFieldSolidColor() { return m_pDPanel->GetFieldSolidColor(); }
void SetFieldSolidColor(COLORREF val) { m_pDPanel->SetFieldSolidColor(val); }
CString GetFieldFileNameTexture() { return m_pDPanel->GetFieldFileNameTexture(); }
void SetFieldFileNameTexture(CString val) { m_pDPanel->SetFieldFileNameTexture(val); }
// виртуальные функции, переопределяемые в классе
virtual void OnDraw();
virtual void Clear();
virtual void SaveParameters(SimpleXML *pSimpleXML);
virtual void LoadParameters(SimpleXML *pSimpleXML);
};
//------------------------------------------------------------------------------ | [
"s-kacnep@ya.ru"
] | s-kacnep@ya.ru |
268367d633d3960c13c9a51951bc16b6f50c937a | 9a4487b0b8bab57246e839bb9349333673f7f05a | /Octo-Spork/Octo-Spork/Utils.cpp | ed91e45276a06724dfb35432b3d36629bc39a06d | [] | no_license | JoshLmao/5CS025-OctoSpork | 68e5dd7b7d353e812b54bbb9e1aded5058e9dc19 | 840b8fc78268cad737195111d4538890df100f0b | refs/heads/master | 2022-03-19T23:02:42.609958 | 2019-11-29T16:18:10 | 2019-11-29T16:18:10 | 212,071,655 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 442 | cpp | #include "Utils.h"
#include <string>
#include <locale>
#include <map>
std::string Utils::ToLower(std::string s)
{
std::string lower = "";
std::locale loc;
for (int i = 0; i < s.length(); i++)
lower += std::tolower(s[i], loc);
return lower;
}
bool Utils::ToLowerCompare(std::string a, std::string b)
{
return ToLower(a) == ToLower(b);
}
std::string Utils::GetColor(Colors col)
{
return "\033[" + std::to_string((int)col) + "m";
} | [
"josh_lmao@live.co.uk"
] | josh_lmao@live.co.uk |
a68b8cfa5076aaea13031575e63dfbdc4fec510b | 6a7dce57186c961826fd9af1732a181dd4f5d2d0 | /src/shendk/files/model/mt7/mt7_node.cpp | f7fc6e7a08736b93db841c10dbb15ad64890a0d7 | [
"MIT"
] | permissive | Shenmue-Mods/ShenmueDK | 3d404166a49bbca811d4e5c384f7aaca5910fcdb | 1dae443814b3755281d207a13f25571c0e51a5d1 | refs/heads/master | 2023-04-10T00:17:35.110739 | 2023-03-31T00:46:11 | 2023-03-31T00:46:11 | 164,145,748 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 24,488 | cpp | #include "shendk/files/model/mt7/mt7_node.h"
#define readBytes(x,y,z) x.read(reinterpret_cast<char*>(&y), z)
namespace shendk {
namespace mt7 {
class NodeMDEntry {
public:
unsigned int Offset1;
unsigned int Offset2;
NodeMDEntry(std::istream& stream)
{
readBytes(stream, Offset1, 4);
readBytes(stream, Offset2, 4);
}
};
struct subNode {
public:
virtual bool isValid(uint32_t signature) = 0;
};
struct MDCX : public subNode {
protected:
static constexpr const uint32_t identifiers[2] = {
1480803405, //MDCX
927155277, //MDC7
};
public:
std::vector<NodeMDEntry> Entries;
unsigned int Token = 0;
Matrix4f Matrix;
unsigned int EntryCount = 0;
void read(std::istream& stream) {
readBytes(stream, Token, 4);
readBytes(stream, Matrix, sizeof(Matrix4f));
readBytes(stream, EntryCount, 4);
for (int i = 0; i < EntryCount; i++)
{
Entries.push_back(NodeMDEntry(stream));
}
}
bool isValid(uint32_t signature) {
for (auto identifier : identifiers) {
if (signature == identifier)
return true;
}
return false;
}
};
struct MDPX : public subNode {
protected:
static constexpr const uint32_t identifiers[2] = {
1481655373, //MDPX
928007245, //MDP7
};
public:
unsigned int Token;
unsigned int Size;
char NameData[4] = { 0x00, 0x00, 0x00, 0x00 };
std::string Name;
char* Data = { '\0' };
bool isValid(uint32_t signature) {
for (auto identifier : identifiers) {
if (signature == identifier)
return true;
}
return false;
}
void read(std::istream& stream) {
int position = (int)stream.tellg();
readBytes(stream, Token, 4);
readBytes(stream, Size, 4);
readBytes(stream, NameData, 4);
Name = std::string(NameData, 4);
printf("Name = %s\n", Name.c_str());
readBytes(stream, Data, (int)Size - 12);
}
};
struct MDOX : public subNode {
protected:
static constexpr const uint32_t identifiers[2] = {
1481589837, //MDOX
927941709, //MDO7
};
public:
bool isValid(uint32_t signature) {
for (auto identifier : identifiers) {
if (signature == identifier)
return true;
}
return false;
}
};
struct MDLX : public subNode {
protected:
static constexpr const uint32_t identifiers[2] = {
1481393229, //MDLX
927745101 //MDL7
};
public:
bool isValid(uint32_t signature) {
for (auto identifier : identifiers) {
if (signature == identifier)
return true;
}
return false;
}
};
enum XB01EntryType
{
Zero = 0x00, //Always at start, Always size 5
Type01 = 0x01,
Type02 = 0x02,
Floats = 0x04,
Type05 = 0x05,
Texture = 0x0B,
TexAttr = 0x0D,
Type0E = 0x0E,
Strip = 0x10, //Strip/VertexArray
Type16 = 0x16,
Type89 = 0x89,
TypeD8 = 0xD8
};
class XB01Entry
{
public:
XB01EntryType Type;
unsigned int Size;
unsigned int Offset;
char* Data = nullptr;
XB01Entry(std::istream& stream) { }
};
class XB01Group
{
public:
char ID;
unsigned short Size;
unsigned short *Data = nullptr; //looks like unsigned short values and not floats
unsigned int Offset;
std::vector<XB01Entry> Entries;
XB01Group(std::istream& stream)
{
Offset = static_cast<int>(stream.tellg());
readBytes(stream, ID, 1);
readBytes(stream, Size, 2);
stream.seekg(1, std::ios::cur);
Data = new unsigned short[8];
for (int i = 0; i < 8; i++)
{
readBytes(stream, Data[i], 2);
}
}
};
class XB01_Tex : public XB01Entry
{
public:
unsigned int Size = 0;
XB01EntryType Type;
char* Data = nullptr;
unsigned int Offset = 0;
unsigned int Unknown;
std::vector<unsigned int> Textures;
XB01_Tex(std::istream& stream) : XB01Entry(stream) { Read(stream); }
void Read(std::istream& stream)
{
long position = (long)stream.tellg();
Offset = (unsigned int)position;
readBytes(stream, Type, 1);
readBytes(stream, Size, 1);
Size = (char)Size - 1;
stream.seekg(2, std::ios::cur);
readBytes(stream, Unknown, 4);
for (int i = 0; i < Size - 2; i++)
{
int tmp = 0;
readBytes(stream, tmp, 4);
Textures.push_back(tmp);
}
stream.seekg(position, std::ios::beg);
readBytes(stream, Data, ((int)Size * 4));
stream.seekg(position + (Size + 1) * 4, std::ios::beg);
}
};
class XB01_TexAttr : public XB01Entry
{
public:
unsigned int Size;
XB01EntryType Type;
char* Data = nullptr;
unsigned int Offset;
unsigned int AttributeCount;
TextureWrapMode Wrap;
bool Transparent = false;
bool Unlit = false;
XB01_TexAttr(std::istream& stream) : XB01Entry(stream) { Read(stream); }
void Read(std::istream& stream)
{
long position = stream.tellg();
Offset = (unsigned int)position;
int tmp = 0;
readBytes(stream, tmp, 1);
Type = (enum XB01EntryType)tmp;
readBytes(stream, Size, 1);
stream.seekg(2, std::ios::cur);
readBytes(stream, AttributeCount, 4);
for (int i = 0; i < AttributeCount; i++)
{
unsigned int attr = 0;
readBytes(stream, attr, 2);
if (attr == 0x0010) //Transparency stuff
{
Transparent = true;
unsigned int val = 0;
readBytes(stream, val, 2);
if (val == 0x0400)
{
Unlit = true;
}
}
else if (attr == 0x0100)
{
unsigned int val = 0;
readBytes(stream, val, 2);
}
else if (attr == 0x0000)
{
unsigned int val = 0;
readBytes(stream, val, 2);
if (val == 0x0002)
{
Wrap = TextureWrapMode::MirroredRepeat;
}
else if (val == 0x0001)
{
Wrap = TextureWrapMode::Repeat;
}
else if (val == 0x0003)
{
Wrap = TextureWrapMode::Repeat;
}
}
else
{
unsigned int val = 0;
readBytes(stream, val, 2);
}
}
stream.seekg(position + Size * 4, std::ios::beg);
}
};
class XB01_Floats : public XB01Entry
{
public:
unsigned int Size;
XB01EntryType Type;
char* Data = nullptr;
unsigned int Offset;
std::vector <float> Floats = std::vector<float>();
XB01_Floats(std::istream& stream) : XB01Entry(stream) { Read(stream); }
void Read(std::istream& stream)
{
int position = static_cast<int>(stream.tellg());
Offset = (unsigned int)position;
int tmp = 0;
readBytes(stream, tmp, 1);
Type = (enum XB01EntryType)tmp;
readBytes(stream, Size, 1);
stream.seekg(position, std::ios::beg);
Floats = std::vector<float>();
Floats.clear();
Floats.reserve(Size - 1);
for (int i = 0; i < Size - 1; i++)
{
float tmp = 0.f;
readBytes(stream, tmp, 4);
Floats.push_back(tmp);
}
stream.seekg(position + Size * 4, std::ios::beg);
}
};
class XB01_Unknown : public XB01Entry
{
public:
unsigned int Size;
XB01EntryType Type;
char* Data = nullptr;
unsigned int Offset;
XB01_Unknown(std::istream& stream) : XB01Entry(stream) { Read(stream); }
void Read(std::istream& stream)
{
long position = static_cast<long>(stream.tellg());
Offset = (unsigned int)position;
int tmp = 0;
readBytes(stream, tmp, 1);
Type = (enum XB01EntryType)tmp;
readBytes(stream, tmp, 1);
Size = (char)(tmp & 0x0F);
stream.seekg(-2, std::ios::cur);
stream.seekg(position + Size * 4, std::ios::beg);
if (Size == 0)
{
stream.seekg(position + 4, std::ios::beg);
}
}
};
class XB01_Strip : public XB01Entry
{
public:
unsigned int Size;
XB01EntryType Type;
char* Data = nullptr;
unsigned int Offset;
unsigned int VertCount;
unsigned int Unknown; //Should be strip type (5 = GL_TRIANGLES)
std::vector<unsigned short> VertIndices;
XB01_Strip(std::istream& stream) : XB01Entry(stream) { Read(stream); }
void Read(std::istream& stream)
{
long position = static_cast<long>(stream.tellg());
Offset = (unsigned int)position;
char tmp = 0;
readBytes(stream, tmp, 1);
Type = (enum XB01EntryType)tmp;
short tmp2 = 0;
readBytes(stream, tmp2, 2);
Size = (unsigned int)tmp2;
stream.seekg(1, std::ios::cur);
readBytes(stream, Unknown, 4);
readBytes(stream, VertCount, 4);
for (int i = 0; i < VertCount; i++)
{
unsigned short tmp = 0;
readBytes(stream, tmp, 2);
VertIndices.push_back(tmp);
}
stream.seekg(position + Size * 4, std::ios::beg);
}
};
class XB01_Zero : public XB01Entry
{
public:
unsigned int Size;
XB01EntryType Type;
char* Data = nullptr;
unsigned int Offset;
XB01_Zero(std::istream& stream) : XB01Entry(stream) { Read(stream); }
void Read(std::istream& stream)
{
Offset = static_cast<int>(stream.tellg());
char tmp = 0;
readBytes(stream, tmp, 1);
Type = (enum XB01EntryType)tmp;
char tmp2 = 0;
readBytes(stream, tmp2, 1);
Size = (unsigned int)tmp2;
stream.seekg(-2, std::ios::cur);
}
};
enum EDataFlags
{
Vertex = 1,
Normal = 2,
UV = 4,
Color = 8
};
enum EVertexFormat
{
Undefined = 0,
VertexStd = EDataFlags::Vertex,
VertexNormal = EDataFlags::Vertex | EDataFlags::Normal,
VertexNormalUV = EDataFlags::Vertex | EDataFlags::Normal | EDataFlags::UV,
VertexNormalUVColor = EDataFlags::Vertex | EDataFlags::Normal | EDataFlags::UV | EDataFlags::Color,
VertexNormalColor = EDataFlags::Vertex | EDataFlags::Normal | EDataFlags::Color
};
static EVertexFormat GetFormat(unsigned int stride)
{
switch (stride)
{
case 12:
return EVertexFormat::VertexStd;
case 24:
return EVertexFormat::VertexNormal;
case 32:
return EVertexFormat::VertexNormalUV;
case 40:
return EVertexFormat::VertexNormalColor;
case 48:
return EVertexFormat::VertexNormalUVColor;
default:
return EVertexFormat::VertexNormalUV;
}
}
class XB01
{
public:
static bool IsValid(uint32_t identifier)
{
if (identifier == 825246296)
return true;
return false;
}
MT7Node* m_node;
unsigned int Offset;
unsigned int Identifier;
unsigned int Unknown;
unsigned int FirstEntryOffset;
unsigned int Size;
unsigned int vertUnknown1;
unsigned int vertUnknown2;
unsigned int vertUnknown3;
unsigned int verticesSize;
unsigned short vertSize;
std::vector<XB01Group> Groups;
XB01(ModelNode node)
{
//TODO: XB01 generation....
}
XB01(std::istream& stream, MT7Node* node)
{
Read(stream, node);
}
void Read(std::istream& stream, MT7Node* node)
{
m_node = node;
Offset = static_cast<int>(stream.tellg());
readBytes(stream, Identifier, 4);
readBytes(stream, Unknown, 4);
readBytes(stream, m_node->center, sizeof(Vector3f));
readBytes(stream, m_node->radius, sizeof(float));
readBytes(stream, FirstEntryOffset, 4);
readBytes(stream, Size, 4);
// Read vertices first
unsigned int offsetVertices = Size * 4 + static_cast<int>(stream.tellg()) - 4;
stream.seekg(offsetVertices, std::ios::beg);
readBytes(stream, vertUnknown1, 4);
readBytes(stream, vertUnknown2, 4);
readBytes(stream, vertSize, 2);
readBytes(stream, vertUnknown3, 2);
readBytes(stream, verticesSize, 4);
EVertexFormat vertexFormat = GetFormat(vertSize);
for (int i = 0; i < verticesSize; i += vertSize)
{
Vector3f pos;
readBytes(stream, pos, sizeof(Vector3f));
printf("v %f %f %f\n", pos.x, pos.y, pos.z);
node->model->vertexBuffer.positions.push_back(pos);
if (vertSize > 12)
{
Vector3f norm;
readBytes(stream, norm, sizeof(Vector3f));
printf("vn %f %f %f\n", norm.x, norm.y, norm.z);
node->model->vertexBuffer.normals.push_back(norm);
if (vertSize > 24)
{
Vector2f uv;
readBytes(stream, uv, sizeof(Vector2f));
printf("vt %f %f\n", uv.x, uv.y);
node->model->vertexBuffer.texcoords.push_back(uv);
}
}
}
//Read faces
stream.seekg(Offset + (FirstEntryOffset + 6) * 4, std::ios::beg);
XB01Group group = XB01Group(stream);
Groups.push_back(group);
XB01_Tex * currentTexture = nullptr;
XB01_TexAttr * currentTexAttr = nullptr;
while (static_cast<int>(stream.tellg()) < offsetVertices - 8)
{
unsigned int zeroCheck = 0;
readBytes(stream, zeroCheck, 4);
if (zeroCheck != 0)
{
stream.seekg(-4, std::ios::cur);
}
else
{
if (static_cast<int>(stream.tellg()) >= (static_cast<long long>(group.Offset) + group.Size))
{
group = XB01Group(stream);
Groups.push_back(group);
}
else
{
continue;
}
}
char type = 0;
readBytes(stream, type, 1);
stream.seekg(-1, std::ios::cur);
XB01Entry *entry = nullptr;
switch (type)
{
case 0x00: {
entry = new XB01_Zero(stream);
group.Entries.push_back(*entry);
break;
}
case 0x04: {
entry = new XB01_Floats(stream);
group.Entries.push_back(*entry);
break;
}
case 0x0B: {
currentTexture = new XB01_Tex(stream);
group.Entries.push_back(*currentTexture);
break;
}
case 0x0D: {
currentTexAttr = new XB01_TexAttr(stream);
group.Entries.push_back(*currentTexAttr);
break;
}
case 0x10: {
XB01_Strip* strip = new XB01_Strip(stream);
/*MeshFace face = new MeshFace(
{
TextureIndex = currentTexture.Textures[0],
Type = PrimitiveType.Triangles,
Wrap = currentTexAttr.Wrap,
Transparent = currentTexAttr.Transparent,
Unlit = currentTexAttr.Unlit
});*/
//face.PositionIndices.AddRange(strip->VertIndices);
if (vertSize > 12)
{
//face.NormalIndices.AddRange(strip->VertIndices);
if (vertSize > 24)
{
//face.UVIndices.AddRange(strip->VertIndices);
}
}
//m_node.Faces.Add(face);
group.Entries.push_back(*strip);
break;
}
default: {
entry = new XB01_Unknown(stream);
group.Entries.push_back(*entry);
break;
}
}
}
};
};
MT7Node::MT7Node(Model* model, MT7Node* _parent)
: ModelNode(model)
{
parent = _parent;
}
MT7Node::MT7Node(Model* model, std::istream& stream, int64_t baseOffset, MT7Node* _parent)
: ModelNode(model)
{
parent = _parent;
read(stream, baseOffset);
}
MT7Node::~MT7Node() {}
void MT7Node::read(std::istream& stream, int64_t baseOffset)
{
//printf("current pos = %d\n", static_cast<int>(stream.tellg()));
readBytes(stream, id, 4);
readBytes(stream, position, sizeof(Vector3f));
readBytes(stream, rotation, sizeof(Vector3f));
readBytes(stream, scale, sizeof(Vector3f));
readBytes(stream, XB01Offset, 4);
readBytes(stream, ChildOffset, 4);
readBytes(stream, SiblingOffset, 4);
readBytes(stream, ParentOffset, 4);
//printf("POS/ROT/SCL\n%f %f %f\n%f %f %f\n%f %f %f\nXB01Offset = %d\nChildOffset = %d\nSiblingOffset = %d\nParentOffset = %d\n", position.x, position.y, position.z, rotation.x, rotation.y, rotation.z, scale.x, scale.y, scale.z, XB01Offset, ChildOffset, SiblingOffset, ParentOffset);
stream.seekg(8, std::ios::cur);
// Check for sub nodes
unsigned int subNodeIdentifier = 0;
readBytes(stream, subNodeIdentifier, 4);
stream.seekg(-4, std::ios::cur);
MDCX mdcx; MDPX mdpx; MDOX mdox; MDLX mdlx;
if (mdcx.isValid(subNodeIdentifier))
{
printf("[*] Parsing MDCX node\n");
mdcx.read(stream);
printf("[*] Finished parsing MDCX node\n");
}
else if (mdpx.isValid(subNodeIdentifier))
{
printf("[*] Parsing MDPX node\n");
mdpx.read(stream);
printf("[*] Finished parsing MDPX node\n");
}
else if (mdox.isValid(subNodeIdentifier))
{
new std::runtime_error ("Never seen this, please report.");
}
else if (mdlx.isValid(subNodeIdentifier))
{
new std::runtime_error ("Never seen this, please report.");
}
// Read XB01 mesh data
int offset = static_cast<int>(stream.tellg());
if (XB01Offset != 0)
{
HasMesh = true;
stream.seekg(XB01Offset, std::ios::beg);
printf("[*] Parsing XB01\n");
auto tmp = new XB01(stream, this);
printf("[*] Completed parsing XB01\n");
}
// Construct node tree recursively
if (ChildOffset != 0)
{
printf("[*] Parsing Child node\n");
stream.seekg(ChildOffset, std::ios::beg);
child = new MT7Node(model, stream, ChildOffset, this);
printf("[*] Finished parsing Child node\n");
}
if (SiblingOffset != 0)
{
printf("[*] Parsing Sibling node\n");
stream.seekg(SiblingOffset, std::ios::beg);
nextSibling = new MT7Node(model, stream, SiblingOffset, dynamic_cast<MT7Node*>(parent));
printf("[*] Finished parsing Sibling node\n");
}
//printf("current pos = %d\n", static_cast<int>(stream.tellg()));
stream.seekg(offset, std::ios::beg);
}
}
} | [
"35783139+LemonHaze420@users.noreply.github.com"
] | 35783139+LemonHaze420@users.noreply.github.com |
8ab327b85d7a32bff57fca72409222c8ef0535b7 | c3b6ddcc57d79fc79ed241a63b72f870793fd969 | /src/scenario.cpp | 71bac91c2265478881caa562576ba4b1a2eb6ec4 | [] | no_license | mboeh/AUNRIES | b4a8f2a044cd290f5fe9044d975596fd5fd82217 | 85c00cbda6238cb8493cd3e3b045367a9eb048d6 | refs/heads/main | 2023-04-29T02:17:34.560934 | 2021-05-24T01:15:28 | 2021-05-24T01:15:28 | 370,193,357 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 69 | cpp | //
// Created by Matthew Boeh on 5/17/21.
//
#include "scenario.hpp" | [
"m@mboeh.com"
] | m@mboeh.com |
5aff3d0255416f88bc6631c6ba55624570a3c96b | b365e2934404c2f30274808e135e575514351f8e | /src/dm/impls/moab/examples/tests/ex2.cxx | 05e0a58d49d408131b5df0ea37b7160b365755e0 | [
"BSD-2-Clause"
] | permissive | mchandra/petsc | 757bffe87e40cb982060ac2aab8d35faef821c6d | b19ca9c001e69f13e725bb828a15ecf9835165a6 | refs/heads/master | 2021-01-17T11:24:29.081151 | 2015-09-28T16:20:58 | 2015-09-28T16:20:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,812 | cxx | static char help[] = "Create a box mesh with DMMoab and test defining a tag on the mesh\n\n";
#include <petscdmmoab.h>
typedef struct {
DM dm; /* DM implementation using the MOAB interface */
PetscBool debug; /* The debugging level */
PetscLogEvent createMeshEvent;
/* Domain and mesh definition */
PetscInt dim; /* The topological mesh dimension */
PetscInt nele; /* Elements in each dimension */
PetscBool simplex; /* Use simplex elements */
PetscBool interlace;
char input_file[PETSC_MAX_PATH_LEN]; /* Import mesh from file */
char output_file[PETSC_MAX_PATH_LEN]; /* Output mesh file name */
PetscBool write_output; /* Write output mesh and data to file */
PetscInt nfields; /* Number of fields */
char *fieldnames[PETSC_MAX_PATH_LEN]; /* Name of a defined field on the mesh */
} AppCtx;
#undef __FUNCT__
#define __FUNCT__ "ProcessOptions"
PetscErrorCode ProcessOptions(MPI_Comm comm, AppCtx *options)
{
PetscErrorCode ierr;
PetscBool flg;
PetscFunctionBegin;
options->debug = PETSC_FALSE;
options->dim = 2;
options->nele = 5;
options->nfields = 256;
options->simplex = PETSC_FALSE;
options->write_output = PETSC_FALSE;
options->interlace = PETSC_FALSE;
options->input_file[0] = '\0';
ierr = PetscStrcpy(options->output_file,"ex2.h5m");CHKERRQ(ierr);
ierr = PetscOptionsBegin(comm, "", "Meshing Problem Options", "DMMOAB");CHKERRQ(ierr);
ierr = PetscOptionsBool("-debug", "Enable debug messages", "ex2.c", options->debug, &options->debug, NULL);CHKERRQ(ierr);
ierr = PetscOptionsBool("-interlace", "Use interlaced arrangement for the field data", "ex2.c", options->interlace, &options->interlace, NULL);CHKERRQ(ierr);
ierr = PetscOptionsBool("-simplex", "Create simplices instead of tensor product elements", "ex2.c", options->simplex, &options->simplex, NULL);CHKERRQ(ierr);
ierr = PetscOptionsInt("-dim", "The topological mesh dimension", "ex2.c", options->dim, &options->dim, NULL);CHKERRQ(ierr);
ierr = PetscOptionsInt("-n", "The number of elements in each dimension", "ex2.c", options->nele, &options->nele, NULL);CHKERRQ(ierr);
ierr = PetscOptionsString("-meshfile", "The input mesh file", "ex2.c", options->input_file, options->input_file, PETSC_MAX_PATH_LEN, NULL);CHKERRQ(ierr);
ierr = PetscOptionsString("-out", "Write out the mesh and solution that is defined on it (Default H5M format)", "ex2.c", options->output_file, options->output_file, PETSC_MAX_PATH_LEN, &options->write_output);CHKERRQ(ierr);
ierr = PetscOptionsStringArray("-fields", "The list of names of the field variables", "ex2.c", options->fieldnames,&options->nfields, &flg);CHKERRQ(ierr);
ierr = PetscOptionsEnd();
if (options->debug) PetscPrintf(comm, "Total number of fields: %D.\n",options->nfields);
if (!flg) { /* if no field names were given by user, assign a default */
options->nfields = 1;
ierr = PetscStrallocpy("TestEX2Var",&options->fieldnames[0]);CHKERRQ(ierr);
}
ierr = PetscLogEventRegister("CreateMesh", DM_CLASSID, &options->createMeshEvent);CHKERRQ(ierr);
PetscFunctionReturn(0);
};
#undef __FUNCT__
#define __FUNCT__ "CreateMesh"
PetscErrorCode CreateMesh(MPI_Comm comm, AppCtx *user)
{
PetscInt i;
size_t len;
PetscMPIInt rank;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = PetscLogEventBegin(user->createMeshEvent,0,0,0,0);CHKERRQ(ierr);
ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr);
ierr = PetscStrlen(user->input_file, &len);CHKERRQ(ierr);
if (len) {
if (user->debug) PetscPrintf(comm, "Loading mesh from file: %s and creating a DM object.\n",user->input_file);
ierr = DMMoabLoadFromFile(comm, user->dim, user->input_file, "", &user->dm);CHKERRQ(ierr);
}
else {
if (user->debug) {
PetscPrintf(comm, "Creating a %D-dimensional structured %s mesh of %Dx%Dx%D in memory and creating a DM object.\n",user->dim,(user->simplex?"simplex":"regular"),user->nele,user->nele,user->nele);
}
ierr = DMMoabCreateBoxMesh(comm, user->dim, user->simplex, NULL, user->nele, 1, &user->dm);CHKERRQ(ierr);
}
if (user->debug) {
PetscPrintf(comm, "Setting field names to DM: \n");
for (i=0; i<user->nfields; i++)
PetscPrintf(comm, "\t Field{%D} = %s.\n",i,user->fieldnames[i]);
}
ierr = DMMoabSetFieldNames(user->dm, user->nfields, (const char**)user->fieldnames);CHKERRQ(ierr);
ierr = PetscObjectSetName((PetscObject)user->dm, "Structured Mesh");CHKERRQ(ierr);
ierr = PetscLogEventEnd(user->createMeshEvent,0,0,0,0);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "main"
int main(int argc, char **argv)
{
AppCtx user; /* user-defined work context */
PetscRandom rctx;
Vec solution;
Mat system;
MPI_Comm comm;
PetscInt i;
PetscErrorCode ierr;
ierr = PetscInitialize(&argc, &argv, NULL, help);CHKERRQ(ierr);
comm = PETSC_COMM_WORLD;
ierr = ProcessOptions(comm, &user);CHKERRQ(ierr);
ierr = CreateMesh(comm, &user);CHKERRQ(ierr);
/* set block size */
ierr = DMMoabSetBlockSize(user.dm, (user.interlace?user.nfields:1));CHKERRQ(ierr);
ierr = DMSetMatType(user.dm,MATAIJ);CHKERRQ(ierr);
ierr = DMSetFromOptions(user.dm);CHKERRQ(ierr);
/* SetUp the data structures for DMMOAB */
ierr = DMSetUp(user.dm);CHKERRQ(ierr);
if (user.debug) PetscPrintf(comm, "Creating a global vector defined on DM and setting random data.\n");
ierr = DMCreateGlobalVector(user.dm,&solution);CHKERRQ(ierr);
ierr = PetscRandomCreate(comm,&rctx);CHKERRQ(ierr);
ierr = VecSetRandom(solution,rctx);CHKERRQ(ierr);
/* test if matrix allocation for the prescribed matrix type is done correctly */
if (user.debug) PetscPrintf(comm, "Creating a global matrix defined on DM with the right block structure.\n");
ierr = DMCreateMatrix(user.dm,&system);CHKERRQ(ierr);
if (user.write_output) {
ierr = DMMoabSetGlobalFieldVector(user.dm, solution);CHKERRQ(ierr);
if (user.debug) PetscPrintf(comm, "Output mesh and associated field data to file: %s.\n",user.output_file);
ierr = DMMoabOutput(user.dm,(const char*)user.output_file,"");CHKERRQ(ierr);
}
if (user.fieldnames) {
for(i=0; i<user.nfields; i++) {
ierr = PetscFree(user.fieldnames[i]);CHKERRQ(ierr);
}
}
ierr = PetscRandomDestroy(&rctx);CHKERRQ(ierr);
ierr = VecDestroy(&solution);CHKERRQ(ierr);
ierr = MatDestroy(&system);CHKERRQ(ierr);
ierr = DMDestroy(&user.dm);CHKERRQ(ierr);
ierr = PetscFinalize();
return 0;
}
| [
"vijay.m@gmail.com"
] | vijay.m@gmail.com |
9d9a6f80150965585b88ce69e7c648fa76a9a30a | 7e4724913dde962d642a85eaf5e3b2e7365021aa | /icu4c/source/i18n/unicode/msgfmtnano_pluralprovider.h | 18492744e789d6f0429dfe561555fd4a9acbc576 | [
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"ICU",
"BSD-3-Clause",
"NAIST-2003",
"LicenseRef-scancode-unicode",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | bhamiltoncx/icu | 7269d17a23e01eabf32e1c4d52d918ea27260e97 | 4f074e602717a115fe56378c1c175eb72bd4c102 | refs/heads/master | 2022-11-14T09:09:42.830009 | 2020-06-30T20:12:46 | 2020-06-30T20:12:46 | 272,472,461 | 0 | 0 | null | 2020-06-15T15:15:34 | 2020-06-15T15:15:33 | null | UTF-8 | C++ | false | false | 1,086 | h | // © 2019 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
#ifndef __SOURCE_I18N_UNICODE_MSGFMTNANO_PLURALPROVIDER_H__
#define __SOURCE_I18N_UNICODE_MSGFMTNANO_PLURALPROVIDER_H__
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_FORMATTING
#include "unicode/msgfmtnano.h"
#include "unicode/localpointer.h"
#include "unicode/uloc.h"
U_NAMESPACE_BEGIN
class U_I18N_API PluralFormatProviderNano {
public:
PluralFormatProviderNano() = delete;
PluralFormatProviderNano &operator=(const PluralFormatProviderNano&) = delete;
PluralFormatProviderNano &operator=(PluralFormatProviderNano&&) = delete;
PluralFormatProviderNano(const PluralFormatProviderNano&) = delete;
PluralFormatProviderNano(PluralFormatProviderNano&&) = delete;
static LocalPointer<const PluralFormatProvider> U_EXPORT2 createInstance(UErrorCode& success);
};
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // __SOURCE_I18N_UNICODE_MSGFMTNANO_PLURALPROVIDER_H__
| [
"benhamilton@google.com"
] | benhamilton@google.com |
f796670445e9a6a7336efa546b668f6eebd900df | e01d541554b2541e280a2581c31f3c8904a5b923 | /nt4/public/sdk/inc/crt/stdiostr.h | 8f6c53af6c975b71d699e3ed4f06f597e6333192 | [] | no_license | tmplazy/NT_4.0_SourceCode | b9a6a65fa3ca3e008b0277c7f5884aa7b3c57b9f | e293359a21b004f6840ec66c0a7ad1077a80f22b | refs/heads/master | 2021-07-22T13:57:15.412794 | 2017-10-31T10:48:43 | 2017-10-31T10:50:50 | 105,346,067 | 1 | 0 | null | 2017-09-30T06:03:46 | 2017-09-30T06:03:45 | null | UTF-8 | C++ | false | false | 2,051 | h | /***
*stdiostr.h - definitions/declarations for stdiobuf, stdiostream
*
* Copyright (c) 1991-1995, Microsoft Corporation. All rights reserved.
*
*Purpose:
* This file defines the classes, values, macros, and functions
* used by the stdiostream and stdiobuf classes.
* [AT&T C++]
*
* [Public]
*
****/
#if _MSC_VER > 1000
#pragma once
#endif
#ifdef __cplusplus
#ifndef _INC_STDIOSTREAM
#define _INC_STDIOSTREAM
#if !defined(_WIN32) && !defined(_MAC)
#error ERROR: Only Mac or Win32 targets supported!
#endif
#ifdef _MSC_VER
// Currently, all MS C compilers for Win32 platforms default to 8 byte
// alignment.
#pragma pack(push,8)
#endif // _MSC_VER
/* Define _CRTIMP */
#ifndef _CRTIMP
#ifdef _NTSDK
/* definition compatible with NT SDK */
#define _CRTIMP
#else /* ndef _NTSDK */
/* current definition */
#ifdef _DLL
#define _CRTIMP __declspec(dllimport)
#else /* ndef _DLL */
#define _CRTIMP
#endif /* _DLL */
#endif /* _NTSDK */
#endif /* _CRTIMP */
#include <iostream.h>
#include <stdio.h>
#ifdef _MSC_VER
#pragma warning(disable:4514) // disable unwanted /W4 warning
// #pragma warning(default:4514) // use this to reenable, if necessary
#endif // _MSC_VER
class _CRTIMP stdiobuf : public streambuf {
public:
stdiobuf(FILE* f);
FILE * stdiofile() { return _str; }
virtual int pbackfail(int c);
virtual int overflow(int c = EOF);
virtual int underflow();
virtual streampos seekoff( streamoff, ios::seek_dir, int =ios::in|ios::out);
virtual int sync();
~stdiobuf();
int setrwbuf(int _rsize, int _wsize);
// protected:
// virtual int doallocate();
private:
FILE * _str;
};
// obsolescent
class _CRTIMP stdiostream : public iostream { // note: spec.'d as : public IOS...
public:
stdiostream(FILE *);
~stdiostream();
stdiobuf* rdbuf() const { return (stdiobuf*) ostream::rdbuf(); }
private:
};
#ifdef _MSC_VER
// Restore default packing
#pragma pack(pop)
#endif // _MSC_VER
#endif // _INC_STDIOSTREAM
#endif /* __cplusplus */
| [
"gasgas4@gmail.com"
] | gasgas4@gmail.com |
4e25422bb11143906a563b624cd651aec65180be | 02e55afe8921e5e580ba56233966ffed5c5832f7 | /intern/GHOST_DisplayManagerSDL.h | 2a815b1dc28fb1dd1cf2a4924e495eaa90b5d02e | [] | no_license | theoriticthierry/Ghost2 | f764de860a2aa788dad55003afab11ad56fe5ccb | 4f2fb169f85bd2d1cf028e2fbbf54a0d485e8c27 | refs/heads/master | 2021-01-23T02:53:35.431754 | 2013-03-18T20:28:55 | 2013-03-18T20:28:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,023 | h | /*
* $Id$
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor(s): Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_DisplayManagerSDL.h
* \ingroup GHOST
* Declaration of GHOST_DisplayManagerSDL class.
*/
#ifndef _GHOST_DISPLAY_MANAGER_SDL_H_
#define _GHOST_DISPLAY_MANAGER_SDL_H_
#include "GHOST_DisplayManager.h"
extern "C" {
#include "SDL.h"
}
#if !SDL_VERSION_ATLEAST(1, 3, 0)
# error "SDL 1.3 or newer is needed to build with Ghost"
#endif
class GHOST_SystemSDL;
class GHOST_DisplayManagerSDL : public GHOST_DisplayManager
{
public:
GHOST_DisplayManagerSDL(GHOST_SystemSDL *system);
GHOST_TSuccess
getNumDisplays(GHOST_TUns8& numDisplays);
GHOST_TSuccess
getNumDisplaySettings(GHOST_TUns8 display,
GHOST_TInt32& numSettings);
GHOST_TSuccess
getDisplaySetting(GHOST_TUns8 display,
GHOST_TInt32 index,
GHOST_DisplaySetting& setting);
GHOST_TSuccess
getCurrentDisplaySetting(GHOST_TUns8 display,
GHOST_DisplaySetting& setting);
GHOST_TSuccess
setCurrentDisplaySetting(GHOST_TUns8 display,
const GHOST_DisplaySetting& setting);
private :
GHOST_SystemSDL * m_system;
};
#endif /* _GHOST_DISPLAY_MANAGER_SDL_H_ */
| [
"asilepolitique@gmail.com"
] | asilepolitique@gmail.com |
cefaa2e095bda4e13b317437257e98fcfc82aca0 | 6fbcb29d1607d637adff16028f0b1cf08c0481f5 | /src/button.h | 6a23d7771dc6b15928401a6c3911ae613705a820 | [] | no_license | kentdev/Trichromic | 893c8108b682d67947c883043e6c0b84a81475b6 | 9e71addbc51c3f4986e87d690cb82cfd68281d8c | refs/heads/master | 2021-05-02T02:00:25.306155 | 2020-01-16T04:12:22 | 2020-01-16T04:12:22 | 28,209,064 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 737 | h | #ifndef _button_h
#define _button_h
class _button
{
bool click, rclick;
bool sound;
int type;
int textw;
float texta;
string text;
public:
bool clickable;
short x;
short y;
short w;
short h;
int color;
string get_text();
ol::Bitmap *picture;
void draw_disabled();
void draw();
void check();
bool mouseover();
bool mousedown();
bool rmousedown();
bool clicked();
bool rclicked();
void init(int ix, int iy, int iw, int ih, int itype = 0);
void init(int ix, int iy, int iw, int ih, string itext, int itype = 0, int color = makecol(255,255,255));
void init(int ix, int iy, int iw, int ih, string itext, ol::Bitmap *ipicture, int itype = 0, int color = makecol(0,0,0));
};
#endif
| [
"kent@kentdev.net"
] | kent@kentdev.net |
b492d185e05094891d9527fac163c371817a5d2c | f8f3b88f9728cc25530d38b4d413ca4bd5e28419 | /hub/hub.ino | a258e4be799ca6b171be1e39a04b2cf23eef8c75 | [
"MIT"
] | permissive | UAlberta-DORN/espnow_firmware | aba737dd8455b4eee28db7079585e893e4d07e96 | 0752fe8ef19e5d3150806427baf18b6ba3ef3d45 | refs/heads/main | 2023-04-08T03:28:57.206925 | 2021-04-16T05:32:29 | 2021-04-16T05:32:29 | 308,136,866 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 7,279 | ino | #include "hub_settings.h" // we can include a setting file specially made for this script, else compliler will use the default settings
#include <custom_capstone_lib.h>
int resend_counter=10;
DynamicJsonDocument data_json(DEFAULT_DOC_SIZE);
void setup() {
Serial.begin(115200);
printlnd("Hub:");
//Set device in STA mode to begin with
WiFi.mode(WIFI_AP);
// This is the mac address of the Master in Station Mode
printd("STA MAC: "); printlnd(WiFi.macAddress());
data_json=init_doc(data_json);
serializeJson(data_json, Serial);
Serial.println("");
// Init ESPNow with a fallback logic
InitESPNow();
// Once ESPNow is successfully Init, we will register for recv CB to
// get recv packer info.
esp_now_register_recv_cb(OnDataRecv);
esp_now_register_send_cb(OnDataSent);
}
// callback when data is recv from Master
void OnDataRecv(const uint8_t *mac_addr, const uint8_t *data, int data_len) {
printlnd("Data Recived!");printlnd("Data Recived!");printlnd("Data Recived!");printlnd("Data Recived!");
char macStr[18];
snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x",
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
DynamicJsonDocument message_doc(400);
message_doc=decode_espnow_message(data, data_len);
printd("message_doc: ");
json_printd(message_doc);
printlnd();
String message = message_doc["json"].as<String>();
printlnd(message);
if (resend_counter<0){
resend_counter = 10;
}
if (resend_counter>0){
if (check_package_hash(message_doc)){
DeserializationError err = deserializeJson(message_doc, message);
printd("message_doc: ");
json_printd(message_doc); printlnd();
if (err) {
printd(F("deserializeJson() failed: "));
printlnd(err.c_str());
}
resend_counter=0;
} else {
printlnd("Asking for resend...");
ask_for_resend(mac_addr,data_json);
return;
}
resend_counter--;
}
printd("Last Packet Recv from: "); printlnd(macStr);
if (resend_counter==0){
printlnd("Error: ckecksum not matching");
printd("Last Packet Recv Data: ");
printlnd(*data);
printlnd("");
} else {
printd("Decoded Message:");
json_printd(message_doc);
printlnd("");
printlnd("");
json_printd(message_doc["peers"]["hub"]);
printlnd("");
json_printd(message_doc["header"]["DEVICE_ID"]);
printlnd("");
printlnd("Message Data:");
json_printd(message_doc["data"]);
resend_counter = 10;
}
String command = message_doc["command"].as<String>();
int sender_device_type = message_doc["header"]["DEVICE_TYPE"].as<int>();
String sender_DEVICE_ID = message_doc["header"]["DEVICE_ID"].as<String>();
if (sender_device_type == 0){
// Should not be talking to another hub
} else if (sender_device_type != 0){
// Devices are sensors, save the data
printlnd("Updating the children data...");
data_json["children"][sender_DEVICE_ID]["header"]["DEVICE_TYPE"] = sender_device_type;
data_json["children"][sender_DEVICE_ID]["header"]["DEVICE_ID"] = sender_DEVICE_ID;
data_json["children"][sender_DEVICE_ID]["header"]["POWER_SOURCE"] = message_doc["header"]["POWER_SOURCE"].as<String>();
data_json["children"][sender_DEVICE_ID]["data"]["temp"] = message_doc["data"]["temp"].as<float>();
data_json["children"][sender_DEVICE_ID]["data"]["light"] = message_doc["data"]["light"].as<float>();
data_json["children"][sender_DEVICE_ID]["data"]["timestamp"] = millis();
data_json["header"]["LOCAL_TIME"] = millis();
printlnd("current data_json:");
json_printd(data_json);
serializeJson(data_json, Serial);Serial.println("");
} else {
// some thing went wrong, ask for clarification
printd("Cannot understand data: ");
ask_for_resend(mac_addr,data_json);
}
if (command.indexOf("A")>=0){
// Do A
} else if (command.indexOf("B")>=0){
// Do B
} else if (command.indexOf("Callback")>=0){
data_json["command"] = "Callback";
printd("Sending commands to: "); printlnd(*mac_addr);
sendData(mac_addr, package_json(data_json));
printlnd("Commands sent");
} else {
// some thing went wrong, ask for clarification
printd("Cannot understand command: ");
// printlnd(message_doc["command"]);
command_clarification(mac_addr,data_json);
}
}
// callback when data is sent from Master to Slave
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
char macStr[18];
snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x",
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
printd("Last Packet Sent to: "); printlnd(macStr);
printd("Last Packet Send Status: "); printlnd(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
}
esp_now_peer_info_t slaves[NUMSLAVES] = {};
esp_now_peer_info_t peerInfo;
int SlaveCnt = 0;
int loop_counter = 0;
int push_counter = 0;
int search_counter = 100;
void loop() {
// printd("Loop number "); printlnd(loop_counter);
if (search_counter>10){
// In the loop we scan for slave
*slaves = ScanForSlave();
// If Slave is found, it would be populate in `slave` variable
// We will check if `slave` is defined and then we proceed further
SlaveCnt=count_slaves(slaves);
// TODO: implement eeprom
printd("Found "); printd(SlaveCnt); printlnd(" slave(s)");
printd("Slave addr = "); printlnd(*(slaves[0].peer_addr));
search_counter = 0;
}
if (SlaveCnt > 0 & loop_counter>2) { // check if slave channel is defined
loop_counter = 0;
// `slave` is defined
// Add slave as peer if it has not been added already
manageSlave(slaves);
// pair success or already paired
// Send data to device
for (int i = 0; i < SlaveCnt; i++) {
// data_json["command"] = "Callback";
//// printd("Sending commands to: "); printlnd(*(slaves[i].peer_addr));
//// sendData(slaves[i].peer_addr, package_json(data_json));
//
// printd("Sending commands to: "); printlnd(*(slaves[i].peer_addr));
// sendData(slaves[i].peer_addr, package_json(data_json));
// printlnd("Commands sent");
// data_json["command"] = "";
}
} else {
// No slave found to process
}
// read input from RPi, and process/ act on the commands
if (Serial.available()) {
printd("Time Commands Recived:");printlnd(millis());
// Serial.print("Time Commands Recived:");Serial.println(millis());
String inByte = Serial.readString();
printlnd(inByte);
DynamicJsonDocument rpi_command(500);
deserializeJson(rpi_command, inByte);
printlnd(rpi_command.size());
process_rpi_command(rpi_command, data_json, slaves[0]);
}
// Every few rounds, send info to RPi
if (push_counter>=10){
printd("Current Time:");printd(millis());printlnd("");
data_json["header"]["LOCAL_TIME"] = millis();
printlnd("Push this to RPi:");
serializeJson(data_json, Serial);Serial.println("");
push_counter=0;
}
// printlnd("Loop End\n");
loop_counter++;
push_counter++;
search_counter++;
}
| [
"ray@rayliu.ca"
] | ray@rayliu.ca |
a362ba8a81741930780a2ada3577acd385add0b5 | c7aac55da99b0c2fbaa67d86b6a7be604c69dc4e | /hw2-starterCode/.history/hw2_core_code/hw2_20200329224606.cpp | 3134df11d5f14b5708ec29b22436854b8a14174e | [] | no_license | RealZiangLiu/usc_csci420_sp20 | 76733daa3ec84d9c3283330b65ca37fda416a350 | c3a7e38d32cf1f14100512a6da23aa34673f682d | refs/heads/master | 2023-02-19T09:33:39.379731 | 2020-04-23T01:29:34 | 2020-04-23T01:29:34 | 242,432,725 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 50,999 | cpp | /*
CSCI 420 Computer Graphics, USC
Assignment 2: Roller Coaster
C++ starter code
Student username: ziangliu
ID: 9114346039
*/
#include "basicPipelineProgram.h"
#include "openGLMatrix.h"
#include "imageIO.h"
#include "openGLHeader.h"
#include "glutHeader.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#if defined(WIN32) || defined(_WIN32)
#ifdef _DEBUG
#pragma comment(lib, "glew32d.lib")
#else
#pragma comment(lib, "glew32.lib")
#endif
#endif
#if defined(WIN32) || defined(_WIN32)
char shaderBasePath[1024] = SHADER_BASE_PATH;
#else
char shaderBasePath[1024] = "../openGLHelper-starterCode";
#endif
using namespace std;
// Constant parameters
const double param_s = 0.5;
const double param_u_step = 0.001;
const int param_speed = 10;
const double param_rail_scale = 0.05;
const float param_La[4] = {0.8, 0.8, 0.8, 1.0};
const float param_Ld[4] = {0.8, 0.8, 0.8, 1.0};
const float param_Ls[4] = {1, 0.9, 0.8, 1.0};
const float param_alpha = 51.2;
// const float param_ka[4] = {0.24725, 0.1995, 0.0745, 1.0};
// const float param_kd[4] = {0.75164, 0.60648, 0.22648, 1.0};
// const float param_ks[4] = {0.628281, 0.555802, 0.366065, 1.0};
const float param_ka[4] = {0.19225, 0.19225, 0.19225, 1.0};
const float param_kd[4] = {0.50754, 0.50754, 0.50754, 1.0};
const float param_ks[4] = {0.508273, 0.508273, 0.508273, 1.0};
// the “Sun” at noon
const float lightDirection[3] = { -1, 0, 0 };
// represents one control point along the spline
struct Point
{
double x;
double y;
double z;
Point () {};
Point (double x_, double y_, double z_)
: x(x_), y(y_), z(z_) {}
Point operator- (Point other) {
return Point(x - other.x, y - other.y, z - other.z);
}
Point operator+ (Point other) {
return Point(x + other.x, y + other.y, z + other.z);
}
Point operator* (double mult) {
return Point(x * mult, y * mult, z * mult);
}
Point operator/ (double div) {
return Point(x / div, y / div, z / div);
}
void normalize () {
double norm = sqrt(x * x + y * y + z * z);
x /= norm;
y /= norm;
z /= norm;
}
Point cross (Point& other) {
Point res(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x);
return res;
}
};
Point normalize (Point pt) {
double norm = sqrt(pt.x * pt.x + pt.y * pt.y + pt.z * pt.z);
return pt / norm;
}
// spline struct
// contains how many control points the spline has, and an array of control points
struct Spline
{
int numControlPoints;
Point * points;
};
struct CatmullMatrix
{
const vector< vector<double> > basis = { {-param_s, 2 - param_s, param_s - 2, param_s },
{2 * param_s, param_s - 3, 3 - 2 * param_s, -param_s},
{-param_s, 0, param_s, 0 },
{0, 1, 0, 0}};
Point computePosition (double u_, Point& p_1, Point& p_2, Point& p_3, Point& p_4) {
vector<double> first_res(4, 0.0);
vector<double> final_res(3, 0.0);
vector<double> design = {pow(u_, 3), pow(u_, 2), u_, 1.0};
vector<Point> control = {p_1, p_2, p_3, p_4};
// Multiply design matrix with basis
for (int i=0; i<4; ++i) {
for (int j=0; j<4; ++j) {
first_res[i] += (design[j] * basis[j][i]);
}
}
// Multiply previous result with control matrix
for (int i=0; i<4; ++i) {
final_res[0] += (first_res[i] * control[i].x);
final_res[1] += (first_res[i] * control[i].y);
final_res[2] += (first_res[i] * control[i].z);
}
return Point(final_res[0], final_res[1], final_res[2]);
}
Point computeTangent (double u_, Point& p_1, Point& p_2, Point& p_3, Point& p_4) {
vector<double> first_res(4, 0.0);
vector<double> final_res(3, 0.0);
vector<double> design = {3 * pow(u_, 2), 2 * u_, 1.0, 0.0};
vector<Point> control = {p_1, p_2, p_3, p_4};
// Multiply design matrix with basis
for (int i=0; i<4; ++i) {
for (int j=0; j<4; ++j) {
first_res[i] += (design[j] * basis[j][i]);
}
}
// Multiply previous result with control matrix
for (int i=0; i<4; ++i) {
final_res[0] += (first_res[i] * control[i].x);
final_res[1] += (first_res[i] * control[i].y);
final_res[2] += (first_res[i] * control[i].z);
}
Point res(final_res[0], final_res[1], final_res[2]);
return normalize(res);
}
};
CatmullMatrix computeMatrix;
Point initial_V(0.0, 0.0, -1.0);
// the spline array
Spline * splines;
// total number of splines
int numSplines;
int mousePos[2]; // x,y coordinate of the mouse position
int leftMouseButton = 0; // 1 if pressed, 0 if not
int middleMouseButton = 0; // 1 if pressed, 0 if not
int rightMouseButton = 0; // 1 if pressed, 0 if not
typedef enum { ROTATE, TRANSLATE, SCALE } CONTROL_STATE;
CONTROL_STATE controlState = ROTATE;
// state of the world
float landRotate[3] = { 0.0f, 0.0f, 0.0f };
float landTranslate[3] = { 0.0f, 0.0f, 0.0f };
float landScale[3] = { 1.0f, 1.0f, 1.0f };
int windowWidth = 1280;
int windowHeight = 720;
char windowTitle[512] = "CSCI 420 homework II";
int mode = 1;
int record_animation = 0;
int camera_on_rail = 0;
int roller_frame_count = 0;
// Global arrays
GLuint groundVBO, groundVAO;
// texture handles
GLuint groundHandle;
vector<GLuint> splineVBOs;
vector<GLuint> splineVAOs;
vector<int> splineVertexCnt;
vector<int> splineSquareEBOCnt;
// store point positions along spline
vector< vector<Point> > splinePointCoords, splineTangents, splineNormals, splineBinormals;
OpenGLMatrix matrix;
BasicPipelineProgram * milestonePipelineProgram, *texturePipelineProgram;
int frame_cnt = 0;
// void renderWireframe();
void renderSplines();
void renderTexture();
int loadSplines(char * argv)
{
char * cName = (char *) malloc(128 * sizeof(char));
FILE * fileList;
FILE * fileSpline;
int iType, i = 0, j, iLength;
// load the track file
fileList = fopen(argv, "r");
if (fileList == NULL)
{
printf ("can't open file\n");
exit(1);
}
// stores the number of splines in a global variable
fscanf(fileList, "%d", &numSplines);
splines = (Spline*) malloc(numSplines * sizeof(Spline));
// reads through the spline files
for (j = 0; j < numSplines; j++)
{
i = 0;
fscanf(fileList, "%s", cName);
fileSpline = fopen(cName, "r");
if (fileSpline == NULL)
{
printf ("can't open file\n");
exit(1);
}
// gets length for spline file
fscanf(fileSpline, "%d %d", &iLength, &iType);
// allocate memory for all the points
splines[j].points = (Point *)malloc(iLength * sizeof(Point));
splines[j].numControlPoints = iLength;
// saves the data to the struct
while (fscanf(fileSpline, "%lf %lf %lf",
&splines[j].points[i].x,
&splines[j].points[i].y,
&splines[j].points[i].z) != EOF)
{
i++;
}
}
free(cName);
return 0;
}
int initTexture(const char * imageFilename, GLuint textureHandle)
{
// read the texture image
ImageIO img;
ImageIO::fileFormatType imgFormat;
ImageIO::errorType err = img.load(imageFilename, &imgFormat);
if (err != ImageIO::OK)
{
printf("Loading texture from %s failed.\n", imageFilename);
return -1;
}
// check that the number of bytes is a multiple of 4
if (img.getWidth() * img.getBytesPerPixel() % 4)
{
printf("Error (%s): The width*numChannels in the loaded image must be a multiple of 4.\n", imageFilename);
return -1;
}
// allocate space for an array of pixels
int width = img.getWidth();
int height = img.getHeight();
unsigned char * pixelsRGBA = new unsigned char[4 * width * height]; // we will use 4 bytes per pixel, i.e., RGBA
// fill the pixelsRGBA array with the image pixels
memset(pixelsRGBA, 0, 4 * width * height); // set all bytes to 0
for (int h = 0; h < height; h++)
for (int w = 0; w < width; w++)
{
// assign some default byte values (for the case where img.getBytesPerPixel() < 4)
pixelsRGBA[4 * (h * width + w) + 0] = 0; // red
pixelsRGBA[4 * (h * width + w) + 1] = 0; // green
pixelsRGBA[4 * (h * width + w) + 2] = 0; // blue
pixelsRGBA[4 * (h * width + w) + 3] = 255; // alpha channel; fully opaque
// set the RGBA channels, based on the loaded image
int numChannels = img.getBytesPerPixel();
for (int c = 0; c < numChannels; c++) // only set as many channels as are available in the loaded image; the rest get the default value
pixelsRGBA[4 * (h * width + w) + c] = img.getPixel(w, h, c);
}
// bind the texture
glBindTexture(GL_TEXTURE_2D, textureHandle);
// initialize the texture
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixelsRGBA);
// generate the mipmaps for this texture
glGenerateMipmap(GL_TEXTURE_2D);
// set the texture parameters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
// query support for anisotropic texture filtering
GLfloat fLargest;
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fLargest);
printf("Max available anisotropic samples: %f\n", fLargest);
// set anisotropic texture filtering
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 0.5f * fLargest);
// query for any errors
GLenum errCode = glGetError();
if (errCode != 0)
{
printf("Texture initialization error. Error code: %d.\n", errCode);
return -1;
}
// de-allocate the pixel array -- it is no longer needed
delete [] pixelsRGBA;
return 0;
}
void loadGroundTexture () {
glGenTextures(1, &groundHandle);
int code = initTexture("texture_stone.jpg", groundHandle);
if (code != 0) {
printf("Error loading the texture image.\n");
exit(EXIT_FAILURE);
}
glm::vec3* groundPositions = new glm::vec3[6];
glm::vec2* groundTexCoords = new glm::vec2[6];
// Populate positions array
groundPositions[0] = glm::vec3(100, -10, 100);
groundPositions[1] = glm::vec3(100, -10, -100);
groundPositions[2] = glm::vec3(-100, -10, -100);
groundPositions[3] = glm::vec3(100, -10, 100);
groundPositions[4] = glm::vec3(-100, -10, 100);
groundPositions[5] = glm::vec3(-100, -10, -100);
groundTexCoords[0] = glm::vec2(1, 0);
groundTexCoords[1] = glm::vec2(1, 1);
groundTexCoords[2] = glm::vec2(0, 1);
groundTexCoords[3] = glm::vec2(1, 0);
groundTexCoords[4] = glm::vec2(0, 0);
groundTexCoords[5] = glm::vec2(0, 1);
// ============================= Bind texture VAO and VBO ========================
// Set positions VBO
glGenBuffers(1, &groundVBO);
glBindBuffer(GL_ARRAY_BUFFER, groundVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * 6 + sizeof(glm::vec2) * 6, nullptr, GL_STATIC_DRAW);
// Upload position data
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(glm::vec3) * 6, groundPositions);
// Upload texCoord data
glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * 6, sizeof(glm::vec2) * 6, groundTexCoords);
// Set VAO
glGenVertexArrays(1, &groundVAO);
glBindVertexArray(groundVAO);
// Bind vbo
glBindBuffer(GL_ARRAY_BUFFER, groundVBO);
// Set "position" layout
GLuint loc = glGetAttribLocation(texturePipelineProgram->GetProgramHandle(), "position");
glEnableVertexAttribArray(loc);
const void * offset = (const void*) 0;
GLsizei stride = 0;
glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, stride, offset);
// Set "texCoord" layout
loc = glGetAttribLocation(texturePipelineProgram->GetProgramHandle(), "texCoord");
glEnableVertexAttribArray(loc);
// offset = (const void*) sizeof(pointPositions);
// offset = (const void*) (sizeof(glm::vec3) * uNumPoints);
offset = (const void*) (sizeof(glm::vec3) * 6);
glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, stride, offset);
glBindVertexArray(0); // Unbind the VAO
glBindBuffer(GL_ARRAY_BUFFER, 0); // Unbind the VBO
// ======================== End texture VAO/VBO Binding ===========================
}
// write a screenshot to the specified filename
void saveScreenshot(const char * filename)
{
unsigned char * screenshotData = new unsigned char[windowWidth * windowHeight * 3];
glReadPixels(0, 0, windowWidth, windowHeight, GL_RGB, GL_UNSIGNED_BYTE, screenshotData);
ImageIO screenshotImg(windowWidth, windowHeight, 3, screenshotData);
if (screenshotImg.save(filename, ImageIO::FORMAT_JPEG) == ImageIO::OK)
std::cout << "File " << filename << " saved successfully." << endl;
else std::cout << "Failed to save file " << filename << '.' << endl;
delete [] screenshotData;
}
// write a screenshot to the specified filename
/*
void saveScreenshot(const char * filename)
{
int scale = 2;
int ww = windowWidth * scale;
int hh = windowHeight * scale;
unsigned char * screenshotData = new unsigned char[ww * hh * 3];
glReadPixels(0, 0, ww, hh, GL_RGB, GL_UNSIGNED_BYTE, screenshotData);
unsigned char * screenshotData1 = new unsigned char[windowWidth * windowHeight * 3];
for (int h = 0; h < windowHeight; h++) {
for (int w = 0; w < windowWidth; w++) {
int h1 = h * scale;
int w1 = w * scale;
screenshotData1[(h * windowWidth + w) * 3] = screenshotData[(h1 * ww + w1) * 3];
screenshotData1[(h * windowWidth + w) * 3 + 1] = screenshotData[(h1 * ww + w1) * 3 + 1];
screenshotData1[(h * windowWidth + w) * 3 + 2] = screenshotData[(h1 * ww + w1) * 3 + 2];
}
}
ImageIO screenshotImg(windowWidth, windowHeight, 3, screenshotData1);
if (screenshotImg.save(filename, ImageIO::FORMAT_JPEG) == ImageIO::OK)
cout << "File " << filename << " saved successfully." << endl;
else cout << "Failed to save file " << filename << '.' << endl;
delete [] screenshotData;
delete [] screenshotData1;
}*/
void displayFunc()
{
// render some stuff...
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Reset roller coaster frame counter
roller_frame_count %= splineVertexCnt[0];
float m[16], p[16]; // Column-major
if (!camera_on_rail) {
matrix.SetMatrixMode(OpenGLMatrix::ModelView);
matrix.LoadIdentity();
matrix.LookAt(0, 0, 5, 0, 0, 0, 0, 1, 0);
// matrix.SetMatrixMode(OpenGLMatrix::ModelView);
matrix.Translate(landTranslate[0], landTranslate[1], landTranslate[2]);
matrix.Rotate(landRotate[0], 1, 0, 0);
matrix.Rotate(landRotate[1], 0, 1, 0);
matrix.Rotate(landRotate[2], 0, 0, 1);
matrix.Scale(landScale[0], landScale[1], landScale[2]);
matrix.GetMatrix(m);
matrix.SetMatrixMode(OpenGLMatrix::Projection);
matrix.GetMatrix(p);
} else {
matrix.SetMatrixMode(OpenGLMatrix::ModelView);
matrix.LoadIdentity();
int focusIdx = (roller_frame_count+1) % splineVertexCnt[0];
matrix.LookAt(splinePointCoords[0][roller_frame_count].x + 0.13 * splineNormals[0][roller_frame_count].x,
splinePointCoords[0][roller_frame_count].y + 0.13 * splineNormals[0][roller_frame_count].y,
splinePointCoords[0][roller_frame_count].z + 0.13 * splineNormals[0][roller_frame_count].z, // eye point
splinePointCoords[0][focusIdx].x + 0.13 * splineNormals[0][focusIdx].x,
splinePointCoords[0][focusIdx].y + 0.13 * splineNormals[0][focusIdx].y,
splinePointCoords[0][focusIdx].z + 0.13 * splineNormals[0][focusIdx].z, // focus point
splineNormals[0][roller_frame_count].x,
splineNormals[0][roller_frame_count].y,
splineNormals[0][roller_frame_count].z);
matrix.Translate(landTranslate[0], landTranslate[1], landTranslate[2]);
matrix.Rotate(landRotate[0], 1, 0, 0);
matrix.Rotate(landRotate[1], 0, 1, 0);
matrix.Rotate(landRotate[2], 0, 0, 1);
matrix.Scale(landScale[0], landScale[1], landScale[2]);
matrix.GetMatrix(m);
matrix.SetMatrixMode(OpenGLMatrix::Projection);
matrix.GetMatrix(p);
}
// ++roller_frame_count;
roller_frame_count += param_speed;
// DEBUG print
// cout << "Coord: " << splinePointCoords[0][roller_frame_count].x << " " << splinePointCoords[0][roller_frame_count].y << " " << splinePointCoords[0][roller_frame_count].z << endl;
// ================================= Set milestone pipeline program =================================
// get a handle to the program
GLuint milestoneProgram = milestonePipelineProgram->GetProgramHandle();
// get a handle to the modelViewMatrix shader variable
GLint h_modelViewMatrix_milestone = glGetUniformLocation(milestoneProgram, "modelViewMatrix");
// get a handle to the projectionMatrix shader variable
GLint h_projectionMatrix_milestone = glGetUniformLocation(milestoneProgram, "projectionMatrix");
// Get handle to mode shader variable
GLint h_mode_milestone = glGetUniformLocation(milestoneProgram, "mode");
// get a handle to the viewLightDirection shader variable
GLint h_viewLightDirection = glGetUniformLocation(milestoneProgram, "viewLightDirection");
// get a handle to the normalMatrix shader variable
GLint h_normalMatrix = glGetUniformLocation(milestoneProgram, "normalMatrix");
// get a handle to all those constants
GLint h_La = glGetUniformLocation(milestoneProgram, "La");
GLint h_Ld = glGetUniformLocation(milestoneProgram, "Ld");
GLint h_Ls = glGetUniformLocation(milestoneProgram, "Ls");
GLint h_alpha = glGetUniformLocation(milestoneProgram, "alpha");
GLint h_ka = glGetUniformLocation(milestoneProgram, "ka");
GLint h_kd = glGetUniformLocation(milestoneProgram, "kd");
GLint h_ks = glGetUniformLocation(milestoneProgram, "ks");
float n[16];
matrix.SetMatrixMode(OpenGLMatrix::ModelView);
matrix.GetNormalMatrix(n); // get normal matrix
// light direction in the view space
float viewLightDirection[3];
// Compute viewLightDirection
viewLightDirection[0] = m[0] * lightDirection[0] + m[4] * lightDirection[1] + m[8] * lightDirection[2];
viewLightDirection[1] = m[1] * lightDirection[0] + m[5] * lightDirection[1] + m[9] * lightDirection[2];
viewLightDirection[2] = m[2] * lightDirection[0] + m[6] * lightDirection[1] + m[10] * lightDirection[2];
// bind shader
milestonePipelineProgram->Bind();
// Upload matrices to GPU
GLboolean isRowMajor = GL_FALSE;
glUniformMatrix4fv(h_modelViewMatrix_milestone, 1, isRowMajor, m);
glUniformMatrix4fv(h_projectionMatrix_milestone, 1, isRowMajor, p);
// upload viewLightDirection to the GPU
glUniform3fv(h_viewLightDirection, 1, viewLightDirection);
// upload n to the GPU
glUniformMatrix4fv(h_normalMatrix, 1, isRowMajor, n);
// upload light && material parameters to GPU
glUniform4fv(h_La, 1, param_La);
glUniform4fv(h_Ld, 1, param_Ld);
glUniform4fv(h_Ls, 1, param_Ls);
glUniform1f(h_alpha, param_alpha);
glUniform4fv(h_ka, 1, param_ka);
glUniform4fv(h_kd, 1, param_kd);
glUniform4fv(h_ks, 1, param_ks);
// set variable
milestonePipelineProgram->SetModelViewMatrix(m);
milestonePipelineProgram->SetProjectionMatrix(p);
// ================================= End milestone pipeline program =================================
renderSplines();
// ================================= Set texture pipeline program =================================
// get a handle to the program
GLuint textureProgram = texturePipelineProgram->GetProgramHandle();
// get a handle to the modelViewMatrix shader variable
GLint h_modelViewMatrix_texture = glGetUniformLocation(textureProgram, "modelViewMatrix");
// get a handle to the projectionMatrix shader variable
GLint h_projectionMatrix_texture = glGetUniformLocation(textureProgram, "projectionMatrix");
// Get handle to mode shader variable
GLint h_mode_texture = glGetUniformLocation(textureProgram, "mode");
// bind shader
texturePipelineProgram->Bind();
// Upload matrices to GPU
glUniformMatrix4fv(h_modelViewMatrix_texture, 1, isRowMajor, m);
glUniformMatrix4fv(h_projectionMatrix_texture, 1, isRowMajor, p);
// set variable
texturePipelineProgram->SetModelViewMatrix(m);
texturePipelineProgram->SetProjectionMatrix(p);
// select the active texture unit
glActiveTexture(GL_TEXTURE0); // it is safe to always use GL_TEXTURE0
// select the texture to use (“texHandle” was generated by glGenTextures)
glBindTexture(GL_TEXTURE_2D, groundHandle);
// ================================= End milestone pipeline program =================================
// renderWireframe();
renderTexture();
glutSwapBuffers();
}
void idleFunc()
{
if (record_animation == 1) {
// Save screenshots for animation
if (frame_cnt % 4 == 0 && frame_cnt < 1200) {
string file_path = "../screenshots/";
string id;
int t = frame_cnt / 4;
for (int i=0; i<3; ++i) {
id += to_string(t % 10);
t /= 10;
}
reverse(id.begin(), id.end());
file_path += (id + ".jpg");
saveScreenshot(file_path.c_str());
}
++frame_cnt;
}
// make the screen update
glutPostRedisplay();
}
void reshapeFunc(int w, int h)
{
glViewport(0, 0, w, h);
matrix.SetMatrixMode(OpenGLMatrix::Projection);
matrix.LoadIdentity();
matrix.Perspective(54.0f, (float)w / (float)h, 0.01f, 100.0f);
matrix.SetMatrixMode(OpenGLMatrix::ModelView);
}
void mouseMotionDragFunc(int x, int y)
{
// mouse has moved and one of the mouse buttons is pressed (dragging)
// the change in mouse position since the last invocation of this function
int mousePosDelta[2] = { x - mousePos[0], y - mousePos[1] };
switch (controlState)
{
// translate the landscape
case TRANSLATE:
if (leftMouseButton)
{
// control x,y translation via the left mouse button
landTranslate[0] += mousePosDelta[0] * 0.01f;
landTranslate[1] -= mousePosDelta[1] * 0.01f;
}
if (middleMouseButton)
{
// control z translation via the middle mouse button
landTranslate[2] += mousePosDelta[1] * 0.01f;
}
break;
// rotate the landscape
case ROTATE:
if (leftMouseButton)
{
// control x,y rotation via the left mouse button
landRotate[0] += mousePosDelta[1];
landRotate[1] += mousePosDelta[0];
}
if (middleMouseButton)
{
// control z rotation via the middle mouse button
landRotate[2] += mousePosDelta[1];
}
break;
// scale the landscape
case SCALE:
if (leftMouseButton)
{
// control x,y scaling via the left mouse button
landScale[0] *= 1.0f + mousePosDelta[0] * 0.01f;
landScale[1] *= 1.0f - mousePosDelta[1] * 0.01f;
}
if (middleMouseButton)
{
// control z scaling via the middle mouse button
landScale[2] *= 1.0f - mousePosDelta[1] * 0.01f;
}
break;
}
// store the new mouse position
mousePos[0] = x;
mousePos[1] = y;
}
void mouseMotionFunc(int x, int y)
{
// mouse has moved
// store the new mouse position
mousePos[0] = x;
mousePos[1] = y;
}
void mouseButtonFunc(int button, int state, int x, int y)
{
// a mouse button has has been pressed or depressed
// keep track of the mouse button state, in leftMouseButton, middleMouseButton, rightMouseButton variables
switch (button)
{
case GLUT_LEFT_BUTTON:
leftMouseButton = (state == GLUT_DOWN);
break;
case GLUT_MIDDLE_BUTTON:
middleMouseButton = (state == GLUT_DOWN);
break;
case GLUT_RIGHT_BUTTON:
rightMouseButton = (state == GLUT_DOWN);
break;
}
// keep track of whether CTRL and SHIFT keys are pressed
switch (glutGetModifiers())
{
case GLUT_ACTIVE_CTRL:
controlState = TRANSLATE;
break;
case GLUT_ACTIVE_SHIFT:
controlState = SCALE;
break;
// if CTRL and SHIFT are not pressed, we are in rotate mode
default:
controlState = ROTATE;
break;
}
// store the new mouse position
mousePos[0] = x;
mousePos[1] = y;
}
void keyboardFunc(unsigned char key, int x, int y)
{
switch (key)
{
case 27: // ESC key
exit(0); // exit the program
break;
case ' ':
std::cout << "You pressed the spacebar." << endl;
break;
case 't': // Translate
controlState = TRANSLATE;
break;
case 'x':
// take a screenshot
saveScreenshot("screenshot.jpg");
break;
case 's':
// Start capture animation
record_animation = (1 - record_animation);
break;
case 'r':
// Run the roller coaster
camera_on_rail = 1 - camera_on_rail;
if (camera_on_rail) {
cout << "Placing camera on rail. Press 'r' again to change." << endl;
} else {
cout << "Camera free move mode. Press 'r' again to change." << endl;
}
break;
}
}
void renderSplines () {
for (size_t i=0; i<numSplines; ++i) {
// draw left
glBindVertexArray(splineVAOs[i*2]);
// glDrawArrays(GL_LINE_STRIP, 0, splineVertexCnt[i]);
glDrawArrays(GL_TRIANGLES, 0, splineSquareEBOCnt[i*2]);
// glDrawElements(GL_TRIANGLES, splineSquareEBOCnt[i], GL_UNSIGNED_INT, (void*)0);
glBindVertexArray(0);
// draw right
glBindVertexArray(splineVAOs[i*2+1]);
glDrawArrays(GL_TRIANGLES, 0, splineSquareEBOCnt[i*2+1]);
glBindVertexArray(0);
}
}
void renderTexture () {
glBindVertexArray(groundVAO);
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);
}
void add_square_rail_points (glm::vec3* squarePositions, int splineIdx, int pointCnt) {
int squarePointCnt = 0;
for (int i=0; i<pointCnt; ++i) {
Point p_0 = splinePointCoords[splineIdx][i];
Point n_0 = splineNormals[splineIdx][i];
Point b_0 = splineBinormals[splineIdx][i];
Point v_0, v_1, v_2, v_3, v_4;
v_0 = p_0 + (b_0 - n_0) * param_rail_scale;
v_1 = p_0 + (n_0 + b_0) * param_rail_scale;
v_2 = p_0 + (n_0 - b_0) * param_rail_scale;
v_3 = p_0 + (Point(0,0,0) - n_0 - b_0) * param_rail_scale;
squarePositions[squarePointCnt++] = glm::vec3(v_0.x, v_0.y, v_0.z);
squarePositions[squarePointCnt++] = glm::vec3(v_1.x, v_1.y, v_1.z);
squarePositions[squarePointCnt++] = glm::vec3(v_2.x, v_2.y, v_2.z);
squarePositions[squarePointCnt++] = glm::vec3(v_3.x, v_3.y, v_3.z);
}
}
void add_t_rail_points (glm::vec3* tPositions, int splineIdx, int pointCnt) {
int tPointCnt = 0;
double ho_1 = 0.01875;
double ho_2 = 0.0045;
double ho_3 = 0.03;
double ve_1 = 0.016;
double ve_2 = 0.03;
double ve_3 = 0.02625;
for (int i=0; i<pointCnt; ++i) {
Point p_0 = splinePointCoords[splineIdx][i];
Point n_0 = splineNormals[splineIdx][i];
Point b_0 = splineBinormals[splineIdx][i];
Point v_0, v_1, v_2, v_3, v_4, v_5, v_6, v_7, v_8, v_9;
// TODO: check this
v_0 = p_0 + n_0 * ve_2 - b_0 * ho_1;
v_1 = p_0 + n_0 * ve_2 + b_0 * ho_1;
v_2 = p_0 + n_0 * ve_1 - b_0 * ho_1;
v_3 = p_0 + n_0 * ve_1 + b_0 * ho_1;
v_4 = p_0 + n_0 * ve_1 - b_0 * ho_2;
v_5 = p_0 + n_0 * ve_1 + b_0 * ho_2;
v_6 = p_0 - n_0 * ve_1 - b_0 * ho_2;
v_7 = p_0 - n_0 * ve_1 + b_0 * ho_2;
v_8 = p_0 - n_0 * ve_3 - b_0 * ho_3;
v_9 = p_0 - n_0 * ve_3 + b_0 * ho_3;
tPositions[tPointCnt++] = glm::vec3(v_0.x, v_0.y, v_0.z);
tPositions[tPointCnt++] = glm::vec3(v_1.x, v_1.y, v_1.z);
tPositions[tPointCnt++] = glm::vec3(v_2.x, v_2.y, v_2.z);
tPositions[tPointCnt++] = glm::vec3(v_3.x, v_3.y, v_3.z);
tPositions[tPointCnt++] = glm::vec3(v_4.x, v_4.y, v_4.z);
tPositions[tPointCnt++] = glm::vec3(v_5.x, v_5.y, v_5.z);
tPositions[tPointCnt++] = glm::vec3(v_6.x, v_6.y, v_6.z);
tPositions[tPointCnt++] = glm::vec3(v_7.x, v_7.y, v_7.z);
tPositions[tPointCnt++] = glm::vec3(v_8.x, v_8.y, v_8.z);
tPositions[tPointCnt++] = glm::vec3(v_9.x, v_9.y, v_9.z);
}
}
void compute_square_rail_idx (glm::vec3* squareTrianglePositions, glm::vec3* squareColors, glm::vec3* squarePositions, int pointCnt, int splineIdx) {
int currCnt = 0;
for (int i=0; i<pointCnt-1; ++i) {
// TODO: change these into a for loop
// right
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 0];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 4];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 1];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 4];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 5];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 1];
// top
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 1];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 5];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 2];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 5];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 6];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 2];
// left
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 2];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 6];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 3];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 6];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 7];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 3];
// bottom
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 3];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 7];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 0];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 7];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 4];
squareTrianglePositions[currCnt++] = squarePositions[i * 4 + 0];
}
cout << "In idx: " << currCnt << endl;
}
void compute_t_rail_idx (glm::vec3* tTrianglePositions, glm::vec3* tColors, glm::vec3* tPositions, int pointCnt, int splineIdx, bool left) {
int currCnt = 0;
double mult = left? (-0.15) : 0.15;
for (int i=0; i<pointCnt-1; ++i) {
glm::vec3 offset_curr = glm::vec3(splineBinormals[splineIdx][i].x * mult, splineBinormals[splineIdx][i].y * mult, splineBinormals[splineIdx][i].z * mult);
glm::vec3 offset_next = glm::vec3(splineBinormals[splineIdx][i+1].x * mult, splineBinormals[splineIdx][i+1].y * mult, splineBinormals[splineIdx][i+1].z * mult);
// top
tTrianglePositions[currCnt++] = tPositions[i * 10 + 0] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 10] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 1] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 10] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 11] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 1] + offset_curr;
// top left
tTrianglePositions[currCnt++] = tPositions[i * 10 + 2] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 12] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 0] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 12] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 10] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 0] + offset_curr;
// top bottom left
tTrianglePositions[currCnt++] = tPositions[i * 10 + 2] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 12] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 14] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 2] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 4] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 14] + offset_next;
// left
tTrianglePositions[currCnt++] = tPositions[i * 10 + 4] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 14] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 16] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 4] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 6] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 16] + offset_next;
// bottom top left
tTrianglePositions[currCnt++] = tPositions[i * 10 + 6] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 8] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 18] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 6] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 16] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 18] + offset_next;
// bottom
tTrianglePositions[currCnt++] = tPositions[i * 10 + 8] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 9] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 19] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 8] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 18] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 19] + offset_next;
// bottom top right
tTrianglePositions[currCnt++] = tPositions[i * 10 + 7] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 9] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 19] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 7] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 17] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 19] + offset_next;
// right
tTrianglePositions[currCnt++] = tPositions[i * 10 + 5] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 7] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 17] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 5] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 15] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 17] + offset_next;
// top bottom right
tTrianglePositions[currCnt++] = tPositions[i * 10 + 5] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 3] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 13] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 5] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 15] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 13] + offset_next;
// top right
tTrianglePositions[currCnt++] = tPositions[i * 10 + 1] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 3] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 13] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 1] + offset_curr;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 11] + offset_next;
tTrianglePositions[currCnt++] = tPositions[i * 10 + 13] + offset_next;
}
}
void compute_store_points_tangents (glm::vec3* pointPositions, int splineIdx, int pointCnt, int u_cnt, Point& p_1, Point& p_2, Point& p_3, Point& p_4) {
Point res = computeMatrix.computePosition(u_cnt * param_u_step, p_1, p_2, p_3, p_4);
// Position vector to put into VBO
pointPositions[pointCnt] = glm::vec3(res.x, res.y, res.z);
// Global position vector to track point locations
splinePointCoords[splineIdx].push_back(res);
Point tangent = computeMatrix.computeTangent(u_cnt * param_u_step, p_1, p_2, p_3, p_4);
// Global tangent vector to track tangent of spline at this point
splineTangents[splineIdx].push_back(tangent);
}
void compute_catmull_rom_point (glm::vec3* pointPositions, glm::vec3* squarePositions, Point* points, int currNumCtrlPts, int splineIdx, Point& prev_1, Point& prev_2, Point& next_1, bool connect_prev, bool connect_next) {
int pointCnt = 0;
if (connect_prev) {
// First segment to connect with previous spline
for (int u_cnt=0; u_cnt < (int)(1.0 / param_u_step); ++u_cnt) {
compute_store_points_tangents(pointPositions, splineIdx, pointCnt, u_cnt, prev_2, prev_1, points[1], points[2]);
++pointCnt;
}
// Second segment to connect with previous spline
for (int u_cnt=0; u_cnt < (int)(1.0 / param_u_step); ++u_cnt) {
compute_store_points_tangents(pointPositions, splineIdx, pointCnt, u_cnt, prev_1, points[1], points[2], points[3]);
++pointCnt;
}
}
int start = connect_prev ? 2 : 1;
int end = connect_next ? (currNumCtrlPts-3) : (currNumCtrlPts-2);
for (int i=start; i<end; ++i) {
for (int u_cnt=0; u_cnt < (int)(1.0 / param_u_step); ++u_cnt) {
compute_store_points_tangents(pointPositions, splineIdx, pointCnt, u_cnt, points[i-1], points[i], points[i+1], points[i+2]);
++pointCnt;
}
}
// last point
if (connect_next) {
for (int u_cnt=0; u_cnt <= (int)(1.0 / param_u_step); ++u_cnt) {
compute_store_points_tangents(pointPositions, splineIdx, pointCnt, u_cnt, points[currNumCtrlPts-4], points[currNumCtrlPts-3], points[currNumCtrlPts-2], next_1);
++pointCnt;
}
} else {
compute_store_points_tangents(pointPositions, splineIdx, pointCnt, (int)(1.0 / param_u_step), points[currNumCtrlPts-4], points[currNumCtrlPts-3], points[currNumCtrlPts-2], points[currNumCtrlPts-1]);
++pointCnt;
}
cout << "IN func: " << pointCnt << endl;
// Compute initial Frenet Frame vectors
Point T_0 = splineTangents[splineIdx][0];
Point N_0 = normalize(T_0.cross(initial_V));
Point B_0 = normalize(T_0.cross(N_0));
splineNormals[splineIdx].push_back(N_0);
splineBinormals[splineIdx].push_back(B_0);
for (int i=1; i<pointCnt; ++i) {
splineNormals[splineIdx].push_back(normalize(splineBinormals[splineIdx][i-1].cross(splineTangents[splineIdx][i])));
splineBinormals[splineIdx].push_back(normalize(splineTangents[splineIdx][i].cross(splineNormals[splineIdx][i])));
}
// Add four square vertices for each spline point
// Switch to square rail
// add_square_rail_points(squarePositions, splineIdx, pointCnt);
// Switch to t shaped rail
add_t_rail_points(squarePositions, splineIdx, pointCnt);
}
void initScene(int argc, char *argv[])
{
// load the splines from the provided filename
loadSplines(argv[1]);
printf("Loaded %d spline(s).\n", numSplines);
for(int i=0; i<numSplines; i++)
printf("Num control points in spline %d: %d.\n", i, splines[i].numControlPoints);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
/*
Initialize pipelineProgram
*/
milestonePipelineProgram = new BasicPipelineProgram;
int ret = milestonePipelineProgram->Init(shaderBasePath, false);
if (ret != 0) abort();
texturePipelineProgram = new BasicPipelineProgram;
ret = texturePipelineProgram->Init(shaderBasePath, true);
if (ret != 0) abort();
// Load ground texture
loadGroundTexture();
Point prev_1_point;
Point prev_2_point;
Point next_1_point;
// Intialize global coord and tangent vectors
splinePointCoords.resize(numSplines); // mult by 2 for two rails
splineTangents.resize(numSplines);
splineNormals.resize(numSplines);
splineBinormals.resize(numSplines);
for (int i=0; i<numSplines; ++i) {
// cout << "[DEBUG] Control points: " << splines[i].numControlPoints << endl;
int currNumCtrlPts = splines[i].numControlPoints;
// currNumCtrlPts - 3 segments, +1 for endpoint
int uNumPoints = ((int)(1.0 / param_u_step)) * (currNumCtrlPts - 3) + 1;
GLuint currLeftVBO, currRightVBO, currLeftVAO, currRightVAO;
GLuint currEBO;
bool connect_prev = false;
if (i > 0) {
connect_prev = true;
prev_1_point = splines[i-1].points[splines[i-1].numControlPoints-2];
prev_2_point = splines[i-1].points[splines[i-1].numControlPoints-3];
}
bool connect_next = false;
if (i < numSplines - 1) {
connect_next = true;
next_1_point = splines[i+1].points[1];
}
cout << connect_prev << " " << connect_next << endl;
if (connect_prev) {
uNumPoints += ((int)(1.0 / param_u_step));
}
int squareIdxCnt = 24 * (uNumPoints - 1);
int tIdxCnt = 60 * (uNumPoints - 1);
cout << "uNum: " << uNumPoints << endl;
glm::vec3* pointPositions = new glm::vec3[uNumPoints];
// TODO: change this to general positions
// Switch to square rail
glm::vec3* squarePositions = new glm::vec3[uNumPoints * 4];
// Switch to t shaped rail
glm::vec3* tPositions = new glm::vec3[uNumPoints * 10];
glm::vec3* squareTrianglePositions = new glm::vec3[squareIdxCnt];
glm::vec3* tLeftTrianglePositions = new glm::vec3[tIdxCnt];
glm::vec3* tRightTrianglePositions = new glm::vec3[tIdxCnt];
// unsigned int* squareIndex = new unsigned int[squareIdxCnt];
// TODO: remove this.
glm::vec4* pointColors = new glm::vec4[uNumPoints];
// TODO: Change this to normal
glm::vec3* squareColors = new glm::vec3[squareIdxCnt];
glm::vec3* tColors = new glm::vec3[tIdxCnt];
// Disable multiple curve connection
// connect_prev = false;
// connect_next = false;
compute_catmull_rom_point(pointPositions, tPositions, splines[i].points, currNumCtrlPts, i, prev_1_point, prev_2_point, next_1_point, connect_prev, connect_next);
// Set colors for line track
for (int j=0; j<uNumPoints; ++j) {
pointColors[j] = glm::vec4(1.0, 1.0, 1.0, 1.0);
}
// TODO: remove this
// Set colors for square track as normal
for (int j=0; j<uNumPoints-1; ++j) {
for (int k=0; k<6; ++k) {
// bottom right: right
squareColors[j*24+k] = glm::vec3(splineBinormals[i][j].x, splineBinormals[i][j].y, splineBinormals[i][j].z);
// top right: top
squareColors[j*24+1*6+k] = glm::vec3(splineNormals[i][j].x, splineNormals[i][j].y, splineNormals[i][j].z);
// top left: left
squareColors[j*24+2*6+k] = glm::vec3(-splineBinormals[i][j].x, -splineBinormals[i][j].y, -splineBinormals[i][j].z);
// bottom left: bottom
squareColors[j*24+3*6+k] = glm::vec3(-splineNormals[i][j].x, -splineNormals[i][j].y, -splineNormals[i][j].z);
}
}
// Compute vertex colors for t shaped rail
for (int j=0; j<uNumPoints-1; ++j) {
for (int k=0; k<6; ++k) {
// top
tColors[j*60+k] = glm::vec3(splineNormals[i][j].x, splineNormals[i][j].y, splineNormals[i][j].z);
// top left
tColors[j*60+1*6+k] = glm::vec3(-splineBinormals[i][j].x, -splineBinormals[i][j].y, -splineBinormals[i][j].z);
// top bottom left
tColors[j*60+2*6+k] = glm::vec3(-splineNormals[i][j].x, -splineNormals[i][j].y, -splineNormals[i][j].z);
// left
tColors[j*60+3*6+k] = glm::vec3(-splineBinormals[i][j].x, -splineBinormals[i][j].y, -splineBinormals[i][j].z);
// bottom top left // TODO: change this to slope normal
tColors[j*60+4*6+k] = glm::vec3(splineNormals[i][j].x, splineNormals[i][j].y, splineNormals[i][j].z);
// bottom
tColors[j*60+5*6+k] = glm::vec3(-splineNormals[i][j].x, -splineNormals[i][j].y, -splineNormals[i][j].z);
// bottom top right // TODO: change this to slope normal
tColors[j*60+6*6+k] = glm::vec3(splineNormals[i][j].x, splineNormals[i][j].y, splineNormals[i][j].z);
// right
tColors[j*60+7*6+k] = glm::vec3(splineBinormals[i][j].x, splineBinormals[i][j].y, splineBinormals[i][j].z);
// top bottom right
tColors[j*60+8*6+k] = glm::vec3(-splineNormals[i][j].x, -splineNormals[i][j].y, -splineNormals[i][j].z);
// top right
tColors[j*60+9*6+k] = glm::vec3(splineBinormals[i][j].x, splineBinormals[i][j].y, splineBinormals[i][j].z);
}
}
// add triangle vertex for square track
// compute_square_rail_idx(squareTrianglePositions, squareColors, squarePositions, uNumPoints, i);
bool left = true;
compute_t_rail_idx(tLeftTrianglePositions, tColors, tPositions, uNumPoints, i, left);
compute_t_rail_idx(tRightTrianglePositions, tColors, tPositions, uNumPoints, i, !left);
// =================================================== Bind vertex VAO and VBO for left rail ===================================================
// Set positions VBO
glGenBuffers(1, &currLeftVBO);
glBindBuffer(GL_ARRAY_BUFFER, currLeftVBO);
// glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * uNumPoints + sizeof(glm::vec4) * uNumPoints, nullptr, GL_STATIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * tIdxCnt + sizeof(glm::vec3) * tIdxCnt, nullptr, GL_STATIC_DRAW);
// Upload position data
// glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(glm::vec3) * uNumPoints, pointPositions);
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(glm::vec3) * tIdxCnt, tLeftTrianglePositions);
// Upload color data
// glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * uNumPoints, sizeof(glm::vec4) * uNumPoints, pointColors);
glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * tIdxCnt, sizeof(glm::vec3) * tIdxCnt, tColors);
glGenVertexArrays(1, &currLeftVAO);
glBindVertexArray(currLeftVAO);
// Bind pointVBO
glBindBuffer(GL_ARRAY_BUFFER, currLeftVBO);
// Set "position" layout
GLuint loc = glGetAttribLocation(milestonePipelineProgram->GetProgramHandle(), "position");
glEnableVertexAttribArray(loc);
const void * offset = (const void*) 0;
GLsizei stride = 0;
glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, stride, offset);
// Set "color" layout
loc = glGetAttribLocation(milestonePipelineProgram->GetProgramHandle(), "normal");
glEnableVertexAttribArray(loc);
// offset = (const void*) sizeof(pointPositions);
// offset = (const void*) (sizeof(glm::vec3) * uNumPoints);
offset = (const void*) (sizeof(glm::vec3) * tIdxCnt);
glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, stride, offset);
glBindVertexArray(0); // Unbind the VAO
glBindBuffer(GL_ARRAY_BUFFER, 0); // Unbind the VBO
// =================================================== End vertex VAO/VBO Binding ===================================================
// =================================================== Bind vertex VAO and VBO for right rail ===================================================
// Set positions VBO
glGenBuffers(1, &currRightVBO);
glBindBuffer(GL_ARRAY_BUFFER, currRightVBO);
// glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * uNumPoints + sizeof(glm::vec4) * uNumPoints, nullptr, GL_STATIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * tIdxCnt + sizeof(glm::vec3) * tIdxCnt, nullptr, GL_STATIC_DRAW);
// Upload position data
// glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(glm::vec3) * uNumPoints, pointPositions);
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(glm::vec3) * tIdxCnt, tRightTrianglePositions);
// Upload color data
// glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * uNumPoints, sizeof(glm::vec4) * uNumPoints, pointColors);
glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * tIdxCnt, sizeof(glm::vec3) * tIdxCnt, tColors);
glGenVertexArrays(1, &currRightVAO);
glBindVertexArray(currRightVAO);
// Bind pointVBO
glBindBuffer(GL_ARRAY_BUFFER, currRightVBO);
// Set "position" layout
loc = glGetAttribLocation(milestonePipelineProgram->GetProgramHandle(), "position");
glEnableVertexAttribArray(loc);
offset = (const void*) 0;
stride = 0;
glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, stride, offset);
// Set "color" layout
loc = glGetAttribLocation(milestonePipelineProgram->GetProgramHandle(), "normal");
glEnableVertexAttribArray(loc);
// offset = (const void*) sizeof(pointPositions);
// offset = (const void*) (sizeof(glm::vec3) * uNumPoints);
offset = (const void*) (sizeof(glm::vec3) * tIdxCnt);
glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, stride, offset);
glBindVertexArray(0); // Unbind the VAO
glBindBuffer(GL_ARRAY_BUFFER, 0); // Unbind the VBO
// =================================================== End vertex VAO/VBO Binding ===================================================
splineVBOs.push_back(currLeftVBO);
splineVAOs.push_back(currLeftVAO);
splineVertexCnt.push_back(uNumPoints);
splineSquareEBOCnt.push_back(60 * (uNumPoints - 1));
splineVBOs.push_back(currRightVBO);
splineVAOs.push_back(currRightVAO);
splineVertexCnt.push_back(uNumPoints);
splineSquareEBOCnt.push_back(60 * (uNumPoints - 1));
delete [] pointColors;
delete [] pointPositions;
delete [] squareColors;
delete [] squarePositions;
delete [] squareTrianglePositions;
}
glEnable(GL_DEPTH_TEST);
std::cout << "GL error: " << glGetError() << std::endl;
}
int main(int argc, char *argv[])
{
if (argc<2)
{
printf ("usage: %s <trackfile>\n", argv[0]);
exit(0);
}
std::cout << "Initializing GLUT..." << endl;
glutInit(&argc,argv);
std::cout << "Initializing OpenGL..." << endl;
#ifdef __APPLE__
glutInitDisplayMode(GLUT_3_2_CORE_PROFILE | GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL);
#else
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL);
#endif
glutInitWindowSize(windowWidth, windowHeight);
glutInitWindowPosition(0, 0);
glutCreateWindow(windowTitle);
std::cout << "OpenGL Version: " << glGetString(GL_VERSION) << endl;
std::cout << "OpenGL Renderer: " << glGetString(GL_RENDERER) << endl;
std::cout << "Shading Language Version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << endl;
#ifdef __APPLE__
// This is needed on recent Mac OS X versions to correctly display the window.
glutReshapeWindow(windowWidth - 1, windowHeight - 1);
#endif
// tells glut to use a particular display function to redraw
glutDisplayFunc(displayFunc);
// perform animation inside idleFunc
glutIdleFunc(idleFunc);
// callback for mouse drags
glutMotionFunc(mouseMotionDragFunc);
// callback for idle mouse movement
glutPassiveMotionFunc(mouseMotionFunc);
// callback for mouse button changes
glutMouseFunc(mouseButtonFunc);
// callback for resizing the window
glutReshapeFunc(reshapeFunc);
// callback for pressing the keys on the keyboard
glutKeyboardFunc(keyboardFunc);
// init glew
#ifdef __APPLE__
// nothing is needed on Apple
#else
// Windows, Linux
GLint result = glewInit();
if (result != GLEW_OK)
{
std::cout << "error: " << glewGetErrorString(result) << endl;
exit(EXIT_FAILURE);
}
#endif
// do initialization
initScene(argc, argv);
// sink forever into the glut loop
glutMainLoop();
}
| [
"ziangliu@usc.edu"
] | ziangliu@usc.edu |
ace1f99fb7b438eb472636b15e378466ca275e4c | dac1cc13f6b3cb0f561107f379ca7bc1205f9f72 | /generateParentheses.cpp | b8dc3fdcd75deb938934eabf33def44d4a681558 | [] | no_license | adityavijay88/avijay | 8cfd76d76ba789acaf6b17598846254f8f158da1 | 759e136164fea60216fb8d68c1019be0ce40cc59 | refs/heads/master | 2016-09-06T17:01:55.035108 | 2014-12-01T10:41:53 | 2014-12-01T10:41:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 539 | cpp | #include <iostream>
#include <math.h>
#include <vector>
using namespace std;
void gp(string str, int l, int h,int &n, vector<string>&res){
if(l>n) return;
if(l==n && h==n){
res.push_back(str);
}else{
gp(str+"(",l+1,h,n,res);
if(l>h){
gp(str+")",l,h+1,n,res);
}
}
}
void generateP(int n){
vector<string>res;
if(n==0) return ;
gp("",0,0,n,res);
for(int i=0;i<res.size();i++){
cout<<res[i]<<endl;
}
}
int main()
{
generateP(3);
return 0;
}
| [
"avijay@usc.edu"
] | avijay@usc.edu |
a50a1500c7cea25b44342a3b9632406056758c1b | 4f8e66ebd1bc845ba011907c9fc7c6400dd7a6be | /SDL_Core/src/components/JSONHandler/src/SDLRPCObjectsImpl/V2/ReadDID_responseMarshaller.cpp | bfadc37b7544fbdbf75386e688b93869cb616a93 | [] | no_license | zhanzhengxiang/smartdevicelink | 0145c304f28fdcebb67d36138a3a34249723ae28 | fbf304e5c3b0b269cf37d3ab22ee14166e7a110b | refs/heads/master | 2020-05-18T11:54:10.005784 | 2014-05-18T09:46:33 | 2014-05-18T09:46:33 | 20,008,961 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,717 | cpp | //
// Copyright (c) 2013, Ford Motor Company
// 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 the Ford Motor Company 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 "../include/JSONHandler/SDLRPCObjects/V2/ReadDID_response.h"
#include "ResultMarshaller.h"
#include "VehicleDataResultCodeMarshaller.h"
#include "ReadDID_responseMarshaller.h"
/*
interface Ford Sync RAPI
version 2.0O
date 2012-11-02
generated at Thu Jan 24 06:36:23 2013
source stamp Thu Jan 24 06:35:41 2013
author RC
*/
using namespace NsSmartDeviceLinkRPCV2;
bool ReadDID_responseMarshaller::checkIntegrity(ReadDID_response& s)
{
return checkIntegrityConst(s);
}
bool ReadDID_responseMarshaller::fromString(const std::string& s,ReadDID_response& e)
{
try
{
Json::Reader reader;
Json::Value json;
if(!reader.parse(s,json,false)) return false;
if(!fromJSON(json,e)) return false;
}
catch(...)
{
return false;
}
return true;
}
const std::string ReadDID_responseMarshaller::toString(const ReadDID_response& e)
{
Json::FastWriter writer;
return checkIntegrityConst(e) ? writer.write(toJSON(e)) : "";
}
bool ReadDID_responseMarshaller::checkIntegrityConst(const ReadDID_response& s)
{
if(!ResultMarshaller::checkIntegrityConst(s.resultCode)) return false;
if(s.info && s.info->length()>1000) return false;
if(s.dataResult)
{
unsigned int i=s.dataResult[0].size();
if(i>1000 || i<0) return false;
while(i--)
{
if(!VehicleDataResultCodeMarshaller::checkIntegrityConst(s.dataResult[0][i])) return false;
}
}
if(s.data)
{
unsigned int i=s.data[0].size();
if(i>1000 || i<0) return false;
while(i--)
{
if(s.data[0][i].length()>5000) return false;
}
}
return true;
}
Json::Value ReadDID_responseMarshaller::toJSON(const ReadDID_response& e)
{
Json::Value json(Json::objectValue);
if(!checkIntegrityConst(e))
return Json::Value(Json::nullValue);
json["success"]=Json::Value(e.success);
json["resultCode"]=ResultMarshaller::toJSON(e.resultCode);
if(e.info)
json["info"]=Json::Value(*e.info);
if(e.dataResult)
{
unsigned int sz=e.dataResult->size();
json["dataResult"]=Json::Value(Json::arrayValue);
json["dataResult"].resize(sz);
for(unsigned int i=0;i<sz;i++)
json["dataResult"][i]=VehicleDataResultCodeMarshaller::toJSON(e.dataResult[0][i]);
}
if(e.data)
{
unsigned int sz=e.data->size();
json["data"]=Json::Value(Json::arrayValue);
json["data"].resize(sz);
for(unsigned int i=0;i<sz;i++)
json["data"][i]=Json::Value(e.data[0][i]);
}
return json;
}
bool ReadDID_responseMarshaller::fromJSON(const Json::Value& json,ReadDID_response& c)
{
if(c.info) delete c.info;
c.info=0;
if(c.dataResult) delete c.dataResult;
c.dataResult=0;
if(c.data) delete c.data;
c.data=0;
try
{
if(!json.isObject()) return false;
if(!json.isMember("success")) return false;
{
const Json::Value& j=json["success"];
if(!j.isBool()) return false;
c.success=j.asBool();
}
if(!json.isMember("resultCode")) return false;
{
const Json::Value& j=json["resultCode"];
if(!ResultMarshaller::fromJSON(j,c.resultCode))
return false;
}
if(json.isMember("info"))
{
const Json::Value& j=json["info"];
if(!j.isString()) return false;
c.info=new std::string(j.asString());
}
if(json.isMember("dataResult"))
{
const Json::Value& j=json["dataResult"];
if(!j.isArray()) return false;
c.dataResult=new std::vector<VehicleDataResultCode>();
c.dataResult->resize(j.size());
for(unsigned int i=0;i<j.size();i++)
{
VehicleDataResultCode t;
if(!VehicleDataResultCodeMarshaller::fromJSON(j[i],t))
return false;
c.dataResult[0][i]=t;
}
}
if(json.isMember("data"))
{
const Json::Value& j=json["data"];
if(!j.isArray()) return false;
c.data=new std::vector<std::string>();
c.data->resize(j.size());
for(unsigned int i=0;i<j.size();i++)
if(!j[i].isString())
return false;
else
c.data[0][i]=j[i].asString();
}
}
catch(...)
{
return false;
}
return checkIntegrity(c);
}
| [
"kburdet1@ford.com"
] | kburdet1@ford.com |
028f28b367bf8aa37568029940e0d483d2055024 | 96aed31564b495b225ad39ed9491424b67ba0d56 | /source/update_check.cpp | 94b7835c9fe1606c32b4410aafd89eb0ddad4ff7 | [
"BSD-3-Clause"
] | permissive | masterwishx/reshade | 3d30c7a17169c8ab3261fe4fd4512979b7c641cb | 7977654d52463670cac0065fbcefb9443448c406 | refs/heads/master | 2020-04-19T22:48:33.464592 | 2019-01-30T21:24:00 | 2019-01-30T21:24:00 | 168,479,638 | 2 | 0 | BSD-3-Clause | 2019-01-31T07:08:03 | 2019-01-31T07:08:03 | null | UTF-8 | C++ | false | false | 2,115 | cpp | #include "version.h"
#include "runtime.hpp"
#include <Windows.h>
#include <WinInet.h>
struct scoped_handle
{
scoped_handle(HINTERNET handle) : handle(handle) {}
~scoped_handle() { InternetCloseHandle(handle); }
inline operator HINTERNET() const { return handle; }
private:
HINTERNET handle;
};
bool reshade::runtime::check_for_update(unsigned long latest_version[3])
{
memset(latest_version, 0, 3 * sizeof(unsigned long));
#if !defined(_DEBUG)
const scoped_handle handle = InternetOpen(L"reshade", INTERNET_OPEN_TYPE_PRECONFIG, nullptr, nullptr, 0);
if (handle == nullptr)
{
return false;
}
constexpr auto api_url = TEXT("https://api.github.com/repos/crosire/reshade/tags");
const scoped_handle request = InternetOpenUrl(handle, api_url, nullptr, 0, INTERNET_FLAG_RELOAD | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_NO_CACHE_WRITE, 0);
if (request == nullptr)
{
return false;
}
char response_data[32];
DWORD response_length = 0;
if (InternetReadFile(request, response_data, sizeof(response_data) - 1, &response_length) && response_length > 0)
{
response_data[response_length] = '\0';
const char *version_major_offset = std::strchr(response_data, 'v');
if (version_major_offset == nullptr) return false; else version_major_offset++;
const char *version_minor_offset = std::strchr(version_major_offset, '.');
if (version_minor_offset == nullptr) return false; else version_minor_offset++;
const char *version_revision_offset = std::strchr(version_minor_offset, '.');
if (version_revision_offset == nullptr) return false; else version_revision_offset++;
latest_version[0] = std::strtoul(version_major_offset, nullptr, 10);
latest_version[1] = std::strtoul(version_minor_offset, nullptr, 10);
latest_version[2] = std::strtoul(version_revision_offset, nullptr, 10);
if ((latest_version[0] > VERSION_MAJOR) ||
(latest_version[0] == VERSION_MAJOR && latest_version[1] > VERSION_MINOR) ||
(latest_version[0] == VERSION_MAJOR && latest_version[1] == VERSION_MINOR && latest_version[2] > VERSION_REVISION))
{
return true;
}
}
#endif
return false;
}
| [
"crosiredev@gmail.com"
] | crosiredev@gmail.com |
575d236b6250052206dc13eeee87e32f7e7f47f5 | d4b4513c6314871a268ab97d0aece052a632d57d | /soft/common/protocpp/gtool.eproto.pb.cc | b63ff3876ca20ed5d941dd8a8564bd0434416c26 | [] | no_license | atom-chen/tssj | f99b87bcaa809a99e8af0e2ba388dbaac7156a31 | f4345ad6b39f7f058fac987c2fed678d719a4482 | refs/heads/master | 2022-03-14T22:23:50.952836 | 2019-10-31T11:47:28 | 2019-10-31T11:47:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | true | 13,079 | cc | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: gtool.eproto
#include "gtool.eproto.pb.h"
#include <algorithm>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/port.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// This is a temporary google only hack
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
#include "third_party/protobuf/version.h"
#endif
// @@protoc_insertion_point(includes)
namespace dhc {
class gtool_tDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<gtool_t>
_instance;
} _gtool_t_default_instance_;
} // namespace dhc
namespace protobuf_gtool_2eeproto {
static void InitDefaultsgtool_t() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::dhc::_gtool_t_default_instance_;
new (ptr) ::dhc::gtool_t();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::dhc::gtool_t::InitAsDefaultInstance();
}
::google::protobuf::internal::SCCInfo<0> scc_info_gtool_t =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsgtool_t}, {}};
void InitDefaults() {
::google::protobuf::internal::InitSCC(&scc_info_gtool_t.base);
}
::google::protobuf::Metadata file_level_metadata[1];
const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::dhc::gtool_t, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::dhc::gtool_t, guid_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::dhc::gtool_t, num_),
};
static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::dhc::gtool_t)},
};
static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::dhc::_gtool_t_default_instance_),
};
void protobuf_AssignDescriptors() {
AddDescriptors();
AssignDescriptors(
"gtool.eproto", schemas, file_default_instances, TableStruct::offsets,
file_level_metadata, NULL, NULL);
}
void protobuf_AssignDescriptorsOnce() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
}
void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n\014gtool.eproto\022\003dhc\"$\n\007gtool_t\022\014\n\004guid\030\001"
" \001(\004\022\013\n\003num\030\002 \001(\004b\006proto3"
};
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
descriptor, 65);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"gtool.eproto", &protobuf_RegisterTypes);
}
void AddDescriptors() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at dynamic initialization time.
struct StaticDescriptorInitializer {
StaticDescriptorInitializer() {
AddDescriptors();
}
} static_descriptor_initializer;
} // namespace protobuf_gtool_2eeproto
namespace dhc {
// ===================================================================
void gtool_t::InitAsDefaultInstance() {
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int gtool_t::kGuidFieldNumber;
const int gtool_t::kNumFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
gtool_t::gtool_t()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
::google::protobuf::internal::InitSCC(
&protobuf_gtool_2eeproto::scc_info_gtool_t.base);
SharedCtor();
// @@protoc_insertion_point(constructor:dhc.gtool_t)
}
gtool_t::gtool_t(const gtool_t& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
::memcpy(&guid_, &from.guid_,
static_cast<size_t>(reinterpret_cast<char*>(&num_) -
reinterpret_cast<char*>(&guid_)) + sizeof(num_));
// @@protoc_insertion_point(copy_constructor:dhc.gtool_t)
}
void gtool_t::SharedCtor() {
::memset(&guid_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&num_) -
reinterpret_cast<char*>(&guid_)) + sizeof(num_));
}
gtool_t::~gtool_t() {
// @@protoc_insertion_point(destructor:dhc.gtool_t)
SharedDtor();
}
void gtool_t::SharedDtor() {
}
void gtool_t::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ::google::protobuf::Descriptor* gtool_t::descriptor() {
::protobuf_gtool_2eeproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_gtool_2eeproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const gtool_t& gtool_t::default_instance() {
::google::protobuf::internal::InitSCC(&protobuf_gtool_2eeproto::scc_info_gtool_t.base);
return *internal_default_instance();
}
void gtool_t::Clear() {
// @@protoc_insertion_point(message_clear_start:dhc.gtool_t)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
::memset(&guid_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&num_) -
reinterpret_cast<char*>(&guid_)) + sizeof(num_));
_internal_metadata_.Clear();
}
bool gtool_t::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:dhc.gtool_t)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// uint64 guid = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
input, &guid_)));
} else {
goto handle_unusual;
}
break;
}
// uint64 num = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
input, &num_)));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:dhc.gtool_t)
return true;
failure:
// @@protoc_insertion_point(parse_failure:dhc.gtool_t)
return false;
#undef DO_
}
void gtool_t::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:dhc.gtool_t)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// uint64 guid = 1;
if (this->guid() != 0) {
::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->guid(), output);
}
// uint64 num = 2;
if (this->num() != 0) {
::google::protobuf::internal::WireFormatLite::WriteUInt64(2, this->num(), output);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
}
// @@protoc_insertion_point(serialize_end:dhc.gtool_t)
}
::google::protobuf::uint8* gtool_t::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
(void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:dhc.gtool_t)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// uint64 guid = 1;
if (this->guid() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(1, this->guid(), target);
}
// uint64 num = 2;
if (this->num() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(2, this->num(), target);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:dhc.gtool_t)
return target;
}
size_t gtool_t::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:dhc.gtool_t)
size_t total_size = 0;
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
}
// uint64 guid = 1;
if (this->guid() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::UInt64Size(
this->guid());
}
// uint64 num = 2;
if (this->num() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::UInt64Size(
this->num());
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void gtool_t::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:dhc.gtool_t)
GOOGLE_DCHECK_NE(&from, this);
const gtool_t* source =
::google::protobuf::internal::DynamicCastToGenerated<const gtool_t>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:dhc.gtool_t)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:dhc.gtool_t)
MergeFrom(*source);
}
}
void gtool_t::MergeFrom(const gtool_t& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:dhc.gtool_t)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.guid() != 0) {
set_guid(from.guid());
}
if (from.num() != 0) {
set_num(from.num());
}
}
void gtool_t::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:dhc.gtool_t)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void gtool_t::CopyFrom(const gtool_t& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:dhc.gtool_t)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool gtool_t::IsInitialized() const {
return true;
}
void gtool_t::Swap(gtool_t* other) {
if (other == this) return;
InternalSwap(other);
}
void gtool_t::InternalSwap(gtool_t* other) {
using std::swap;
swap(guid_, other->guid_);
swap(num_, other->num_);
_internal_metadata_.Swap(&other->_internal_metadata_);
}
::google::protobuf::Metadata gtool_t::GetMetadata() const {
protobuf_gtool_2eeproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_gtool_2eeproto::file_level_metadata[kIndexInFileMessages];
}
// @@protoc_insertion_point(namespace_scope)
} // namespace dhc
namespace google {
namespace protobuf {
template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::dhc::gtool_t* Arena::CreateMaybeMessage< ::dhc::gtool_t >(Arena* arena) {
return Arena::CreateInternal< ::dhc::gtool_t >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
| [
"rocketxyfb@163.com"
] | rocketxyfb@163.com |
d09f223a403a5a0b7e8ec9ebcba8037cc356e190 | 46dffb041c76cfccbf58e325129867ed05a3a391 | /boat-ws/devel/include/vesc_msgs/VescState.h | 6c9408540a685ed83998ef99ea542e26e0446fc2 | [] | no_license | loloduca/AV_Invisible_Boat | 8537f9edba79482037d61811b292972826bea05a | c0631c3b91cabdbc0ae3b4c579cd95bbb4f7a02c | refs/heads/master | 2021-04-30T13:02:22.820990 | 2018-03-14T18:15:00 | 2018-03-14T18:15:00 | 121,286,633 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,357 | h | // Generated by gencpp from file vesc_msgs/VescState.msg
// DO NOT EDIT!
#ifndef VESC_MSGS_MESSAGE_VESCSTATE_H
#define VESC_MSGS_MESSAGE_VESCSTATE_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
namespace vesc_msgs
{
template <class ContainerAllocator>
struct VescState_
{
typedef VescState_<ContainerAllocator> Type;
VescState_()
: voltage_input(0.0)
, temperature_pcb(0.0)
, current_motor(0.0)
, current_input(0.0)
, speed(0.0)
, duty_cycle(0.0)
, charge_drawn(0.0)
, charge_regen(0.0)
, energy_drawn(0.0)
, energy_regen(0.0)
, displacement(0.0)
, distance_traveled(0.0)
, fault_code(0) {
}
VescState_(const ContainerAllocator& _alloc)
: voltage_input(0.0)
, temperature_pcb(0.0)
, current_motor(0.0)
, current_input(0.0)
, speed(0.0)
, duty_cycle(0.0)
, charge_drawn(0.0)
, charge_regen(0.0)
, energy_drawn(0.0)
, energy_regen(0.0)
, displacement(0.0)
, distance_traveled(0.0)
, fault_code(0) {
(void)_alloc;
}
typedef double _voltage_input_type;
_voltage_input_type voltage_input;
typedef double _temperature_pcb_type;
_temperature_pcb_type temperature_pcb;
typedef double _current_motor_type;
_current_motor_type current_motor;
typedef double _current_input_type;
_current_input_type current_input;
typedef double _speed_type;
_speed_type speed;
typedef double _duty_cycle_type;
_duty_cycle_type duty_cycle;
typedef double _charge_drawn_type;
_charge_drawn_type charge_drawn;
typedef double _charge_regen_type;
_charge_regen_type charge_regen;
typedef double _energy_drawn_type;
_energy_drawn_type energy_drawn;
typedef double _energy_regen_type;
_energy_regen_type energy_regen;
typedef double _displacement_type;
_displacement_type displacement;
typedef double _distance_traveled_type;
_distance_traveled_type distance_traveled;
typedef int32_t _fault_code_type;
_fault_code_type fault_code;
enum { FAULT_CODE_NONE = 0 };
enum { FAULT_CODE_OVER_VOLTAGE = 1 };
enum { FAULT_CODE_UNDER_VOLTAGE = 2 };
enum { FAULT_CODE_DRV8302 = 3 };
enum { FAULT_CODE_ABS_OVER_CURRENT = 4 };
enum { FAULT_CODE_OVER_TEMP_FET = 5 };
enum { FAULT_CODE_OVER_TEMP_MOTOR = 6 };
typedef boost::shared_ptr< ::vesc_msgs::VescState_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::vesc_msgs::VescState_<ContainerAllocator> const> ConstPtr;
}; // struct VescState_
typedef ::vesc_msgs::VescState_<std::allocator<void> > VescState;
typedef boost::shared_ptr< ::vesc_msgs::VescState > VescStatePtr;
typedef boost::shared_ptr< ::vesc_msgs::VescState const> VescStateConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::vesc_msgs::VescState_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::vesc_msgs::VescState_<ContainerAllocator> >::stream(s, "", v);
return s;
}
} // namespace vesc_msgs
namespace ros
{
namespace message_traits
{
// BOOLTRAITS {'IsFixedSize': True, 'IsMessage': True, 'HasHeader': False}
// {'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../msg'], 'vesc_msgs': ['/home/racecar/AV_Invisible_Boat/boat-ws/src/vesc/vesc_msgs/msg']}
// !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types']
template <class ContainerAllocator>
struct IsFixedSize< ::vesc_msgs::VescState_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::vesc_msgs::VescState_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::vesc_msgs::VescState_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::vesc_msgs::VescState_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::vesc_msgs::VescState_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct HasHeader< ::vesc_msgs::VescState_<ContainerAllocator> const>
: FalseType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::vesc_msgs::VescState_<ContainerAllocator> >
{
static const char* value()
{
return "81214bb4c1945e7c159bd76ec397ac04";
}
static const char* value(const ::vesc_msgs::VescState_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0x81214bb4c1945e7cULL;
static const uint64_t static_value2 = 0x159bd76ec397ac04ULL;
};
template<class ContainerAllocator>
struct DataType< ::vesc_msgs::VescState_<ContainerAllocator> >
{
static const char* value()
{
return "vesc_msgs/VescState";
}
static const char* value(const ::vesc_msgs::VescState_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::vesc_msgs::VescState_<ContainerAllocator> >
{
static const char* value()
{
return "# Vedder VESC open source motor controller state (telemetry)\n\
\n\
# fault codes\n\
int32 FAULT_CODE_NONE=0\n\
int32 FAULT_CODE_OVER_VOLTAGE=1\n\
int32 FAULT_CODE_UNDER_VOLTAGE=2\n\
int32 FAULT_CODE_DRV8302=3\n\
int32 FAULT_CODE_ABS_OVER_CURRENT=4\n\
int32 FAULT_CODE_OVER_TEMP_FET=5\n\
int32 FAULT_CODE_OVER_TEMP_MOTOR=6\n\
\n\
float64 voltage_input # input voltage (volt)\n\
float64 temperature_pcb # temperature of printed circuit board (degrees Celsius)\n\
float64 current_motor # motor current (ampere)\n\
float64 current_input # input current (ampere)\n\
float64 speed # motor electrical speed (revolutions per minute) \n\
float64 duty_cycle # duty cycle (0 to 1)\n\
float64 charge_drawn # electric charge drawn from input (ampere-hour)\n\
float64 charge_regen # electric charge regenerated to input (ampere-hour)\n\
float64 energy_drawn # energy drawn from input (watt-hour)\n\
float64 energy_regen # energy regenerated to input (watt-hour)\n\
float64 displacement # net tachometer (counts)\n\
float64 distance_traveled # total tachnometer (counts)\n\
int32 fault_code\n\
";
}
static const char* value(const ::vesc_msgs::VescState_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::vesc_msgs::VescState_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.voltage_input);
stream.next(m.temperature_pcb);
stream.next(m.current_motor);
stream.next(m.current_input);
stream.next(m.speed);
stream.next(m.duty_cycle);
stream.next(m.charge_drawn);
stream.next(m.charge_regen);
stream.next(m.energy_drawn);
stream.next(m.energy_regen);
stream.next(m.displacement);
stream.next(m.distance_traveled);
stream.next(m.fault_code);
}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct VescState_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::vesc_msgs::VescState_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::vesc_msgs::VescState_<ContainerAllocator>& v)
{
s << indent << "voltage_input: ";
Printer<double>::stream(s, indent + " ", v.voltage_input);
s << indent << "temperature_pcb: ";
Printer<double>::stream(s, indent + " ", v.temperature_pcb);
s << indent << "current_motor: ";
Printer<double>::stream(s, indent + " ", v.current_motor);
s << indent << "current_input: ";
Printer<double>::stream(s, indent + " ", v.current_input);
s << indent << "speed: ";
Printer<double>::stream(s, indent + " ", v.speed);
s << indent << "duty_cycle: ";
Printer<double>::stream(s, indent + " ", v.duty_cycle);
s << indent << "charge_drawn: ";
Printer<double>::stream(s, indent + " ", v.charge_drawn);
s << indent << "charge_regen: ";
Printer<double>::stream(s, indent + " ", v.charge_regen);
s << indent << "energy_drawn: ";
Printer<double>::stream(s, indent + " ", v.energy_drawn);
s << indent << "energy_regen: ";
Printer<double>::stream(s, indent + " ", v.energy_regen);
s << indent << "displacement: ";
Printer<double>::stream(s, indent + " ", v.displacement);
s << indent << "distance_traveled: ";
Printer<double>::stream(s, indent + " ", v.distance_traveled);
s << indent << "fault_code: ";
Printer<int32_t>::stream(s, indent + " ", v.fault_code);
}
};
} // namespace message_operations
} // namespace ros
#endif // VESC_MSGS_MESSAGE_VESCSTATE_H
| [
"brettg0396@gmail.com"
] | brettg0396@gmail.com |
ffef3fc8160cd68b4971dddd8037f6af11692ae2 | 448ae129ff28b0e4688fbf105d40681f9aa896d5 | /2DWalking/src/objects/boxs/colliderbox.cpp | 95b55befd5bbbcb8573220779c69e4c6d5736a32 | [] | no_license | ISahoneI/2DWalking | 00ef06711946f837de3a897bfa9187f5723a9884 | bbdd5a3d11becfd26d806a056b6950e25db310c0 | refs/heads/master | 2021-06-24T06:23:53.274731 | 2020-10-25T23:46:49 | 2020-10-25T23:46:49 | 138,442,552 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,739 | cpp | #include "colliderbox.h"
Colliderbox::Colliderbox(float x, float y, float width, float height) : Sprite(x, y, width, height, glm::vec4(128, 0, 255, 128))
{
setIsRender(false);
setIsVisible(false);
setIsCollidable(true);
setLevel(SpriteLevel::LEVEL4);
}
Colliderbox::~Colliderbox()
{
}
bool Colliderbox::isOverlap(const Colliderbox* target)
{
bool collisionX = this->getPositionX() + this->getWidth() >= target->getPositionX() &&
target->getPositionX() + target->getWidth() >= this->getPositionX();
bool collisionY = this->getPositionY() + this->getHeight() >= target->getPositionY() &&
target->getPositionY() + target->getHeight() >= this->getPositionY();
return collisionX && collisionY;
}
bool Colliderbox::collide(const Colliderbox* target)
{
if (!getIsCollidable() || !target->getIsCollidable())
return false;
const glm::vec2 thisCenter = glm::vec2(getPositionX() + getWidth() * 0.5f, getPositionY() + getHeight() * 0.5f);
const glm::vec2 targetCenter = glm::vec2(target->getPositionX() + target->getWidth() * 0.5f, target->getPositionY() + target->getHeight() * 0.5f);
const float dx = thisCenter.x - targetCenter.x;
const float dy = thisCenter.y - targetCenter.y;
const float aw = (getWidth() + target->getWidth()) * 0.5f;
const float ah = (getHeight() + target->getHeight()) * 0.5f;
if (abs(dx) >= aw || abs(dy) >= ah)
return false;
if (abs(dx / target->getWidth()) > abs(dy / target->getHeight())) {
if (dx < 0) setPositionX(target->getPositionX() - getWidth());
else setPositionX(target->getPositionX() + target->getWidth());
}
else {
if (dy < 0) setPositionY(target->getPositionY() - getHeight());
else setPositionY(target->getPositionY() + target->getHeight());
}
return true;
}
| [
"Sahone.come@hotmail.fr"
] | Sahone.come@hotmail.fr |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.