blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 2
247
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
57
| license_type
stringclasses 2
values | repo_name
stringlengths 4
111
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
58
| visit_date
timestamp[ns]date 2015-07-25 18:16:41
2023-09-06 10:45:08
| revision_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| committer_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| github_id
int64 3.89k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 25
values | gha_event_created_at
timestamp[ns]date 2012-06-07 00:51:45
2023-09-14 21:58:52
⌀ | gha_created_at
timestamp[ns]date 2008-03-27 23:40:48
2023-08-24 19:49:39
⌀ | gha_language
stringclasses 159
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
10.5M
| extension
stringclasses 111
values | filename
stringlengths 1
195
| text
stringlengths 7
10.5M
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
e086176a9ea787f17e4b952677e2418877586daa
|
d6f690f2e32b73056e7c429dd070fdd68d34f3e0
|
/C++/剑指Offer算法题/42_1_ReverseSentence.cpp
|
f62e459737b7afe32f45f81a1ab8fb714386c828
|
[] |
no_license
|
ccc013/DataStructe-Algorithms_Study
|
13da51c72bbccfc7ca117b6925f57fc5d04bc1f7
|
8987859c4c3faedf7159b5a6ec3155609689760e
|
refs/heads/master
| 2021-06-22T16:28:09.438171
| 2021-03-06T01:48:24
| 2021-03-06T01:48:24
| 60,660,281
| 15
| 11
| null | null | null | null |
GB18030
|
C++
| false
| false
| 1,758
|
cpp
|
42_1_ReverseSentence.cpp
|
#include<iostream>
#include<string>
using std::string;
using std::cout;
using std::endl;
using std::cin;
/*输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺序不变。*/
// 翻转字符串中的一段
void Reverse(string &pStr, int pBegin, int pEnd){
if (pStr.size() <= 0)
return;
char temp;
int j = (pEnd - pBegin) / 2;
for (int i = 0; i <= j; i++){
temp = pStr[pBegin];
pStr[pBegin++] = pStr[pEnd];
pStr[pEnd--] = temp;
}
}
// 解法,先翻转整个句子,再翻转每个单词
string ReverseSentence(string pData){
if (pData.size() <= 0)
return NULL;
int pBegin = 0;
int pEnd = pData.size() - 1;
// 翻转整个句子
Reverse(pData, pBegin,pEnd);
// 翻转句子中的每个单词
int i = 0;
// 判断是否找到单词
bool isWord = false;
pBegin = pEnd = 0;
while (pData[pEnd+1] != '\0'){
if (pData[pEnd] != ' ' && pData[pEnd] != '\0'){
++pEnd;
isWord = true;
}
else{
// 找到单词
Reverse(pData, pBegin, pEnd-1);
isWord = false;
// 下一个还是空格
while (pData[pEnd + 1] == ' ' && pData[pEnd + 1] != '\0')
++pEnd;
pBegin = ++pEnd;
}
}
if (isWord)
// 最后一个单词
Reverse(pData, pBegin, pEnd);
return pData;
}
void Test(string pData){
if (pData.size()>0)
cout << "Test sentence: " << pData << endl;
else
cout << "Test for NULL: \n";
string pResult = ReverseSentence(pData);
if (pData.size()>0)
cout << "Reverse sentence: " << pResult << endl;
else
cout << "NULL\n";
}
// 测试
int main(void){
char *test[] = { "hello world. I will go back!", "hello"};
for (int i = 0; i < 2; i++)
Test(test[i]);
system("pause");
return 0;
}
|
1c2dd969b0895c1e0c327e883da8694eb7129206
|
9f9ac37f22333569ae3bec78075d0918c3ad2742
|
/include/tab_completion.hxx
|
9b2ee6d8b3dafdd8560f27baf8f996a44bc8f56d
|
[
"MIT"
] |
permissive
|
credativ/pg_backup_ctl-plus
|
602bcd0ce2bcce1653dd340e7b134c3b8f92973d
|
d1655f9791be9227e17b60731829bbd8572e850b
|
refs/heads/master
| 2023-03-20T22:15:21.159701
| 2021-03-16T18:08:53
| 2021-03-16T18:08:53
| 348,447,804
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 442
|
hxx
|
tab_completion.hxx
|
#include <rtconfig.hxx>
/*
* Helper functions/callbacks for readline support.
*
* See tab_completion.cxx for details.
*/
char **keyword_completion(const char *input, int start, int end);
/*
* Initializes readline machinery.
*/
void init_readline(std::string catalog_name,
std::shared_ptr<pgbckctl::RuntimeConfiguration> rtc);
/*
* Resets readline machinery after command
* completion.
*/
void step_readline();
|
5029f4bbb00465f6dc0bc64925b59efb2dff4c7e
|
bfb8b16cf73137018cd39c03f3aa87c5efe59c28
|
/PCR.ino
|
69d3ce650a8e05988a5075824d8b00320807c87f
|
[
"BSD-3-Clause",
"BSD-2-Clause"
] |
permissive
|
opensourcelabsdotca/PCR
|
cc55ada341ebac98285f7dc8e703fb7697cd5428
|
a28eaf78d66790b9404e2cd2a13cf21bfe21ca16
|
refs/heads/master
| 2016-09-06T07:30:54.142899
| 2014-08-21T04:02:54
| 2014-08-21T04:02:54
| 23,168,029
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,789
|
ino
|
PCR.ino
|
#include <Adafruit_GFX.h> // https://github.com/adafruit/Adafruit-GFX-Library
#include <Adafruit_PCD8544.h> // https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library
#include "Adafruit_MAX31855.h" // https://github.com/adafruit/Adafruit-MAX31855-library
#define Relay1 8
#define Relay2 12
#define thermoDO 7
#define thermoCS 10
#define thermoCLK 11
#define lid 3 //pin for heated lid
#define buzzer A2
#define thermistor A1
//pid control (proportional and integral)
#define Kp 2.0
#define Ki 0.07
#define startPin A4
#define stopPin 13
#define alarmThreshold 100
#define holdThresholdUpper 0
#define holdThresholdLower 1
#define NUMTEMPS 20 //number of temperatures in the lookup table
short temptable[NUMTEMPS][2] = {
{1, 916},
{54, 265},
{107, 216},
{160, 189},
{213, 171},
{266, 157},
{319, 146},
{372, 136},
{425, 127},
{478, 118},
{531, 110},
{584, 103},
{637, 95},
{690, 88},
{743, 80},
{796, 71},
{849, 62},
{902, 50},
{955, 34},
{1008, 2},
};
//temperature table for thermistor
/*PCR state defined as:
0 = standby
1 = denature
2 = anneal
3 = extend
4 = hold
*/
int pcrState = 0;
int cycleCount = 0;
//code for buttons, debouncing
int startState; //the state of the start button
int stopState;
int lastStartState = LOW; //previous button state
int lastStopState = LOW;
long lastDebounceTime = 0;
long debounceDelay = 50;
//variable that stores run time
int startTime = 0;
//variables that keep track of hold time
long holdStart = 0;
long holdMillis = 0;
long holdInterval = 50;
double holdTemp = 0;
//stores last PCR state
int intpcrState = 0;
// pin 9- Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin A0 - LCD reset (RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(9, 6, 5, 4, A0);
Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);
//heated lid code
double lidSetpoint = 350; //optimal reading for the heated lid thermistor
double integral = 0; //pid control for heated lid
int lidPower = 0;
double lidError = 0;
//code for temperature slope
long interval = 1000; //interval at which temperature is measures
long previousMillis = 0;
double previousTemp = 0;
double deltaTemp[3]={
0,0,0}; //average of last three seconds
//to be changed to amount of time needed for temperature to change one degree
//temperature of the thermal block, measured by thermocouple
double blockTemp()
{
return (thermocouple.readCelsius());
}
void setup()
{
Serial.begin(9600);
pinMode(startPin, INPUT);
pinMode(stopPin, INPUT);
pinMode(Relay1, OUTPUT);
pinMode(Relay2, OUTPUT);
pinMode(3,OUTPUT); //pin for encoder
pinMode(buzzer, INPUT);
// Serial.println("MAX31855 test");
// wait for MAX chip to stabilize
delay(500);
display.begin();
// init done
// you can change the contrast around to adapt the display
// for the best viewing!
display.setContrast(50);
}
void loop()
{
alarm();
if (stopbutton())
{
off();
cycleCount = 0;
startTime = 0;
}
screen();
//debugLid();
//debugHold();
switch (pcrState)
{
case 0:
if (startbutton())
{
startTime = millis();
}
break;
case 1:
heat();
if (blockTemp() >= 95)
{
pcrState = 2;
hold(2);
}
break;
case 2:
cool();
if (blockTemp() <= 55)
{
pcrState = 3;
hold(3);
}
break;
case 3:
heat();
if (blockTemp() == 75)
{
heat();
cycleCount++;
if (cycleCount == 30) pcrState = 5;
else
{
hold(1);
}
}
break;
case 4:
{
if(holdTemp - blockTemp() >= holdThresholdLower)
{
heat();
}
if(blockTemp() - holdTemp >= holdThresholdUpper)
{
off();
}
// if (millis() - holdStart < holdInterval)
// {
// heat();
// if (blockTemp() >= holdTemp)
// {
// off;
// }
// }
if ((millis() - holdStart) > 30000) pcrState = intpcrState;
}
break;
case 5:
if (cycleCount == 30)
{
off();
pcrState = 0;
}
break;
//install counter and turn relays off until it expires
}
Serial.println(blockTemp());
//pid();
//heat();
/*while(blockTemp() < 95)
{
Serial.println(blockTemp());
screen();
display.display();
delay(100);
}
cool();
while(blockTemp() > 55)
{
Serial.println(blockTemp());
screen();
display.display();
delay(100);
}
heat();
while(blockTemp() < 70)
{
Serial.println(blockTemp());
screen();
display.display();
delay(100);
}
*/
//off();
// delay(1000);
//display.print("P value = ");
display.display();
}
|
8a72bc92bc8d999470b5da63737135f99b93d9c9
|
d322446df7dc61a83c9e4cd4a25f32a6bef10e30
|
/Banking Management System/Banking Management System/User.cpp
|
94916f581df0cb6ef7ac138af2292152f2b93d4a
|
[] |
no_license
|
SirenLX/CPlusPlus-Banking-Management-System
|
1666aadcabd7f51e82d42f95cf717b00539a9563
|
a61ada489fdf0ff5b22f295c5fec033a881b915e
|
refs/heads/master
| 2020-03-30T03:56:33.603433
| 2018-10-01T08:22:13
| 2018-10-01T08:22:13
| 150,716,231
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,306
|
cpp
|
User.cpp
|
#include "User.h"
#include <iostream>
#include <vector>
// ----- Getters ----- //
// Function to get the userID of the user
int User::GetUserID() { return userID; }
// Function to get the username of the user
std::string User::GetUsername() { return username; }
// Function to get the account number of the user
int User::GetAccountNumber() { return accountNumber; }
// Function to get the account balance of the user
float User::GetAccountBalance() { return accountBalance; }
// Function to get the user's first name
std::string User::GetUserFirstName() { return firstName; }
// Function to get the user's last name
std::string User::GetUserLastName() { return lastName; }
// Function to get the user's middle name
std::string User::GetUserMiddleName() { return middleName; }
// Function to get the user's hashed password
std::string User::GetUserHashedPassword() { return hashedPassword; }
// ----- Setters ----- //
// Function to set the userID of the user
void User::SetUserID(int userIDInput) { userID = userIDInput; }
// Function to set the username of the user
void User::SetUsername(std::string usernameInput) { username = usernameInput; }
// Function to set the account number of the user
void User::SetAccountNumber(int accountNumberInput) { accountNumber = accountNumberInput; }
// Function to set the account balance of the user
void User::SetAccountBalance(float accountBalanceInput) { accountBalance = accountBalanceInput; }
// Function to set the user's first name
void User::SetUserFirstName(std::string firstNameInput) { firstName = firstNameInput; }
// Function to set the user's last name
void User::SetUserLastName(std::string lastNameInput) { lastName = lastNameInput; }
// Function to set the user's middle name
void User::SetUserMiddleName(std::string middleNameInput) { middleName = middleNameInput; }
// Function to set the user's hashed password
void User::SetUserHashedPassword(std::string hashedPasswordInput) { hashedPassword = hashedPasswordInput; }
// ----- Main Functions and Methods ----- //
// Function to add amount to the user's account balance
void User::AddAccountBalance(int amount) { accountBalance += amount; }
// Function to deduct amount from the user's account balance
void User::DeductAccountBalance(int amount) { accountBalance -= amount; }
|
9787190ec2e27241f3b73aaac035b640ee21662c
|
a5e05718b6f8b402141e6cfd963b340c613200bc
|
/Submodules/mxml/src/mxml/parsing/MeasureHandler.h
|
d2b54fd515b235f85255370cf2584467c5dd27a9
|
[
"MIT"
] |
permissive
|
yk81708090/musitkit
|
8617699d49da9ddea0dc28897c0f6a0895fac9de
|
7d57e4dd3a21df2dc82f6725accdd89a8560d7d2
|
refs/heads/master
| 2022-04-07T08:23:46.894850
| 2019-12-20T19:25:29
| 2019-12-20T19:25:29
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,647
|
h
|
MeasureHandler.h
|
// Copyright © 2016 Venture Media Labs.
//
// This file is part of mxml. The full mxml copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
#pragma once
#include <lxml/BaseRecursiveHandler.h>
#include "AttributesHandler.h"
#include "BackupHandler.h"
#include "BarlineHandler.h"
#include "DirectionHandler.h"
#include "ForwardHandler.h"
#include "NoteHandler.h"
#include "PrintHandler.h"
#include <mxml/dom/Chord.h>
#include <mxml/dom/Measure.h>
#include <memory>
namespace mxml {
namespace parsing {
class MeasureHandler : public lxml::BaseRecursiveHandler<std::unique_ptr<dom::Measure>> {
public:
MeasureHandler() : _lastTime(), _time() {}
RecursiveHandler* startSubElement(const lxml::QName& qname);
void endElement(const lxml::QName& qname, const std::string& contents);
void endSubElement(const lxml::QName& qname, RecursiveHandler* parser);
void startElement(const lxml::QName& qname, const AttributeMap& attributes);
private:
void handleNote(std::unique_ptr<dom::Note>&& note);
void startChord(std::unique_ptr<dom::Note>&& note);
void endChord();
private:
AttributesHandler _attributesHandler;
NoteHandler _noteHandler;
BackupHandler _backupHandler;
ForwardHandler _forwardHandler;
DirectionHandler _directionHandler;
PrintHandler _printHandler;
BarlineHandler _barlineHandler;
const dom::Attributes* _attributes;
dom::Chord* _chord;
int _lastTime;
int _time;
bool _empty;
};
} // namespace parsing
} // namespace mxml
|
0d624751a06c54715a4860f1c7f3ca543d0bf1ba
|
e013ec787e57af5c8c798f5714d9f930b76dfd32
|
/Solutions/Codeforces Solutions/101020-D_Sequences.cpp
|
dea1ad6dd082fbdfc8bf27c8c5260726604c28cf
|
[] |
no_license
|
omaryasser/Competitive-Programming
|
da66cb75bf6ed5495454d2f57333b02fe30a5b68
|
ba71b23ae3d0c4ef8bbdeff0cd12c3daca19d809
|
refs/heads/master
| 2021-04-29T00:39:29.663196
| 2019-02-19T04:20:56
| 2019-02-19T04:20:56
| 121,832,844
| 17
| 8
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 53
|
cpp
|
101020-D_Sequences.cpp
|
https://codeforces.com/gym/101020/submission/20176490
|
de5e8180c38a45895457f3f7a6c0dd02b182210b
|
ffff723a6c8527b45299a7e6aec3044c9b00e923
|
/PS/BOJ/11005/11005.cc
|
ea7fffe4ddd777f8510acbf44686121b2eb071e9
|
[] |
no_license
|
JSYoo5B/TIL
|
8e3395a106656e090eeb0260fa0b0dba985d3beb
|
3f9ce4c65451512cfa2279625e44a844d476b68f
|
refs/heads/master
| 2022-03-14T09:15:59.828223
| 2022-02-26T01:30:41
| 2022-02-26T01:30:41
| 231,383,838
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 456
|
cc
|
11005.cc
|
#include <iostream>
#include <stack>
using namespace std;
int main(void) {
stack<char> base_nums;
int number;
cin >> number;
int base;
cin >> base;
while(number > 0) {
int new_num = number % base;
char conv_num;
if (new_num < 10)
conv_num = new_num + '0';
else
conv_num = new_num - 10 + 'A';
base_nums.push(conv_num);
number /= base;
}
while(base_nums.empty() == false) {
cout << base_nums.top();
base_nums.pop();
}
}
|
698fe30e6bbb95e74c57e0327013c2a0d6b87475
|
a83378a11aa6b7f766374b50bd5082a2acb7ae54
|
/Xtreme/DX11/DX11Renderer.cpp
|
53b792fb0e9249dae996401ca7f75582940cd42f
|
[] |
no_license
|
Spritutu/Common
|
5e21579fa767621b6d3e487bdd9f12209d8f0948
|
311e512d896f563a9353c743bb0878dafcca1b5b
|
refs/heads/master
| 2022-12-25T16:36:40.449491
| 2020-09-27T09:48:18
| 2020-09-27T09:50:10
| null | 0
| 0
| null | null | null | null |
ISO-8859-2
|
C++
| false
| false
| 124,923
|
cpp
|
DX11Renderer.cpp
|
#include "DX11Font.h"
#include "DX11Renderer.h"
#include "DX11PixelShader.h"
#include "DX11Texture.h"
#include "DX11VertexShader.h"
#include "DX11VertexBuffer.h"
#include <Xtreme/XAsset/XAssetLoader.h>
#include <Xtreme/XAsset/XAssetImage.h>
#include <Xtreme/XAsset/XAssetImageSection.h>
#include <Xtreme/XAsset/XAssetFont.h>
#include <Xtreme/XAsset/XAssetMesh.h>
#include <Xtreme/MeshFormate/T3DLoader.h>
#include <Grafik/ImageFormate/ImageFormatManager.h>
#include <Xtreme/Environment/XWindow.h>
#if ( OPERATING_SUB_SYSTEM == OS_SUB_UNIVERSAL_APP ) || ( OPERATING_SUB_SYSTEM == OS_SUB_WINDOWS_PHONE )
#include <Xtreme/Environment/XWindowUniversalApp.h>
#endif
#include <IO/FileUtil.h>
#include <String/StringUtil.h>
#if ( OPERATING_SUB_SYSTEM == OS_SUB_UNIVERSAL_APP )
#include <dxgi1_4.h>
#elif ( OPERATING_SUB_SYSTEM == OS_SUB_WINDOWS_PHONE )
#include <dxgi1_3.h>
#else
#include <WinSys/SubclassManager.h>
#endif
#pragma comment( lib, "d3d11.lib" )
#pragma comment( lib, "dxgi.lib" )
DX11Renderer::DX11Renderer( HINSTANCE hInstance ) :
m_Width( 0 ),
m_Height( 0 ),
m_VSyncEnabled( false ),
m_pDevice( NULL ),
m_pDeviceContext( NULL ),
m_pMatrixBuffer( NULL ),
m_pLightBuffer( NULL ),
m_pMaterialBuffer( NULL ),
m_pFogBuffer( NULL ),
m_pSwapChain( NULL ),
m_pTargetBackBuffer( NULL ),
m_pTempBuffer( NULL ),
m_pSamplerStateLinear( NULL ),
m_pSamplerStatePoint( NULL ),
m_pRasterizerStateCullBack( NULL ),
m_pRasterizerStateCullFront( NULL ),
m_pRasterizerStateCullNone( NULL ),
m_pRasterizerStateCullBackWireframe( NULL ),
m_pRasterizerStateCullFrontWireframe( NULL ),
m_pRasterizerStateCullNoneWireframe( NULL ),
m_pBlendStateAdditive( NULL ),
m_pBlendStateNoBlend( NULL ),
m_pBlendStateAlphaBlend( NULL ),
m_CurrentShaderType( ST_INVALID ),
m_NumActiveLights( 0 ),
m_LightingEnabled( false ),
m_depthStencilBuffer( NULL ),
m_depthStencilStateZBufferCheckAndWriteEnabled( NULL ),
m_depthStencilStateZBufferCheckAndWriteDisabled( NULL ),
m_depthStencilStateZBufferCheckEnabledNoWrite( NULL ),
m_depthStencilStateZBufferWriteEnabledNoCheck( NULL ),
m_depthStencilView( NULL ),
m_pCurrentlySetRenderTargetTexture( NULL ),
m_QuadCache( this, XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_NORMAL | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_XYZRHW ),
m_QuadCache3d( this, XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_NORMAL | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_XYZ ),
m_LineCache( this, XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_NORMAL | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_XYZRHW ),
m_LineCache3d( this, XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_NORMAL | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_XYZ ),
m_TriangleCache( this, XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_NORMAL | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_XYZRHW ),
m_TriangleCache3d( this, XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_NORMAL | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_XYZ ),
m_Windowed( true ),
m_CacheMode( CM_QUAD ),
m_LightsChanged( false ),
m_ForceToWindowedMode( false ),
m_TogglingFullScreen( false ),
m_Ready( false )
{
m_ClearColor[0] = 0.0f;
m_ClearColor[1] = 0.0f;
m_ClearColor[2] = 0.0f;
m_ClearColor[3] = 1.0f;
for ( int i = 0; i < 8; ++i )
{
m_SetTextures[i] = NULL;
m_SetLights[i].m_Type = XLight::LT_INVALID;
m_LightEnabled[i] = false;
}
m_Material.Ambient = ColorValue( 0xffffffff );
m_Material.Emissive = ColorValue();
m_Material.Diffuse = ColorValue( 0xffffffff );
m_Material.Specular = ColorValue( 0xffffffff );
m_Material.SpecularPower = 1.0f;
}
DX11Renderer::~DX11Renderer()
{
Release();
}
bool DX11Renderer::AddBasicVertexShaderFromFile( const GR::String& Filename, const GR::String& Desc, GR::u32 VertexFormat )
{
GR::String basePath = "D:/projekte/Xtreme/DX11Renderer/shaders/";
//GR::String basePath = "D:/privat/projekte/Xtreme/DX11Renderer/shaders/";
ByteBuffer shaderData = GR::IO::FileUtil::ReadFileAsBuffer( ( basePath + Filename ).c_str() );
if ( shaderData.Empty() )
{
return false;
}
auto pVShader = AddBasicVertexShader( Desc, shaderData.ToHexString(), VertexFormat );
if ( pVShader == NULL )
{
return false;
}
pVShader->m_LoadedFromFile = Filename;
return true;
}
bool DX11Renderer::AddBasicPixelShaderFromFile( const GR::String& Filename, const GR::String& Desc, GR::u32 VertexFormat )
{
GR::String basePath = "D:/projekte/Xtreme/DX11Renderer/shaders/";
//GR::String basePath = "D:/privat/projekte/Xtreme/DX11Renderer/shaders/";
ByteBuffer shaderData = GR::IO::FileUtil::ReadFileAsBuffer( ( basePath + Filename ).c_str() );
if ( shaderData.Empty() )
{
return false;
}
return AddBasicPixelShader( Desc, shaderData.ToHexString(), VertexFormat );
}
bool DX11Renderer::InitialiseBasicShaders()
{
bool hadError = false;
#include "ShaderBinary.inl"
return !hadError;
return true;
}
DX11VertexShader* DX11Renderer::AddBasicVertexShader( const GR::String& Desc, const GR::String& HexVS, GR::u32 VertexFormat )
{
ByteBuffer vsFlat( HexVS );
auto shader = new DX11VertexShader( this, VertexFormat );
if ( !shader->CreateFromBuffers( vsFlat ) )
{
delete shader;
return NULL;
}
m_BasicVertexShaders[Desc] = shader;
m_VertexShaders.push_back( shader );
m_VSInputLayout[VertexFormat] = shader;
return shader;
}
bool DX11Renderer::AddBasicPixelShader( const GR::String& Desc, const GR::String& HexPS, GR::u32 VertexFormat )
{
ByteBuffer psFlat( HexPS );
auto shader = new DX11PixelShader( this );
if ( !shader->CreateFromBuffers( psFlat ) )
{
delete shader;
return false;
}
m_BasicPixelShaders[Desc] = shader;
m_PixelShaders.push_back( shader );
return true;
}
bool DX11Renderer::Initialize( GR::u32 Width,
GR::u32 Height,
GR::u32 Depth,
GR::u32 Flags,
GR::IEnvironment& Environment )
{
if ( m_Ready )
{
return true;
}
m_pEnvironment = &Environment;
m_Windowed = !( Flags & XRenderer::IN_FULLSCREEN );
m_VSyncEnabled = !!( Flags & XRenderer::IN_VSYNC );
UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#if OPERATING_SUB_SYSTEM == OS_SUB_DESKTOP
#if defined(_DEBUG)
//if ( DX::SdkLayersAvailable() )
{
// If the project is in a debug build, enable debugging via SDK Layers with this flag.
creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
}
#endif
#endif
#if OPERATING_SUB_SYSTEM == OS_SUB_WINDOWS_PHONE
//creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_3,
D3D_FEATURE_LEVEL_9_2,
D3D_FEATURE_LEVEL_9_1
};
m_FeatureLevel = D3D_FEATURE_LEVEL_9_1;
ID3D11DeviceContext* pDC;
ID3D11Device* pDevice;
HRESULT hr = D3D11CreateDevice( nullptr, // Specify nullptr to use the default adapter.
D3D_DRIVER_TYPE_HARDWARE, // Create a device using the harare graphics driver.
0, // Should be 0 unless the driver is D3D_DRIVER_TYPE_SOFTWARE.
creationFlags, // Set debug and Direct2D compatibility flags.
featureLevels, // List of feature levels this app can support.
ARRAYSIZE( featureLevels ), // Size of the list above.
D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps.
&pDevice, // Returns the Direct3D device created.
&m_FeatureLevel, // Returns feature level of device created.
&pDC // Returns the device immediate context.
);
if ( FAILED( hr ) )
{
// fallback to WARP device
if ( FAILED( D3D11CreateDevice( nullptr,
D3D_DRIVER_TYPE_WARP, // Create a WARP device instead of a harare device.
0,
creationFlags,
featureLevels,
ARRAYSIZE( featureLevels ),
D3D11_SDK_VERSION,
&pDevice,
&m_FeatureLevel,
&pDC ) ) )
{
return false;
}
}
Xtreme::IAppWindow* pWindowService = ( Xtreme::IAppWindow* )Environment.Service( "Window" );
HWND hWnd = NULL;
if ( pWindowService != NULL )
{
hWnd = (HWND)pWindowService->Handle();
}
else
{
dh::Log( "No Window service found in environment" );
}
m_hwndViewport = hWnd;
m_DisplayOffset.clear();
#if OPERATING_SUB_SYSTEM == OS_SUB_DESKTOP
RECT windowRect;
GetWindowRect( m_hwndViewport, &windowRect );
m_WindowedPlacement.set( windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top );
#endif
//pDC->QueryInterface( __uuidof( ID3D11DeviceContext3 ), (void**)&m_pDeviceContext );
hr = pDC->QueryInterface( __uuidof( ID3D11DeviceContext ), (void**)&m_pDeviceContext );
pDC->Release();
if ( FAILED( hr ) )
{
return false;
}
//pDevice->QueryInterface( __uuidof( ID3D11Device3 ), (void**)&m_pDevice );
hr = pDevice->QueryInterface( __uuidof( ID3D11Device ), (void**)&m_pDevice );
pDevice->Release();
if ( FAILED( hr ) )
{
return false;
}
if ( !InitialiseBasicShaders() )
{
Release();
return false;
}
m_Width = Width;
m_Height = Height;
m_Canvas.set( 0, 0, m_Width, m_Height );
SetVertexShader( "position_color" );
SetPixelShader( "position_color" );
m_VirtualSize.set( m_Width, m_Height );
CD3D11_BUFFER_DESC constantBufferDesc( sizeof( ModelViewProjectionConstantBuffer ), D3D11_BIND_CONSTANT_BUFFER );
if ( FAILED( m_pDevice->CreateBuffer( &constantBufferDesc, nullptr, &m_pMatrixBuffer ) ) )
{
Release();
return false;
}
constantBufferDesc = CD3D11_BUFFER_DESC( sizeof( LightsConstantBuffer ), D3D11_BIND_CONSTANT_BUFFER );
if ( FAILED( m_pDevice->CreateBuffer( &constantBufferDesc, nullptr, &m_pLightBuffer ) ) )
{
Release();
return false;
}
constantBufferDesc = CD3D11_BUFFER_DESC( sizeof( MaterialConstantBuffer ), D3D11_BIND_CONSTANT_BUFFER );
if ( FAILED( m_pDevice->CreateBuffer( &constantBufferDesc, nullptr, &m_pMaterialBuffer ) ) )
{
Release();
return false;
}
constantBufferDesc = CD3D11_BUFFER_DESC( sizeof( FogConstantBuffer ), D3D11_BIND_CONSTANT_BUFFER );
if ( FAILED( m_pDevice->CreateBuffer( &constantBufferDesc, nullptr, &m_pFogBuffer ) ) )
{
Release();
return false;
}
// Create a texture sampler state description.
D3D11_SAMPLER_DESC samplerDesc;
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 1;
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
samplerDesc.BorderColor[0] = 0;
samplerDesc.BorderColor[1] = 0;
samplerDesc.BorderColor[2] = 0;
samplerDesc.BorderColor[3] = 0;
samplerDesc.MinLOD = 0;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
if ( FAILED( m_pDevice->CreateSamplerState( &samplerDesc, &m_pSamplerStateLinear ) ) )
{
Release();
return false;
}
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
if ( FAILED( m_pDevice->CreateSamplerState( &samplerDesc, &m_pSamplerStatePoint ) ) )
{
Release();
return false;
}
D3D11_BLEND_DESC blendState;
ZeroMemory( &blendState, sizeof( blendState ) );
blendState.RenderTarget[0].BlendEnable = FALSE;
blendState.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
if ( FAILED( m_pDevice->CreateBlendState( &blendState, &m_pBlendStateNoBlend ) ) )
{
Release();
return false;
}
ZeroMemory( &blendState, sizeof( blendState ) );
blendState.RenderTarget[0].BlendEnable = TRUE;
blendState.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
blendState.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
blendState.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
blendState.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
blendState.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
blendState.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
blendState.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
if ( FAILED( m_pDevice->CreateBlendState( &blendState, &m_pBlendStateAlphaBlend ) ) )
{
Release();
return false;
}
ZeroMemory( &blendState, sizeof( blendState ) );
blendState.RenderTarget[0].BlendEnable = TRUE;
blendState.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
blendState.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
//blendState.RenderTarget[0].SrcBlend = D3D11_BLEND_OP_ADD;
blendState.RenderTarget[0].DestBlend = D3D11_BLEND_ONE;
blendState.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
//blendState.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
blendState.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
blendState.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE;
blendState.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
if ( FAILED( m_pDevice->CreateBlendState( &blendState, &m_pBlendStateAdditive ) ) )
{
Release();
return false;
}
// Initialize the description of the depth buffer.
D3D11_TEXTURE2D_DESC depthBufferDesc;
D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc;
ZeroMemory( &depthBufferDesc, sizeof( depthBufferDesc ) );
// Set up the description of the depth buffer.
depthBufferDesc.Width = m_Width;
depthBufferDesc.Height = m_Height;
depthBufferDesc.MipLevels = 1;
depthBufferDesc.ArraySize = 1;
depthBufferDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthBufferDesc.SampleDesc.Count = 1;
depthBufferDesc.SampleDesc.Quality = 0;
depthBufferDesc.Usage = D3D11_USAGE_DEFAULT;
depthBufferDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
depthBufferDesc.CPUAccessFlags = 0;
depthBufferDesc.MiscFlags = 0;
// Create the texture for the depth buffer using the filled out description.
HRESULT result = m_pDevice->CreateTexture2D( &depthBufferDesc, NULL, &m_depthStencilBuffer );
if ( FAILED( result ) )
{
return false;
}
// Initialize the description of the stencil state.
ZeroMemory( &depthStencilDesc, sizeof( depthStencilDesc ) );
// Set up the description of the stencil state.
depthStencilDesc.DepthEnable = true;
depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL;
depthStencilDesc.StencilEnable = false;
depthStencilDesc.StencilReadMask = 0xFF;
depthStencilDesc.StencilWriteMask = 0xFF;
// Stencil operations if pixel is front-facing.
depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
// Stencil operations if pixel is back-facing.
depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
// Create the depth stencil state.
result = m_pDevice->CreateDepthStencilState( &depthStencilDesc, &m_depthStencilStateZBufferCheckAndWriteEnabled );
if ( FAILED( result ) )
{
return false;
}
depthStencilDesc.DepthEnable = false;
result = m_pDevice->CreateDepthStencilState( &depthStencilDesc, &m_depthStencilStateZBufferWriteEnabledNoCheck );
if ( FAILED( result ) )
{
return false;
}
depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
result = m_pDevice->CreateDepthStencilState( &depthStencilDesc, &m_depthStencilStateZBufferCheckAndWriteDisabled );
if ( FAILED( result ) )
{
return false;
}
depthStencilDesc.DepthEnable = true;
result = m_pDevice->CreateDepthStencilState( &depthStencilDesc, &m_depthStencilStateZBufferCheckEnabledNoWrite );
if ( FAILED( result ) )
{
return false;
}
// Set the depth stencil state.
m_pDeviceContext->OMSetDepthStencilState( m_depthStencilStateZBufferCheckAndWriteDisabled, 1 );
// Initialize the depth stencil view.
ZeroMemory( &depthStencilViewDesc, sizeof( depthStencilViewDesc ) );
// Set up the depth stencil view description.
depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
depthStencilViewDesc.Texture2D.MipSlice = 0;
// Create the depth stencil view.
result = m_pDevice->CreateDepthStencilView( m_depthStencilBuffer, &depthStencilViewDesc, &m_depthStencilView );
if ( FAILED( result ) )
{
return false;
}
// Bind the render target view and depth stencil buffer to the output render pipeline.
m_pDeviceContext->OMSetRenderTargets( 1, &m_pTargetBackBuffer, m_depthStencilView );
m_RasterizerDescCullBack.FillMode = D3D11_FILL_SOLID;
m_RasterizerDescCullBack.CullMode = D3D11_CULL_BACK;
m_RasterizerDescCullBack.DepthBias = D3D11_DEFAULT_DEPTH_BIAS;
m_RasterizerDescCullBack.DepthBiasClamp = D3D11_DEFAULT_DEPTH_BIAS_CLAMP;
m_RasterizerDescCullBack.FrontCounterClockwise = FALSE;
m_RasterizerDescCullBack.SlopeScaledDepthBias = D3D11_DEFAULT_SLOPE_SCALED_DEPTH_BIAS;
m_RasterizerDescCullBack.DepthClipEnable = TRUE;
m_RasterizerDescCullBack.ScissorEnable = FALSE;
m_RasterizerDescCullBack.MultisampleEnable = FALSE;
m_RasterizerDescCullBack.AntialiasedLineEnable = FALSE;
m_RasterizerDescCullBackWireframe = m_RasterizerDescCullBack;
m_RasterizerDescCullBackWireframe.FillMode = D3D11_FILL_WIREFRAME;
m_RasterizerDescCullFront = m_RasterizerDescCullBack;
m_RasterizerDescCullFront.CullMode = D3D11_CULL_FRONT;
m_RasterizerDescCullFrontWireframe = m_RasterizerDescCullFront;
m_RasterizerDescCullFrontWireframe.FillMode = D3D11_FILL_WIREFRAME;
m_RasterizerDescCullNone = m_RasterizerDescCullBack;
m_RasterizerDescCullNone.CullMode = D3D11_CULL_NONE;
m_RasterizerDescCullNoneWireframe = m_RasterizerDescCullNone;
m_RasterizerDescCullNoneWireframe.FillMode = D3D11_FILL_WIREFRAME;
if ( ( FAILED( m_pDevice->CreateRasterizerState( &m_RasterizerDescCullBack, &m_pRasterizerStateCullBack ) ) )
|| ( FAILED( m_pDevice->CreateRasterizerState( &m_RasterizerDescCullFront, &m_pRasterizerStateCullFront ) ) )
|| ( FAILED( m_pDevice->CreateRasterizerState( &m_RasterizerDescCullNone, &m_pRasterizerStateCullNone ) ) )
|| ( FAILED( m_pDevice->CreateRasterizerState( &m_RasterizerDescCullBackWireframe, &m_pRasterizerStateCullBackWireframe ) ) )
|| ( FAILED( m_pDevice->CreateRasterizerState( &m_RasterizerDescCullFrontWireframe, &m_pRasterizerStateCullFrontWireframe ) ) )
|| ( FAILED( m_pDevice->CreateRasterizerState( &m_RasterizerDescCullNoneWireframe, &m_pRasterizerStateCullNoneWireframe ) ) ) )
{
Release();
return false;
}
m_pDeviceContext->VSSetSamplers( 0, 1, &m_pSamplerStateLinear );
m_pDeviceContext->PSSetSamplers( 0, 1, &m_pSamplerStateLinear );
XViewport vp;
vp.X = 0;
vp.Y = 0;
vp.Width = m_Width;
vp.Height = m_Height;
vp.MinZ = 0.0f;
vp.MaxZ = 1.0f;
SetViewport( vp );
m_Matrices.ScreenCoord2d.OrthoOffCenterLH( 0.0f,
( GR::f32 )m_Width,
( GR::f32 )m_Height,
0.0f,
0.0f,
1.0f );
m_Matrices.ScreenCoord2d.Transpose();
m_Matrices.Model.Identity();
m_Matrices.TextureTransform.Identity();
m_StoredTextureTransform.Identity();
m_LightInfo.Ambient = ColorValue( 0x00000000 );
SetTransform( XRenderer::TT_WORLD, m_Matrices.Model );
if ( !CreateSwapChain() )
{
Release();
return false;
}
#if OPERATING_SUB_SYSTEM == OS_SUB_DESKTOP
ISubclassManager* pManager = (ISubclassManager*)m_pEnvironment->Service( "SubclassManager" );
if ( pManager )
{
pManager->AddHandler( "DX11Renderer", fastdelegate::MakeDelegate( this, &DX11Renderer::WindowProc ) );
}
#endif
ID3D11Texture2D* pBackBuffer;
if ( FAILED( m_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), (LPVOID*)&pBackBuffer ) ) )
{
Release();
return false;
}
// use the back buffer address to create the render target
if ( FAILED( m_pDevice->CreateRenderTargetView( pBackBuffer, NULL, &m_pTargetBackBuffer ) ) )
{
pBackBuffer->Release();
Release();
return false;
}
pBackBuffer->Release();
for ( int i = 0; i < 8; ++i )
{
m_SetTextures[i] = NULL;
}
RecreateBuffers();
// init material
m_pDeviceContext->UpdateSubresource( m_pMaterialBuffer, 0, NULL, &m_Material, 0, 0 );
m_pDeviceContext->VSSetConstantBuffers( 2, 1, &m_pMaterialBuffer );
m_Fog.FogType = 0; // FOG_TYPE_NONE;
m_Fog.FogColor = ColorValue( 0x00000000 );
m_Fog.FogStart = 10.0f;
m_Fog.FogEnd = 25.0f;
m_Fog.FogDensity = 0.02f;
m_pDeviceContext->UpdateSubresource( m_pFogBuffer, 0, NULL, &m_Fog, 0, 0 );
m_pDeviceContext->VSSetConstantBuffers( 3, 1, &m_pFogBuffer );
m_pDeviceContext->PSSetConstantBuffers( 3, 1, &m_pFogBuffer );
// assets
if ( m_pEnvironment )
{
Xtreme::Asset::IAssetLoader* pLoader = ( Xtreme::Asset::IAssetLoader* )m_pEnvironment->Service( "AssetLoader" );
if ( pLoader )
{
LoadImageAssets();
LoadImageSectionAssets();
LoadFontAssets();
LoadMeshAssets();
pLoader->NotifyService( "GUI", "AssetsLoaded" );
}
}
m_RenderStates[std::make_pair( RS_CULLMODE, 0 )] = RSV_CULL_CCW;
m_RenderStates[std::make_pair( RS_FILL_MODE, 0 )] = RSV_FILL_SOLID;
m_Ready = true;
return true;
}
#if OPERATING_SUB_SYSTEM == OS_SUB_DESKTOP
BOOL DX11Renderer::WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch ( uMsg )
{
case WM_SIZE:
{
int width = LOWORD( lParam );
int height = HIWORD( lParam );
//dh::Log( "WM_SIZE Size changed to %dx%d", width, height );
}
break;
case WM_ACTIVATEAPP:
if ( !wParam )
{
// we're being deactivated
//dh::Log( "I'm being deactivated" );
if ( ( !m_TogglingFullScreen )
&& ( IsFullscreen() ) )
{
// switch off fullscreen
ToggleFullscreen();
}
}
else
{
//dh::Log( "I'm being activated" );
}
break;
}
if ( m_pEnvironment != NULL )
{
ISubclassManager* pManager = (ISubclassManager*)m_pEnvironment->Service( "SubclassManager" );
if ( pManager )
{
return pManager->CallNext( hWnd, uMsg, wParam, lParam );
}
}
return (BOOL)CallWindowProc( NULL, hWnd, uMsg, wParam, lParam );
}
#endif
void DX11Renderer::SetVertexShader( const GR::String& Desc )
{
if ( m_CurrentVertexShader == Desc )
{
return;
}
std::map<GR::String, DX11VertexShader*>::iterator itVS( m_BasicVertexShaders.find( Desc ) );
if ( itVS == m_BasicVertexShaders.end() )
{
dh::Log( "tried to set Unknown vertex shader %s", Desc.c_str() );
return;
}
m_pDeviceContext->VSSetShader( itVS->second->m_pShader, NULL, 0 );
m_CurrentVertexShader = Desc;
//dh::Log( "Set vertex shader %s", Desc.c_str() );
}
void DX11Renderer::SetPixelShader( const GR::String& Desc )
{
if ( m_CurrentPixelShader == Desc )
{
return;
}
std::map<GR::String, DX11PixelShader*>::iterator itPS( m_BasicPixelShaders.find( Desc ) );
if ( itPS == m_BasicPixelShaders.end() )
{
dh::Log( "tried to set Unknown pixel shader %s", Desc.c_str() );
return;
}
m_pDeviceContext->PSSetShader( itPS->second->m_pShader, NULL, 0 );
m_CurrentPixelShader = Desc;
//dh::Log( "Set pixel shader %s", Desc.c_str() );
}
void DX11Renderer::SetTransform( eTransformType tType, const math::matrix4& matTrix )
{
FlushAllCaches();
XBasicRenderer::SetTransform( tType, matTrix );
switch ( tType )
{
case TT_PROJECTION:
m_Matrices.Projection = matTrix;
m_Matrices.Projection.Transpose();
break;
case TT_WORLD:
m_Matrices.Model = matTrix;
m_Matrices.Model.Transpose();
break;
case TT_VIEW:
m_Matrices.View = matTrix;
m_Matrices.View.Transpose();
m_Matrices.ViewIT = matTrix;
m_Matrices.ViewIT.Inverse();
m_Matrices.ViewIT.Transpose();
break;
case TT_TEXTURE_STAGE_0:
m_StoredTextureTransform = matTrix;
// my shader hack uses these fields
m_StoredTextureTransform.ms._14 = matTrix.ms._31;
m_StoredTextureTransform.ms._24 = matTrix.ms._32;
if ( m_RenderStates[std::make_pair( XRenderer::RS_TEXTURE_TRANSFORM, 0 )] == XRenderer::RSV_DISABLE )
{
// only store, do not set
return;
}
m_Matrices.TextureTransform = m_StoredTextureTransform;
break;
default:
dh::Log( "DX11Renderer::SetTransform unsupported transform type %d", tType );
break;
}
m_QuadCache.TransformChanged( tType );
m_QuadCache3d.TransformChanged( tType );
m_LineCache.TransformChanged( tType );
m_LineCache3d.TransformChanged( tType );
m_TriangleCache.TransformChanged( tType );
m_TriangleCache3d.TransformChanged( tType );
// Prepare the constant buffer to send it to the graphics device.
m_pDeviceContext->UpdateSubresource( m_pMatrixBuffer, 0, NULL, &m_Matrices, 0, 0 );
m_pDeviceContext->VSSetConstantBuffers( 0, 1, &m_pMatrixBuffer );
// camera pos is required for lights
if ( m_NumActiveLights > 0 )
{
if ( tType == TT_WORLD )
{
m_LightInfo.EyePos.set( matTrix.ms._41, matTrix.ms._42, matTrix.ms._43 );
m_pDeviceContext->UpdateSubresource( m_pLightBuffer, 0, NULL, &m_LightInfo, 0, 0 );
m_pDeviceContext->VSSetConstantBuffers( 1, 1, &m_pLightBuffer );
m_LightsChanged = false;
}
}
}
void DX11Renderer::FlushLightChanges()
{
if ( m_LightsChanged )
{
m_LightsChanged = false;
m_pDeviceContext->UpdateSubresource( m_pLightBuffer, 0, NULL, &m_LightInfo, 0, 0 );
m_pDeviceContext->VSSetConstantBuffers( 1, 1, &m_pLightBuffer );
}
}
void DX11Renderer::FlushAllCaches()
{
FlushLightChanges();
m_QuadCache3d.FlushCache();
m_QuadCache.FlushCache();
m_LineCache.FlushCache();
m_LineCache3d.FlushCache();
m_TriangleCache.FlushCache();
m_TriangleCache3d.FlushCache();
}
bool DX11Renderer::Release()
{
if ( !m_Ready )
{
return true;
}
//OutputDebugStringA( "DX11Renderer::Release called\n" );
if ( m_pDevice == NULL )
{
return true;
}
if ( IsFullscreen() )
{
ToggleFullscreen();
}
#if OPERATING_SUB_SYSTEM == OS_SUB_DESKTOP
if ( m_pEnvironment != NULL )
{
ISubclassManager* pManager = (ISubclassManager*)m_pEnvironment->Service( "SubclassManager" );
if ( pManager )
{
pManager->RemoveHandler( "DX11Renderer" );
}
}
#endif
// unbind all bound objects
m_pDeviceContext->IASetInputLayout( NULL );
m_pDeviceContext->VSSetShader( NULL, NULL, 0 );
m_pDeviceContext->PSSetShader( NULL, NULL, 0 );
m_pDeviceContext->RSSetState( NULL );
m_pDeviceContext->OMSetBlendState( NULL, NULL, 0xffffffff );
m_pDeviceContext->OMSetRenderTargets( 0, NULL, NULL );
#if OPERATING_SUB_SYSTEM == OS_SUB_UNIVERSAL_APP
if ( m_pSwapChain != NULL )
{
//m_pSwapChain->SetFullscreenState( FALSE, NULL );
}
#endif
if ( m_pBlendStateAdditive != NULL )
{
m_pBlendStateAdditive->Release();
m_pBlendStateAdditive = NULL;
}
if ( m_pBlendStateAlphaBlend != NULL )
{
m_pBlendStateAlphaBlend->Release();
m_pBlendStateAlphaBlend = NULL;
}
if ( m_pBlendStateNoBlend != NULL )
{
m_pBlendStateNoBlend->Release();
m_pBlendStateNoBlend = NULL;
}
if ( m_pRasterizerStateCullBack != NULL )
{
m_pRasterizerStateCullBack->Release();
m_pRasterizerStateCullBack = NULL;
}
if ( m_pRasterizerStateCullFront != NULL )
{
m_pRasterizerStateCullFront->Release();
m_pRasterizerStateCullFront = NULL;
}
if ( m_pRasterizerStateCullNone != NULL )
{
m_pRasterizerStateCullNone->Release();
m_pRasterizerStateCullNone = NULL;
}
if ( m_pRasterizerStateCullBackWireframe != NULL )
{
m_pRasterizerStateCullBackWireframe->Release();
m_pRasterizerStateCullBackWireframe = NULL;
}
if ( m_pRasterizerStateCullFrontWireframe != NULL )
{
m_pRasterizerStateCullFrontWireframe->Release();
m_pRasterizerStateCullFrontWireframe = NULL;
}
if ( m_pRasterizerStateCullNoneWireframe != NULL )
{
m_pRasterizerStateCullNoneWireframe->Release();
m_pRasterizerStateCullNoneWireframe = NULL;
}
if ( m_depthStencilBuffer != NULL )
{
m_depthStencilBuffer->Release();
m_depthStencilBuffer = NULL;
}
if ( m_depthStencilStateZBufferCheckAndWriteEnabled != NULL )
{
m_depthStencilStateZBufferCheckAndWriteEnabled->Release();
m_depthStencilStateZBufferCheckAndWriteEnabled = NULL;
}
if ( m_depthStencilStateZBufferCheckAndWriteDisabled != NULL )
{
m_depthStencilStateZBufferCheckAndWriteDisabled->Release();
m_depthStencilStateZBufferCheckAndWriteDisabled = NULL;
}
if ( m_depthStencilStateZBufferCheckEnabledNoWrite != NULL )
{
m_depthStencilStateZBufferCheckEnabledNoWrite->Release();
m_depthStencilStateZBufferCheckEnabledNoWrite = NULL;
}
if ( m_depthStencilStateZBufferWriteEnabledNoCheck != NULL )
{
m_depthStencilStateZBufferWriteEnabledNoCheck->Release();
m_depthStencilStateZBufferWriteEnabledNoCheck = NULL;
}
if ( m_depthStencilView != NULL )
{
m_depthStencilView->Release();
m_depthStencilView = NULL;
}
if ( m_pSamplerStatePoint != NULL )
{
m_pSamplerStatePoint->Release();
m_pSamplerStatePoint = NULL;
}
if ( m_pSamplerStateLinear != NULL )
{
m_pSamplerStateLinear->Release();
m_pSamplerStateLinear = NULL;
}
if ( m_pFogBuffer != NULL )
{
m_pFogBuffer->Release();
m_pFogBuffer = NULL;
}
if ( m_pMaterialBuffer != NULL )
{
m_pMaterialBuffer->Release();
m_pMaterialBuffer = NULL;
}
if ( m_pLightBuffer != NULL )
{
m_pLightBuffer->Release();
m_pLightBuffer = NULL;
}
if ( m_pMatrixBuffer != NULL )
{
m_pMatrixBuffer->Release();
m_pMatrixBuffer = NULL;
}
if ( m_pTargetBackBuffer != NULL )
{
m_pTargetBackBuffer->Release();
m_pTargetBackBuffer = NULL;
}
DestroyAllTextures();
DestroyAllVertexBuffers();
m_pCurrentlySetRenderTargetTexture = NULL;
m_BasicVertexBuffers.clear();
std::list<DX11VertexShader*>::iterator itVS( m_VertexShaders.begin() );
while ( itVS != m_VertexShaders.end() )
{
DX11VertexShader* pShader = *itVS;
pShader->Release();
++itVS;
}
std::list<DX11PixelShader*>::iterator itPS( m_PixelShaders.begin() );
while ( itPS != m_PixelShaders.end() )
{
DX11PixelShader* pShader = *itPS;
pShader->Release();
++itPS;
}
m_VertexShaders.clear();
m_PixelShaders.clear();
m_BasicPixelShaders.clear();
m_BasicVertexShaders.clear();
if ( m_pSwapChain != NULL )
{
m_pSwapChain->Release();
m_pSwapChain = NULL;
}
if ( m_pDeviceContext != NULL )
{
m_pDeviceContext->Release();
m_pDeviceContext = NULL;
}
/*
// display alive objects
ID3D11Debug* pDebug = NULL;
m_pDevice->QueryInterface( __uuidof( ID3D11Debug ), reinterpret_cast<void**>( &pDebug ) );
pDebug->ReportLiveDeviceObjects( D3D11_RLDO_DETAIL );
pDebug->Release();
*/
m_pDevice->Release();
m_pDevice = NULL;
m_hwndViewport = NULL;
m_pEnvironment = NULL;
m_Ready = false;
return true;
}
bool DX11Renderer::OnResized()
{
//dh::Log( "OnResized" );
ReleaseBuffers();
/*
if ( m_pDeviceContext != NULL )
{
m_pDeviceContext->OMSetRenderTargets( 0, 0, 0 );
}*/
if ( m_pSwapChain == NULL )
{
//dh::Log( "OnResized SwapChain== NULL" );
return false;
}
// Release all outstanding references to the swap chain's buffers.
if ( m_pTargetBackBuffer != NULL )
{
m_pTargetBackBuffer->Release();
m_pTargetBackBuffer = NULL;
}
HRESULT hr;
// Preserve the existing buffer count and format.
// Automatically choose the width and height to match the client rect for HWNDs.
//if ( FAILED( hr = m_pSwapChain->ResizeBuffers( 0, 0, 0, DXGI_FORMAT_UNKNOWN, 0 ) ) )
//if ( FAILED( hr = m_pSwapChain->ResizeBuffers( 0, m_Width, m_Height, DXGI_FORMAT_UNKNOWN, DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH ) ) )
if ( FAILED( hr = m_pSwapChain->ResizeBuffers( 2, m_Width, m_Height, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH ) ) )
{
// Perform error handling here!
dh::Log( "m_pSwapChain->ResizeBuffer failed, %x", hr );
}
DXGI_SWAP_CHAIN_DESC desc;
if ( SUCCEEDED( m_pSwapChain->GetDesc( &desc ) ) )
{
// early return when the client size changed
#if OPERATING_SUB_SYSTEM == OS_SUB_DESKTOP
RECT rc;
::GetClientRect( desc.OutputWindow, &rc );
/*
dh::Log( "OnResized - buffer now %dx%d, thought to be %dx%d, window client size is %dx%d",
desc.BufferDesc.Width,
desc.BufferDesc.Height,
m_Width, m_Height,
rc.right - rc.left, rc.bottom - rc.top );*/
if ( ( rc.right - rc.left != m_Width )
|| ( rc.bottom - rc.top != m_Height ) )
{
m_Width = rc.right - rc.left;
m_Height = rc.bottom - rc.top;
m_ViewPort.Width = m_Width;
m_ViewPort.Height = m_Height;
//dh::Log( "OnResized: ================ New Size set %dx%d", m_Width, m_Height );
SetViewport( m_ViewPort );
return OnResized();
}
#endif
}
// Get buffer and create a render-target-view.
ID3D11Texture2D* pBuffer;
if ( FAILED( hr = m_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), (void**)&pBuffer ) ) )
{
// Perform error handling here!
dh::Log( "m_pSwapChain->GetBuffer failed, %x", hr );
return false;
}
if ( FAILED( hr = m_pDevice->CreateRenderTargetView( pBuffer, NULL, &m_pTargetBackBuffer ) ) )
{
// Perform error handling here!
dh::Log( "m_pDevice->CreateRenderTargetView failed, %x", hr );
pBuffer->Release();
return false;
}
pBuffer->Release();
if ( !RecreateBuffers() )
{
dh::Log( "OnResized RecreateBuffers failed" );
return false;
}
m_pDeviceContext->OMSetRenderTargets( 1, &m_pTargetBackBuffer, m_depthStencilView );
//dh::Log( "OnResized OK" );
return true;
}
bool DX11Renderer::IsReady() const
{
return m_Ready;
}
bool DX11Renderer::BeginScene()
{
BOOL fullScreen = FALSE;
if ( ( m_pSwapChain != NULL )
&& ( SUCCEEDED( m_pSwapChain->GetFullscreenState( &fullScreen, NULL ) ) )
&& ( !fullScreen )
&& ( !m_Windowed ) )
{
//dh::Log( "lost device detected?" );
//OutputDebugStringA( "Lost device detected\n" );
// lost device -> switch to windowed mode
m_ForceToWindowedMode = true;
ToggleFullscreen();
//OutputDebugStringA( "---Lost device togglefullscreen done\n" );
}
if ( m_pTargetBackBuffer )
{
// set the render target as the back buffer
m_pDeviceContext->OMSetRenderTargets( 1, &m_pTargetBackBuffer, m_depthStencilView );
}
// viewport has to be set every frame
SetViewport( m_ViewPort );
return true;
}
void DX11Renderer::EndScene()
{
FlushAllCaches();
}
bool DX11Renderer::CreateSwapChain()
{
IDXGIDevice* pDXGIDevice = NULL;
if ( FAILED( m_pDevice->QueryInterface( __uuidof( IDXGIDevice ), (void **)&pDXGIDevice ) ) )
{
return false;
}
IDXGIAdapter * pDXGIAdapter;
if ( FAILED( pDXGIDevice->GetParent( __uuidof( IDXGIAdapter ), (void **)&pDXGIAdapter ) ) )
{
pDXGIDevice->Release();
return false;
}
#if OPERATING_SUB_SYSTEM == OS_SUB_UNIVERSAL_APP
IDXGIFactory4* pIDXGIFactory;
if ( FAILED( pDXGIAdapter->GetParent( IID_PPV_ARGS( &pIDXGIFactory ) ) ) )
{
pDXGIAdapter->Release();
pDXGIDevice->Release();
return false;
}
#else
IDXGIFactory* pIDXGIFactory;
if ( FAILED( pDXGIAdapter->GetParent( __uuidof( IDXGIFactory ), (void **)&pIDXGIFactory ) ) )
{
pDXGIAdapter->Release();
pDXGIDevice->Release();
return false;
}
#endif
/*
// Create a DirectX graphics interface factory.
IDXGIFactory* pIDXGIFactory = NULL;
HRESULT result = CreateDXGIFactory( __uuidof( IDXGIFactory ), (void**)&pIDXGIFactory );
if ( FAILED( result ) )
{
return false;
}
*/
IDXGIAdapter* adapter = NULL;
// Use the factory to create an adapter for the primary graphics interface (video card).
HRESULT result = pIDXGIFactory->EnumAdapters( 0, &adapter );
if ( FAILED( result ) )
{
pIDXGIFactory->Release();
pDXGIAdapter->Release();
pDXGIDevice->Release();
return false;
}
// Enumerate the primary adapter output (monitor).
IDXGIOutput* adapterOutput = NULL;
result = adapter->EnumOutputs( 0, &adapterOutput );
if ( FAILED( result ) )
{
pIDXGIFactory->Release();
pDXGIAdapter->Release();
pDXGIDevice->Release();
return false;
}
// Get the number of modes that fit the DXGI_FORMAT_R8G8B8A8_UNORM display format for the adapter output (monitor).
UINT numModes = 0;
result = adapterOutput->GetDisplayModeList( DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED | DXGI_ENUM_MODES_SCALING, &numModes, NULL );
if ( FAILED( result ) )
{
pIDXGIFactory->Release();
pDXGIAdapter->Release();
pDXGIDevice->Release();
return false;
}
// Create a list to hold all the possible display modes for this monitor/video card combination.
DXGI_MODE_DESC* displayModeList = new DXGI_MODE_DESC[numModes];
if ( !displayModeList )
{
pIDXGIFactory->Release();
pDXGIAdapter->Release();
pDXGIDevice->Release();
return false;
}
// Now fill the display mode list structures.
result = adapterOutput->GetDisplayModeList( DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, displayModeList );
if ( FAILED( result ) )
{
pIDXGIFactory->Release();
pDXGIAdapter->Release();
pDXGIDevice->Release();
return false;
}
// Now go through all the display modes and find the one that matches the screen width and height.
// When a match is found store the numerator and denominator of the refresh rate for that monitor.
int numerator = 0;
int denominator = 1;
for ( UINT i = 0; i < numModes; i++ )
{
const auto& displayMode( displayModeList[i] );
m_DisplayModes.push_back( XRendererDisplayMode( displayMode.Width, displayMode.Height, MapFormat( displayMode.Format ) ) );
if ( displayMode.Width == (unsigned int)m_Width )
{
if ( displayMode.Height == (unsigned int)m_Height )
{
numerator = displayModeList[i].RefreshRate.Numerator;
denominator = displayModeList[i].RefreshRate.Denominator;
}
}
}
/*
// Get the adapter (video card) description.
result = adapter->GetDesc( &adapterDesc );
if ( FAILED( result ) )
{
return false;
}
// Store the dedicated video card memory in megabytes.
m_videoCardMemory = (int)( adapterDesc.DedicatedVideoMemory / 1024 / 1024 );
// Convert the name of the video card to a character array and store it.
error = wcstombs_s( &stringLength, m_videoCardDescription, 128, adapterDesc.Description, 128 );
if ( error != 0 )
{
return false;
}*/
// Release the display mode list.
delete[] displayModeList;
displayModeList = 0;
// Release the adapter output.
adapterOutput->Release();
adapterOutput = 0;
// Release the adapter.
adapter->Release();
adapter = 0;
#if OPERATING_SUB_SYSTEM == OS_SUB_UNIVERSAL_APP
DXGI_SWAP_CHAIN_DESC1 swapChainDesc0;
// Initialize the swap chain description.
ZeroMemory( &swapChainDesc0, sizeof( swapChainDesc0 ) );
// Set the width and height of the back buffer.
swapChainDesc0.Width = m_Width;
swapChainDesc0.Height = m_Height;
// Set regular 32-bit surface for the back buffer.
//swapChainDesc0.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDesc0.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
swapChainDesc0.Stereo = false;
swapChainDesc0.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
// Set the scan line ordering and scaling to unspecified.
//swapChainDesc0.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapChainDesc0.Scaling = DXGI_SCALING_STRETCH;
#else
DXGI_SWAP_CHAIN_DESC swapChainDesc0;
// Initialize the swap chain description.
ZeroMemory( &swapChainDesc0, sizeof( swapChainDesc0 ) );
// Set the width and height of the back buffer.
swapChainDesc0.BufferDesc.Width = m_Width;
swapChainDesc0.BufferDesc.Height = m_Height;
// Set regular 32-bit surface for the back buffer.
swapChainDesc0.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
// Set the refresh rate of the back buffer.
if ( m_VSyncEnabled )
{
swapChainDesc0.BufferDesc.RefreshRate.Numerator = numerator;
swapChainDesc0.BufferDesc.RefreshRate.Denominator = denominator;
}
else
{
swapChainDesc0.BufferDesc.RefreshRate.Numerator = 0;
swapChainDesc0.BufferDesc.RefreshRate.Denominator = 1;
}
// Set the scan line ordering and scaling to unspecified.
swapChainDesc0.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapChainDesc0.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
#endif
// Set the usage of the back buffer.
swapChainDesc0.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
#if OPERATING_SUB_SYSTEM == OS_SUB_DESKTOP
// Set the handle for the window to render to.
swapChainDesc0.OutputWindow = m_hwndViewport;
// Set to full screen or windowed mode.
if ( !m_Windowed )
{
swapChainDesc0.Windowed = FALSE;
}
else
{
swapChainDesc0.Windowed = TRUE;
}
#endif
// Turn multisampling off.
swapChainDesc0.SampleDesc.Count = 1;
swapChainDesc0.SampleDesc.Quality = 0;
#if OPERATING_SUB_SYSTEM == OS_SUB_DESKTOP
// Discard the back buffer contents after presenting.
swapChainDesc0.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; // DXGI_SWAP_EFFECT_FLIP_DISCARD does not exist in this SDK yet
// Set to a single back buffer.
swapChainDesc0.BufferCount = 1;
// Don't set the advanced flags.
swapChainDesc0.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
#elif ( OPERATING_SUB_SYSTEM == OS_SUB_UNIVERSAL_APP ) || ( OPERATING_SUB_SYSTEM == OS_SUB_WINDOWS_PHONE )
swapChainDesc0.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // All Windows Store apps must use this SwapEffect.
swapChainDesc0.BufferCount = 2; // Use double-buffering to minimize latency.
swapChainDesc0.Flags = 0;
#if ( OPERATING_SUB_SYSTEM == OS_SUB_WINDOWS_PHONE )
swapChainDesc0.Windowed = TRUE;
swapChainDesc0.OutputWindow = m_hwndViewport;
#endif
#endif
#if ( OPERATING_SUB_SYSTEM == OS_SUB_UNIVERSAL_APP ) || ( OPERATING_SUB_SYSTEM == OS_SUB_WINDOWS_PHONE )
auto pWindowService = (Xtreme::IAppWindow*)m_pEnvironment->Service( "Window" );
if ( pWindowService == NULL )
{
dh::Log( "No Window service found" );
return false;
}
Xtreme::UniversalAppWindow* pWnd = (Xtreme::UniversalAppWindow*)pWindowService;
auto coreWindow = pWnd->CoreWindow;// Windows::UI::Core::CoreWindow::GetForCurrentThread();
/*
result = pIDXGIFactory->CreateSwapChainForComposition(
m_pDevice,
&swapChainDesc0,
nullptr,
&m_pSwapChain
);*/
#if ( OPERATING_SUB_SYSTEM == OS_SUB_WINDOWS_PHONE )
result = pIDXGIFactory->CreateSwapChain( m_pDevice, &swapChainDesc0, &m_pSwapChain );
#else
result = pIDXGIFactory->CreateSwapChainForCoreWindow(
m_pDevice,
reinterpret_cast<IUnknown*>( coreWindow.Get() ),
&swapChainDesc0,
nullptr,
&m_pSwapChain
);
#endif
#else
// Create the swap chain, Direct3D device, and Direct3D device context.
result = pIDXGIFactory->CreateSwapChain( m_pDevice, &swapChainDesc0, &m_pSwapChain );
#endif
if ( FAILED( result ) )
{
// Release the factory.
pIDXGIFactory->Release();
pIDXGIFactory = 0;
return false;
}
#if OPERATING_SUB_SYSTEM == OS_SUB_DESKTOP
//result = pIDXGIFactory->MakeWindowAssociation( m_hwndViewport, DXGI_MWA_NO_ALT_ENTER );
result = pIDXGIFactory->MakeWindowAssociation( m_hwndViewport, DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER | DXGI_MWA_NO_PRINT_SCREEN );
if ( FAILED( result ) )
{
pIDXGIFactory->Release();
pDXGIAdapter->Release();
pDXGIDevice->Release();
return false;
}
#endif
// Release the factory.
pIDXGIFactory->Release();
pIDXGIFactory = 0;
pDXGIAdapter->Release();
pDXGIDevice->Release();
return true;
}
void DX11Renderer::PresentScene( GR::tRect* rectSrc, GR::tRect* rectDest )
{
FlushAllCaches();
if ( m_pSwapChain == NULL )
{
return;
}
// The first argument instructs DXGI to block until VSync, putting the application
// to sleep until the next VSync. This ensures we don't waste any cycles rendering
// frames that will never be displayed to the screen.
HRESULT hr = m_pSwapChain->Present( m_VSyncEnabled ? 1 : 0, 0 );
if ( hr != S_OK )
{
//OutputDebugStringA( "Present returned not S_OK\n" );
}
// Discard the contents of the render target.
// This is a valid operation only when the existing contents will be entirely
// overwritten. If dirty or scroll rects are used, this call should be removed.
//m_pDeviceContext->DiscardView( m_pTargetBackBuffer );
/*
// Discard the contents of the depth stencil.
m_pDeviceContext->DiscardView( m_d3dDepthStencilView.Get() );
*/
// If the device was removed either by a disconnection or a driver upgrade, we
// must recreate all device resources.
if ( ( hr == DXGI_ERROR_DEVICE_REMOVED )
|| ( hr == DXGI_ERROR_DEVICE_RESET ) )
{
dh::Log( "TODO - device lost" );
//HandleDeviceLost();
}
else if ( FAILED( hr ) )
{
dh::Log( "Present had an error!" );
}
}
bool DX11Renderer::ToggleFullscreen()
{
//OutputDebugStringA( "ToggleFullscreen called\n" );
if ( m_TogglingFullScreen )
{
return true;
}
m_TogglingFullScreen = true;
#if OPERATING_SUB_SYSTEM == OS_SUB_UNIVERSAL_APP
auto view = Windows::UI::ViewManagement::ApplicationView::GetForCurrentView();
if ( view->IsFullScreenMode )
{
view->ExitFullScreenMode();
Windows::UI::ViewManagement::ApplicationView::PreferredLaunchWindowingMode = Windows::UI::ViewManagement::ApplicationViewWindowingMode::Auto;
// The SizeChanged event will be raised when the exit from full-screen mode is complete.
m_TogglingFullScreen = false;
return true;
}
else
{
if ( view->TryEnterFullScreenMode() )
{
Windows::UI::ViewManagement::ApplicationView::PreferredLaunchWindowingMode = Windows::UI::ViewManagement::ApplicationViewWindowingMode::FullScreen;
// The SizeChanged event will be raised when the entry to full-screen mode is complete.
m_TogglingFullScreen = false;
return true;
}
}
m_TogglingFullScreen = false;
return false;
#endif
// regular win32 desktop from here on
BOOL fullScreen = FALSE;
HRESULT hr = S_OK;
DXGI_MODE_DESC modeDesc;
modeDesc.Width = m_Width;
modeDesc.Height = m_Height;
modeDesc.Format = DXGI_FORMAT_UNKNOWN;
modeDesc.RefreshRate.Denominator = 0;
modeDesc.RefreshRate.Numerator = 0;
modeDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
modeDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
if ( FAILED( hr = m_pSwapChain->GetFullscreenState( &fullScreen, NULL ) ) )
{
dh::Log( "GetFullscreenState failed (%x)", hr );
m_TogglingFullScreen = false;
return false;
}
m_TogglingToFullScreen = !fullScreen;
// temporarely set m_Windowed to target
m_Windowed = !fullScreen;
if ( FAILED( hr = m_pSwapChain->ResizeTarget( &modeDesc ) ) )
{
dh::Log( "ResizeTarget failed (%x)", hr );
m_TogglingFullScreen = false;
return false;
}
if ( m_ForceToWindowedMode )
{
//dh::Log( "Forced window mode" );
m_ForceToWindowedMode = false;
fullScreen = true;
m_Windowed = false;
}
// store window placement
if ( !fullScreen )
{
#if OPERATING_SUB_SYSTEM == OS_SUB_DESKTOP
RECT windowRect;
GetWindowRect( m_hwndViewport, &windowRect );
m_WindowedPlacement.set( windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top );
//dh::Log( "Store m_WindowedPlacement as %d,%d %dx%d", windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top );
#endif
}
//dh::Log( "SwapChain says fullscreen state is %d", fullScreen );
//OutputDebugStringA( CMisc::printf( "SwapChain says fullscreen state is %d, calling ReleaseBuffers\n", fullScreen ) );
//dh::Log( "calling ReleaseBuffers in ToggleFullscreen" );
//ReleaseBuffers();
//OnResized();
hr = m_pSwapChain->SetFullscreenState( !fullScreen, NULL );
if ( FAILED( hr ) )
{
dh::Log( "SetFullscreenState failed (%x)", hr );
m_TogglingFullScreen = false;
m_Windowed = !!fullScreen;
return false;
}
//dh::Log( "SwapChain tried fullscreen state set to %d", !fullScreen );
if ( FAILED( hr = m_pSwapChain->GetFullscreenState( &fullScreen, NULL ) ) )
{
dh::Log( "GetFullscreenState failed (%x)", hr );
m_TogglingFullScreen = false;
m_Windowed = !!fullScreen;
return false;
}
m_Windowed = !fullScreen;
//dh::Log( "SwapChain says fullscreen state is now %d", fullScreen );
if ( !fullScreen )
{
// restore window placement
#if OPERATING_SUB_SYSTEM == OS_SUB_DESKTOP
//dh::Log( "restore m_WindowedPlacement as %d,%d %dx%d", m_WindowedPlacement.Left, m_WindowedPlacement.Top, m_WindowedPlacement.width(), m_WindowedPlacement.height() );
SetWindowPos( m_hwndViewport, NULL, m_WindowedPlacement.Left, m_WindowedPlacement.Top, m_WindowedPlacement.width(), m_WindowedPlacement.height(), SWP_NOACTIVATE );
//RecreateBuffers();
/*
ID3D11Debug* pDebug = NULL;
if ( SUCCEEDED( m_pDevice->QueryInterface( __uuidof( ID3D11Debug ), reinterpret_cast<void**>( &pDebug ) ) ) )
{
OutputDebugStringA( "===================Before ResizeBuffers after back to window mode=================" );
pDebug->ReportLiveDeviceObjects( D3D11_RLDO_DETAIL );
pDebug->Release();
}*/
//m_pSwapChain->ResizeBuffers( 2, m_WindowedPlacement.width(), m_WindowedPlacement.height(), DXGI_FORMAT_UNKNOWN, 0 );
#endif
}
//m_Windowed = !fullScreen;
m_TogglingFullScreen = false;
return true;
}
bool DX11Renderer::ReleaseBuffers()
{
if ( m_pDeviceContext == NULL )
{
//dh::Log( "DX11Renderer::SetMode called with m_pDeviceContext = NULL" );
return false;
}
if ( m_pDevice == NULL )
{
//dh::Log( "DX11Renderer::SetMode called with m_pDevice = NULL" );
return false;
}
// invalidate all buffers
// Release all vidmem objects
SetRenderTarget( NULL );
for ( int i = 0; i < 8; ++i )
{
SetTexture( i, NULL );
}
// unbind all bound objects
//m_pDeviceContext->IASetInputLayout( NULL );
//m_pDeviceContext->VSSetShader( NULL, NULL, 0 );
//m_pDeviceContext->PSSetShader( NULL, NULL, 0 );
//m_pDeviceContext->RSSetState( NULL );
//m_pDeviceContext->OMSetBlendState( NULL, NULL, 0xffffffff );
m_pDeviceContext->OMSetRenderTargets( 0, NULL, NULL );
if ( m_depthStencilBuffer != NULL )
{
m_depthStencilBuffer->Release();
m_depthStencilBuffer = NULL;
}
if ( m_depthStencilView != NULL )
{
m_depthStencilView->Release();
m_depthStencilView = NULL;
}
return true;
}
bool DX11Renderer::SetMode( XRendererDisplayMode& DisplayMode )
{
//dh::Log( "SetMode called" );
if ( m_Windowed == !DisplayMode.FullScreen )
{
//dh::Log( "m_Windowed == !DisplayMode.FullScreen" );
//ReleaseBuffers();
bool olindowMode = m_Windowed;
// still try?
m_Width = DisplayMode.Width;
m_Height = DisplayMode.Height;
return OnResized();
//return RecreateBuffers();
}
if ( m_Windowed != !DisplayMode.FullScreen )
{
//dh::Log( "m_Windowed != !DisplayMode.FullScreen" );
m_Width = DisplayMode.Width;
m_Height = DisplayMode.Height;
if ( !ToggleFullscreen() )
{
//dh::Log( "-failed" );
return false;
}
}
return true;
}
bool DX11Renderer::RecreateBuffers()
{
//dh::Log( "Recreating buffers for size %dx%d", m_Width, m_Height );
//OutputDebugStringA( CMisc::printf( "Recreating buffers for size %dx%d\n", m_Width, m_Height ) );
if ( m_depthStencilBuffer == NULL )
{
// rebuild released buffers
D3D11_TEXTURE2D_DESC depthBufferDesc;
ZeroMemory( &depthBufferDesc, sizeof( depthBufferDesc ) );
// Set up the description of the depth buffer.
depthBufferDesc.Width = m_Width;
depthBufferDesc.Height = m_Height;
depthBufferDesc.MipLevels = 1;
depthBufferDesc.ArraySize = 1;
depthBufferDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthBufferDesc.SampleDesc.Count = 1;
depthBufferDesc.SampleDesc.Quality = 0;
depthBufferDesc.Usage = D3D11_USAGE_DEFAULT;
depthBufferDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
depthBufferDesc.CPUAccessFlags = 0;
depthBufferDesc.MiscFlags = 0;
// Create the texture for the depth buffer using the filled out description.
HRESULT result = m_pDevice->CreateTexture2D( &depthBufferDesc, NULL, &m_depthStencilBuffer );
if ( FAILED( result ) )
{
dh::Log( "CreateTexture2D m_depthStencilBuffer failed (%x)\n", result );
return false;
}
}
if ( m_depthStencilView == NULL )
{
// Initialize the depth stencil view.
D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc;
ZeroMemory( &depthStencilViewDesc, sizeof( depthStencilViewDesc ) );
// Set up the depth stencil view description.
depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
depthStencilViewDesc.Texture2D.MipSlice = 0;
// Create the depth stencil view.
HRESULT result = m_pDevice->CreateDepthStencilView( m_depthStencilBuffer, &depthStencilViewDesc, &m_depthStencilView );
if ( FAILED( result ) )
{
dh::Log( "CreateDepthStencilView m_depthStencilView failed (%x)", result );
return false;
}
}
m_pDeviceContext->OMSetRenderTargets( 1, &m_pTargetBackBuffer, m_depthStencilView );
return true;
}
void DX11Renderer::RestoreAllTextures()
{
tListTextures::iterator it( m_Textures.begin() );
while ( it != m_Textures.end() )
{
XTexture* pTexture = *it;
if ( pTexture->m_LoadedFromFile.empty() )
{
// eine bloss erzeugte Textur
DX11Texture* pDX11Texture = (DX11Texture*)pTexture;
// sicher gehen
pDX11Texture->Release();
if ( !CreateNativeTextureResources( pDX11Texture ) )
{
Log( "Renderer.General", "CreateTexture failed" );
}
GR::u32 MipMapLevel = 0;
std::list<GR::Graphic::ImageData>::iterator itID( pDX11Texture->m_StoredImageData.begin() );
while ( itID != pDX11Texture->m_StoredImageData.end() )
{
CopyDataToTexture( pDX11Texture, *itID, 0, MipMapLevel );
++itID;
++MipMapLevel;
}
if ( pDX11Texture->AllowUsageAsRenderTarget )
{
// TODO
}
}
else
{
if ( m_pEnvironment == NULL )
{
return;
}
ImageFormatManager* pManager = (ImageFormatManager*)m_pEnvironment->Service( "ImageLoader" );
if ( pManager == NULL )
{
return;
}
GR::Graphic::ImageData* pData = pManager->LoadData( pTexture->m_LoadedFromFile.c_str() );
if ( pData )
{
pData->ConvertSelfTo( pTexture->m_ImageFormat, 0, pTexture->m_ColorKey != 0, pTexture->m_ColorKey, 0, 0, 0, 0, pTexture->m_ColorKeyReplacementColor );
XTextureBase* pDX11Texture = (XTextureBase*)pTexture;
// sicher gehen
pDX11Texture->Release();
if ( CreateNativeTextureResources( pDX11Texture ) )
{
CopyDataToTexture( pTexture, *pData );
// Mipmap-Levels einlesen
std::list<GR::String>::iterator it( pDX11Texture->FileNames.begin() );
GR::u32 Level = 1;
while ( it != pDX11Texture->FileNames.end() )
{
GR::String& strPath( *it );
GR::Graphic::ImageData* pData = LoadAndConvert( strPath.c_str(), ( GR::Graphic::eImageFormat )pDX11Texture->m_ImageFormat, pDX11Texture->m_ColorKey, pDX11Texture->m_ColorKeyReplacementColor );
if ( pData == NULL )
{
Log( "Renderer.General", CMisc::printf( "DX8Renderer:: RestoreAllTextures failed to load MipMap (%s)", strPath.c_str() ) );
}
else
{
CopyDataToTexture( pTexture, *pData, pDX11Texture->m_ColorKey, Level );
delete pData;
}
++it;
++Level;
}
}
else
{
Log( "Renderer.General", "Create Texture Failed" );
}
delete pData;
}
}
++it;
}
}
bool DX11Renderer::IsFullscreen()
{
if ( m_TogglingFullScreen )
{
return m_TogglingToFullScreen;
}
return !m_Windowed;
/*
BOOL fullScreen = FALSE;
if ( m_pSwapChain == NULL )
{
return false;
}
if ( FAILED( m_pSwapChain->GetFullscreenState( &fullScreen, NULL ) ) )
{
return false;
}
// during startup?
if ( fullScreen != m_Windowed )
{
return !m_Windowed;
}
return !!fullScreen;*/
}
void DX11Renderer::SetCullFillMode( GR::u32 CullMode, GR::u32 FillMode )
{
switch ( CullMode )
{
case XRenderer::RSV_CULL_CCW:
if ( FillMode == RSV_FILL_SOLID )
{
m_pDeviceContext->RSSetState( m_pRasterizerStateCullBack );
}
else if ( FillMode == RSV_FILL_WIREFRAME )
{
m_pDeviceContext->RSSetState( m_pRasterizerStateCullBackWireframe );
}
break;
case XRenderer::RSV_CULL_CW:
if ( FillMode == RSV_FILL_SOLID )
{
m_pDeviceContext->RSSetState( m_pRasterizerStateCullFront );
}
else if ( FillMode == RSV_FILL_WIREFRAME )
{
m_pDeviceContext->RSSetState( m_pRasterizerStateCullFrontWireframe );
}
break;
case XRenderer::RSV_CULL_NONE:
if ( FillMode == RSV_FILL_SOLID )
{
m_pDeviceContext->RSSetState( m_pRasterizerStateCullNone );
}
else if ( FillMode == RSV_FILL_WIREFRAME )
{
m_pDeviceContext->RSSetState( m_pRasterizerStateCullNoneWireframe );
}
break;
}
}
bool DX11Renderer::SetState( eRenderState rState, GR::u32 rValue, GR::u32 Stage )
{
tMapRenderStates::iterator it( m_RenderStates.find( std::make_pair( rState, Stage ) ) );
if ( it != m_RenderStates.end() )
{
if ( it->second == rValue )
{
return true;
}
}
switch ( rState )
{
case RS_AMBIENT:
m_LightInfo.Ambient = ColorValue( rValue );
m_LightsChanged = true;
if ( m_LightingEnabled )
{
FlushAllCaches();
}
break;
case RS_CLEAR_COLOR:
m_ClearColor[2] = ( ( rValue >> 0 ) & 0xff ) / 255.0f;
m_ClearColor[1] = ( ( rValue >> 8 ) & 0xff ) / 255.0f;
m_ClearColor[0] = ( ( rValue >> 16 ) & 0xff ) / 255.0f;
m_ClearColor[3] = ( ( rValue >> 24 ) & 0xff ) / 255.0f;
break;
case RS_LIGHTING:
if ( rValue == XRenderer::RSV_ENABLE )
{
if ( !m_LightingEnabled )
{
FlushAllCaches();
m_LightingEnabled = true;
}
}
else if( rValue == XRenderer::RSV_DISABLE )
{
if ( m_LightingEnabled )
{
FlushAllCaches();
m_LightingEnabled = false;
}
}
break;
case RS_LIGHT:
if ( Stage < 8 )
{
if ( rValue == XRenderer::RSV_ENABLE )
{
if ( !m_LightEnabled[Stage] )
{
FlushAllCaches();
m_LightEnabled[Stage] = true;
++m_NumActiveLights;
}
}
else if ( rValue == XRenderer::RSV_DISABLE )
{
if ( m_LightEnabled[Stage] )
{
FlushAllCaches();
m_LightEnabled[Stage] = false;
--m_NumActiveLights;
}
}
}
break;
case RS_CULLMODE:
FlushAllCaches();
SetCullFillMode( rValue, m_RenderStates[std::make_pair( RS_FILL_MODE, 0 )] );
break;
case RS_FILL_MODE:
FlushAllCaches();
SetCullFillMode( m_RenderStates[std::make_pair( RS_CULLMODE, 0 )], rValue );
break;
case RS_ZBUFFER:
if ( Stage == 0 )
{
if ( ( rValue == XRenderer::RSV_ENABLE )
|| ( rValue == XRenderer::RSV_DISABLE ) )
{
FlushAllCaches();
ID3D11DepthStencilState* pStateToSet = m_depthStencilStateZBufferCheckAndWriteEnabled;
if ( m_RenderStates[std::make_pair( XRenderer::RS_ZWRITE, 0 )] == XRenderer::RSV_ENABLE )
{
pStateToSet = ( rValue == XRenderer::RSV_ENABLE ) ? m_depthStencilStateZBufferCheckAndWriteEnabled : m_depthStencilStateZBufferWriteEnabledNoCheck;
}
else if ( m_RenderStates[std::make_pair( XRenderer::RS_ZWRITE, 0 )] == XRenderer::RSV_DISABLE )
{
pStateToSet = ( rValue == XRenderer::RSV_ENABLE ) ? m_depthStencilStateZBufferCheckEnabledNoWrite : m_depthStencilStateZBufferCheckAndWriteDisabled;
}
m_pDeviceContext->OMSetDepthStencilState( pStateToSet, 1 );
}
}
break;
case RS_ZWRITE:
if ( Stage == 0 )
{
if ( ( rValue == XRenderer::RSV_ENABLE )
|| ( rValue == XRenderer::RSV_DISABLE ) )
{
FlushAllCaches();
ID3D11DepthStencilState* pStateToSet = m_depthStencilStateZBufferCheckAndWriteEnabled;
if ( m_RenderStates[std::make_pair( XRenderer::RS_ZBUFFER, 0 )] == XRenderer::RSV_ENABLE )
{
pStateToSet = ( rValue == XRenderer::RSV_ENABLE ) ? m_depthStencilStateZBufferCheckAndWriteEnabled : m_depthStencilStateZBufferCheckEnabledNoWrite;
}
else if ( m_RenderStates[std::make_pair( XRenderer::RS_ZBUFFER, 0 )] == XRenderer::RSV_DISABLE )
{
pStateToSet = ( rValue == XRenderer::RSV_ENABLE ) ? m_depthStencilStateZBufferWriteEnabledNoCheck : m_depthStencilStateZBufferCheckAndWriteDisabled;
}
m_pDeviceContext->OMSetDepthStencilState( pStateToSet, 1 );
}
}
break;
case RS_MINFILTER:
case RS_MAGFILTER:
case RS_MIPFILTER:
FlushAllCaches();
// TODO - THAT'S A HACK! THERE OUGHT TO BE DIFFERENT SAMPLERS FOR ALL COMBINATIONS!
if ( rValue == RSV_FILTER_POINT )
{
m_pDeviceContext->VSSetSamplers( 0, 1, &m_pSamplerStatePoint );
m_pDeviceContext->PSSetSamplers( 0, 1, &m_pSamplerStatePoint );
}
else
{
m_pDeviceContext->VSSetSamplers( 0, 1, &m_pSamplerStateLinear );
m_pDeviceContext->PSSetSamplers( 0, 1, &m_pSamplerStateLinear );
}
break;
case RS_TEXTURE_TRANSFORM:
FlushAllCaches();
if ( rValue == RSV_DISABLE )
{
math::matrix4 matTemp = m_StoredTextureTransform;
SetTransform( XRenderer::TT_TEXTURE_STAGE_0, math::matrix4().Identity() );
m_StoredTextureTransform = matTemp;
}
else if ( rValue == RSV_TEXTURE_TRANSFORM_COUNT2 )
{
SetTransform( XRenderer::TT_TEXTURE_STAGE_0, m_StoredTextureTransform );
}
break;
case RS_FOG_COLOR:
m_Fog.FogColor = ColorValue( rValue );
if ( m_Fog.FogType != 0 )
{
SetFogInfo();
}
break;
case RS_FOG_ENABLE:
if ( rValue == RSV_ENABLE )
{
if ( m_Fog.FogType != m_CachedFontType )
{
m_Fog.FogType = m_CachedFontType;
}
}
else if ( m_Fog.FogType != 0 )
{
m_CachedFontType = m_Fog.FogType;
m_Fog.FogType = 0;
}
SetFogInfo();
break;
case RS_FOG_DENSITY:
m_Fog.FogDensity = *( GR::f32* )&rValue;
if ( m_Fog.FogType != 0 )
{
SetFogInfo();
}
break;
case RS_FOG_START:
m_Fog.FogStart = *( GR::f32* )&rValue;
if ( m_Fog.FogType != 0 )
{
SetFogInfo();
}
break;
case RS_FOG_END:
m_Fog.FogEnd = *( GR::f32* )&rValue;
if ( m_Fog.FogType != 0 )
{
SetFogInfo();
}
break;
case RS_FOG_VERTEXMODE:
if ( ( rValue >= RSV_FOG_EXP )
&& ( rValue <= RSV_FOG_LINEAR ) )
{
if ( m_Fog.FogType == 0 )
{
if ( m_RenderStates[std::make_pair( RS_FOG_ENABLE, Stage )] == RSV_ENABLE )
{
// fog is enabled!
m_Fog.FogType = rValue - RSV_FOG_NONE;
m_CachedFontType = rValue - RSV_FOG_NONE;
SetFogInfo();
}
}
else if ( m_Fog.FogType != rValue - RSV_FOG_NONE )
{
m_Fog.FogType = rValue - RSV_FOG_NONE;
m_CachedFontType = rValue - RSV_FOG_NONE;
SetFogInfo();
}
}
break;
}
m_RenderStates[std::make_pair( rState, Stage )] = rValue;
return true;
}
bool DX11Renderer::SetViewport( const XViewport& Viewport )
{
if ( m_pDeviceContext == NULL )
{
return false;
}
FlushAllCaches();
m_ViewPort = Viewport;
CD3D11_VIEWPORT viewPort;
GR::f32 virtualX = ( GR::f32 )m_Canvas.width() / m_VirtualSize.x;
GR::f32 virtualY = ( GR::f32 )m_Canvas.height() / m_VirtualSize.y;
viewPort.Width = (GR::f32)virtualX * Viewport.Width;
viewPort.Height = (GR::f32)virtualY * Viewport.Height;
viewPort.TopLeftX = m_Canvas.Left + (GR::f32)virtualX * Viewport.X;
viewPort.TopLeftY = m_Canvas.Top + (GR::f32)virtualY * Viewport.Y;
viewPort.MinDepth = Viewport.MinZ;
viewPort.MaxDepth = Viewport.MaxZ;
if ( viewPort.TopLeftX >= m_Canvas.Left + m_Canvas.width() )
{
viewPort.TopLeftX = (GR::f32)m_Canvas.Left + m_Canvas.width();
viewPort.Width = 0;
}
if ( viewPort.TopLeftY >= m_Canvas.Top + m_Canvas.height() )
{
viewPort.TopLeftY = (GR::f32)m_Canvas.Top + m_Canvas.height();
viewPort.Height = 0;
}
if ( viewPort.TopLeftX + viewPort.Width > m_Canvas.Left + m_Canvas.width() )
{
viewPort.Width = m_Canvas.Left + m_Canvas.width() - viewPort.TopLeftX;
}
if ( viewPort.TopLeftY + viewPort.Height> m_Canvas.Top + m_Canvas.height() )
{
viewPort.Height = m_Canvas.Top + m_Canvas.height() - viewPort.TopLeftY;
}
// adjust ortho matrix?
m_Matrices.ScreenCoord2d.OrthoOffCenterLH( viewPort.TopLeftX,
viewPort.TopLeftX + viewPort.Width,
viewPort.TopLeftY + viewPort.Height,
viewPort.TopLeftY,
0.0f,
1.0f );
//dh::Log( "Set viewport %f,%f %fx%f", viewPort.TopLeftX, viewPort.TopLeftY, viewPort.Width, viewPort.Height );
m_Matrices.ScreenCoord2d.Transpose();
// Prepare the constant buffer to send it to the graphics device.
m_pDeviceContext->UpdateSubresource( m_pMatrixBuffer, 0, NULL, &m_Matrices, 0, 0 );
m_pDeviceContext->VSSetConstantBuffers( 0, 1, &m_pMatrixBuffer );
m_pDeviceContext->RSSetViewports( 1, &viewPort );
return true;
}
bool DX11Renderer::SetTrueViewport( const XViewport& Viewport )
{
FlushAllCaches();
m_VirtualViewport = Viewport;
CD3D11_VIEWPORT viewPort;
viewPort.Width = ( GR::f32 )Viewport.Width;
viewPort.Height = ( GR::f32 )Viewport.Height;
viewPort.TopLeftX = ( GR::f32 )Viewport.X;
viewPort.TopLeftY = ( GR::f32 )Viewport.Y;
viewPort.MinDepth = Viewport.MinZ;
viewPort.MaxDepth = Viewport.MaxZ;
if ( viewPort.TopLeftX >= Width() )
{
viewPort.TopLeftX = ( GR::f32 )Width();
viewPort.Width = 0;
}
if ( viewPort.TopLeftY >= Height() )
{
viewPort.TopLeftY = ( GR::f32 )Height();
viewPort.Height = 0;
}
if ( viewPort.TopLeftX + viewPort.Width > Width() )
{
viewPort.Width = Width() - viewPort.TopLeftX;
}
if ( viewPort.TopLeftY + viewPort.Height> Height() )
{
viewPort.Height = Height() - viewPort.TopLeftY;
}
m_pDeviceContext->RSSetViewports( 1, &viewPort );
return true;
}
GR::u32 DX11Renderer::Width()
{
return m_Width;
}
GR::u32 DX11Renderer::Height()
{
return m_Height;
}
void DX11Renderer::Clear( bool ClearColor, bool ClearZ )
{
FlushAllCaches();
if ( ClearColor )
{
if ( m_pCurrentlySetRenderTargetTexture != NULL )
{
m_pDeviceContext->ClearRenderTargetView( m_pCurrentlySetRenderTargetTexture->m_pTextureRenderTargetView, m_ClearColor );
}
else if ( m_pTargetBackBuffer != NULL )
{
m_pDeviceContext->ClearRenderTargetView( m_pTargetBackBuffer, m_ClearColor );
}
}
if ( ClearZ )
{
if ( m_depthStencilView == NULL )
{
dh::Log( "Trying to clear NULL m_depthStencilView!" );
}
else
{
m_pDeviceContext->ClearDepthStencilView( m_depthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0 );
}
}
}
bool DX11Renderer::IsTextureFormatOK( GR::Graphic::eImageFormat imgFormat, bool AllowUsageAsRenderTarget )
{
auto mappedFormat = MapFormat( imgFormat );
switch ( mappedFormat )
{
case DXGI_FORMAT_P8:
// no indexed formats!
return false;
case DXGI_FORMAT_B5G5R5A1_UNORM:
case DXGI_FORMAT_B5G6R5_UNORM:
// Requires DXGI 1.2 or later. DXGI 1.2 types are only supported on systems with Direct3D 11.1 or later (but also says >= 9.1, go figure)
if ( m_FeatureLevel >= D3D_FEATURE_LEVEL_11_1 )
{
return true;
}
return false;
}
return true;
}
DXGI_FORMAT DX11Renderer::MapFormat( GR::Graphic::eImageFormat imgFormat )
{
DXGI_FORMAT d3dFmt = DXGI_FORMAT_UNKNOWN;
switch ( imgFormat )
{
case GR::Graphic::IF_A1R5G5B5:
case GR::Graphic::IF_X1R5G5B5:
d3dFmt = DXGI_FORMAT_B5G5R5A1_UNORM;
break;
case GR::Graphic::IF_A4R4G4B4:
d3dFmt = DXGI_FORMAT_B4G4R4A4_UNORM;
break;
case GR::Graphic::IF_A8:
d3dFmt = DXGI_FORMAT_A8_UNORM;
break;
case GR::Graphic::IF_A8R8G8B8:
d3dFmt = DXGI_FORMAT_B8G8R8A8_UNORM;
break;
case GR::Graphic::IF_INDEX8:
d3dFmt = DXGI_FORMAT_P8;
break;
case GR::Graphic::IF_R5G6B5:
d3dFmt = DXGI_FORMAT_B5G6R5_UNORM;
break;
case GR::Graphic::IF_R8G8B8:
case GR::Graphic::IF_X8R8G8B8:
d3dFmt = DXGI_FORMAT_B8G8R8X8_UNORM;
break;
default:
dh::Log( "DX11Renderer::MapFormat Unsupported format %d", imgFormat );
break;
}
return d3dFmt;
}
GR::Graphic::eImageFormat DX11Renderer::MapFormat( DXGI_FORMAT Format )
{
GR::Graphic::eImageFormat imgFmt = GR::Graphic::IF_UNKNOWN;
switch ( Format )
{
case DXGI_FORMAT_B5G5R5A1_UNORM:
imgFmt = GR::Graphic::IF_A1R5G5B5;
break;
case DXGI_FORMAT_B4G4R4A4_UNORM:
imgFmt = GR::Graphic::IF_A4R4G4B4;
break;
case DXGI_FORMAT_A8_UNORM:
imgFmt = GR::Graphic::IF_A8;
break;
case DXGI_FORMAT_R8G8B8A8_UNORM:
// TODO - not correct!
imgFmt = GR::Graphic::IF_A8R8G8B8;
break;
case DXGI_FORMAT_B8G8R8A8_UNORM:
imgFmt = GR::Graphic::IF_A8R8G8B8;
break;
case DXGI_FORMAT_P8:
imgFmt = GR::Graphic::IF_INDEX8;
break;
case DXGI_FORMAT_B5G6R5_UNORM:
imgFmt = GR::Graphic::IF_R5G6B5;
break;
case DXGI_FORMAT_B8G8R8X8_UNORM:
imgFmt = GR::Graphic::IF_X8R8G8B8;
break;
default:
dh::Log( "DX11Renderer::MapFormat Unsupported D3D format %d", Format );
break;
}
return imgFmt;
}
XTexture* DX11Renderer::CreateTexture( const GR::u32 Width, const GR::u32 Height, const GR::Graphic::eImageFormat imgFormatArg, const GR::u32 MipMapLevels, bool AllowUsageAsRenderTarget )
{
if ( ( Width == 0 )
|| ( Height == 0 )
|| ( m_pDevice == NULL ) )
{
return NULL;
}
GR::Graphic::eImageFormat imgFormat( imgFormatArg );
if ( !IsTextureFormatOK( imgFormat, AllowUsageAsRenderTarget ) )
{
// unterstützte Wechsel
if ( imgFormat == GR::Graphic::IF_PALETTED )
{
imgFormat = GR::Graphic::IF_X8R8G8B8;
}
if ( imgFormat == GR::Graphic::IF_R8G8B8 )
{
imgFormat = GR::Graphic::IF_X8R8G8B8;
if ( !IsTextureFormatOK( imgFormat, AllowUsageAsRenderTarget ) )
{
return NULL;
}
}
else if ( imgFormat == GR::Graphic::IF_X1R5G5B5 )
{
imgFormat = GR::Graphic::IF_R5G6B5;
if ( !IsTextureFormatOK( imgFormat, AllowUsageAsRenderTarget ) )
{
imgFormat = GR::Graphic::IF_X8R8G8B8;
if ( !IsTextureFormatOK( imgFormat, AllowUsageAsRenderTarget ) )
{
return NULL;
}
}
}
else if ( imgFormat == GR::Graphic::IF_A1R5G5B5 )
{
imgFormat = GR::Graphic::IF_A8R8G8B8;
if ( !IsTextureFormatOK( imgFormat, AllowUsageAsRenderTarget ) )
{
return NULL;
}
}
else
{
return NULL;
}
}
int iTWidth = Width,
iTHeight = Height;
int iDummy = 1;
for ( int i = 0; i < 32; i++ )
{
if ( iTWidth <= iDummy )
{
iTWidth = iDummy;
break;
}
iDummy <<= 1;
}
iDummy = 1;
for ( int i = 0; i < 32; i++ )
{
if ( iTHeight <= iDummy )
{
iTHeight = iDummy;
break;
}
iDummy <<= 1;
}
DX11Texture* pTexture = NULL;
pTexture = new( std::nothrow )DX11Texture();
if ( pTexture == NULL )
{
return NULL;
}
pTexture->m_MipMapLevels = MipMapLevels;
if ( pTexture->m_MipMapLevels == 0 )
{
pTexture->m_MipMapLevels = 1;
}
pTexture->AllowUsageAsRenderTarget = AllowUsageAsRenderTarget;
pTexture->m_ImageSourceSize.set( Width, Height );
pTexture->m_ImageFormat = imgFormat;
if ( !CreateNativeTextureResources( pTexture ) )
{
delete pTexture;
return false;
}
AddTexture( pTexture );
return pTexture;
}
bool DX11Renderer::CreateNativeTextureResources( XTextureBase* pTextureBase )
{
DX11Texture* pTexture = (DX11Texture*)pTextureBase;
D3D11_TEXTURE2D_DESC desc;
ZeroMemory( &desc, sizeof( desc ) );
desc.Width = pTexture->m_SurfaceSize.x;
desc.Height = pTexture->m_SurfaceSize.y;
if ( pTexture->m_SurfaceSize.x == 0 )
{
desc.Width = pTexture->m_ImageSourceSize.x;
desc.Height = pTexture->m_ImageSourceSize.y;
}
desc.MipLevels = pTexture->m_MipMapLevels;
desc.ArraySize = pTexture->m_MipMapLevels;
desc.Format = MapFormat( pTexture->m_ImageFormat );
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = 0;
desc.SampleDesc.Count = 1;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.MiscFlags = 0;
if ( pTexture->AllowUsageAsRenderTarget )
{
// allow CPU read/write
desc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
}
ID3D11Texture2D* pTexture2d = NULL;
if ( FAILED( m_pDevice->CreateTexture2D( &desc, NULL, &pTexture2d ) ) )
{
dh::Log( "CreateTexture: CreateTexture failed" );
return NULL;
}
D3D11_TEXTURE2D_DESC texDesc;
pTexture2d->GetDesc( &texDesc );
pTexture->m_SurfaceSize.set( texDesc.Width, texDesc.Height );
pTexture->m_D3DFormat = texDesc.Format;
// re-map since a few formats do not exist anymore (e.g. GR::Graphic::IF_X1R5G5B5)
pTexture->m_ImageFormat = MapFormat( pTexture->m_D3DFormat );//imgFormat;
pTexture->m_pTexture = pTexture2d;
// render target view required if wanted as render target
if ( pTexture->AllowUsageAsRenderTarget )
{
D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
ZeroMemory( &renderTargetViewDesc, sizeof( renderTargetViewDesc ) );
renderTargetViewDesc.Format = texDesc.Format;
renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
renderTargetViewDesc.Texture2D.MipSlice = 0;
// Create the render target view
if ( FAILED( m_pDevice->CreateRenderTargetView( pTexture2d, &renderTargetViewDesc, &pTexture->m_pTextureRenderTargetView ) ) )
{
pTexture->Release();
delete pTexture;
return false;
}
}
D3D11_SHADER_RESOURCE_VIEW_DESC shaderResDesc;
ZeroMemory( &shaderResDesc, sizeof( shaderResDesc ) );
shaderResDesc.Format = texDesc.Format;
shaderResDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
shaderResDesc.Texture2D.MostDetailedMip = 0;
if ( pTexture->AllowUsageAsRenderTarget )
{
shaderResDesc.Texture2D.MipLevels = 1;
}
else
{
shaderResDesc.Texture2D.MipLevels = -1; // -1 = consider all mip map levels
}
if ( FAILED( m_pDevice->CreateShaderResourceView( pTexture2d, &shaderResDesc, &pTexture->m_pTextureShaderResourceView ) ) )
{
pTexture->Release();
return false;
}
return true;
}
XTexture* DX11Renderer::CreateTexture( const GR::Graphic::ImageData& ImageData, const GR::u32 MipMapLevels, bool AllowUsageAsRenderTarget )
{
XTexture* pTexture = CreateTexture( ImageData.Width(), ImageData.Height(), ImageData.ImageFormat(), MipMapLevels );
if ( pTexture == NULL )
{
return NULL;
}
CopyDataToTexture( pTexture, ImageData );
return pTexture;
}
XTexture* DX11Renderer::LoadTexture( const char* FileName, GR::Graphic::eImageFormat imgFormatToConvert, GR::u32 ColorKey, const GR::u32 MipMapLevels, GR::u32 ColorKeyReplacementColor )
{
GR::String path = FileName;
GR::Graphic::ImageData* pData = LoadAndConvert( path.c_str(), imgFormatToConvert, ColorKey, ColorKeyReplacementColor );
if ( pData == NULL )
{
dh::Log( "Failed to load texture %s", FileName );
return NULL;
}
XTexture* pTexture = CreateTexture( *pData, MipMapLevels );
if ( pTexture == NULL )
{
delete pData;
return NULL;
}
pTexture->m_ColorKey = ColorKey;
pTexture->m_ColorKeyReplacementColor = ColorKeyReplacementColor;
pTexture->m_LoadedFromFile = path;
delete pData;
return pTexture;
}
void DX11Renderer::SetTexture( GR::u32 Stage, XTexture* pTexture )
{
if ( Stage >= 8 )
{
return;
}
if ( m_SetTextures[Stage] == pTexture )
{
return;
}
m_SetTextures[Stage] = pTexture;
if ( pTexture == NULL )
{
// TODO - need flags if texture is set in stage?
return;
}
// only set on pixel shader (for now)
DX11Texture* pDXTexture = (DX11Texture*)pTexture;
m_pDeviceContext->PSSetShaderResources( Stage, 1, &pDXTexture->m_pTextureShaderResourceView );
}
bool DX11Renderer::CopyDataToTexture( XTexture* pTexture, const GR::Graphic::ImageData& ImageData, GR::u32 ColorKey, const GR::u32 MipMapLevel )
{
FlushAllCaches();
if ( pTexture == NULL )
{
dh::Error( "CopyDataToTexture: Texture was NULL" );
return false;
}
DX11Texture* pDXTexture = (DX11Texture*)pTexture;
if ( MipMapLevel >= pDXTexture->m_MipMapLevels )
{
dh::Error( "CopyDataToTexture: MipMapLevel out of bounds %d >= %d", MipMapLevel, ( (DX11Texture*)pTexture )->m_MipMapLevels );
return false;
}
GR::u32 Width = pTexture->m_SurfaceSize.x;
GR::u32 Height = pTexture->m_SurfaceSize.y;
GR::u32 CurLevel = MipMapLevel;
while ( CurLevel >= 1 )
{
Width /= 2;
if ( Width == 0 )
{
Width = 1;
}
Height /= 2;
if ( Height == 0 )
{
Height = 1;
}
--CurLevel;
}
if ( ( ImageData.Width() > (int)Width )
|| ( ImageData.Height() > (int)Height ) )
{
dh::Error( "CopyDataToTexture: Sizes mismatching %dx%d != %dx%d", ImageData.Width(), ImageData.Height(), Width, Height );
return false;
}
GR::Graphic::ImageData convertedData( ImageData );
if ( !convertedData.ConvertSelfTo( pDXTexture->m_ImageFormat ) )
{
dh::Error( "CopyDataToTexture ConvertInto failed" );
return false;
}
D3D11_BOX updateRect;
updateRect.left = 0;
updateRect.top = 0;
updateRect.right = convertedData.Width();
updateRect.bottom = convertedData.Height();
updateRect.front = 0;
updateRect.back = 1;
m_pDeviceContext->UpdateSubresource( pDXTexture->m_pTexture,
D3D11CalcSubresource( MipMapLevel, 0, pDXTexture->m_MipMapLevels ),
&updateRect,
convertedData.Data(),
convertedData.BytesPerLine(),
0 );
// store copied data
while ( pDXTexture->m_StoredImageData.size() <= MipMapLevel )
{
pDXTexture->m_StoredImageData.push_back( GR::Graphic::ImageData() );
}
pDXTexture->m_StoredImageData.back() = ImageData;
return true;
}
// Lights
bool DX11Renderer::SetLight( GR::u32 LightIndex, XLight& Light )
{
if ( LightIndex >= 8 )
{
return false;
}
FlushAllCaches();
bool hadChange = false;
if ( m_SetLights[LightIndex].m_Type != XLight::LT_INVALID )
{
if ( m_LightEnabled[LightIndex] )
{
--m_NumActiveLights;
hadChange = true;
}
}
m_SetLights[LightIndex] = Light;
if ( Light.m_Type == XLight::LT_DIRECTIONAL )
{
m_LightInfo.Light[LightIndex].Diffuse = ColorValue( Light.m_Diffuse );
m_LightInfo.Light[LightIndex].Ambient = ColorValue( Light.m_Ambient );
m_LightInfo.Light[LightIndex].Direction = Light.m_Direction;
m_LightInfo.Light[LightIndex].Specular = ColorValue( Light.m_Specular );
}
if ( m_SetLights[LightIndex].m_Type != XLight::LT_INVALID )
{
if ( m_LightEnabled[LightIndex] )
{
++m_NumActiveLights;
hadChange = true;
}
}
if ( hadChange )
{
m_pDeviceContext->UpdateSubresource( m_pLightBuffer, 0, NULL, &m_LightInfo, 0, 0 );
m_pDeviceContext->VSSetConstantBuffers( 1, 1, &m_pLightBuffer );
m_LightsChanged = false;
}
else
{
m_LightsChanged = true;
}
return true;
}
bool DX11Renderer::SetMaterial( const XMaterial& Material )
{
FlushAllCaches();
m_Material.Ambient = ColorValue( Material.Ambient );
m_Material.Emissive = ColorValue( Material.Emissive );
m_Material.Diffuse = ColorValue( Material.Diffuse );
m_Material.Specular = ColorValue( Material.Specular );
m_Material.SpecularPower = Material.Power;
if ( m_Material.Diffuse == ColorValue( 0 ) )
{
m_Material.Diffuse = ColorValue( 0xffffffff );
}
m_pDeviceContext->UpdateSubresource( m_pMaterialBuffer, 0, NULL, &m_Material, 0, 0 );
m_pDeviceContext->VSSetConstantBuffers( 2, 1, &m_pMaterialBuffer );
return true;
}
bool DX11Renderer::SetFogInfo()
{
FlushAllCaches();
m_pDeviceContext->UpdateSubresource( m_pFogBuffer, 0, NULL, &m_Fog, 0, 0 );
m_pDeviceContext->VSSetConstantBuffers( 3, 1, &m_pFogBuffer );
m_pDeviceContext->PSSetConstantBuffers( 3, 1, &m_pFogBuffer );
return true;
}
XVertexBuffer* DX11Renderer::CreateVertexBuffer( GR::u32 PrimitiveCount, GR::u32 VertexFormat, XVertexBuffer::PrimitiveType Type )
{
if ( !m_pDevice )
{
dh::Log( "DX11Renderer::CreateVertexBuffer: no Device" );
return NULL;
}
DX11VertexBuffer* pBuffer = new DX11VertexBuffer( this );
if ( !pBuffer->Create( PrimitiveCount, VertexFormat, Type ) )
{
delete pBuffer;
return NULL;
}
AddVertexBuffer( pBuffer );
return pBuffer;
}
XVertexBuffer* DX11Renderer::CreateVertexBuffer( GR::u32 VertexFormat, XVertexBuffer::PrimitiveType Type )
{
if ( !m_pDevice )
{
dh::Log( "DX11Renderer::CreateVertexBuffer: no Device" );
return NULL;
}
DX11VertexBuffer* pBuffer = new DX11VertexBuffer( this );
if ( !pBuffer->Create( VertexFormat, Type ) )
{
delete pBuffer;
return NULL;
}
AddVertexBuffer( pBuffer );
return pBuffer;
}
XVertexBuffer* DX11Renderer::CreateVertexBuffer( const Mesh::IMesh& MeshObject, GR::u32 VertexFormat )
{
XVertexBuffer* pBuffer = CreateVertexBuffer( MeshObject.FaceCount(), VertexFormat, XVertexBuffer::PT_TRIANGLE );
if ( pBuffer == NULL )
{
return NULL;
}
pBuffer->FillFromMesh( MeshObject );
return pBuffer;
}
void DX11Renderer::DestroyVertexBuffer( XVertexBuffer* pVB )
{
if ( pVB != NULL )
{
pVB->Release();
delete pVB;
m_VertexBuffers.remove( pVB );
}
}
bool DX11Renderer::RenderVertexBuffer( XVertexBuffer* pBuffer, GR::u32 Index, GR::u32 Count )
{
DX11VertexBuffer* pVB = (DX11VertexBuffer*)pBuffer;
if ( pVB == NULL )
{
return false;
}
ChooseShaders( pVB->VertexFormat() );
FlushAllCaches();
return pVB->Display( Index, Count );
}
void DX11Renderer::RenderLine2d( const GR::tPoint& pt1, const GR::tPoint& pt2, GR::u32 Color1, GR::u32 Color2, float fZ )
{
if ( Color2 == 0 )
{
Color2 = Color1;
}
SetLineMode();
m_LineCache3d.FlushCache();
GR::f32 virtualX = ( GR::f32 )m_Canvas.width() / m_VirtualSize.x;
GR::f32 virtualY = ( GR::f32 )m_Canvas.height() / m_VirtualSize.y;
m_LineCache.AddEntry( m_SetTextures[0],
GR::tVector( m_Canvas.Left + m_DisplayOffset.x + ( GR::f32 )pt1.x * virtualX, m_Canvas.Top + m_DisplayOffset.y + ( GR::f32 )pt1.y * virtualY, fZ ), 0.0f, 0.0f,
GR::tVector( m_Canvas.Left + m_DisplayOffset.x + ( GR::f32 )pt2.x * virtualX, m_Canvas.Top + m_DisplayOffset.y + ( GR::f32 )pt2.y * virtualY, fZ ), 0.0f, 0.0f,
Color1, Color2,
m_CurrentShaderType );
}
void DX11Renderer::RenderLine( const GR::tVector& Pos1, const GR::tVector& Pos2, GR::u32 Color1, GR::u32 Color2 )
{
if ( Color2 == 0 )
{
Color2 = Color1;
}
SetLineMode();
m_LineCache.FlushCache();
m_LineCache3d.AddEntry( m_SetTextures[0],
Pos1, 0.0f, 0.0f,
Pos2, 0.0f, 0.0f,
Color1, Color2,
m_CurrentShaderType );
}
void DX11Renderer::SetLineMode()
{
if ( m_CacheMode == CM_LINE )
{
return;
}
m_CacheMode = CM_LINE;
m_QuadCache3d.FlushCache();
m_QuadCache.FlushCache();
m_TriangleCache.FlushCache();
m_TriangleCache3d.FlushCache();
}
void DX11Renderer::SetQuadMode()
{
if ( m_CacheMode == CM_QUAD )
{
return;
}
m_CacheMode = CM_QUAD;
m_LineCache.FlushCache();
m_LineCache3d.FlushCache();
m_TriangleCache.FlushCache();
m_TriangleCache3d.FlushCache();
}
void DX11Renderer::SetTriangleMode()
{
if ( m_CacheMode == CM_TRIANGLE )
{
return;
}
m_CacheMode = CM_TRIANGLE;
m_LineCache.FlushCache();
m_LineCache3d.FlushCache();
m_QuadCache.FlushCache();
m_QuadCache3d.FlushCache();
}
void DX11Renderer::RenderQuad2d( GR::i32 iX, GR::i32 iY, GR::i32 iWidth, GR::i32 iHeight,
GR::f32 fTU1, GR::f32 fTV1,
GR::f32 fTU2, GR::f32 fTV2,
GR::f32 fTU3, GR::f32 fTV3,
GR::f32 fTU4, GR::f32 fTV4,
GR::u32 Color1, GR::u32 Color2,
GR::u32 Color3, GR::u32 Color4, float fZ )
{
if ( ( Color2 == Color3 )
&& ( Color3 == Color4 )
&& ( Color4 == 0 ) )
{
Color2 = Color3 = Color4 = Color1;
}
iX += m_DisplayOffset.x;
iY += m_DisplayOffset.y;
GR::f32 virtualX = ( GR::f32 )m_Canvas.width() / m_VirtualSize.x;
GR::f32 virtualY = ( GR::f32 )m_Canvas.height() / m_VirtualSize.y;
SetQuadMode();
m_QuadCache3d.FlushCache();
m_QuadCache.AddEntry( m_SetTextures[0],
GR::tVector( m_Canvas.Left + iX * virtualX, m_Canvas.Top + iY * virtualY, fZ ), fTU1, fTV1,
GR::tVector( m_Canvas.Left + ( iX + iWidth ) * virtualX, m_Canvas.Top + iY * virtualY, fZ ), fTU2, fTV2,
GR::tVector( m_Canvas.Left + iX * virtualX, m_Canvas.Top + ( iY + iHeight ) * virtualY, fZ ), fTU3, fTV3,
GR::tVector( m_Canvas.Left + ( iX + iWidth ) * virtualX, m_Canvas.Top + ( iY + iHeight ) * virtualY, fZ ), fTU4, fTV4,
Color1, Color2, Color3, Color4, m_CurrentShaderType );
}
bool DX11Renderer::RenderMesh2d( const Mesh::IMesh& Mesh )
{
auto pVB = CreateVertexBuffer( Mesh, XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_DIFFUSE );
//auto pVB = CreateVertexBuffer( Mesh, XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE );
if ( pVB == NULL )
{
return false;
}
RenderVertexBuffer( pVB );
DestroyVertexBuffer( pVB );
return true;
}
void DX11Renderer::RenderQuadDetail2d( GR::f32 fX, GR::f32 fY, GR::f32 fWidth, GR::f32 fHeight,
GR::f32 fTU1, GR::f32 fTV1,
GR::f32 fTU2, GR::f32 fTV2,
GR::f32 fTU3, GR::f32 fTV3,
GR::f32 fTU4, GR::f32 fTV4,
GR::u32 Color1, GR::u32 Color2,
GR::u32 Color3, GR::u32 Color4, float fZ )
{
if ( ( Color2 == Color3 )
&& ( Color3 == Color4 )
&& ( Color4 == 0 ) )
{
Color2 = Color3 = Color4 = Color1;
}
GR::f32 virtualX = ( GR::f32 )m_Canvas.width() / m_VirtualSize.x;
GR::f32 virtualY = ( GR::f32 )m_Canvas.height() / m_VirtualSize.y;
fX *= virtualX;
fY *= virtualY;
fX += m_DisplayOffset.x;
fY += m_DisplayOffset.y;
SetQuadMode();
m_QuadCache3d.FlushCache();
m_QuadCache.AddEntry( m_SetTextures[0],
GR::tVector( m_Canvas.Left + fX, m_Canvas.Top + fY, fZ ), fTU1, fTV1,
GR::tVector( m_Canvas.Left + fX + fWidth * virtualX, m_Canvas.Top + fY, fZ ), fTU2, fTV2,
GR::tVector( m_Canvas.Left + fX, m_Canvas.Top + fY + fHeight * virtualY, fZ ), fTU3, fTV3,
GR::tVector( m_Canvas.Left + fX + fWidth * virtualX, m_Canvas.Top + fY + fHeight * virtualY, fZ ), fTU4, fTV4,
Color1, Color2, Color3, Color4, m_CurrentShaderType );
}
void DX11Renderer::RenderQuad( const GR::tVector& ptPos1,
const GR::tVector& ptPos2,
const GR::tVector& ptPos3,
const GR::tVector& ptPos4,
GR::f32 fTU1, GR::f32 fTV1,
GR::f32 fTU2, GR::f32 fTV2,
GR::u32 Color1, GR::u32 Color2,
GR::u32 Color3, GR::u32 Color4 )
{
RenderQuad( ptPos1, ptPos2, ptPos3, ptPos4,
fTU1, fTV1, fTU2, fTV1, fTU1, fTV2, fTU2, fTV2,
Color1, Color2, Color3, Color4 );
}
void DX11Renderer::RenderQuad( const GR::tVector& ptPos1,
const GR::tVector& ptPos2,
const GR::tVector& ptPos3,
const GR::tVector& ptPos4,
GR::f32 fTU1, GR::f32 fTV1,
GR::f32 fTU2, GR::f32 fTV2,
GR::f32 fTU3, GR::f32 fTV3,
GR::f32 fTU4, GR::f32 fTV4,
GR::u32 Color1, GR::u32 Color2,
GR::u32 Color3, GR::u32 Color4 )
{
if ( ( Color2 == Color3 )
&& ( Color3 == Color4 )
&& ( Color4 == 0 ) )
{
Color2 = Color3 = Color4 = Color1;
}
SetQuadMode();
m_QuadCache.FlushCache();
m_QuadCache3d.AddEntry( m_SetTextures[0],
ptPos1, fTU1, fTV1,
ptPos2, fTU2, fTV2,
ptPos3, fTU3, fTV3,
ptPos4, fTU4, fTV4,
Color1, Color2, Color3, Color4, m_CurrentShaderType );
}
void DX11Renderer::RenderTriangle( const GR::tVector& pt1,
const GR::tVector& pt2,
const GR::tVector& pt3,
GR::f32 fTU1, GR::f32 fTV1,
GR::f32 fTU2, GR::f32 fTV2,
GR::f32 fTU3, GR::f32 fTV3,
GR::u32 Color1, GR::u32 Color2,
GR::u32 Color3 )
{
SetTriangleMode();
FlushLightChanges();
if ( ( Color2 == Color3 )
&& ( Color3 == 0 ) )
{
Color2 = Color3 = Color1;
}
m_TriangleCache3d.AddEntry( m_SetTextures[0],
pt1, fTU1, fTV1,
pt2, fTU2, fTV2,
pt3, fTU3, fTV3,
Color1, Color2, Color3,
m_CurrentShaderType );
/*
XMesh mesh;
mesh.AddVertex( pt1 );
mesh.AddVertex( pt2 );
mesh.AddVertex( pt3 );
Mesh::Face face1( 0, Color1, 1, Color2, 2, Color3 );
face1.m_TextureX[0] = fTU1;
face1.m_TextureY[0] = fTV1;
face1.m_TextureX[1] = fTU2;
face1.m_TextureY[1] = fTV2;
face1.m_TextureX[2] = fTU3;
face1.m_TextureY[2] = fTV3;
mesh.AddFace( face1 );
mesh.CalculateNormals();
RenderMesh( mesh );*/
}
void DX11Renderer::RenderTriangle2d( const GR::tPoint& pt1,
const GR::tPoint& pt2,
const GR::tPoint& pt3,
GR::f32 fTU1, GR::f32 fTV1,
GR::f32 fTU2, GR::f32 fTV2,
GR::f32 fTU3, GR::f32 fTV3,
GR::u32 Color1, GR::u32 Color2,
GR::u32 Color3, float fZ )
{
SetQuadMode();
FlushLightChanges();
m_QuadCache.FlushCache();
if ( ( Color2 == Color3 )
&& ( Color3 == 0 ) )
{
Color2 = Color3 = Color1;
}
GR::f32 virtualX = (GR::f32)m_Canvas.width() / m_VirtualSize.x;
GR::f32 virtualY = ( GR::f32 )m_Canvas.height() / m_VirtualSize.y;
m_TriangleCache.AddEntry( m_SetTextures[0],
GR::tVector( m_Canvas.Left + m_DisplayOffset.x + ( GR::f32 )pt1.x * virtualX, m_Canvas.Top + m_DisplayOffset.y + ( GR::f32 )pt1.y * virtualY, fZ ), fTU1, fTV1,
GR::tVector( m_Canvas.Left + m_DisplayOffset.x + ( GR::f32 )pt2.x * virtualX, m_Canvas.Top + m_DisplayOffset.y + ( GR::f32 )pt2.y * virtualY, fZ ), fTU2, fTV2,
GR::tVector( m_Canvas.Left + m_DisplayOffset.x + ( GR::f32 )pt3.x * virtualX, m_Canvas.Top + m_DisplayOffset.y + ( GR::f32 )pt3.y * virtualY, fZ ), fTU3, fTV3,
Color1, Color2, Color3,
m_CurrentShaderType );
/*
XMesh mesh;
mesh.AddVertex( GR::tVector( ( GR::f32 )pt1.x, ( GR::f32 )pt1.y, fZ ) );
mesh.AddVertex( GR::tVector( ( GR::f32 )pt2.x, ( GR::f32 )pt2.y, fZ ) );
mesh.AddVertex( GR::tVector( ( GR::f32 )pt3.x, ( GR::f32 )pt3.y, fZ ) );
Mesh::Face face1( 0, Color1, 1, Color2, 2, Color3 );
face1.m_TextureX[0] = fTU1;
face1.m_TextureY[0] = fTV1;
face1.m_TextureX[1] = fTU2;
face1.m_TextureY[1] = fTV2;
face1.m_TextureX[2] = fTU3;
face1.m_TextureY[2] = fTV3;
mesh.AddFace( face1 );
RenderMesh2d( mesh );*/
}
bool DX11Renderer::SaveScreenShot( const char* FileName )
{
FlushAllCaches();
return true;
}
bool DX11Renderer::VSyncEnabled()
{
return m_VSyncEnabled;
}
void DX11Renderer::EnableVSync( bool Enable )
{
if ( m_VSyncEnabled != Enable )
{
m_VSyncEnabled = Enable;
}
}
GR::Graphic::eImageFormat DX11Renderer::ImageFormat()
{
return GR::Graphic::IF_A8R8G8B8;
}
bool DX11Renderer::ImageDataFromTexture( XTexture* pTexture, GR::Graphic::ImageData& ImageData, const GR::u32 MipMapLevel )
{
if ( pTexture == NULL )
{
dh::Error( "Renderer.General", "ImageDataFromTexture: Texture was NULL" );
return false;
}
DX11Texture* pDX11Texture = (DX11Texture*)pTexture;
if ( MipMapLevel >= pDX11Texture->m_StoredImageData.size() )
{
dh::Error( "Renderer.General", "ImageDataFromTexture: MipMapLevel out of bounds %d >= %d", MipMapLevel, pDX11Texture->m_MipMapLevels );
return false;
}
std::list<GR::Graphic::ImageData>::iterator it( pDX11Texture->m_StoredImageData.begin() );
std::advance( it, MipMapLevel );
ImageData = *it;
return true;
}
bool DX11Renderer::RenderMesh( const Mesh::IMesh& Mesh )
{
SetQuadMode();
FlushLightChanges();
m_QuadCache.FlushCache();
GR::u32 vertexFormat = XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_NORMAL;
if ( Mesh.FaceCount() == 2 )
{
// a quad, reuse stored vertex buffer
std::map<GR::u32, XVertexBuffer*>::iterator itMVB( m_BasicVertexBuffers.find( vertexFormat ) );
if ( itMVB == m_BasicVertexBuffers.end() )
{
auto pVB = CreateVertexBuffer( Mesh, vertexFormat );
m_BasicVertexBuffers[vertexFormat] = pVB;
pVB->FillFromMesh( Mesh );
RenderVertexBuffer( pVB );
return true;
}
auto pVB = itMVB->second;
pVB->FillFromMesh( Mesh );
RenderVertexBuffer( pVB );
return true;
}
// create temporary
auto pVB = CreateVertexBuffer( Mesh, vertexFormat );
if ( pVB == NULL )
{
return false;
}
RenderVertexBuffer( pVB );
DestroyVertexBuffer( pVB );
return true;
}
void DX11Renderer::RenderQuadDetail2d( GR::f32 X1, GR::f32 Y1,
GR::f32 X2, GR::f32 Y2,
GR::f32 X3, GR::f32 Y3,
GR::f32 X4, GR::f32 Y4,
GR::f32 TU1, GR::f32 TV1,
GR::f32 TU2, GR::f32 TV2,
GR::f32 TU3, GR::f32 TV3,
GR::f32 TU4, GR::f32 TV4,
GR::u32 Color1, GR::u32 Color2,
GR::u32 Color3, GR::u32 Color4, float fZ )
{
if ( ( Color2 == Color3 )
&& ( Color3 == Color4 )
&& ( Color4 == 0 ) )
{
Color2 = Color3 = Color4 = Color1;
}
GR::f32 virtualX = ( GR::f32 )m_Canvas.width() / m_VirtualSize.x;
GR::f32 virtualY = ( GR::f32 )m_Canvas.height() / m_VirtualSize.y;
X1 *= virtualX;
Y1 *= virtualY;
X2 *= virtualX;
Y2 *= virtualY;
X3 *= virtualX;
Y3 *= virtualY;
X4 *= virtualX;
Y4 *= virtualY;
X1 += m_DisplayOffset.x;
Y1 += m_DisplayOffset.y;
X2 += m_DisplayOffset.x;
Y2 += m_DisplayOffset.y;
X3 += m_DisplayOffset.x;
Y3 += m_DisplayOffset.y;
X4 += m_DisplayOffset.x;
Y4 += m_DisplayOffset.y;
SetQuadMode();
m_QuadCache3d.FlushCache();
m_QuadCache.AddEntry( m_SetTextures[0],
GR::tVector( m_Canvas.Left + X1, m_Canvas.Top + Y1, fZ ), TU1, TV1,
GR::tVector( m_Canvas.Left + X2, m_Canvas.Top + Y2, fZ ), TU2, TV2,
GR::tVector( m_Canvas.Left + X3, m_Canvas.Top + Y3, fZ ), TU3, TV3,
GR::tVector( m_Canvas.Left + X4, m_Canvas.Top + Y4, fZ ), TU4, TV4,
Color1, Color2, Color3, Color4,
m_CurrentShaderType );
}
void DX11Renderer::SetRenderTarget( XTexture* pTexture )
{
if ( pTexture == m_pCurrentlySetRenderTargetTexture )
{
return;
}
FlushAllCaches();
m_pCurrentlySetRenderTargetTexture = (DX11Texture*)pTexture;
if ( m_pCurrentlySetRenderTargetTexture )
{
m_pDeviceContext->OMSetRenderTargets( 1, &m_pCurrentlySetRenderTargetTexture->m_pTextureRenderTargetView, NULL );
}
else
{
// back to regular back buffer
m_pDeviceContext->OMSetRenderTargets( 1, &m_pTargetBackBuffer, m_depthStencilView );
}
}
ID3D11Device* DX11Renderer::Device()
{
return m_pDevice;
}
ID3D11DeviceContext* DX11Renderer::DeviceContext()
{
return m_pDeviceContext;
}
ID3D11InputLayout* DX11Renderer::InputLayout( GR::u32 VertexFormat )
{
std::map<GR::u32, DX11VertexShader*>::iterator it( m_VSInputLayout.find( VertexFormat ) );
if ( it == m_VSInputLayout.end() )
{
return NULL;
}
return it->second->m_pInputLayout;
}
void DX11Renderer::ChooseShaders( GR::u32 VertexFormat )
{
eShaderType shaderTypeToUse = m_CurrentShaderType;
if ( shaderTypeToUse == ST_ALPHA_BLEND )
{
m_pDeviceContext->OMSetBlendState( m_pBlendStateAlphaBlend, NULL, 0xffffffff );
shaderTypeToUse = ST_FLAT;
}
else if ( shaderTypeToUse == ST_ALPHA_BLEND_AND_TEST )
{
m_pDeviceContext->OMSetBlendState( m_pBlendStateAlphaBlend, NULL, 0xffffffff );
shaderTypeToUse = ST_ALPHA_TEST;
}
else if ( shaderTypeToUse == ST_ADDITIVE )
{
m_pDeviceContext->OMSetBlendState( m_pBlendStateAdditive, NULL, 0xffffffff );
}
else
{
m_pDeviceContext->OMSetBlendState( NULL, NULL, 0xffffffff );
}
// fall back to non-texture mode?
if ( m_SetTextures[0] == NULL )
{
if ( shaderTypeToUse == ST_FLAT )
{
shaderTypeToUse = ST_FLAT_NO_TEXTURE;
}
}
int numLights = m_NumActiveLights;
bool lightDisabled = ( m_RenderStates[std::make_pair( XRenderer::RS_LIGHTING, 0 )] == XRenderer::RSV_DISABLE );
switch ( shaderTypeToUse )
{
case ST_FLAT:
if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD ) )
{
SetVertexShader( "position_texture_color" );
SetPixelShader( "position_texture_color" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD ) )
{
SetVertexShader( "positionrhw_texture_color" );
SetPixelShader( "position_texture_color" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_NORMAL ) )
{
SetVertexShader( "positionrhw_texture_color_normal_nolight" );
SetPixelShader( "position_texture_color" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE ) )
{
SetVertexShader( "position_color" );
SetPixelShader( "position_color" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE ) )
{
SetVertexShader( "positionrhw_color" );
SetPixelShader( "position_color" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_NORMAL ) )
{
if ( lightDisabled )
{
SetVertexShader( "position_texture_color_normal_lightdisabled" );
SetPixelShader( "position_texture_color" );
return;
}
else if ( numLights == 0 )
{
SetVertexShader( "position_texture_color_normal_nolight" );
SetPixelShader( "position_texture_color" );
return;
}
else if ( numLights == 1 )
{
SetVertexShader( "position_texture_color_normal_light1" );
SetPixelShader( "position_texture_color" );
return;
}
else if ( numLights == 2 )
{
SetVertexShader( "position_texture_color_normal_light2" );
SetPixelShader( "position_texture_color" );
return;
}
}
break;
case ST_FLAT_NO_TEXTURE:
if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE ) )
{
SetVertexShader( "position_color" );
SetPixelShader( "position_color" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD ) )
{
SetVertexShader( "position_notexture_color" );
SetPixelShader( "position_color" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_NORMAL ) )
{
SetVertexShader( "positionrhw_notexture_color_normal_nolight" );
SetPixelShader( "position_color" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_NORMAL ) )
{
if ( lightDisabled )
{
SetVertexShader( "position_notexture_color_normal_lightdisabled" );
//SetPixelShader( "position_texture_color" );
SetPixelShader( "position_color" );
return;
}
else if ( numLights == 0 )
{
SetVertexShader( "position_notexture_color_normal_nolight" );
SetPixelShader( "position_color" );
return;
}
else if ( numLights == 1 )
{
SetVertexShader( "position_notexture_color_normal_light1" );
SetPixelShader( "position_color" );
return;
}
else if ( numLights == 2 )
{
SetVertexShader( "position_notexture_color_normal_light2" );
SetPixelShader( "position_color" );
return;
}
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE ) )
{
SetVertexShader( "positionrhw_color" );
SetPixelShader( "position_color" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD ) )
{
SetVertexShader( "positionrhw_notexture_color" );
SetPixelShader( "position_color" );
return;
}
break;
case ST_ALPHA_TEST:
if ( m_SetTextures[0] == NULL )
{
// no texture set
if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD ) )
{
SetVertexShader( "position_notexture_color" );
SetPixelShader( "position_color_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD ) )
{
SetVertexShader( "positionrhw_notexture_color" );
SetPixelShader( "position_color_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_NORMAL ) )
{
// no light with XYZRHW!
SetVertexShader( "positionrhw_notexture_color_normal_nolight" );
SetPixelShader( "position_color_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_NORMAL ) )
{
if ( lightDisabled )
{
SetVertexShader( "position_notexture_color_normal_lightdisabled" );
SetPixelShader( "position_color_alphatest" );
return;
}
else if ( numLights == 0 )
{
SetVertexShader( "position_notexture_color_normal_nolight" );
SetPixelShader( "position_color_alphatest" );
return;
}
else if ( numLights == 1 )
{
SetVertexShader( "position_notexture_color_normal_light1" );
SetPixelShader( "position_color_alphatest" );
return;
}
else if ( numLights == 2 )
{
SetVertexShader( "position_notexture_color_normal_light2" );
SetPixelShader( "position_color_alphatest" );
return;
}
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE ) )
{
SetVertexShader( "position_color" );
SetPixelShader( "position_color_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE ) )
{
SetVertexShader( "positionrhw_color" );
SetPixelShader( "position_color_alphatest" );
return;
}
}
else
{
// has texture set
if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD ) )
{
SetVertexShader( "position_texture_color" );
SetPixelShader( "position_texture_color_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_NORMAL ) )
{
// no lights with xyzrhw
SetVertexShader( "positionrhw_texture_color_normal_nolight" );
SetPixelShader( "position_texture_color_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_NORMAL ) )
{
if ( lightDisabled )
{
SetVertexShader( "position_texture_color_normal_lightdisabled" );
SetPixelShader( "position_texture_color_alphatest" );
return;
}
else if ( numLights == 0 )
{
SetVertexShader( "position_texture_color_normal_nolight" );
SetPixelShader( "position_texture_color_alphatest" );
return;
}
else if ( numLights == 1 )
{
SetVertexShader( "position_texture_color_normal_light1" );
SetPixelShader( "position_texture_color_alphatest" );
return;
}
else if ( numLights == 2 )
{
SetVertexShader( "position_texture_color_normal_light2" );
SetPixelShader( "position_texture_color_alphatest" );
return;
}
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD ) )
{
SetVertexShader( "positionrhw_texture_color" );
SetPixelShader( "position_texture_color_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE ) )
{
SetVertexShader( "position_color" );
SetPixelShader( "position_color_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE ) )
{
SetVertexShader( "positionrhw_color" );
SetPixelShader( "position_color_alphatest" );
return;
}
}
break;
case ST_ADDITIVE:
if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_NORMAL ) )
{
if ( lightDisabled )
{
SetVertexShader( "position_texture_color_normal_lightdisabled" );
SetPixelShader( "position_texture_color" );
return;
}
else if ( numLights == 0 )
{
SetVertexShader( "position_texture_color_normal_nolight" );
SetPixelShader( "position_texture_color" );
return;
}
else if ( numLights == 1 )
{
SetVertexShader( "position_texture_color_normal_light1" );
SetPixelShader( "position_texture_color" );
return;
}
else if ( numLights == 2 )
{
SetVertexShader( "position_texture_color_normal_light2" );
SetPixelShader( "position_texture_color" );
return;
}
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_NORMAL ) )
{
// no lights with xyzrhw
SetVertexShader( "positionrhw_texture_color_normal_nolight" );
SetPixelShader( "position_texture_color" );
return;
}
break;
case ST_ALPHA_TEST_COLOR_FROM_DIFFUSE:
if ( m_SetTextures[0] == NULL )
{
// no texture set
if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD ) )
{
SetVertexShader( "position_notexture_color" );
SetPixelShader( "position_color_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD ) )
{
SetVertexShader( "positionrhw_notexture_color" );
SetPixelShader( "position_color_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_NORMAL ) )
{
// no lights with xyzrhw
SetVertexShader( "positionrhw_notexture_color_normal_nolight" );
SetPixelShader( "position_color_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_NORMAL ) )
{
if ( lightDisabled )
{
SetVertexShader( "position_texture_color_normal_lightdisabled" );
SetPixelShader( "position_texture_color_alphatest" );
return;
}
else if ( numLights == 0 )
{
SetVertexShader( "position_texture_color_normal_nolight" );
SetPixelShader( "position_texture_color_alphatest" );
return;
}
else if ( numLights == 1 )
{
SetVertexShader( "position_texture_color_normal_light1" );
SetPixelShader( "position_texture_color_alphatest" );
return;
}
else if ( numLights == 2 )
{
SetVertexShader( "position_texture_color_normal_light2" );
SetPixelShader( "position_texture_color_alphatest" );
return;
}
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE ) )
{
SetVertexShader( "position_color" );
SetPixelShader( "position_color_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE ) )
{
SetVertexShader( "positionrhw_color" );
SetPixelShader( "position_color_alphatest" );
return;
}
}
else
{
// has texture set
if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD ) )
{
SetVertexShader( "position_texture_color" );
SetPixelShader( "position_texture_colordiffuse_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_NORMAL ) )
{
// no lights with xyzrhw
SetVertexShader( "positionrhw_texture_color_normal_nolight" );
SetPixelShader( "position_texture_colordiffuse_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD | XVertexBuffer::VFF_NORMAL ) )
{
if ( lightDisabled )
{
SetVertexShader( "position_texture_color_normal_lightdisabled" );
SetPixelShader( "position_texture_colordiffuse_alphatest" );
return;
}
else if ( numLights == 0 )
{
SetVertexShader( "position_texture_color_normal_nolight" );
SetPixelShader( "position_texture_colordiffuse_alphatest" );
return;
}
else if ( numLights == 1 )
{
SetVertexShader( "position_texture_color_normal_light1" );
SetPixelShader( "position_texture_colordiffuse_alphatest" );
return;
}
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE | XVertexBuffer::VFF_TEXTURECOORD ) )
{
SetVertexShader( "positionrhw_texture_color" );
SetPixelShader( "position_texture_colordiffuse_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZ | XVertexBuffer::VFF_DIFFUSE ) )
{
SetVertexShader( "position_color" );
SetPixelShader( "position_color_alphatest" );
return;
}
else if ( VertexFormat == ( XVertexBuffer::VFF_XYZRHW | XVertexBuffer::VFF_DIFFUSE ) )
{
SetVertexShader( "positionrhw_color" );
SetPixelShader( "position_color_alphatest" );
return;
}
}
break;
}
dh::Log( "ChooseShaders unsupported shader for shader type %d, vertex format 0x%x, really active %d lights, texture set %x", shaderTypeToUse, VertexFormat, numLights, m_SetTextures[0] );
}
void DX11Renderer::RenderBox( const GR::tVector& vPos, const GR::tVector& vSize, GR::u32 Color )
{
SetQuadMode();
m_QuadCache.FlushCache();
XMesh meshBox;
meshBox.AddVertex( vPos );
meshBox.AddVertex( vPos + GR::tVector( vSize.x, 0.0f, 0.0f ) );
meshBox.AddVertex( vPos + GR::tVector( 0.0f, vSize.y, 0.0f ) );
meshBox.AddVertex( vPos + GR::tVector( vSize.x, vSize.y, 0.0f ) );
meshBox.AddVertex( vPos + GR::tVector( 0.0f, 0.0f, vSize.z ) );
meshBox.AddVertex( vPos + GR::tVector( vSize.x, 0.0f, vSize.z ) );
meshBox.AddVertex( vPos + GR::tVector( 0.0f, vSize.y, vSize.z ) );
meshBox.AddVertex( vPos + GR::tVector( vSize.x, vSize.y, vSize.z ) );
Mesh::Face faceFront1( 2, Color, 6, Color, 3, Color );
Mesh::Face faceFront2( 6, Color, 7, Color, 3, Color );
Mesh::Face faceLeft1( 0, Color, 4, Color, 2, Color );
Mesh::Face faceLeft2( 4, Color, 6, Color, 2, Color );
Mesh::Face faceRight1( 3, Color, 7, Color, 1, Color );
Mesh::Face faceRight2( 7, Color, 5, Color, 1, Color );
Mesh::Face faceBack1( 1, Color, 5, Color, 0, Color );
Mesh::Face faceBack2( 5, Color, 4, Color, 0, Color );
Mesh::Face faceTop1( 0, Color, 2, Color, 1, Color );
Mesh::Face faceTop2( 2, Color, 3, Color, 1, Color );
Mesh::Face faceBottom1( 6, Color, 4, Color, 7, Color );
Mesh::Face faceBottom2( 4, Color, 5, Color, 7, Color );
meshBox.AddFace( faceFront1 );
meshBox.AddFace( faceFront2 );
meshBox.AddFace( faceLeft1 );
meshBox.AddFace( faceLeft2 );
meshBox.AddFace( faceRight1 );
meshBox.AddFace( faceRight2 );
meshBox.AddFace( faceBack1 );
meshBox.AddFace( faceBack2 );
meshBox.AddFace( faceTop1 );
meshBox.AddFace( faceTop2 );
meshBox.AddFace( faceBottom1 );
meshBox.AddFace( faceBottom2 );
for ( int i = 0; i < 12; ++i )
{
if ( i % 2 )
{
meshBox.m_Faces[i].m_TextureX[0] = 0.0f;
meshBox.m_Faces[i].m_TextureY[0] = 1.0f;
meshBox.m_Faces[i].m_TextureX[1] = 1.0f;
meshBox.m_Faces[i].m_TextureY[1] = 0.0f;
meshBox.m_Faces[i].m_TextureX[2] = 1.0f;
meshBox.m_Faces[i].m_TextureY[2] = 1.0f;
}
else
{
meshBox.m_Faces[i].m_TextureX[0] = 0.0f;
meshBox.m_Faces[i].m_TextureY[0] = 0.0f;
meshBox.m_Faces[i].m_TextureX[1] = 1.0f;
meshBox.m_Faces[i].m_TextureY[1] = 0.0f;
meshBox.m_Faces[i].m_TextureX[2] = 0.0f;
meshBox.m_Faces[i].m_TextureY[2] = 1.0f;
}
}
meshBox.CalculateNormals();
RenderMesh( meshBox );
}
void DX11Renderer::SetShader( eShaderType sType )
{
m_CurrentShaderType = sType;
if ( sType == ST_FLAT_NO_TEXTURE )
{
SetTexture( 0, NULL );
SetTexture( 1, NULL );
}
}
XFont* DX11Renderer::LoadFontSquare( const char* FileName, GR::u32 Flags, GR::u32 TransparentColor )
{
XFont* pFont = new DX11Font( this, m_pEnvironment );
pFont->LoadFontSquare( FileName, Flags, TransparentColor );
AddFont( pFont );
return pFont;
}
XFont* DX11Renderer::LoadFont( const char* FileName, GR::u32 TransparentColor )
{
XFont* pFont = new DX11Font( this, m_pEnvironment );
if ( !pFont->LoadFont( FileName, 0, TransparentColor ) )
{
delete pFont;
return NULL;
}
AddFont( pFont );
return pFont;
}
int DX11Renderer::MaxPrimitiveCount()
{
switch ( m_FeatureLevel )
{
default:
case D3D_FEATURE_LEVEL_9_1:
return D3D_FL9_1_IA_PRIMITIVE_MAX_COUNT;
case D3D_FEATURE_LEVEL_9_2:
case D3D_FEATURE_LEVEL_9_3:
case D3D_FEATURE_LEVEL_10_0:
case D3D_FEATURE_LEVEL_10_1:
case D3D_FEATURE_LEVEL_11_0:
case D3D_FEATURE_LEVEL_11_1:
return D3D_FL9_2_IA_PRIMITIVE_MAX_COUNT;
}
return D3D_FL9_1_IA_PRIMITIVE_MAX_COUNT;
}
|
bb043c18c2858eccaf0da3b3cc0ed00dc9e31322
|
5ecd8d226de41603f9d179c4f5255bec1c7cb81b
|
/morse/main.cpp
|
3dfc189c1cc9cff2bd0a31aaf50e114e0ab2a30c
|
[] |
no_license
|
hanganflorin/Sources-and-Algorithms
|
902d249a6796323696bc81be0b18c1edf8a2ab9c
|
c5099b451a21ac18f944c709271754fa145e8bc5
|
refs/heads/master
| 2020-12-25T18:33:51.942506
| 2017-06-11T00:08:37
| 2017-06-11T00:08:37
| 93,971,485
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 404
|
cpp
|
main.cpp
|
#include <fstream>
#include <cstring>
using namespace std;
ifstream is("a.in");
ofstream os("a.out");
int n, cnt = 1;
void Morse(string x );
int main()
{
is >> n;
Morse("");
is.close();
os.close();
return 0;
}
void Morse(string x )
{
if ( x.size() == n )
{
os << x << '\n';
return;
}
Morse(x+'-');
Morse(x+'.');
}
|
05eff46118dac28eb0694b66ad4d01e6174cd068
|
5c799690bcd76010484af134132056a04ae855a0
|
/src/WiFiManagerHandler.h
|
2a1c8e4207b299b4a1c9b74da457539837e59141
|
[
"MIT"
] |
permissive
|
PedroDiogo/ESP8266SensorNode
|
f4cfb2efafe64d12b2c20a4bf89d6fb0201c01c4
|
52d9c063ccf65153e400a399c62b7444aac50d15
|
refs/heads/master
| 2020-03-19T18:59:08.826506
| 2018-07-07T20:18:10
| 2018-07-07T20:18:10
| 136,834,803
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 683
|
h
|
WiFiManagerHandler.h
|
#ifndef WIFIMANAGERHANDLER_H
#define WIFIMANAGERHANDLER_H
#include <WiFiManager.h>
#include "ConfigManager.h"
#define CONFIGURATION_AP_SSID "HomeSensorsConfig"
class WifiManagerHandler
{
public:
WifiManagerHandler(ConfigManager *config);
void connectAndSetConfigs();
void reset();
private:
WiFiManagerParameter _mqtt_server_param = NULL;
WiFiManagerParameter _mqtt_port_param = NULL;
WiFiManagerParameter _mqtt_username_param = NULL;
WiFiManagerParameter _mqtt_password_param = NULL;
WiFiManagerParameter _device_id_param = NULL;
ConfigManager * _config;
WiFiManager _wifiManager;
void configureCustomParameters();
void saveCustomParameters();
};
#endif
|
941377092d2ef023298526edb5124ff048e3dd62
|
7591757b8897fbd664972374dfcee63b95ef7b59
|
/Cpp11/function<ClassMemberObject>.cpp
|
dea477267c2cb6e708d115d854c632257b61501c
|
[] |
no_license
|
StevenHD/LearnCSWithCpp
|
02f8c6719c3285f21277bbd044742bd78fe8ce28
|
bb2d0397bdeeb1c3fc3b257ac67db28082eb38cb
|
refs/heads/master
| 2023-06-01T16:47:51.699152
| 2021-06-16T07:18:16
| 2021-06-16T07:18:16
| 365,490,841
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 910
|
cpp
|
function<ClassMemberObject>.cpp
|
//
// Created by helianhaodong on 2021/4/25.
//
// fucntion 作类成员实现回调
// 类似于观察者模式
#include "../all.h"
class FunctorA
{
public:
void operator()()
{
std::cout << "class FunctorA" << std::endl;
}
};
class FunctorB
{
public:
void operator()()
{
std::cout << "class FunctorB" << std::endl;
}
};
class FunctorC
{
public:
void operator()()
{
std::cout << "class FunctorC" << std::endl;
}
};
class Object
{
public:
Object(FunctorA a, FunctorB b, FunctorC c)
{
m_list.push_back(a);
m_list.push_back(b);
m_list.push_back(c);
}
void notify()
{
for (auto& item : m_list) item();
}
private:
std::list<std::function<void(void)>> m_list;
};
int mainfco()
{
FunctorA a;
FunctorB b;
FunctorC c;
Object obj(a, b, c);
obj.notify();
return 0;
}
|
474bdb535a56a938e6ff0fe69af12c3733cf366c
|
f6996face7fdbe49b73e90ecf3cc287dada9e247
|
/src/plugins/phonevendors/ezx/ezxmodempinmanager.cpp
|
5f8ad77aaf0c2ffdee2d1bc6cc62595867fd7b9a
|
[] |
no_license
|
trollsid/qtextended-device-ezx
|
56dba940ed345f668dcd882d01deede75fb828dd
|
4368db50f4ea6ecc7893963a30fca138e2ce32f6
|
refs/heads/master
| 2021-01-23T08:04:22.572080
| 2010-03-06T14:10:18
| 2010-03-06T14:10:18
| 549,802
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,819
|
cpp
|
ezxmodempinmanager.cpp
|
/****************************************************************************
**
** Copyright (C) 2000-2008 TROLLTECH ASA. All rights reserved.
**
** This file is part of the Opensource Edition of the Qtopia Toolkit.
**
** This software is licensed under the terms of the GNU General Public
** License (GPL) version 2.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include <ezxmodempinmanager.h>
#include "../../../../../../src/libraries/qtopiaphonemodem/qmodempinmanager_p.h"
#include <qmodemservice.h>
#include <qatchat.h>
#include <qatresult.h>
#include <qatresultparser.h>
#include <qatutils.h>
#include <qtopialog.h>
#include <QTimer>
class EzxModemPinManagerPrivate
{
public:
EzxModemPinManagerPrivate( QModemService *service )
{
this->service = service;
this->querying = false;
this->simMissing = false;
}
QModemService *service;
QString expectedPin;
QString expectedAskPin;
QString changingPin;
QString lastSimPin;
QString currentPin;
bool querying;
QList<QModemPendingPin *> pending;
QString pendingPin;
QTimer *lastPinTimer;
bool simMissing;
QModemPendingPin *findPending( const QString& type );
};
QModemPendingPin *EzxModemPinManagerPrivate::findPending( const QString& type )
{
QList<QModemPendingPin *>::ConstIterator it;
for ( it = pending.begin(); it != pending.end(); ++it ) {
if ( (*it)->type() == type )
return *it;
}
return 0;
}
/*!
Create a modem pin manager for \a service.
*/
EzxModemPinManager::EzxModemPinManager( QModemService *service )
: QModemPinManager( service )
{
d = new EzxModemPinManagerPrivate( service );
d->lastPinTimer = new QTimer( this );
d->lastPinTimer->setSingleShot( true );
connect( d->lastPinTimer, SIGNAL(timeout()), this, SLOT(lastPinTimeout()) );
// Hook onto the "pinquery" event to allow other providers
// to ask us to query for the pin the modem wants. This may
// be sent during initialization, functionality changes,
// or when the modem reports a "pin/puk required" error.
service->connectToPost( "pinquery", this, SLOT(sendQuery()) );
service->connectToPost( "simnotinserted", this, SLOT(simMissing()) );
}
/*!
Destroy this modem pin manager.
*/
EzxModemPinManager::~EzxModemPinManager()
{
delete d;
}
void EzxModemPinManager::enterPin( const QString& type, const QString& pin )
{
// Pending pins should be sent to the object that asked for them.
QModemPendingPin *pending;
bool hadPending = false;
while ( ( pending = d->findPending( type ) ) != 0 ) {
d->pending.removeAll( pending );
pending->emitHavePin( pin );
delete pending;
hadPending = true;
}
if ( hadPending )
return;
// If this wasn't a pending pin, then we were probably processing
// the answer to a sendQuery() request.
if ( type != d->expectedPin ) {
qLog( Modem ) << "Pin" << type
<< "entered, expecting" << d->expectedPin;
return;
}
d->currentPin = pin;
d->service->chat( "AT+CPIN=1,\"" + QAtUtils::quote( pin ) + "\"",
this, SLOT(cpinResponse(bool,QAtResult)) );
}
void EzxModemPinManager::enterPuk
( const QString& type, const QString& puk, const QString& newPin )
{
if ( ( type != "SIM PUK" && type != "SIM PUK2" ) || !d->expectedPin.isEmpty() ) {
if ( type != d->expectedPin ) {
qLog( Modem ) << "Puk" << type
<< "entered, expecting" << d->expectedPin;
return;
}
}
if ( type.contains("PUK") && d->findPending( type ) != 0 ) {
// We will need newPin later if the puk is verified.
d->pendingPin = newPin;
d->service->chat( "AT+CPIN=\"" + QAtUtils::quote( puk ) + "\",\"" +
QAtUtils::quote( newPin ) + "\"",
this, SLOT(cpukResponse(bool)) );
} else {
d->currentPin = newPin;
d->expectedPin = type;
d->service->chat(
"AT+CPUR=1;+CPIN=\"" + puk + "\",\"" + newPin + "\"",
this, SLOT(cpinResponse(bool,QAtResult)) );
}
}
// Process the response to a AT+CPIN=[puk,]pin command.
void EzxModemPinManager::cpinResponse( bool ok, const QAtResult& result )
{
d->lastSimPin = QString();
if ( ok ) {
// The pin was entered correctly.
QPinOptions options;
options.setMaxLength( pinMaximum() );
emit pinStatus( d->expectedPin, QPinManager::Valid, options );
if ( d->expectedPin.contains( "PUK" ) ) {
// If we just successfully sent the PUK, then the PIN
// version is also successfull.
QString pin = d->expectedPin.replace( "PUK", "PIN" );
emit pinStatus( pin, QPinManager::Valid, options );
}
if ( d->expectedPin == "SIM PIN" ) {
// Cache the last valid SIM PIN value because some modems will ask
// for it again immediately even when they accept it first time.
// 3GPP TS 27.007 requires this behaviour.
d->lastSimPin = d->currentPin;
d->lastPinTimer->start( 5000 ); // Clear it after 5 seconds.
}
d->expectedPin = QString();
d->service->post( "simpinentered" );
}
d->currentPin = QString();
// If the result includes a "+CPIN" line, then the modem may
// be asking for a new pin/puk already. Otherwise send AT+CPIN?
// to ask whether the modem is "READY" or needs another pin/puk.
QAtResultParser parser( result );
if ( parser.next( "+CPIN:" ) ) {
d->querying = true;
cpinQuery( true, result );
} else {
sendQuery();
}
}
void EzxModemPinManager::sendQuery()
{
if ( !d->querying ) {
d->querying = true;
if ( d->service->multiplexer()->channel( "primary" )->isValid() ) {
d->service->chat
( "AT+CPIN?", this, SLOT(cpinQuery(bool,QAtResult)) );
} else {
// The underlying serial device could not be opened,
// so we are not talking to a modem. Fake sim ready.
QAtResult result;
result.setResultCode( QAtResult::OK );
result.setContent( "+CPIN: READY" );
cpinQuery( true, result );
}
}
}
// Process the response to a AT+CPIN? command.
void EzxModemPinManager::cpinQuery( bool ok, const QAtResult& result )
{
if ( !ok ) {
// The AT+CPIN? request failed. The SIM may not be ready.
// Wait three seconds and resend.
if ( !d->simMissing )
QTimer::singleShot( 3000, this, SLOT(sendQueryAgain()) );
} else {
// No longer querying for the pin.
d->querying = false;
// Extract the required pin from the returned result.
QAtResultParser parser( result );
parser.next( "+CPIN:" );
QString pin = parser.line().trimmed().remove("\"");
if ( pin == "READY" || ( pin.isEmpty() && emptyPinIsReady() ) ) {
// No more PIN's are required, so the sim is ready.
d->expectedPin = QString();
d->service->post( "simready" );
// Notify the application level that the sim is ready.
emit pinStatus( "READY", QPinManager::Valid, QPinOptions() );
} else if ( pin == "SIM PIN" && !d->lastSimPin.isEmpty() ) {
// We have a cached version of the primary "SIM PIN"
// that we know is valid. Re-send it immediately.
// Some modems ask for the SIM PIN multiple times.
// 3GPP TS 27.007 requires this behaviour.
d->expectedPin = pin;
d->currentPin = d->lastSimPin;
d->service->chat( "AT+CPIN=1,\"" + d->lastSimPin +
"\"", this, SLOT(cpinResponse(bool,QAtResult)) );
} else {
// Ask that the pin be supplied by the user.
d->expectedPin = pin;
QPinManager::Status status;
if ( pin.contains( "PUK" ) )
status = QPinManager::NeedPuk;
else {
status = QPinManager::NeedPin;
d->service->post( "simpinrequired" );
}
QPinOptions options;
options.setMaxLength( pinMaximum() );
emit pinStatus( d->expectedPin, status, options );
}
}
}
|
a13f7157d1c7865c0f5e130a37407aaea953933b
|
485779519ff79e52e5da2a0953cdb6d4f44e5abb
|
/ex2/meshModel.cpp
|
b98237fd6ab1a413c62fb0a5e08486b61aaf5cd7
|
[] |
no_license
|
huajian1069/Geo3D-ex
|
6de1d2c53d03e01cb35d0a22e93da8b9fc3ab1e4
|
e1f6efc2c8c75f94810225b9ac0ab87f9063028d
|
refs/heads/master
| 2021-03-26T17:39:11.469625
| 2020-05-04T22:42:41
| 2020-05-04T22:42:41
| 247,727,266
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,816
|
cpp
|
meshModel.cpp
|
#include "meshModel.h"
#include <QString>
#include <QtCore/QDebug>
#include <QtCore/QString>
#include <QtWidgets/QCommandLinkButton>
#include <Qt3DRender/QObjectPicker>
#include <Qt3DExtras/QTorusMesh>
#include <Qt3DRender/QPickingSettings>
extern QCommandLinkButton *info;
SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity)
: m_rootEntity(rootEntity)
{
// set picking method
Qt3DRender::QPickingSettings *settings = new Qt3DRender::QPickingSettings();
settings->setPickMethod(Qt3DRender::QPickingSettings::PickMethod::TrianglePicking);
// Mesh shape data
Qt3DRender::QMesh *mesh = new Qt3DRender::QMesh();
mesh->setSource(QUrl("qrc:/mesh/TrackML-PixelDetector.obj"));
mesh->setProperty("Vertices", QVariant(37216));
mesh->setProperty("Edges", QVariant(58416));
mesh->setProperty("Faces", QVariant(29208));
// Mesh Transform
Qt3DCore::QTransform *meshTransform = new Qt3DCore::QTransform();
meshTransform->setScale(0.006f);
meshTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(0.0f, 1.0f, 0.0f), 0.0f));
meshTransform->setTranslation(QVector3D(-2.0f, -2.0f, 0.0f));
// Mesh material
Qt3DExtras::QPhongMaterial *meshMaterial = new Qt3DExtras::QPhongMaterial();
meshMaterial->setDiffuse(QColor(QRgb(0xbeb32b)));
// picker
Qt3DRender::QObjectPicker *picker = new Qt3DRender::QObjectPicker();
picker->setEnabled(true);
// Mesh Entity
m_meshEntity = new Qt3DCore::QEntity(m_rootEntity);
m_meshEntity->addComponent(mesh);
m_meshEntity->addComponent(meshMaterial);
m_meshEntity->addComponent(meshTransform);
m_meshEntity->addComponent(picker);
QObject::connect(picker, &Qt3DRender::QObjectPicker::clicked, this, &SceneModifier::onClicked);
// Torus Mesh shape data
Qt3DExtras::QTorusMesh *torusMesh = new Qt3DExtras::QTorusMesh();
torusMesh->setRadius(1.0f);
torusMesh->setMinorRadius(0.4f);
torusMesh->setRings(100);
torusMesh->setSlices(20);
// Torus Mesh Transform
Qt3DCore::QTransform *torusMeshTransform = new Qt3DCore::QTransform();
torusMeshTransform->setScale(3.0f);
torusMeshTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(0.0f, 1.0f, 0.0f), 30.0f));
torusMeshTransform->setTranslation(QVector3D(20.0f, 15.0f, -40.0f));
// Torus picker
Qt3DRender::QObjectPicker *torusPicker = new Qt3DRender::QObjectPicker();
torusPicker->setEnabled(true);
// Torus Mesh Entity
m_torusMeshEntity = new Qt3DCore::QEntity(m_rootEntity);
m_torusMeshEntity->addComponent(torusMesh);
m_torusMeshEntity->addComponent(meshMaterial);
m_torusMeshEntity->addComponent(torusMeshTransform);
m_torusMeshEntity->addComponent(torusPicker);
QObject::connect(torusPicker, &Qt3DRender::QObjectPicker::clicked, this, &SceneModifier::onClickedTorus);
}
SceneModifier::~SceneModifier()
{
}
void SceneModifier::onClicked(Qt3DRender::QPickEvent* event){
Qt3DRender::QMesh *mesh = (Qt3DRender::QMesh*)(m_meshEntity->componentsOfType<Qt3DRender::QMesh>()[0]);
info->setDescription(QString("Vertices: ") + mesh->property("Vertices").toString() +
QString("\nEdges: ") + mesh->property("Edges").toString() +
QString("\nFaces: ") + mesh->property("Faces").toString());
}
void SceneModifier::onClickedTorus(Qt3DRender::QPickEvent* event){
Qt3DExtras::QTorusMesh *mesh = (Qt3DExtras::QTorusMesh*)(m_torusMeshEntity->componentsOfType<Qt3DExtras::QTorusMesh>()[0]);
info->setDescription(QString("Radius: %1 \nRings: %2 \nSlices: %3")
.arg(mesh->radius()).arg(mesh->rings()).arg(mesh->slices()));
}
void SceneModifier::enableMesh(bool enabled)
{
m_meshEntity->setEnabled(enabled);
}
void SceneModifier::scaleMesh(int magnitude)
{
float magnitudeF = 0.001 + (float)(magnitude) * 0.01 / 100.0;
Qt3DCore::QTransform *transform = (Qt3DCore::QTransform*)(m_meshEntity->componentsOfType<Qt3DCore::QTransform>()[0]);
transform->setScale(magnitudeF);
}
void SceneModifier::rotateMeshX(int degree)
{
float degreeF = degree * 360.0 / 100.0;
Qt3DCore::QTransform *transform = (Qt3DCore::QTransform*)(m_meshEntity->componentsOfType<Qt3DCore::QTransform>()[0]);
transform->setRotationX(degreeF);
}
void SceneModifier::rotateMeshY(int degree)
{
float degreeF = degree * 360.0 / 100.0;
Qt3DCore::QTransform *transform = (Qt3DCore::QTransform*)(m_meshEntity->componentsOfType<Qt3DCore::QTransform>()[0]);
transform->setRotationY(degreeF);
}
void SceneModifier::rotateMeshZ(int degree)
{
float degreeF = degree * 360.0 / 100.0;
Qt3DCore::QTransform *transform = (Qt3DCore::QTransform*)(m_meshEntity->componentsOfType<Qt3DCore::QTransform>()[0]);
transform->setRotationZ(degreeF);
}
|
a9a79f3d496238bc4a246769e9a89fbd35f4b037
|
25a8e519ed58b22655ac0fc744dd5ff5e3060288
|
/code/threads/BoundedBuffer.cc
|
47ceb7459d85d56ed42bfe7899c54b2a73a44749
|
[
"MIT-Modern-Variant"
] |
permissive
|
a123wyn/Nachos
|
44632a37564018cf8f229eb6c45c1474c45590dc
|
f795e72acb7dae7b9f5f5c20baad252f8562ada3
|
refs/heads/master
| 2022-12-02T18:32:07.972659
| 2020-08-21T15:25:15
| 2020-08-21T15:25:15
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,722
|
cc
|
BoundedBuffer.cc
|
#include "synch.h"
#include "system.h"
#include "BoundedBuffer.h"
BoundedBuffer::BoundedBuffer(int size)
{
// 初始化
this->maxsize = size;
head = 0;
tail = 0;
n = 0;
buffer = new char[size]();
lock = new Lock("buffer's lock");
bufferempty = new Condition("buffer is empty");
bufferfull = new Condition("buffer is full");
}
BoundedBuffer::~BoundedBuffer()
{
delete[] buffer;
delete lock;
delete bufferempty;
delete bufferfull;
}
void BoundedBuffer::Read(void *data, int size) // 消费者
{
lock->Acquire(); // 获得锁
for (int i = 0; i < size; i++) // 循环读取size大小数据
{
while (n == 0) // 如果当前缓冲区为空,则在条件变量上阻塞
bufferempty->Wait(lock);
((char *)data)[i] = buffer[head]; // 从head处读取到data中
head = (head + 1) % maxsize; // head往后移,data过后也会往后移
n--; // 当前数据-1
bufferfull->Signal(lock); // 读取后唤醒一个生产者
printf("Thread %s Read - head: %d tail: %d n: %d\n", currentThread->getName(), head, tail, n);
}
lock->Release(); // 释放锁
}
void BoundedBuffer::Write(void *data, int size) // 生产者
{
lock->Acquire(); // 获得锁
for (int i = 0; i < size; i++) // 循环写入size大小数据
{
while (n == maxsize) // 如果当前缓冲区已经满了,则在相应条件变量上阻塞
bufferfull->Wait(lock);
buffer[tail] = ((char *)data)[i]; // 缓冲区末尾追加
tail = (tail + 1) % maxsize; // tail往后移,data过后也会往后移
n++; // 当前数据+1
bufferempty->Signal(lock); // 写入后唤醒消费者
printf("Thread %s Write - head: %d tail: %d n: %d\n", currentThread->getName(), head, tail, n);
}
lock->Release(); // 释放锁
}
|
c51e61ea599dd73576b88455f326d2f635f2afde
|
0e074ec3c2e39eca7d40c2fd6f4470ca2f5c9748
|
/ESP32-SensorBoard/lib/JSUtilities/scr/jsutilities.cpp
|
f879b53378758d5271be58f265e886f22447a460
|
[] |
no_license
|
MrFlexi/ESP32-SensorBoard
|
cf2ac00ea915211828776c9609a181a244004edb
|
d88df15d0c8fc90466b99511d73c1f450344826d
|
refs/heads/master
| 2023-02-25T02:11:56.968793
| 2023-02-07T07:37:12
| 2023-02-07T07:37:12
| 267,228,567
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 10,219
|
cpp
|
jsutilities.cpp
|
#include "jsutilities.h"
// Local logging tag
static const char TAG[] = __FILE__;
#define SSD1306_PRIMARY_ADDRESS (0x3D)
#define SSD1306_SECONDARY_ADDRESS (0x3C)
#define BME_PRIMARY_ADDRESS (0x77)
#define BME_SECONDARY_ADDRESS (0x76)
#define AXP192_PRIMARY_ADDRESS (0x34)
#define MCP_24AA02E64_PRIMARY_ADDRESS (0x50)
#define QUECTEL_GPS_PRIMARY_ADDRESS (0x10)
#define ADXL345 (0x53)
int i2c_scan(void) {
int i2c_ret, addr;
int devices = 0;
Serial.println( "Scanning I2C");
ESP_LOGI(TAG, "Starting I2C bus scan...");
for (addr = 8; addr <= 119; addr++) {
// scan i2c bus with no more to 100KHz
Wire.begin(SDA, SCL, 100000);
Wire.beginTransmission(addr);
Wire.write(addr);
i2c_ret = Wire.endTransmission();
if (i2c_ret == 0) {
devices++;
switch (addr) {
case INA3221_ADDRESS:
ESP_LOGI(TAG, "0x%X: INA 3221 Voltage+Current detector", addr);
break;
case SSD1306_PRIMARY_ADDRESS:
case SSD1306_SECONDARY_ADDRESS:
ESP_LOGI(TAG, "0x%X: SSD1306 Display controller", addr);
break;
case BME_PRIMARY_ADDRESS:
case BME_SECONDARY_ADDRESS:
ESP_LOGI(TAG, "0x%X: Bosch BME MEMS", addr);
break;
case AXP192_PRIMARY_ADDRESS:
ESP_LOGI(TAG, "0x%X: AXP192 power management", addr);
break;
case QUECTEL_GPS_PRIMARY_ADDRESS:
ESP_LOGI(TAG, "0x%X: Quectel GPS", addr);
break;
case MCP_24AA02E64_PRIMARY_ADDRESS:
ESP_LOGI(TAG, "0x%X: 24AA02E64 serial EEPROM", addr);
break;
case ADXL345:
ESP_LOGI(TAG, "0x%X: ADXL345 3 Axis Accel", addr);
break;
default:
ESP_LOGI(TAG, "0x%X: Unknown device", addr);
break;
}
} // switch
} // for loop
ESP_LOGI(TAG, "I2C scan done, %u devices found.", devices);
return devices;
}
/**************************************************************************/
/*!
@brief Sends a single command byte over I2C
*/
/**************************************************************************/
void SDL_Arduino_INA3221::wireWriteRegister (uint8_t reg, uint16_t value)
{
Wire.beginTransmission(INA3221_i2caddr);
#if ARDUINO >= 100
Wire.write(reg); // Register
Wire.write((value >> 8) & 0xFF); // Upper 8-bits
Wire.write(value & 0xFF); // Lower 8-bits
#else
Wire.send(reg); // Register
Wire.send(value >> 8); // Upper 8-bits
Wire.send(value & 0xFF); // Lower 8-bits
#endif
Wire.endTransmission();
}
/**************************************************************************/
/*!
@brief Reads a 16 bit values over I2C
*/
/**************************************************************************/
void SDL_Arduino_INA3221::wireReadRegister(uint8_t reg, uint16_t *value)
{
Wire.beginTransmission(INA3221_i2caddr);
#if ARDUINO >= 100
Wire.write(reg); // Register
#else
Wire.send(reg); // Register
#endif
Wire.endTransmission();
delay(1); // Max 12-bit conversion time is 586us per sample
Wire.requestFrom(INA3221_i2caddr, (uint8_t)2);
#if ARDUINO >= 100
// Shift values to create properly formed integer
*value = ((Wire.read() << 8) | Wire.read());
#else
// Shift values to create properly formed integer
*value = ((Wire.receive() << 8) | Wire.receive());
#endif
}
//
void SDL_Arduino_INA3221::INA3221SetConfig(void)
{
// Set Config register to take into account the settings above
uint16_t config = INA3221_CONFIG_ENABLE_CHAN1 |
INA3221_CONFIG_ENABLE_CHAN2 |
INA3221_CONFIG_ENABLE_CHAN3 |
INA3221_CONFIG_AVG1 |
INA3221_CONFIG_VBUS_CT2 |
INA3221_CONFIG_VSH_CT2 |
INA3221_CONFIG_MODE_2 |
INA3221_CONFIG_MODE_1 |
INA3221_CONFIG_MODE_0;
wireWriteRegister(INA3221_REG_CONFIG, config);
}
/**************************************************************************/
/*!
@brief Instantiates a new SDL_Arduino_INA3221 class
*/
/**************************************************************************/
SDL_Arduino_INA3221::SDL_Arduino_INA3221(uint8_t addr, float shuntresistor) {
INA3221_i2caddr = addr;
INA3221_shuntresistor = shuntresistor;
}
/**************************************************************************/
/*!
@brief Setups the HW (defaults to 32V and 2A for calibration values)
*/
/**************************************************************************/
void SDL_Arduino_INA3221::begin() {
Wire.begin();
// Set chip to known config values to start
INA3221SetConfig();
// Serial.print("shut resistor="); Serial.println(INA3221_shuntresistor);
// Serial.print("address="); Serial.println(INA3221_i2caddr);
}
/**************************************************************************/
/*!
@brief Gets the raw bus voltage (16-bit signed integer, so +-32767)
*/
/**************************************************************************/
int16_t SDL_Arduino_INA3221::getBusVoltage_raw(int channel) {
uint16_t value;
wireReadRegister(INA3221_REG_BUSVOLTAGE_1+(channel -1) *2, &value);
// Serial.print("BusVoltage_raw=");
// Serial.println(value,HEX);
// Shift to the right 3 to drop CNVR and OVF and multiply by LSB
return (int16_t)(value );
}
/**************************************************************************/
/*!
@brief Gets the raw shunt voltage (16-bit signed integer, so +-32767)
*/
/**************************************************************************/
int16_t SDL_Arduino_INA3221::getShuntVoltage_raw(int channel) {
uint16_t value;
wireReadRegister(INA3221_REG_SHUNTVOLTAGE_1+(channel -1) *2, &value);
// Serial.print("ShuntVoltage_raw=");
// Serial.println(value,HEX);
return (int16_t)value;
}
/**************************************************************************/
/*!
@brief Gets the shunt voltage in mV (so +-168.3mV)
*/
/**************************************************************************/
float SDL_Arduino_INA3221::getShuntVoltage_mV(int channel) {
int16_t value;
value = getShuntVoltage_raw(channel);
return value * 0.005;
}
/**************************************************************************/
/*!
@brief Gets the shunt voltage in volts
*/
/**************************************************************************/
float SDL_Arduino_INA3221::getBusVoltage_V(int channel) {
int16_t value = getBusVoltage_raw(channel);
return value * 0.001;
}
/**************************************************************************/
/*!
@brief Gets the current value in mA, taking into account the
config settings and current LSB
*/
/**************************************************************************/
float SDL_Arduino_INA3221::getCurrent_mA(int channel) {
float valueDec = getShuntVoltage_mV(channel)/INA3221_shuntresistor;
return valueDec;
}
/**************************************************************************/
/*!
@brief Gets the Manufacturers ID
*/
/**************************************************************************/
int SDL_Arduino_INA3221::getManufID()
{
uint16_t value;
wireReadRegister(0xFE, &value);
return value;
}
void display_chip_info()
{
// print chip information on startup if in verbose mode after coldstart
esp_chip_info_t chip_info;
esp_chip_info(&chip_info);
ESP_LOGI(TAG,
"This is ESP32 chip with %d CPU cores, WiFi%s%s, silicon revision "
"%d, %dMB %s Flash",
chip_info.cores,
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "",
chip_info.revision, spi_flash_get_chip_size() / (1024 * 1024),
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded"
: "external");
ESP_LOGI(TAG, "Internal Total heap %d, internal Free Heap %d",
ESP.getHeapSize(), ESP.getFreeHeap());
#if (BOARD_HAS_PSRAM)
ESP_LOGI(TAG, "SPIRam Total heap %d, SPIRam Free Heap %d",
ESP.getPsramSize(), ESP.getFreePsram());
#endif
ESP_LOGI(TAG, "ChipRevision %d, Cpu Freq %d, SDK Version %s",
ESP.getChipRevision(), ESP.getCpuFreqMHz(), ESP.getSdkVersion());
ESP_LOGI(TAG, "Flash Size %d, Flash Speed %d", ESP.getFlashChipSize(),
ESP.getFlashChipSpeed());
}
void print_wakeup_reason()
{
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
Serial.print(F("WakeUp caused by: "));
switch (wakeup_reason)
{
case ESP_SLEEP_WAKEUP_EXT0:
Serial.println(F("external signal using RTC_IO"));
break;
case ESP_SLEEP_WAKEUP_EXT1:
Serial.println(F("external signal using RTC_CNTL"));
break;
case ESP_SLEEP_WAKEUP_TIMER:
Serial.println("by timer");
break;
case ESP_SLEEP_WAKEUP_TOUCHPAD:
Serial.println(F("touchpad"));
break;
case ESP_SLEEP_WAKEUP_ULP:
Serial.println(F("ULP program"));
break;
default:
Serial.printf("Wakeup was not caused by deep sleep: %d\n", wakeup_reason);
break;
}
}
void print_wakeup_touchpad()
{
touch_pad_t pin;
switch (esp_sleep_get_touchpad_wakeup_status())
{
case 0:
Serial.println("Touch detected on GPIO 4");
break;
case 1:
Serial.println("Touch detected on GPIO 0");
break;
case 2:
Serial.println("Touch detected on GPIO 2");
break;
case 3:
Serial.println("Touch detected on GPIO 15");
break;
case 4:
Serial.println("Touch detected on GPIO 13");
break;
case 5:
Serial.println("Touch detected on GPIO 12");
break;
case 6:
Serial.println("Touch detected on GPIO 14");
break;
case 7:
Serial.println("Touch detected on GPIO 27");
break;
case 8:
Serial.println("Touch detected on GPIO 33");
break;
case 9:
Serial.println("Touch detected on GPIO 32");
break;
default:
Serial.println("Wakeup not by touchpad");
break;
}
}
|
e9cc66e13667b5c7e994de03c8e6528b858134ec
|
6edba1daadb561a52e023042a1efa63d278e5061
|
/common/febird/febird-0.21/include/febird/util/throw.hpp
|
edcb9b91c80887bc649724f9c7f5bd298611aacb
|
[] |
no_license
|
career-tankles/scrawl
|
86ccaf62683ae651a0e7c21408593852c35fa1ce
|
680b2d71e844d19f9537629d4be9bc655eb321f1
|
refs/heads/master
| 2021-01-18T18:55:28.360442
| 2014-05-15T02:44:58
| 2014-05-15T02:44:58
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 568
|
hpp
|
throw.hpp
|
#ifndef __febird_util_throw_hpp__
#define __febird_util_throw_hpp__
#include "autofree.hpp"
#include <boost/current_function.hpp>
#define FEBIRD_THROW(Except, fmt, ...) \
do { \
febird::AutoFree<char> msg; \
int len = asprintf(&msg.p, "%s:%d: %s: " fmt, \
__FILE__, __LINE__, BOOST_CURRENT_FUNCTION, \
##__VA_ARGS__); \
fprintf(stderr, "%s\n", msg.p); \
std::string strMsg(msg.p, len); \
throw Except(strMsg); \
} while (0)
#define THROW_STD(Except, fmt, ...) \
FEBIRD_THROW(std::Except, fmt, ##__VA_ARGS__)
#endif // __febird_util_throw_hpp__
|
b704eff7594ba43a06105227c72b654698b84e5e
|
d2bb671cef1678f8e6370da97f5e9ae161ef1c86
|
/suil/file.h
|
4fa698e89d166a87b94373ecf5e83ce53c900400
|
[
"LicenseRef-scancode-other-permissive",
"MIT"
] |
permissive
|
suilteam/suil
|
f964539566d5dd5138e828e2631f2c08511c14dd
|
5cc143891147cb9bec1448d3f319cead9b4ccad9
|
refs/heads/master
| 2021-09-28T10:48:00.736081
| 2021-09-17T19:28:37
| 2021-09-17T19:28:37
| 283,538,168
| 0
| 0
|
MIT
| 2021-09-17T19:28:38
| 2020-07-29T15:39:37
|
C++
|
UTF-8
|
C++
| false
| false
| 9,746
|
h
|
file.h
|
//
// Created by dc on 12/11/18.
//
#ifndef SUIL_FILE_H
#define SUIL_FILE_H
#include <fcntl.h>
#include <libmill/libmill.h>
#include <suil/zstring.h>
#include <suil/buffer.h>
#include <suil/logging.h>
namespace suil {
/**
* File provides asynchronous operations for writing
* and reading from files. It's an abstraction on top of libmill's
* file API's
*/
struct File {
/**
* Creates a new file taking a lib mill file object
* @param mf a lib mill file object
*/
File(mfile mf);
/**
* creates a new file which operates on the given file path
* see syscall open
*
* @param path the path of the file to work with
* @param flags file open flags
* @param mode file open mode
*/
File(const char *path, int flags, mode_t mode);
/**
* creates a new file which operates on the given file descriptor
* @param fd the file descriptor to work with
* @param own if true, the created \class File object will take
* ownership of the given descriptor and takes care of cleaning it
* up
*/
explicit File(int fd, bool own = false);
File(File&) = delete;
File&operator=(File&) = delete;
/**
* move constructor
* @param f
*/
File(File&& f)
: fd(f.fd)
{
f.fd = nullptr;
}
/**
* move assignment
* @param f
* @return
*/
File& operator=(File&& f) {
fd = f.fd;
f.fd = nullptr;
return Ego;
}
/**
* writes the given data to the file
*
* @param data pointer to the data to write
* @param size the size to write to file from data buffer
* @param dd the deadline time for the write
* @return number of bytes written to file
*/
virtual size_t write(const void*data, size_t size, int64_t dd = -1);
/**
* read data from file
* @param data the buffer to hold the read data.
* @param size the size of the given output buffer \param data. after reading,
* this reference variable will have the number of bytes read into buffer
* @param dd the deadline time for the read
* @return true for a successful read, false otherwise
*/
virtual bool read(void *data, size_t& size, int64_t dd = -1);
/**
* file seek to given offset
* @param off the offset to seek to
* @return the new position in file
*/
virtual off_t seek(off_t off);
/**
* get the offset on the file
* @return the current offset on the file
*/
virtual off_t tell();
/**
* check if the offset is at the end of file
* @return true if offset at end of file
*/
virtual bool eof();
/**
* flush the data to disk
* @param dd timestamp to wait for until flush is completed
*/
virtual void flush(int64_t dd = -1);
/**
* closes the file descriptor if it's being owned and it's valid
*/
virtual void close();
/**
* checks if the given file descriptor is valid
* @return true if the descriptor is valid, false otherwise
*/
virtual bool valid() {
return fd != nullptr;
}
/**
* get the file descriptor associated with the given file
* @return
*/
virtual int raw() {
return mfget(fd);
}
/**
* eq equality operator, check if two \class File objects
* point to the same file descriptor
* @param other
* @return
*/
bool operator==(const File& other) {
return (this == &other) ||
( fd == other.fd);
}
/**
* neq equality operator, check if two \class File objects
* point to different file descriptor
* @param other
* @return
*/
bool operator!=(const File& other) {
return !(*this == other);
}
/**
* stream operator - write a stringview into the file
* @param sv the string view to write
* @return
*/
File& operator<<(strview& sv);
/**
* stream operator - write a \class String into the file
* @param str the \class String to write
* @return
*/
File& operator<<(const String& str);
/**
* stream operator - write a \class OBuffer into the file
* @param b the buffer to write to file
* @return
*/
File& operator<<(const OBuffer& b);
/**
* stream operator - write c-style string into file
* @param str the string to write
* @return
*/
File& operator<<(const char* str);
/**
* stream operator - write c-style string into file
* @param str the string to write
* @return
*/
inline File& operator<<(const std::string& str) {
String tmp(str);
return (Ego << tmp);
}
virtual ~File();
protected:
mfile fd;
};
namespace utils::fs {
inline String realpath(const char *path) {
char base[PATH_MAX];
if (::realpath(path, base) == nullptr) {
if (errno != EACCES && errno != ENOENT)
return String();
}
return std::move(String{base}.dup());
}
inline size_t size(const char *path) {
struct stat st;
if (stat(path, &st) == 0) {
return (size_t) st.st_size;
}
throw Exception::create("file '", path, "' does not exist");
}
inline void touch(const char *path, mode_t mode=0777) {
if (::open(path, O_CREAT|O_TRUNC|O_WRONLY, mode) < 0) {
throw Exception::create("touching file '", path, "' failed: ", errno_s);
}
}
inline bool exists(const char *path) {
return access(path, F_OK) != -1;
}
inline bool isdir(const char *path) {
struct stat st{};
return (stat(path, &st) == 0) && (S_ISDIR(st.st_mode));
}
String currdir();
bool isdirempty(const char *dir);
String getname(const char *path);
void mkdir(const char *path, bool recursive = false, mode_t mode = 0777);
void mkdir(const char *base, const std::vector<const char*> paths, bool recursive = false, mode_t mode = 0777);
inline void mkdir(const std::vector<const char*> paths, bool recursive = false, mode_t mode = 0777) {
char base[PATH_MAX];
getcwd(base, PATH_MAX);
mkdir(base, std::move(paths), recursive, mode);
}
void remove(const char *path, bool recursive = false, bool contents = false);
void remove(const char *base, const std::vector<const char*> paths, bool recursive = false);
inline void remove(const std::vector<const char*>&& paths, bool recursive = false) {
char base[PATH_MAX];
getcwd(base, PATH_MAX);
remove(base, std::move(paths), recursive);
}
void forall(const char *path, std::function<bool(const String&, bool)> h, bool recursive = false, bool pod = false);
std::vector<String> ls(const char *path, bool recursive = false);
void readall(OBuffer& out, const char *path, bool async = false);
String readall(const char* path, bool async = false);
void append(const char *path, const void *data, size_t sz, bool async = true);
inline void append(const char *path, const OBuffer& b, bool async = true) {
append(path, b.data(), b.size(), async);
}
inline void append(const char *path, const std::string& s, bool async = true) {
append(path, s.data(), s.size(), async);
}
inline void append(const char *path, const strview& s, bool async = true) {
append(path, s.data(), s.size(), async);
}
inline void append(const char *path, const String& s, bool async = true) {
append(path, s.data(), s.size(), async);
}
inline void append(const char *path, const char* s, bool async = true) {
append(path, String{s}, async);
}
inline void clear(const char *path) {
if ((::truncate(path, 0) < 0) && errno != EEXIST) {
throw Exception::create("clearing file '", path, "' failed: ", errno_s);
}
}
template <typename __T, std::enable_if_t<!std::is_pointer_v<__T>, __T>* = nullptr>
inline void append(const char* path, __T d, bool async = true) {
OBuffer b(15);
b << d;
append(path, b, async);
}
bool read(const char *path, void *data, size_t sz, bool async = true);
}
struct FileLogger {
FileLogger(const std::string dir, const std::string prefix);
FileLogger()
: dst(nullptr)
{}
virtual void log(const char *, size_t, log::Level);
inline void close() {
dst.close();
}
void open(const std::string& str, const std::string& prefix);
inline ~FileLogger() {
close();
}
private:
File dst;
};
}
#endif //SUIL_FILE_H
|
8b64843cbfeebb6216bf86e55fc122aa04ba87fe
|
ea6c500b2f82f889d10ae4c2a9f54359f210c4b3
|
/src/string/missingCharsforPangram.cpp
|
00df48f2cf81b8f5f977f21b7262ed047b8abfca
|
[] |
no_license
|
ranjithtamil/cplusplus
|
8de4a28c6f49a6991548fb676c28ef1fec828ebe
|
69ad0f4cf42ccc47f4346ec9095d08e884a95863
|
refs/heads/master
| 2021-06-20T07:29:29.427222
| 2021-01-29T03:32:40
| 2021-01-29T03:32:40
| 174,779,654
| 0
| 2
| null | 2021-01-04T23:24:32
| 2019-03-10T04:57:34
|
C++
|
UTF-8
|
C++
| false
| false
| 1,225
|
cpp
|
missingCharsforPangram.cpp
|
#include <bits/stdc++.h>
#include <vector>
using namespace std;
void missingCharsForPangram(char a[],vector<char> &b)
{
map<int,int> chrmap;
chrmap.clear(); //Very important too.
b.clear(); //Very Important to clear Vector. Else you get inconsistent output.
for(int i=0;a[i]!='\0';i++)
{
//Map's Key is index w.r.t. Capital A (Between 0 to 25)
if(a[i]>='A' && a[i]<='Z')
{
chrmap[a[i]-'A']=1;
}
//Map's Key is index w.r.t. Capital a (Between 0 to 25)
if(a[i]>='a' && a[i]<='z')
{
chrmap[a[i]-'a']=1;
}
}
for(int c=0;c<=25;c++)
{
if(chrmap.count(c)==0)
{
b.push_back(c+'a');
}
}
// for(int i=0;i<b.size();i++)
// cout<<b[i];
}
// Driver function
int main()
{
char s1[100] = "The quick brown fox jumps over the lazy dog";
char s2[100] = "The quick brown fox jumps over the dog";
vector<char>missing(26);
missingCharsForPangram(s2,missing);
for(int i=0;i<missing.size();i++)
cout<<missing[i];
return 0;
}
|
6c6281dea324d78292faea405d034978c0d80586
|
ce7e834bb8f610828324f9eaa782f2b51bd9d3cf
|
/Classes/Role.h
|
c1d1ba680ee7a40da8572a039655e09a010afcbe
|
[] |
no_license
|
fungamescn/ProjectX
|
a5b6cc4c07c8327f3892176513ebdbc228fcbbe0
|
7e9288de9e146dd9f9d5c66912a3fe9636b2e05a
|
refs/heads/master
| 2021-01-01T04:56:43.191666
| 2016-04-24T13:49:31
| 2016-04-24T13:49:31
| 56,973,903
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,166
|
h
|
Role.h
|
#ifndef __ROLE_H__
#define __ROLE_H__
#include <list>
#include "cocos2d.h"
#include "Base.h"
#include "RoleAI.h"
#include "Attribute.h"
#include "HpBarBase.h"
#include "Config.h"
#include "cocostudio/CocoStudio.h"
using namespace cocostudio;
enum ROLE_STATE
{
ROLE_STATE_STAND,
ROLE_STATE_MOVE,
ROLE_STATE_ATTAK,
ROLE_STATE_CONJURE,
ROLE_STATE_MOVE_ATTACK,
ROLE_STATE_MOVE_CONJURE,
ROLE_STATE_HURT,
ROLE_STATE_DEAD,
};
enum ACTION_TAG
{
ACTION_TAG_SHIELD = 1,
ACTION_TAG_FIRE,
ACTION_TAG_HURT
};
//人物,怪物基类
class Role : public Base, public RoleAI
{
public:
bool isLeader = false;
static Role* create(const int &roleId, const int &groupType);
Role(const int &roleId);
~Role();
virtual bool init();
void createSpriteChilds();
void initSpriteChilds();
virtual void refreshProp(int roleId);
void setDirection(const int &direction, bool update = false);
void stand();
void move();
void attack();
void conjure();
void moveAttack(bool retreat = false);
void moveConjure(bool retreat = false);
void beAttacked();
virtual void hurt() override;
virtual void dead() override;
void deadEndCall();
int getRoleId() const;
std::list<cocos2d::Point> findPath(cocos2d::Point destination);
virtual void doFindPath(cocos2d::Point destination);//执行AI寻路
virtual void doAIAction(float del) override;//执行AI逻辑
virtual int getBaseType() override{ return BASE_TYPE_MONSTER; };
virtual void update(float delta) override;
void setRolePosition(cocos2d::Point position);
cocos2d::Vec2 getShootPoint();
Attribute* getAttribute(){ return _attribute; };
virtual OBB2d* getOBB2d() override;
virtual cocos2d::Rect getTouchRect() override;
void clearFindPathList();
virtual int getTemplateId() override;
float getSpeed();
virtual int getMaterialType() override;
virtual float getCurrentHp() override;
virtual void setCurrentHp(const float &hp) override;
virtual float getFinalHp() override;
virtual void setFinalHp(const float &hp) override;
virtual float getAttack() override;
virtual void setAttack(const float &attack) override;
virtual float getDefense() override;
virtual float getShield() override;
virtual void setShield(const float &shp) override;
virtual bool isQuest() override;
virtual bool isWarn() override;
virtual cocos2d::Vec2 getShadowPoint() { return this->getPosition(); };
virtual void hideHpBar(){ hpBar->setVisible(false); };
virtual void createRole(const int &roleId, const int &groupType, cocos2d::Point &point, bool isTiledPos = true);
virtual void releaseSkill() override;
virtual void retainSkill() override;
virtual void releaseBullet() override;
virtual void retainBullet() override;
virtual void releaseAttack() override;
virtual void retainAttack() override;
virtual bool canRecovey() override;
virtual void setGroupType(const int &grouptype) override;
virtual std::string& getMiniSpriteNum() override;
private:
int _roleId;//角色 id
//0:待机, 1:移动, 2:原地攻击, 3:原地施法, 4:移动攻击, 5:移动施法, 6:受击, 7:死亡
int _roleState = 0;//角色状态
int _direction = 0;//上半身方向
float _shootDelta = 0;//子弹时间统计
bool _isRetreat = false;//是否后退
bool _directChanged;//是否改变了方向(用于重复调动作判断)
bool _useSkill = false;
int _skillNum = 0;
int _bulletNum = 0;
int _aiActionCount = 0;
Base * _oldRole = NULL; //锁定目标
cocos2d::Sprite* _shadowPart = nullptr;//阴影
cocos2d::Sprite* _lowerPart = nullptr;//下半身
cocos2d::Sprite* _upperPart = nullptr;//上半身
cocos2d::Sprite* _specialPart = nullptr;//特殊部分(死亡动作等...)
cocos2d::Sprite* _firePart = nullptr;//开火特效
cocos2d::Sprite* _shieldPart = nullptr;//护盾
cocos2d::Sprite* _tipPart = nullptr;
std::vector<cocos2d::Sprite*> _segmentSprites;
Armature *armature = NULL;
cocos2d::Vec2 _destVec;
cocos2d::Vec2 _attackVec;
Attribute* _attribute;
cocos2d::Point _oldNodePoint;
#if DEBUG_MODE
cocos2d::DrawNode* _drawNode;
#endif
void changeState(const int &state);
void playSegment(const unsigned int &segmentId, const int &repeat = 0, bool reverse = false, cocos2d::CallFunc* endCall = nullptr);
void stopSegment(const int &segmentId);
cocos2d::Vec2 getNextdestVec();
void moveUpdate();
void attackUpdate(float delta);
void moveAttackUpdate(float delta);
void conjureUpdate();
void moveConjureUpdate();
void updateFireEffect();
void updateShield();
void attackHurt(Base* enemey, float delta);
protected:
const int ROLE_SEGMENTS = 3; //0:"upper", 1 : "lower", 2 : "special", 3 : "shadow"
//0:待机, 1:移动, 2:受击, 3:死亡, 4攻击, 5:魔法
static const std::vector<std::vector<int>> ACTION_DICT;//动作表
static const std::vector<std::vector<int>> STATE_DICT;//状态表
static int roleTag;
std::string roleType = "monster";//类型前缀
int totalDirs = 8;//总方向(一半有资源)
int kind;//类型:生物、机械、建筑
int movefps;
int actionUpdateCount = 0;//action update次数
std::list<cocos2d::Point> findPathList; //寻路坐标集合
HpBarBase* hpBar = nullptr;//血条
virtual int calRoleState(); //计算本次RoleState的状态
//设置和获取roleState
int& getRoleState(){ return _roleState; };
void setRoleState(const int &roleState){ _roleState = roleState; };
Base * getOldRole();
void setOldRole(Base * Role);
cocos2d::Point getNearNode(Base * role);
virtual void setAIAttTarget() override;//设定AI锁定目标
virtual void createAI(int aiid) override;
virtual Base * getTargetAI() override;
virtual Base * getFollowAI() override;
virtual Base * getSkillTargetAI() override;
virtual int getToPositiontDir(const cocos2d::Vec2& dest, bool isAttack = false);
virtual void initHpBar();
Base * getRecentEnemyByGroupType(const int groupType, float skillDistance, bool useIds);
Base * getFollowEnemyByGroupType(const int groupType, bool useIds);
void deadEvent();
void changeSkillState();
void hurtEffect();
};
#endif
|
f97f11c9e1b5366d90dd856b438dbc88db4c9530
|
7d8e61d16c33f38504552aef72468a7ab5258fb0
|
/A1 - Counting Inversions/Source.cpp
|
886a3a71ff5ca359ba632fd68a906290c000573f
|
[] |
no_license
|
kaczorrrro/Stanford-Algorithms-1
|
08ece35ed461a01496acd7a68ca16698e9293f23
|
8b2ed79400948750bef2faa2990ed2f0c21963c3
|
refs/heads/master
| 2021-01-21T10:20:01.943909
| 2017-02-28T09:13:44
| 2017-02-28T09:13:44
| 83,412,334
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,830
|
cpp
|
Source.cpp
|
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<ctime>
using namespace std;
vector<int> countInversions(vector<int> v, long long &invSum) {
if (v.size() == 1)
return v;
int totalElements = v.size();
int middle = totalElements / 2;
vector<int> left = countInversions(vector<int>(v.begin(), v.begin() + middle), invSum);
vector<int> right = countInversions(vector<int>(v.begin() + middle, v.end()), invSum);
int lElemLeft = left.size();
int rElemLeft = right.size();
for (int i = 0, lPos = 0, rPos = 0; i < totalElements; i++) {
//no elems left in one array
if (rElemLeft == 0) {
v[i] = left[lPos++];
}
else if (lElemLeft == 0) {
v[i] = right[rPos++];
}
//some elements in both
else if (left[lPos] < right[rPos]) {
v[i] = left[lPos++];
lElemLeft--;
}
else {
v[i] = right[rPos++];
rElemLeft--;
invSum += (long long)lElemLeft;
}
}
return v;
}
int main(int argc, char* argv[]) {
if (argc != 2) {
cout << "Usage: Counting Inversions Filename" << endl;
return 1;
}
srand(time(NULL));
vector<int> input;
ifstream file;
file.open(argv[1]);
int temp;
while (file >> temp) {
input.push_back(temp);
}
cout << input.size() << endl;
//for (int i : input)
// cout << i << endl;
//for (int i = 0; i < 10000; i++)
// input.push_back(10000-i);
//int sumTemp = 0;
//int size = input.size();
//for (int i = 0; i < size; i++) {
// if (i % 1000 == 0)
// cout << i << endl;
// for (int j = i+1; j < size; j++) {
// if (input[i] > input[j])
// sumTemp++;
// }
//}
//cout << sumTemp << endl;
long long sum = 0;
cout << "start" << endl;
vector<int> output = countInversions(input,sum);
//for (int i = 1; i < 10000; i++)
// if (output[i] < output[i - 1])
// cout << "zjebae" << endl;
cout << sum << endl;
}
|
d9f4a5c27ed7f2d3a4e00fad39859235dc6ff237
|
c5a0d8d899238fcfcbde91e6bd05872441ce93d6
|
/LRUCache/LRUCache/LRUCache.cpp
|
e9430e3c056265339248315562816a3a926b10f6
|
[] |
no_license
|
jatbains/Code-Samples
|
239a7f83086030d30daddefe98fa0cd33c93f1bb
|
92b6819b5a40608fe5ecf037198efd74d5404cb6
|
refs/heads/master
| 2023-05-14T15:31:48.814836
| 2021-06-06T01:28:36
| 2021-06-06T01:28:36
| 212,496,929
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,644
|
cpp
|
LRUCache.cpp
|
// LRUCache.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <vector>
#include <list>
#include <unordered_map>
using namespace std;
typedef pair<int, int> val;
class LRUCache {
private:
int csize;
list<val> cache;
unordered_map<int, list<val>::iterator> look;
public:
LRUCache(int capacity);
int get(int key);
void put(int key, int value);
};
LRUCache::LRUCache(int capacity) : csize(capacity) {}
int LRUCache::get(int key) {
// Check if key < capacity
// if found i.e. value is not -1 move it to front of array
// else return -1
if (look.find(key) == look.end()) {
// not in list
return -1;
}
// else erase old entry get value
int nVal = look[key]->second;
// Erase value and push to front
// val node = cache.back();
cache.erase(look[key]);
val insert = make_pair(key, nVal);
cache.push_front(insert);
look[key] = cache.begin();
// Not found
return nVal;
}
void LRUCache::put(int key, int value) {
// Check if we exceed size
// If exceeded then delete last and add to front
// else
// Check if in cache Update if in cache move to front
//
val newVal = make_pair(key, value);
// Check if already there
if (look.find(key) == look.end()) { // Not in list
// See if full
if (cache.size() == csize) {
// delete least recently used element
val last = cache.back();
// Pops the last elmeent
cache.pop_back();
// Erase the last
look.erase(last.first);
}
}
else {
cache.erase(look[key]);
}
cache.push_front(newVal);
look[key] = cache.begin();
}
int main()
{
LRUCache myCache(10);
myCache.put(2, 25);
myCache.put(5, 12);
myCache.put(0, 19);
myCache.put(4, 100);
cout << myCache.get(0) << endl;
cout << myCache.get(9) << endl;
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
|
38705e9ae14d35b274cb590c0a91f79dc7df4493
|
cbf21a42a47eca7b4ed61c17be218e99d5338558
|
/ss.cpp
|
0f7dd7eee39e136e3c3211a87c4918cfe89fa2ea
|
[] |
no_license
|
exgsan/syntax-check
|
04773d339cc8ad5d48482e80d4f582cc580bd4ec
|
84eb916e830fb425865e5571cfab980f805e0efa
|
refs/heads/master
| 2016-09-10T20:11:43.762963
| 2015-06-19T05:09:55
| 2015-06-19T05:09:55
| 37,701,417
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,171
|
cpp
|
ss.cpp
|
#include "StdAfx.h"
int symbol[][4]=
{
1, 1, 1, 0,
1, 0, 0, 1,
0, 1, 1, 0,
1, 0, 0, 1
};
int symbol_type( char s)
{
if( s>='0' && s<='9')
return 0;
else if ( s=='+' || s=='-' || s=='*' || s=='/')
return 1;
else if ( s=='(')
return 2;
else if ( s==')')
return 3;
else
return 4;
}
void process(char *expr)
{
int LB = 0;
char *head = expr;
int lastType = symbol_type(*head++);
if(lastType == 2)
LB++;
while (*head != '\0')
{
int t = symbol_type(*head);
if (t == 2)
LB++;
else if (t == 3)
{
if(--LB<0)
{
printf("unmatched bracket,pos: %d\n",head-expr);
return;
}
}
else if(t == 4)
{
printf("illeagal chracter: %c\n",*head);
return;
}
if(symbol[t][lastType])
{
lastType = t;
head++;
}
else
{
printf("illeagal sequence: %c%c\n",*(head-1),*head);
return;
}
}
if(LB)
{
printf("unmatched bracket,pos: %d\n",head-expr);
return;
}
if(lastType == 1)
{
printf("illeagal sequence: %c%c\n",*(head-2),*(head-1));
return;
}
printf("correct!\n");
return;
}
int main(void)
{
char *s="(1-5/5564+455-*(4+1))";
process(s);
char *c = new char[100];
scanf(c);
return 0;
}
|
dbf11a2f5487199cf34b5840cd3c5bbd833702a3
|
ceb020fee45a01645f0b2adc118483c6cf296226
|
/RemoveDuplicatesFromSortedList2.cpp
|
0748987a8c370281f19e1eb73f9e60fae7439fa3
|
[] |
no_license
|
anaypaul/LeetCode
|
6423c4ca1b0d147206c06ebb86c9e558a85077f2
|
667825d32df2499301184d486e3a674291c0ca0b
|
refs/heads/master
| 2021-09-28T06:05:21.256702
| 2020-10-12T04:01:46
| 2020-10-12T04:01:46
| 153,226,092
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,377
|
cpp
|
RemoveDuplicatesFromSortedList2.cpp
|
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
if(head == NULL || head->next == NULL){
return head;
}
ListNode * dummy = new ListNode(INT_MIN);
dummy->next = head;
ListNode * res = NULL;
ListNode * prev = NULL;
ListNode * curr = dummy;
ListNode * temp = NULL;
ListNode * t_prev = NULL;
while(curr&&curr->next){
t_prev = curr;
temp = curr->next;
while(temp!= NULL && temp->val == curr->val){
t_prev = temp;
temp = temp->next;
}
if(curr->next == temp && !res){
prev = curr;
curr = temp;
res = prev;
}
else if(curr->next != NULL &&curr->next == temp ){
prev = curr;
curr = temp;
}else{
if(!res){
res = temp;
curr = temp;
}else{
prev->next = temp;
t_prev->next = NULL;
curr = temp;
}
}
}
return dummy->next;
}
};
|
f3c318464e6dfa127b07e1199a4a8d54094eeadf
|
c1737c2e3d1d91b0ac29a7885e536c09ed75f43c
|
/src/image.cpp
|
074d01541699c190088115c7866e869574fc068b
|
[] |
no_license
|
SethKasmann/sdlx
|
8e0fe786ee398107fe9db17dc0e0a85d890fdb6f
|
704c4db59214de1493caf8f14cd42953b88def6c
|
refs/heads/master
| 2021-01-20T21:19:35.568742
| 2017-08-29T18:46:17
| 2017-08-29T18:46:17
| 101,763,947
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,654
|
cpp
|
image.cpp
|
/*
* SDLX, a SDL graphics library for CS students.
* Copyright (C) 2017, Yihsiang Liow, Seth Kasmann
*
* 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 3 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 "image.h"
#include "window.h"
#include "sdllib.h"
namespace sdlx {
/*****************************************************************************
Class Font
*****************************************************************************/
Font::Font(const std::string& fontfamily, size_t size)
: _font(NULL)
{
_font = TTF_OpenFont(fontfamily.c_str(), size);
}
Font::~Font()
{
TTF_CloseFont(_font);
}
TTF_Font* Font::get_font()
{
return _font;
}
/*****************************************************************************
Class Image
*****************************************************************************/
Image::Image()
: _image(NULL), _w(0), _h(0)
{}
Image::Image(const std::string& filename, Window& window)
: Image()
{
_image = IMG_LoadTexture(window.get_renderer(), filename.c_str());
if (_image == NULL)
{
std::cout << "Error in Image::Image(): No image file" << filename << '\n';
exit(1);
}
SDL_QueryTexture(_image, NULL, NULL, &_w, &_h);
}
Image::Image(const std::string& text, Font& font, const Color& c, Window& window)
: Image()
{
SDL_Color color = { c.r, c.b, c.g, c.a };
SDL_Surface* s = TTF_RenderText_Solid(font.get_font(), text.c_str(), color);
_image = SDL_CreateTextureFromSurface(window.get_renderer(), s);
SDL_QueryTexture(_image, NULL, NULL, &_w, &_h);
}
Image::~Image()
{
SDL_DestroyTexture(_image);
}
SDL_Texture* Image::get_texture()
{
return _image;
}
int Image::get_width() const
{
return _w;
}
int Image::get_height() const
{
return _h;
}
Rect Image::get_rect() const
{
return Rect { 0, 0, _w, _h };
}
}
|
357b6760ae267b27873143579822e9b269d6b9bc
|
3d26e9deaf7cdeae9b682cc2fb71a83b786bb1a4
|
/pedestrian/source/test/diffEvoTest.cpp
|
9e51938b5eec694f34e21353ae9f95399284fdaa
|
[] |
no_license
|
peiyongxia/diploma-thesis
|
1779cda6cba670013bf09fd12c97de8413c51bf0
|
82c95a6a47c5d4744255c7cca95d49d9021eda14
|
refs/heads/master
| 2020-03-19T15:49:55.303968
| 2018-04-29T12:14:14
| 2018-04-29T12:14:14
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 681
|
cpp
|
diffEvoTest.cpp
|
#include "diffEvoTest.h"
double DiffEvoTest::EvaluteCost(std::vector<double> inputs) const
{
SvmTest st;
st.preprocessing();
st.setParams((int) inputs[0] * 1000, inputs[1], inputs[2], inputs[3]);
return (1 - st.process());
}
unsigned int DiffEvoTest::NumberOfParameters() const
{
return m_dim;
}
std::vector<de::IOptimizable::Constraints> DiffEvoTest::GetConstraints() const
{
std::vector<Constraints> constr;
constr.push_back(Constraints(0.1, 3.0, true));
constr.push_back(Constraints(0.1, 0.5, true));
constr.push_back(Constraints(0.1, 0.5, true));
constr.push_back(Constraints(0.1, 0.5, true));
//constr.push_back(Constraints(0.3, 1.0, true));
return constr;
}
|
9f15e7d94bb86c0c9ee9389ce7ebed531bc723c3
|
3ae7e15a25e872391f720a44ed0fec682af88d34
|
/Code/CommonUtil/FileUtils.cpp
|
aab0a17a6178b46ff89612ea12e4da8c48ea83f3
|
[] |
no_license
|
petersbingham/Brainer
|
486193ed63f3daa6574e22c933f4b0d2c5707688
|
77797146b7091da654c3d6c0ef46f316b9dbd56b
|
refs/heads/master
| 2018-10-30T23:47:34.185279
| 2018-08-23T22:07:24
| 2018-08-23T22:07:24
| 100,266,976
| 0
| 0
| null | 2018-08-23T22:07:25
| 2017-08-14T12:49:27
|
C++
|
UTF-8
|
C++
| false
| false
| 5,003
|
cpp
|
FileUtils.cpp
|
//---------------------------------------------------------------------------
#include "stdafx.h"
#include "AppException.h"
#include "FileUtils.h"
#include <stdio.h>
#include <direct.h>
TFileNames::TFileNames()
{
next = NULL;
mpc_FileName = NULL;
}
TFileNames::~TFileNames()
{
if(mpc_FileName) {
delete mpc_FileName;
}
if(next) {
delete next;
}
}
void TFileNames::AddFileName(char* _pc_FileName)
{
if(mpc_FileName == NULL) {
mpc_FileName = new char[strlen(_pc_FileName)+1];
#ifdef _MSC_VER
strcpy_s(mpc_FileName,strlen(_pc_FileName)+1,_pc_FileName);
#else
strcpy(mpc_FileName,_pc_FileName);
#endif
}
else if (next == NULL){
next = new TFileNames();
next->AddFileName(_pc_FileName);
}
else {
next->AddFileName(_pc_FileName);
}
}
int TFileNames::GetFileNameLength(int* _pi_FileNameLength, int _i_Index)
{
int iret = RET_RANGEERR;
if(_i_Index==1) {
*_pi_FileNameLength = strlen(mpc_FileName);
iret = RET_OK;
}
else if(next != NULL) {
iret = next->GetFileNameLength(_pi_FileNameLength,_i_Index-1);
}
return iret;
}
int TFileNames::GetFileName(char* _pc_FileName, int _i_Index)
{
int iret = RET_RANGEERR;
if(_i_Index==1) {
#ifdef _MSC_VER
strcpy_s(_pc_FileName,strlen(mpc_FileName)+1,mpc_FileName);
#else
strcpy(_pc_FileName,mpc_FileName);
#endif
iret = RET_OK;
}
else if(next != NULL) {
iret = next->GetFileName(_pc_FileName,_i_Index-1);
}
return iret;
}
unsigned int TFileUtils::MAX_LINE_LEN = 512;
void TFileUtils::GetFilesInDir(const char* _pc_Path,
int* _pi_DllsinDir, TFileNames* _p_FileNames,
const char* _pc_PreID, const char* _pc_FileType)
{
*_pi_DllsinDir = 0;
WIN32_FIND_DATAA FindFileData;
HANDLE hFind;
char* cp_FileNames = new char[strlen(_pc_PreID)+strlen(_pc_FileType)+5];
#ifdef _MSC_VER
sprintf_s(cp_FileNames,strlen(_pc_PreID)+strlen(_pc_FileType)+5, "\\%s*.%s", _pc_PreID, _pc_FileType);
#else
sprintf(cp_FileNames, "\\%s*.%s", _pc_PreID, _pc_FileType);
#endif
char* cp_SearchString = new char[strlen(_pc_Path)+strlen(cp_FileNames)+5];
int iDestSize = strlen(cp_SearchString);
if (cp_SearchString) {
#ifdef _MSC_VER
sprintf_s(cp_SearchString,strlen(_pc_Path)+strlen(cp_FileNames)+5,"%s%s",_pc_Path,cp_FileNames);
#else
sprintf(cp_SearchString,"%s%s",_pc_Path,cp_FileNames);
#endif
}
if(cp_SearchString) {
hFind = FindFirstFileA(cp_SearchString, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
delete[] cp_SearchString;
int iError = GetLastError();
throw TAppException(TAppException::APPEXCEPTION_UNABLETOFINDANYFILES,"Unable to find any files");
}
else
{
(*_pi_DllsinDir)++;
_p_FileNames->AddFileName((char*)FindFileData.cFileName);
int iret = 1;
while(iret) {
iret = FindNextFileA(hFind, &FindFileData);
if(iret) {
_p_FileNames->AddFileName((char*)FindFileData.cFileName);
(*_pi_DllsinDir)++;
}
}
}
FindClose(hFind);
}
delete[] cp_SearchString;
delete[] cp_FileNames;
}
bool TFileUtils::CheckFileExists(const char* _pc_Path)
{
bool b_ret = true;
WIN32_FIND_DATAA FindFileData;
HANDLE hFind = FindFirstFileA(_pc_Path, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE) {
b_ret = false;
}
else {
FindClose(hFind);
}
return b_ret;
}
bool TFileUtils::CreateNewFile(const char* _pc_Path)
{
bool b_ret = true;
HANDLE hFind = CreateFileA(_pc_Path, (GENERIC_READ | GENERIC_WRITE),
0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFind == INVALID_HANDLE_VALUE) {
b_ret = false;
}
else {
FindClose(hFind);
}
return b_ret;
}
bool TFileUtils::CreateCWDPath(char* _pc_Path, unsigned int _ui_buffLen, const char* _pc_FileName)
{
bool b_ret = false;
if(_getcwd(_pc_Path, _ui_buffLen)) {
b_ret = true;
if(_pc_FileName) {
#ifdef _MSC_VER
sprintf_s(_pc_Path,_ui_buffLen,"%s\\%s",_pc_Path,_pc_FileName);
#else
sprintf(_pc_Path,"%s\\%s",_pc_Path,_pc_FileName);
#endif
}
}
else {
_pc_Path = NULL;
}
return b_ret;
}
int TFileUtils::GetNumLinesInFile(char* _pc_FileName, int _i_MaxLineLength)
{
FILE *fp = fopen(_pc_FileName,"r");
int i_numLines = 0;
if (fp != NULL) {
char* stringptr = new char[_i_MaxLineLength];
while (true) {
if (fgets(stringptr, _i_MaxLineLength, fp) == NULL) break;
i_numLines++;
if (feof(fp)) break;
}
delete[] stringptr;
fclose(fp);
}
return i_numLines;
}
bool TFileUtils::GetAllLinesInFile(char* _pc_FileName, char*** _ppc_allLines, int* _pi_NumLines, int _i_MaxLineLength)
{
int i_numLines = GetNumLinesInFile(_pc_FileName, _i_MaxLineLength);
*_pi_NumLines = 0;
if (i_numLines>0) {
FILE *fp = fopen(_pc_FileName,"r");
if (fp != NULL) {
*_ppc_allLines = new char*[i_numLines];
for (int i=0;i<i_numLines;++i) {
*(*_ppc_allLines+i) = new char[_i_MaxLineLength];
if (fgets(*(*_ppc_allLines+i), _i_MaxLineLength, fp) == NULL) break;
if (feof(fp)) break;
}
fclose(fp);
*_pi_NumLines = i_numLines;
return true;
}
}
return false;
}
|
22196c7510657b9e634cf032f29e2d78011eac7d
|
ae31542273a142210a1ff30fb76ed9d45d38eba9
|
/src/backend/gpopt/translate/CQueryMutators.cpp
|
2c96a6cdb8ee6e28445a37b37baa548f138af745
|
[
"Apache-2.0",
"LicenseRef-scancode-generic-cla",
"PostgreSQL",
"OpenSSL",
"LicenseRef-scancode-stream-benchmark",
"ISC",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-ssleay-windows",
"BSD-2-Clause",
"Python-2.0"
] |
permissive
|
greenplum-db/gpdb
|
8334837bceb2d5d51a684500793d11b190117c6a
|
2c0f8f0fb24a2d7a7da114dc80f5f5a2712fca50
|
refs/heads/main
| 2023-08-22T02:03:03.806269
| 2023-08-21T22:59:53
| 2023-08-22T01:17:10
| 44,781,140
| 6,417
| 2,082
|
Apache-2.0
| 2023-09-14T20:33:42
| 2015-10-23T00:25:17
|
C
|
UTF-8
|
C++
| false
| false
| 53,087
|
cpp
|
CQueryMutators.cpp
|
//---------------------------------------------------------------------------
// Greenplum Database
// Copyright (C) 2012 EMC Corp.
//
// @filename:
// CQueryMutators.cpp
//
// @doc:
// Implementation of methods used during translating a GPDB Query object into a
// DXL Tree
//
// @test:
//
//---------------------------------------------------------------------------
extern "C" {
#include "postgres.h"
#include "nodes/makefuncs.h"
#include "nodes/parsenodes.h"
#include "nodes/plannodes.h"
#include "optimizer/walkers.h"
}
#include "gpopt/base/CUtils.h"
#include "gpopt/gpdbwrappers.h"
#include "gpopt/mdcache/CMDAccessor.h"
#include "gpopt/mdcache/CMDAccessorUtils.h"
#include "gpopt/translate/CQueryMutators.h"
#include "gpopt/translate/CTranslatorDXLToPlStmt.h"
#include "naucrates/exception.h"
#include "naucrates/md/IMDAggregate.h"
#include "naucrates/md/IMDScalarOp.h"
#include "naucrates/md/IMDTypeBool.h"
using namespace gpdxl;
using namespace gpmd;
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::NeedsProjListNormalization
//
// @doc:
// Is the group by project list flat (contains only aggregates, grouping
// funcs, and grouping columns)
//---------------------------------------------------------------------------
BOOL
CQueryMutators::NeedsProjListNormalization(const Query *query)
{
if (!query->hasAggs && nullptr == query->groupClause &&
nullptr == query->groupingSets)
{
return false;
}
SContextTLWalker context(query->targetList, query->groupClause);
ListCell *lc = nullptr;
ForEach(lc, query->targetList)
{
TargetEntry *target_entry = (TargetEntry *) lfirst(lc);
if (ShouldFallback((Node *) target_entry->expr, &context))
{
// TODO: remove temporary fix (revert exception to assert) to avoid crash during algebrization
GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiQuery2DXLError,
GPOS_WSZ_LIT("No attribute"));
}
// Normalize when there is an expression that is neither used for grouping
// nor is an aggregate function
if (!IsA(target_entry->expr, Aggref) &&
!IsA(target_entry->expr, GroupingFunc) &&
!CTranslatorUtils::IsGroupingColumn((Node *) target_entry->expr,
query->groupClause,
query->targetList))
{
return true;
}
}
return false;
}
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::ShouldFallback
//
// @doc:
// Fall back when the target list refers to a attribute which algebrizer
// at this point cannot resolve
//---------------------------------------------------------------------------
BOOL
CQueryMutators::ShouldFallback(Node *node, SContextTLWalker *context)
{
if (nullptr == node)
{
return false;
}
if (IsA(node, Const) || IsA(node, Aggref) || IsA(node, GroupingFunc) ||
IsA(node, SubLink))
{
return false;
}
TargetEntry *entry = gpdb::FindFirstMatchingMemberInTargetList(
node, context->m_target_entries);
if (nullptr != entry && CTranslatorUtils::IsGroupingColumn(
(Node *) entry->expr, context->m_group_clause,
context->m_target_entries))
{
return false;
}
if (IsA(node, SubLink))
{
return false;
}
if (IsA(node, Var))
{
Var *var = (Var *) node;
if (0 == var->varlevelsup)
{
// if we reach a Var that was not a grouping column then there is an equivalent column
// which the algebrizer at this point cannot resolve
// example: consider two table r(a,b) and s(c,d) and the following query
// SELECT a from r LEFT JOIN s on (r.a = s.c) group by r.a
// In the query object, generated by the parse, the output columns refer to the output of
// the left outer join while the grouping column refers to the base table column.
// While r.a and a are equivalent, the algebrizer at this point cannot detect this.
// Therefore, we fall back.
return true;
}
return false;
}
return gpdb::WalkExpressionTree(
node, (ExprWalkerFn) CQueryMutators::ShouldFallback, context);
}
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::NormalizeGroupByProjList
//
// @doc:
// Flatten expressions in project list to contain only aggregates, grouping
// funcs and grouping columns
// ORGINAL QUERY:
// SELECT * from r where r.a > (SELECT max(c) + min(d) FROM t where r.b = t.e)
// NEW QUERY:
// SELECT * from r where r.a > (SELECT x1+x2 as x3
// FROM (SELECT max(c) as x2, min(d) as x2
// FROM t where r.b = t.e) t2)
//---------------------------------------------------------------------------
Query *
CQueryMutators::NormalizeGroupByProjList(CMemoryPool *mp,
CMDAccessor *md_accessor,
const Query *query)
{
Query *query_copy = (Query *) gpdb::CopyObject(const_cast<Query *>(query));
if (!NeedsProjListNormalization(query_copy))
{
return query_copy;
}
Query *new_query =
ConvertToDerivedTable(query_copy, false /*should_fix_target_list*/,
true /*should_fix_having_qual*/);
gpdb::GPDBFree(query_copy);
GPOS_ASSERT(1 == gpdb::ListLength(new_query->rtable));
Query *derived_table_query =
(Query *) ((RangeTblEntry *) gpdb::ListNth(new_query->rtable, 0))
->subquery;
SContextGrpbyPlMutator context(mp, md_accessor, derived_table_query,
nullptr);
List *target_list_copy =
(List *) gpdb::CopyObject(derived_table_query->targetList);
ListCell *lc = nullptr;
// first normalize grouping columns
ForEach(lc, target_list_copy)
{
TargetEntry *target_entry = (TargetEntry *) lfirst(lc);
GPOS_ASSERT(nullptr != target_entry);
if (CTranslatorUtils::IsGroupingColumn(
target_entry, derived_table_query->groupClause))
{
target_entry->expr = (Expr *) FixGroupingCols(
(Node *) target_entry->expr, target_entry, &context);
}
}
lc = nullptr;
// normalize remaining project elements
ForEach(lc, target_list_copy)
{
TargetEntry *target_entry = (TargetEntry *) lfirst(lc);
GPOS_ASSERT(nullptr != target_entry);
BOOL is_grouping_col = CTranslatorUtils::IsGroupingColumn(
target_entry, derived_table_query->groupClause);
if (!is_grouping_col)
{
target_entry->expr = (Expr *) RunExtractAggregatesMutator(
(Node *) target_entry->expr, &context);
GPOS_ASSERT(!IsA(target_entry->expr, Aggref) &&
"New target list entry should not contain any Aggrefs");
GPOS_ASSERT(
!IsA(target_entry->expr, GroupingFunc) &&
"New target list entry should not contain any GroupingFuncs");
}
}
derived_table_query->targetList = context.m_lower_table_tlist;
new_query->targetList = target_list_copy;
ReassignSortClause(new_query, derived_table_query);
return new_query;
}
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::RunIncrLevelsUpMutator
//
// @doc:
// Increment any the query levels up of any outer reference by one
//---------------------------------------------------------------------------
Node *
CQueryMutators::RunIncrLevelsUpMutator(Node *node,
SContextIncLevelsupMutator *context)
{
if (nullptr == node)
{
return nullptr;
}
if (IsA(node, Var))
{
Var *var = (Var *) gpdb::CopyObject(node);
// Consider the following use case:
// ORGINAL QUERY:
// SELECT * from r where r.a > (SELECT max(c) + min(d)
// FROM t where r.b = t.e)
// NEW QUERY:
// SELECT * from r where r.a > (SELECT x1+x2 as x3
// FROM (SELECT max(c) as x2, min(d) as x2
// FROM t where r.b = t.e) t2)
//
// In such a scenario, we need increment the levels up for the
// correlation variable r.b in the subquery by 1.
if (var->varlevelsup > context->m_current_query_level)
{
var->varlevelsup++;
return (Node *) var;
}
return (Node *) var;
}
if (IsA(node, TargetEntry) && 0 == context->m_current_query_level &&
!context->m_should_fix_top_level_target_list)
{
return (Node *) gpdb::CopyObject(node);
}
// recurse into query structure
if (IsA(node, Query))
{
context->m_current_query_level++;
Query *query = query_tree_mutator(
(Query *) node,
(MutatorWalkerFn) CQueryMutators::RunIncrLevelsUpMutator, context,
0 // flags
);
context->m_current_query_level--;
return (Node *) query;
}
return expression_tree_mutator(
node, (MutatorWalkerFn) CQueryMutators::RunIncrLevelsUpMutator,
context);
}
//---------------------------------------------------------------------------
// CQueryMutators::RunFixCTELevelsUpWalker
//
// Increment CTE range table reference by one if it refers to
// an ancestor of the original Query node (level 0 in the context)
//---------------------------------------------------------------------------
BOOL
CQueryMutators::RunFixCTELevelsUpWalker(Node *node,
SContextIncLevelsupMutator *context)
{
if (nullptr == node)
{
return false;
}
if (IsA(node, RangeTblEntry))
{
RangeTblEntry *rte = (RangeTblEntry *) node;
if (RTE_CTE == rte->rtekind &&
rte->ctelevelsup >= context->m_current_query_level)
{
// fix the levels up for CTE range table entry when needed
// the walker in GPDB does not walk range table entries of type CTE
rte->ctelevelsup++;
}
// always return false, as we want to continue fixing up RTEs
return false;
}
// recurse into query structure, incrementing the query level
if (IsA(node, Query))
{
context->m_current_query_level++;
BOOL result = query_tree_walker(
(Query *) node,
(ExprWalkerFn) CQueryMutators::RunFixCTELevelsUpWalker, context,
QTW_EXAMINE_RTES_BEFORE // flags - visit RTEs
);
context->m_current_query_level--;
return result;
}
if (IsA(node, TargetEntry) &&
!context->m_should_fix_top_level_target_list &&
0 == context->m_current_query_level)
{
// skip the top-level target list, if requested
return false;
}
return expression_tree_walker(
node, (ExprWalkerFn) CQueryMutators::RunFixCTELevelsUpWalker, context);
}
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::RunGroupingColMutator
//
// @doc:
// Mutate the grouping columns, fix levels up when necessary
//
//---------------------------------------------------------------------------
Node *
CQueryMutators::RunGroupingColMutator(Node *node,
SContextGrpbyPlMutator *context)
{
if (nullptr == node)
{
return nullptr;
}
if (IsA(node, Const))
{
return (Node *) gpdb::CopyObject(node);
}
if (IsA(node, Var))
{
Var *var_copy = (Var *) gpdb::CopyObject(node);
if (var_copy->varlevelsup > context->m_current_query_level)
{
var_copy->varlevelsup++;
}
return (Node *) var_copy;
}
if (IsA(node, Aggref))
{
// merely fix the arguments of an aggregate
Aggref *old_aggref = (Aggref *) node;
Aggref *aggref = FlatCopyAggref(old_aggref);
aggref->agglevelsup = old_aggref->agglevelsup;
List *new_args = NIL;
ListCell *lc = nullptr;
BOOL is_agg = context->m_is_mutating_agg_arg;
context->m_is_mutating_agg_arg = true;
ForEach(lc, old_aggref->args)
{
Node *arg = (Node *) gpdb::CopyObject((Node *) lfirst(lc));
GPOS_ASSERT(nullptr != arg);
// traverse each argument and fix levels up when needed
new_args = gpdb::LAppend(
new_args,
gpdb::MutateQueryOrExpressionTree(
arg,
(MutatorWalkerFn) CQueryMutators::RunGroupingColMutator,
(void *) context,
0 // flags -- mutate into cte-lists
));
}
context->m_is_mutating_agg_arg = is_agg;
aggref->args = new_args;
return (Node *) aggref;
}
if (IsA(node, GroupingFunc))
{
// FIXME: we do not fix levelsup for GroupingFunc here, the translator
// will fall back later when it detects levelsup > 0. We need to do
// similar things as AggRef here when ORCA adds support for GroupingFunc
// with outer refs
return (Node *) gpdb::CopyObject(node);
}
if (IsA(node, SubLink))
{
SubLink *old_sublink = (SubLink *) node;
SubLink *new_sublink = MakeNode(SubLink);
new_sublink->subLinkType = old_sublink->subLinkType;
new_sublink->location = old_sublink->location;
new_sublink->operName =
(List *) gpdb::CopyObject(old_sublink->operName);
new_sublink->testexpr = gpdb::MutateQueryOrExpressionTree(
old_sublink->testexpr,
(MutatorWalkerFn) CQueryMutators::RunGroupingColMutator,
(void *) context,
0 // flags -- mutate into cte-lists
);
context->m_current_query_level++;
GPOS_ASSERT(IsA(old_sublink->subselect, Query));
new_sublink->subselect = gpdb::MutateQueryOrExpressionTree(
old_sublink->subselect,
(MutatorWalkerFn) CQueryMutators::RunGroupingColMutator, context,
0 // flags -- mutate into cte-lists
);
context->m_current_query_level--;
return (Node *) new_sublink;
}
if (IsA(node, CommonTableExpr))
{
CommonTableExpr *cte = (CommonTableExpr *) gpdb::CopyObject(node);
context->m_current_query_level++;
GPOS_ASSERT(IsA(cte->ctequery, Query));
cte->ctequery = gpdb::MutateQueryOrExpressionTree(
cte->ctequery,
(MutatorWalkerFn) CQueryMutators::RunGroupingColMutator,
(void *) context,
0 // flags --- mutate into cte-lists
);
context->m_current_query_level--;
return (Node *) cte;
}
// recurse into query structure
if (IsA(node, Query))
{
Query *query = gpdb::MutateQueryTree(
(Query *) node,
(MutatorWalkerFn) CQueryMutators::RunGroupingColMutator, context,
1 // flag -- do not mutate range table entries
);
// fix the outer reference in derived table entries
List *rtable = query->rtable;
ListCell *lc = nullptr;
ForEach(lc, rtable)
{
RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc);
if (RTE_SUBQUERY == rte->rtekind)
{
Query *subquery = rte->subquery;
// since we did not walk inside derived tables
context->m_current_query_level++;
rte->subquery =
(Query *) RunGroupingColMutator((Node *) subquery, context);
context->m_current_query_level--;
gpdb::GPDBFree(subquery);
}
}
return (Node *) query;
}
return gpdb::MutateExpressionTree(
node, (MutatorWalkerFn) CQueryMutators::RunGroupingColMutator, context);
}
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::FixGroupingCols
//
// @doc:
// Mutate the grouping columns, fix levels up when necessary
//---------------------------------------------------------------------------
Node *
CQueryMutators::FixGroupingCols(Node *node, TargetEntry *orginal_target_entry,
SContextGrpbyPlMutator *context)
{
GPOS_ASSERT(nullptr != node);
ULONG arity = gpdb::ListLength(context->m_lower_table_tlist) + 1;
// fix any outer references in the grouping column expression
Node *expr = (Node *) RunGroupingColMutator(node, context);
CHAR *name = CQueryMutators::GetTargetEntryColName(orginal_target_entry,
context->m_query);
TargetEntry *new_target_entry = gpdb::MakeTargetEntry(
(Expr *) expr, (AttrNumber) arity, name, false /*resjunk */);
new_target_entry->ressortgroupref = orginal_target_entry->ressortgroupref;
new_target_entry->resjunk = false;
context->m_lower_table_tlist =
gpdb::LAppend(context->m_lower_table_tlist, new_target_entry);
Var *new_var = gpdb::MakeVar(
1, // varno
(AttrNumber) arity, gpdb::ExprType((Node *) orginal_target_entry->expr),
gpdb::ExprTypeMod((Node *) orginal_target_entry->expr),
0 // query levelsup
);
return (Node *) new_var;
}
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::GetTargetEntryForAggExpr
//
// @doc:
// Return a target entry for an aggregate expression
//---------------------------------------------------------------------------
TargetEntry *
CQueryMutators::GetTargetEntryForAggExpr(CMemoryPool *mp,
CMDAccessor *md_accessor, Node *node,
ULONG attno)
{
GPOS_ASSERT(IsA(node, Aggref) || IsA(node, GroupingFunc));
// get the function/aggregate name
CHAR *name = nullptr;
if (IsA(node, GroupingFunc))
{
name = CTranslatorUtils::CreateMultiByteCharStringFromWCString(
GPOS_WSZ_LIT("grouping"));
}
else
{
Aggref *aggref = (Aggref *) node;
CMDIdGPDB *agg_mdid =
GPOS_NEW(mp) CMDIdGPDB(IMDId::EmdidGeneral, aggref->aggfnoid);
const IMDAggregate *md_agg = md_accessor->RetrieveAgg(agg_mdid);
agg_mdid->Release();
const CWStringConst *str = md_agg->Mdname().GetMDName();
name = CTranslatorUtils::CreateMultiByteCharStringFromWCString(
str->GetBuffer());
}
GPOS_ASSERT(nullptr != name);
return gpdb::MakeTargetEntry((Expr *) node, (AttrNumber) attno, name,
false);
}
// Traverse the entire tree under an arbitrarily complex project element (node)
// to extract all aggregate functions out into the derived query's target list
//
// This mutator should be called after creating a derived query (a subquery in
// the FROM clause), on each element in the old query's target list or qual to
// update any AggRef, GroupingFunc & Var to refer to the output from the derived
// query.
//
// See comments below & in the callers for specific use cases.
Node *
CQueryMutators::RunExtractAggregatesMutator(Node *node,
SContextGrpbyPlMutator *context)
{
if (nullptr == node)
{
return nullptr;
}
if (IsA(node, Const))
{
return (Node *) gpdb::CopyObject(node);
}
if (IsA(node, Aggref))
{
Aggref *old_aggref = (Aggref *) node;
// If the agglevelsup matches the current query level, this Aggref only
// uses vars from the top level query. This needs to be moved to the
// derived query, and the entire AggRef replaced with a Var referencing the
// derived table's target list.
if (old_aggref->agglevelsup == context->m_current_query_level)
{
Aggref *new_aggref = FlatCopyAggref(old_aggref);
BOOL is_agg_old = context->m_is_mutating_agg_arg;
ULONG agg_levels_up = context->m_agg_levels_up;
context->m_is_mutating_agg_arg = true;
context->m_agg_levels_up = old_aggref->agglevelsup;
List *new_args = NIL;
ListCell *lc = nullptr;
ForEach(lc, old_aggref->args)
{
Node *arg = (Node *) lfirst(lc);
GPOS_ASSERT(nullptr != arg);
// traverse each argument and fix levels up when needed
new_args = gpdb::LAppend(
new_args,
gpdb::MutateQueryOrExpressionTree(
arg, (MutatorWalkerFn) RunExtractAggregatesMutator,
(void *) context,
0 // mutate into cte-lists
));
}
new_aggref->args = new_args;
context->m_is_mutating_agg_arg = is_agg_old;
context->m_agg_levels_up = agg_levels_up;
// create a new entry in the derived table and return its corresponding var
return (Node *) MakeVarInDerivedTable((Node *) new_aggref, context);
}
}
if (0 == context->m_current_query_level)
{
if (IsA(node, Var) && context->m_is_mutating_agg_arg)
{
// This mutator may be run on a nested query object with aggregates on
// outer references. It pulls out any aggregates and moves it into the
// derived query (which is subquery), in effect, increasing the levels up
// any Var in the aggregate must now reference
//
// e.g SELECT (SELECT sum(o.o) + 1 FROM i GRP BY i.i) FROM o;
// becomes SELECT (SELECT x + 1 FROM (SELECT sum(o.o) GRP BY i.i)) FROM o;
// which means Var::varlevelup must be increased for o.o
return (Node *) IncrLevelsUpIfOuterRef((Var *) node);
}
if (IsA(node, GroupingFunc))
{
// create a new entry in the derived table and return its corresponding var
Node *node_copy = (Node *) gpdb::CopyObject(node);
return (Node *) MakeVarInDerivedTable(node_copy, context);
}
if (!context->m_is_mutating_agg_arg)
{
// check if an entry already exists, if so no need for duplicate
Node *found_node = FindNodeInGroupByTargetList(node, context);
if (nullptr != found_node)
{
return found_node;
}
}
}
if (IsA(node, Var))
{
Var *var = (Var *) gpdb::CopyObject(node);
// Handle other top-level outer references in the project element.
if (var->varlevelsup == context->m_current_query_level)
{
if (var->varlevelsup == context->m_agg_levels_up)
{
// If Var references the top level query inside an Aggref that also
// references top level query, the Aggref is moved to the derived query
// (see comments in Aggref if-case above). Thus, these Var references
// are brought up to the top-query level.
// e.g:
// explain select (select sum(foo.a) from jazz) from foo group by a, b;
// is transformed into
// select (select fnew.sum_t from jazz)
// from (select foo.a, foo.b, sum(foo.a) sum_t
// from foo group by foo.a, foo.b) fnew;
//
// Note the foo.a var which is in sum() in a subquery must now become a
// var referencing the current query level.
var->varlevelsup = 0;
return (Node *) var;
}
// Skip vars inside Aggrefs, since they have already been fixed when they
// were moved into the derived query in ConvertToDerivedTable(), and thus,
// the relative varno, varattno & varlevelsup should still be valid.
// e.g:
// SELECT foo.b+1, avg(( SELECT bar.f FROM bar
// WHERE bar.d = foo.b)) AS t
// FROM foo GROUP BY foo.b;
// is transformed into
// SELECT fnew.b+1, fnew.avg_t
// FROM (SELECT foo.b,`avg(( SELECT bar.f FROM bar
// WHERE bar.d = foo.b)) AS t
// FROM foo) fnew;
//
// Note the foo.b outerref in subquery inside the avg() aggregation.
// Because it is inside the aggregation, it was pushed down along with
// the aggregate function, and thus does not need to be fixed.
if (context->m_is_mutating_agg_arg)
{
return (Node *) var;
}
// For other top-level references, correct their varno & varattno, since
// they now must refer to the target list of the derived query - whose
// target list may be different from the original query.
// Set varlevelsup to 0 temporarily while searching in the target list
var->varlevelsup = 0;
TargetEntry *found_tle = gpdb::FindFirstMatchingMemberInTargetList(
(Node *) var, context->m_lower_table_tlist);
if (nullptr == found_tle)
{
// Consider two table r(a,b) and s(c,d) and the following query
// SELECT 1 from r LEFT JOIN s on (r.a = s.c) group by r.a having count(*) > a
// The having clause refers to the output of the left outer join while the
// grouping column refers to the base table column.
// While r.a and a are equivalent, the algebrizer at this point cannot detect this.
// Therefore, found_target_entry will be NULL and we fall back.
// TODO: Oct 14 2013, remove temporary fix (revert exception to assert) to avoid crash during algebrization
GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiQuery2DXLError,
GPOS_WSZ_LIT("No attribute"));
return nullptr;
}
var->varno =
1; // derived query is the only table in FROM expression
var->varattno = found_tle->resno;
var->varlevelsup =
context->m_current_query_level; // reset varlevels up
found_tle->resjunk = false;
return (Node *) var;
}
return (Node *) var;
}
if (IsA(node, CommonTableExpr))
{
CommonTableExpr *cte = (CommonTableExpr *) gpdb::CopyObject(node);
context->m_current_query_level++;
GPOS_ASSERT(IsA(cte->ctequery, Query));
cte->ctequery = gpdb::MutateQueryOrExpressionTree(
cte->ctequery, (MutatorWalkerFn) RunExtractAggregatesMutator,
(void *) context,
0 // mutate into cte-lists
);
context->m_current_query_level--;
return (Node *) cte;
}
if (IsA(node, SubLink))
{
SubLink *old_sublink = (SubLink *) node;
SubLink *new_sublink = MakeNode(SubLink);
new_sublink->subLinkType = old_sublink->subLinkType;
new_sublink->location = old_sublink->location;
new_sublink->operName =
(List *) gpdb::CopyObject(old_sublink->operName);
new_sublink->testexpr = gpdb::MutateQueryOrExpressionTree(
old_sublink->testexpr,
(MutatorWalkerFn) RunExtractAggregatesMutator, (void *) context,
0 // mutate into cte-lists
);
context->m_current_query_level++;
GPOS_ASSERT(IsA(old_sublink->subselect, Query));
new_sublink->subselect = gpdb::MutateQueryOrExpressionTree(
old_sublink->subselect,
(MutatorWalkerFn) RunExtractAggregatesMutator, (void *) context,
0 // mutate into cte-lists
);
context->m_current_query_level--;
return (Node *) new_sublink;
}
return gpdb::MutateExpressionTree(
node, (MutatorWalkerFn) RunExtractAggregatesMutator, context);
}
// Create a new entry in the derived table and return its corresponding var
Var *
CQueryMutators::MakeVarInDerivedTable(Node *node,
SContextGrpbyPlMutator *context)
{
GPOS_ASSERT(nullptr != node);
GPOS_ASSERT(nullptr != context);
GPOS_ASSERT(IsA(node, Aggref) || IsA(node, Var) || IsA(node, GroupingFunc));
// Append a new target entry for the node to the derived target list ...
const ULONG attno = gpdb::ListLength(context->m_lower_table_tlist) + 1;
TargetEntry *tle = nullptr;
if (IsA(node, Aggref) || IsA(node, GroupingFunc))
{
tle = GetTargetEntryForAggExpr(context->m_mp, context->m_mda, node,
attno);
}
else if (IsA(node, Var))
{
tle = gpdb::MakeTargetEntry((Expr *) node, (AttrNumber) attno, nullptr,
false);
}
context->m_lower_table_tlist =
gpdb::LAppend(context->m_lower_table_tlist, tle);
// ... and return a Var referring to it in its stead
// NB: Since the new tle is appended at the top query level, Var::varlevelsup
// should equal the current nested level. This will take care of any outer references
// to the original tlist.
Var *new_var =
gpdb::MakeVar(1 /* varno */, attno, gpdb::ExprType((Node *) node),
gpdb::ExprTypeMod((Node *) node),
context->m_current_query_level /* varlevelsup */);
return new_var;
}
// Check if a matching entry already exists in the list of target
// entries, if yes return its corresponding var, otherwise return NULL
Node *
CQueryMutators::FindNodeInGroupByTargetList(Node *node,
SContextGrpbyPlMutator *context)
{
GPOS_ASSERT(nullptr != node);
GPOS_ASSERT(nullptr != context);
TargetEntry *found_tle = gpdb::FindFirstMatchingMemberInTargetList(
node, context->m_lower_table_tlist);
if (nullptr != found_tle)
{
gpdb::GPDBFree(node);
// NB: Var::varlevelsup is set to the current query level since the created
// Var must reference the group by targetlist at the top level.
Var *new_var =
gpdb::MakeVar(1 /* varno */, found_tle->resno,
gpdb::ExprType((Node *) found_tle->expr),
gpdb::ExprTypeMod((Node *) found_tle->expr),
context->m_current_query_level /* varlevelsup */);
found_tle->resjunk = false;
return (Node *) new_var;
}
return nullptr;
}
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::FlatCopyAggref
//
// @doc:
// Make a copy of the aggref (minus the arguments)
//---------------------------------------------------------------------------
Aggref *
CQueryMutators::FlatCopyAggref(Aggref *old_aggref)
{
Aggref *new_aggref = MakeNode(Aggref);
*new_aggref = *old_aggref;
new_aggref->agglevelsup = 0;
// This is not strictly necessary: we seem to ALWAYS assgin to args from
// the callers
// Explicitly setting this both to be safe and to be clear that we are
// intentionally NOT copying the args
new_aggref->args = NIL;
return new_aggref;
}
// Increment the levels up of outer references
Var *
CQueryMutators::IncrLevelsUpIfOuterRef(Var *var)
{
GPOS_ASSERT(nullptr != var);
Var *var_copy = (Var *) gpdb::CopyObject(var);
if (0 != var_copy->varlevelsup)
{
var_copy->varlevelsup++;
}
return var_copy;
}
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::NormalizeHaving
//
// @doc:
// Pull up having qual into a select and fix correlated references
// to the top-level query
//---------------------------------------------------------------------------
Query *
CQueryMutators::NormalizeHaving(CMemoryPool *mp, CMDAccessor *md_accessor,
const Query *query)
{
Query *query_copy = (Query *) gpdb::CopyObject(const_cast<Query *>(query));
if (nullptr == query->havingQual)
{
return query_copy;
}
Query *new_query =
ConvertToDerivedTable(query_copy, true /*should_fix_target_list*/,
false /*should_fix_having_qual*/);
gpdb::GPDBFree(query_copy);
RangeTblEntry *rte =
((RangeTblEntry *) gpdb::ListNth(new_query->rtable, 0));
Query *derived_table_query = (Query *) rte->subquery;
// Add all necessary target list entries of subquery
// into the target list of the RTE as well as the new top most query
ListCell *lc = nullptr;
ULONG num_target_entries = 1;
ForEach(lc, derived_table_query->targetList)
{
TargetEntry *target_entry = (TargetEntry *) lfirst(lc);
GPOS_ASSERT(nullptr != target_entry);
// Add to the target lists:
// (1) All grouping / sorting columns even if they do not appear in the subquery output (resjunked)
// (2) All non-resjunked target list entries
if (CTranslatorUtils::IsGroupingColumn(
target_entry, derived_table_query->groupClause) ||
CTranslatorUtils::IsSortingColumn(
target_entry, derived_table_query->sortClause) ||
!target_entry->resjunk)
{
TargetEntry *new_target_entry =
MakeTopLevelTargetEntry(target_entry, num_target_entries);
new_query->targetList =
gpdb::LAppend(new_query->targetList, new_target_entry);
// Ensure that such target entries is not suppressed in the target list of the RTE
// and has a name
target_entry->resname =
GetTargetEntryColName(target_entry, derived_table_query);
target_entry->resjunk = false;
new_target_entry->ressortgroupref = target_entry->ressortgroupref;
num_target_entries++;
}
}
SContextGrpbyPlMutator context(mp, md_accessor, derived_table_query,
derived_table_query->targetList);
// fix outer references in the qual
new_query->jointree->quals =
RunExtractAggregatesMutator(derived_table_query->havingQual, &context);
derived_table_query->havingQual = nullptr;
ReassignSortClause(new_query, rte->subquery);
if (!rte->subquery->hasAggs && NIL == rte->subquery->groupClause &&
NIL == rte->subquery->groupingSets)
{
// if the derived table has no grouping columns or aggregates then the
// subquery is equivalent to select XXXX FROM CONST-TABLE
// (where XXXX is the original subquery's target list)
Query *new_subquery = MakeNode(Query);
new_subquery->commandType = CMD_SELECT;
new_subquery->targetList = NIL;
new_subquery->hasAggs = false;
new_subquery->hasWindowFuncs = false;
new_subquery->hasSubLinks = false;
ListCell *lc = nullptr;
ForEach(lc, rte->subquery->targetList)
{
TargetEntry *target_entry = (TargetEntry *) lfirst(lc);
GPOS_ASSERT(nullptr != target_entry);
GPOS_ASSERT(!target_entry->resjunk);
new_subquery->targetList =
gpdb::LAppend(new_subquery->targetList,
(TargetEntry *) gpdb::CopyObject(target_entry));
}
gpdb::GPDBFree(rte->subquery);
rte->subquery = new_subquery;
rte->subquery->jointree = MakeNode(FromExpr);
rte->subquery->groupClause = NIL;
rte->subquery->groupingSets = NIL;
rte->subquery->sortClause = NIL;
rte->subquery->windowClause = NIL;
}
return new_query;
}
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::NormalizeQuery
//
// @doc:
// Normalize queries with having and group by clauses
//---------------------------------------------------------------------------
Query *
CQueryMutators::NormalizeQuery(CMemoryPool *mp, CMDAccessor *md_accessor,
const Query *query, ULONG query_level)
{
// flatten join alias vars defined at the current level of the query
Query *pqueryResolveJoinVarReferences =
gpdb::FlattenJoinAliasVar(const_cast<Query *>(query), query_level);
// eliminate distinct clause
Query *pqueryEliminateDistinct =
CQueryMutators::EliminateDistinctClause(pqueryResolveJoinVarReferences);
GPOS_ASSERT(nullptr == pqueryEliminateDistinct->distinctClause);
gpdb::GPDBFree(pqueryResolveJoinVarReferences);
// normalize window operator's project list
Query *pqueryWindowPlNormalized = CQueryMutators::NormalizeWindowProjList(
mp, md_accessor, pqueryEliminateDistinct);
gpdb::GPDBFree(pqueryEliminateDistinct);
// pull-up having quals into a select
Query *pqueryHavingNormalized = CQueryMutators::NormalizeHaving(
mp, md_accessor, pqueryWindowPlNormalized);
GPOS_ASSERT(nullptr == pqueryHavingNormalized->havingQual);
gpdb::GPDBFree(pqueryWindowPlNormalized);
// normalize the group by project list
Query *new_query = CQueryMutators::NormalizeGroupByProjList(
mp, md_accessor, pqueryHavingNormalized);
gpdb::GPDBFree(pqueryHavingNormalized);
return new_query;
}
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::GetTargetEntry
//
// @doc:
// Given an Target list entry in the derived table, create a new
// TargetEntry to be added to the top level query. This function allocates
// memory
//---------------------------------------------------------------------------
TargetEntry *
CQueryMutators::MakeTopLevelTargetEntry(TargetEntry *old_target_entry,
ULONG attno)
{
Var *new_var = gpdb::MakeVar(
1, (AttrNumber) attno, gpdb::ExprType((Node *) old_target_entry->expr),
gpdb::ExprTypeMod((Node *) old_target_entry->expr),
0 // query levelsup
);
TargetEntry *new_target_entry = gpdb::MakeTargetEntry(
(Expr *) new_var, (AttrNumber) attno, old_target_entry->resname,
old_target_entry->resjunk);
return new_target_entry;
}
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::GetTargetEntryColName
//
// @doc:
// Return the column name of the target list entry
//---------------------------------------------------------------------------
CHAR *
CQueryMutators::GetTargetEntryColName(TargetEntry *target_entry, Query *query)
{
if (nullptr != target_entry->resname)
{
return target_entry->resname;
}
// Since a resjunked target list entry will not have a column name create a dummy column name
CWStringConst dummy_colname(GPOS_WSZ_LIT("?column?"));
return CTranslatorUtils::CreateMultiByteCharStringFromWCString(
dummy_colname.GetBuffer());
}
//---------------------------------------------------------------------------
// CQueryMutators::ConvertToDerivedTable
//
// Convert "original_query" into two nested Query structs
// and return the new upper query.
//
// upper_query
// original_query ===> |
// lower_query
//
// - The result lower Query has:
// * The original rtable, join tree, groupClause, WindowClause, etc.,
// with modified varlevelsup and ctelevelsup fields, as needed
// * The original targetList, either modified or unmodified,
// depending on should_fix_target_list
// * The original havingQual, either modified or unmodified,
// depending on should_fix_having_qual
//
// - The result upper Query has:
// * a single RTE, pointing to the lower query
// * the CTE list of the original query
// (CTE levels in original have been fixed up)
// * an empty target list
//
//---------------------------------------------------------------------------
Query *
CQueryMutators::ConvertToDerivedTable(const Query *original_query,
BOOL should_fix_target_list,
BOOL should_fix_having_qual)
{
// Step 1: Make a copy of the original Query, this will become the lower query
Query *query_copy =
(Query *) gpdb::CopyObject(const_cast<Query *>(original_query));
// Step 2: Remove things from the query copy that will go in the new, upper Query object
// or won't be modified
Node *having_qual = nullptr;
if (!should_fix_having_qual)
{
having_qual = query_copy->havingQual;
query_copy->havingQual = nullptr;
}
List *original_cte_list = query_copy->cteList;
query_copy->cteList = NIL;
// intoPolicy, if not null, must be set on the top query, not on the derived table
struct GpPolicy *into_policy = query_copy->intoPolicy;
query_copy->intoPolicy = nullptr;
// Step 3: fix outer references and CTE levels
// increment varlevelsup in the lower query where they point to a Query
// that is an ancestor of the original query
Query *lower_query;
{
SContextIncLevelsupMutator context1(0, should_fix_target_list);
lower_query = gpdb::MutateQueryTree(
query_copy, (MutatorWalkerFn) RunIncrLevelsUpMutator, &context1,
0 // flags
);
}
// fix the CTE levels up -- while the old query is converted into a derived table, its cte list
// is re-assigned to the new top-level query. The references to the ctes listed in the old query
// as well as those listed before the current query level are accordingly adjusted in the new
// derived table.
{
SContextIncLevelsupMutator context2(0 /*starting level */,
should_fix_target_list);
(void) gpdb::WalkQueryOrExpressionTree(
(Node *) lower_query, (ExprWalkerFn) RunFixCTELevelsUpWalker,
&context2, QTW_EXAMINE_RTES_BEFORE);
}
if (nullptr != having_qual)
{
lower_query->havingQual = having_qual;
}
// Step 4: Create a new, single range table entry for the upper query
RangeTblEntry *rte = MakeNode(RangeTblEntry);
rte->rtekind = RTE_SUBQUERY;
rte->subquery = lower_query;
rte->inFromCl = true;
rte->subquery->cteList = NIL;
// create a new range table reference for the new RTE
RangeTblRef *rtref = MakeNode(RangeTblRef);
rtref->rtindex = 1;
// Step 5: Create a new upper query with the new RTE in its from clause
Query *upper_query = MakeNode(Query);
upper_query->cteList = original_cte_list;
upper_query->rtable = gpdb::LAppend(upper_query->rtable, rte);
upper_query->intoPolicy = into_policy;
upper_query->parentStmtType = lower_query->parentStmtType;
lower_query->parentStmtType = PARENTSTMTTYPE_NONE;
FromExpr *fromexpr = MakeNode(FromExpr);
fromexpr->quals = nullptr;
fromexpr->fromlist = gpdb::LAppend(fromexpr->fromlist, rtref);
upper_query->jointree = fromexpr;
upper_query->commandType = CMD_SELECT;
GPOS_ASSERT(1 == gpdb::ListLength(upper_query->rtable));
GPOS_ASSERT(false == upper_query->hasWindowFuncs);
return upper_query;
}
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::EliminateDistinctClause
//
// @doc:
// Eliminate distinct columns by translating it into a grouping columns
//---------------------------------------------------------------------------
Query *
CQueryMutators::EliminateDistinctClause(const Query *query)
{
if (0 == gpdb::ListLength(query->distinctClause))
{
return (Query *) gpdb::CopyObject(const_cast<Query *>(query));
}
// create a derived table out of the previous query
Query *new_query =
ConvertToDerivedTable(query, true /*should_fix_target_list*/,
true /*should_fix_having_qual*/);
GPOS_ASSERT(1 == gpdb::ListLength(new_query->rtable));
Query *derived_table_query =
(Query *) ((RangeTblEntry *) gpdb::ListNth(new_query->rtable, 0))
->subquery;
ReassignSortClause(new_query, derived_table_query);
new_query->targetList = NIL;
List *target_entries = derived_table_query->targetList;
ListCell *lc = nullptr;
// build the project list of the new top-level query
ForEach(lc, target_entries)
{
ULONG resno = gpdb::ListLength(new_query->targetList) + 1;
TargetEntry *target_entry = (TargetEntry *) lfirst(lc);
GPOS_ASSERT(nullptr != target_entry);
if (!target_entry->resjunk)
{
// create a new target entry that points to the corresponding entry in the derived table
Var *new_var =
gpdb::MakeVar(1, target_entry->resno,
gpdb::ExprType((Node *) target_entry->expr),
gpdb::ExprTypeMod((Node *) target_entry->expr),
0 // query levels up
);
TargetEntry *new_target_entry =
gpdb::MakeTargetEntry((Expr *) new_var, (AttrNumber) resno,
target_entry->resname, false);
new_target_entry->ressortgroupref = target_entry->ressortgroupref;
new_query->targetList =
gpdb::LAppend(new_query->targetList, new_target_entry);
}
if (0 < target_entry->ressortgroupref &&
!CTranslatorUtils::IsGroupingColumn(
target_entry, derived_table_query->groupClause) &&
!CTranslatorUtils::IsReferencedInWindowSpec(
target_entry, derived_table_query->windowClause))
{
// initialize the ressortgroupref of target entries not used in the grouping clause
target_entry->ressortgroupref = 0;
}
}
if (gpdb::ListLength(new_query->targetList) !=
gpdb::ListLength(query->distinctClause))
{
GPOS_RAISE(
gpdxl::ExmaDXL, gpdxl::ExmiQuery2DXLUnsupportedFeature,
GPOS_WSZ_LIT(
"DISTINCT operation on a subset of target list columns"));
}
ListCell *pl = nullptr;
ForEach(pl, query->distinctClause)
{
SortGroupClause *sort_group_clause = (SortGroupClause *) lfirst(pl);
GPOS_ASSERT(nullptr != sort_group_clause);
SortGroupClause *new_sort_group_clause = MakeNode(SortGroupClause);
new_sort_group_clause->tleSortGroupRef =
sort_group_clause->tleSortGroupRef;
new_sort_group_clause->eqop = sort_group_clause->eqop;
new_sort_group_clause->sortop = sort_group_clause->sortop;
new_sort_group_clause->nulls_first = sort_group_clause->nulls_first;
new_query->groupClause =
gpdb::LAppend(new_query->groupClause, new_sort_group_clause);
}
new_query->distinctClause = NIL;
derived_table_query->distinctClause = NIL;
return new_query;
}
//---------------------------------------------------------------------------
// CQueryMutators::NeedsProjListWindowNormalization
//
// Check whether the window operator's project list only contains
// window functions, vars, or expressions used in the window specification.
// Examples of queries that will be normalized:
// select rank() over(...) -1
// select rank() over(order by a), a+b
// select (SQ), rank over(...)
// Some of these, e.g. the second one, may not strictly need normalization.
//---------------------------------------------------------------------------
BOOL
CQueryMutators::NeedsProjListWindowNormalization(const Query *query)
{
if (!query->hasWindowFuncs)
{
return false;
}
ListCell *lc = nullptr;
ForEach(lc, query->targetList)
{
TargetEntry *target_entry = (TargetEntry *) lfirst(lc);
if (!CTranslatorUtils::IsReferencedInWindowSpec(target_entry,
query->windowClause) &&
!IsA(target_entry->expr, WindowFunc) &&
!IsA(target_entry->expr, Var))
{
// computed columns in the target list that is not
// used in the order by or partition by of the window specification(s)
return true;
}
}
return false;
}
//---------------------------------------------------------------------------
// CQueryMutators::NormalizeWindowProjList
//
// Flatten expressions in project list to contain only window functions,
// columns (vars) and columns (vars) used in the window specifications.
// This is a restriction in Orca and DXL, that we don't support a mix of
// window functions and general expressions in a target list.
//
// ORGINAL QUERY:
// SELECT row_number() over() + rank() over(partition by a+b order by a-b) from foo
//
// NEW QUERY:
// SELECT rn+rk from (SELECT row_number() over() as rn, rank() over(partition by a+b order by a-b) as rk FROM foo) foo_new
//---------------------------------------------------------------------------
Query *
CQueryMutators::NormalizeWindowProjList(CMemoryPool *mp,
CMDAccessor *md_accessor,
const Query *original_query)
{
Query *query_copy =
(Query *) gpdb::CopyObject(const_cast<Query *>(original_query));
if (!NeedsProjListWindowNormalization(original_query))
{
return query_copy;
}
// we assume here that we have already performed the transformGroupedWindows()
// transformation, which separates GROUP BY from window functions
GPOS_ASSERT(nullptr == original_query->distinctClause);
GPOS_ASSERT(nullptr == original_query->groupClause);
GPOS_ASSERT(nullptr == original_query->groupingSets);
// we do not fix target list of the derived table since we will be mutating it below
// to ensure that it does not have window functions
Query *upper_query =
ConvertToDerivedTable(query_copy, false /*should_fix_target_list*/,
true /*should_fix_having_qual*/);
gpdb::GPDBFree(query_copy);
GPOS_ASSERT(1 == gpdb::ListLength(upper_query->rtable));
Query *lower_query =
(Query *) ((RangeTblEntry *) gpdb::ListNth(upper_query->rtable, 0))
->subquery;
SContextGrpbyPlMutator projlist_context(mp, md_accessor, lower_query,
nullptr);
ListCell *lc = nullptr;
List *target_entries = lower_query->targetList;
ForEach(lc, target_entries)
{
// If this target entry is referenced in a window spec, is a var or is a window function,
// add it to the lower target list. Adjust the outer refs to ancestors of the orginal
// query by adding one to the varlevelsup. Add a var to the upper target list to refer
// to it.
//
// Any other target entries, add them to the upper target list, and ensure that any vars
// they reference in the current scope are produced by the lower query and are adjusted
// to refer to the new, single RTE of the upper query.
TargetEntry *target_entry = (TargetEntry *) lfirst(lc);
const ULONG ulResNoNew = gpdb::ListLength(upper_query->targetList) + 1;
if (CTranslatorUtils::IsReferencedInWindowSpec(
target_entry, original_query->windowClause))
{
// This entry is used in a window spec. Since this clause refers to its argument by
// ressortgroupref, the target entry must be preserved in the lower target list,
// so insert the entire Expr of the TargetEntry into the lower target list, using the
// same ressortgroupref and also preserving the resjunk attribute.
SContextIncLevelsupMutator level_context(
0, true /* should_fix_top_level_target_list */);
TargetEntry *lower_target_entry =
(TargetEntry *) gpdb::MutateExpressionTree(
(Node *) target_entry,
(MutatorWalkerFn) RunIncrLevelsUpMutator, &level_context);
lower_target_entry->resno =
gpdb::ListLength(projlist_context.m_lower_table_tlist) + 1;
projlist_context.m_lower_table_tlist = gpdb::LAppend(
projlist_context.m_lower_table_tlist, lower_target_entry);
BOOL is_sorting_col = CTranslatorUtils::IsSortingColumn(
target_entry, original_query->sortClause);
if (!target_entry->resjunk || is_sorting_col)
{
// the target list entry is present in the query output or it is used in the ORDER BY,
// so also add it to the target list of the new upper Query
Var *new_var = gpdb::MakeVar(
1, lower_target_entry->resno,
gpdb::ExprType((Node *) target_entry->expr),
gpdb::ExprTypeMod((Node *) target_entry->expr),
0 // query levels up
);
TargetEntry *upper_target_entry = gpdb::MakeTargetEntry(
(Expr *) new_var, ulResNoNew, target_entry->resname,
target_entry->resjunk);
if (is_sorting_col)
{
// This target list entry is referenced in the ORDER BY as well, evaluated in the upper
// query. Set the ressortgroupref, keeping the same number as in the original query.
upper_target_entry->ressortgroupref =
lower_target_entry->ressortgroupref;
}
// Set target list entry of the derived table to be non-resjunked, since we need it in the upper
lower_target_entry->resjunk = false;
upper_query->targetList =
gpdb::LAppend(upper_query->targetList, upper_target_entry);
}
}
else
{
// push any window functions in the target entry into the lower target list
// and also add any needed vars to the lower target list
target_entry->resno = ulResNoNew;
TargetEntry *upper_target_entry =
(TargetEntry *) gpdb::MutateExpressionTree(
(Node *) target_entry,
(MutatorWalkerFn) RunWindowProjListMutator,
&projlist_context);
upper_query->targetList =
gpdb::LAppend(upper_query->targetList, upper_target_entry);
}
}
// once we finish the above loop, the context has accumulated all the needed vars,
// window spec expressions and window functions for the lower targer list
lower_query->targetList = projlist_context.m_lower_table_tlist;
GPOS_ASSERT(gpdb::ListLength(upper_query->targetList) <=
gpdb::ListLength(original_query->targetList));
ReassignSortClause(upper_query, lower_query);
return upper_query;
}
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::RunWindowProjListMutator
//
// @doc:
// Traverse the project list of extract all window functions in an
// arbitrarily complex project element
//---------------------------------------------------------------------------
Node *
CQueryMutators::RunWindowProjListMutator(Node *node,
SContextGrpbyPlMutator *context)
{
if (nullptr == node)
{
return nullptr;
}
const ULONG resno = gpdb::ListLength(context->m_lower_table_tlist) + 1;
if (IsA(node, WindowFunc) && 0 == context->m_current_query_level)
{
// This is a window function that needs to be executed in the lower Query.
// Insert window function as a new TargetEntry into the lower target list
// (requires incrementing varlevelsup on its arguments).
// Create a var that refers to the newly created lower TargetEntry and return
// that, to be used instead of the window function in the upper TargetEntry.
// make a copy of the tree and increment varlevelsup, using a different mutator
SContextIncLevelsupMutator levelsUpContext(
context->m_current_query_level,
true /* should_fix_top_level_target_list */);
WindowFunc *window_func = (WindowFunc *) expression_tree_mutator(
node, (MutatorWalkerFn) RunIncrLevelsUpMutator, &levelsUpContext);
GPOS_ASSERT(IsA(window_func, WindowFunc));
// get the function name and create a new target entry for window_func
CMDIdGPDB *mdid_func = GPOS_NEW(context->m_mp)
CMDIdGPDB(IMDId::EmdidGeneral, window_func->winfnoid);
const CWStringConst *str =
CMDAccessorUtils::PstrWindowFuncName(context->m_mda, mdid_func);
mdid_func->Release();
TargetEntry *target_entry = gpdb::MakeTargetEntry(
(Expr *) window_func, (AttrNumber) resno,
CTranslatorUtils::CreateMultiByteCharStringFromWCString(
str->GetBuffer()),
false /* resjunk */
);
context->m_lower_table_tlist =
gpdb::LAppend(context->m_lower_table_tlist, target_entry);
// return a variable referring to the lower table's corresponding target entry,
// to be used somewhere in the upper query's target list
Var *new_var = gpdb::MakeVar(
1, // derived query which is now the only table in FROM expression
(AttrNumber) resno, gpdb::ExprType(node), gpdb::ExprTypeMod(node),
0 // query levelsup
);
return (Node *) new_var;
}
if (IsA(node, Var) &&
((Var *) node)->varlevelsup == context->m_current_query_level)
{
// This is a Var referencing the original query scope. It now needs to reference
// the new upper query scope.
// Since the rtable of the upper Query is different from that of the original
// Query, calculate the new varno (always 1) and varattno to use.
Var *var = (Var *) gpdb::CopyObject(node);
// Set varlevelsup to 0 temporarily while searching in the target list
var->varlevelsup = 0;
TargetEntry *found_tle = gpdb::FindFirstMatchingMemberInTargetList(
(Node *) var, context->m_lower_table_tlist);
if (nullptr == found_tle)
{
// this var is not yet provided by the lower target list, so
// create a new TargetEntry for it
Node *var_copy = (Node *) gpdb::CopyObject(var);
return (Node *) MakeVarInDerivedTable(var_copy, context);
}
var->varno = 1; // derived query is the only table in FROM expression
var->varattno = found_tle->resno;
var->varlevelsup =
context->m_current_query_level; // reset varlevels up
found_tle->resjunk = false;
return (Node *) var;
}
if (IsA(node, Query))
{
// recurse into Query nodes
context->m_current_query_level++;
Query *result = query_tree_mutator(
(Query *) node, (MutatorWalkerFn) RunWindowProjListMutator, context,
0);
context->m_current_query_level--;
return (Node *) result;
}
return expression_tree_mutator(
node, (MutatorWalkerFn) CQueryMutators::RunWindowProjListMutator,
context);
}
//---------------------------------------------------------------------------
// @function:
// CQueryMutators::ReassignSortClause
//
// @doc:
// Reassign the sorting clause from the derived table to the new top-level query
//---------------------------------------------------------------------------
void
CQueryMutators::ReassignSortClause(Query *top_level_query,
Query *derived_table_query)
{
top_level_query->sortClause = derived_table_query->sortClause;
top_level_query->limitOffset = derived_table_query->limitOffset;
top_level_query->limitCount = derived_table_query->limitCount;
derived_table_query->sortClause = nullptr;
derived_table_query->limitOffset = nullptr;
derived_table_query->limitCount = nullptr;
}
// EOF
|
c0c86d0bba0c76addb1237b0fa17c4dcac107e6e
|
ea7434d4d17149932d14c79f2f59dc2cc4aa05b3
|
/HE1.7.cpp
|
c5f9069a0b3d623f8a571e1c56e26e25ff390036
|
[] |
no_license
|
siddharthsaumya/OOP-Ass-1
|
da94c274be3cf5fe86da4a97e45a8e47607b408d
|
d6c16bec9a977aed1c270e2435bcb6a8acb51b47
|
refs/heads/master
| 2022-12-02T17:17:17.347940
| 2020-08-04T14:17:21
| 2020-08-04T14:17:21
| 285,001,125
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,226
|
cpp
|
HE1.7.cpp
|
#include<iostream>
using namespace std;
// Returns maximum repeating element in arr[0..n-1].
// The array elements are in range from 0 to k-1
int maxRepeating(int* arr, int n, int k)
{
// Iterate though input array, for every element
// arr[i], increment arr[arr[i]%k] by k
for (int i = 0; i< n; i++)
arr[arr[i]%k] += k;
// Find index of the maximum repeating element
int max = arr[0], result = 0;
for (int i = 1; i < n; i++)
{
if (arr[i] > max)
{
max = arr[i];
result = i;
}
}
/* Uncomment this code to get the original array back
for (int i = 0; i< n; i++)
arr[i] = arr[i]%k; */
// Return index of the maximum element
return result;
}
// Driver program to test above function
int main()
{
int z,i,arr[z];
cout<<"Enter the value of n: ";
cin>>z;
cout<<"Enter the elements: ";
for(i=0;i<z;i++){
cin>>arr[i];
}
int n = sizeof(arr[z])/sizeof(arr[0]);
int k = 8;
cout << "The maximum repeating number is " <<
maxRepeating(arr, n, k) << endl;
return 0;
}
|
349c453b452492f21aafdcec8679f9fd29792d40
|
dfd64f551a3d6a9e6626518a15e28b14e45a3f4f
|
/leetcode_c/frequent_element.h
|
e6b12828dd3c885b844296ca6eef3eb9294dc6fb
|
[] |
no_license
|
shadowwalker2718/data_structure_algorithm
|
36bce2394be42f527b28a224f4e5cb49a56c08f6
|
c40ef3212e3f12aee414c7bbd31feb62105853c0
|
refs/heads/master
| 2021-05-01T11:52:29.290761
| 2018-01-23T01:29:25
| 2018-01-23T01:29:25
| 74,696,374
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 802
|
h
|
frequent_element.h
|
#pragma once
#include "henry.h"
namespace _frequent_element {
void frequent_element(vector<int> nums, int k) {
map<int, int> m;
for (int i : nums) {
if (m.size() < k-1)
m[i]++;
else
for (auto it = m.begin(); it != m.end();)
if (--m[it->first] == 0)
it = m.erase(it);
else
++it;
}
if(m.size()>1)
for (auto it = m.begin(); it != m.end();)
if (--m[it->first] == 0)
it = m.erase(it);
else
++it;
for (auto pr : m)
cout << pr.first << "," << pr.second << endl;
}
void test() {
//vector<int> nums = {1,2,3,4,5,6,7,8,9,1,1,1,1};
vector<int> nums = { 1,1,1,2,2,2,3,3,3,4,4,4,4 };
frequent_element(nums, 4);
}
}
|
2e7da48dc8b23f33538b3c1c6dce1773f00cdb82
|
a54188c3302fce4372c30c9fa973394614c2ca33
|
/src/misc/netstorage/object.hpp
|
99fcadab1a2450873b4937f566e402b758a354ac
|
[] |
no_license
|
DmitrySigaev/ncbi
|
5747f36076a80bf4080c09315ab3e95a4ea0dc58
|
088aa1b09693e1b6241582f017f859b8e5600e8a
|
refs/heads/master
| 2021-01-01T05:07:57.992119
| 2016-05-10T18:23:57
| 2016-05-10T18:23:57
| 58,489,985
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,352
|
hpp
|
object.hpp
|
#ifndef MISC_NETSTORAGE___OBJECT__HPP
#define MISC_NETSTORAGE___OBJECT__HPP
/* $Id$
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
* National Center for Biotechnology Information
*
* This software/database is a "United States Government Work" under the
* terms of the United States Copyright Act. It was written as part of
* the author's official duties as a United States Government employee and
* thus cannot be copyrighted. This software/database is freely available
* to the public for use. The National Library of Medicine and the U.S.
* Government have not placed any restriction on its use or reproduction.
*
* Although all reasonable efforts have been taken to ensure the accuracy
* and reliability of the software and data, the NLM and the U.S.
* Government do not and cannot warrant the performance or results that
* may be obtained by using this software or data. The NLM and the U.S.
* Government disclaim all warranties, express or implied, including
* warranties of performance, merchantability or fitness for any particular
* purpose.
*
* Please cite the author in any work or product based on this material.
*
* ===========================================================================
*
* Author: Rafael Sadyrov
*
*/
#include <connect/services/impl/netstorage_impl.hpp>
#include "state.hpp"
BEGIN_NCBI_SCOPE
namespace NDirectNetStorageImpl
{
class CObj : public SNetStorageObjectImpl, private IState, private ILocation
{
public:
CObj(ISelector::Ptr selector, bool relocating = false)
: m_Selector(selector),
m_State(this),
m_Location(this),
m_Relocating(relocating)
{
_ASSERT(m_Selector.get());
}
virtual ~CObj();
ERW_Result Read(void*, size_t, size_t*);
ERW_Result Write(const void*, size_t, size_t*);
void Close();
void Abort();
string GetLoc();
bool Eof();
Uint8 GetSize();
list<string> GetAttributeList() const;
string GetAttribute(const string&) const;
void SetAttribute(const string&, const string&);
CNetStorageObjectInfo GetInfo();
void SetExpiration(const CTimeout&);
string FileTrack_Path();
TUserInfo GetUserInfo();
const TObjLoc& Locator() const;
string Relocate(TNetStorageFlags);
bool Exists();
ENetStorageRemoveResult Remove();
private:
ERW_Result ReadImpl(void*, size_t, size_t*);
bool EofImpl();
ERW_Result WriteImpl(const void*, size_t, size_t*);
void CloseImpl() {}
void AbortImpl() {}
template <class TCaller>
typename TCaller::TReturn MetaMethod(const TCaller& caller);
IState* StartRead(void*, size_t, size_t*, ERW_Result*);
IState* StartWrite(const void*, size_t, size_t*, ERW_Result*);
Uint8 GetSizeImpl();
CNetStorageObjectInfo GetInfoImpl();
bool ExistsImpl();
ENetStorageRemoveResult RemoveImpl();
void SetExpirationImpl(const CTimeout&);
string FileTrack_PathImpl();
TUserInfo GetUserInfoImpl();
bool IsSame(const ILocation* other) const { return To<CObj>(other); }
void RemoveOldCopyIfExists() const;
ISelector::Ptr m_Selector;
IState* m_State;
ILocation* m_Location;
const bool m_Relocating;
};
}
END_NCBI_SCOPE
#endif
|
d64331bc5d8b6d4a32a7427d6ae8ad9559fdce0a
|
dec6eb1e04c123c932be1fe6d1fde095177b866b
|
/ghost/src/3d/TT_Box.cpp
|
9734473a459f8e1b6ec6199a5edb402123c2bad7
|
[] |
no_license
|
yty/ghost
|
62c82dc0c8e4aae40ad15efa342172b62bc84eac
|
fa06d1ec54759a3f2bc72c9a7397484156ec0257
|
refs/heads/master
| 2021-01-22T15:50:48.624059
| 2012-06-18T00:35:27
| 2012-06-18T00:35:27
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,986
|
cpp
|
TT_Box.cpp
|
//
// TT_Box.cpp
// ghost
//
// Created by Thomas Eberwein on 24/04/2012.
// Copyright 2012 __MyCompanyName__. All rights reserved.
//
#include "TT_Box.h"
void TT_Box::build()
{
float h = 1;
mesh.clear();
ofVec3f vertices[] = {
ofVec3f(+h,-h,+h), ofVec3f(+h,-h,-h), ofVec3f(+h,+h,-h), ofVec3f(+h,+h,+h),
ofVec3f(+h,+h,+h), ofVec3f(+h,+h,-h), ofVec3f(-h,+h,-h), ofVec3f(-h,+h,+h),
ofVec3f(+h,+h,+h), ofVec3f(-h,+h,+h), ofVec3f(-h,-h,+h), ofVec3f(+h,-h,+h),
ofVec3f(-h,-h,+h), ofVec3f(-h,+h,+h), ofVec3f(-h,+h,-h), ofVec3f(-h,-h,-h),
ofVec3f(-h,-h,+h), ofVec3f(-h,-h,-h), ofVec3f(+h,-h,-h), ofVec3f(+h,-h,+h),
ofVec3f(-h,-h,-h), ofVec3f(-h,+h,-h), ofVec3f(+h,+h,-h), ofVec3f(+h,-h,-h)
};
mesh.addVertices(vertices,24);
static ofFloatColor colors[] = {
c, c, c, c,
c, c, c, c,
c, c, c, c,
c, c, c, c
};
mesh.addColors( colors, 24 );
static ofVec3f normals[] = {
ofVec3f(+1,0,0), ofVec3f(+1,0,0), ofVec3f(+1,0,0), ofVec3f(+1,0,0),
ofVec3f(0,+1,0), ofVec3f(0,+1,0), ofVec3f(0,+1,0), ofVec3f(0,+1,0),
ofVec3f(0,0,+1), ofVec3f(0,0,+1), ofVec3f(0,0,+1), ofVec3f(0,0,+1),
ofVec3f(-1,0,0), ofVec3f(-1,0,0), ofVec3f(-1,0,0), ofVec3f(-1,0,0),
ofVec3f(0,-1,0), ofVec3f(0,-1,0), ofVec3f(0,-1,0), ofVec3f(0,-1,0),
ofVec3f(0,0,-1), ofVec3f(0,0,-1), ofVec3f(0,0,-1), ofVec3f(0,0,-1)
};
mesh.addNormals(normals,24);
static ofVec2f tex[] = {
ofVec2f(1,0), ofVec2f(0,0), ofVec2f(0,1), ofVec2f(1,1),
ofVec2f(1,1), ofVec2f(1,0), ofVec2f(0,0), ofVec2f(0,1),
ofVec2f(0,1), ofVec2f(1,1), ofVec2f(1,0), ofVec2f(0,0),
ofVec2f(0,0), ofVec2f(0,1), ofVec2f(1,1), ofVec2f(1,0),
ofVec2f(0,0), ofVec2f(0,1), ofVec2f(1,1), ofVec2f(1,0),
ofVec2f(0,0), ofVec2f(0,1), ofVec2f(1,1), ofVec2f(1,0)
};
mesh.addTexCoords(tex,24);
static ofIndexType indices[] = {
0,1,2, // right top left
0,2,3, // right bottom right
4,5,6, // bottom top right
4,6,7, // bottom bottom left
8,9,10, // back bottom right
8,10,11, // back top left
12,13,14, // left bottom right
12,14,15, // left top left
16,17,18, // ... etc
16,18,19,
20,21,22,
20,22,23
};
mesh.addIndices(indices,36);
mesh.setMode(OF_PRIMITIVE_TRIANGLES);
}
void TT_Box::customDraw()
{
drawBox();
}
void TT_Box::drawBox()
{
// ofEnableAlphaBlending();
glEnable(GL_DEPTH_TEST);
glPushMatrix();
ofScale( width,height,depth );
mesh.draw();
glPopMatrix();
// ofDisableAlphaBlending();
glDisable(GL_DEPTH_TEST);
}
void TT_Box::setColor( ofFloatColor _c )
{
// c = ofFloatColor( 0.1,0.1,0.1,0.1);
c = _c;
for (int i=0; i<24; i++) {
mesh.setColor( i, _c );
}
}
ofFloatColor TT_Box::getColor()
{
return c;
}
|
f3184dc3bfeae9b0a72945b05e8e7494062201c3
|
c24fd3736a20c701a8ebe5a5656240a4f49949c7
|
/Source/Teme/Tema2/Obstacle.h
|
27545a4e60aa8244eb1930f03909ba3fdfa4fc6c
|
[
"MIT"
] |
permissive
|
adinasm/EGC
|
546ef2536a2e2623d109633cb53d6cf3da9c9e7b
|
01b51ed98790635bcec723253a771d8b98c09b4b
|
refs/heads/master
| 2021-01-01T02:40:13.477791
| 2020-02-08T15:10:39
| 2020-02-08T15:10:39
| 239,145,456
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 638
|
h
|
Obstacle.h
|
#pragma once
#include <Component/SimpleScene.h>
#include <Core/Engine.h>
class Obstacle
{
public:
Obstacle();
~Obstacle();
int getObstacleCount();
float getObstacleDistanceAngle();
float getRadiusX(int index);
float getRadiusY(int index);
float getAngle(int index);
void setAngle(int index, float value);
float getScale(int index);
void createObstacle();
void deleteObstacle(int i);
private:
float obstacleDistanceAngle;
float minRadiusX;
float maxRadiusX;
float minRadiusY;
float maxRadiusY;
std::vector<float> scales;
std::vector<float> radiusesX;
std::vector<float> radiusesY;
std::vector<float> angles;
};
|
b20bccf22c335cf9e420a93d8b5594247b1fe6b5
|
cb233ee8ca1c0bf530bb00c4edf1cbc7426ba326
|
/vetor3.cpp
|
72517d0d01a6c791b83a0c17c0a635ee9c8f879d
|
[] |
no_license
|
MykeDrn/exercicios-vetor
|
a27c203dd6d2917dd30953abf2df7b8c9b8b9902
|
a8cd1a3e7c670d2b59483d5dbddc483d584c502f
|
refs/heads/main
| 2023-01-22T21:08:23.520509
| 2020-11-22T16:03:30
| 2020-11-22T16:03:30
| 315,076,049
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 401
|
cpp
|
vetor3.cpp
|
#include <iostream>
using namespace std;
int main(){
int n[20] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10}, a, cont = 0, eq = 0;
cout << "informe o numero: ";
cin >> a;
for(cont; cont < 20; cont++){
if(n[cont]==a){
eq++;
}
}
cout << "\no numero informado aparece " << eq << " vezes no vetor n";
}
|
ab4d4e9f100d9d20693764e556b30b7f8de8fb06
|
48d13d5b04dd6f94d67ca68196d778897c71be77
|
/src/rophy/vk/vk_command_buffer_allocator.cc
|
958034f78f43b4a4479f3733a3981c744d0a3145
|
[] |
no_license
|
jaesung-cs/rophy
|
15ca806b1a537cc955ee64eec64b45f0b86200b6
|
29d8f9011ef8a3511e4ecf1f22960130634d01ec
|
refs/heads/master
| 2022-12-09T17:58:11.356417
| 2020-09-06T03:46:08
| 2020-09-06T03:46:08
| 292,987,768
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,532
|
cc
|
vk_command_buffer_allocator.cc
|
#include <rophy/vk/vk_command_buffer_allocator.h>
#include <iostream>
#include <rophy/vk/vk_exception.h>
namespace rophy
{
namespace vk
{
CommandBufferAllocator::CommandBufferAllocator(Device device, CommandPool command_pool)
: device_(device)
, command_pool_(command_pool)
{
allocate_info_.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
allocate_info_.commandPool = *command_pool_;
allocate_info_.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
}
CommandBufferAllocator::~CommandBufferAllocator() = default;
std::vector<CommandBuffer> CommandBufferAllocator::Allocate(int command_buffer_count)
{
allocate_info_.commandBufferCount = static_cast<uint32_t>(command_buffer_count);
// Verbose log
Print(std::cout);
std::cout << std::endl;
std::vector<VkCommandBuffer> command_buffer_handles(command_buffer_count);
VkResult result;
if ((result = vkAllocateCommandBuffers(*device_, &allocate_info_, command_buffer_handles.data())) != VK_SUCCESS)
throw Exception("Failed to allocate command buffer.", result);
std::vector<CommandBuffer> command_buffers;
for (auto command_buffer_handle : command_buffer_handles)
{
auto command_buffer = std::make_shared<impl::CommandBufferImpl>(*device_, allocate_info_.commandPool, command_buffer_handle);
device_->AddChildObject(command_buffer);
command_buffers.push_back(command_buffer);
}
return command_buffers;
}
void CommandBufferAllocator::Print(std::ostream& out) const
{
out
<< "CommandBuffer allocate info" << std::endl;
}
}
}
|
816d3e0d599b147b2831237a9f336023181e54fa
|
1b73c418ede5b941aac33e986e251ebe9683af6a
|
/competitive/Graph 2/djikstra.cpp
|
7e6f1223f48e2d70c171b1f2e74097357c64baae
|
[] |
no_license
|
gauravengine/CPP_Freak
|
492e7478c5e3bcb08e641b160c69e247b21f5503
|
0f98c2cd943d062578cc30839524d1814af0efa3
|
refs/heads/main
| 2023-08-02T04:10:32.720437
| 2021-09-22T09:21:04
| 2021-09-22T09:21:04
| 313,554,738
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,433
|
cpp
|
djikstra.cpp
|
#include<bits/stdc++.h>
using namespace std;
int min_distance(int* distance , bool* visited , int v){
// returns min distance from unvisiteds
int min=-1;
for(int i=0;i<v;i++){
if(!visited[i] && ( min==-1 || distance[i] < distance[min] ) ){
min = i;
}
}
return min;
}
void djikstra(int** edges , int v){
bool * visited = new bool[v]();
int* distance= new int[v];
for(int i=0;i<v;i++) distance[i] = INT_MAX;
int *parent= new int[v];
for(int i=0;i<v;i++) parent[i]=i;
distance[0]=0; // let src be 0
for(int i=0;i<v-1;i++){
int x= min_distance(distance , visited ,v);
visited[x]= true;
for(int j=0;j<v;j++){
if(edges[x][j] > 0 && !visited[j]){
// update distance if greater
if(distance[j] > distance[x] + edges[x][j]){
parent[j]= x;
distance[j] = distance[x] + edges[x][j];
}
}
}
}
for(int i=0;i<v;i++){
cout<<i<<" "<<distance[i]<<"\n";
}
cout<<"printing parent array :"<<endl;
for(int i=0;i<v;i++){
cout<<"parent of "<<i<<" : "<<parent[i]<<endl;
}
}
int main(){
int v,e;
cin>>v>>e;
int** edges = new int* [v];
for(int i=0 ;i<v ;i++){
edges[i]= new int[v];
for (int j = 0; j < v; j++)
{
edges[i][j]=0;
}
}
// taking edges and weight now
for(int i=0;i<e;i++){
int src,des,weight;
cin>>src>>des>>weight;
edges[src][des]= weight;
edges[des][src]= weight;
}
// lets use functions
djikstra(edges , v);
return 0;
}
|
b9e055749b688f29ecb5132a631092e98447e0d9
|
edab58696afb07657232f17490b24c8e1e11b6c2
|
/miscellanious/bfs_weighted_faster.cpp
|
6d6782b44bef50731af0bef59a02717e08ce25e6
|
[] |
no_license
|
mhcayan/competitive-programming
|
cd8e08da67138cfbdcd2d47cd70572a7fc6435fd
|
f80ab6929a5d2eb780d35679688ea39138cf9e8a
|
refs/heads/master
| 2022-05-27T15:03:46.147224
| 2022-05-22T00:21:29
| 2022-05-22T00:21:29
| 161,851,714
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,063
|
cpp
|
bfs_weighted_faster.cpp
|
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
//#define push_back pb
#define SIZE 200
const int inf=2000000000;
long count1,count2;
vector<long>edge[SIZE],cost[SIZE];
long bfs(long s,long d,long n)
{
long dis[10000],status[10000],i,u,v;
for(i=0;i<=n;i++)
{
status[i]=0;
dis[i]=inf;
}
queue<long>q;
q.push(s);
status[s]=1;
dis[s]=0;
while(!q.empty())
{
count1++;
u=q.front();
status[u]=0;
q.pop();
for(i=0;i<edge[u].size();i++)
{
v=edge[u][i];
if(dis[v]>dis[u]+cost[u][i])
{
dis[v]=dis[u]+cost[u][i];
if(status[v]==0)
{
q.push(v);
count2++;
status[v]=1;
}
}
}
}
return dis[d];
}
int main()
{
long s,d,u,v,n,e,i,c;
while(scanf("%ld %ld",&n,&e)==2)
{
count1=count2=0;
for(i=0;i<e;i++)
{
scanf("%ld %ld %ld",&u,&v,&c);
edge[u].push_back(v);
edge[v].push_back(u);
cost[u].push_back(c);
cost[v].push_back(c);
}
scanf("%ld %ld",&s,&d);
printf("%ld\n",bfs(s,d,n));
printf("complexity:\n%ld %ld\n",count1,count2);
}
return 0;
}
|
3a02a5c0ca847b8729e1294e0c56265b2f392da6
|
66b3ef6a474b25487b52c28d6ab777c4bff82431
|
/old/v2/src/mouse/mackAlgoTwo/Maze.cpp
|
fe84ba7068cfbc36be45b3b179570b8d17ddf3a8
|
[
"MIT"
] |
permissive
|
mackorone/mms
|
63127b1aa27658e4d6ee88d3aefc9969b11497de
|
9ec759a32b4ff882f71ad4315cf9abbc575b30a1
|
refs/heads/main
| 2023-07-20T06:10:47.377682
| 2023-07-17T01:08:53
| 2023-07-17T01:29:31
| 14,811,400
| 281
| 73
|
MIT
| 2023-07-08T09:59:59
| 2013-11-29T22:36:30
|
C++
|
UTF-8
|
C++
| false
| false
| 2,255
|
cpp
|
Maze.cpp
|
#include "Maze.h"
namespace mackAlgoTwo {
byte Maze::m_data[] = {0};
Info Maze::m_info[] = {0};
byte Maze::getX(byte cell) {
return cell / HEIGHT;
}
byte Maze::getY(byte cell) {
return cell % HEIGHT;
}
byte Maze::getCell(byte x, byte y) {
return x * HEIGHT + y;
}
bool Maze::isKnown(byte x, byte y, byte direction) {
return isKnown(getCell(x, y), direction);
}
bool Maze::isWall(byte x, byte y, byte direction) {
return isWall(getCell(x, y), direction);
}
void Maze::setWall(byte x, byte y, byte direction, bool isWall) {
setWall(getCell(x, y), direction, isWall);
}
void Maze::unsetWall(byte x, byte y, byte direction) {
unsetWall(getCell(x, y), direction);
}
bool Maze::isKnown(byte cell, byte direction) {
return (m_data[cell] >> direction + 4) & 1;
}
bool Maze::isWall(byte cell, byte direction) {
return (m_data[cell] >> direction) & 1;
}
void Maze::setWall(byte cell, byte direction, bool isWall) {
m_data[cell] |= 1 << direction + 4;
m_data[cell] =
(m_data[cell] & ~(1 << direction)) | (isWall ? 1 << direction : 0);
}
void Maze::unsetWall(byte cell, byte direction) {
m_data[cell] &= ~(1 << direction + 4);
m_data[cell] &= ~(1 << direction);
}
twobyte Maze::getDistance(byte cell) {
return m_info[cell].distance;
}
void Maze::setDistance(byte cell, twobyte distance) {
m_info[cell].distance = distance;
}
bool Maze::getDiscovered(byte cell) {
return m_info[cell].misc & 1;
}
void Maze::setDiscovered(byte cell, bool discovered) {
m_info[cell].misc = (m_info[cell].misc & ~1) | (discovered ? 1 : 0);
}
bool Maze::hasNext(byte cell) {
return m_info[cell].misc & 2;
}
void Maze::clearNext(byte cell) {
m_info[cell].misc &= ~2;
}
byte Maze::getNextDirection(byte cell) {
return m_info[cell].misc >> 2 & 3;
}
void Maze::setNextDirection(byte cell, byte nextDirection) {
m_info[cell].misc |= 2;
m_info[cell].misc = (m_info[cell].misc & ~12) | (nextDirection << 2);
}
byte Maze::getStraightAwayLength(byte cell) {
return m_info[cell].misc >> 4 & 15;
}
void Maze::setStraightAwayLength(byte cell, byte straightAwayLength) {
m_info[cell].misc = (m_info[cell].misc & 15) | (straightAwayLength << 4);
}
} // namespace mackAlgoTwo
|
c381c71e23d37787980747da412f0a2676951e62
|
fe05f22c9e6be4ab8d7e1e3971c1b69102f31d1c
|
/lib/vfs/zdos.cc
|
aa47bb7ae89ca4b016c47fd5a61d7076dd79b83d
|
[
"MIT",
"GPL-2.0-only",
"LicenseRef-scancode-public-domain",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"Unlicense"
] |
permissive
|
davidgiven/fluxengine
|
53b3d5447c69b8fa9d04ccc5481f662e2554dc5a
|
9e61670116f6ececa3e51acfc50b196f74df5bb3
|
refs/heads/master
| 2023-09-01T08:05:34.560835
| 2023-08-20T20:00:51
| 2023-08-20T20:00:51
| 149,908,319
| 309
| 70
|
MIT
| 2023-08-20T20:01:44
| 2018-09-22T19:05:57
|
C++
|
UTF-8
|
C++
| false
| false
| 9,115
|
cc
|
zdos.cc
|
#include "lib/globals.h"
#include "lib/vfs/vfs.h"
#include "lib/config.pb.h"
#include "lib/layout.h"
#include <iomanip>
/* See
* https://oldcomputers.dyndns.org/public/pub/rechner/zilog/zds/manuals/z80-rio_os_userman.pdf,
* page 116. */
enum
{
ZDOS_TYPE_DATA = 0x10,
ZDOS_TYPE_ASCII = 0x20,
ZDOS_TYPE_DIRECTORY = 0x40,
ZDOS_TYPE_PROCEDURE = 0x80
};
enum
{
ZDOS_MODE_FORCE = 1 << 2,
ZDOS_MODE_RANDOM = 1 << 3,
ZDOS_MODE_SECRET = 1 << 4,
ZDOS_MODE_LOCKED = 1 << 5,
ZDOS_MODE_ERASEPROTECT = 1 << 6,
ZDOS_MODE_WRITEPROTECT = 1 << 7
};
static const std::map<uint8_t, std::string> fileTypeMap = {
{0, "INVALID" },
{ZDOS_TYPE_DATA, "DATA" },
{ZDOS_TYPE_ASCII, "ASCII" },
{ZDOS_TYPE_DIRECTORY, "DIRECTORY"},
{ZDOS_TYPE_PROCEDURE, "PROCEDURE"}
};
static std::string convertTime(std::string zdosTime)
{
/* Due to a bug in std::get_time, we can't parse the string directly --- a
* pattern of %y%m%d causes the first four digits of the string to become
* the year. So we need to reform the string. */
zdosTime = fmt::format("{}-{}-{}",
zdosTime.substr(0, 2),
zdosTime.substr(2, 2),
zdosTime.substr(4, 2));
std::tm tm = {};
std::stringstream(zdosTime) >> std::get_time(&tm, "%y-%m-%d");
std::stringstream ss;
ss << std::put_time(&tm, "%FT%T%z");
return ss.str();
}
class ZDosFilesystem : public Filesystem
{
class ZDosDescriptor
{
public:
ZDosDescriptor(ZDosFilesystem* zfs, int block): zfs(zfs)
{
Bytes bytes = zfs->getLogicalSector(block);
ByteReader br(bytes);
br.seek(8);
firstRecord = zfs->readBlockNumber(br);
br.seek(12);
type = br.read_8();
recordCount = br.read_le16();
recordSize = br.read_le16();
br.seek(19);
properties = br.read_8();
startAddress = br.read_le16();
lastRecordSize = br.read_le16();
br.seek(24);
ctime = br.read(8);
mtime = br.read(8);
rewind();
}
void rewind()
{
currentRecord = firstRecord;
eof = false;
}
Bytes readRecord()
{
assert(!eof);
int count = recordSize / 0x80;
Bytes result;
ByteWriter bw(result);
while (count--)
{
Bytes sector = zfs->getLogicalSector(currentRecord);
ByteReader br(sector);
bw += br.read(0x80);
br.skip(2);
int sectorId = br.read_8();
int track = br.read_8();
currentRecord = zfs->toBlockNumber(sectorId, track);
if (sectorId == 0xff)
eof = true;
}
return result;
}
public:
ZDosFilesystem* zfs;
uint16_t firstRecord;
uint8_t type;
uint16_t recordCount;
uint16_t recordSize;
uint8_t properties;
uint16_t startAddress;
uint16_t lastRecordSize;
std::string ctime;
std::string mtime;
uint16_t currentRecord;
bool eof;
};
class ZDosDirent : public Dirent
{
public:
ZDosDirent(ZDosFilesystem* zfs,
const std::string& filename,
int descriptorBlock):
zfs(zfs),
descriptorBlock(descriptorBlock),
zd(zfs, descriptorBlock)
{
file_type = TYPE_FILE;
this->filename = filename;
length = (zd.recordCount - 1) * zd.recordSize + zd.lastRecordSize;
mode = "";
if (zd.properties & ZDOS_MODE_FORCE)
mode += 'F';
if (zd.properties & ZDOS_MODE_RANDOM)
mode += 'R';
if (zd.properties & ZDOS_MODE_SECRET)
mode += 'S';
if (zd.properties & ZDOS_MODE_LOCKED)
mode += 'L';
if (zd.properties & ZDOS_MODE_ERASEPROTECT)
mode += 'E';
if (zd.properties & ZDOS_MODE_WRITEPROTECT)
mode += 'W';
path = {filename};
attributes[Filesystem::FILENAME] = filename;
attributes[Filesystem::LENGTH] = std::to_string(length);
attributes[Filesystem::FILE_TYPE] = "file";
attributes[Filesystem::MODE] = mode;
attributes["zdos.descriptor_record"] =
std::to_string(descriptorBlock);
attributes["zdos.first_record"] = std::to_string(zd.firstRecord);
attributes["zdos.record_size"] = std::to_string(zd.recordSize);
attributes["zdos.record_count"] = std::to_string(zd.recordCount);
attributes["zdos.last_record_size"] =
std::to_string(zd.lastRecordSize);
attributes["zdos.start_address"] =
fmt::format("0x{:04x}", zd.startAddress);
attributes["zdos.type"] = fileTypeMap.at(zd.type & 0xf0);
attributes["zdos.ctime"] = convertTime(zd.ctime);
attributes["zdos.mtime"] = convertTime(zd.mtime);
}
public:
ZDosFilesystem* zfs;
int descriptorBlock;
ZDosDescriptor zd;
};
public:
ZDosFilesystem(
const ZDosProto& config, std::shared_ptr<SectorInterface> sectors):
Filesystem(sectors),
_config(config)
{
}
uint32_t capabilities() const
{
return OP_GETFSDATA | OP_LIST | OP_GETFILE | OP_GETDIRENT;
}
FilesystemStatus check() override
{
return FS_OK;
}
std::map<std::string, std::string> getMetadata() override
{
mount();
std::map<std::string, std::string> attributes;
attributes[VOLUME_NAME] = "";
attributes[TOTAL_BLOCKS] = std::to_string(_totalBlocks);
attributes[USED_BLOCKS] = std::to_string(_usedBlocks);
attributes[BLOCK_SIZE] = "128";
return attributes;
}
std::shared_ptr<Dirent> getDirent(const Path& path) override
{
mount();
if (path.size() != 1)
throw BadPathException();
return findFile(path.front());
}
std::vector<std::shared_ptr<Dirent>> list(const Path& path) override
{
mount();
if (!path.empty())
throw FileNotFoundException();
std::vector<std::shared_ptr<Dirent>> result;
for (auto& de : _dirents)
result.push_back(de);
return result;
}
Bytes getFile(const Path& path) override
{
mount();
if (path.size() != 1)
throw BadPathException();
auto dirent = findFile(path.front());
dirent->zd.rewind();
Bytes bytes;
ByteWriter bw(bytes);
while (!dirent->zd.eof)
{
bw += dirent->zd.readRecord();
}
return bytes.slice(0, dirent->length);
}
private:
void mount()
{
_sectorsPerTrack = Layout::getLayoutOfTrack(0, 0)->numSectors;
int rootBlock = toBlockNumber(_config.filesystem_start().sector(),
_config.filesystem_start().track());
ZDosDescriptor zd(this, rootBlock);
if (zd.type != ZDOS_TYPE_DIRECTORY)
throw BadFilesystemException();
_totalBlocks = getLogicalSectorCount();
_usedBlocks = (zd.recordCount * zd.recordSize) / 0x80 + 1;
while (!zd.eof)
{
Bytes bytes = zd.readRecord();
ByteReader br(bytes);
for (;;)
{
int len = br.read_8();
if (len == 0xff)
break;
std::string filename = br.read(len & 0x7f);
int descriptorBlock = readBlockNumber(br);
auto dirent = std::make_unique<ZDosDirent>(
this, filename, descriptorBlock);
_usedBlocks +=
(dirent->zd.recordCount * dirent->zd.recordSize) / 0x80 + 1;
_dirents.push_back(std::move(dirent));
}
}
}
std::shared_ptr<ZDosDirent> findFile(const std::string filename)
{
for (const auto& dirent : _dirents)
{
if (dirent->filename == filename)
return dirent;
}
throw FileNotFoundException();
}
int toBlockNumber(int sectorId, int track)
{
return track * _sectorsPerTrack + sectorId;
}
int readBlockNumber(ByteReader& br)
{
int sectorId = br.read_8();
int track = br.read_8();
return toBlockNumber(sectorId, track);
}
private:
const ZDosProto& _config;
unsigned _sectorsPerTrack;
unsigned _totalBlocks;
unsigned _usedBlocks;
std::vector<std::shared_ptr<ZDosDirent>> _dirents;
};
std::unique_ptr<Filesystem> Filesystem::createZDosFilesystem(
const FilesystemProto& config, std::shared_ptr<SectorInterface> sectors)
{
return std::make_unique<ZDosFilesystem>(config.zdos(), sectors);
}
|
f30bc114a946a41740fcfdbd523e18c36f799c54
|
cb80a8562d90eb969272a7ff2cf52c1fa7aeb084
|
/inletTest10/0.028/k
|
6d39c0f74b766b95c428072cda86cd287cdfbda4
|
[] |
no_license
|
mahoep/inletCFD
|
eb516145fad17408f018f51e32aa0604871eaa95
|
0df91e3fbfa60d5db9d52739e212ca6d3f0a28b2
|
refs/heads/main
| 2023-08-30T22:07:41.314690
| 2021-10-14T19:23:51
| 2021-10-14T19:23:51
| 314,657,843
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 96,201
|
k
|
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0.028";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
11076
(
145.807
145.807
145.807
145.807
145.809
145.811
145.814
145.815
145.81
145.755
145.569
145.228
144.772
144.253
143.708
143.154
142.593
142.023
141.44
140.839
140.218
139.579
138.919
138.242
137.548
136.839
136.115
135.378
134.63
133.872
133.105
132.33
131.55
130.765
129.978
129.19
128.402
127.617
126.835
126.06
125.291
124.532
123.783
123.046
122.323
121.615
120.924
120.253
119.601
118.97
118.36
117.767
117.187
116.614
116.05
115.509
115.035
114.696
114.533
114.508
114.543
114.596
114.643
114.663
114.68
114.611
114.414
114.059
113.496
112.315
110.384
100.181
88.9329
105.149
110.887
107.768
97.712
79.83
72.8702
91.6065
104.316
100.311
85.2341
67.0518
62.8451
80.7686
96.8663
92.9914
75.838
59.1395
56.4287
72.5389
90.1053
86.6924
68.9709
53.9058
52.1575
66.9012
84.4638
81.5133
64.0904
50.334
49.1172
62.7609
79.832
77.3129
60.5463
47.7293
46.824
59.6285
75.9795
73.8009
57.833
45.7228
45.0105
57.1562
72.719
70.8057
55.6743
44.107
43.5175
55.1275
69.9078
68.2035
53.8836
42.7502
42.2457
53.4264
67.4463
65.9085
52.3519
41.5759
41.132
51.9586
65.2569
63.861
51.0107
40.5338
40.1339
50.6634
63.28
62.0115
49.8113
39.5891
39.2218
49.4993
61.4852
60.3228
48.7228
38.7179
38.3754
48.4384
59.8406
58.7663
47.7222
37.9034
37.58
47.4597
58.3213
57.3219
46.7925
37.1332
36.8248
46.5477
56.9082
55.9728
45.9208
36.3981
36.1013
45.6904
55.5859
54.7054
45.0969
35.6907
35.4028
44.8781
54.3417
53.5092
44.3124
35.005
34.7239
44.1032
53.1658
52.3761
43.5609
34.3362
34.0601
43.3597
52.0508
51.2992
42.8375
33.6801
33.4073
42.6429
50.9899
50.2722
42.1376
33.0331
32.7624
41.9483
49.977
49.2895
41.4572
32.392
32.1221
41.272
49.0065
48.3455
40.7925
31.754
31.4837
40.6103
48.0732
47.4354
40.1399
31.1163
30.8444
39.9597
47.1724
46.5549
39.4961
30.4762
30.2019
39.3171
46.2999
45.7002
38.8583
29.8315
29.5537
38.6794
45.4519
44.8672
38.2234
29.1801
28.898
38.0439
44.6245
44.0524
37.5887
28.5197
28.2325
37.4078
43.8142
43.2527
36.9519
27.8485
27.5552
36.7687
43.0181
42.4649
36.3101
27.1639
26.8633
36.1237
42.2327
41.6854
35.6603
26.4636
26.1552
35.47
41.4544
40.9106
35.0005
25.7465
25.4298
34.8059
40.68
40.1383
34.3289
25.0106
24.684
34.1286
39.9076
39.3662
33.6418
24.253
23.9164
33.4352
39.1339
38.5903
32.9375
23.474
23.1278
32.7249
38.3559
37.8093
32.2161
22.6731
22.3162
31.9961
37.5722
37.0206
31.4736
21.8487
21.4821
31.2461
36.7793
36.2198
30.7099
21.0035
20.6279
30.4756
35.9752
35.4115
29.9267
20.1367
19.7514
29.6846
35.1643
34.5934
29.1206
19.2489
18.8582
28.872
34.3394
33.7559
28.2956
18.3496
17.9532
28.0413
33.4996
32.9137
27.4536
17.4366
17.0374
27.1941
32.6558
32.0619
26.5992
16.5214
16.1272
26.3381
31.7971
31.1939
25.7392
15.6133
15.2202
25.4755
30.9342
30.3394
24.875
14.7146
14.3407
24.6176
30.0779
29.4766
24.0318
13.86
13.5074
23.7828
29.2168
28.6265
23.2086
13.0438
12.713
22.9676
28.383
27.8174
22.4177
12.2885
12.002
22.2003
27.5804
27.0279
21.6917
11.6224
11.3763
21.494
26.8066
26.2838
21.0165
11.042
10.8422
20.8393
26.0842
25.603
20.4089
10.5675
10.4201
20.2618
25.425
24.9868
19.8855
10.2045
10.1074
19.7629
24.8353
24.4459
19.4317
9.94784
9.89199
19.33
24.316
23.9742
19.048
9.78768
9.76935
18.9504
23.8592
23.5532
18.6742
9.72034
9.71873
18.5754
23.4495
23.1615
18.3
9.69548
9.70392
18.2095
23.0634
22.7875
17.9537
9.69457
9.71163
17.8721
22.6903
22.4274
17.6365
9.71073
9.732
17.5637
22.3374
22.0934
17.3517
9.74014
9.77237
17.2887
22.0137
21.7826
17.0953
9.7867
9.83048
17.0419
21.7044
21.471
16.8615
9.84389
9.878
16.808
21.3904
21.1687
16.6356
9.88491
9.9074
16.59
21.1056
20.9175
16.4433
9.92007
9.95556
16.4152
20.8678
20.7032
16.2953
9.97236
10.0123
16.2726
20.6552
20.4941
16.1584
10.0275
10.066
16.1394
20.4489
20.302
16.0389
10.0752
10.0977
16.0215
20.2659
20.1309
15.9289
10.111
10.1464
15.92
20.0993
19.976
15.8469
10.1665
10.2029
15.8404
19.9469
19.8306
15.7702
10.2165
10.2355
15.7574
19.7936
19.6721
15.6761
10.2368
10.2464
15.666
19.6429
19.5292
15.5902
10.2493
10.2678
15.5873
19.5132
19.4066
15.5311
10.2838
10.3138
15.5156
19.3674
19.2835
15.4807
10.3591
10.3572
15.4519
19.2079
19.2001
15.4242
10.4032
10.5171
15.5668
19.3841
19.595
15.7671
10.6374
26.8379
33.7868
40.1642
46.2606
51.3086
56.6743
60.9029
64.6838
67.7461
70.3574
72.4105
73.9614
74.9297
75.3471
75.1013
74.0922
72.2168
69.2638
65.9
60.9408
52.9786
46.3321
38.8549
30.6393
22.7097
19.557
12.6546
12.5784
18.7999
21.996
21.5787
18.6275
12.3426
11.9631
18.1799
21.0294
21.0093
18.308
11.7829
11.7911
18.3957
21.1974
21.0909
18.1864
11.7438
11.8733
18.387
21.5242
21.4221
18.2409
11.8639
12.0246
18.5958
21.8607
21.7746
18.4564
12.0047
12.1501
18.7856
22.2156
22.1164
18.6498
12.124
12.2686
18.9805
22.5719
22.4798
18.8379
12.2413
12.3792
19.1862
22.9566
22.8527
19.0491
12.3525
12.5071
19.4039
23.3408
23.2423
19.2578
12.4858
12.6448
19.6288
23.7516
23.6466
19.4837
12.6263
12.798
19.8677
24.1847
24.0864
19.7194
12.7832
12.9594
20.1305
24.6619
24.5597
19.9851
12.9459
13.1341
20.4042
25.1604
25.0581
20.2574
13.1237
13.3168
20.7044
25.6804
25.5668
20.563
13.308
13.5066
21.0153
26.2079
26.1003
20.8587
13.4958
13.6928
21.3266
26.7664
26.6588
21.1683
13.6812
13.8787
21.6478
27.3485
27.2296
21.4898
13.8661
14.0765
21.9791
27.9608
27.8435
21.8198
14.066
14.279
22.3355
28.6032
28.4779
22.1755
14.271
14.4969
22.7068
29.2788
29.1492
22.5462
14.4922
14.7304
23.0962
29.9762
29.8495
22.9245
14.7288
14.9753
23.4985
30.7036
30.5693
23.3215
14.977
15.2327
23.8938
31.4512
31.2951
23.7185
15.2343
15.5001
24.2935
32.2187
32.0736
24.0927
15.5066
15.7864
24.6596
33.0047
32.8303
24.4505
15.7986
16.0974
25.0003
33.8129
33.6525
24.7617
16.127
16.4579
25.316
34.6734
34.4818
25.0744
16.5161
16.9076
25.6325
35.5905
35.4051
25.3812
17.0334
17.4975
25.978
36.5972
36.3833
25.7237
17.697
18.1764
26.3965
37.7652
37.4718
26.0693
18.3175
18.6878
26.8694
39.0331
38.6432
26.3655
18.641
18.8324
27.0764
40.1189
39.7053
26.6161
18.7592
18.9156
27.3061
41.3516
40.9427
26.6636
18.8453
19.0298
27.3115
42.5829
42.3381
26.8539
18.9489
19.2288
27.7273
44.3237
44.2728
27.4996
19.4639
20.2705
29.1559
47.1599
47.6179
29.451
21.2933
23.7936
31.961
52.4023
54.9176
32.8052
26.8753
31.9966
39.4823
70.6615
82.8494
51.3486
35.6249
40.5014
68.8211
94.3921
98.6246
68.6546
40.088
42.0826
64.7533
91.3449
105.187
75.7879
46.4329
50.1674
82.9186
110.925
120.1
92.0419
53.851
57.4354
98.8278
126.529
134.773
107.851
61.3237
64.7661
116.044
142.087
151.087
124.973
67.9731
70.1572
129.501
155.169
153.647
128.709
70.1378
76.3907
139.458
163.562
170.731
147.657
79.7712
83.4791
154.938
178.178
181.397
157.248
82.9816
81.6748
154.296
178.927
181.593
156.572
82.287
85.516
158.797
181.81
190.8
168.523
92.4731
101.001
178.623
198.846
208.227
188.764
108.788
114.997
195.795
214.01
216.205
200.448
121.066
131.708
209.6
223.195
229.493
219.989
142.875
150.955
224.95
230.887
229.994
226.169
159.072
166.717
226.394
226.394
222.14
224.87
173.086
177.296
221.222
216.921
207.189
215.537
180.669
181.697
209.084
200.164
197.64
205.42
181.143
180.395
204.15
197.091
197.252
204.092
178.562
176.939
206.447
199.144
203.809
206.525
173.668
170.662
205.231
208.221
208.009
197.771
167.563
164.613
192.543
208.553
203.858
182.417
161.45
158.239
169.571
185.951
184.478
162.962
154.385
150.691
154.898
174.833
154.752
145.898
145.92
141.274
138.966
156.311
149.491
132.149
135.899
130.644
124.425
133.152
137.721
117.561
124.473
118.751
112.988
130.439
115.675
103.364
112.396
106.38
103.97
129.775
121.655
96.9831
100.187
94.804
98.6289
137.185
128.736
93.53
89.5775
84.6503
88.9328
119.11
100.257
81.4121
79.5265
74.4096
81.28
108.616
106.213
78.5444
70.2402
65.6195
71.1713
89.5846
100.184
73.0504
61.9645
58.7326
69.7165
92.8342
85.7191
64.5002
55.4802
52.3723
57.3402
71.4982
79.9094
58.6089
48.8869
47.4197
56.7535
75.5953
57.6716
45.5031
43.9468
40.0006
41.7571
65.5068
52.6918
36.7017
37.7898
35.9545
33.3505
45.982
31.4576
27.0973
31.6929
31.3001
33.1573
41.0029
38.3848
31.1787
30.8465
29.9637
25.1431
26.6218
40.0366
31.5987
30.6089
30.7888
28.7948
35.3119
31.4103
26.3476
30.5567
31.3057
22.3964
23.0142
33.4856
26.6287
28.7346
29.1893
24.9035
31.4437
22.171
21.7283
29.8384
28.1324
26.0177
33.0237
30.4658
24.7804
28.5306
29.8882
21.7614
21.7957
32.4451
25.9562
28.0135
28.6912
24.5567
30.0332
21.7966
21.6798
30.335
28.3864
25.8051
32.0693
28.5247
23.8772
29.2121
30.2482
22.3773
25.471
20.2171
20.8839
32.2684
27.8515
22.5177
26.6684
25.0105
21.3168
28.6003
31.0487
20.0064
19.4242
25.3642
21.4386
27.0081
27.8817
20.6888
23.4328
18.7046
19.5359
30.6465
26.5173
20.184
23.3908
22.0661
19.7811
27.618
30.8531
19.0647
17.7543
22.594
19.5272
26.632
28.0552
19.1668
21.4072
17.5125
18.6723
31.6154
26.7936
18.5591
21.1556
20.3914
18.2674
28.573
32.6042
18.434
17.0468
20.4291
18.6354
27.4134
29.9602
18.3699
17.306
23.3066
19.2539
26.2045
27.914
19.0678
21.5349
17.6573
19.0853
31.354
26.8738
19.5516
22.3791
20.9735
19.3915
28.5136
32.1896
19.549
17.6629
22.08
19.5847
27.5066
29.3686
19.2562
20.362
18.0996
20.2439
33.4123
28.1495
19.1182
20.5947
19.234
18.7143
30.1395
34.3645
21.3678
17.7516
19.7469
18.1149
29.0607
32.6003
19.7492
17.6732
20.635
18.6192
28.0535
30.7767
18.0426
19.0415
17.5237
21.163
34.8101
29.136
18.1908
18.9884
17.9538
17.4538
31.9643
36.3648
21.5491
16.9542
18.0524
17.3004
29.6907
33.6976
19.7184
16.7599
18.6451
17.399
28.4163
31.2713
16.9657
17.4424
16.7049
21.0375
35.502
29.4667
17.659
17.9748
16.8938
17.2957
32.5037
37.369
22.3803
16.8557
17.5468
17.0511
30.4945
35.2771
20.4514
16.5839
18.0281
17.5275
29.5099
32.7959
17.2711
16.7666
16.9383
23.0361
37.7211
30.824
16.9512
17.0522
16.4096
20.5996
35.7745
29.8345
17.4241
17.6873
16.6494
17.3912
33.1184
38.323
22.9345
16.883
17.6976
18.004
31.4929
34.9006
18.0867
16.4647
17.3515
24.8144
40.479
32.8188
16.9326
16.5652
16.4121
21.7041
38.4606
31.7725
17.3179
17.2034
15.9851
17.3392
35.7856
41.7164
25.1353
17.0109
16.0669
16.7379
33.5308
39.4798
21.6055
16.0615
16.6639
16.8317
32.1696
36.1397
17.0372
15.6094
16.8829
25.591
42.229
33.7846
16.6709
15.936
16.1091
22.2024
40.1885
32.9942
17.0847
16.8157
15.736
17.4473
37.1811
43.8143
26.4737
17.2196
16.1378
16.9517
35.1093
41.8218
22.9106
16.3592
16.7281
17.1231
33.8835
38.2933
17.6151
15.6905
17.4562
27.5416
45.4732
36.4571
17.342
16.3146
16.7028
23.7867
43.4693
35.2349
17.5479
17.095
16.0419
18.1229
39.9628
47.5459
28.6814
17.9858
16.649
17.7907
37.9757
45.5558
24.5459
17.0646
17.2661
17.8123
36.7768
41.6426
18.472
16.2645
18.4191
29.9205
49.4407
39.4401
18.3166
17.0199
17.5982
25.6513
47.3936
38.3178
18.4052
17.784
16.7368
19.1431
43.5195
51.9104
31.3031
19.1037
17.4663
18.9033
41.101
49.4407
26.6884
18.0912
18.0844
18.7868
39.5257
44.9405
19.6736
17.0595
19.597
32.2909
53.6968
42.7356
19.3998
17.8776
18.703
27.9298
51.5317
41.3372
19.4357
18.6053
17.5583
20.3561
47.0677
56.3879
33.86
20.349
18.4467
20.0958
44.7835
54.0552
28.8882
19.3262
19.0072
19.891
43.1374
49.0697
20.8459
17.9407
20.9699
35.0691
58.7715
46.6025
20.6903
18.9497
20.046
30.364
56.3856
44.9908
20.6141
19.589
18.5326
21.7236
51.2887
61.6389
36.7516
21.7883
19.5921
21.4686
48.6886
58.9378
31.5239
20.7726
20.0956
21.2148
46.8858
53.3881
22.2888
19.0091
22.504
38.2404
64.17
50.4663
22.2459
20.2061
21.6273
33.2472
61.2484
48.797
22.0742
20.8213
19.7449
23.3546
55.8089
67.3134
39.9218
23.4742
20.9456
23.0768
53.0179
64.224
34.1278
22.3664
21.3683
22.6484
50.8305
57.9175
23.9047
20.2534
24.2532
41.331
69.7739
55.0652
23.8249
21.5882
23.289
36.0349
67.0163
53.4077
23.6638
22.2019
21.0801
24.9984
60.9145
73.441
43.5402
25.4995
22.3911
24.8535
57.6293
69.9533
37.2124
24.1551
22.8591
24.3733
55.2723
62.9607
25.7184
21.7129
26.3924
45.1032
76.2286
59.9488
25.8001
23.1987
25.2126
39.1674
72.9036
57.9638
25.4514
23.8153
22.6719
27.0049
66.1378
79.8126
46.9734
27.6284
24.0611
26.7524
62.715
76.246
40.5586
26.1125
24.6023
26.3537
59.7297
67.9921
27.7799
23.3688
27.9553
48.1287
82.3923
64.7106
28.3742
24.9756
24.1136
29.504
73.7698
89.3482
51.9689
30.1702
25.3966
28.5709
69.2026
83.9684
44.1545
28.2124
25.7883
27.8895
65.7342
74.9473
29.4276
24.5591
30.8956
53.2643
91.0675
70.7361
29.5192
26.0307
28.9897
45.8025
86.0963
67.4469
28.7772
26.6299
25.4608
30.7049
76.76
92.6399
54.185
31.285
26.9224
31.1503
72.6271
82.6897
31.9498
25.9698
33.4474
58.4769
101.325
78.0532
31.3195
27.405
31.4154
49.9
95.1626
74.0249
30.3924
27.6168
26.4841
32.4936
84.2877
101.757
58.6389
33.3388
27.8538
32.8434
79.05
89.961
33.7674
26.9197
35.2773
62.5848
109.959
84.046
32.7717
28.4841
33.1411
53.7039
102.705
79.4101
31.9099
28.6905
27.6893
34.2738
90.326
109.065
63.0309
35.2611
29.2517
34.7617
84.4049
96.4514
36.2472
28.3599
37.6431
66.4692
117.801
90.2586
34.7919
30.1329
35.6403
57.9324
110.642
85.6765
34.0771
30.2315
29.2171
36.3985
97.4111
117.741
67.3192
37.5572
30.7885
36.8981
90.7338
103.419
38.3735
29.8399
39.1441
71.0471
126.359
96.5502
38.0812
31.5635
30.4844
39.4058
109.772
133.628
74.2826
40.4403
32.1614
39.1681
101.345
114.913
40.9274
31.1597
42.1153
78.1338
139.068
105.457
40.715
33.0448
31.9228
41.1229
118.967
146.327
81.1249
43.6542
33.7201
41.6964
110.148
125.04
43.4411
32.6411
44.9939
83.7256
151.258
114.012
42.9793
34.5569
33.3782
44.3844
129.463
157.569
86.1185
46.1657
35.0696
43.385
118.44
134.621
45.2688
33.9342
47.5492
89.5949
163.399
122.629
45.3798
36.0174
34.8453
46.6035
138.619
167.673
91.4045
48.6121
36.7378
45.5387
124.18
141.001
47.6758
35.5362
49.9868
95.2062
173.341
129.466
47.8679
37.791
36.5529
48.9287
145.875
176.493
94.53
49.8495
38.27
47.7669
131.052
144.299
52.3301
36.9151
36.6297
58.7908
166.806
202.272
111.754
56.4726
40.5318
52.8458
149.161
166.923
59.7991
39.4943
38.543
58.2074
185.53
225.773
120.2
60.1207
41.2935
54.696
162.805
178.622
60.2533
40.099
39.6352
65.4123
203.058
239.988
127.897
63.5291
43.0047
57.5005
173.74
194.133
64.1855
41.4291
40.3338
65.4977
217.757
256.129
129.207
62.6682
42.8016
56.7949
176.306
198.943
60.606
40.9826
39.5895
63.067
218.674
247.182
79.3181
40.7765
39.0499
74.7325
263.168
306.075
157.5
70.4706
45.0681
64.5722
209.752
230.333
61.458
42.4145
42.3227
78.462
253.025
276.446
73.9935
41.104
41.0645
85.1333
292.929
308.32
81.6201
39.9206
40.2849
90.4398
309.543
304.561
90.9297
39.8365
40.4829
96.8556
294.63
277.456
97.335
40.1316
41.1335
102.628
260.184
242.933
103.752
40.8569
42.5404
110.026
227.252
212.511
112.106
42.5113
45.0256
119.753
199.756
188.188
121.523
45.2233
48.5101
127.807
178.23
169.349
130.43
49.0337
53.1344
134.689
161.591
154.827
137.818
53.9385
59.1426
140.105
148.801
143.611
142.866
60.1833
65.8883
144.605
138.946
134.995
146.917
66.9077
72.7501
148.414
131.378
128.445
150.514
73.903
79.8522
151.716
125.616
123.542
153.59
81.0117
87.1119
154.582
121.238
119.991
156.155
88.2354
94.1233
156.905
118.104
117.475
158.137
95.0515
100.642
158.724
115.966
115.696
159.702
101.426
106.601
160.092
114.563
114.506
160.808
107.15
111.924
161.074
113.704
113.778
161.644
112.312
116.64
161.659
113.19
113.335
162.088
116.766
120.657
162.014
112.911
113.114
162.339
120.709
124.135
162.167
112.789
113.03
162.389
124.042
127.073
162.154
112.769
113.048
162.316
126.907
129.542
162.021
112.825
113.159
162.124
129.279
131.601
161.799
112.951
113.315
161.875
131.291
133.294
161.514
113.116
113.497
161.561
132.916
134.673
161.191
113.306
113.7
161.227
134.273
135.784
160.837
113.517
113.918
160.859
135.339
136.664
160.473
113.742
114.151
160.494
136.215
137.353
160.098
113.981
114.393
160.115
136.877
137.88
159.73
114.229
114.647
159.754
137.411
138.276
159.356
114.489
114.909
159.375
137.791
138.558
158.996
114.756
115.179
159.026
138.085
138.752
158.636
115.03
115.455
158.661
138.267
138.885
158.294
115.311
115.738
158.331
138.4
138.959
157.962
115.598
116.024
157.999
138.447
138.961
157.642
115.889
116.314
157.686
138.451
138.918
157.327
116.182
116.604
157.367
138.381
138.795
157.016
116.475
116.894
157.056
138.246
138.599
156.696
116.767
117.177
156.723
138.016
138.324
156.365
117.051
117.451
156.391
137.737
138.003
156.017
117.325
117.712
156.027
137.383
137.63
155.657
117.586
117.959
155.671
137.013
137.238
155.287
117.832
118.189
155.287
136.587
136.802
154.912
118.061
118.405
154.916
136.144
136.348
154.531
118.275
118.602
154.519
135.675
135.877
154.142
118.471
118.784
154.14
135.214
135.408
153.764
118.652
118.949
153.748
134.741
134.937
153.383
118.815
119.099
153.381
134.285
134.476
153.019
118.965
119.236
153.013
133.828
134.026
152.666
119.101
119.361
152.675
133.397
133.589
152.33
119.226
119.475
152.341
132.968
133.166
152.012
119.338
119.579
152.035
132.559
132.755
151.707
119.443
119.673
151.732
132.156
132.359
151.42
119.537
119.761
151.457
131.775
131.974
151.146
119.625
119.84
151.184
131.399
131.606
150.888
119.704
119.914
150.938
131.045
131.25
150.643
119.778
119.981
150.693
130.696
130.909
150.412
119.844
120.044
150.472
130.369
130.58
150.192
119.907
120.101
150.252
130.045
130.265
149.985
119.964
120.154
150.056
129.747
129.964
149.788
120.019
120.204
149.858
129.45
129.676
149.603
120.068
120.25
149.683
129.174
129.397
149.427
120.115
120.293
149.505
128.899
129.132
149.261
120.157
120.333
149.348
128.65
128.879
149.103
120.198
120.369
149.187
128.39
128.633
148.953
120.235
120.404
149.047
128.162
128.401
148.81
120.27
120.435
148.901
127.924
128.178
148.675
120.301
120.465
148.775
127.717
127.967
148.547
120.331
120.492
148.643
127.499
127.764
148.425
120.358
120.518
148.53
127.312
127.572
148.31
120.384
120.542
148.411
127.113
127.387
148.201
120.407
120.564
148.311
126.943
127.212
148.097
120.429
120.584
148.203
126.761
127.044
147.999
120.449
120.603
148.113
126.608
126.885
147.906
120.468
120.62
148.016
126.442
126.732
147.818
120.484
120.635
147.936
126.303
126.589
147.734
120.5
120.65
147.847
126.15
126.449
147.654
120.514
120.662
147.776
126.026
126.319
147.579
120.527
120.674
147.695
125.886
126.192
147.506
120.538
120.685
147.631
125.774
126.073
147.439
120.549
120.695
147.558
125.646
125.957
147.373
120.559
120.704
147.5
125.544
125.848
147.312
120.569
120.714
147.433
125.425
125.742
147.253
120.579
120.724
147.382
125.333
125.642
147.197
120.59
120.735
147.32
125.222
125.544
147.143
120.601
120.746
147.274
125.139
125.453
147.093
120.614
120.759
147.218
125.036
125.363
147.045
120.627
120.774
147.178
124.96
125.279
147
120.644
120.79
147.127
124.865
125.196
146.957
120.661
120.808
147.092
124.796
125.118
146.918
120.681
120.829
147.046
124.706
125.041
146.88
120.701
120.851
147.016
124.643
124.969
146.845
120.725
120.874
146.975
124.56
124.897
146.812
120.749
120.898
146.949
124.501
124.83
146.782
120.774
120.924
146.913
124.422
124.762
146.752
120.801
120.952
146.892
124.367
124.7
146.727
120.83
120.983
146.86
124.293
124.638
146.699
120.862
121.02
146.831
124.233
124.555
146.676
120.899
121.105
146.811
124.162
124.489
146.649
120.993
121.179
146.768
124.091
124.402
146.603
121.068
121.349
146.698
123.937
124.069
146.617
121.258
121.696
146.656
123.406
122.838
146.552
122.08
123.222
145.875
121.958
118.31
144.863
125.098
126.7
143.517
115.197
109.738
142.572
128.642
76.4732
61.4274
62.2331
72.7445
88.9089
97.1666
102.692
118.742
129.329
134.593
137.263
138.404
138.61
138.249
137.679
137.095
136.579
136.153
135.813
135.544
135.334
135.168
135.039
134.937
134.858
134.796
134.75
134.716
134.695
134.682
134.676
134.675
134.673
134.669
134.664
134.658
134.651
134.643
134.635
134.626
134.617
134.609
134.601
134.593
134.587
134.583
134.58
134.578
134.579
134.583
134.592
134.606
134.624
134.647
134.681
134.73
134.797
134.882
134.984
135.098
135.219
135.343
135.463
135.578
135.687
135.789
135.885
135.979
136.069
136.159
136.25
136.342
136.436
136.534
136.636
136.743
136.856
136.975
137.1
137.231
137.369
137.514
137.664
137.821
137.982
138.149
138.319
138.492
138.668
138.846
139.025
139.203
139.382
139.559
139.734
139.907
140.077
140.244
140.408
140.568
140.724
140.875
141.023
141.166
141.305
141.439
141.569
141.695
141.817
141.934
142.048
142.157
142.263
142.365
142.463
142.558
142.65
142.738
142.824
142.907
142.987
143.064
143.14
143.212
143.283
143.352
143.418
143.483
143.546
143.607
143.667
143.725
143.782
143.838
143.892
143.946
143.998
144.049
144.099
144.148
144.197
144.245
144.292
144.339
144.386
144.431
144.477
144.522
144.568
144.612
144.657
144.702
144.747
144.792
144.837
144.882
144.927
144.973
145.019
145.066
145.114
145.162
145.211
145.261
145.311
145.363
145.415
145.467
145.52
145.571
145.621
145.666
145.706
145.739
145.767
145.788
145.801
145.806
145.806
145.807
145.809
145.809
145.799
145.764
145.676
145.496
145.194
144.778
144.286
143.755
143.206
142.646
142.074
141.486
140.882
140.258
139.614
138.952
138.272
137.575
136.862
136.136
135.397
134.646
133.885
133.116
132.34
131.557
130.771
129.982
129.193
128.404
127.617
126.835
126.058
125.288
124.528
123.777
123.04
122.316
121.607
120.916
120.244
119.593
118.963
118.353
117.762
117.186
116.624
116.079
115.57
115.138
114.83
114.659
114.587
114.56
114.547
114.505
114.325
113.44
112.228
108.826
107.007
105.474
103.498
102.042
100.071
98.7361
96.8157
95.6106
93.76
92.6837
90.909
89.9504
88.2587
87.3983
85.7886
85.0143
83.4838
82.7839
81.3285
80.6882
79.3082
78.7114
77.4055
76.8468
75.6067
75.0817
73.9004
73.4054
72.277
71.8094
70.7301
70.2878
69.2542
68.8352
67.8437
67.4457
66.4927
66.1137
65.1955
64.8336
63.9472
63.6006
62.7428
62.4099
61.5787
61.2581
60.4506
60.1407
59.3542
59.0535
58.2853
57.9927
57.2406
56.9548
56.2165
55.936
55.2089
54.9326
54.2148
53.9418
53.2315
52.9604
52.2548
51.9843
51.2813
51.0109
50.3096
50.0378
49.3347
49.0603
48.3539
48.0769
47.368
47.0874
46.3728
46.0874
45.3657
45.075
44.3458
44.0507
43.3152
43.0146
42.2702
41.9638
41.2133
40.9071
40.1606
39.8518
39.101
38.7914
38.0473
37.7491
37.0271
36.7389
36.0309
35.754
35.0771
34.829
34.2067
33.9906
33.4229
33.2331
32.7139
32.5517
32.0892
31.9528
31.54
31.4155
31.0317
30.9222
30.5684
30.4665
30.1302
30.0333
29.7107
29.6248
29.3209
29.2392
28.9547
28.8841
28.627
28.5713
28.338
28.2937
28.0752
28.0277
27.8075
27.7613
27.5502
27.5138
27.3176
27.2883
27.1114
27.0815
26.9068
26.8771
26.7009
26.6771
26.5002
26.4499
26.3045
26.2063
26.2744
26.3952
33.4698
33.2689
39.834
40.0659
46.4684
46.6231
48.5091
39.3086
33.1103
33.0363
38.5324
40.0833
33.4533
33.3252
39.0028
48.9182
49.55
40.5056
33.782
33.6149
39.3609
40.8793
34.058
33.878
39.6849
50.0832
50.6044
41.2223
34.3127
34.1307
39.9927
41.5503
34.5619
34.3791
40.3005
51.1128
51.6077
41.8939
34.8356
34.6588
40.6343
42.2602
35.144
34.9742
40.9954
52.0806
52.539
42.6394
35.4692
35.2976
41.3628
43.0224
35.7942
35.6172
41.7343
52.9942
53.4619
43.4088
36.1231
35.9495
42.1106
43.8072
36.4747
36.3087
42.5113
53.9531
54.4878
44.2361
36.8631
36.7051
42.951
44.7111
37.2941
37.1479
43.4561
55.073
55.7192
45.26
37.7737
37.6377
44.0374
45.8874
38.3004
38.176
44.696
56.4555
57.2917
46.5906
38.8762
38.7642
45.4335
47.4058
39.5253
39.432
46.2596
58.2574
59.3798
48.3571
40.2718
40.2007
47.2227
49.4544
41.1259
41.0761
48.3176
60.6535
62.0491
50.6654
42.0773
42.0429
49.5127
51.959
43.1125
43.0934
50.7924
63.5403
65.1158
53.3338
44.2355
44.2335
52.1529
54.7688
45.4396
45.4542
53.5663
66.7353
68.3606
56.2266
46.6925
46.7047
54.9984
57.6812
47.9627
47.9744
56.4309
69.9471
71.4908
59.1215
49.2475
49.2561
57.8544
60.5322
50.5284
50.5254
59.2456
72.9769
74.3877
61.8921
51.7871
51.7749
60.5942
63.2057
53.025
53.0044
61.9022
75.7317
77.0057
64.4727
54.2376
54.2081
63.1676
65.6976
55.4244
55.3875
64.397
78.2213
79.3911
66.8915
56.591
56.5479
65.5992
68.0583
57.7384
57.6895
66.7761
80.5234
81.6193
69.198
58.8667
58.8124
67.9279
70.3152
59.9791
59.9215
69.0613
82.6852
83.7297
71.4182
61.0817
61.0219
70.1818
72.5078
62.1752
62.1135
71.29
84.754
85.7594
73.5857
63.2616
63.199
72.3885
74.6558
64.3448
64.2824
73.4796
86.7482
87.7217
75.7209
65.4274
65.3661
74.5637
76.7838
66.5129
66.4539
75.6482
88.684
89.6374
77.8468
67.6049
67.5494
76.7363
78.9129
68.7059
68.6547
77.8299
90.5877
91.5371
79.9839
69.8182
69.7724
78.9306
81.0616
70.9449
70.9057
80.0407
92.4851
93.4325
82.1478
72.0888
72.0572
81.1614
83.2433
73.2521
73.2294
82.2944
94.3785
95.3232
84.3498
74.4378
74.4253
83.4418
85.4692
75.6486
75.6475
84.6065
96.2672
97.2109
86.6045
76.8896
76.9052
85.7911
87.7571
78.1629
78.1969
86.9972
98.1557
99.1019
88.9294
79.4708
79.525
88.2268
90.1227
80.816
80.8923
89.4799
100.049
100.996
91.3391
82.2017
82.3022
90.7555
92.5796
83.6317
83.7588
92.0587
101.94
102.881
93.8459
85.1101
85.2666
93.3927
95.1427
86.6405
86.8287
94.7643
103.813
104.73
96.481
88.2214
88.439
96.1582
97.8355
89.8508
90.0997
97.5727
105.643
106.548
99.2059
91.5307
91.8135
99.0064
100.59
93.2629
93.5828
100.457
107.443
108.325
101.986
95.0502
95.4113
101.923
103.39
96.8943
97.3004
103.401
109.188
110.027
104.794
98.7979
99.2552
104.901
106.193
100.753
101.271
106.393
110.833
111.597
107.572
102.728
103.333
107.864
108.92
104.73
105.416
109.291
112.31
112.959
110.219
106.738
107.485
110.648
111.436
108.704
109.492
111.893
113.529
113.996
112.535
110.577
111.345
112.968
114.361
114.148
113.876
113.556
113.195
112.797
112.368
111.91
111.427
110.924
110.404
109.867
109.317
108.753
108.175
107.586
106.986
106.378
105.765
105.147
104.522
103.89
103.252
102.608
101.961
101.311
100.66
100.008
99.3568
98.6934
98.0091
97.3089
96.5952
95.8679
95.1262
94.3689
93.5938
92.7948
91.9641
91.0964
90.1846
89.2158
88.1737
87.0583
85.8631
84.6292
83.2868
81.8078
80.2662
78.6992
77.1637
75.7082
74.3766
73.2068
72.2074
71.3515
70.5984
69.9096
69.2579
68.6089
67.9456
67.2546
66.5293
65.7791
64.9923
64.1635
63.3121
62.4196
61.5636
60.5871
60.1221
57.3375
51.3346
51.3956
56.9756
61.1455
61.3446
65.3719
64.9736
68.0195
68.3017
67.8888
73.308
71.1084
70.6661
72.7355
73.1808
74.8512
74.319
75.3016
75.855
76.7237
77.8591
76.3757
75.7636
75.5528
76.1964
75.2589
74.5708
72.6737
73.3177
75.987
69.022
69.698
69.4714
65.8379
66.1501
57.7471
57.9851
48.7074
46.7161
45.8086
44.0257
44.2685
37.0822
36.347
28.7956
29.2544
27.8837
34.8417
33.878
27.8588
28.4615
36.1016
45.139
57.0173
56.3851
45.4727
36.8355
34.4676
28.1654
29.0413
28.6731
35.1679
37.6727
46.7469
59.0566
70.5429
77.9286
79.7135
78.3683
74.7028
68.8723
70.1655
76.3081
80.2967
81.9551
84.1635
82.1943
77.8774
71.3894
72.6259
79.4614
81.0385
73.8341
75.0232
82.6072
88.0547
86.0846
84.1326
86.4589
88.7976
91.1963
93.6547
90.0375
84.1612
76.1798
77.2939
85.69
87.1773
78.3623
79.3746
88.6097
95.9539
94.004
92.026
96.1681
98.7249
101.308
103.893
97.8533
89.9722
80.3235
81.2117
91.2469
92.4147
82.0443
82.835
93.4692
102.919
101.372
99.6713
106.447
108.927
111.273
118.037
114.414
110.802
107.261
103.815
100.48
97.2645
94.1758
91.213
88.361
85.6258
82.9608
80.4763
73.4075
61.5516
58.3162
47.4351
48.8899
49.5579
60.737
64.0888
76.0453
79.0414
82.1232
85.409
73.1218
69.3121
69.8701
66.2182
66.8725
63.3683
51.9013
51.1548
41.1596
38.3393
40.1408
37.4404
39.3437
36.6694
38.4282
35.8622
29.2239
29.6011
30.1914
29.8033
30.8159
30.4006
31.4386
31.0438
32.1145
31.6727
39.1767
42.0053
40.1502
32.365
32.7782
33.5238
43.1211
53.6329
54.4601
44.0368
41.0683
33.0668
34.2756
33.8521
42.1309
45.2538
56.3406
57.2631
59.3093
60.3424
72.6838
76.6753
88.8616
92.537
96.4663
100.67
89.5255
84.813
84.8632
80.4025
80.5898
76.3699
63.722
62.5693
50.162
46.67
48.6943
45.3957
47.5869
44.2917
46.2566
43.1357
34.6288
35.1052
35.9179
35.4735
36.8121
36.3119
37.7005
37.2405
38.6897
38.1687
47.8936
51.38
49.2949
39.1969
39.6743
40.7687
52.9949
66.1469
67.4337
54.3378
50.6478
40.223
41.8549
41.3499
52.1873
56.1134
70.0998
71.5492
74.4987
76.1426
89.6941
94.6342
105.175
110.006
115.166
120.663
113.321
107.789
106.508
101.139
100.275
95.1181
81.3223
79.4279
63.4909
58.9909
61.2606
57.0769
59.5864
55.397
57.6055
53.6872
42.4716
43.0488
44.2394
43.708
45.5519
44.9449
46.8739
46.3151
48.3437
47.7055
60.9024
65.4025
63.0803
49.2559
49.8424
51.5124
67.9371
85.014
87.2107
70.1485
65.2775
50.8405
53.2272
52.626
67.7998
73.104
91.4264
94.0309
98.9501
102.003
115.001
120.571
126.55
121.563
113.416
104.278
94.4158
83.6171
84.4363
95.2742
96.0894
85.3424
86.3879
96.9254
106.917
106.28
105.408
115.252
116.573
117.156
117.22
107.428
97.8422
87.5847
88.8987
98.8427
99.8755
90.2611
91.5588
100.733
109.009
108.367
107.849
117.03
116.985
117.393
117.573
109.777
101.643
92.7355
93.8841
102.503
103.29
94.9481
95.8937
103.975
110.992
110.753
110.375
117.59
117.37
117.08
116.754
111.129
104.529
96.7626
97.5451
104.985
105.368
98.2569
98.9071
105.696
111.219
111.217
111.195
116.416
116.081
115.757
119.521
120.153
120.845
121.608
122.445
123.358
124.371
125.465
126.382
127.211
128.345
129.179
128.954
127.549
124.815
132.555
138.426
143.392
147.035
142.245
137.208
132.286
128.497
123.16
111.74
107.776
86.6403
80.1339
82.3806
76.4765
79.2051
73.3667
75.7336
70.392
54.4567
55.1802
57.2628
56.5559
59.5531
58.7528
61.994
61.2181
64.7044
64.0614
84.1766
90.8594
89.0356
67.4096
67.8811
71.7388
96.4638
118.217
123.404
102.403
94.6903
71.4019
76.2517
76.1567
101.472
109.901
130.227
136.692
144.617
152.653
152.725
156.275
145.752
145.214
140.931
136.884
150.84
154.62
157.496
161.848
161.843
161.139
166.449
159.623
152.276
146.186
141.891
134.175
127.753
118.615
118.537
109.304
81.6748
81.4954
99.0521
100.599
113.465
124.547
134.449
139.167
128.317
122.807
112.965
136.41
146.308
151.072
156.41
161.603
166.364
162.635
157.349
149.308
142.085
155.629
163.63
168.796
170.692
171.683
173.575
178.992
175.743
174.912
180.168
184.327
182.541
187.539
170.506
165.127
183.248
200.234
198.022
188.225
184.042
178.793
171.72
166.698
174.318
180.632
187.131
198.473
207.3
209.949
199.445
191.88
172.099
163.742
174.88
183.262
192.574
204.282
215.899
217.596
214.92
211.192
204.897
198.529
190.774
193.557
200.86
207.625
215.098
221.149
221.557
225.511
221.966
219.939
212.563
205.47
199.095
204.688
212.722
220.498
226.513
210.63
216.524
225.202
207.376
201.427
196.551
192.279
181.99
172.459
168.837
161.36
155.122
144.695
133.931
131.069
128.889
127.211
131.416
134.062
137.733
143.825
150.272
153.658
158.402
165.958
171.353
178.864
186.47
189.604
193.23
197.796
191.13
187.523
183.259
176.054
185.372
186.247
193.651
200.747
209.663
192.917
186.185
185.555
191.618
190.981
185.035
185.685
191.28
193.802
187.039
187.279
194.734
202.621
202.955
208.314
209.197
207.874
198.518
204.689
193.503
172.023
188.695
177.181
155.586
178.957
199.251
192.647
200.714
205.586
206.805
202.044
208.299
209.414
209.549
208.41
199.382
202.152
193.516
194.548
186.967
187.283
176.975
184.184
183.861
191.67
197.216
205.433
200.394
190.596
192.26
205.132
208.781
206.854
194.974
189.204
196.708
200.475
193.094
177.753
150.258
160.001
163.421
179.322
164.009
150.367
134.289
150.553
140.148
120.86
139.287
122.772
113.369
97.296
116.141
106.229
80.8049
109.411
77.8935
69.9842
50.6249
79.1076
73.2943
49.7548
84.4295
69.4435
62.5635
42.1987
70.9553
64.7952
42.2922
70.6736
63.897
41.628
69.0212
62.3744
40.1807
71.1968
58.1503
50.5986
33.4836
55.7201
50.3224
31.7468
55.8341
48.6028
29.4684
53.7354
47.7194
28.8836
52.9655
45.656
26.9259
50.4543
44.1894
24.1551
51.8732
30.168
56.9379
49.0632
28.4451
53.7989
46.5516
27.8956
50.3639
43.2867
25.2174
47.9729
40.9834
22.9536
46.0054
26.4003
50.362
39.7674
22.9252
44.8288
35.0395
20.834
42.9242
23.023
48.9082
38.3439
21.7397
44.6461
34.3914
20.5539
40.2061
22.0923
45.8288
32.0788
19.6815
40.2138
21.8094
46.5136
34.1205
20.6362
41.3205
27.7415
18.8424
35.4932
20.5886
40.5861
26.3211
18.3478
32.8624
19.4783
41.6869
26.4416
18.1649
33.7344
19.9128
38.888
25.271
18.2275
31.1613
19.1722
39.6947
25.3606
18.3403
31.4421
19.6858
36.4209
24.1513
18.4907
29.9094
19.4135
37.1671
24.4385
18.8404
29.9346
19.9726
34.216
23.4095
19.112
28.8803
19.9334
34.6764
23.6462
19.4922
28.8313
20.4465
33.0432
23.1755
19.9548
28.0568
20.6187
33.2463
23.3575
20.4134
28.081
21.2004
32.1246
23.1584
20.9861
27.4494
21.474
32.6664
23.5614
21.5784
27.8177
22.2413
31.7113
23.5384
22.1924
27.2901
22.5674
32.399
24.0841
22.7607
27.8514
23.4408
31.5744
24.3403
23.0482
27.5833
23.9014
32.6841
25.1269
23.7968
28.2546
24.9024
32.0701
25.5481
24.2248
28.3574
25.4832
33.6162
26.6977
25.2717
30.6995
25.922
25.1151
28.0493
25.992
31.7758
26.5039
25.7054
29.0309
26.9869
32.9311
27.6553
26.5564
30.8088
27.0245
26.5704
28.9848
27.3346
31.7374
27.8212
26.9843
30.8402
27.5893
27.3475
29.723
28.1668
32.9621
28.972
28.2799
31.8006
28.7779
28.722
30.6448
29.3083
33.4494
30.1051
29.4914
33.2576
30.38
29.9349
32.7595
30.5474
30.2453
33.2685
31
30.9446
33.3372
31.1312
31.1657
33.88
31.7215
31.7954
34.0336
31.9935
32.1377
34.8328
32.7126
32.8856
35.2765
33.2866
33.4265
36.4388
34.3036
34.4588
37.2596
35.362
35.1655
39.3844
37.3441
35.7424
36.0291
38.4576
36.8115
35.5912
36.0028
39.3803
37.4058
36.5024
37.1127
39.8125
38.3565
37.0503
37.1721
42.1089
40.1466
39.2989
38.4071
37.0905
37.4476
40.892
39.7584
38.6441
38.5473
36.8773
36.8503
35.2765
35.4374
34.037
34.22
32.9008
33.0941
31.9858
32.1799
31.3679
31.5967
31.0482
31.3796
31.0214
31.5189
31.3712
32.0142
32.1232
32.8341
33.3695
34.0684
34.9915
35.68
37.0165
37.6201
39.2143
39.7819
41.6395
42.1495
44.2182
44.7184
47.0432
47.4712
50.0694
50.3387
53.1666
53.3069
56.2753
56.2856
59.3141
59.1836
62.3131
62.0766
65.2455
64.8701
68.1012
67.6174
70.8507
70.23
73.4914
72.7694
76.004
75.1549
78.3892
77.4463
80.6286
79.5738
82.7345
81.5956
84.6862
83.4501
86.5025
85.1931
88.1672
86.7818
89.7124
88.2597
91.1041
89.595
92.4011
90.8404
93.5588
91.9521
94.6318
92.9815
95.574
93.8886
96.4397
94.7032
97.1876
95.4388
97.8637
96.0858
98.43
96.6331
98.9381
97.1065
99.3546
97.5255
99.7206
97.8641
100.023
98.1675
100.284
98.4009
100.499
98.6116
100.658
98.7652
100.787
98.8806
100.869
98.9626
100.93
99.0145
100.951
99.0403
100.96
99.0432
100.935
99.0263
100.903
98.9923
100.85
98.934
100.786
98.8858
100.702
98.8137
100.621
98.734
100.526
98.6381
100.43
98.5585
100.318
98.4609
100.215
98.3606
100.098
98.2584
99.991
98.1548
99.872
98.0504
99.7645
97.9455
99.6455
97.8411
99.5391
97.7371
99.4224
97.6346
99.3188
97.533
99.2055
97.4335
99.1058
97.3353
99.0022
97.2305
98.9048
97.148
98.8047
97.0459
98.7108
96.9665
98.6091
96.8768
98.5216
96.7892
98.4252
96.7046
98.3429
96.6214
98.2563
96.5313
98.1751
96.4621
98.0902
96.3731
98.0112
96.3062
97.9293
96.22
97.8533
96.1553
97.7737
96.0709
97.6997
96.008
97.6171
95.9347
97.5481
95.8622
97.4738
95.7884
97.3941
95.7234
97.3325
95.6404
97.245
95.5852
97.1746
95.4838
97.0658
95.4009
96.9628
95.2423
96.7093
94.2073
95.7553
92.2311
85.6639
82.6484
61.6602
62.2923
60.5397
60.7214
63.9371
81.0635
60.6166
61.7747
62.796
63.1143
62.704
60.5532
64.1183
62.4039
60.4241
64.1188
62.382
60.0201
64.2395
62.4324
60.4476
64.1827
62.4291
60.07
64.2956
62.4735
60.4543
64.2422
62.4761
60.1205
64.3436
62.5259
60.4931
64.2946
62.5214
60.1696
64.389
62.5662
60.5406
64.3357
62.5633
60.2122
64.4258
62.6044
60.58
64.3685
62.5923
60.245
64.4561
62.6288
60.6102
64.3939
62.6116
60.2682
64.4772
62.6431
60.6304
64.4092
62.6201
60.2799
64.4876
62.6455
60.6382
64.4126
62.6146
60.2785
64.4833
62.6284
60.6329
64.4029
62.5947
60.2622
64.4662
62.6015
60.6119
64.3788
62.5611
60.2306
64.4374
62.5653
60.574
64.3403
62.5123
60.183
64.393
62.5081
60.5197
64.287
62.4452
60.1172
64.3301
62.4271
60.4473
64.2169
62.3592
60.0321
64.2498
62.3311
60.3544
64.1264
62.2524
59.9262
64.1493
62.2134
60.2398
64.0145
62.1228
59.7976
64.0262
62.0714
60.1016
63.8786
61.9676
59.6446
63.8776
61.9025
59.9382
63.7158
61.7843
59.4653
63.7008
61.7044
59.7479
63.5237
61.5714
59.2582
63.4947
61.48
59.5284
63.2973
61.3235
59.0211
63.2504
61.2091
59.2799
63.0364
61.04
58.7516
62.9717
60.9121
58.9975
62.7339
60.7167
58.4507
62.6477
60.5624
58.6854
62.3882
60.3496
58.1171
62.2769
60.1727
58.3418
61.9906
59.9367
57.7512
61.8568
59.7346
57.968
61.5384
59.4759
57.3436
61.3881
59.2483
57.5719
61.0276
58.9649
56.9006
60.8618
58.7194
57.1489
60.4577
58.4057
56.4301
60.278
58.1368
56.7015
59.8302
57.7977
55.9384
59.6326
57.5054
56.2371
59.1398
57.1392
55.4278
58.9219
56.8175
55.7633
58.3807
56.4289
54.9092
58.1376
56.092
55.2915
57.5477
55.6653
54.3978
57.2727
55.2907
54.8412
56.6125
54.8237
53.9239
56.2751
54.4569
54.4551
55.517
53.9107
53.5453
55.0426
53.4357
54.2248
54.3158
52.9433
53.2238
53.7899
52.4124
54.0236
53.0591
51.8947
52.9792
52.5667
51.438
53.8722
51.888
50.9096
52.8501
51.3967
50.5186
53.8604
50.7745
50.0182
52.8669
50.3169
49.7314
54.0052
49.7549
49.2848
53.0524
49.3609
49.0566
54.327
48.7167
48.7162
53.4408
48.399
48.4828
54.927
47.7891
48.1607
54.1247
47.515
47.996
55.874
46.8844
47.6848
55.1858
46.5749
47.4947
57.294
45.799
47.0628
56.8073
45.3075
46.7174
59.45
44.1738
46.0194
59.3106
43.5946
46.0231
62.2185
42.8918
45.9902
62.1139
42.8469
46.8064
65.0291
43.1003
47.4527
64.9947
43.8263
48.4758
68.3815
44.2905
49.3335
68.6938
45.229
50.5634
72.4326
45.8887
51.5924
73.1549
46.9816
52.9599
77.2014
47.7653
54.1071
78.3514
48.9239
55.5303
82.5876
49.7437
56.6269
84.0902
50.7806
57.8355
88.6617
51.2047
58.7647
90.5608
52.196
60.7605
97.1807
54.4079
65.7388
101.759
62.1714
79.3031
48.0307
51.9176
74.5549
114.652
121.07
87.3643
59.5313
63.9552
83.3214
94.028
74.5443
83.3441
49.9993
55.7676
94.0592
56.9094
74.6
46.7087
54.5333
71.9828
110.418
151.306
145.476
132.566
89.5805
151.495
172.815
149.304
169.846
146.415
137.183
166.866
140.566
132.984
165.002
137.629
130.759
163.195
135.544
128.241
161.253
132.943
125.093
159.083
129.873
121.755
156.622
126.639
118.466
153.966
123.466
115.339
151.231
120.437
112.272
148.467
117.458
109.249
145.759
114.52
106.386
143.091
111.715
103.736
140.483
109.089
101.303
137.946
106.66
99.0793
135.489
104.417
97.0471
133.122
102.349
95.188
130.833
100.439
93.4821
128.637
98.6699
91.9275
126.527
97.0381
90.5325
124.502
95.5558
89.2773
122.562
94.203
88.1478
120.702
92.9682
87.1288
118.922
91.8385
86.2059
117.218
90.8012
85.3659
115.586
89.8457
84.5949
114.024
88.9592
83.8867
112.527
88.1336
83.234
111.093
87.3638
82.6249
109.719
86.641
82.0539
108.399
85.9585
81.515
107.137
85.3127
81.0019
105.919
84.6949
80.5148
104.751
84.105
80.046
103.627
83.5382
79.5935
102.546
82.9918
79.1551
101.503
82.4629
78.7285
100.498
81.9499
78.3124
99.5272
81.4509
77.9053
98.5906
80.9646
77.5063
97.6848
80.4897
77.114
96.8103
80.026
76.7269
95.9634
79.5707
76.3461
95.1454
79.1242
75.9729
94.3506
78.6869
75.6034
93.5865
78.2585
75.2403
92.8324
77.839
74.882
92.1024
77.4255
74.53
91.3923
77.0189
74.1865
90.8071
76.6349
73.884
90.2621
76.2963
73.5975
90.9701
76.1162
73.5906
90.4247
75.7592
73.3477
98.669
77.3347
96.856
96.8558
124.04
122.749
133.352
133.767
137.534
137.743
139.21
138.861
138.991
139.299
138.741
138.506
137.839
138.005
138.187
139.011
139.685
139.715
138.212
133.389
121.378
121.712
122.481
123.218
135.459
134.64
133.92
138.806
139.5
140.219
140.96
136.319
124.135
125.006
125.951
126.884
139.019
138.1
137.197
141.714
142.483
143.268
143.769
143.157
142.557
141.968
141.387
140.816
140.247
140.084
140.501
140.919
139.871
139.582
139.293
138.377
138.569
138.759
138.947
140.16
141.342
141.77
142.203
142.643
141.037
140.742
140.45
139.133
139.318
139.501
138.236
138.13
138.02
137.907
137.79
137.67
137.547
137.422
137.302
137.192
136.637
136.708
136.231
136.187
135.833
135.859
135.571
135.556
135.34
135.349
135.177
135.172
135.041
135.043
135.044
135.181
135.358
135.588
135.889
136.28
136.785
136.865
136.942
137.015
136.418
136.376
136.33
135.918
135.945
135.967
135.985
136.456
137.083
137.148
137.208
137.263
136.541
136.517
136.489
135.999
136.008
136.011
135.627
135.633
135.636
135.634
135.628
135.618
135.605
135.366
135.371
135.373
135.181
135.183
135.183
135.043
135.04
135.035
135.028
135.175
135.372
135.367
135.358
135.346
135.14
135.155
135.167
135.017
135.004
134.988
134.876
134.892
134.905
134.916
134.924
134.931
134.936
134.938
134.939
134.938
134.858
134.858
134.795
134.796
134.749
134.747
134.713
134.715
134.693
134.691
134.678
134.681
134.675
134.687
134.71
134.744
134.793
134.856
134.852
134.847
134.84
134.775
134.783
134.788
134.74
134.734
134.727
134.718
134.766
134.831
134.82
134.808
134.793
134.731
134.744
134.756
134.708
134.698
134.686
134.654
134.665
134.675
134.684
134.692
134.699
134.705
134.683
134.676
134.669
134.656
134.664
134.67
134.649
134.661
134.653
134.643
134.634
134.622
134.631
134.64
134.613
134.624
134.643
134.674
134.717
134.777
134.859
134.97
135.121
135.329
135.615
136.011
136.559
137.314
138.338
139.684
141.333
143.09
144.393
144.07
139.961
127.864
128.854
129.879
130.927
142.912
141.906
140.922
144.889
145.726
146.58
147.453
143.941
132.003
133.107
134.237
135.399
147.168
146.069
144.993
148.346
149.257
150.188
149.142
148.419
147.712
147.019
146.342
145.679
145.029
143.545
144.008
144.478
142.239
141.934
141.632
139.865
140.044
140.222
140.399
142.547
144.958
145.447
145.945
146.454
143.495
143.175
142.859
140.575
140.75
140.924
141.097
143.82
146.974
149.881
151.139
148.29
136.587
137.808
139.057
140.338
151.803
150.607
149.437
152.11
153.101
154.113
155.146
153.022
141.65
142.996
144.373
145.785
156.831
155.536
154.267
156.2
157.274
158.371
155.538
154.675
153.832
153.006
152.199
151.41
150.637
147.506
148.049
148.604
144.828
144.486
144.15
141.27
141.442
141.614
141.787
145.177
149.173
149.754
150.349
150.959
146.269
145.897
145.533
141.96
142.134
142.31
142.488
146.649
151.582
156.419
159.488
158.149
147.229
148.708
150.221
151.768
162.256
160.862
159.493
160.628
161.79
162.975
164.184
163.675
153.35
154.968
156.62
158.307
168.076
166.585
165.118
165.416
166.672
167.955
163.12
162.107
161.111
160.134
159.176
158.238
157.319
152.218
152.869
153.532
147.836
147.433
147.037
142.668
142.85
143.034
143.219
148.245
154.206
154.891
155.584
156.283
149.469
149.065
148.656
143.401
143.578
143.743
143.889
149.861
156.983
164.151
169.262
169.589
160.029
161.786
163.576
165.399
174.255
172.681
171.125
170.594
171.949
173.326
174.723
175.844
167.254
169.136
171.041
172.961
180.636
179.043
177.442
176.134
177.552
178.964
171.576
170.553
169.49
168.413
167.334
166.261
165.199
157.683
158.374
159.05
150.872
150.57
150.231
144.001
144.059
143.963
143.591
151.105
159.7
160.31
160.88
161.146
150.326
150.926
151.165
142.969
142.001
140.857
134.229
135.305
136.371
137.366
138.261
138.862
139.242
139.418
139.444
139.462
139.462
139.454
139.44
139.422
139.401
139.376
139.347
139.313
139.275
139.232
139.184
139.13
139.072
139.009
138.941
138.868
138.791
138.709
138.623
138.532
138.437
137.359
137.399
137.434
136.579
136.578
136.572
136.005
135.993
135.975
135.951
136.574
137.463
137.485
137.501
137.51
136.514
136.542
136.562
135.92
135.881
135.835
135.377
135.431
135.478
135.517
135.55
135.577
135.599
135.308
135.282
135.252
135.042
135.072
135.099
134.948
134.923
134.895
134.862
135.007
135.216
135.174
135.126
135.072
134.87
134.922
134.967
134.826
134.786
134.74
134.689
134.813
135.01
135.316
135.781
136.479
137.512
137.507
137.494
137.472
136.317
136.381
136.435
135.717
135.644
135.56
135.465
136.243
137.442
137.403
137.354
137.297
135.951
136.061
136.158
135.357
135.236
135.101
134.584
134.728
134.857
134.972
135.074
135.165
135.245
134.94
134.86
134.771
134.591
134.674
134.747
134.631
134.566
134.492
134.408
134.497
134.67
134.557
134.43
134.286
134.134
134.27
134.391
134.313
134.204
134.073
134.058
134.191
134.293
134.377
134.449
134.512
134.567
134.616
134.659
134.697
134.732
134.763
134.791
134.816
134.839
134.759
134.74
134.718
134.668
134.685
134.702
134.661
134.647
134.633
134.619
134.649
134.695
134.67
134.642
134.611
134.585
134.608
134.63
134.605
134.59
134.574
134.573
134.582
134.591
134.601
134.611
134.622
134.632
134.615
134.606
134.597
134.59
134.597
134.605
134.585
134.59
134.584
134.579
134.575
134.577
134.578
134.581
134.579
134.571
134.563
134.558
134.56
134.577
134.538
134.494
134.443
134.458
134.498
134.531
134.538
134.516
134.489
134.459
134.409
134.382
134.307
134.211
134.092
134.197
134.277
134.348
134.425
134.389
134.353
134.522
134.517
134.519
134.525
134.533
134.542
134.553
134.57
134.572
134.578
134.609
134.595
134.584
134.628
134.587
134.601
134.625
134.662
134.754
134.696
134.655
134.829
134.716
134.542
134.325
134.111
133.953
133.887
133.908
133.979
134.126
134.423
134.951
135.829
137.23
137.153
137.066
136.97
135.375
135.542
135.692
134.784
134.6
134.395
134.163
135.192
136.865
136.752
136.629
136.44
134.269
134.707
134.997
133.837
133.358
132.727
131.801
132.448
133.029
133.49
133.809
134.046
134.245
133.947
133.724
133.427
133.169
133.518
133.784
133.687
133.406
133.085
132.752
132.752
133.017
132.511
131.962
131.429
131.561
131.899
132.311
132.452
132.216
132.054
131.97
131.315
130.973
131.158
132
133.625
136.095
135.554
134.782
133.908
131.213
132.031
132.858
131.256
130.552
129.908
129.355
130.436
132.977
132.055
131.162
130.312
128.446
129.025
129.709
128.9
128.542
128.279
129.025
129.079
129.2
129.407
129.694
130.08
130.569
130.617
130.362
130.192
131.052
131.078
131.156
131.942
131.945
131.984
132.04
131.054
130.104
130.072
130.068
130.104
131.224
131.15
131.094
132.112
132.191
132.279
133.233
133.14
133.051
132.967
132.888
132.817
132.762
132.726
132.728
132.764
132.858
133.013
133.216
133.448
133.68
133.801
133.654
133.529
133.934
133.968
134.032
134.312
134.316
134.344
134.395
133.927
133.44
133.398
133.391
133.419
134.072
134.002
133.951
134.465
134.55
134.642
135.096
134.994
134.891
134.794
134.706
134.633
134.578
134.788
134.876
134.977
135.144
135.028
134.922
135.263
135.085
135.197
135.308
135.414
135.602
135.495
135.381
135.704
135.515
135.196
134.737
134.154
133.473
133.543
133.623
133.708
134.421
134.331
134.241
134.831
134.924
135.015
135.106
134.511
133.795
133.884
133.976
134.071
134.791
134.695
134.602
135.197
135.29
135.386
135.847
135.752
135.659
135.568
135.477
135.386
135.292
135.612
135.706
135.797
135.985
135.894
135.801
136.075
135.887
135.978
136.07
136.165
136.353
136.258
136.166
136.451
136.264
135.946
135.486
134.891
134.171
133.332
132.374
131.308
130.162
129.012
128.091
127.968
129.48
133.165
139.636
149.333
161.195
172.605
180.356
182.209
174.884
176.795
178.68
180.492
186.548
185.22
183.745
181.689
182.977
183.902
184.312
187.442
182.078
183.121
183.671
183.95
187.251
187.889
187.813
184.405
183.827
182.523
167.381
169.81
171.748
172.953
173.672
173.636
173.323
160.749
159.778
158.486
145.063
146.641
148.061
138.36
137.042
135.701
134.37
143.389
156.793
154.867
152.683
150.256
137.84
139.837
141.679
132.992
131.503
130.163
128.983
135.673
147.509
164.361
180.774
186.154
183.993
183.638
183.515
182.992
181.68
183.441
184.895
178.429
175.225
170.809
165.522
179.194
182.431
178.141
178.807
163.827
138.32
88.9998
53.3107
46.1049
76.6971
64.7527
86.3525
117.581
84.2893
56.2251
75.3407
44.8951
53.5248
75.8123
110.037
136.118
149.272
123.594
92.4568
66.5095
81.0064
48.3342
59.0347
97.459
69.2057
44.3932
58.3021
73.6215
44.2871
55.2216
92.4982
66.109
41.6747
54.9551
71.2672
42.1419
52.7362
92.016
63.5736
40.147
53.0377
69.4853
41.2639
52.3883
90.8008
64.477
39.7347
53.3868
71.0652
41.268
52.8364
93.8445
65.8955
40.1789
54.5848
73.2747
42.6255
56.3118
96.6092
73.6672
43.5438
66.0215
37.9315
51.5863
70.7281
40.5891
54.8029
80.6952
103.609
81.1839
94.7404
117.149
91.8697
129.921
149.859
119.727
97.0828
77.243
44.7223
66.9828
37.8756
51.8377
69.7078
40.3328
54.2039
95.8507
85.4249
107.198
78.4202
87.9864
98.7336
131.342
142.43
124.865
133.375
115.365
89.8961
65.1556
37.4819
52.5635
71.1605
40.8472
56.6109
82.3642
102.566
78.6752
93.1166
117.687
98.2381
79.5025
46.7534
70.7103
39.6587
56.9292
75.9868
44.9797
67.1173
37.4129
52.0138
77.5547
98.2905
88.6649
109.036
90.2433
101.013
81.1998
125.574
132.992
115.52
94.5212
73.1144
43.3884
61.8163
77.6727
49.9043
70.9114
40.6462
57.6833
94.2971
83.8964
106.433
83.6931
97.6647
121.164
145.166
129.581
112.96
91.6436
71.3056
41.5479
61.3998
81.9154
105.217
95.7196
76.8026
49.9708
70.843
40.3071
58.3661
94.3118
74.563
47.5277
71.0357
42.0851
61.8359
76.6163
50.9336
70.9681
40.6458
59.9873
93.7724
75.2434
49.5881
71.8343
43.966
63.0668
82.7319
105.001
95.8566
111.638
91.4422
127.428
141.777
118.802
104.474
83.4662
81.5723
95.0776
112.108
91.1541
123.809
134.906
147.896
133.658
120.759
129.337
126.109
139.311
153.924
142.56
162.494
159.93
152.072
138.348
126.64
138.687
131.219
145.075
159.025
147.344
151.08
127.505
134.853
145.105
159.372
164.926
169.199
168.474
166.433
160.084
140.35
126.531
149.131
114.688
84.5877
86.5149
127.527
112.796
82.5436
84.3771
139.898
161.732
142.284
150.417
113.39
81.0239
81.4026
125.422
129.107
114.659
82.8823
83.4187
142.646
164.918
144.164
153.456
118.25
85.2327
84.5358
129.106
139.405
149.76
169.391
174.668
178.895
179.202
179.026
180.381
175.636
159.774
153.464
171.465
164.847
176.455
172.614
176.92
175.911
176.268
171.076
172.965
173.644
168.374
170.52
171.317
170.518
168.931
164.992
168.749
171.076
172.676
170.579
173.258
174.792
171.938
175.308
167.76
160.454
153.422
167.868
161.352
153.929
166.72
160.939
153.463
147.09
159.529
166.661
168.37
166.657
167.241
163.708
165.134
165.317
164.661
166.259
164.412
166.833
162.944
157.482
150.661
160.621
155.108
162.004
164.049
163.561
159.672
161.57
156.015
158.935
150.459
136.629
124.484
131.634
119.792
95.48
61.229
43.0684
71.7764
53.1697
77.8725
84.8994
76.5581
52.1579
72.685
46.5479
64.49
79.2209
55.6646
71.9984
46.3448
62.7691
96.3126
85.8237
105.552
83.7563
96.8403
112.023
91.8909
123.36
140.086
133.62
145.409
128.117
140.141
156.352
160.259
160.401
158.377
153.065
155.984
148.2
135.624
124.612
106.548
85.3685
66.3612
50.0085
74.3902
55.7017
78.7152
92.5897
112.022
98.1273
126.965
118.842
81.5304
58.9031
73.7898
49.7447
64.7182
98.1239
80.3349
58.9778
75.0954
53.7142
67.0983
83.0885
61.3859
75.1736
53.0433
65.8312
98.5729
82.3282
61.7971
76.8357
57.2625
68.6203
87.017
108.467
100.204
113.079
93.9796
127.363
139.434
119.43
107.265
88.6187
85.9888
98.9757
112.715
93.1667
123.995
133.394
144.044
131.009
120.133
127.949
139.112
150.849
153.6
146.899
135.532
125.361
131.241
120.895
100.08
66.7064
56.1742
77.1917
64.3591
84.8619
90.3161
83.3855
63.1421
77.9293
59.2603
69.6011
85.47
65.553
77.6966
57.8148
67.4095
100.211
90.5694
108.998
87.4249
100.814
114.065
94.9096
124.916
139.536
120.352
128.161
114.381
95.4572
78.3203
59.6451
69.3148
87.7416
109.463
101.406
85.6792
63.8744
73.6707
91.7513
105.153
90.9233
72.7786
84.0932
64.6887
73.9924
91.0524
70.3555
80.6934
60.8882
70.1948
90.7282
106.874
99.8437
114.394
97.952
108.154
120.7
131.933
126.241
135.858
146.239
139.202
143.481
129.703
134.454
125.126
140.174
120.572
103.388
87.4068
68.6611
77.8674
92.7605
74.3141
84.0896
65.1555
73.2692
106.36
97.4705
114.627
94.4559
107.215
129.321
136.256
125.583
132.798
119.192
99.516
79.966
69.2497
88.757
96.3876
76.028
85.8084
66.0738
74.438
95.7201
111.518
104.912
125.207
108.385
91.8378
71.8297
80.3019
98.9155
119.279
112.46
95.6466
73.6902
81.7363
101.057
113.906
98.0985
78.6417
87.2061
101.473
83.022
92.1767
73.1268
80.3699
113.913
95.2912
75.4936
85.1795
101.266
77.3971
84.8085
117.129
99.5732
78.9343
88.714
104.932
80.109
87.1674
121.142
101.71
79.3084
88.4185
102.45
119.844
134.32
112.741
150.538
139.785
130.906
110.025
114.661
142.658
150.665
146.401
145.769
132.426
122.91
105.686
104.718
117.23
129.174
136.662
147.325
140.895
139.064
134.046
141.475
148.611
144.229
144.235
129.572
135.907
139.952
146.382
149.836
151.445
150.695
148.7
151.766
150.341
152.759
151.771
149.385
143.526
128.632
133.853
138.97
151.714
154.805
154.976
153.396
153.875
154.075
152.996
154.691
155.884
156.194
155.624
153.699
157.335
157.539
157.225
158.542
158.953
159.181
157.703
155.126
151.675
155.358
156.551
155.196
152.959
149.996
145.294
148.977
152.628
147.465
143.523
140.065
137.01
141.742
146.605
150.541
152.818
153.513
152.451
152.857
151.999
152.12
151.658
150.744
148.491
150.793
148.119
150.778
147.517
143.295
140.187
144.561
141.548
145.408
142.693
145.987
148.741
150.702
151.446
150.97
151.267
150.719
151.308
150.662
151.771
151.301
149.774
150.849
149.302
150.689
148.978
146.446
144.157
146.899
144.779
147.436
145.484
148.114
150.415
152.044
152.7
153.3
154.323
149.195
138.841
117.032
94.6154
102.471
122.349
134.471
119.455
97.6771
105.918
126.036
143.721
137.964
147.064
152.498
155.519
153.425
156.499
151.688
138.818
120.964
104.17
97.0764
121.188
126.219
130.489
108.166
115.115
148.843
130.914
107.837
118.14
135.704
150.114
158.516
142.011
161.628
159.112
157.195
157.24
155.571
155.59
152.116
152.977
150.376
151.417
149.062
147.562
145.884
149.086
147.506
150.951
154.749
160.254
164.3
164.92
157.512
146.034
126.789
138.669
152.084
136.994
142.735
159.383
168.451
155.035
162.547
174.68
168.089
156.568
168.404
158.002
165.667
181.568
177.642
169.118
178.802
188.584
191.144
186.344
184.457
186.15
193.101
194.707
193.295
175.452
166.395
178.951
178.928
168.811
167.583
166.388
159.399
157.025
151.532
157.575
167.181
175.229
166.642
172.175
182.827
175.453
180.381
168.692
174.817
167.49
169.708
170.246
176.805
176.635
176.736
175.429
176.061
176.083
176.466
180.426
180.644
180.446
179.876
180.727
181.172
181.399
181.188
175.133
169.233
167.436
161.075
169.44
170.914
162.574
152.221
161.664
160.865
151.396
157.552
156.15
161.818
163.905
149.149
143.553
144.72
145.011
143.073
139.119
134.912
132.465
129.417
125.807
124.606
123.562
122.643
125.211
126.392
127.766
130.349
128.692
127.284
128.896
130.482
132.345
134.873
137.669
139.589
139.958
139.429
136.544
136.997
136.46
133.736
131.745
130.05
130.653
132.376
134.33
134.043
132.152
130.496
129.931
131.435
133.21
135.37
138.136
141.367
146.268
151.018
147.032
142.864
138.924
136.175
134.061
136.377
139.609
143.131
146.808
151.163
153.72
149.38
146.317
142.621
138.978
142.085
145.227
141.319
143.879
140.335
142.579
144.555
146.385
143.498
141.452
139.302
136.994
134.597
137.8
135.246
138.437
135.777
132.899
130.532
132.362
130.053
131.769
133.835
136.116
138.326
140.491
142.634
139.605
141.87
138.612
141.048
143.508
139.994
137.453
135.151
132.113
134.004
136.219
138.743
134.95
137.365
133.679
135.954
138.649
134.544
132.476
130.84
129.552
131.829
130.313
132.887
131.175
129.78
128.187
129.12
127.8
128.549
127.501
128.084
128.894
129.952
131.38
133.143
135.433
138.21
141.562
145.504
149.976
154.429
157.621
159.888
161.321
162.044
161.89
163.427
162.479
158.171
152.491
159.498
155.547
160.1
156.998
152.727
147.629
143.256
137.395
140.776
145.111
149.952
142.23
146.903
139.37
143.752
148.749
140.306
145.121
137.368
141.172
146.289
152.299
141.772
137.728
134.348
132.074
130.172
134.128
131.983
136.814
133.786
130.16
128.245
129.112
127.77
128.165
129.011
130.078
132.001
134.354
137.762
141.976
147.275
137.264
141.718
146.536
136.342
140.437
145.312
150.971
158.252
142.799
147.594
135.746
139.199
143.073
147.703
152.169
156.546
160.72
144.518
141.329
138.054
130.047
131.678
133.508
128.034
127.322
126.812
126.537
128.819
135.311
132.766
130.877
129.248
126.819
127.213
127.818
126.407
126.372
126.42
126.565
126.65
128.219
133.073
130.82
138.298
135.077
132.264
130.298
128.955
133.534
130.995
129.58
134.134
131.662
129.878
128.783
128.02
127.384
127.509
127.814
128.397
127.314
127.543
127.998
127.088
127.223
127.56
128.162
129.34
127.068
127.441
126.597
126.713
126.97
126.653
126.792
126.892
126.85
126.917
127.055
127.216
127.069
127.166
127.299
127.249
127.266
127.385
127.506
127.365
127.662
127.489
127.446
127.46
127.556
127.487
127.834
129.124
131.743
136.074
133.419
138.443
135.273
132.951
131.078
134.578
139.485
136.355
133.871
131.884
129.481
130.752
132.4
129.752
128.772
128.072
127.44
127.717
128.214
128.903
129.987
131.399
129.029
130.111
128.267
127.581
127.49
127.841
127.571
128.288
127.782
127.523
127.396
127.355
127.522
127.438
127.429
127.458
127.505
127.467
127.654
127.545
127.476
127.691
127.556
128.004
127.718
127.539
127.434
127.748
128.069
128.476
129.412
129.011
128.594
128.155
127.778
127.483
128.283
127.828
127.487
128.443
127.972
127.537
127.205
126.956
127.716
127.293
128.501
128.043
127.583
127.169
126.844
126.589
126.441
126.324
126.274
126.3
126.393
126.59
126.959
127.482
128.197
129.051
130.044
131.085
132.12
128.675
128.001
127.444
127.157
127.336
127.599
127.99
127.95
127.945
128.013
127.064
127.031
126.752
126.573
126.49
127.11
127.02
127.023
128.119
128.258
128.436
129.785
129.603
129.443
129.307
129.191
129.106
129.043
130.242
130.337
130.448
131.631
131.512
131.405
132.477
132.588
132.709
132.842
131.763
130.576
130.721
130.884
131.065
132.246
132.07
131.909
132.986
133.143
133.314
133.498
132.439
131.264
129.989
128.634
127.249
126.462
126.472
126.567
126.724
128.018
127.721
127.461
128.869
129.127
129.412
129.715
128.346
126.963
127.283
127.661
128.072
129.425
129.049
128.686
130.037
130.375
130.725
131.961
131.636
131.322
131.02
130.734
130.465
130.217
131.483
131.719
131.971
133.106
132.87
132.647
133.695
133.906
134.127
134.36
133.356
132.239
132.52
132.811
133.112
134.163
133.886
133.616
134.602
134.851
135.107
135.939
135.703
135.471
135.246
135.029
134.821
134.623
134.436
134.26
134.096
133.943
133.801
133.67
133.549
133.437
134.277
134.389
134.509
135.226
135.107
134.996
135.59
135.7
135.817
135.94
135.352
134.638
134.776
134.924
135.082
135.782
135.63
135.486
136.072
136.211
136.358
136.803
136.659
136.524
136.395
136.273
136.158
136.049
136.366
136.474
136.588
136.774
136.661
136.553
136.893
136.708
136.835
136.969
137.109
137.289
137.15
137.018
137.434
137.256
136.953
136.513
135.943
135.25
135.428
135.615
135.811
136.476
136.291
136.113
136.676
136.846
137.023
137.206
136.668
136.015
136.225
136.441
136.661
137.275
137.069
136.866
137.393
137.585
137.781
138.171
137.984
137.8
137.62
137.445
137.275
137.111
137.41
137.57
137.735
137.906
137.743
137.586
138.074
137.906
138.08
138.259
138.439
138.598
138.42
138.245
138.777
138.622
138.359
137.978
137.485
136.885
136.18
135.367
134.445
133.418
132.293
131.084
129.81
128.49
128.914
129.337
129.765
130.999
130.6
130.203
131.45
131.818
132.189
132.558
131.396
130.19
128.966
129.403
128.19
128.665
129.13
129.572
130.015
128.911
129.347
129.784
128.726
129.169
129.585
129.998
130.396
131.41
131.02
130.617
130.206
131.267
130.861
130.439
131.541
131.131
130.713
130.283
129.854
131.03
130.61
131.791
132.925
133.286
132.182
132.566
131.438
131.844
132.238
132.625
133.001
131.94
132.329
132.707
131.666
132.052
132.428
133.428
133.073
134.064
133.721
133.366
134.363
134.022
133.673
133.312
132.944
133.992
133.643
134.653
134.325
133.992
133.654
133.314
132.972
132.631
133.729
134.043
134.356
135.307
135.019
134.731
135.63
135.895
136.159
136.423
135.594
134.669
134.979
135.285
135.586
136.435
136.159
135.878
136.684
136.942
137.195
137.444
136.706
135.881
134.975
135.289
134.333
134.666
134.99
135.305
135.61
134.692
135.012
135.32
134.397
134.718
133.771
132.791
131.791
130.789
129.808
128.875
129.248
128.366
128.744
127.939
128.263
129.093
129.992
129.63
130.57
130.19
131.168
131.54
131.898
130.934
131.295
130.357
129.455
128.613
127.864
128.159
127.6
127.775
128.049
128.334
127.673
127.351
127.305
127.622
128.578
130.355
129.212
128.337
127.732
127.191
127.47
127.919
127.327
127.184
127.121
127.103
127.036
127.294
127.022
126.864
127.093
126.824
127.245
126.859
127.481
128.661
130.519
133.1
136.273
134.119
137.367
135.12
133.022
130.471
132.163
129.822
131.324
129.212
127.793
127.136
128.17
127.37
128.603
127.655
129.071
131.126
129.563
128.339
127.405
128.717
127.683
129.1
130.986
133.382
136.284
139.497
136.487
133.945
132.015
130.381
132.046
133.756
131.915
130.33
129.022
128.016
129.127
130.481
129.074
127.959
127.04
126.181
126.919
127.809
128.869
130.169
131.744
133.713
131.38
129.846
128.6
127.341
128.295
129.474
127.981
127.101
126.399
125.839
126.572
127.586
126.755
126.067
125.498
125.017
125.436
125.947
125.39
125.03
124.741
124.659
124.839
125.074
125.375
125.76
126.252
126.88
126.138
126.689
126.064
126.532
127.155
127.982
126.943
126.416
126.031
125.838
126.044
126.347
126.776
126.327
126.66
126.36
126.6
126.964
126.602
126.45
126.368
126.334
126.213
126.13
126.105
125.963
125.877
126.104
126.096
126.429
126.346
126.78
126.667
126.572
126.556
126.588
126.668
126.76
126.788
126.973
126.943
126.967
127.143
127.261
127.431
128.042
127.826
127.612
127.419
127.29
127.24
127.251
127.417
127.556
127.775
128.441
128.181
127.921
128.62
128.907
129.194
129.48
128.708
128.012
128.248
128.496
128.742
129.505
129.242
128.974
129.762
130.04
130.312
131.146
130.873
130.592
130.303
130.008
129.708
129.403
129.096
128.786
128.478
129.278
128.941
129.798
130.705
131.051
130.144
130.477
129.603
129.929
130.246
130.558
130.862
131.737
131.436
131.125
130.807
131.709
131.384
132.304
131.978
131.64
132.582
132.247
133.195
132.861
132.517
132.159
133.143
133.482
133.81
134.126
134.431
133.517
133.827
132.908
133.222
134.126
135.006
134.724
135.589
135.314
135.028
134.731
134.422
134.103
135.027
135.326
135.614
136.45
136.183
135.906
135.619
136.466
136.19
135.905
136.736
136.464
136.184
135.894
135.596
136.452
136.17
136.971
137.688
137.926
137.229
137.481
136.726
136.992
137.25
137.5
137.741
136.999
137.253
137.497
136.731
136.988
137.234
137.472
136.707
135.891
136.157
136.414
136.66
135.853
136.108
135.278
134.414
133.525
132.62
132.924
132.022
132.327
132.621
132.904
132.029
131.158
131.446
131.725
131.995
132.847
132.584
132.311
133.178
133.442
133.696
134.534
134.29
134.037
133.774
133.501
133.218
134.098
133.817
134.691
135.539
135.79
134.958
135.214
134.368
134.629
134.879
135.12
135.352
136.146
135.927
135.698
135.461
136.264
136.032
136.814
136.588
136.353
137.125
136.897
137.641
137.421
137.192
136.955
137.7
137.92
138.132
138.788
138.593
138.39
138.18
137.961
137.733
138.417
138.2
137.975
138.629
138.414
138.192
137.962
137.725
138.382
138.157
138.754
138.54
138.321
138.096
137.866
137.632
137.395
137.154
136.911
136.667
136.423
137.111
137.337
137.563
138.118
137.907
137.695
138.177
138.377
138.576
138.774
138.329
137.789
138.012
138.232
138.449
138.945
138.743
138.537
138.97
139.164
139.355
139.671
139.49
139.305
139.118
138.929
138.74
138.549
138.806
138.99
139.174
139.317
139.138
138.957
139.496
139.356
139.537
139.715
139.89
140.02
139.848
139.673
140.188
140.063
139.85
139.542
139.144
138.662
138.87
139.074
139.272
139.714
139.529
139.339
139.725
139.904
140.079
140.249
139.894
139.465
138.961
139.163
138.6
138.812
139.017
139.548
139.359
139.834
139.652
140.069
140.414
140.574
140.239
140.404
140.01
140.18
139.731
139.214
139.406
138.836
139.036
139.229
138.626
138.828
139.022
139.209
139.389
139.932
139.766
139.594
139.415
139.94
139.768
139.59
140.079
139.908
140.345
140.504
140.657
140.244
140.403
140.556
140.105
140.264
140.418
140.566
140.092
139.562
138.976
138.335
138.531
137.853
138.056
137.345
137.555
138.252
138.9
138.719
139.33
139.157
139.729
139.889
140.043
139.497
139.658
139.074
138.44
137.758
137.031
137.241
136.487
136.702
136.909
137.107
136.357
135.575
134.768
133.941
133.101
132.256
131.412
130.579
129.767
128.991
128.269
127.624
127.083
127.232
126.782
126.885
127.015
127.582
127.405
128.028
127.82
128.497
129.238
129.483
128.728
128.957
128.237
128.451
127.771
127.168
127.328
127.498
126.913
127.057
126.525
126.642
126.173
125.843
125.701
125.754
125.561
125.714
125.457
125.717
125.396
125.273
125.331
125.427
125.573
125.611
125.844
125.899
125.964
125.568
125.606
125.286
125.14
125.153
124.974
124.839
124.729
124.964
124.983
125.037
125.275
125.295
125.33
125.796
125.722
125.657
126.139
126.048
126.581
126.463
126.354
126.253
126.768
126.905
127.045
127.189
127.333
126.704
126.829
126.239
126.343
126.956
127.618
127.477
128.168
128.011
127.852
127.691
127.529
127.368
127.21
127.852
127.673
128.355
128.159
127.963
128.663
128.875
129.084
129.846
129.631
129.41
129.186
129.959
129.723
130.519
130.275
130.023
130.838
131.09
131.334
131.571
130.758
130.989
130.189
130.413
130.631
131.429
131.213
132.02
131.8
132.615
132.392
132.159
131.919
131.669
132.508
132.751
132.986
133.809
133.582
133.346
134.177
134.404
134.622
134.832
134.027
133.212
133.43
133.639
132.831
133.038
132.233
132.438
131.637
130.841
130.056
129.289
128.55
128.743
128.031
128.21
128.386
129.117
128.932
129.684
129.489
130.259
131.045
131.241
130.456
130.646
129.873
130.056
129.296
128.559
128.727
128.891
129.049
128.32
128.467
127.757
127.081
126.45
125.876
125.375
124.962
124.659
124.515
124.509
124.673
125.022
125.556
126.253
127.062
127.906
128.674
129.137
129.242
128.642
127.567
126.085
124.187
121.831
118.949
115.449
111.196
105.981
99.5109
100.078
106.238
106.473
100.613
101.124
106.695
111.11
111.136
111.167
115.162
114.898
114.66
114.448
111.096
106.91
101.616
102.095
107.121
107.334
102.563
103.023
107.551
111.122
111.098
111.091
114.261
114.1
113.963
113.85
111.161
107.774
103.478
103.929
108.006
108.251
104.378
104.827
108.513
111.375
111.288
111.217
113.759
113.688
113.638
113.605
111.475
108.786
105.278
105.731
109.062
109.341
106.185
106.638
109.621
111.83
111.703
111.585
113.591
113.589
113.6
115.046
115.122
115.215
115.327
115.461
115.618
115.8
116.009
116.247
116.517
116.82
117.16
117.54
117.962
118.431
121.108
120.461
119.883
121.786
122.493
123.288
125.044
124.131
123.324
122.606
121.155
119.363
118.897
118.479
118.103
119.621
120.08
120.589
121.964
121.387
120.868
121.884
122.445
123.069
123.764
124.543
125.422
126.421
127.431
126.38
125.458
126.021
126.953
128.012
127.955
126.942
126.06
125.285
125.201
124.643
123.917
123.268
122.684
123.238
123.821
124.472
124.597
123.985
123.436
122.944
122.713
122.158
121.378
120.399
119.209
117.766
117.465
117.196
116.957
118.201
118.502
118.837
119.975
119.592
119.246
118.932
117.93
116.745
116.558
116.394
116.249
117.271
117.468
117.686
118.648
118.39
118.156
118.937
119.194
119.477
119.787
120.129
120.505
120.92
121.683
121.252
120.862
121.424
121.811
122.239
122.5
122.099
121.737
121.408
121.072
120.508
120.185
119.891
119.623
120.193
120.459
120.752
121.109
120.838
120.59
120.365
119.949
119.379
118.703
117.944
117.095
116.123
114.986
113.625
111.964
109.903
107.089
107.537
110.185
110.467
107.98
108.416
110.748
112.411
112.255
112.106
113.662
113.71
113.767
113.834
112.574
111.027
108.841
109.252
111.306
111.583
109.659
110.06
111.855
113.084
112.916
112.745
113.906
113.982
114.059
114.136
113.25
112.122
110.454
110.839
112.381
112.632
111.212
111.573
112.871
113.713
113.565
113.41
114.212
114.287
114.361
114.433
113.853
113.096
111.92
112.253
113.307
113.505
112.571
112.874
113.69
114.22
114.108
113.985
114.502
114.564
114.617
114.978
114.971
114.961
114.948
114.933
114.918
114.905
114.892
114.882
114.876
114.874
114.877
114.888
114.909
114.941
116.014
115.919
115.836
116.666
116.794
116.936
117.752
117.576
117.417
117.273
116.551
115.765
115.704
115.651
115.604
116.27
116.354
116.447
117.142
117.023
116.916
117.562
117.68
117.812
117.957
118.118
118.295
118.489
119.157
118.954
118.77
119.342
119.526
119.728
120.16
119.973
119.803
119.649
119.175
118.603
118.452
118.317
118.195
118.764
118.887
119.024
119.51
119.383
119.269
119.164
118.652
118.085
117.455
116.818
116.193
115.564
115.528
115.495
115.466
116.004
116.061
116.124
116.73
116.651
116.581
116.521
115.953
115.44
115.415
115.392
115.37
115.838
115.87
115.908
116.469
116.426
116.39
116.982
117.028
117.078
117.134
117.199
117.275
117.36
117.987
117.897
117.813
118.373
118.458
118.551
119.07
118.983
118.903
118.83
118.296
117.737
117.669
117.608
117.551
118.101
118.161
118.225
118.764
118.702
118.646
119.2
119.249
119.303
119.362
119.426
119.496
119.572
119.655
119.747
119.847
119.956
120.078
120.211
120.358
120.521
120.7
120.897
121.114
121.353
121.617
121.908
122.23
122.588
122.984
123.426
123.924
124.485
125.118
125.836
126.654
127.588
126.952
126.129
125.413
124.948
125.552
126.251
125.587
125.015
124.525
124.1
124.423
124.788
124.24
123.755
123.326
123.204
123.56
123.963
123.732
123.411
123.131
123.141
123.352
123.593
123.874
124.201
124.582
125.03
124.625
124.29
124.01
123.963
124.156
124.389
124.323
124.17
124.044
123.949
123.799
123.773
123.571
123.396
123.248
123.468
123.554
123.662
123.881
123.828
123.787
123.755
123.395
123.127
122.956
122.885
122.889
122.942
122.6
122.295
122.022
122.142
122.362
122.61
122.666
122.476
122.308
122.158
121.945
121.777
121.555
121.355
121.175
121.467
121.61
121.768
122.025
121.906
121.8
122.187
122.261
122.343
122.437
122.543
122.663
122.799
123.023
122.932
122.854
123.242
123.284
123.335
123.731
123.714
123.701
123.694
123.207
122.787
122.728
122.677
122.632
123.134
123.154
123.178
123.689
123.688
123.688
124.289
124.271
124.255
124.239
124.224
124.211
124.202
124.195
124.195
124.198
124.209
124.231
124.266
124.317
124.399
124.625
124.611
124.608
125.043
125.007
124.98
125.43
125.492
125.557
125.625
125.084
124.615
124.631
124.653
124.678
125.228
125.178
125.13
125.695
125.763
125.831
126.478
126.397
126.312
126.226
126.138
126.049
125.962
126.558
126.665
126.77
127.443
127.326
127.205
127.892
128.022
128.148
128.268
127.556
126.873
126.972
127.068
127.16
127.869
127.769
127.665
128.383
128.494
128.599
128.699
127.964
127.248
126.557
125.898
125.278
124.707
124.737
124.769
124.801
125.424
125.376
125.327
125.962
126.025
126.085
126.143
125.471
124.834
124.866
124.898
124.929
125.602
125.56
125.516
126.198
126.252
126.302
127.023
126.966
126.906
126.843
126.776
126.706
126.633
127.333
127.414
127.491
128.224
128.142
128.055
128.795
128.886
128.972
129.054
128.303
127.564
127.634
127.7
127.762
128.513
128.447
128.377
129.131
129.204
129.273
129.337
128.575
127.82
127.077
126.35
125.642
124.959
124.306
123.69
123.117
122.593
122.122
121.705
121.338
121.011
120.863
120.729
120.608
121.023
121.118
121.222
121.619
121.542
121.472
121.41
120.937
120.498
120.399
120.308
120.226
120.724
120.789
120.86
121.353
121.301
121.254
121.82
121.851
121.885
121.922
121.964
122.011
122.063
122.558
122.528
122.502
123.082
123.092
123.103
123.694
123.698
123.703
123.708
123.075
122.478
122.457
122.438
122.422
123.058
123.063
123.068
123.714
123.72
123.725
123.73
123.054
122.407
121.791
121.211
120.665
120.15
120.081
120.018
119.96
120.517
120.562
120.612
121.172
121.136
121.104
121.074
120.476
119.907
119.858
119.814
119.773
120.373
120.404
120.438
121.047
121.022
121
121.655
121.669
121.685
121.702
121.721
121.743
121.766
122.393
122.381
122.369
123.045
123.048
123.051
123.735
123.739
123.743
123.747
123.042
122.359
122.35
122.341
122.334
123.035
123.037
123.039
123.75
123.753
123.755
124.491
124.485
124.478
124.471
124.462
124.453
124.442
124.43
124.418
124.404
124.39
124.374
124.358
124.341
124.324
124.988
125.016
125.042
125.75
125.716
125.68
126.395
126.438
126.478
126.515
125.782
125.067
125.09
125.112
125.132
125.865
125.839
125.812
126.55
126.582
126.612
127.37
127.337
127.301
127.262
127.22
127.176
127.128
127.875
127.927
127.975
128.739
128.688
128.633
129.398
129.455
129.508
129.558
128.786
128.02
128.062
128.101
128.137
128.911
128.872
128.831
129.605
129.648
129.688
129.725
128.946
128.171
127.401
126.639
125.888
125.151
125.168
125.184
125.198
125.948
125.93
125.91
126.665
126.688
126.709
126.728
125.964
125.211
125.222
125.232
125.241
126.003
125.991
125.978
126.745
126.76
126.774
127.552
127.537
127.519
127.5
127.479
127.455
127.429
128.201
128.229
128.255
129.036
129.009
128.979
129.759
129.791
129.82
129.847
129.061
128.279
128.3
128.319
128.336
129.123
129.105
129.084
129.871
129.892
129.912
129.929
129.139
128.351
127.566
126.786
126.013
125.249
124.496
123.757
123.033
122.327
121.642
120.981
120.345
119.737
119.155
118.594
118.045
117.496
116.936
116.359
115.811
115.35
114.98
114.661
114.318
113.86
113.158
113.424
114.014
114.15
113.667
113.887
114.269
114.525
114.471
114.402
114.695
114.719
114.734
114.739
114.564
114.369
114.082
114.249
114.449
114.509
114.385
114.484
114.545
114.601
114.602
114.59
114.733
114.718
114.694
114.877
114.914
114.94
114.958
114.969
114.976
114.979
115.333
115.317
115.303
115.751
115.77
115.789
116.331
116.303
116.269
116.233
115.728
115.286
115.263
115.231
115.188
115.613
115.657
115.697
116.194
116.152
116.112
116.649
116.683
116.723
116.764
116.807
116.85
116.892
117.445
117.397
117.351
117.901
117.945
117.993
118.546
118.503
118.464
118.43
117.861
117.308
117.268
117.232
117.204
117.773
117.796
117.826
118.4
118.376
118.36
118.966
118.977
118.995
119.018
119.046
119.078
119.114
119.704
119.676
119.651
120.281
120.3
120.321
120.964
120.949
120.937
120.927
120.267
119.63
119.613
119.6
119.594
120.244
120.247
120.255
120.919
120.915
120.914
121.604
121.603
121.605
121.609
121.615
121.622
121.631
122.321
122.317
122.313
123.03
123.03
123.032
123.759
123.761
123.762
123.764
123.03
122.31
122.309
122.31
122.312
123.036
123.032
123.03
123.766
123.77
123.773
124.524
124.52
124.516
124.512
124.509
124.505
124.501
125.256
125.262
125.267
126.036
126.029
126.022
126.796
126.805
126.813
126.819
126.041
125.272
125.276
125.28
125.285
126.055
126.051
126.046
126.824
126.829
126.832
127.615
127.612
127.608
127.602
127.596
127.587
127.577
128.363
128.374
128.383
129.174
129.164
129.153
129.943
129.956
129.966
129.973
129.181
128.391
128.396
128.4
128.403
129.192
129.191
129.187
129.979
129.982
129.983
130.772
130.772
130.77
130.764
130.757
130.746
130.733
130.718
130.7
130.68
130.657
130.632
130.604
130.574
130.541
130.505
130.467
130.425
130.38
130.332
130.281
130.226
130.167
130.105
130.038
129.968
129.893
129.813
129.729
129.64
129.546
129.448
129.344
129.235
129.121
129.001
128.876
128.745
128.609
129.348
129.202
129.954
129.799
129.638
129.47
130.231
130.401
130.563
131.335
131.173
131.005
130.829
131.611
131.429
132.217
132.031
131.838
132.635
132.824
133.005
133.179
132.395
132.566
131.784
131.951
132.111
132.887
132.73
133.507
133.347
134.122
133.959
133.79
133.613
133.429
133.238
134.033
133.84
134.633
134.439
134.237
135.033
135.227
135.414
136.177
135.998
135.813
135.62
135.419
135.21
134.993
135.79
135.996
136.195
136.943
136.755
136.56
137.298
137.482
137.659
137.829
137.124
136.386
136.569
136.746
136.916
137.627
137.465
137.298
137.993
138.151
138.303
138.45
137.782
137.08
136.348
135.593
134.82
134.999
134.219
134.397
134.568
135.336
135.171
135.931
135.766
136.514
137.237
137.389
136.672
136.825
136.09
136.243
135.495
134.732
134.89
135.041
134.278
134.428
133.66
133.807
133.038
132.264
131.49
130.718
130.867
130.102
130.244
129.488
129.622
130.38
131.145
131.009
131.779
131.638
132.41
132.55
132.684
131.915
132.044
131.275
130.509
129.75
129.872
129.989
130.1
130.863
130.751
130.633
131.399
131.517
131.63
132.397
132.285
132.167
132.934
132.812
133.577
133.451
133.319
133.182
133.948
134.083
134.212
134.335
134.452
133.697
133.811
133.051
133.161
133.92
134.671
134.564
135.307
135.198
135.084
134.964
134.839
134.708
134.571
135.325
135.186
135.933
135.793
135.647
136.39
136.531
136.666
137.378
137.248
137.112
136.972
137.675
137.535
138.214
138.075
137.931
138.591
138.727
138.859
138.985
138.348
138.476
137.81
137.94
138.064
138.72
138.6
139.225
139.107
139.7
139.584
139.465
139.341
139.213
139.08
138.942
138.8
138.651
138.498
138.338
138.172
138
137.821
137.635
137.442
138.14
137.953
138.621
139.241
139.402
138.795
138.962
138.32
138.494
138.661
138.822
138.976
139.572
139.428
139.278
139.123
139.707
139.558
140.106
139.962
139.813
140.335
140.192
140.674
140.536
140.394
140.246
140.708
140.845
140.977
141.104
141.227
140.806
140.933
140.472
140.605
141.056
141.459
141.345
141.708
141.598
141.484
141.366
141.243
141.115
140.983
140.846
140.704
141.086
140.948
140.805
141.149
141.01
140.866
140.717
140.563
140.88
140.73
140.982
140.834
140.681
140.524
140.362
140.195
140.024
140.231
140.396
140.557
140.672
140.515
140.353
140.825
140.713
140.865
141.013
141.156
141.259
141.119
140.974
141.395
141.295
141.125
141.264
141.025
141.166
141.301
141.433
141.559
141.282
141.412
141.536
141.218
141.346
141.47
141.588
141.703
141.991
141.883
141.772
141.656
141.912
141.799
141.681
141.889
141.773
141.652
141.527
141.398
141.558
141.429
141.526
141.653
141.776
141.683
141.804
141.921
142.034
142.142
142.002
142.11
142.215
142.022
142.127
142.229
142.327
142.095
141.814
141.92
142.023
142.122
141.814
141.916
141.569
141.175
140.733
140.244
140.377
139.851
139.989
140.123
140.252
139.711
139.125
139.269
139.408
139.541
140.098
139.973
139.844
140.376
140.496
140.612
141.083
140.976
140.864
140.749
140.629
140.505
140.975
140.856
141.289
141.675
141.777
141.399
141.505
141.09
141.201
141.308
141.411
141.512
141.897
141.804
141.708
141.608
141.972
141.876
142.203
142.11
142.015
142.31
142.218
142.475
142.385
142.292
142.195
142.422
142.514
142.603
142.771
142.686
142.598
142.507
142.413
142.316
142.447
142.349
142.247
142.328
142.226
142.119
142.008
141.894
142.428
142.524
142.616
142.541
142.632
142.72
142.805
142.887
142.956
142.875
142.792
142.706
143.034
142.967
142.853
142.688
142.771
142.563
142.647
142.4
142.487
142.729
142.929
142.851
143.009
142.933
143.044
143.119
143.191
143.084
143.156
143.004
142.808
142.57
142.292
142.379
142.064
142.154
142.241
142.325
141.987
141.609
141.188
140.724
140.218
139.67
139.794
139.915
140.031
140.556
140.447
140.335
140.833
140.937
141.039
141.137
140.661
140.143
140.252
140.357
139.811
139.919
139.339
139.449
138.835
138.184
137.502
136.795
136.068
136.196
135.458
135.585
135.707
136.436
136.319
137.038
136.919
137.622
138.3
138.411
137.737
137.847
137.151
137.26
136.549
135.823
135.933
136.039
136.14
135.411
135.51
134.772
134.023
133.266
132.503
131.737
130.97
130.206
130.307
130.402
130.493
131.259
131.168
131.072
131.839
131.935
132.027
132.113
131.346
130.578
130.659
130.736
130.808
131.577
131.504
131.427
132.195
132.272
132.345
133.109
133.036
132.959
132.877
132.791
132.7
132.605
133.366
133.461
133.551
134.304
134.215
134.122
134.869
134.961
135.048
135.131
134.389
133.637
133.718
133.794
133.867
134.617
134.545
134.469
135.21
135.285
135.356
136.083
136.013
135.94
135.862
135.78
135.695
135.605
136.329
136.237
136.95
136.857
136.759
136.656
137.364
137.463
137.558
138.242
138.15
138.053
137.952
138.619
138.517
139.156
139.053
138.946
139.555
139.658
139.758
139.854
139.255
139.351
138.718
138.812
138.902
139.532
139.443
140.037
139.947
140.501
140.411
140.319
140.224
140.125
140.024
140.558
140.459
140.958
140.862
140.763
141.233
141.326
141.415
141.833
141.749
141.662
141.573
141.481
141.386
141.288
141.702
141.794
141.882
142.242
142.16
142.075
142.407
142.486
142.563
142.638
142.322
141.968
142.051
142.132
142.211
142.55
142.476
142.4
142.711
142.782
142.852
143.117
143.052
142.985
142.916
142.846
142.773
142.699
142.622
142.544
142.462
142.73
142.651
142.884
143.077
143.148
142.959
143.031
142.806
142.88
142.952
143.023
143.091
143.3
143.236
143.169
143.101
143.283
143.217
143.361
143.294
143.226
143.33
143.262
143.324
143.255
143.183
143.11
143.391
143.456
143.396
143.461
143.52
143.581
143.523
143.425
143.488
143.349
143.412
143.474
143.534
143.364
143.157
143.222
143.286
143.348
143.545
143.486
143.425
143.594
143.651
143.708
143.835
143.78
143.724
143.667
143.609
143.549
143.644
143.584
143.642
143.7
143.758
143.702
143.759
143.815
143.869
143.923
143.975
143.922
143.868
143.814
144.026
143.975
143.889
143.764
143.603
143.409
143.182
142.92
142.622
142.288
141.915
141.503
141.051
141.141
140.654
140.747
140.838
141.315
141.229
141.671
141.588
141.995
142.363
142.436
142.073
142.149
141.752
141.83
141.399
140.926
141.012
141.095
140.588
140.672
140.123
140.207
139.617
138.989
138.33
137.649
137.736
137.039
137.125
136.416
136.5
137.206
137.897
137.818
138.495
138.415
139.072
139.151
139.226
138.572
138.645
137.972
137.283
136.58
136.656
136.728
136.796
137.495
137.428
137.357
138.044
138.112
138.178
138.845
138.782
138.715
139.367
139.298
139.924
139.853
139.777
139.699
140.288
140.366
140.442
140.514
140.584
139.993
140.059
139.432
139.495
140.121
140.715
140.651
141.2
141.131
141.06
140.987
140.911
140.834
140.754
141.256
141.176
141.637
141.56
141.48
141.908
141.983
142.057
142.437
142.367
142.296
142.223
142.578
142.507
142.829
142.762
142.693
142.986
143.051
143.115
143.178
142.896
142.961
142.646
142.714
142.78
143.087
143.025
143.3
143.24
143.485
143.426
143.367
143.306
143.245
143.469
143.527
143.585
143.771
143.716
143.66
143.818
143.872
143.925
143.977
143.825
143.641
143.697
143.752
143.542
143.599
143.36
143.419
143.15
142.846
142.507
142.13
141.714
141.789
141.334
141.41
141.484
141.935
141.862
142.272
142.202
142.575
142.911
142.975
142.642
142.709
142.342
142.411
142.006
141.557
141.628
141.698
141.766
141.266
141.33
140.776
140.181
139.554
138.905
138.24
137.558
136.862
136.15
135.424
134.685
133.936
133.178
132.414
131.646
130.875
130.939
130.999
131.055
131.828
131.771
131.71
132.479
132.54
132.597
132.651
131.881
131.108
131.157
131.202
131.245
132.021
131.978
131.931
132.702
132.749
132.793
133.559
133.514
133.467
133.416
133.362
133.304
133.243
134
134.061
134.119
134.867
134.81
134.749
135.487
135.548
135.605
135.658
134.921
134.173
134.224
134.272
134.317
135.065
135.02
134.972
135.709
135.757
135.803
135.845
135.108
134.359
133.601
132.834
132.062
131.285
131.322
131.356
131.387
132.167
132.134
132.099
132.873
132.908
132.941
132.972
132.196
131.416
131.442
131.466
131.487
132.27
132.248
132.223
132.999
133.024
133.047
133.817
133.794
133.768
133.74
133.709
133.676
133.639
134.398
134.435
134.469
135.218
135.184
135.147
135.885
135.922
135.956
135.988
135.25
134.5
134.529
134.555
134.578
135.329
135.305
135.279
136.017
136.044
136.068
136.794
136.77
136.743
136.713
136.681
136.646
136.609
136.569
136.527
136.481
136.433
136.383
136.329
136.273
136.213
136.924
136.983
137.039
137.733
137.677
137.619
138.299
138.356
138.41
138.461
137.785
137.092
137.143
137.19
137.235
137.928
137.883
137.835
138.51
138.557
138.602
139.258
139.214
139.168
139.121
139.07
139.018
138.963
139.61
139.664
139.715
140.341
140.291
140.237
140.835
140.89
140.942
140.991
140.389
139.764
139.81
139.854
139.896
140.519
140.478
140.435
141.038
141.082
141.123
141.161
140.558
139.937
139.299
138.644
137.97
137.278
137.318
137.355
137.39
138.083
138.048
138.01
138.684
138.721
138.757
138.79
138.115
137.423
137.453
137.48
137.505
138.199
138.174
138.146
138.821
138.849
138.875
139.531
139.505
139.476
139.444
139.411
139.376
139.338
139.975
140.012
140.046
140.664
140.63
140.595
141.198
141.233
141.266
141.297
140.696
140.079
140.111
140.14
140.167
140.783
140.756
140.727
141.327
141.355
141.382
141.964
141.938
141.91
141.88
141.849
141.815
141.779
141.741
141.7
141.656
141.609
141.559
141.506
141.45
141.392
141.897
141.833
142.282
142.215
142.146
142.077
142.479
142.547
142.614
142.97
142.905
142.84
142.775
143.101
143.038
143.332
143.272
143.211
143.477
143.535
143.592
143.648
143.391
143.45
143.163
143.225
143.287
143.569
143.51
143.761
143.705
143.927
143.873
143.819
143.765
143.71
143.655
143.859
143.806
143.983
143.931
143.878
144.028
144.078
144.128
144.241
144.193
144.144
144.094
144.044
143.993
143.941
144.026
144.077
144.127
144.175
144.126
144.077
144.224
144.176
144.224
144.272
144.319
144.365
144.318
144.271
144.411
144.366
144.289
144.178
144.034
144.084
143.912
143.965
144.017
144.184
144.135
144.275
144.226
144.336
144.412
144.458
144.383
144.43
144.323
144.371
144.234
144.068
144.12
144.171
143.981
144.034
143.817
143.873
143.628
143.349
143.035
142.681
142.747
142.348
142.414
141.96
142.021
142.478
142.879
142.813
143.164
143.099
143.411
143.474
143.537
143.229
143.295
142.944
142.541
142.079
142.134
142.187
142.237
142.718
142.661
142.602
143.009
143.073
143.136
143.493
143.426
143.36
143.665
143.601
143.869
143.808
143.747
143.687
143.93
143.987
144.045
144.104
144.163
143.931
143.995
143.731
143.797
144.059
144.286
144.224
144.423
144.365
144.308
144.252
144.197
144.142
144.088
144.274
144.222
144.382
144.333
144.283
144.419
144.466
144.514
144.616
144.57
144.523
144.477
144.55
144.504
144.548
144.503
144.457
144.593
144.638
144.596
144.641
144.687
144.728
144.683
144.773
144.732
144.663
144.562
144.432
144.481
144.326
144.378
144.431
144.582
144.532
144.658
144.61
144.709
144.778
144.824
144.756
144.804
144.707
144.756
144.633
144.484
144.538
144.593
144.65
144.482
144.542
144.349
144.125
143.864
143.559
143.198
142.773
142.284
142.327
142.368
142.405
142.919
142.874
142.825
143.258
143.316
143.372
143.425
142.962
142.44
142.472
142.502
142.529
143.068
143.036
143
143.475
143.521
143.563
143.992
143.936
143.878
143.817
143.754
143.69
143.624
143.932
144
144.069
144.33
144.261
144.192
144.414
144.481
144.548
144.618
144.401
144.138
144.207
144.275
144.341
144.617
144.544
144.472
144.689
144.761
144.835
145.01
144.938
144.868
144.8
144.733
144.668
144.604
144.766
144.707
144.846
144.791
144.738
144.685
144.806
144.857
144.908
144.998
144.949
144.9
144.852
144.917
144.87
144.91
144.864
144.819
144.956
145.002
144.964
145.012
145.061
145.097
145.05
145.146
145.11
145.049
144.961
145.014
144.902
144.96
144.827
144.889
145.019
145.125
145.069
145.153
145.101
145.16
145.211
145.263
145.207
145.262
145.183
145.079
144.952
145.018
145.085
145.153
145.269
145.205
145.141
145.241
145.301
145.362
145.432
145.374
145.318
145.37
145.316
145.348
145.296
145.245
145.195
145.401
145.454
145.425
145.479
145.507
145.56
145.534
145.489
145.423
145.334
145.222
145.083
144.909
144.69
144.406
144.044
143.601
143.097
142.554
141.988
141.407
140.809
140.192
139.555
138.898
138.221
137.527
136.815
136.089
135.35
134.599
133.837
133.066
132.289
131.505
131.521
131.535
131.545
132.33
132.319
132.305
133.083
133.097
133.109
133.117
132.338
131.553
131.558
131.56
131.56
132.343
132.344
132.342
133.121
133.122
133.12
133.891
133.893
133.892
133.888
133.88
133.869
133.854
134.616
134.631
134.643
135.395
135.383
135.368
136.108
136.123
136.135
136.144
135.403
134.651
134.655
134.656
134.653
135.404
135.408
135.408
136.148
136.149
136.144
136.872
136.876
136.876
136.872
136.863
136.85
136.834
137.546
137.562
137.575
138.271
138.258
138.241
138.919
138.936
138.95
138.961
138.281
137.585
137.589
137.59
137.585
138.282
138.287
138.287
138.967
138.968
138.963
139.626
139.63
139.628
139.622
139.61
139.595
139.577
140.214
140.234
140.25
140.869
140.852
140.832
141.43
141.451
141.469
141.483
140.883
140.262
140.27
140.273
140.269
140.893
140.895
140.892
141.494
141.499
141.497
142.084
142.084
142.077
142.066
142.05
142.032
142.011
142.577
142.598
142.617
143.167
143.146
143.123
143.636
143.666
143.693
143.716
143.185
142.633
142.645
142.653
142.654
143.212
143.209
143.199
143.735
143.75
143.757
144.28
144.263
144.239
144.209
144.175
144.136
144.092
144.469
144.529
144.585
144.904
144.834
144.762
144.985
145.062
145.138
145.215
144.972
144.636
144.683
144.725
144.757
145.152
145.099
145.038
145.291
145.366
145.436
145.613
145.54
145.463
145.385
145.309
145.232
145.157
145.292
145.364
145.435
145.531
145.466
145.4
145.484
145.544
145.603
145.659
145.596
145.507
145.579
145.65
145.715
145.769
145.72
145.659
145.712
145.758
145.792
145.8
145.777
145.742
145.7
145.652
145.6
145.545
145.587
145.637
145.683
145.699
145.657
145.61
145.734
145.723
145.757
145.784
145.801
145.801
145.787
145.764
149.596
174.96
142.641
101.988
93.9514
114.728
121.514
133.378
142.169
129.319
125.319
105.739
110.425
135.283
93.8002
63.8456
84.0493
87.8348
143.085
83.7721
46.982
75.179
42.1545
71.6865
91.8148
144.057
202.559
110.273
111.674
112.692
113.794
113.439
112.863
113.764
114.042
114.517
114.206
114.338
113.98
113.3
114.546
114.639
114.587
114.58
114.561
114.559
114.608
114.77
115.086
115.533
116.057
116.613
117.181
117.76
118.353
118.965
119.596
120.248
120.92
121.611
122.32
123.043
123.781
124.53
125.29
126.059
126.836
127.618
128.404
129.192
129.981
130.769
131.554
132.335
133.111
133.879
134.638
135.388
136.126
136.851
137.562
138.257
138.936
139.598
140.24
140.863
141.467
142.053
142.626
143.188
143.74
144.279
144.784
145.22
145.541
145.724
145.794
145.811
145.813
145.811
145.809
)
;
boundaryField
{
bottomEmptyFaces
{
type empty;
}
topEmptyFaces
{
type empty;
}
inlet
{
type turbulentIntensityKineticEnergyInlet;
intensity 0.15;
value nonuniform List<scalar>
70
(
145.807
145.808
145.811
145.814
145.818
145.816
145.764
145.571
145.218
144.751
144.227
143.681
143.128
142.571
142.005
141.424
140.826
140.207
139.569
138.911
138.234
137.541
136.833
136.11
135.374
134.626
133.868
133.102
132.328
131.548
130.763
129.976
129.188
128.401
127.616
126.835
126.059
125.291
124.531
123.783
123.046
122.323
121.616
120.926
120.255
119.604
118.974
118.365
117.774
117.195
116.624
116.056
115.506
115.015
114.656
114.484
114.47
114.529
114.603
114.706
114.698
114.647
114.672
114.444
114.07
113.485
145.806
107.423
111.406
112.509
)
;
}
outlet
{
type inletOutlet;
inletValue uniform 1;
value nonuniform List<scalar>
34
(
134.682
134.695
134.716
134.75
134.796
134.858
134.937
135.039
135.168
135.334
135.544
135.813
136.153
136.579
137.095
137.679
138.249
138.61
138.404
137.263
134.593
129.329
102.692
118.742
97.1666
88.9089
72.7445
62.2331
61.4274
76.4732
134.676
128.642
142.572
109.738
)
;
}
walls
{
type kqRWallFunction;
value nonuniform List<scalar>
768
(
112.911
113.114
112.789
113.03
112.769
113.048
112.825
113.159
112.951
113.315
113.116
113.497
113.306
113.7
113.517
113.918
113.742
114.151
113.981
114.393
114.229
114.647
114.489
114.909
114.756
115.179
115.03
115.455
115.311
115.738
115.598
116.024
115.889
116.314
116.182
116.604
116.475
116.894
116.767
117.177
117.051
117.451
117.325
117.712
117.586
117.959
117.832
118.189
118.061
118.405
118.275
118.602
118.471
118.784
118.652
118.949
118.815
119.099
118.965
119.236
119.101
119.361
119.226
119.475
119.338
119.579
119.443
119.673
119.537
119.761
119.625
119.84
119.704
119.914
119.778
119.981
119.844
120.044
119.907
120.101
119.964
120.154
120.019
120.204
120.068
120.25
120.115
120.293
120.157
120.333
120.198
120.369
120.235
120.404
120.27
120.435
120.301
120.465
120.331
120.492
120.358
120.518
120.384
120.542
120.407
120.564
120.429
120.584
120.449
120.603
120.468
120.62
120.484
120.635
120.5
120.65
120.514
120.662
120.527
120.674
120.538
120.685
120.549
120.695
120.559
120.704
120.569
120.714
120.579
120.724
120.59
120.735
120.601
120.746
120.614
120.759
120.627
120.774
120.644
120.79
120.661
120.808
120.681
120.829
120.701
120.851
120.725
120.874
120.749
120.898
120.774
120.924
120.801
120.952
120.83
120.983
120.862
121.02
120.899
121.105
120.993
121.179
121.068
121.349
121.258
121.696
122.08
123.222
125.098
126.7
29.1893
28.5306
28.1324
29.8384
28.6912
29.2121
28.3864
30.335
28.0135
29.8882
44.9405
41.3372
51.5317
42.7356
53.6968
41.6426
38.2933
35.2349
43.4693
36.4571
45.4732
39.9628
37.9757
47.5459
36.7768
45.5558
43.5195
41.101
51.9104
38.3178
47.3936
39.4401
49.4407
39.5257
49.4407
29.5099
35.2771
31.2713
31.9643
29.6907
36.3648
28.4163
33.6976
32.5037
29.4667
35.502
30.4945
37.369
28.573
27.4134
32.6042
27.914
28.5136
26.8738
31.354
26.2045
29.9602
28.6003
27.0081
31.0487
27.618
26.632
30.8531
27.8817
26.5173
30.6465
30.2482
27.8515
32.2684
28.0552
26.7936
31.6154
29.3686
30.1395
28.1495
33.4123
28.0535
32.6003
30.7767
29.136
34.8101
29.0607
34.3645
27.5066
32.1896
34.9006
31.7725
38.4606
32.8188
40.479
36.1397
37.1811
35.1093
43.8143
32.9942
40.1885
33.7846
42.229
35.7856
33.5308
41.7164
32.1696
39.4798
33.1184
29.8345
35.7745
32.7959
30.824
37.7211
31.4929
38.323
33.8835
41.8218
129.463
118.44
157.569
96.4514
76.76
67.4469
86.0963
82.6897
74.0249
95.1626
78.0532
101.325
72.6271
92.6399
84.2877
79.05
101.757
89.961
84.046
109.959
90.326
79.4101
102.705
84.4049
109.065
109.772
101.345
133.628
97.4111
90.7338
117.741
85.6765
110.642
90.2586
117.801
103.419
89.5775
94.804
100.187
96.5502
126.359
118.967
110.148
146.327
114.913
105.457
139.068
125.04
114.012
151.258
47.4197
70.2402
61.9645
65.6195
84.6503
74.4096
79.5265
58.7326
55.4802
48.8869
52.3723
161.45
154.385
158.239
150.691
141.274
145.92
164.613
167.563
170.662
173.668
176.939
178.562
135.899
124.473
130.644
118.751
106.38
112.396
180.395
181.143
181.697
180.669
173.086
177.296
166.717
150.955
159.072
142.875
131.708
114.997
121.066
108.788
101.001
92.4731
82.287
85.516
82.9816
81.6748
37.7898
40.0006
43.9468
35.9545
31.3001
31.6929
30.8465
30.6089
29.9637
30.7888
30.5567
28.7346
31.3057
83.4791
79.7712
76.3907
70.1572
70.1378
67.9731
64.7661
61.3237
57.4354
53.851
145.875
131.052
176.493
138.619
124.18
167.673
134.621
122.629
163.399
141.001
50.1674
129.466
173.341
46.4329
40.088
42.0826
40.5014
166.923
35.6249
144.299
31.9966
166.806
149.161
202.272
26.8753
23.7936
185.53
162.805
225.773
178.622
203.058
21.2933
20.2705
19.4639
19.2288
18.9489
19.0298
18.8453
18.9156
194.133
217.757
176.306
256.129
198.943
218.674
247.182
263.168
230.333
253.025
276.446
209.752
306.075
292.929
308.32
309.543
304.561
173.74
239.988
294.63
277.456
260.184
242.933
227.252
212.511
199.756
188.188
178.23
169.349
161.591
154.827
148.801
143.611
138.946
134.995
131.378
128.445
125.616
123.542
121.238
119.991
118.104
117.475
115.966
115.696
114.563
114.506
113.704
113.778
113.19
113.335
18.7592
18.8324
18.641
18.6878
18.3175
18.1764
17.697
17.4975
17.0334
16.9076
16.5161
16.4579
16.127
16.0974
15.7986
15.7864
15.5066
15.5001
15.2343
15.2327
14.977
14.9753
14.7288
14.7304
14.4922
14.4969
14.271
14.279
14.066
14.0765
13.8661
13.8787
13.6812
13.6928
13.4958
13.5066
13.308
13.3168
13.1237
13.1341
12.9459
12.9594
12.7832
12.798
12.6263
12.6448
12.4858
12.5071
12.3525
12.3792
12.2413
12.2686
12.124
12.1501
12.0047
12.0246
11.8639
11.8733
11.7438
11.7911
11.7829
11.9631
12.3426
12.5784
57.9175
53.3881
48.797
61.2484
50.4663
64.17
55.8089
53.0179
67.3134
50.8305
64.224
62.9607
57.9638
72.9036
59.9488
76.2286
67.9921
65.7342
83.9684
73.7698
64.7106
82.3923
69.2026
89.3482
66.1378
62.715
79.8126
59.7297
76.246
60.9145
57.6293
73.441
53.4077
67.0163
55.0652
69.7739
55.2723
69.9533
49.0697
51.2887
48.6886
61.6389
44.9908
56.3856
46.6025
58.7715
47.0677
44.7835
56.3879
43.1374
54.0552
46.8858
58.9378
74.9473
70.7361
91.0675
12.6546
128.642
88.9329
79.83
72.8702
67.0518
62.8451
59.1395
56.4287
53.9058
52.1575
50.334
49.1172
47.7293
46.824
45.7228
45.0105
44.107
43.5175
42.7502
42.2457
41.5759
41.132
40.5338
40.1339
39.5891
39.2218
38.7179
38.3754
37.9034
37.58
37.1332
36.8248
36.3981
36.1013
35.6907
35.4028
35.005
34.7239
34.3362
34.0601
33.6801
33.4073
33.0331
32.7624
32.392
32.1221
31.754
31.4837
31.1163
30.8444
30.4762
30.2019
29.8315
29.5537
29.1801
28.898
28.5197
28.2325
27.8485
27.5552
27.1639
26.8633
26.4636
26.1552
25.7465
25.4298
25.0106
24.684
24.253
23.9164
23.474
23.1278
22.6731
22.3162
21.8487
21.4821
21.0035
20.6279
20.1367
19.7514
19.2489
18.8582
18.3496
17.9532
17.4366
17.0374
16.5214
16.1272
15.6133
15.2202
14.7146
14.3407
13.86
13.5074
13.0438
12.713
12.2885
12.002
11.6224
11.3763
11.042
10.8422
10.5675
10.4201
10.2045
10.1074
9.94784
9.89199
9.78768
9.76935
9.72034
9.71873
9.69548
9.70392
9.69457
9.71163
9.71073
9.732
9.74014
9.77237
9.7867
9.83048
9.84389
9.878
9.88491
9.9074
9.92007
9.95556
9.97236
10.0123
10.0275
10.066
10.0752
10.0977
10.111
10.1464
10.1665
10.2029
10.2165
10.2355
10.2368
10.2464
10.2493
10.2678
10.2838
10.3138
10.3591
10.3572
10.4032
10.5171
100.181
10.6374
)
;
}
rightWall
{
type inletOutlet;
inletValue uniform 1;
value nonuniform List<scalar>
30
(
30.6393
38.8549
46.3321
52.9786
60.9408
65.9
69.2638
72.2168
74.0922
75.1013
75.3471
74.9297
73.9614
72.4105
70.3574
67.7461
64.6838
60.9029
56.6743
51.3086
46.2606
40.1642
33.7868
26.8379
12.6546
19.557
22.7097
10.6374
15.7671
19.595
)
;
}
symmetryLine
{
type symmetryPlane;
}
}
// ************************************************************************* //
|
|
b8ab38c5eab89ce15baabde3ed458784962a9466
|
e9bfd0de76a01de74baf3c7b993c1e1b91095cd1
|
/apps/DirectMemoryAccess/Demo/Effect.h
|
5febdbdfc8e8f15f776573a254337c9bb91f3470
|
[] |
no_license
|
UIKit0/mowa.cc
|
95ea22c88aff4f893614ec0deb6016bc3476677a
|
91ec92a6345148a41b2df7c3f126d2048e43f2ba
|
refs/heads/master
| 2020-04-06T04:38:53.029613
| 2010-01-15T15:29:49
| 2010-01-15T15:29:49
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 475
|
h
|
Effect.h
|
/*
* Effect.h
* DMA
*
* Created by vorg on 2009-10-17.
* Copyright 2009 Vorg. All rights reserved.
*
*/
#ifndef EFFECT_H
#define EFFECT_H
#include "Utils.h"
using namespace flow;
class Effect {
public:
Effect() {}
virtual ~Effect() {};
virtual void draw() {};
virtual void onMouseDown(int x, int y, int key = 1) {};
virtual void onMouseUp(int x, int y, int key = 1) {};
virtual void onMouseMove(int x, int y, int key = 1) {};
};
#endif EFFECT_H
|
93502c1bf689d5a0373f685fc67134309a156ec7
|
eeb014a48d22e38bb4f866838c06f64ac2b4f4c6
|
/recursion/findPath.cpp
|
6245b353b7de08c4eca46f5ee1c4f5014f3671a0
|
[] |
no_license
|
oumkale/Geeks-For-Geeks-Work
|
8cb2b7948fe1afc4dfa18d6d30f9ca1fc83db9cf
|
96893a593b8e1dc03e0d8d3d23c279cd7968e1e6
|
refs/heads/master
| 2021-03-02T18:24:41.660387
| 2020-03-08T21:55:02
| 2020-03-08T21:55:02
| 245,893,402
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 409
|
cpp
|
findPath.cpp
|
#include<iostream>
using namespace std;
int countway(int i,int j, int n, int m)
{
if(n==i && m==j)
return 1;
if(i>n || j>m)
return 0;
int c1 = countway(i+1,j,n,m);
int c2 = countway(i,j+1,n,m);
return (c1+c2);
}
int main()
{
//code
int t;
cin>>t;
while(t--)
{
int n,m;
cin>>n>>m;
int count = countway(1,1,n,m);
cout << count << endl;
}
return 0;
}
|
d850124283812390d4cb0944e8169a44737f0eab
|
7e69c1476e8a8a46ba0a0a72b5ec2f0b6bfb23f1
|
/analyscep.cc
|
f6eb95d0a4a7a2f29662167c2b42244d410376a0
|
[
"MIT"
] |
permissive
|
mieskolainen/DREM-PID
|
9e1be57f700e6bb2704d3018ebeb6e3789714478
|
d6594ea0e7b21a1ec55785bd8e26c5b27702b033
|
refs/heads/master
| 2021-09-06T21:30:35.474592
| 2018-02-11T19:47:25
| 2018-02-11T19:47:25
| 115,795,780
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 46,655
|
cc
|
analyscep.cc
|
// Multichannel Double Recursive Frequentist-Bayesian Particle Identification (pion, kaon, proton, electron etc.)
//
// COMPILE with: root analyscep.cc+ -b -q
//
// TODO: write down a C++ class of this.
//
//
// mikael.mieskolainen@cern.ch, 2018
// C++
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
// ROOT
#include "TFile.h"
#include "TBranch.h"
#include "TRandom.h"
#include "TTree.h"
#include "TH1.h"
#include "TH2.h"
#include "TCanvas.h"
#include "TLorentzVector.h"
#include "TROOT.h"
#include "TStyle.h"
#include "TColor.h"
#include "TProfile.h"
#include "TF1.h"
#include "TObject.h"
#include "TSystem.h"
#include "TLegend.h"
// Set "nice" 2D-plot style
// Read here more about problems with the Rainbow
void set_plot_style() {
// Set Smooth color gradients
const Int_t NRGBs = 5;
const Int_t NCont = 255;
Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
gStyle->SetNumberContours(NCont);
// Black-Red palette
//gStyle->SetPalette(53); // 53/56 for (non)-inverted
gStyle->SetTitleOffset(1.6,"x"); //X-axis title offset from axis
gStyle->SetTitleOffset(2.5,"y"); //Y-axis title offset from axis
gStyle->SetTitleSize(0.03,"x"); //X-axis title size
gStyle->SetTitleSize(0.03,"y"); //Y-axis
gStyle->SetTitleSize(0.03,"z");
gStyle->SetLabelOffset(0.025);
}
void SetHStyle(TH1F*& h1) {
h1->SetLineColor(kBlack);
h1->SetMarkerColor(kBlack);
h1->SetMarkerStyle(kFullCircle);
h1->SetMarkerSize(0.2);
}
// Global Style Setup
void setROOTstyle() {
gStyle->SetOptStat(1); // Statistics BOX OFF [0,1]
gStyle->SetTitleSize(0.0475,"t"); // Title with "t" (or anything else than xyz)
gStyle->SetStatY(1.0);
gStyle->SetStatX(1.0);
gStyle->SetStatW(0.15);
gStyle->SetStatH(0.09);
// See below
set_plot_style();
}
// PID vectors
std::vector<std::vector<std::vector<double>>> nsigma;
std::vector<std::vector<double>> posterior;
std::vector<std::vector<double>> particleweight;
// Text Labels
std::vector<TString> pname_a;
std::vector<TString> pname_b;
std::vector<TString> slabels;
std::vector<TString> alabels;
std::vector<TString> blabels;
std::vector<TString> plabels;
// Initial state setup
const double sqrts = 13000; // Needed for some observables
// Final state setup
// Masses in GeV
const double ME = 0.510998928e-3;
const double MPI = 0.13957018;
const double MK = 0.493677;
const double MP = 0.9382720813;
const double MASS[3] = {MPI, MK, MP};
const int NFINALSTATES = 2; // number of track
const int NSPECIES = 3; // number of particle species
const int NCHANNEL = 9; // number of 2-body channels, NSPECIES^NFINALSTATE
// Fixed indexing
const int Pi_ind = 0;
const int Ka_ind = 1;
const int Pr_ind = 2;
const int TPC_ind = 0;
const int TOF_ind = 1;
// Phase I PID binning setup
const double PMIN = 0.0;
const double PMAX = 3.5;
const int PBINS = 25;
const int ITER = 10;
// Phase II system binning setup
const double SPMIN = 0.0;
const double SPMAX = 2.0;
const int SPBINS = 15;
const int SITER = 10;
// Phase III mode
// 0 for Hard (Maximum Probability) or 1 for Soft (weighted)
int PROBmode = 0;
// ROOT Tree input
TFile* f;
TTree* tree2track;
Int_t run = 0;
Float_t zVtx = 0;
Float_t px1 = 0;
Float_t py1 = 0;
Float_t pz1 = 0;
Float_t px2 = 0;
Float_t py2 = 0;
Float_t pz2 = 0;
Float_t sigmaPiTPC1 = 0;
Float_t sigmaKaTPC1 = 0;
Float_t sigmaPrTPC1 = 0;
Float_t sigmaPiTPC2 = 0;
Float_t sigmaKaTPC2 = 0;
Float_t sigmaPrTPC2 = 0;
Float_t sigmaPiTOF1 = 0;
Float_t sigmaKaTOF1 = 0;
Float_t sigmaPrTOF1 = 0;
Float_t sigmaPiTOF2 = 0;
Float_t sigmaKaTOF2 = 0;
Float_t sigmaPrTOF2 = 0;
Float_t pxMc1 = 0;
Float_t pyMc1 = 0;
Float_t pzMc1 = 0;
Float_t pxMc2 = 0;
Float_t pyMc2 = 0;
Float_t pzMc2 = 0;
Int_t pidCode1 = 0;
Int_t pidCode2 = 0;
Char_t ada = 0;
Char_t adc = 0;
// Histograms
std::vector<TH1F*> h1M(NCHANNEL, 0);
std::vector<TH1F*> h1MJPsi(NCHANNEL, 0);
std::vector<TH1F*> h1Pt(NCHANNEL, 0);
std::vector<TH1F*> h1pt(NCHANNEL, 0);
std::vector<TH1F*> h1Y(NCHANNEL, 0);
std::vector<TH1F*> h1y(NCHANNEL, 0);
std::vector<TH1F*> h1eta(NCHANNEL, 0);
std::vector<TH1F*> h1dy(NCHANNEL, 0);
std::vector<TH1F*> h1xi1(NCHANNEL, 0);
std::vector<TH1F*> h1xi2(NCHANNEL, 0);
std::vector<TH2F*> h2xi1xi2(NCHANNEL, 0);
std::vector<TH2F*> h2y1y2(NCHANNEL, 0);
std::vector<TProfile*> hprMPt(NCHANNEL, 0);
std::vector<TProfile*> hprMpt(NCHANNEL, 0);
std::vector<TH2F*> h2MPt(NCHANNEL, 0);
std::vector<TH2F*> h2Mdphi(NCHANNEL, 0);
std::vector<TH2F*> h2Mpt(NCHANNEL, 0);
std::vector<TH2F*> h2Ptdphi(NCHANNEL, 0);
std::vector<TH2F*> h2ptdphi(NCHANNEL, 0);
std::vector<TH1F*> h1XF(NCHANNEL, 0);
std::vector<TH2F*> h2MXF(NCHANNEL, 0);
std::vector<TProfile*> hprMXF(NCHANNEL, 0);
std::vector<TH1F*> h1XT(NCHANNEL, 0);
std::vector<TH2F*> h2MXT(NCHANNEL, 0);
std::vector<TProfile*> hprMXT(NCHANNEL, 0);
std::vector<TH2F*> h2EtaPhi(NCHANNEL, 0);
std::vector<TH2F*> h2MCosTheta(NCHANNEL, 0);
std::vector<TH2F*> h2TPC_Pi(NCHANNEL, 0);
std::vector<TH2F*> h2TPC_Ka(NCHANNEL, 0);
std::vector<TH2F*> h2TPC_Pr(NCHANNEL, 0);
std::vector<TH2F*> h2TOF_Pi(NCHANNEL, 0);
std::vector<TH2F*> h2TOF_Ka(NCHANNEL, 0);
std::vector<TH2F*> h2TOF_Pr(NCHANNEL, 0);
TProfile* hPl[NCHANNEL][8];
// Track 4-momentum
std::vector<TLorentzVector> p_g; // generated
std::vector<TLorentzVector> p_r; // reconstructed
// System
TLorentzVector system_g;
TLorentzVector system_r;
// SANITY CUTS to skip event completely
const double TPCCUT = 6.0; // sigmas
const double TOFCUT = 1e6;
// SANITY CUTS to skip detector in the product likelihood
const double BOUND = 50; // No signal bound +- sigmas
// Constants
const double z95 = 1.96; // 95% Gaussian CL
const double PI = 3.14159265359; // pi
// ASCII output
FILE* asciif;
// ----------------------------------------------------------------------
// Function prototypes
std::vector<std::vector<double>> EM(double PMIN, double PMAX, int PBINS, int ITER);
int GetIdx(double value, double MINVAL, double MAXVAL, int NUMBINS);
void GetProb(std::vector<double>& posterior, const std::vector<std::vector<double>>& nsigma, const std::vector<double>& prior);
double fG(double n);
void InitTree(std::string tree_filename);
void CloseTree();
void GetSignal();
bool CheckPIDsignal();
bool CheckForwardVeto();
void InitHistogram();
void FillHisto(std::vector<double> prob_);
void MakePlots();
void Analyzer(std::vector<std::vector<double>>& channel_prior, int mode);
void HEframe(std::vector<TLorentzVector>& p);
bool DEBUG = false;
// ROOT data input
std::string ROOT_datafile;
std::string output_ascii;
// Forward veto mode
int VMODE = 0;
// MAIN FUNCTION
int analyscep() {
// VETO mode setup (set manually, see CheckForwardVeto::), 0 for no veto considerations
// VMODE = 0;
VMODE = 1;
// VMODE = 2;
// VMODE = 3;
// VMODE = 4;
output_ascii = "tree2track_CUP25";
//output_ascii = "tree2track_CUP13";
//output_ascii = "tree2track_kPipmOrexp";
//output_ascii = "tree2track_kKpkmOrexp";
// --------------------------------------------------------------------------
// 0. SETUP ROOT input
ROOT_datafile = output_ascii + ".root";
// --------------------------------------------------------------------------
// 0. Init vectors
InitHistogram();
std::vector<std::vector<double>> ttemp = {{0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}};
posterior = ttemp;
// [N final states] x [P particle species] x [D detectors]
std::vector<std::vector<double>> tempvec = {{0.0, 0.0},{0.0, 0.0},{0.0, 0.0}};
TLorentzVector temp4vec;
for (int i = 0; i < NFINALSTATES; ++i) {
nsigma.push_back(tempvec);
p_g.push_back(temp4vec);
p_r.push_back(temp4vec);
}
// --------------------------------------------------------------------------
// Setup output file
if (VMODE == 0) {
output_ascii = output_ascii;
}
if (VMODE == 1) {
output_ascii = output_ascii + "_ADC=0_AND_ADA=0";
}
if (VMODE == 2) {
output_ascii = output_ascii + "_ADC=0_AND_ADA=1";
}
if (VMODE == 3) {
output_ascii = output_ascii + "_ADC=1_AND_ADA=0";
}
if (VMODE == 4) {
output_ascii = output_ascii + "_ADC=1_AND_ADA=1";
}
// Open ASCII output
asciif = fopen((output_ascii + ".ascii").c_str(), "w");
if (asciif == NULL) {
printf("Error opening ascii output file: %s !\n", output_ascii.c_str());
exit(1);
}
printf("Reading input from: %s \n", ROOT_datafile.c_str());
// --------------------------------------------------------------------------
// 1. Run Phase I analysis
particleweight = EM(PMIN, PMAX, PBINS, ITER);
// --------------------------------------------------------------------------
// 2. Run Phase II analysis
std::vector<std::vector<double>> channel_prior(SPBINS, std::vector<double> (NCHANNEL, 1.0/(double)(NCHANNEL)));
// EM iterations
int mode = 1;
for (int i = 0; i < SITER; ++i) {
Analyzer(channel_prior, mode);
}
// Save final histograms
mode = 2;
Analyzer(channel_prior, mode);
// --------------------------------------------------------------------------
// 3. Make plots
setROOTstyle();
MakePlots();
// Close ascii output
fclose(asciif);
return EXIT_SUCCESS;
}
// Legendre polynomials
double legendre_pl(int l, double x) {
if (l == 0) {
return 1.0;
} else if (l == 1) {
return x;
} else if (l == 2) {
return 0.5*(3.0*x*x - 1.0);
} else if (l == 3) {
return 0.5*(5.0*x*x*x - 3.0*x);
} else if (l == 4) {
return (35.0*x*x*x*x - 30.0*x*x + 3.0) / 8.0;
} else if (l == 5) {
return (63.0 * x*x*x*x*x - 70*x*x*x + 15 * x)/ 8.0;
} else if (l == 6) {
return (231.0 * x*x*x*x*x*x - 315.0*x*x*x*x + 105.0*x*x - 5.0)/ 16.0;
} else if (l == 7) {
return (429.0 * x*x*x*x*x*x*x - 693.0*x*x*x*x*x + 315.0*x*x*x - 35.0*x)/ 16.0;
} else if (l == 8) {
return (6435.0*x*x*x*x*x*x*x*x - 12012.0*x*x*x*x*x*x + 6930.0*x*x*x*x - 1260.0*x*x + 35.0)/ 128.0;
}
}
// Initialize input ROOT tree
void InitTree(std::string tree_filename) {
f = new TFile(tree_filename.c_str());
tree2track = (TTree*) f->Get("tree2track");
tree2track->SetBranchAddress("run",&run);
tree2track->SetBranchAddress("pxMc1",&pxMc1);
tree2track->SetBranchAddress("pyMc1",&pyMc1);
tree2track->SetBranchAddress("pzMc1",&pzMc1);
tree2track->SetBranchAddress("pxMc2",&pxMc2);
tree2track->SetBranchAddress("pyMc2",&pyMc2);
tree2track->SetBranchAddress("pzMc2",&pzMc2);
tree2track->SetBranchAddress("pidCode1",&pidCode1);
tree2track->SetBranchAddress("pidCode2",&pidCode2);
tree2track->SetBranchAddress("zVtx",&zVtx);
tree2track->SetBranchAddress("px1",&px1);
tree2track->SetBranchAddress("py1",&py1);
tree2track->SetBranchAddress("pz1",&pz1);
tree2track->SetBranchAddress("px2",&px2);
tree2track->SetBranchAddress("py2",&py2);
tree2track->SetBranchAddress("pz2",&pz2);
tree2track->SetBranchAddress("sigmaPiTPC1",&sigmaPiTPC1);
tree2track->SetBranchAddress("sigmaKaTPC1",&sigmaKaTPC1);
tree2track->SetBranchAddress("sigmaPrTPC1",&sigmaPrTPC1);
tree2track->SetBranchAddress("sigmaPiTPC2",&sigmaPiTPC2);
tree2track->SetBranchAddress("sigmaKaTPC2",&sigmaKaTPC2);
tree2track->SetBranchAddress("sigmaPrTPC2",&sigmaPrTPC2);
tree2track->SetBranchAddress("sigmaPiTOF1",&sigmaPiTOF1);
tree2track->SetBranchAddress("sigmaKaTOF1",&sigmaKaTOF1);
tree2track->SetBranchAddress("sigmaPrTOF1",&sigmaPrTOF1);
tree2track->SetBranchAddress("sigmaPiTOF2",&sigmaPiTOF2);
tree2track->SetBranchAddress("sigmaKaTOF2",&sigmaKaTOF2);
tree2track->SetBranchAddress("sigmaPrTOF2",&sigmaPrTOF2);
tree2track->SetBranchAddress("ada",&ada);
tree2track->SetBranchAddress("adc",&adc);
}
void CloseTree() {
delete f;
}
// Set detector PID signals
void GetSignal() {
nsigma.at(0).at(Pi_ind).at(TPC_ind) = sigmaPiTPC1;
nsigma.at(0).at(Ka_ind).at(TPC_ind) = sigmaKaTPC1;
nsigma.at(0).at(Pr_ind).at(TPC_ind) = sigmaPrTPC1;
nsigma.at(0).at(Pi_ind).at(TOF_ind) = sigmaPiTOF1;
nsigma.at(0).at(Ka_ind).at(TOF_ind) = sigmaKaTOF1;
nsigma.at(0).at(Pr_ind).at(TOF_ind) = sigmaPrTOF1;
nsigma.at(1).at(Pi_ind).at(TPC_ind) = sigmaPiTPC2;
nsigma.at(1).at(Ka_ind).at(TPC_ind) = sigmaKaTPC2;
nsigma.at(1).at(Pr_ind).at(TPC_ind) = sigmaPrTPC2;
nsigma.at(1).at(Pi_ind).at(TOF_ind) = sigmaPiTOF2;
nsigma.at(1).at(Ka_ind).at(TOF_ind) = sigmaKaTOF2;
nsigma.at(1).at(Pr_ind).at(TOF_ind) = sigmaPrTOF2;
}
// PID signal sanity checks
bool CheckPIDsignal() {
if (std::abs(sigmaPiTPC1) < TPCCUT || std::abs(sigmaKaTPC1) < TPCCUT || std::abs(sigmaPrTPC1) < TPCCUT) {
return true;
} else {
return false;
}
if (std::abs(sigmaPiTPC2) < TPCCUT || std::abs(sigmaKaTPC2) < TPCCUT || std::abs(sigmaPrTPC2) < TPCCUT) {
return true;
} else {
return false;
}
/*
if (std::abs(sigmaPiTOF1) < TOFCUT || std::abs(sigmaKaTOF1) < TOFCUT || std::abs(sigmaPrTOF1) < TOFCUT) {
return true;
} else {
return false;
}
if (std::abs(sigmaPiTOF2) < TOFCUT || std::abs(sigmaKaTOF2) < TOFCUT || std::abs(sigmaPrTOF2) < TOFCUT) {
return true;
} else {
return false;
}*/
}
// Forward VETO check, return true if veto condition is satisfied, else false
bool CheckForwardVeto() {
if (VMODE == 0) { // No selection on forward veto, return true always
return true;
}
if (VMODE == 1) {
if (adc == false && ada == false) // ADC=0_AND_ADA=0 ~ "elastic" like
return true;
}
if (VMODE == 2) {
if (adc == false && ada == true) // ADC=0_AND_ADA=1 ~ "SDR" like
return true;
}
if (VMODE == 3) {
if (adc == true && ada == false) // ADC=1_AND_ADA=0 ~ "SDL" like
return true;
}
if (VMODE == 4) {
if (adc == true && ada == true) // ADC=1_AND_ADA=1 ~ "DD" like
return true;
}
return false; // default
}
// Initialize histograms
void InitHistogram() {
printf("InitHistogram:: \n");
int BINS = 0;
// Mass limits
double MIN_M = 0;
double MAX_M = 5.0;
// Rapidity limits
double MIN_Y = -1.25;
double MAX_Y = 1.25;
BINS = 250; MIN_M = 0.0;
pname_a.push_back("#pi^{+}"); pname_a.push_back("K^{+}"); pname_a.push_back("p");
pname_b.push_back("#pi^{-}"); pname_b.push_back("K^{-}"); pname_b.push_back("#bar{p}");
plabels.push_back("Pi"); plabels.push_back("Ka"); plabels.push_back("Pr");
for (int i = 0; i < NSPECIES; ++i) {
for (int j = 0; j < NSPECIES; ++j) {
TString label = pname_a[i] + pname_b[j];
slabels.push_back(label);
alabels.push_back(pname_a.at(i));
blabels.push_back(pname_b.at(j));
}
}
for (int k = 0; k < NCHANNEL; ++k) {
h1M[k] = new TH1F(Form("M(%d)", k), Form(";M(%s) (GeV); Events / (%0.3f GeV)", slabels.at(k).Data(), (MAX_M - MIN_M)/(double)BINS), BINS, MIN_M, MAX_M);
h1MJPsi[k] = new TH1F(Form("M_Jpsi(%d)", k), Form(";M(%s) (GeV); Events / (%0.3f GeV)", slabels.at(k).Data(), (3.3 - 2.9)/(double)50), 50, 2.9, 3.3);
h1Pt[k] = new TH1F(Form("Pt(%d)", k), Form(";System p_{t}(%s) (GeV); Events / (%0.3f GeV)", slabels.at(k).Data(), (MAX_M - MIN_M)/(double)BINS), BINS, MIN_M, MAX_M);
h1pt[k] = new TH1F(Form("pt(%d)", k), Form(";Particle p_{t}(%s) (GeV); Events / (%0.3f GeV)", alabels.at(k).Data(), (MAX_M - MIN_M)/(double)BINS), BINS, MIN_M, MAX_M);
h1xi1[k] = new TH1F(Form("h1xi1(%d)", k), Form(";#xi_{1}(%s); Events / (%0.3E bin)", slabels.at(k).Data(), (3e-4 - 5e-5)/(double)BINS), BINS, 1e-5, 3e-4);
h1xi2[k] = new TH1F(Form("h1xi2(%d)", k), Form(";#xi_{2}(%s); Events / (%0.3E bin)", slabels.at(k).Data(), (3e-4 - 5e-5)/(double)BINS), BINS, 1e-5, 3e-4);
h2xi1xi2[k] = new TH2F(Form("h1xi1xi2(%d)", k), Form("%s;#xi_{1}; #xi_{2}", slabels.at(k).Data()), BINS/2, 1e-5, 3e-4, BINS/2, 1e-5, 3e-4);
h2y1y2[k] = new TH2F(Form("h1y1y2(%d)", k), Form("%s;y_{1}; y_{2}", slabels.at(k).Data()), BINS/2, -1, 1, BINS/2, -1, 1);
h1Y[k] = new TH1F(Form("Y(%d)", k), Form(";Rapidity Y(%s); Events / %0.3f", slabels.at(k).Data(), (MAX_Y - MIN_Y)/(double)BINS), BINS, MIN_Y, MAX_Y);
h1y[k] = new TH1F(Form("y(%d)", k), Form(";Rapidity y(%s); Events / %0.3f", alabels.at(k).Data(), (MAX_Y - MIN_Y)/(double)BINS), BINS, MIN_Y, MAX_Y);
h1eta[k] = new TH1F(Form("eta(%d)", k), Form(";Pseudorapidity #eta(%s); Events / %0.3f", alabels.at(k).Data(), (MAX_Y - MIN_Y)/(double)BINS), BINS, MIN_Y, MAX_Y);
h1dy[k] = new TH1F(Form("Deltay(%d)", k), Form(";Pair #Deltay(%s); Events / %0.3f", slabels.at(k).Data(), 2*(MAX_Y - MIN_Y)/(double)BINS), BINS, 2*MIN_Y, 2*MAX_Y);
hprMPt[k] = new TProfile(Form("prof MPt(%d)", k), Form(";M(%s) (GeV); System <p_{t}> (GeV)", slabels.at(k).Data()), BINS, MIN_M, MAX_M);
hprMpt[k] = new TProfile(Form("prof Mpt(%d)", k), Form(";M(%s) (GeV); Particle <p_{t}(%s)> (GeV)", slabels.at(k).Data(), alabels.at(k).Data()), BINS, MIN_M, MAX_M);
h2EtaPhi[k] = new TH2F(Form("eta,phi(%d)", k), Form(";Particle #eta(%s); Particle #phi(%s) (rad)", alabels.at(k).Data(), alabels.at(k).Data()), BINS/2, MIN_Y, MAX_Y, BINS/2, -PI, PI);
h2MCosTheta[k] = new TH2F(Form("M,costheta(%d)", k), Form(";M(%s) (GeV); cos #theta(%s)_{ r.f.} (rad)", slabels.at(k).Data(), alabels.at(k).Data()), BINS/2, MIN_M, MAX_M, BINS/2, -1, 1);
//h1M_pipi->Sumw2();
h2MPt[k] = new TH2F(Form("M(%d),Pt()", k), Form(";M(%s) (GeV); System p_{T} (GeV)", slabels.at(k).Data()), BINS/2, MIN_M, MAX_M, BINS/2, 0, 2.5);
h2Mdphi[k] = new TH2F(Form("M(%d),dphi()", k), Form(";M(%s) (GeV); #Delta#phi (rad)", slabels.at(k).Data()), BINS/2, MIN_M, MAX_M, BINS/2, 0, 3.14159);
h2Mpt[k] = new TH2F(Form("M(%d),pt()", k), Form(";M(%s) (GeV); %s p_{T} (GeV)", slabels.at(k).Data(), alabels.at(k).Data()), BINS/2, MIN_M, MAX_M, BINS/2, 0, 2.5);
h2Ptdphi[k] = new TH2F(Form("Pt(%d),dphi()", k), Form(";System p_{T}(%s) (GeV); #Delta#phi (rad)", slabels.at(k).Data()), BINS/2, 0.0, 2.5, BINS/2, 0, 3.14159);
h2ptdphi[k] = new TH2F(Form("pt(%d),dphi()", k), Form(";Particle p_{T}(%s) (GeV); #Delta#phi (rad)", alabels.at(k).Data()), BINS/2, 0.0, 2.5, BINS/2, 0, 3.14159);
// Feynman xF
h1XF[k] = new TH1F(Form("x_F(%d)", k), Form(";Feynman x_{F}(%s);Events", alabels.at(k).Data()), BINS, 0, 1);
h2MXF[k] = new TH2F(Form("M x_F(%d)", k), Form(";M(%s) (GeV); Feynman x_{F}(%s)", slabels.at(k).Data(), alabels.at(k).Data()), BINS/2, 0, 4, BINS/2, 0, 1);
hprMXF[k] = new TProfile(Form("prof MXF(%d)", k), Form(";M(%s) (GeV); Feynman <x_{F}(%s)>", slabels.at(k).Data(), alabels.at(k).Data()), BINS, MIN_M, MAX_M);
// xT
h1XT[k] = new TH1F(Form("x_T(%d) ", k), Form(";x_{T}(%s);Events", slabels.at(k).Data()), BINS, 0, 1);
h2MXT[k] = new TH2F(Form("M x_T(%d) ", k), Form(";M(%s) (GeV); x_{T}(%s)", slabels.at(k).Data(), alabels.at(k).Data()), BINS/2, 0, 4, BINS/2, 0, 1);
hprMXT[k] = new TProfile(Form("prof MXT(%d)", k), Form(";M(%s) (GeV); <x_{T}(%s)>", slabels.at(k).Data(), alabels.at(k).Data()), BINS, MIN_M, MAX_M);
// Save errors
hprMPt[k]->Sumw2();
hprMpt[k]->Sumw2();
hprMXF[k]->Sumw2();
hprMXT[k]->Sumw2();
h2TPC_Pi[k] = new TH2F(Form("(p,TPC_Pi(%d))", k), ";p (GeV); #sigma #pi TPC", 200, 0, 3, 200, -50, 50);
h2TPC_Ka[k] = new TH2F(Form("(p,TPC_Ka(%d))", k), ";p (GeV); #sigma K TPC", 200, 0, 3, 200, -50, 50);
h2TPC_Pr[k] = new TH2F(Form("(p,TPC_Pr(%d))", k), ";p (GeV); #sigma p TPC", 200, 0, 3, 200, -50, 50);
h2TOF_Pi[k] = new TH2F(Form("(p,TOF_Pi(%d))", k), ";p (GeV); #sigma #pi TOF", 200, 0, 3, 200, -50, 50);
h2TOF_Ka[k] = new TH2F(Form("(p,TOF_Ka(%d))", k), ";p (GeV); #sigma K TOF", 200, 0, 3, 200, -50, 50);
h2TOF_Pr[k] = new TH2F(Form("(p,TOF_Pr(%d))", k), ";p (GeV); #sigma p TOF", 200, 0, 3, 200, -50, 50);
// Legendre polynomials, DO NOT CHANGE THE Y-RANGE [-1,1]
for (int i = 0; i < 8; ++i) {
hPl[k][i] = new TProfile(Form("hPl%d(%d)", k, i+1),"", 100, 0.0, MAX_M, -1, 1);
hPl[k][i]->SetXTitle(Form("M(%s) (GeV)", slabels.at(k).Data()));
hPl[k][i]->SetYTitle(Form("#LTP_{l}(cos(#theta)#GT |_{ r.f.}"));
}
}
}
// Fill histograms
void FillHisto(std::vector<double> prob_) {
// Find the maximum probability channel
uint k_max = 999;
double P_max = -1;
for (uint i = 0; i < prob_.size(); ++i) {
if (prob_.at(i) > P_max) {
P_max = prob_.at(i);
k_max = i;
}
}
// Fill hard classification vector [0,0,1,0,..,,0]
std::vector<double> weight_(NCHANNEL, 0.0);
// Hard
if (PROBmode == 0) {
for (uint k = 0; k < weight_.size(); ++k) {
if (k == k_max) {
weight_.at(k) = 1.0;
}
}
}
// Weighted
if (PROBmode == 1) {
weight_ = prob_;
}
// Hard classification for each k-th channel
int k = 0;
for (int i = 0; i < NSPECIES; ++i) {
for (int j = 0; j < NSPECIES; ++j) {
// NOTE HERE THAT one must NOT fill events with zero weights in the hard
// mode, otherwise the statistical errors are not properly calculated.
if (PROBmode == 0 && weight_.at(k) > 1e-5 || PROBmode == 1) {
// Reconstruct final state 4-momentum
p_r.at(0).SetVectM(p_r.at(0).Vect(), MASS[i]);
p_r.at(1).SetVectM(p_r.at(1).Vect(), MASS[j]);
system_r = p_r.at(0) + p_r.at(1);
if (k == 0) { // Write down ascii output for channel[0]
fprintf(asciif, "%0.6f,%0.6f,%0.6f,%0.6f \n", system_r.M(), system_r.Px(), system_r.Py(), system_r.Pz());
}
// Observables
double M = system_r.M();
double Pt = system_r.Perp();
double Y = system_r.Rapidity();
double pt = p_r.at(0).Perp();
double y = p_r.at(0).Rapidity();
double eta = p_r.at(0).Eta();
double phi = p_r.at(0).Phi();
// Fractional longitudinal momentum (pz) loss in the collinear limit
double xi1 = M / sqrts * std::exp(Y);
double xi2 = M / sqrts * std::exp(-Y);
// Fill histograms >>
h1xi1[k]->Fill(xi1, weight_.at(k));
h1xi2[k]->Fill(xi2, weight_.at(k));
h2xi1xi2[k]->Fill(xi1, xi2, weight_.at(k));
h1M[k]->Fill(M, weight_.at(k));
h1MJPsi[k]->Fill(M, weight_.at(k));
h1Pt[k]->Fill(Pt, weight_.at(k));
h1pt[k]->Fill(pt, weight_.at(k));
h1Y[k]->Fill(Y, weight_.at(k));
h1y[k]->Fill(y, weight_.at(k));
h1eta[k]->Fill(eta, weight_.at(k));
h1dy[k]->Fill(p_r.at(0).Rapidity() - p_r.at(1).Rapidity(), weight_.at(k));
h2y1y2[k]->Fill(p_r.at(0).Rapidity(), p_r.at(1).Rapidity(), weight_.at(k));
hprMPt[k]->Fill(M, Pt, weight_.at(k));
hprMpt[k]->Fill(M, pt, weight_.at(k));
h2EtaPhi[k]->Fill(eta, phi, weight_.at(k));
// Calculate Feynman x_F = 2 |p_z*| / sqrt(shat)
// Boost particles to the central system rest frame
TVector3 betavec = -system_r.BoostVector(); // Note the minus sign
TLorentzVector pboosted = p_r.at(0);
pboosted.Boost(betavec);
double xf = 2*std::abs(pboosted.Pz()) / system_r.M();
double xt = 2*std::abs(pboosted.Perp()) / system_r.M();
h1XF[k]->Fill(xf, weight_.at(k));
h2MXF[k]->Fill(M, xf, weight_.at(k));
hprMXF[k]->Fill(M, xf, weight_.at(k));
h1XT[k]->Fill(xt, weight_.at(k));
h2MXT[k]->Fill(M, xt, weight_.at(k));
hprMXT[k]->Fill(M, xt, weight_.at(k));
h2MCosTheta[k]->Fill(M, pboosted.CosTheta(), weight_.at(k));
h2MPt[k]->Fill(M, Pt, weight_.at(k));
h2Mdphi[k]->Fill(M, p_r.at(0).DeltaPhi(p_r.at(1)), weight_.at(k));
h2Mpt[k]->Fill(M, p_r.at(0).Perp(), weight_.at(k));
h2Mpt[k]->Fill(M, p_r.at(1).Perp(), weight_.at(k));
h2Ptdphi[k]->Fill(Pt, p_r.at(0).DeltaPhi(p_r.at(1)), weight_.at(k));
h2ptdphi[k]->Fill(pt, p_r.at(0).DeltaPhi(p_r.at(1)), weight_.at(k));
// Calculate cos(theta) in the non-rotated rest frame
double costheta = pboosted.CosTheta();
// Calculate cos(theta) in the rotated helicity frame
std::vector<TLorentzVector> fs;
fs.push_back(p_r.at(0)); fs.push_back(p_r.at(1));
HEframe(fs);
double HEcostheta = fs.at(0).CosTheta(); // Take the first daughter
// Legendre polynomials P_l cos(theta), l = 1,2,3,4,5,6,7,8
for (int l = 0; l < 8; ++l) { // note l+1
double value = legendre_pl((l+1), HEcostheta); // cos(theta)
hPl[k][l]->Fill(system_r.M(), value);
}
}
++k;
}
}
}
// From lab to the Helicity frame
// Quantization z-axis as the direction of the resonance in the lab frame
//
// Input is a vector of final state 4-momentum
void HEframe(std::vector<TLorentzVector>& p) {
// Sum to get the system 4-momentum
TLorentzVector X(0,0,0,0);
for (UInt_t i = 0; i < p.size(); ++i) {
X += p.at(i);
}
// ********************************************************************
if (DEBUG) {
printf("\n\n ::HELICITY FRAME:: \n");
printf("- Pions in LAB FRAME: \n");
p.at(0).Print();
p.at(1).Print();
}
// ********************************************************************
// ACTIVE (cf. PASSIVE) rotation of final states by z-y-z (phi,theta,-phi)
// (in the opposite direction -> minus signs) Euler angle sequence.
double Z_angle = - X.Phi();
double Y_angle = - X.Theta();
for (UInt_t i = 0; i < p.size(); ++i) {
p.at(i).RotateZ(Z_angle);
p.at(i).RotateY(Y_angle);
// p.at(i).RotateZ(-Z_angle); // Comment this one out for tests
}
// ********************************************************************
if (DEBUG) {
printf("- Pions in ROTATED LAB FRAME: \n");
p.at(0).Print();
p.at(1).Print();
TVector3 ex(1,0,0);
TVector3 ey(0,1,0);
TVector3 ez(0,0,1);
// x -> x'
ex.RotateZ(Z_angle);
ex.RotateY(Y_angle);
// ex.RotateZ(-Z_angle); // Comment this one out for tests
// y -> y'
ey.RotateZ(Z_angle);
ey.RotateY(Y_angle);
// ey.RotateZ(-Z_angle); // Comment this one out for tests
// z -> z'
ez.RotateZ(Z_angle);
ez.RotateY(Y_angle);
// ez.RotateZ(-Z_angle); // Comment this one out for tests
printf("- AXIS vectors after rotation: \n");
ex.Print();
ey.Print();
ez.Print();
}
// ********************************************************************
// Construct the central system 4-momentum in ROTATED FRAME
TLorentzVector XNEW(0,0,0,0);
for (UInt_t i = 0; i < p.size(); ++i) {
XNEW += p.at(i);
}
// Boost particles to the central system rest frame
// -> Helicity frame obtained
TVector3 betavec = -XNEW.BoostVector(); // Note the minus sign
for (UInt_t i = 0; i < p.size(); ++i) {
p.at(i).Boost(betavec);
}
// ********************************************************************
if (DEBUG) {
printf("- Pions after boost in HELICITY FRAME: \n");
p.at(0).Print();
p.at(1).Print();
printf("- Central system in LAB FRAME: \n");
X.Print();
printf("- Central system in ROTATED LAB FRAME: \n");
XNEW.Print();
printf("\n");
}
// ********************************************************************
TLorentzVector sum;
for (UInt_t i = 0; i < p.size(); ++i) {
sum += p.at(i);
}
Double_t epsilon = 1e-6;
if (std::abs(sum.Px()) > epsilon || std::abs(sum.Py()) > epsilon || std::abs(sum.Pz()) > epsilon) {
printf("HEframe:: Not a rest frame!! \n");
}
}
// Quadratic polynomial background function
Double_t background(Double_t *x, Double_t *par) {
return par[2]*x[0]*x[0] + par[1]*x[0] + par[0];
}
Double_t exponential(Double_t *x, Double_t *par) {
return par[0] * std::exp(par[1]*x[0] + par[2]);
}
// Breit-wigner function
Double_t lorentzianPeak(Double_t *x, Double_t *par) {
return (0.5*par[0]*par[1]/TMath::Pi()) /
TMath::Max(1.e-10, (x[0]-par[2])*(x[0]-par[2]) + 0.25*par[1]*par[1]);
}
// Sum of background and peak function
Double_t fitFunction(Double_t *x, Double_t *par) {
return background(x,par) + lorentzianPeak(x,&par[3]);
}
// Create plots
void MakePlots() {
printf("MakePlots:: \n");
// Title
//h1M_pipi->SetTitle(Form("#Sigma N = %0.0f / %d / %d", channelweight[0], N_selected, N_tot));
for (int k = 0; k < NCHANNEL; ++k) {
// Create output directory in a case
gSystem->Exec(Form("mkdir ./figs/%s/", output_ascii.c_str() ));
std::string output_dir = "./figs/" + output_ascii + "/" + slabels.at(k).Data();
gSystem->Exec(Form("mkdir %s", output_dir.c_str()));
TCanvas c10("c10", "c10", 400, 300);
TCanvas c10_log("c10_log", "c10_log", 400, 300);
c10_log.SetLogy();
c10.cd();
h1xi1[k]->Draw();
c10.SaveAs(Form("./figs/%s/%s/h1xi1_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c10_log.cd();
h1xi1[k]->Draw(); h1xi1[k]->SetMinimum(0.1); // Y-axis minimum (for log only)
c10_log.SaveAs(Form("./figs/%s/%s/h1xi1_logy_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c10.cd();
h1xi2[k]->Draw();
c10.SaveAs(Form("./figs/%s/%s/h1xi2_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c10_log.cd();
h1xi2[k]->Draw(); h1xi2[k]->SetMinimum(0.1); // Y-axis minimum (for log only)
c10_log.SaveAs(Form("./figs/%s/%s/h1xi2_logy_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c10.cd();
h1M[k]->Draw();
c10.SaveAs(Form("./figs/%s/%s/h1M_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c10_log.cd();
h1M[k]->Draw(); h1M[k]->SetMinimum(0.1); // Y-axis minimum (for log only)
c10_log.SaveAs(Form("./figs/%s/%s/h1M_logy_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
// ----------------------------------------------------------------------------
// J/psi
/*
c10.cd();
// create a TF1 with the range from 0 to 4 and 6 parameters
TF1 *fitFcn = new TF1("fitFcn",fitFunction,0,4,6);
fitFcn->SetNpx(500);
fitFcn->SetLineWidth(4);
fitFcn->SetLineColor(kRed);
// Set parameters
fitFcn->SetParameters(256, -1.16, 4, 10, 0.1, 3.1);
fitFcn->FixParameter(1, -3.8);
fitFcn->FixParameter(2, 12);
fitFcn->FixParameter(4, 0.1);
fitFcn->FixParameter(5, 3.1);
h1MJPsi[k]->Fit("fitFcn","V+","ep");
// Improve the picture:
TF1 *backFcn = new TF1("backFcn",background,0,4, 3);
backFcn->SetLineColor(kRed);
TF1 *signalFcn = new TF1("signalFcn",lorentzianPeak,0,4, 3);
signalFcn->SetLineColor(kBlue);
signalFcn->SetNpx(500);
// Writes the fit results into the par array
Double_t par[6];
fitFcn->GetParameters(par);
backFcn->SetParameters(par);
backFcn->Draw("same");
signalFcn->SetParameters(&par[3]);
signalFcn->Draw("same");
h1MJPsi[k]->Draw("E");
c10.SaveAs(Form("./figs/%s/h1MJPsi_%d.pdf", slabels.at(k).Data(), k));
c10_log.cd();
h1MJPsi[k]->Draw(); h1MJPsi[k]->SetMinimum(0.1); // Y-axis minimum (for log only)
c10_log.SaveAs(Form("./figs/%s/h1MJPsi_logy_%d.pdf", slabels.at(k).Data(), k));
*/
// ----------------------------------------------------------------------------
c10.cd();
h1Pt[k]->Draw();
c10.SaveAs(Form("./figs/%s/%s/h1Pt_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c10_log.cd();
h1Pt[k]->Draw(); h1Pt[k]->SetMinimum(0.1); // Y-axis minimum (for log only)
c10_log.SaveAs(Form("./figs/%s/%s/h1Pt_logy_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c10.cd();
h1pt[k]->Draw();
c10.SaveAs(Form("./figs/%s/%s/h1pt_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c10_log.cd();
h1pt[k]->Draw(); h1pt[k]->SetMinimum(0.1); // Y-axis minimum (for log only)
c10_log.SaveAs(Form("./figs/%s/%s/h1pt_logy_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c10.cd();
h1Y[k]->Draw(); c10.SaveAs(Form("./figs/%s/%s/h1Y_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
h1y[k]->Draw(); c10.SaveAs(Form("./figs/%s/%s/h1y_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
h1eta[k]->Draw(); c10.SaveAs(Form("./figs/%s/%s/h1eta_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
h1dy[k]->Draw(); c10.SaveAs(Form("./figs/%s/%s/h1dy_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
hprMPt[k]->Draw(); c10.SaveAs(Form("./figs/%s/%s/hprMPt_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
hprMpt[k]->Draw(); c10.SaveAs(Form("./figs/%s/%s/hprMpt_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
TCanvas c100("c100", "c100", 400, 400);
c100.cd();
h2xi1xi2[k]->Draw("COLZ"); c100.SaveAs(Form("./figs/%s/%s/h2xi1xi2_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c100.cd();
h2y1y2[k]->Draw("COLZ"); c100.SaveAs(Form("./figs/%s/%s/h2y1y2_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c100.cd();
h2EtaPhi[k]->Draw("COLZ"); c100.SaveAs(Form("./figs/%s/%s/h2EtaPhi_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c100.cd();
h2MCosTheta[k]->Draw("COLZ"); c100.SaveAs(Form("./figs/%s/%s/h2MCosTheta_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c100.cd();
h2MPt[k]->Draw("COLZ"); c100.SaveAs(Form("./figs/%s/%s/h2MPt_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c100.cd();
h2Mdphi[k]->Draw("COLZ"); c100.SaveAs(Form("./figs/%s/%s/h2Mdphi_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c100.cd();
h2Mpt[k]->Draw("COLZ"); c100.SaveAs(Form("./figs/%s/%s/h2Mpt_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c100.cd();
h2Ptdphi[k]->Draw("COLZ"); c100.SaveAs(Form("./figs/%s/%s/h2Ptdphi_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
c100.cd();
h2ptdphi[k]->Draw("COLZ"); c100.SaveAs(Form("./figs/%s/%s/h2ptdphi_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
// -------------------------------------------------------------------------------------
TCanvas cX("cX", "cX", 400, 300);
cX.cd();
h1XF[k]->Draw(); cX.SaveAs(Form("./figs/%s/%s/h1XF_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
TCanvas cX2("cX2", "cX2", 400, 300);
cX2.cd();
h2MXF[k]->Draw("COLZ"); cX2.SaveAs(Form("./figs/%s/%s/h2MXF_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
TCanvas cX3("cX3", "cX3", 400, 300);
cX3.cd();
hprMXF[k]->Draw(); cX3.SaveAs(Form("./figs/%s/%s/hprMXF_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
cX.cd();
h1XT[k]->Draw(); cX.SaveAs(Form("./figs/%s/%s/h1XT_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
cX2.cd();
h2MXT[k]->Draw("COLZ"); cX2.SaveAs(Form("./figs/%s/%s/h2MXT_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
cX3.cd();
hprMXT[k]->Draw(); cX3.SaveAs(Form("./figs/%s/%s/hprMXT_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
// -------------------------------------------------------------------------------------
// Legendre polynomials in a Rest Frame
const Int_t colors[4] = {48, 53, 98, 32};
// 1...4
{
TCanvas* c115 = new TCanvas("c115","Legendre polynomials",600,400);
TLegend* leg[4];
c115->Divide(2,2, 0.001, 0.001);
for (Int_t l = 0; l < 4; ++l) {
c115->cd(l+1); // note (l+1)
leg[l] = new TLegend(0.15,0.75,0.4,0.85); // x1,y1,x2,y2
hPl[k][l]->SetLineColor(colors[l]);
hPl[k][l]->Draw();
hPl[k][l]->SetMinimum(-0.4); // Y-axis minimum
hPl[k][l]->SetMaximum( 0.4); // Y-axis maximum
leg[l]->SetFillColor(0); // White background
leg[l]->SetBorderSize(0); // No box
leg[l]->AddEntry(hPl[k][l], Form("l = %d", l+1), "l");
leg[l]->Draw();
}
c115->SaveAs(Form("./figs/%s/%s/hPl_1to4_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
}
// 5...8
{
TCanvas* c115 = new TCanvas("c115","Legendre polynomials",600,400);
TLegend* leg[4];
c115->Divide(2,2, 0.001, 0.001);
const Int_t colors[4] = {48, 53, 98, 32};
for (Int_t l = 4; l < 8; ++l) {
c115->cd(l-3); // note (l-3)
leg[l] = new TLegend(0.15,0.75,0.4,0.85); // x1,y1,x2,y2
hPl[k][l]->SetLineColor(colors[l-4]);
hPl[k][l]->Draw();
hPl[k][l]->SetMinimum(-0.4); // Y-axis minimum
hPl[k][l]->SetMaximum( 0.4); // Y-axis maximum
leg[l]->SetFillColor(0); // White background
leg[l]->SetBorderSize(0); // No box
leg[l]->AddEntry(hPl[k][l], Form("l = %d", l+1), "l");
leg[l]->Draw();
}
c115->SaveAs(Form("./figs/%s/%s/hPl_5to8_%d.pdf", output_ascii.c_str(), slabels.at(k).Data(), k));
}
}
}
// Phase II analyzer
void Analyzer(std::vector<std::vector<double>>& channel_prior, int mode) {
printf("EM Phase II: \n");
std::vector<std::vector<double>> channelweight(SPBINS, std::vector<double> (NCHANNEL, 1.0/(double)(NCHANNEL)));
std::vector<double> posterior_sum(NCHANNEL, 0.0);
// Init data
InitTree(ROOT_datafile);
// Loop over events
int N_selected = 0;
for (Int_t ev = 0; ev < tree2track->GetEntries(); ++ev) {
tree2track->GetEntry(ev);
// Get detector signal
GetSignal();
// Check PID signal sanity
if (!CheckPIDsignal())
continue;
// Check VETO
if (!CheckForwardVeto())
continue;
++N_selected;
// Get momentum of tracks
p_r.at(0).SetXYZM(px1,py1,pz1,0);
p_r.at(1).SetXYZM(px2,py2,pz2,0);
system_r = p_r.at(0) + p_r.at(1);
// Find out the momentum bin for each final state
std::vector<int> pbin(NFINALSTATES, 0);
for (uint f = 0; f < NFINALSTATES; ++f) {
pbin.at(f) = GetIdx(p_r.at(f).Perp(), PMIN, PMAX, PBINS);
}
// Get posteriori probabilities for each final states
for (int f = 0; f < NFINALSTATES; ++f) {
GetProb(posterior.at(f), nsigma.at(f), particleweight[pbin.at(f)]);
}
// Find out the momentum bin of the system
int sbin = GetIdx(system_r.Perp(), SPMIN, SPMAX, SPBINS);
// Probabilities of different decay channels, by factorizing (independence) P_tot = P_1 x P_2
std::vector<double> prob_(NCHANNEL, 0.0);
int k = 0;
for (int i = 0; i < NSPECIES; ++i) {
for (int j = 0; j < NSPECIES; ++j) {
prob_[k] = posterior.at(0).at(i) * posterior.at(1).at(j) * channel_prior.at(sbin).at(k); // pi+pi-, KK etc.
++k;
}
}
// Normalize the channel probabilities sum to one
double summ = 1e-12;
for (uint i = 0; i < prob_.size(); ++i) {
summ += prob_[i];
}
for (uint i = 0; i < prob_.size(); ++i) {
prob_.at(i) /= summ;
}
if (mode == 2) {
// Histograms
FillHisto(prob_);
}
// Save decay channel weights
for (uint i = 0; i < prob_.size(); ++i) {
channelweight.at(sbin).at(i) += prob_.at(i);
}
} // Event loop
// Update priors
for (int i = 0; i < SPBINS; ++i) {
for (uint j = 0; j < NCHANNEL; ++j) {
channel_prior.at(i).at(j) = channelweight.at(i).at(j) / (double) N_selected;
}
}
// Collect per channel probabilities
for (int c = 0; c < NCHANNEL; ++c) {
for (int i = 0; i < SPBINS; ++i) {
posterior_sum.at(c) += channelweight.at(i).at(c);
}
}
// Normalize per bin
double NTOT = 0.0;
for (int i = 0; i < SPBINS; ++i) {
double sum = 1e-12;
for (int j = 0; j < NCHANNEL; ++j) {
sum += channelweight[i][j];
}
NTOT += sum;
printf("B[%2d]=[%0.2f,%0.2f] GeV [N = %0.2E]: ", i, (SPMAX - 0.0) / SPBINS * i, (SPMAX - 0.0) / SPBINS * (i+1), sum);
// Ratios
for (int j = 0; j < NCHANNEL; ++j) {
channelweight[i][j] /= sum;
printf("%0.3f ", channelweight[i][j]);
}
printf(" +- ");
// Uncertainty
for (int j = 0; j < NCHANNEL; ++j) {
printf("%0.1E ", z95 * std::sqrt( 1 / sum * channelweight[i][j] * (1.0 - channelweight[i][j]) ));
}
printf("\n");
}
printf("NTOT = %0.2E events \n", NTOT);
printf("\n");
// Calculate sum
double Nsum = 0;
for (int i = 0; i < NCHANNEL; ++i) {
Nsum += posterior_sum.at(i);
}
// Print out particle ratios with Binomial proportion uncertainty
printf("EM Phase II: Integrated channel fractions (CL95 statistical): \n");
for (int i = 0; i < NCHANNEL; ++i) {
double p = posterior_sum.at(i) / Nsum;
printf("Channel[%d] = %0.4f +- %0.2E (%s) \n", i, p, z95 * std::sqrt(1/Nsum * p * (1.0 - p)), slabels.at(i).Data() );
}
printf("\n");
// Close our data source
CloseTree();
}
// Phase I analyzer
std::vector<std::vector<double>> EM(double PMIN, double PMAX, int PBINS, int ITER) {
printf("EM Phase I: \n");
// Init data
InitTree(ROOT_datafile);
std::vector<double> posterior_sum;
for (int i = 0; i < NSPECIES; ++i) {
posterior_sum.push_back(0.0);
}
std::vector<std::vector<double> > particleweight(PBINS, std::vector<double>(NSPECIES, 1.0/(double)NSPECIES));
if (ITER == 0) {
printf("EM Phase I: no iteration, flat priors returned\n");
return particleweight;
}
for (int it = 0; it < ITER; ++it) {
printf("EM Phase I: Iteration = %d/%d (95CL statistical)\n", it+1, ITER);
// Loop over events
for (Int_t ev = 0; ev < tree2track->GetEntries(); ++ev) {
tree2track->GetEntry(ev);
// Get detector signal
GetSignal();
// Check PID signal sanity
if (!CheckPIDsignal())
continue;
// Check VETO
if (!CheckForwardVeto())
continue;
// Get momentum of tracks
p_r.at(0).SetXYZM(px1,py1,pz1,0);
p_r.at(1).SetXYZM(px2,py2,pz2,0);
// Find out the momentum bin for each final state
std::vector<int> pbin(NFINALSTATES, 0);
for (int f = 0; f < NFINALSTATES; ++f) {
pbin.at(f) = GetIdx(p_r.at(f).Perp(), PMIN, PMAX, PBINS);
}
// Get posteriori probabilities for each final states
for (int f = 0; f < NFINALSTATES; ++f) {
GetProb(posterior.at(f), nsigma.at(f), particleweight[pbin.at(f)]);
}
// Save |momentum| dependent weight for iterative mapping
for (int i = 0; i < NSPECIES; ++i) {
// Save weight from each final state
for (int f = 0; f < NFINALSTATES; ++f) {
particleweight[pbin.at(f)][i] += posterior.at(f).at(i);
}
}
// LAST ITERATION: Save posteriori probabilities for particle ratios
if (it == ITER - 1) {
for (int i = 0; i < NSPECIES; ++i) {
// Loop over final states
for (int f = 0; f < NFINALSTATES; ++f) {
posterior_sum.at(i) += posterior.at(f).at(i);
}
}
}
}
// Normalize per bin
double NTOT = 0.0;
for (int i = 0; i < PBINS; ++i) {
double sum = 1e-12;
for (int j = 0; j < NSPECIES; ++j) {
sum += particleweight[i][j];
}
NTOT += sum;
printf("bin[%2d] = [%0.3f, %0.3f] GeV [N = %0.2E]: ", i, (PMAX - 0.0) / PBINS * i, (PMAX - 0.0) / PBINS * (i+1), sum);
// Ratios
for (int j = 0; j < NSPECIES; ++j) {
particleweight[i][j] /= sum;
printf("%0.3f ", particleweight[i][j]);
}
printf(" +- ");
// Uncertainty
for (int j = 0; j < NSPECIES; ++j) {
printf("%0.1E ", z95 * std::sqrt( 1 / sum * particleweight[i][j] * (1.0 - particleweight[i][j]) ));
}
printf("\n");
}
printf("NTOT = %0.2E particles \n", NTOT);
printf("\n");
} // EM iteration
// Calculate sum
double Nsum = 0;
for (int i = 0; i < NSPECIES; ++i) {
Nsum += posterior_sum.at(i);
}
// Print out particle ratios with Binomial proportion uncertainty
printf("EM Phase I: Integrated particle fractions (CL95 statistical): \n");
for (int i = 0; i < NSPECIES; ++i) {
double p = posterior_sum.at(i) / Nsum;
printf("Particle[%d] = %0.4f +- %0.2E (%s) \n", i, p, z95 * std::sqrt(1/Nsum * p * (1.0 - p)), plabels.at(i).Data() );
}
printf("\n");
// Close our data
CloseTree();
return particleweight;
}
// Get table/histogram index for linearly spaced bins
// Gives exact uniform filling within bin boundaries.
int GetIdx(double value, double MINVAL, double MAXVAL, int NUMBINS) {
const double BINWIDTH = (MAXVAL - MINVAL) / (double)NUMBINS;
int idx = std::floor((value - MINVAL) / BINWIDTH);
if (idx < 0) { // Underflow
idx = 0;
}
if (idx > NUMBINS - 1) { // Overflow
idx = NUMBINS - 1;
}
return idx;
}
// Get posteriori probabilities
void GetProb(std::vector<double>& posterior,
const std::vector<std::vector<double>>& nsigma, const std::vector<double>& prior) {
std::vector<double> fval(prior.size(), 1.0); // init with 1.0
// Evaluate likelihood for different particle types
for (uint i = 0; i < prior.size(); ++i) {
// Loop over detectors (TPC,TOF)
//bool check = false;
for (uint det = 0; det < nsigma.at(i).size(); ++det) {
// Missing values (such as missing TOF are omitted from the product likelihood)
if (-BOUND < nsigma.at(i).at(det) && nsigma.at(i).at(det) < BOUND) {
// Independent detectors -> product likelihood (correlation information neglected)
fval.at(i) *= fG(nsigma.at(i).at(det));
}
}
}
// Evaluate Posterior ~ likelihood x prior
for (uint i = 0; i < posterior.size(); ++i) {
posterior.at(i) = fval.at(i) * prior.at(i);
}
// Normalize by evidence (denominator of Bayes formula)
double denominator = 0;
for (uint i = 0; i < posterior.size(); ++i) {
denominator += posterior.at(i);
}
// Now Posterior = likelihood x prior / sum_i likelihood x prior
denominator += 1e-12; // protection
for (uint i = 0; i < posterior.size(); ++i) {
posterior.at(i) /= denominator;
}
}
// Gaussian likelihood (density), based on asumption that the generation of nsigma
// values has been normalized along the different particle species (pion, kaon) etc.
// -> can be compared.
double fG(double n) {
const double sigma = 1.0;
return 1.0/(std::sqrt(2.0*PI)*sigma) * std::exp(-0.5*n*n);
}
|
54c348bd31ffc712992cf9cb6d8a7f89e0da2127
|
04b9e26e4036465ea1038e4ad42406fe95eb9079
|
/transaction.hpp
|
495cf99d6429115232d35383b9f457cf95d78006
|
[] |
no_license
|
prakhar-gupta/cryptocurrency-simulator
|
402a057ee7cdbea9af9292f827415bb79afb8a1b
|
eb4867cfc0c29868f8c7ff41e2b6ab6f4bf82cbf
|
refs/heads/master
| 2021-03-24T12:43:31.843636
| 2018-02-14T18:03:36
| 2018-02-14T18:03:36
| 120,280,634
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 79
|
hpp
|
transaction.hpp
|
struct Transaction {
int id;
int from;
int to;
float value;
};
|
b04a76df3c0ad95d8c33410061c6f3ffac1a7349
|
271a57344dcb49a80feae682ecc1d39f991eec81
|
/src/providerifcs/oop/OW_OOPProtocolCPP1.cpp
|
384692b3204cce85601d5ba0770556c5442de752
|
[
"BSD-3-Clause"
] |
permissive
|
kkaempf/openwbem
|
b16f7b8f0db6c1dbe1ee0467f7ab1b543253ea35
|
b923c1fffd0e7f5489843c8c3b3850c50880ab9b
|
refs/heads/main
| 2023-03-16T00:41:34.967003
| 2023-02-21T06:59:50
| 2023-02-21T06:59:50
| 5,981,070
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 34,596
|
cpp
|
OW_OOPProtocolCPP1.cpp
|
/*******************************************************************************
* Copyright (C) 2005 Quest Software, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of Quest Software, Inc. 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 Quest Software, Inc. OR THE CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
/**
* @author Dan Nuffer
*/
#include "OW_config.h"
#include "OW_OOPProtocolCPP1.hpp"
#include "OW_OOPProtocolCPP1Impl.hpp"
#include "OW_CIMInstance.hpp"
#include "OW_CIMObjectPath.hpp"
#include "OW_BinarySerialization.hpp"
#include "blocxx/IOException.hpp"
#include "OW_CIMException.hpp"
#include "OW_ResultHandlerIFC.hpp"
#include "OW_ProviderEnvironmentIFC.hpp"
#include "blocxx/Format.hpp"
#include "blocxx/LogMessage.hpp"
#include "blocxx/Logger.hpp"
#include "OW_OperationContext.hpp"
#include "OW_BinaryRequestHandler.hpp"
#include "OW_HTTPChunkedIStream.hpp"
#include "OW_HTTPChunkedOStream.hpp"
#include "blocxx/TempFileStream.hpp"
#include "OW_HTTPUtils.hpp"
#include "OW_CIMParamValue.hpp"
#include "blocxx/DateTime.hpp"
#include "blocxx/UnnamedPipe.hpp"
#include "blocxx/DataStreams.hpp"
#include "blocxx/Runnable.hpp"
#include "blocxx/IOIFCStreamBuffer.hpp"
#include "blocxx/ThreadPool.hpp"
#include "blocxx/NonRecursiveMutex.hpp"
#include "blocxx/NonRecursiveMutexLock.hpp"
#include "OW_CIMOMHandleIFC.hpp"
#include "OW_OOPProviderBase.hpp"
#include "OW_OOPDataOStreamBuf.hpp"
#include "OW_OOPCallbackServiceEnv.hpp"
#include "OW_OOPCIMOMHandleConnectionRunner.hpp"
#include "blocxx/SelectEngine.hpp"
#include <deque>
#include <iosfwd>
// The classes and functions defined in this file are not meant for general
// use, they are internal implementation details. They may change at any time.
namespace OW_NAMESPACE
{
using namespace OOPProtocolCPP1Impl;
using namespace blocxx;
OOPProtocolCPP1::OOPProtocolCPP1(OOPProviderBase* pprov)
: OOPProtocolIFC(pprov)
{
}
OOPProtocolCPP1::~OOPProtocolCPP1()
{
}
namespace
{
const String COMPONENT_NAME("ow.provider.OOP.ifc");
enum EReadWriteFlag
{
E_READ_WRITE_UNTIL_FINISHED,
E_WRITE_ONLY
};
void end(Array<unsigned char>& outputBuf,
const UnnamedPipeRef& inputPipe,
const UnnamedPipeRef& outputPipe,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
OperationResultHandler& result,
OOPProviderBase* pprov,
EReadWriteFlag readWriteFlag = E_READ_WRITE_UNTIL_FINISHED)
{
const int MAX_CALLBACK_THREADS = 10;
Logger logger(COMPONENT_NAME);
ThreadPool threadPool(ThreadPool::DYNAMIC_SIZE_NO_QUEUE, MAX_CALLBACK_THREADS, MAX_CALLBACK_THREADS, logger, "OOPProtocolCPP1");
SelectEngine selectEngine;
Array<unsigned char> inputBuf;
std::deque<OutputEntry> outputEntries;
inputPipe->setTimeouts(Timeout::relative(0));
outputPipe->setTimeouts(Timeout::relative(0));
outputPipe->setWriteBlocking(UnnamedPipe::E_NONBLOCKING);
bool finishedSuccessfully = false;
ShutdownThreadPool shutdownThreadPool(threadPool);
SelectableCallbackIFCRef callback(new OOPSelectableCallback(
inputBuf, outputEntries, inputPipe, outputPipe, env, result, selectEngine,
finishedSuccessfully, threadPool, pprov));
if (readWriteFlag == E_READ_WRITE_UNTIL_FINISHED)
{
selectEngine.addSelectableObject(inputPipe->getReadSelectObj(), callback, SelectableCallbackIFC::E_READ_EVENT);
}
if (!outputBuf.empty())
{
outputEntries.push_back(OutputEntry(outputBuf));
selectEngine.addSelectableObject(outputPipe->getWriteSelectObj(), callback, SelectableCallbackIFC::E_WRITE_EVENT);
}
BLOCXX_LOG_DEBUG3(logger, "end() about to run the select engine");
try
{
selectEngine.go(timeout);
}
catch (SelectException& e)
{
OW_THROW(OOPProtocolCPP1Exception, "Timeout expired, provider terminated");
}
if (readWriteFlag == E_READ_WRITE_UNTIL_FINISHED && !finishedSuccessfully)
{
OW_THROW(OOPProtocolCPP1Exception, "pipe closed without sending a BIN_END");
}
}
class CIMObjectPathOperationResultHandler : public OperationResultHandler
{
public:
CIMObjectPathOperationResultHandler(CIMObjectPathResultHandlerIFC& result)
: m_result(result)
{}
virtual void handleResult(std::streambuf & instr, UInt8 op)
{
if (op == BinarySerialization::BINSIG_OP)
{
CIMObjectPath ci = BinarySerialization::readObjectPath(instr);
m_result.handle(ci);
}
else
{
OW_THROW(OOPProtocolCPP1Exception, Format("Invalid op, expected BINSIG_OP, got: %1", static_cast<int>(op)).c_str());
}
}
private:
CIMObjectPathResultHandlerIFC& m_result;
};
class CIMInstanceOperationResultHandler : public OperationResultHandler
{
public:
CIMInstanceOperationResultHandler(CIMInstanceResultHandlerIFC& result)
: m_result(result)
{}
virtual void handleResult(std::streambuf & instr, UInt8 op)
{
if (op == BinarySerialization::BINSIG_INST)
{
CIMInstance ci = BinarySerialization::readInstance(instr);
m_result.handle(ci);
}
else
{
OW_THROW(OOPProtocolCPP1Exception, Format("Invalid op, expected BINSIG_INST, got: %1", static_cast<int>(op)).c_str());
}
}
private:
CIMInstanceResultHandlerIFC& m_result;
};
class GetInstanceOperationResultHandler : public OperationResultHandler
{
public:
GetInstanceOperationResultHandler(CIMInstance& returnValue)
: m_returnValue(returnValue)
{
}
virtual void handleResult(std::streambuf & instr, UInt8 op)
{
if (op == BinarySerialization::BIN_OK)
{
m_returnValue = BinarySerialization::readInstance(instr);
}
else
{
OW_THROW(OOPProtocolCPP1Exception, Format("Invalid op, expected BINSIG_OK, got: %1", static_cast<int>(op)).c_str());
}
}
private:
CIMInstance& m_returnValue;
};
class CreateInstanceOperationResultHandler : public OperationResultHandler
{
public:
CreateInstanceOperationResultHandler(CIMObjectPath& returnValue)
: m_returnValue(returnValue)
{
}
virtual void handleResult(std::streambuf & instr, UInt8 op)
{
if (op == BinarySerialization::BIN_OK)
{
m_returnValue = BinarySerialization::readObjectPath(instr);
}
else
{
OW_THROW(OOPProtocolCPP1Exception, Format("Invalid op, expected BINSIG_OK, got: %1", static_cast<int>(op)).c_str());
}
}
private:
CIMObjectPath& m_returnValue;
};
class VoidOperationResultHandler : public OperationResultHandler
{
public:
VoidOperationResultHandler(bool& gotOK)
: m_gotOK(gotOK)
{
}
virtual void handleResult(std::streambuf & instr, UInt8 op)
{
if (op != BinarySerialization::BIN_OK)
{
OW_THROW(OOPProtocolCPP1Exception, Format("Invalid op, expected BINSIG_OK, got: %1", static_cast<int>(op)).c_str());
}
m_gotOK = true;
}
private:
bool& m_gotOK;
};
class InvokeMethodOperationResultHandler : public OperationResultHandler
{
public:
InvokeMethodOperationResultHandler(CIMValue& returnValue, CIMParamValueArray& outParams, bool& gotOK)
: m_returnValue(returnValue)
, m_outParams(outParams)
, m_gotOK(gotOK)
{
}
virtual void handleResult(std::streambuf & instr, UInt8 op)
{
if (op == BinarySerialization::BIN_OK)
{
m_returnValue = BinarySerialization::readValue(instr);
BinarySerialization::verifySignature(instr, BinarySerialization::BINSIG_PARAMVALUEARRAY);
BinarySerialization::readArray(instr, m_outParams);
m_gotOK = true;
}
else
{
OW_THROW(OOPProtocolCPP1Exception, Format("Invalid op, expected BINSIG_OK, got: %1", static_cast<int>(op)).c_str());
}
}
private:
CIMValue& m_returnValue;
CIMParamValueArray& m_outParams;
bool& m_gotOK;
};
class Int32OperationResultHandler : public OperationResultHandler
{
public:
Int32OperationResultHandler(Int32& returnValue, bool& gotOK)
: m_returnValue(returnValue)
, m_gotOK(gotOK)
{
}
virtual void handleResult(std::streambuf & instr, UInt8 op)
{
if (op == BinarySerialization::BIN_OK)
{
BinarySerialization::read(instr, m_returnValue);
m_gotOK = true;
}
else
{
OW_THROW(OOPProtocolCPP1Exception, Format("Invalid op, expected BINSIG_OK, got: %1", static_cast<int>(op)).c_str());
}
}
private:
Int32& m_returnValue;
bool& m_gotOK;
};
} // end unnamed namespace
void
OOPProtocolCPP1::enumInstanceNames(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
const String& ns,
const String& className,
CIMObjectPathResultHandlerIFC& result,
const CIMClass& cimClass)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::enumInstanceNames about to start filling request buffer");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::BIN_ENUMINSTNAMES);
BinarySerialization::writeString(obuf, ns);
BinarySerialization::writeString(obuf, className);
BinarySerialization::writeClass(obuf, cimClass);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::enumInstanceNames finished filling buffer");
CIMObjectPathOperationResultHandler operationResult(result);
end(buf, in, out, timeout, env, operationResult, m_pprov);
}
void
OOPProtocolCPP1::enumInstances(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
const String& ns,
const String& className,
CIMInstanceResultHandlerIFC& result,
WBEMFlags::ELocalOnlyFlag localOnly,
WBEMFlags::EDeepFlag deep,
WBEMFlags::EIncludeQualifiersFlag includeQualifiers,
WBEMFlags::EIncludeClassOriginFlag includeClassOrigin,
const StringArray* propertyList,
const CIMClass& requestedClass,
const CIMClass& cimClass)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::enumInstances about to start filling request buffer");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::BIN_ENUMINSTS);
BinarySerialization::writeString(obuf, ns);
BinarySerialization::writeString(obuf, className);
BinarySerialization::writeBool(obuf, localOnly);
BinarySerialization::writeBool(obuf, deep);
BinarySerialization::writeBool(obuf, includeQualifiers);
BinarySerialization::writeBool(obuf, includeClassOrigin);
BinarySerialization::writeStringArray(obuf, propertyList);
BinarySerialization::writeClass(obuf, requestedClass);
BinarySerialization::writeClass(obuf, cimClass);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::enumInstances finished filling buffer");
CIMInstanceOperationResultHandler operationResult(result);
end(buf, in, out, timeout, env, operationResult, m_pprov);
}
CIMInstance
OOPProtocolCPP1::getInstance(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
const String& ns,
const CIMObjectPath& instanceName,
WBEMFlags::ELocalOnlyFlag localOnly,
WBEMFlags::EIncludeQualifiersFlag includeQualifiers,
WBEMFlags::EIncludeClassOriginFlag includeClassOrigin,
const StringArray* propertyList,
const CIMClass& cimClass)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::getInstance about to start filling request buffer");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::BIN_GETINST);
BinarySerialization::writeString(obuf, ns);
BinarySerialization::writeObjectPath(obuf, instanceName);
BinarySerialization::writeBool(obuf, localOnly);
BinarySerialization::writeBool(obuf, includeQualifiers);
BinarySerialization::writeBool(obuf, includeClassOrigin);
BinarySerialization::writeStringArray(obuf, propertyList);
BinarySerialization::writeClass(obuf, cimClass);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::getInstance finished filling buffer");
CIMInstance rval(CIMNULL);
GetInstanceOperationResultHandler operationResult(rval);
end(buf, in, out, timeout, env, operationResult, m_pprov);
if (!rval)
{
OW_THROW(OOPProtocolCPP1Exception, "OOPProtocolCPP1: No result from call to getInstance");
}
return rval;
}
CIMObjectPath
OOPProtocolCPP1::createInstance(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
const String& ns,
const CIMInstance& cimInstance)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::createInstance about to start filling request buffer");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::BIN_CREATEINST);
BinarySerialization::writeString(obuf, ns);
BinarySerialization::writeInstance(obuf, cimInstance);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::createInstance finished filling buffer");
CIMObjectPath rval(CIMNULL);
CreateInstanceOperationResultHandler operationResult(rval);
end(buf, in, out, timeout, env, operationResult, m_pprov);
if (!rval)
{
OW_THROW(OOPProtocolCPP1Exception, "OOPProtocolCPP1: No result from call to createInstance");
}
return rval;
}
void
OOPProtocolCPP1::modifyInstance(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
const String& ns,
const CIMInstance& modifiedInstance,
const CIMInstance& previousInstance,
WBEMFlags::EIncludeQualifiersFlag includeQualifiers,
const StringArray* propertyList,
const CIMClass& theClass)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::modifyInstance about to start filling request buffer");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::BIN_MODIFYINST);
BinarySerialization::writeString(obuf, ns);
BinarySerialization::writeInstance(obuf, modifiedInstance);
BinarySerialization::writeInstance(obuf, previousInstance);
BinarySerialization::writeBool(obuf, includeQualifiers);
BinarySerialization::writeStringArray(obuf, propertyList);
BinarySerialization::writeClass(obuf, theClass);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::modifyInstance finished filling buffer");
bool gotOK = false;
VoidOperationResultHandler operationResult(gotOK);
end(buf, in, out, timeout, env, operationResult, m_pprov);
if (!gotOK)
{
OW_THROW(OOPProtocolCPP1Exception, "OOPProtocolCPP1: No result from call to modifyInstance");
}
}
void
OOPProtocolCPP1::deleteInstance(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
const String& ns,
const CIMObjectPath& cop)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::deleteInstance about to start filling request buffer");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::BIN_DELETEINST);
BinarySerialization::writeString(obuf, ns);
BinarySerialization::writeObjectPath(obuf, cop);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::deleteInstance finished filling buffer");
bool gotOK = false;
VoidOperationResultHandler operationResult(gotOK);
end(buf, in, out, timeout, env, operationResult, m_pprov);
if (!gotOK)
{
OW_THROW(OOPProtocolCPP1Exception, "OOPProtocolCPP1: No result from call to deleteInstance");
}
}
void
OOPProtocolCPP1::associators(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
CIMInstanceResultHandlerIFC& result,
const String& ns,
const CIMObjectPath& objectName,
const String& assocClass,
const String& resultClass,
const String& role,
const String& resultRole,
WBEMFlags::EIncludeQualifiersFlag includeQualifiers,
WBEMFlags::EIncludeClassOriginFlag includeClassOrigin,
const StringArray* propertyList)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::associators about to start filling request buffer");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::BIN_ASSOCIATORS);
BinarySerialization::writeString(obuf, ns);
BinarySerialization::writeObjectPath(obuf, objectName);
BinarySerialization::writeString(obuf, assocClass);
BinarySerialization::writeString(obuf, resultClass);
BinarySerialization::writeString(obuf, role);
BinarySerialization::writeString(obuf, resultRole);
BinarySerialization::writeBool(obuf, includeQualifiers);
BinarySerialization::writeBool(obuf, includeClassOrigin);
BinarySerialization::writeStringArray(obuf, propertyList);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::associators finished filling buffer");
CIMInstanceOperationResultHandler operationResult(result);
end(buf, in, out, timeout, env, operationResult, m_pprov);
}
void
OOPProtocolCPP1::associatorNames(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
CIMObjectPathResultHandlerIFC& result,
const String& ns,
const CIMObjectPath& objectName,
const String& assocClass,
const String& resultClass,
const String& role,
const String& resultRole)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::associatorNames about to start filling request buffer");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::BIN_ASSOCNAMES);
BinarySerialization::writeString(obuf, ns);
BinarySerialization::writeObjectPath(obuf, objectName);
BinarySerialization::writeString(obuf, assocClass);
BinarySerialization::writeString(obuf, resultClass);
BinarySerialization::writeString(obuf, role);
BinarySerialization::writeString(obuf, resultRole);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::associatorNames finished filling buffer");
CIMObjectPathOperationResultHandler operationResult(result);
end(buf, in, out, timeout, env, operationResult, m_pprov);
}
void
OOPProtocolCPP1::references(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
CIMInstanceResultHandlerIFC& result,
const String& ns,
const CIMObjectPath& objectName,
const String& resultClass,
const String& role,
WBEMFlags::EIncludeQualifiersFlag includeQualifiers,
WBEMFlags::EIncludeClassOriginFlag includeClassOrigin,
const StringArray* propertyList)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::references about to start filling request buffer");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::BIN_REFERENCES);
BinarySerialization::writeString(obuf, ns);
BinarySerialization::writeObjectPath(obuf, objectName);
BinarySerialization::writeString(obuf, resultClass);
BinarySerialization::writeString(obuf, role);
BinarySerialization::writeBool(obuf, includeQualifiers);
BinarySerialization::writeBool(obuf, includeClassOrigin);
BinarySerialization::writeStringArray(obuf, propertyList);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::references finished filling buffer");
CIMInstanceOperationResultHandler operationResult(result);
end(buf, in, out, timeout, env, operationResult, m_pprov);
}
void
OOPProtocolCPP1::referenceNames(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
CIMObjectPathResultHandlerIFC& result,
const String& ns,
const CIMObjectPath& objectName,
const String& resultClass,
const String& role)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::referenceNames about to start filling request buffer");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::BIN_REFNAMES);
BinarySerialization::writeString(obuf, ns);
BinarySerialization::writeObjectPath(obuf, objectName);
BinarySerialization::writeString(obuf, resultClass);
BinarySerialization::writeString(obuf, role);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::referenceNames finished filling buffer");
CIMObjectPathOperationResultHandler operationResult(result);
end(buf, in, out, timeout, env, operationResult, m_pprov);
}
CIMValue
OOPProtocolCPP1::invokeMethod(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
const String& ns,
const CIMObjectPath& path,
const String& methodName,
const CIMParamValueArray& inparams,
CIMParamValueArray& outparams)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::invokeMethod about to start writing");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::BIN_INVMETH);
BinarySerialization::writeString(obuf, ns);
BinarySerialization::writeObjectPath(obuf, path);
BinarySerialization::writeString(obuf, methodName);
BinarySerialization::write(obuf, BinarySerialization::BINSIG_PARAMVALUEARRAY);
BinarySerialization::writeArray(obuf, inparams);
BinarySerialization::write(obuf, BinarySerialization::BINSIG_PARAMVALUEARRAY);
BinarySerialization::writeArray(obuf, outparams);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::invokeMethod finished writing.");
CIMValue returnValue(CIMNULL);
bool gotOK = false;
InvokeMethodOperationResultHandler operationResult(returnValue, outparams, gotOK);
end(buf, in, out, timeout, env, operationResult, m_pprov);
if (!gotOK)
{
OW_THROW(OOPProtocolCPP1Exception, "OOPProtocolCPP1: No result from call to invokeMethod");
}
return returnValue;
}
Int32
OOPProtocolCPP1::poll(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::poll about to start writing");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::POLL);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::poll finished writing.");
Int32 returnValue(-1);
bool gotOK = false;
Int32OperationResultHandler operationResult(returnValue, gotOK);
end(buf, in, out, timeout, env, operationResult, m_pprov);
if (!gotOK)
{
OW_THROW(OOPProtocolCPP1Exception, "OOPProtocolCPP1: No result from call to poll");
}
return returnValue;
}
Int32
OOPProtocolCPP1::getInitialPollingInterval(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::getInitialPollingInterval about to start writing");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::GET_INITIAL_POLLING_INTERVAL);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::getInitialPollingInterval finished writing.");
Int32 returnValue(-1);
bool gotOK = false;
Int32OperationResultHandler operationResult(returnValue, gotOK);
end(buf, in, out, timeout, env, operationResult, m_pprov);
if (!gotOK)
{
OW_THROW(OOPProtocolCPP1Exception, "OOPProtocolCPP1: No result from call to getInitialPollingInterval");
}
return returnValue;
}
void
OOPProtocolCPP1::setPersistent(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
bool persistent)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, Format("OOPProtocolCPP1::setPersistent about to start writing: %1", persistent));
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::SET_PERSISTENT);
BinarySerialization::writeBool(obuf, persistent);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::setPersistent finished writing.");
NoResultHandler noResultHandler;
end(buf, in, out, timeout, env, noResultHandler, m_pprov, E_WRITE_ONLY);
}
void
OOPProtocolCPP1::setLogLevel(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
ELogLevel logLevel)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, Format("OOPProtocolCPP1::setLogLevel about to start writing: %1", static_cast<int>(logLevel)));
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::SET_LOG_LEVEL);
BinarySerialization::write(obuf, static_cast<UInt8>(logLevel));
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::setLogLevel finished writing.");
NoResultHandler noResultHandler;
end(buf, in, out, timeout, env, noResultHandler, m_pprov, E_WRITE_ONLY);
}
void
OOPProtocolCPP1::activateFilter(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
const WQLSelectStatement& filter,
const String& eventType,
const String& nameSpace,
const StringArray& classes,
bool firstActivation)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::activateFilter about to start writing");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::ACTIVATE_FILTER);
BinarySerialization::writeWQLSelectStatement(obuf, filter);
BinarySerialization::writeString(obuf, eventType);
BinarySerialization::writeString(obuf, nameSpace);
BinarySerialization::writeStringArray(obuf, classes);
Bool(firstActivation).writeObject(obuf);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::activateFilter finished writing.");
bool gotOK = false;
VoidOperationResultHandler operationResult(gotOK);
end(buf, in, out, timeout, env, operationResult, m_pprov);
if (!gotOK)
{
OW_THROW(OOPProtocolCPP1Exception, "OOPProtocolCPP1: No result from call to activateFilter");
}
}
void
OOPProtocolCPP1::authorizeFilter(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
const WQLSelectStatement& filter,
const String& eventType,
const String& nameSpace,
const StringArray& classes,
const String& owner)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::authorizeFilter about to start writing");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::AUTHORIZE_FILTER);
BinarySerialization::writeWQLSelectStatement(obuf, filter);
BinarySerialization::writeString(obuf, eventType);
BinarySerialization::writeString(obuf, nameSpace);
BinarySerialization::writeStringArray(obuf, classes);
BinarySerialization::writeString(obuf, owner);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::authorizeFilter finished writing.");
bool gotOK = false;
VoidOperationResultHandler operationResult(gotOK);
end(buf, in, out, timeout, env, operationResult, m_pprov);
if (!gotOK)
{
OW_THROW(OOPProtocolCPP1Exception, "OOPProtocolCPP1: No result from call to authorizeFilter");
}
}
void
OOPProtocolCPP1::deActivateFilter(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
const WQLSelectStatement& filter,
const String& eventType,
const String& nameSpace,
const StringArray& classes,
bool lastActivation)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::deActivateFilter about to start writing");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::DEACTIVATE_FILTER);
BinarySerialization::writeWQLSelectStatement(obuf, filter);
BinarySerialization::writeString(obuf, eventType);
BinarySerialization::writeString(obuf, nameSpace);
BinarySerialization::writeStringArray(obuf, classes);
Bool(lastActivation).writeObject(obuf);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::deActivateFilter finished writing.");
bool gotOK = false;
VoidOperationResultHandler operationResult(gotOK);
end(buf, in, out, timeout, env, operationResult, m_pprov);
if (!gotOK)
{
OW_THROW(OOPProtocolCPP1Exception, "OOPProtocolCPP1: No result from call to deActivateFilter");
}
}
int
OOPProtocolCPP1::mustPoll(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
const WQLSelectStatement& filter,
const String& eventType,
const String& nameSpace,
const StringArray& classes)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::mustPoll about to start writing");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::MUST_POLL);
BinarySerialization::writeWQLSelectStatement(obuf, filter);
BinarySerialization::writeString(obuf, eventType);
BinarySerialization::writeString(obuf, nameSpace);
BinarySerialization::writeStringArray(obuf, classes);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::mustPoll finished writing.");
Int32 returnValue(-1);
bool gotOK = false;
Int32OperationResultHandler operationResult(returnValue, gotOK);
end(buf, in, out, timeout, env, operationResult, m_pprov);
if (!gotOK)
{
OW_THROW(OOPProtocolCPP1Exception, "OOPProtocolCPP1: No result from call to mustPoll");
}
return returnValue;
}
void
OOPProtocolCPP1::exportIndication(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
const String& ns,
const CIMInstance& indHandlerInst,
const CIMInstance& indicationInst)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::exportIndication about to start writing");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::EXPORT_INDICATION);
BinarySerialization::writeString(obuf, ns);
BinarySerialization::writeInstance(obuf, indHandlerInst);
BinarySerialization::writeInstance(obuf, indicationInst);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::exportIndication finished writing.");
bool gotOK = false;
VoidOperationResultHandler operationResult(gotOK);
end(buf, in, out, timeout, env, operationResult, m_pprov);
if (!gotOK)
{
OW_THROW(OOPProtocolCPP1Exception, "OOPProtocolCPP1: No result from call to exportIndication");
}
}
void
OOPProtocolCPP1::shuttingDown(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::shuttingDown about to start writing");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::SHUTTING_DOWN);
bool gotOK = false;
VoidOperationResultHandler operationResult(gotOK);
end(buf, in, out, timeout, env, operationResult, m_pprov);
if (!gotOK)
{
OW_THROW(OOPProtocolCPP1Exception, "OOPProtocolCPP1: No result from call to shuttingDown");
}
}
void
OOPProtocolCPP1::queryInstances(
const UnnamedPipeRef& in,
const UnnamedPipeRef& out,
const Timeout& timeout,
const ProviderEnvironmentIFCRef& env,
const String& ns,
const WQLSelectStatement& query,
CIMInstanceResultHandlerIFC& result,
const CIMClass& cimClass)
{
Logger logger(COMPONENT_NAME);
BLOCXX_LOG_DEBUG3(logger, "OOPProtocolCPP1::queryInstances about to start filling request buffer");
Array<unsigned char> buf;
OOPDataOStreamBuf obuf(buf);
BinarySerialization::write(obuf, BinarySerialization::BinaryProtocolVersion);
BinarySerialization::write(obuf, BinarySerialization::QUERY_INSTANCES);
BinarySerialization::writeString(obuf, ns);
BinarySerialization::writeWQLSelectStatement(obuf, query);
BinarySerialization::writeClass(obuf, cimClass);
CIMInstanceOperationResultHandler operationResult(result);
end(buf, in, out, timeout, env, operationResult, m_pprov);
}
} // end namespace OW_NAMESPACE
|
a0e92a1f54f6d4299a2c4f1d71d159bc0b8b71b9
|
1075f2ad320c48a245c8f2b795621b773c3375db
|
/module_1/ex00/Pony.hpp
|
69a6f82b8bfdb7f725b6645eca8b0372fe6417f1
|
[
"MIT"
] |
permissive
|
cgriceld/42-cpp-piscine
|
59d1f197a620a12605e5326aeabdcccdeff2b343
|
2d07a886f0eca3216b50a17da807c721d6684e5d
|
refs/heads/main
| 2023-07-02T17:36:59.044027
| 2021-08-16T10:54:04
| 2021-08-16T10:54:04
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 286
|
hpp
|
Pony.hpp
|
#ifndef PONY_HPP
# define PONY_HPP
#include <string>
#include <iostream>
class Pony
{
public:
Pony(std::string type);
Pony(int age, std::string name, std::string type);
~Pony();
void introduce(void) const;
private:
int _age;
std::string _name;
std::string _type;
};
#endif
|
2ce13270f0e5d31f817cb1efc3b9891986b7f894
|
de6984e84538181a52521796ad568fd11583ad1a
|
/src/Input_Output/Input_Output_SEDP.h
|
878dc972eea184adcc0c79ae34541168921a3ed9
|
[
"BSD-2-Clause",
"MIT"
] |
permissive
|
athenarc/SCALE-MAMBA
|
fd75e2173319dba3227511cadd4b76f4f3c80096
|
18fa886d820bec7e441448357b8f09e2be0e7c9e
|
refs/heads/master
| 2020-06-01T10:22:47.681564
| 2019-07-15T16:31:26
| 2019-07-15T16:31:26
| 190,745,488
| 3
| 0
|
NOASSERTION
| 2019-07-23T13:10:27
| 2019-06-07T13:10:57
|
C++
|
UTF-8
|
C++
| false
| false
| 1,875
|
h
|
Input_Output_SEDP.h
|
/*
Copyright (c) 2017, The University of Bristol, Senate House, Tyndall Avenue, Bristol, BS8 1TH, United Kingdom.
Copyright (c) 2018, COSIC-KU Leuven, Kasteelpark Arenberg 10, bus 2452, B-3001 Leuven-Heverlee, Belgium.
All rights reserved
*/
#ifndef _InputOutputSEDP
#define _InputOutputSEDP
/* A simple IO class which just uses standard
* input/output to communicate values
*
* Whereas share values are input/output using
* a steam, with either human or non-human form
*/
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include "App/Protocol.h"
#include "App/Server.h"
#include "IO_Stream.h"
using namespace std;
class Input_Output_SEDP : public IO_Stream
{
private:
unsigned int player_id, number_of_clients;
sedp::Server s;
vector<gfp> data;
public:
string inf_name;
string onf_name;
Input_Output_SEDP(unsigned int player_id, unsigned int number_of_clients)
: IO_Stream(), player_id{player_id}, s{player_id, (14000 + player_id), number_of_clients}
{
;
}
void set_file_names(string inputFile, string outputFile);
virtual long open_channel(unsigned int channel);
virtual void close_channel(unsigned int channel);
virtual gfp private_input_gfp(unsigned int channel);
virtual void private_output_gfp(const gfp &output, unsigned int channel);
virtual void public_output_gfp(const gfp &output, unsigned int channel);
virtual gfp public_input_gfp(unsigned int channel);
virtual void public_output_int(const long output, unsigned int channel);
virtual long public_input_int(unsigned int channel);
virtual void output_share(const Share &S, unsigned int channel);
virtual Share input_share(unsigned int channel);
virtual void trigger(Schedule &schedule);
virtual void debug_output(const stringstream &ss);
virtual void crash(unsigned int PC, unsigned int thread_num);
};
#endif
|
ad11808d4579740692a50456032626ebc53c901b
|
35cf83cc04635d42fcff66db499d05fd4ffb8dd1
|
/src/geosick/sampler.cpp
|
9119cc5854a094c4f7888edd726eaf235169c732
|
[] |
no_license
|
honzasp/geosick
|
41e7da15e35679d3e061f2c12737e3eed7be2b8d
|
97cd363400f1378c4a7e3bd3008d7af3e0a040b3
|
refs/heads/master
| 2021-03-29T06:16:33.648289
| 2020-04-04T19:08:27
| 2020-04-04T19:08:27
| 247,925,478
| 12
| 2
| null | 2020-03-28T16:22:46
| 2020-03-17T09:12:21
|
C++
|
UTF-8
|
C++
| false
| false
| 3,870
|
cpp
|
sampler.cpp
|
#include "geosick/sampler.hpp"
#include "geosick/geo_distance.hpp"
#include <algorithm>
#include <cassert>
namespace geosick {
// Maximum allowable time duration for interpolation between two points
static constexpr int32_t MAX_DELTA_TIME = 5*60;
// Maximum allowable distance for interpolation in meters
static constexpr double MAX_DELTA_DISTANCE_M = 100;
static constexpr double MAX_DELTA_DISTANCE_M_POW2 = MAX_DELTA_DISTANCE_M * MAX_DELTA_DISTANCE_M;
// Minimum allowable accuracy in meters.
static constexpr uint16_t MIN_ACCURACY_M = 4;
namespace {
int round_up(int num_to_round, int multiple)
{
assert(multiple != 0);
int remainder = abs(num_to_round) % multiple;
if (remainder == 0) {
return num_to_round;
}
if (num_to_round < 0) {
return -(abs(num_to_round) - remainder);
} else {
return num_to_round + multiple - remainder;
}
}
template<typename T>
T integer_mod(T x, T m) {
return ((x % m) + m) % m;
}
} // END OF ANONYMOUS NAMESPACE
Sampler::Sampler(int32_t begin_time, int32_t end_time, int32_t period)
: m_begin_time(begin_time), m_end_time(end_time), m_end_offset(end_time - begin_time),
m_period(period)
{
assert(m_begin_time <= m_end_time);
}
int32_t Sampler::time_index_to_timestamp(int32_t time_index) const {
return m_begin_time + m_period * time_index;
}
void
Sampler::sample(ArrayView<const GeoRow> rows, std::vector<GeoSample>& out_samples) const
{
assert(std::is_sorted(rows.begin(), rows.end(),
[](const auto& lhs, const auto& rhs) {
return lhs.timestamp_utc_s < rhs.timestamp_utc_s;
}
));
std::vector<GeoSample> samples;
for (size_t i = 1; i < rows.size(); ++i) {
const auto& row = rows.at(i - 1);
const auto& next_row = rows.at(i);
assert(row.user_id == next_row.user_id);
int32_t row_timestamp = row.timestamp_utc_s;
int32_t next_row_timestamp = next_row.timestamp_utc_s;
int32_t time_delta = next_row_timestamp - row_timestamp;
double distance_m_pow2 = pow2_geo_distance_fast_m(
row.lat, row.lon, next_row.lat, next_row.lon);
if (row_timestamp > m_end_time) {
break;
} else if (next_row_timestamp < m_begin_time) {
continue; // TODO: Possibly use binary search
} else if (time_delta > MAX_DELTA_TIME) {
continue;
} else if (distance_m_pow2 > MAX_DELTA_DISTANCE_M_POW2) {
continue;
}
int32_t row_offset = row_timestamp - m_begin_time;
int32_t next_row_offset = next_row_timestamp - m_begin_time;
assert(next_row_offset >= 0);
int32_t offset = round_up(row_offset, m_period);
if (offset < 0) {
offset = integer_mod(offset, m_period);
}
for (; offset < next_row_offset && offset <= m_end_offset; offset += m_period) {
out_samples.push_back(
get_weighted_sample(row, next_row, row_offset, next_row_offset, offset)
);
}
}
}
GeoSample
Sampler::get_weighted_sample(const GeoRow& row, const GeoRow& next_row,
int32_t row_offset, int32_t next_row_offset, int32_t offset) const
{
assert(offset >= 0);
assert(offset % m_period == 0);
assert(row_offset <= offset);
assert(offset <= next_row_offset);
auto spread = next_row_offset - row_offset;
double w1 = 1 - double(offset - row_offset) / spread;
double w2 = 1 - w1;
assert(0 <= w1 && w1 <= 1);
assert(0 <= w2 && w2 <= 1);
return GeoSample{
.time_index = int32_t(offset / m_period),
.user_id = row.user_id,
.lat = int32_t(w1*row.lat + w2*next_row.lat),
.lon = int32_t(w1*row.lon + w2*next_row.lon),
.accuracy_m = std::max(MIN_ACCURACY_M, uint16_t(w1*row.accuracy_m + w2*next_row.accuracy_m)),
};
}
}
|
b992547b419ba7bb3eda8111c771fac5ebcd526e
|
87e1c219cca80d51e750bd074b6d4e6da6cd0cba
|
/dm/fullham.cpp
|
a73dead89de8582d9d74e1b7316b75f925e4c7ae
|
[] |
no_license
|
olegfafurin/tasks
|
645d71bf371ce07019812b4d37368650c0c22da7
|
b9b1336d668095b9478f21bfb045305c4180a6d8
|
refs/heads/master
| 2021-08-25T09:27:52.477237
| 2021-08-04T22:57:13
| 2021-08-04T22:57:13
| 190,817,603
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,046
|
cpp
|
fullham.cpp
|
//
// Created by imd on 11/2/2018.
//
#include <fstream>
#include <vector>
#include <algorithm>
#include <iostream>
#include <deque>
using namespace std;
int main() {
ifstream fin("fullham.in");
ofstream fout("fullham.out");
int n;
char a;
vector<int> b;
fin >> n;
vector<vector<char>> connect(4000, vector<char>(4000));
deque<int> order;
for (int i = 0; i < n; i++) {
order.push_back(i);
for (int j = 0; j < i; j++) {
fin >> a;
connect[i][j] = a - '0';
connect[j][i] = a - '0';
}
}
for (int i = 0; i < (n - 1) * n; i++) {
if (!connect[order[0]][order[1]]) {
int k = 1;
while ((k < n - 1) && (!((connect[order[k]][order[0]]) && (connect[order[k + 1]][order[1]])))) k++;
reverse(order.begin() + 1, order.begin() + k + 1);
}
order.push_back(order.front());
order.pop_front();
}
for (int i = 0; i < order.size(); i++) {
fout << order[i] + 1 << ' ';
}
}
|
1971acec999357b6968b941f397c1aac2c8272de
|
1491a0e10d2a7b301b07fa0d192424e54cf83013
|
/ivoldual_query.cxx
|
9bcb0a58faa60c95e3bbd2e133a4945c29ef429c
|
[] |
no_license
|
rafewenger/ivoldual2
|
0ba82f5887a460295327753c93e1adbb9a3e0527
|
136ef8c562f6c9d4f88861092918c95910e712ed
|
refs/heads/master
| 2020-04-01T15:12:20.434157
| 2018-10-16T17:50:33
| 2018-10-16T17:50:33
| 153,326,671
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,071
|
cxx
|
ivoldual_query.cxx
|
/// \file ivoldual_query.cxx
/// Query routines for ivoldual.
/*
IJK: Isosurface Jeneration Kode
Copyright (C) 2017 Rephael Wenger
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
(LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or any later version.
This library 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 this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ivoldual_query.h"
// *****************************************************************
// QUERY IN BOX OR PSEUDOBOX
// *****************************************************************
// Return true if vertex is lower left vertex of an isosurface box.
bool IVOLDUAL::is_ivolv_lower_left_vertex_of_isosurface_box
(const IVOL_VERTEX_ADJACENCY_LIST & vertex_adjacency_list,
const DUAL_IVOLVERT_ARRAY & ivolv_list,
const IVOL_VERTEX_INDEX ivolv0,
IVOL_VERTEX_INDEX box_corner[8])
{
const int DIM3(3);
const int NUM_CUBE_VERTICES(8);
const int NUM_CUBE_FACET_VERTICES(NUM_CUBE_VERTICES/2);
const VERTEX_INDEX separation_vertex =
ivolv_list[ivolv0].SeparationVertex();
if (ivolv_list[ivolv0].NumIncidentIsoQuad() != 3) { return(false); }
box_corner[0] = ivolv0;
if (!vertex_adjacency_list.GetAdjacentVertexInOrientedDirection
(ivolv0, 0, 1, box_corner[1])) { return(false); }
if (!vertex_adjacency_list.GetAdjacentVertexInOrientedDirection
(ivolv0, 1, 1, box_corner[2])) { return(false); }
if (!vertex_adjacency_list.GetAdjacentVertexInOrientedDirection
(box_corner[1], 1, 1, box_corner[3])) { return(false); }
for (int j = 0; j < NUM_CUBE_FACET_VERTICES; j++) {
if (!vertex_adjacency_list.GetAdjacentVertexInOrientedDirection
(box_corner[j], 2, 1, box_corner[4+j])) { return(false); }
}
for (int i = 1; i < NUM_CUBE_VERTICES; i++) {
const VERTEX_INDEX ivolv = box_corner[i];
if (ivolv_list[ivolv].separation_vertex != separation_vertex)
{ return(false); }
if (ivolv_list[ivolv].NumIncidentIsoQuad() != 3)
{ return(false); }
}
return(true);
}
// Return true if upper, rightmost vertex of cube is surrounded
// by an isosurface pseudobox.
bool IVOLDUAL::is_upper_right_grid_vertex_in_isosurface_pseudobox
(const IVOL_VERTEX_ADJACENCY_LIST & vertex_adjacency_list,
const std::vector<GRID_CUBE_DATA> & cube_list,
const DUAL_IVOLVERT_ARRAY & ivolv_list,
const VERTEX_INDEX cube0_list_index,
VERTEX_INDEX cube_list_index[8])
{
typedef IVOLDUAL_TABLE_VERTEX_INFO::CUBE_VERTEX_TYPE CUBE_VERTEX_TYPE;
const int DIM3(3);
const int NUM_CUBE_VERTICES(8);
const int NUM_CUBE_FACET_VERTICES(NUM_CUBE_VERTICES/2);
const CUBE_VERTEX_TYPE UNDEFINED_CUBE_VERTEX =
IVOLDUAL_TABLE_VERTEX_INFO::UNDEFINED_CUBE_VERTEX;
static const CUBE_FACE_INFO cube(DIM3);
if (!get_seven_adjacent_cubes
(vertex_adjacency_list, cube_list, ivolv_list, cube0_list_index,
cube_list_index))
{ return(false); }
// The surrounded vertex
const VERTEX_INDEX iv0 = cube_list[cube_list_index[7]].cube_index;
// *** NEED TO ALSO CHECK THAT ALL GRID EDGES INCIDENT ON iv0
// ARE INTERSECTED BY THE APPROPRIATE ISOSURFACE. ***
for (int d = 0; d < DIM3; d++) {
// flag_connects is true if parallel quads with orth dir d
// are connected by some interval volume edge.
bool flag_connects = false;
for (int k = 0; k < NUM_CUBE_FACET_VERTICES; k++) {
CUBE_VERTEX_TYPE icorner0 = cube.FacetVertex(d, k);
CUBE_VERTEX_TYPE icorner1 = cube.VertexNeighbor(icorner0, d);
VERTEX_INDEX i0 = cube_list_index[icorner0];
VERTEX_INDEX i1 = cube_list_index[icorner1];
bool flag0 =
(is_vertex_sep_vertex(iv0, cube_list[i0], ivolv_list) ||
does_cube_contain_doubly_connected_ivol_vertex
(cube_list[i0], ivolv_list));
bool flag1 =
(is_vertex_sep_vertex(iv0, cube_list[i1], ivolv_list) ||
does_cube_contain_doubly_connected_ivol_vertex
(cube_list[i1], ivolv_list));
if (flag0 && flag1) {
flag_connects = true;
break;
}
}
if (!flag_connects) { return(false); }
}
return(true);
}
/// Return true if vertex iv equals w.sep_vert for some interval volume
/// vertex w in cube cube_ivolv.
bool IVOLDUAL::is_vertex_sep_vertex
(const VERTEX_INDEX iv,
const GRID_CUBE_DATA & cube_ivolv,
const DUAL_IVOLVERT_ARRAY & ivolv_list)
{
for (int i = 0; i < cube_ivolv.num_isov; i++) {
int k = cube_ivolv.first_isov + i;
if ((ivolv_list[k].NumIncidentIsoQuad() == 3) &&
(ivolv_list[k].separation_vertex == iv))
{ return(true); }
}
return(false);
}
// Return true if cube contains doubly connected interval volume vertex.
bool IVOLDUAL::does_cube_contain_doubly_connected_ivol_vertex
(const GRID_CUBE_DATA & cube_ivolv,
const DUAL_IVOLVERT_ARRAY & ivolv_list)
{
for (int i = 0; i < cube_ivolv.num_isov; i++) {
int k = cube_ivolv.first_isov + i;
if (ivolv_list[k].is_doubly_connected) { return(true); }
}
return(false);
}
// *****************************************************************
// GET FUNCTIONS
// *****************************************************************
// Get the index in cube_list of the seven cubes sharing the
// rightmost/upper vertex with cube0_list_index.
// - Gets the cubes only if there are interval volume edges
// between interval volume vertices in each pair of cubes.
// - Return true if all 7 cubes found.
// @param[out] cube_list_index[] Cubes cube0_list_index
// and the seven other cubes adjacent to cube0_list_index.
bool IVOLDUAL::get_seven_adjacent_cubes
(const IVOL_VERTEX_ADJACENCY_LIST & vertex_adjacency_list,
const std::vector<GRID_CUBE_DATA> & cube_list,
const DUAL_IVOLVERT_ARRAY & ivolv_list,
const int cube0_list_index,
VERTEX_INDEX cube_list_index[8])
{
const int NUM_CUBE_VERTICES(8);
const int NUM_CUBE_FACET_VERTICES(NUM_CUBE_VERTICES/2);
int list_index;
cube_list_index[0] = cube0_list_index;
if (!get_adjacent_cube_in_oriented_direction
(vertex_adjacency_list, cube_list, ivolv_list,
cube0_list_index, 0, 1, cube_list_index[1]))
{ return(false); }
if (!get_adjacent_cube_in_oriented_direction
(vertex_adjacency_list, cube_list, ivolv_list,
cube0_list_index, 1, 1, cube_list_index[2]))
{ return(false); }
if (!get_adjacent_cube_in_oriented_direction
(vertex_adjacency_list, cube_list, ivolv_list,
cube_list_index[1], 1, 1, cube_list_index[3]))
{ return(false); }
for (int j = 0; j < NUM_CUBE_FACET_VERTICES; j++) {
if (!get_adjacent_cube_in_oriented_direction
(vertex_adjacency_list, cube_list, ivolv_list,
cube_list_index[j], 2, 1, cube_list_index[4+j]))
{ return(false); }
}
return(true);
}
/// Get the index in cube_list of the adjacent cube in the oriented direction
/// if it shares an interval volume edge with cube0_list_index.
bool IVOLDUAL::get_adjacent_cube_in_oriented_direction
(const IVOL_VERTEX_ADJACENCY_LIST & vertex_adjacency_list,
const std::vector<GRID_CUBE_DATA> & cube_list,
const DUAL_IVOLVERT_ARRAY & ivolv_list,
const int cubeA_list_index,
const int direction,
const int orientation,
int & cubeB_list_index)
{
ISO_VERTEX_INDEX ivolvB;
for (int i = 0; i < cube_list[cubeA_list_index].num_isov; i++) {
const ISO_VERTEX_INDEX ivolvA =
cube_list[cubeA_list_index].first_isov + i;
if (vertex_adjacency_list.GetAdjacentVertexInOrientedDirection
(ivolvA, direction, orientation, ivolvB)) {
cubeB_list_index = ivolv_list[ivolvB].cube_list_index;
return(true);
}
}
return(false);
}
|
c0c611d0f514343c915162b633e0128c57d85c22
|
7e0ec0e32282307dd5bf051602cc6c2ea268452c
|
/src/rads/chomp/include/capd/auxil/stringOstream.h
|
d3ae5c7aa6727111fa20e02645a22ff85311d7f0
|
[] |
no_license
|
caosuomo/rads
|
03a31936715da2a9131a73ae80304680c5c3db7e
|
71cab0d6f0711cfab67e8277e1e025b0fc2d8346
|
refs/heads/master
| 2021-01-20T10:18:58.222894
| 2018-05-24T02:18:58
| 2018-05-24T02:18:58
| 1,039,029
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 718
|
h
|
stringOstream.h
|
/// @addtogroup auxil
/// @{
/////////////////////////////////////////////////////////////////////////////
/// @file stringOstream.h
///
/// @author Marian Mrozek
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2000-2006 by the CAPD Group.
//
// This file constitutes a part of the CAPD library,
// distributed under the terms of the GNU General Public License.
// Consult http://capd.wsb-nlu.edu.pl/ for details.
#include <sstream>
#if !defined(_STRINGOSTREAM_H_)
#define _STRINGOSTREAM_H_
template<typename T>
std::string& operator<<(std::string& s,const T& t){
std::ostringstream is;
is << t;
s+=is.str();
return s;
}
#endif //_STRINGOSTREAM_H_
/// @}
|
39a522bbfd13ded33ac86cbadba916b54f435778
|
835a27ad699d0aa27eec37c83e8c8628b4d26ac0
|
/meida/src/main/cpp/mediarecord-jni/jni/ijkmedia/ycmedia/x264/x264Encoder.h
|
ab5ed6f2945c8c4d4462b644fade24f498695f14
|
[] |
no_license
|
dengV/RealX
|
463bd0df13ce67f8ec2957a13a3e829e59b1d87d
|
6951923989b70df59c4cd35cc6fa592601de1ca2
|
refs/heads/master
| 2020-04-08T06:15:14.500929
| 2018-11-22T09:33:34
| 2018-11-22T09:33:34
| 159,090,711
| 2
| 0
| null | 2018-11-26T01:01:49
| 2018-11-26T01:01:49
| null |
UTF-8
|
C++
| false
| false
| 1,940
|
h
|
x264Encoder.h
|
//
// Created by Administrator on 2016/9/13.
//
#ifndef TRUNK_X264ENCODER_H
#define TRUNK_X264ENCODER_H
#include "IVideoCodec.h"
#include "Mediabase.h"
#include "Macros.h"
#include <list>
NAMESPACE_YYMFW_BEGIN
class AdaptivePicBuffer;
NAMESPACE_YYMFW_END
struct X264Encoder;
class CX264Encoder : public IVideoCodec
{
public:
CX264Encoder();
virtual ~CX264Encoder();
int Init(void* pParam, std::string configStr);
int Process(const unsigned char *pData, unsigned int nDataLen, void* pInDes, void** pOutDes);
int flush(void** pOutDes);
int CodecMode();
int CodecID();
int CodecLevel();
void DeInit();
const char* CodecDescribe();
void SetTargetBitrate(int bitrateInKbps);
private:
const uint8_t * find_startcode_internal(const uint8_t *p, const uint8_t *end);
const uint8_t* find_startcode(const uint8_t *p, const uint8_t *end);
void packEncodedList(const uint8_t* p, uint32_t size,unsigned int pts, unsigned int dts, MediaLibrary::VideoFrameType frameType);
void pushVideoEncodedData(MediaLibrary::VideoEncodedData* data);
int convert_to_x264_frame_type(MediaLibrary::VideoFrameType frameType);
MediaLibrary::VideoFrameType convert_to_yy_frame_type(int x264FrameType);
int fetchFrame(void** pOutDes, int nNal, void *pic_out, NAMESPACE_YYMFW::AdaptivePicBuffer *picBuffer);
void clearPicBufferList();
private:
X264Encoder * m_pX264Encoder;
int m_nPicW;
int m_nPicH;
int m_nFps;
int m_nBitrate;
int m_nProfile;
int m_nPicFormat;
unsigned char* m_pSps;
int m_nSpsLen;
unsigned char* m_pPps;
int m_nPpsLen;
bool m_isFirstFrame;
float m_rateFactor;
bool mRepeateHeader;
std::list<NAMESPACE_YYMFW::AdaptivePicBuffer *> m_PicDataBufferList;
MediaLibrary::VideoEncodedList* m_outputList ;
NAMESPACE_YYMFW::AdaptivePicBuffer *m_PicDataBuffer;
NAMESPACE_YYMFW::AdaptivePicBuffer *m_ppsBuffer;
NAMESPACE_YYMFW::AdaptivePicBuffer * m_spsBuffer;
};
#endif //TRUNK_X264ENCODER_H
|
a4c71e52997d7cb70024a18acca9a3978b41cfdc
|
e429ad2481bb272c9f6173474423522f5598aa94
|
/include/sg14/auxiliary/safe_integer.h
|
3a741fb37e0e98ecee2326bbff3dc53a820998d3
|
[] |
no_license
|
lewisgit/caffe-fixedpoint
|
1b4681cd4bbe442234e0b4004f64162154aa146d
|
0cfb006a18f31f7d44d6ae7bdffaa4483f85acbe
|
refs/heads/master
| 2021-01-12T09:05:08.860277
| 2018-08-16T02:01:19
| 2018-08-16T02:01:19
| 76,762,918
| 6
| 4
| null | 2018-08-16T02:01:20
| 2016-12-18T04:39:39
|
C++
|
UTF-8
|
C++
| false
| false
| 1,729
|
h
|
safe_integer.h
|
// Copyright John McFarlane 2015 - 2016.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../../LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file
/// \brief definitions and specializations that adapt boost::numeric::safe<> for use with \ref sg14::fixed_point
#if !defined(SG14_SAFE_INTEGER_H)
#define SG14_SAFE_INTEGER_H 1
#if ! defined(SG14_SAFE_NUMERICS_ENABLED)
#error This header should not be included unless SG14_SAFE_NUMERICS_ENABLED is defined
#endif
#if ! defined(SG14_EXCEPTIONS_ENABLED)
#error Exceptions and RTTI are required to use safe_numerics
#endif
#if ! defined(SG14_BOOST_ENABLED)
#error Boost is required to use safe_numerics
#endif
#include <sg14/type_traits>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <safe_integer.hpp>
#pragma GCC diagnostic pop
namespace sg14 {
template<class Rep>
using _bns = boost::numeric::safe<Rep>;
// sg14::make_signed<boost::numerics::safe<>>
template<typename Rep>
struct make_signed<_bns<Rep>> {
using type = _bns<typename make_signed<Rep>::type>;
};
// sg14::make_unsigned<boost::numerics::safe<>>
template<typename Rep>
struct make_unsigned<_bns<Rep>> {
using type = _bns<typename make_unsigned<Rep>::type>;
};
// sg14::set_width<boost::numerics::safe<>>
template<typename Rep, _width_type MinNumBits>
struct set_width<_bns<Rep>, MinNumBits> {
using type = _bns<set_width_t<Rep, MinNumBits>>;
};
// sg14::width<boost::numerics::safe<>>
template<typename Rep>
struct width<_bns<Rep>> : width<Rep> {
};
}
#endif // SG14_SAFE_INTEGER_H
|
dab092d3e1726df9a26b0c4fa03ca7ca75659921
|
62642bdd1f5d3ba90064591254afe3f807986349
|
/chatClient/controller.cpp
|
d0ec7a11678bf81eaf57e21098a5fdbc3fcd07b0
|
[] |
no_license
|
marcustedesco/ServerClientIM
|
cdd4441b91f65077f31824eab713e286fbb4da54
|
6c6e74267476bea9a864f6f8b532352f4af91aad
|
refs/heads/master
| 2016-09-03T06:33:53.504381
| 2012-12-11T09:17:56
| 2012-12-11T09:17:56
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,205
|
cpp
|
controller.cpp
|
//Marcus Tedesco and Amre Kebaish
//HW7 Group Project
//ECE 3574
//Due: Dec. 9, 2012
//controller.cpp
#include "controller.h"
controller::controller(QObject *parent) :
QObject(parent)
{
wid1 = new clientWid1();
wid2 = new clientWid2();
myClient = new client();
}
void controller::init()
{
//if connect is pushed check if the client was able to connect to the server
connect(wid1,SIGNAL(buttonPushed()),this,SLOT(attemptConnect()));
//if the client connected to the server successfully then close window 1 and open 2
connect(this,SIGNAL(clientMade()),wid2,SLOT(show()));
connect(this,SIGNAL(clientMade()),wid1,SLOT(close()));
connect(wid2,SIGNAL(connectPushed(QString)),this,SLOT(connectToClient(QString)));
//connect(wid2,SIGNAL(disconnectPushed()),this,SLOT(disconnectFromServer()));
//connect(wid2,SIGNAL(disconnectPushed()),wid2,SLOT(close()));
wid1->show();
}
void controller::attemptConnect()
{
QString myIP = wid1->getIP();
QString myPort = wid1->getPort();
QString myName = wid1->getName();
myClient = new client();
bool success = myClient->initialize(myIP, myPort, myName);
if(success){
qDebug() << "Successfully connected to the server";
emit clientMade();
wid2->setWindowTitle("Friend list for " + wid1->getName());
connect(myClient, SIGNAL(updateUsers(QStringList)), wid2, SLOT(updateFriends(QStringList)));
}
else
{
qDebug() << "another user exists with same name";
QMessageBox msgBox;
msgBox.setWindowTitle("Error: Could not connect");
msgBox.setText("Another user already exists with the same name. Choose another name.");
msgBox.exec();
}
//ACTUALLY DO THIS IN CLIENT WITH #include <QMessageBox>
//if not successful client should display error dialog box?
//or the error dialog should be made in here if the initialize
//returns an error string
}
void controller::connectToClient(QString name)
{
//tell client to tell server it wants to connect to client NAME
myClient->connectTo(name);
}
void controller::disconnectFromServer()
{
//myClient->disconnectNow();
}
|
feeddd1c4e865908696f0cc80c379a040375e842
|
6782c237ec6ca60ca265a9d09a6b2935f3a96b0e
|
/StarState.TransitionStep.cpp
|
ad066fe9fe7046f16fc6b676da6500d233257954
|
[] |
no_license
|
olafollgaard/Starscape
|
a9ca0b029954b638d0fb575e493fade50dc5f2f4
|
ea7a41424b3c03b35070e5030e854d2943c6d6b0
|
refs/heads/master
| 2021-08-22T17:17:50.931112
| 2017-11-30T19:12:17
| 2017-11-30T19:12:17
| 112,652,225
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,202
|
cpp
|
StarState.TransitionStep.cpp
|
#include "Arduino.h"
#include "StarState.h"
#define MIN_MS_BETWEEN_STEPS 10
bool StarState::TransitionStep(color_t& current)
{
float nowPct = CalcElapsedPct();
hbr_t &origin = _transition.origin;
hbr_t &target = _transition.target;
hbr_t next;
next.bri = InterpolateByte(nowPct, origin.bri, target.bri);
next.hue = _transition.flags.hueDirectSpan
? InterpolateByte(nowPct, origin.hue, target.hue)
: InterpolateByte(nowPct, 0, target.hue - origin.hue) + origin.hue;
color_t nextColor;
nextColor.SetColor(next);
bool updated = false;
for (uint8_t ch = 0; ch < CHANNELS_PER_PIXEL; ch++) {
updated = updated || nextColor.channel[ch] != current.channel[ch];
current.channel[ch] = nextColor.channel[ch];
}
return updated;
}
float StarState::CalcElapsedPct()
{
uint8_t now16ms = (uint16_t)millis() >> 4;
uint8_t duration16ms = _transition.flags.duration32ms << 1;
uint8_t elapsed16ms = now16ms - _start16ms;
float elapsedPct = elapsed16ms * 1.0 / duration16ms;
return elapsedPct < 0 ? 0 : elapsedPct > 1 ? 1 : elapsedPct;
}
uint8_t StarState::InterpolateByte(float pct, int16_t a, int16_t b)
{
int16_t res = pct * (b - a) + a;
return res < 0 ? 0 : res > 0xFF ? 0xFF : res;
}
|
4999c9d6c280beef3329589fa2d1bbc48fbfcd23
|
d1959a86215dafeabc5ca287464e3436bbb71938
|
/demo-a_declarations.ino
|
573aa67ddaa9c3edd4186456e22d8ea600ff66be
|
[] |
no_license
|
Faber-smythe/esp32-triple-sensor
|
513628f37a8e004a7bac5612fb96ac3d27a0a538
|
94c64af71e3c768936ca837f0223ddeb1bbcaf98
|
refs/heads/main
| 2023-05-29T09:09:42.623021
| 2021-06-11T12:24:39
| 2021-06-11T12:24:39
| 356,995,570
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,068
|
ino
|
demo-a_declarations.ino
|
/* Temperature sensor DS18B20 uses 'OneWire' instead of I2C */
#include <OneWire.h>
#include <DallasTemperature.h>
/* Light sensor BH1750 uses I2C (so 'Wire' lib) */
#include <Wire.h>
#include <ErriezBH1750.h>
/* These lib are needed to send http request to the API */
#include <WiFi.h>
#include <HTTPClient.h>
/*
*
* DEFINING THE NETWORK SETTINGS BELOW /!\
*
*/
const char* ssid = "MyWifi";
const char* password = "MyPassword";
/*
* DEFINING ENDPOINTS HERE /!\
*/
const String API_url = "MyEndpointURL";
/*
* Defining the sensor pins (DO NOT EDIT THESE IF YOU'RE USING THE DVIC CLIMATE SENSOR CIRCUIT)
* Since I2C uses default SCL and SDA pins, lightSensor does not need to specify pins.
*/
const int humiditySensorPin = 39;
const int temperatureSensorPin = 32;
/* Instantiate OneWire and the DallasTemperature sensor */
const int oneWireBus = temperatureSensorPin;
OneWire oneWire(oneWireBus);
DallasTemperature tempSensor(&oneWire);
/* Instantiate the BH1750 luminosity sensor */
BH1750 lightSensor(LOW);
|
500e1561a117b098e8523cd063ed13361d03576a
|
2a3e204a9fd9c25c91dbe9dcb1e7e4804d493c95
|
/src/server/scripts/OutdoorPvP/Ashran/AshranNPCHorde.cpp
|
902ef3c6fe1fdd45d0fb0370acb97cde7ee8f9df
|
[] |
no_license
|
TheGhostGroup/DynastyCore
|
e724ecb09ecd1ac11531b9be4e8e5de39bd4e074
|
d2596357e6fad5778b4688b8d84bd3bd073a873c
|
refs/heads/master
| 2020-07-26T05:36:59.831552
| 2019-11-06T00:26:00
| 2019-11-06T00:26:00
| 208,549,658
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 127,622
|
cpp
|
AshranNPCHorde.cpp
|
////////////////////////////////////////////////////////////////////////////////
//
// MILLENIUM-STUDIO
// Copyright 2016 Millenium-studio SARL
// All Rights Reserved.
//
////////////////////////////////////////////////////////////////////////////////
#include "AshranMgr.hpp"
/// Jeron Emberfall <Warspear Tower Guardian> - 88178
class npc_jeron_emberfall : public CreatureScript
{
public:
npc_jeron_emberfall() : CreatureScript("npc_jeron_emberfall") { }
struct npc_jeron_emberfallAI : public ScriptedAI
{
npc_jeron_emberfallAI(Creature* p_Creature) : ScriptedAI(p_Creature)
{
m_CheckAroundingPlayersTimer = 0;
m_PhoenixStrikeTimer = 0;
}
enum eSpells
{
Fireball = 176652,
Ignite = 176600,
CombustionNova = 176605,
CombustionNovaStun = 176608,
LivingBomb = 176670,
SummonLavaFury = 176664,
TargetedByTheTowerMage = 176076,
PhoenixStrikeSearcher = 176086,
PhoenixStrikeMissile = 176066,
ConjureRefreshment = 176351
};
enum eTalk
{
TalkAggro,
TalkSlay,
TalkDeath,
TalkSpell,
TalkLivingBomb
};
enum eEvents
{
EventFireball = 1,
EventIgnite,
EventLivingBomb,
EventCombustionNova
};
EventMap m_Events;
uint32 m_CheckAroundingPlayersTimer;
uint32 m_PhoenixStrikeTimer;
void Reset() override
{
m_Events.Reset();
me->RemoveFlag(EUnitFields::UNIT_FIELD_FLAGS, eUnitFlags::UNIT_FLAG_DISARMED);
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
Talk(eTalk::TalkAggro);
m_Events.ScheduleEvent(eEvents::EventFireball, 4000);
m_Events.ScheduleEvent(eEvents::EventIgnite, 8000);
m_Events.ScheduleEvent(eEvents::EventLivingBomb, 12000);
m_Events.ScheduleEvent(eEvents::EventCombustionNova, 15000);
}
void KilledUnit(Unit* p_Who) override
{
if (p_Who->IsPlayer())
Talk(eTalk::TalkSlay);
}
void JustDied(Unit* /*p_Killer*/) override
{
Talk(eTalk::TalkDeath);
}
void SpellHitTarget(Unit* p_Victim, SpellInfo const* p_SpellInfo) override
{
if (p_Victim == nullptr)
return;
switch (p_SpellInfo->Id)
{
case eSpells::PhoenixStrikeSearcher:
me->CastSpell(p_Victim, eSpells::PhoenixStrikeMissile, false);
break;
case eSpells::CombustionNova:
if (p_Victim->HasAura(eSpells::Ignite))
me->CastSpell(p_Victim, eSpells::CombustionNovaStun, true);
break;
default:
break;
}
}
void UpdateAI(uint32 const p_Diff) override
{
if (!UpdateVictim())
{
ScheduleTargetingPlayers(p_Diff);
SchedulePhoenixStrike(p_Diff);
return;
}
m_Events.Update(p_Diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventFireball:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_RANDOM))
me->CastSpell(l_Target, eSpells::Fireball, false);
m_Events.ScheduleEvent(eEvents::EventFireball, 10000);
break;
case eEvents::EventIgnite:
Talk(eTalk::TalkSpell);
me->CastSpell(me, eSpells::Ignite, true);
m_Events.ScheduleEvent(eEvents::EventIgnite, 9000);
break;
case eEvents::EventLivingBomb:
Talk(eTalk::TalkLivingBomb);
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_RANDOM))
me->CastSpell(l_Target, eSpells::LivingBomb, false);
m_Events.ScheduleEvent(eEvents::EventLivingBomb, 15000);
break;
case eEvents::EventCombustionNova:
Talk(eTalk::TalkSpell);
me->CastSpell(me, eSpells::CombustionNova, false);
m_Events.ScheduleEvent(eEvents::EventCombustionNova, 20000);
break;
default:
break;
}
EnterEvadeIfOutOfCombatArea(p_Diff);
DoMeleeAttackIfReady();
}
void ScheduleTargetingPlayers(uint32 const p_Diff)
{
if (!m_CheckAroundingPlayersTimer)
return;
if (m_CheckAroundingPlayersTimer <= p_Diff)
{
m_CheckAroundingPlayersTimer = 2500;
std::list<Player*> l_PlayerList;
me->GetPlayerListInGrid(l_PlayerList, 200.0f);
l_PlayerList.remove_if([this](Player* p_Player) -> bool
{
if (p_Player == nullptr)
return true;
if (!me->IsValidAttackTarget(p_Player))
return true;
if (p_Player->HasAura(eSpells::TargetedByTheTowerMage))
return true;
return false;
});
for (Player* l_Player : l_PlayerList)
l_Player->CastSpell(l_Player, eSpells::TargetedByTheTowerMage, true, nullptr, nullptr, me->GetGUID());
}
else
m_CheckAroundingPlayersTimer -= p_Diff;
}
void SchedulePhoenixStrike(uint32 const p_Diff)
{
if (!m_PhoenixStrikeTimer)
return;
if (m_PhoenixStrikeTimer <= p_Diff)
{
if (!me->isInCombat())
me->CastSpell(me, eSpells::PhoenixStrikeSearcher, true);
m_PhoenixStrikeTimer = 10000;
}
else
m_PhoenixStrikeTimer -= p_Diff;
}
void sGossipSelect(Player* p_Player, uint32 /*p_Sender*/, uint32 /*p_Action*/) override
{
p_Player->PlayerTalkClass->SendCloseGossip();
me->CastSpell(p_Player, eSpells::ConjureRefreshment, false);
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_jeron_emberfallAI(p_Creature);
}
};
/// Warspear Shaman - 82438
class npc_ashran_warspear_shaman : public CreatureScript
{
public:
npc_ashran_warspear_shaman() : CreatureScript("npc_ashran_warspear_shaman") { }
struct npc_ashran_warspear_shamanAI : public ScriptedAI
{
npc_ashran_warspear_shamanAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
enum eDatas
{
EventCosmetic = 1,
EarthFury = 82200,
NatureChanneling = 164850
};
EventMap m_Events;
void Reset() override
{
m_Events.ScheduleEvent(eDatas::EventCosmetic, 5000);
}
void UpdateAI(uint32 const p_Diff) override
{
m_Events.Update(p_Diff);
if (m_Events.ExecuteEvent() == eDatas::EventCosmetic)
{
if (Creature* l_EarthFury = me->FindNearestCreature(eDatas::EarthFury, 15.0f))
me->CastSpell(l_EarthFury, eDatas::NatureChanneling, false);
}
if (!UpdateVictim())
return;
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_warspear_shamanAI(p_Creature);
}
};
/// Illandria Belore - 88675
class npc_ashran_illandria_belore : public CreatureScript
{
public:
npc_ashran_illandria_belore() : CreatureScript("npc_ashran_illandria_belore") { }
enum eTalks
{
First,
Second,
Third,
Fourth,
Fifth
};
enum eData
{
RahmFlameheart = 88676,
ActionInit = 0,
ActionLoop = 1,
EventLoop = 1
};
struct npc_ashran_illandria_beloreAI : public MS::AI::CosmeticAI
{
npc_ashran_illandria_beloreAI(Creature* p_Creature) : MS::AI::CosmeticAI(p_Creature) { }
bool m_Init;
EventMap m_Events;
void Reset() override
{
m_Init = false;
if (Creature* l_Creature = me->FindNearestCreature(eData::RahmFlameheart, 15.0f))
{
if (l_Creature->AI())
{
m_Init = true;
l_Creature->AI()->DoAction(eData::ActionInit);
ScheduleAllTalks();
}
}
}
void DoAction(int32 const p_Action) override
{
switch (p_Action)
{
case eData::ActionInit:
if (m_Init)
break;
m_Init = true;
ScheduleAllTalks();
break;
default:
break;
}
}
void ScheduleAllTalks()
{
AddTimedDelayedOperation(1 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::First); });
AddTimedDelayedOperation(18 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Second); });
AddTimedDelayedOperation(36 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Third); });
AddTimedDelayedOperation(66 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Fourth); });
AddTimedDelayedOperation(83 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Fifth); });
}
void LastOperationCalled() override
{
m_Events.ScheduleEvent(eData::EventLoop, 48 * TimeConstants::IN_MILLISECONDS);
}
void UpdateAI(const uint32 p_Diff) override
{
MS::AI::CosmeticAI::UpdateAI(p_Diff);
m_Events.Update(p_Diff);
if (m_Events.ExecuteEvent() == eData::EventLoop)
{
if (Creature* l_Creature = me->FindNearestCreature(eData::RahmFlameheart, 15.0f))
{
if (l_Creature->AI())
{
l_Creature->AI()->DoAction(eData::ActionLoop);
ScheduleAllTalks();
}
}
}
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_illandria_beloreAI(p_Creature);
}
};
/// Examiner Rahm Flameheart <The Reliquary> - 88676
class npc_ashran_examiner_rahm_flameheart : public CreatureScript
{
public:
npc_ashran_examiner_rahm_flameheart() : CreatureScript("npc_ashran_examiner_rahm_flameheart") { }
enum eTalks
{
First,
Second,
Third,
Fourth
};
enum eData
{
IllandriaBelore = 88675,
ActionInit = 0,
ActionLoop = 1
};
struct npc_ashran_examiner_rahm_flameheartAI : public MS::AI::CosmeticAI
{
npc_ashran_examiner_rahm_flameheartAI(Creature* p_Creature) : MS::AI::CosmeticAI(p_Creature) { }
bool m_Init;
void Reset() override
{
m_Init = false;
if (Creature* l_Creature = me->FindNearestCreature(eData::IllandriaBelore, 15.0f))
{
if (l_Creature->AI())
{
m_Init = true;
l_Creature->AI()->DoAction(eData::ActionInit);
ScheduleAllTalks();
}
}
}
void DoAction(int32 const p_Action) override
{
switch (p_Action)
{
case eData::ActionInit:
m_Init = true;
ScheduleAllTalks();
break;
case eData::ActionLoop:
ScheduleAllTalks();
break;
default:
break;
}
}
void ScheduleAllTalks()
{
AddTimedDelayedOperation(10 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::First); });
AddTimedDelayedOperation(27 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Second); });
AddTimedDelayedOperation(75 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Third); });
AddTimedDelayedOperation(92 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Fourth); });
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_examiner_rahm_flameheartAI(p_Creature);
}
};
/// Centurion Firescream <Warspear Tactician> - 88771
class npc_ashran_centurion_firescream : public CreatureScript
{
public:
npc_ashran_centurion_firescream() : CreatureScript("npc_ashran_centurion_firescream") { }
struct npc_ashran_centurion_firescreamAI : public MS::AI::CosmeticAI
{
npc_ashran_centurion_firescreamAI(Creature* p_Creature) : MS::AI::CosmeticAI(p_Creature) { }
void Reset() override
{
AddTimedDelayedOperation(20 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(0); });
}
void LastOperationCalled() override
{
Reset();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_centurion_firescreamAI(p_Creature);
}
};
/// Legionnaire Hellaxe <Warspear Strategist> - 88772
class npc_ashran_legionnaire_hellaxe : public CreatureScript
{
public:
npc_ashran_legionnaire_hellaxe() : CreatureScript("npc_ashran_legionnaire_hellaxe") { }
struct npc_ashran_legionnaire_hellaxeAI : public MS::AI::CosmeticAI
{
npc_ashran_legionnaire_hellaxeAI(Creature* p_Creature) : MS::AI::CosmeticAI(p_Creature) { }
void Reset() override
{
AddTimedDelayedOperation(30 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(0); });
}
void LastOperationCalled() override
{
Reset();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_legionnaire_hellaxeAI(p_Creature);
}
};
/// Kalgan <Warspear Warrior Leader> - 83830
class npc_ashran_kalgan : public CreatureScript
{
public:
npc_ashran_kalgan() : CreatureScript("npc_ashran_kalgan") { }
enum eGossip
{
RidersSummoned = 84923
};
bool OnGossipHello(Player* p_Player, Creature* p_Creature) override
{
ZoneScript* l_ZoneScript = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(p_Creature->GetZoneId());
if (l_ZoneScript == nullptr)
return false;
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)l_ZoneScript)
{
if (l_Ashran->IsArtifactEventLaunched(TeamId::TEAM_HORDE, eArtifactsDatas::CountForWarriorPaladin))
{
p_Player->PlayerTalkClass->ClearMenus();
p_Player->SEND_GOSSIP_MENU(eGossip::RidersSummoned, p_Creature->GetGUID());
return true;
}
}
return false;
}
struct npc_ashran_kalganAI : public ScriptedAI
{
npc_ashran_kalganAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
void sGossipSelect(Player* p_Player, uint32 /*p_Sender*/, uint32 p_Action) override
{
/// "Take all of my Artifact Fragments" is always 0
if (p_Action)
return;
ZoneScript* l_ZoneScript = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(me->GetZoneId());
if (l_ZoneScript == nullptr)
return;
uint32 l_ArtifactCount = p_Player->GetCurrency(CurrencyTypes::CURRENCY_TYPE_ARTIFACT_FRAGEMENT, true);
p_Player->ModifyCurrency(CurrencyTypes::CURRENCY_TYPE_ARTIFACT_FRAGEMENT, -int32(l_ArtifactCount * CURRENCY_PRECISION), false);
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)l_ZoneScript)
{
l_Ashran->AddCollectedArtifacts(TeamId::TEAM_HORDE, eArtifactsDatas::CountForWarriorPaladin, l_ArtifactCount);
l_Ashran->RewardHonorAndReputation(l_ArtifactCount, p_Player);
}
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_kalganAI(p_Creature);
}
};
/// Fura <Warspear Mage Leader> - 83995
class npc_ashran_fura : public CreatureScript
{
public:
npc_ashran_fura() : CreatureScript("npc_ashran_fura") { }
enum eGossip
{
PortalInvoked = 84919
};
bool OnGossipHello(Player* p_Player, Creature* p_Creature) override
{
ZoneScript* l_ZoneScript = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(p_Creature->GetZoneId());
if (l_ZoneScript == nullptr)
return false;
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)l_ZoneScript)
{
if (l_Ashran->IsArtifactEventLaunched(TeamId::TEAM_HORDE, eArtifactsDatas::CountForMage))
{
p_Player->PlayerTalkClass->ClearMenus();
p_Player->SEND_GOSSIP_MENU(eGossip::PortalInvoked, p_Creature->GetGUID());
return true;
}
}
return false;
}
struct npc_ashran_furaAI : public ScriptedAI
{
npc_ashran_furaAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
void sGossipSelect(Player* p_Player, uint32 /*p_Sender*/, uint32 p_Action) override
{
/// "Take all of my Artifact Fragments" is always 0
if (p_Action)
return;
ZoneScript* l_ZoneScript = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(me->GetZoneId());
if (l_ZoneScript == nullptr)
return;
uint32 l_ArtifactCount = p_Player->GetCurrency(CurrencyTypes::CURRENCY_TYPE_ARTIFACT_FRAGEMENT, true);
p_Player->ModifyCurrency(CurrencyTypes::CURRENCY_TYPE_ARTIFACT_FRAGEMENT, -int32(l_ArtifactCount * CURRENCY_PRECISION), false);
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)l_ZoneScript)
{
l_Ashran->AddCollectedArtifacts(TeamId::TEAM_HORDE, eArtifactsDatas::CountForMage, l_ArtifactCount);
l_Ashran->RewardHonorAndReputation(l_ArtifactCount, p_Player);
}
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_furaAI(p_Creature);
}
};
/// Nisstyr <Warspear Warlock Leader> - 83997
class npc_ashran_nisstyr : public CreatureScript
{
public:
npc_ashran_nisstyr() : CreatureScript("npc_ashran_nisstyr") { }
enum eGossip
{
GatewaysInvoked = 85463
};
bool OnGossipHello(Player* p_Player, Creature* p_Creature) override
{
ZoneScript* l_ZoneScript = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(p_Creature->GetZoneId());
if (l_ZoneScript == nullptr)
return false;
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)l_ZoneScript)
{
if (l_Ashran->IsArtifactEventLaunched(TeamId::TEAM_HORDE, eArtifactsDatas::CountForWarlock))
{
p_Player->PlayerTalkClass->ClearMenus();
p_Player->SEND_GOSSIP_MENU(eGossip::GatewaysInvoked, p_Creature->GetGUID());
return true;
}
}
return false;
}
struct npc_ashran_nisstyrAI : public ScriptedAI
{
npc_ashran_nisstyrAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
void sGossipSelect(Player* p_Player, uint32 /*p_Sender*/, uint32 p_Action) override
{
/// "Take all of my Artifact Fragments" is always 0
if (p_Action)
return;
ZoneScript* l_ZoneScript = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(me->GetZoneId());
if (l_ZoneScript == nullptr)
return;
uint32 l_ArtifactCount = p_Player->GetCurrency(CurrencyTypes::CURRENCY_TYPE_ARTIFACT_FRAGEMENT, true);
p_Player->ModifyCurrency(CurrencyTypes::CURRENCY_TYPE_ARTIFACT_FRAGEMENT, -int32(l_ArtifactCount * CURRENCY_PRECISION), false);
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)l_ZoneScript)
{
l_Ashran->AddCollectedArtifacts(TeamId::TEAM_HORDE, eArtifactsDatas::CountForWarlock, l_ArtifactCount);
l_Ashran->RewardHonorAndReputation(l_ArtifactCount, p_Player);
}
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_nisstyrAI(p_Creature);
}
};
/// Atomik <Warspear Shaman Leader> - 82204
class npc_ashran_atomik : public CreatureScript
{
public:
npc_ashran_atomik() : CreatureScript("npc_ashran_atomik") { }
enum eGossip
{
KronusInvoked = 89853
};
bool OnGossipHello(Player* p_Player, Creature* p_Creature) override
{
ZoneScript* l_ZoneScript = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(p_Creature->GetZoneId());
if (l_ZoneScript == nullptr)
return false;
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)l_ZoneScript)
{
if (l_Ashran->IsArtifactEventLaunched(TeamId::TEAM_HORDE, eArtifactsDatas::CountForDruidShaman))
{
p_Player->PlayerTalkClass->ClearMenus();
p_Player->SEND_GOSSIP_MENU(eGossip::KronusInvoked, p_Creature->GetGUID());
return true;
}
}
return false;
}
struct npc_ashran_atomikAI : public ScriptedAI
{
npc_ashran_atomikAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
void sGossipSelect(Player* p_Player, uint32 /*p_Sender*/, uint32 p_Action) override
{
/// "Take all of my Artifact Fragments" is always 0
if (p_Action)
return;
ZoneScript* l_ZoneScript = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(me->GetZoneId());
if (l_ZoneScript == nullptr)
return;
uint32 l_ArtifactCount = p_Player->GetCurrency(CurrencyTypes::CURRENCY_TYPE_ARTIFACT_FRAGEMENT, true);
p_Player->ModifyCurrency(CurrencyTypes::CURRENCY_TYPE_ARTIFACT_FRAGEMENT, -int32(l_ArtifactCount * CURRENCY_PRECISION), false);
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)l_ZoneScript)
{
l_Ashran->AddCollectedArtifacts(TeamId::TEAM_HORDE, eArtifactsDatas::CountForDruidShaman, l_ArtifactCount);
l_Ashran->RewardHonorAndReputation(l_ArtifactCount, p_Player);
}
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_atomikAI(p_Creature);
}
};
/// Zaram Sunraiser <Portal Guardian> - 84468
class npc_ashran_zaram_sunraiser : public CreatureScript
{
public:
npc_ashran_zaram_sunraiser() : CreatureScript("npc_ashran_zaram_sunraiser") { }
enum eSpells
{
SpellMoltenArmor = 79849,
SpellFlamestrike = 79856,
SpellFireball = 79854,
SpellBlastWave = 79857
};
enum eEvents
{
EventFlamestrike = 1,
EventFireball,
EventBlastWave
};
struct npc_ashran_zaram_sunraiserAI : public ScriptedAI
{
npc_ashran_zaram_sunraiserAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
EventMap m_Events;
void Reset() override
{
me->CastSpell(me, eSpells::SpellMoltenArmor, true);
m_Events.Reset();
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->CastSpell(me, eSpells::SpellMoltenArmor, true);
m_Events.ScheduleEvent(eEvents::EventFlamestrike, 7000);
m_Events.ScheduleEvent(eEvents::EventFireball, 3000);
m_Events.ScheduleEvent(eEvents::EventBlastWave, 9000);
}
void JustDied(Unit* /*p_Killer*/) override
{
ZoneScript* l_ZoneScript = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(me->GetZoneId());
if (l_ZoneScript == nullptr)
return;
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)l_ZoneScript)
l_Ashran->EndArtifactEvent(TeamId::TEAM_HORDE, eArtifactsDatas::CountForMage);
}
void UpdateAI(uint32 const p_Diff) override
{
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventFlamestrike:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_RANDOM))
me->CastSpell(l_Target, eSpells::SpellFlamestrike, false);
m_Events.ScheduleEvent(eEvents::EventFlamestrike, 15000);
break;
case eEvents::EventFireball:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::SpellFireball, false);
m_Events.ScheduleEvent(eEvents::EventFireball, 10000);
break;
case eEvents::EventBlastWave:
me->CastSpell(me, eSpells::SpellBlastWave, false);
m_Events.ScheduleEvent(eEvents::EventBlastWave, 20000);
break;
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_zaram_sunraiserAI(p_Creature);
}
};
/// Gayle Plagueheart <Gateway Guardian> - 84645
/// Ilya Plagueheart <Gateway Guardian> - 84646
class npc_ashran_horde_gateway_guardian : public CreatureScript
{
public:
npc_ashran_horde_gateway_guardian() : CreatureScript("npc_ashran_horde_gateway_guardian") { }
enum eSpells
{
SpellChaosBolt = 79939,
SpellFelArmor = 165735,
SpellImmolate = 79937,
SpellIncinerate = 79938
};
enum eEvents
{
EventChaosBolt = 1,
EventImmolate,
EventIncinerate
};
struct npc_ashran_horde_gateway_guardianAI : public ScriptedAI
{
npc_ashran_horde_gateway_guardianAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
EventMap m_Events;
void Reset() override
{
me->CastSpell(me, eSpells::SpellFelArmor, true);
m_Events.Reset();
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->CastSpell(me, eSpells::SpellFelArmor, true);
m_Events.ScheduleEvent(eEvents::EventImmolate, 1000);
m_Events.ScheduleEvent(eEvents::EventIncinerate, 2000);
m_Events.ScheduleEvent(eEvents::EventChaosBolt, 5000);
}
void JustDied(Unit* /*p_Killer*/) override
{
ZoneScript* l_ZoneScript = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(me->GetZoneId());
if (l_ZoneScript == nullptr)
return;
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)l_ZoneScript)
l_Ashran->EndArtifactEvent(TeamId::TEAM_HORDE, eArtifactsDatas::CountForWarlock);
}
void UpdateAI(uint32 const p_Diff) override
{
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventChaosBolt:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::SpellChaosBolt, false);
m_Events.ScheduleEvent(eEvents::EventChaosBolt, 12000);
break;
case eEvents::EventImmolate:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::SpellImmolate, false);
m_Events.ScheduleEvent(eEvents::EventImmolate, 9000);
break;
case eEvents::EventIncinerate:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::SpellIncinerate, false);
m_Events.ScheduleEvent(eEvents::EventIncinerate, 5000);
break;
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_horde_gateway_guardianAI(p_Creature);
}
};
/// Kronus <Horde Guardian> - 82201
class npc_ashran_kronus : public CreatureScript
{
public:
npc_ashran_kronus() : CreatureScript("npc_ashran_kronus") { }
enum eSpells
{
AshranLaneMobScalingAura = 164310,
SpellFractureSearcher = 170892,
SpellFractureMissile = 170893, ///< Trigger 170894
SpellGroundPound = 170905, ///< Periodic Trigger 177605
SpellRockShield = 175058,
SpellStoneEmpowermentAura = 170896
};
enum eEvents
{
EventFracture = 1,
EventGroundPound,
EventRockShield,
EventMove
};
struct npc_ashran_kronusAI : public ScriptedAI
{
npc_ashran_kronusAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
EventMap m_Events;
EventMap m_MoveEvent;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1000);
/// Kronus no longer scales their health based the number of players he's fighting.
/// Each faction guardian's health now scales based on the number of enemy players active at the time when they're summoned.
ZoneScript* l_ZoneScript = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(me->GetZoneId());
if (l_ZoneScript == nullptr)
return;
uint32 l_PlayerCount = 0;
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)l_ZoneScript)
l_PlayerCount = l_Ashran->CountPlayersForTeam(TeamId::TEAM_ALLIANCE);
if (Aura* l_Scaling = me->AddAura(eSpells::AshranLaneMobScalingAura, me))
{
if (AuraEffect* l_Damage = l_Scaling->GetEffect(EFFECT_0))
l_Damage->ChangeAmount(eAshranDatas::HealthPCTAddedByHostileRef * l_PlayerCount);
if (AuraEffect* l_Health = l_Scaling->GetEffect(EFFECT_1))
l_Health->ChangeAmount(eAshranDatas::HealthPCTAddedByHostileRef * l_PlayerCount);
}
}
void Reset() override
{
me->DisableHealthRegen();
me->CastSpell(me, eSpells::SpellStoneEmpowermentAura, true);
me->SetReactState(ReactStates::REACT_AGGRESSIVE);
m_Events.Reset();
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
Position l_Pos;
me->GetPosition(&l_Pos);
me->SetHomePosition(l_Pos);
m_Events.ScheduleEvent(eEvents::EventFracture, 5000);
m_Events.ScheduleEvent(eEvents::EventGroundPound, 12000);
m_Events.ScheduleEvent(eEvents::EventRockShield, 9000);
}
void DamageTaken(Unit* /*p_Attacker*/, uint32& p_Damage, SpellInfo const* /*p_SpellInfo*/) override
{
if (p_Damage < me->GetHealth())
return;
ZoneScript* l_ZoneScript = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(me->GetZoneId());
if (l_ZoneScript == nullptr)
return;
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)l_ZoneScript)
{
if (l_Ashran->IsArtifactEventLaunched(TeamId::TEAM_HORDE, eArtifactsDatas::CountForDruidShaman))
{
l_Ashran->CastSpellOnTeam(me, TeamId::TEAM_ALLIANCE, eAshranSpells::SpellEventAllianceReward);
l_Ashran->EndArtifactEvent(TeamId::TEAM_HORDE, eArtifactsDatas::CountForDruidShaman);
}
}
}
void SpellHitTarget(Unit* p_Target, SpellInfo const* p_SpellInfo) override
{
if (p_Target == nullptr)
return;
if (p_SpellInfo->Id == eSpells::SpellFractureSearcher)
me->CastSpell(p_Target, eSpells::SpellFractureMissile, true);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
me->SetWalk(true);
me->LoadPath(me->GetEntry());
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventFracture:
me->CastSpell(me, eSpells::SpellFractureSearcher, true);
m_Events.ScheduleEvent(eEvents::EventFracture, 16000);
break;
case eEvents::EventGroundPound:
me->CastSpell(me, eSpells::SpellGroundPound, false);
m_Events.ScheduleEvent(eEvents::EventGroundPound, 43000);
break;
case eEvents::EventRockShield:
me->CastSpell(me, eSpells::SpellRockShield, true);
m_Events.ScheduleEvent(eEvents::EventRockShield, 39000);
break;
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_kronusAI(p_Creature);
}
};
/// Underpowered Earth Fury <Horde Guardian> - 82200
class npc_ashran_underpowered_earth_fury : public CreatureScript
{
public:
npc_ashran_underpowered_earth_fury() : CreatureScript("npc_ashran_underpowered_earth_fury") { }
struct npc_ashran_underpowered_earth_furyAI : public ScriptedAI
{
npc_ashran_underpowered_earth_furyAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
enum eData
{
WarspearShaman = 82438
};
EventMap m_Events;
void Reset() override
{
std::list<Creature*> l_WarspearShamans;
me->GetCreatureListWithEntryInGrid(l_WarspearShamans, eData::WarspearShaman, 20.0f);
for (Creature* l_Creature : l_WarspearShamans)
{
if (l_Creature->AI())
l_Creature->AI()->Reset();
}
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_underpowered_earth_furyAI(p_Creature);
}
};
/// Warspear Gladiator - 85811
class npc_ashran_warspear_gladiator : public CreatureScript
{
public:
npc_ashran_warspear_gladiator() : CreatureScript("npc_ashran_warspear_gladiator") { }
enum eSpells
{
SpellCleave = 119419,
SpellDevotionAura = 165712,
SpellMortalStrike = 19643,
SpellNet = 81210,
SpellSnapKick = 15618
};
enum eEvents
{
EventCleave = 1,
EventMortalStrike,
EventNet,
EventSnapKick
};
struct npc_ashran_warspear_gladiatorAI : public ScriptedAI
{
npc_ashran_warspear_gladiatorAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
EventMap m_Events;
void Reset() override
{
m_Events.Reset();
me->CastSpell(me, eSpells::SpellDevotionAura, true);
}
void EnterCombat(Unit* p_Attacker) override
{
me->CastSpell(me, eSpells::SpellDevotionAura, true);
me->CastSpell(p_Attacker, eSpells::SpellNet, true);
m_Events.ScheduleEvent(eEvents::EventCleave, 3000);
m_Events.ScheduleEvent(eEvents::EventMortalStrike, 5000);
m_Events.ScheduleEvent(eEvents::EventNet, 8000);
m_Events.ScheduleEvent(eEvents::EventSnapKick, 9000);
}
void UpdateAI(uint32 const p_Diff) override
{
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventCleave:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::SpellCleave, true);
m_Events.ScheduleEvent(eEvents::EventCleave, 15000);
break;
case eEvents::EventMortalStrike:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::SpellMortalStrike, true);
m_Events.ScheduleEvent(eEvents::EventMortalStrike, 10000);
break;
case eEvents::EventNet:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::SpellNet, true);
m_Events.ScheduleEvent(eEvents::EventNet, 20000);
break;
case eEvents::EventSnapKick:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::SpellSnapKick, true);
m_Events.ScheduleEvent(eEvents::EventSnapKick, 20000);
break;
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_warspear_gladiatorAI(p_Creature);
}
};
/// Excavator Rustshiv - 88568
class npc_ashran_excavator_rustshiv : public CreatureScript
{
public:
npc_ashran_excavator_rustshiv() : CreatureScript("npc_ashran_excavator_rustshiv") { }
enum eTalks
{
First,
Second,
Third,
Fourth,
Fifth,
Sixth
};
enum eData
{
ExcavatorHardtooth = 88567,
ActionInit = 0,
ActionLoop = 1,
EventLoop = 1
};
struct npc_ashran_excavator_rustshivAI : public MS::AI::CosmeticAI
{
npc_ashran_excavator_rustshivAI(Creature* p_Creature) : MS::AI::CosmeticAI(p_Creature) { }
bool m_Init;
EventMap m_Events;
void Reset() override
{
m_Init = false;
if (Creature* l_Creature = me->FindNearestCreature(eData::ExcavatorHardtooth, 15.0f))
{
if (l_Creature->AI())
{
m_Init = true;
l_Creature->AI()->DoAction(eData::ActionInit);
ScheduleAllTalks();
}
}
}
void DoAction(int32 const p_Action) override
{
switch (p_Action)
{
case eData::ActionInit:
if (m_Init)
break;
m_Init = true;
ScheduleAllTalks();
break;
default:
break;
}
}
void ScheduleAllTalks()
{
AddTimedDelayedOperation(1 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::First); });
AddTimedDelayedOperation(18 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Second); });
AddTimedDelayedOperation(36 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Third); });
AddTimedDelayedOperation(67 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Fourth); });
AddTimedDelayedOperation(84 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Fifth); });
AddTimedDelayedOperation(101 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Sixth); });
}
void LastOperationCalled() override
{
m_Events.ScheduleEvent(eData::EventLoop, 31 * TimeConstants::IN_MILLISECONDS);
}
void UpdateAI(const uint32 p_Diff) override
{
MS::AI::CosmeticAI::UpdateAI(p_Diff);
m_Events.Update(p_Diff);
if (m_Events.ExecuteEvent() == eData::EventLoop)
{
if (Creature* l_Creature = me->FindNearestCreature(eData::ExcavatorHardtooth, 15.0f))
{
if (l_Creature->AI())
{
l_Creature->AI()->DoAction(eData::ActionLoop);
ScheduleAllTalks();
}
}
}
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_excavator_rustshivAI(p_Creature);
}
};
/// Excavator Hardtooth - 88567
class npc_ashran_excavator_hardtooth : public CreatureScript
{
public:
npc_ashran_excavator_hardtooth() : CreatureScript("npc_ashran_excavator_hardtooth") { }
enum eTalks
{
First,
Second,
Third,
Fourth
};
enum eData
{
ExcavatorRustshiv = 88568,
ActionInit = 0,
ActionLoop = 1
};
struct npc_ashran_excavator_hardtoothAI : public MS::AI::CosmeticAI
{
npc_ashran_excavator_hardtoothAI(Creature* p_Creature) : MS::AI::CosmeticAI(p_Creature) { }
bool m_Init;
void Reset() override
{
m_Init = false;
if (Creature* l_Creature = me->FindNearestCreature(eData::ExcavatorRustshiv, 15.0f))
{
if (l_Creature->AI())
{
m_Init = true;
l_Creature->AI()->DoAction(eData::ActionInit);
ScheduleAllTalks();
}
}
}
void DoAction(int32 const p_Action) override
{
switch (p_Action)
{
case eData::ActionInit:
m_Init = true;
ScheduleAllTalks();
break;
case eData::ActionLoop:
ScheduleAllTalks();
break;
default:
break;
}
}
void ScheduleAllTalks()
{
AddTimedDelayedOperation(10 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::First); });
AddTimedDelayedOperation(27 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Second); });
AddTimedDelayedOperation(76 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Third); });
AddTimedDelayedOperation(93 * TimeConstants::IN_MILLISECONDS, [this]() -> void { Talk(eTalks::Fourth); });
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_excavator_hardtoothAI(p_Creature);
}
};
/// Vol'jin's Spear Battle Standard - 85383
class npc_ashran_voljins_spear_battle_standard : public CreatureScript
{
public:
npc_ashran_voljins_spear_battle_standard() : CreatureScript("npc_ashran_voljins_spear_battle_standard") { }
struct npc_ashran_voljins_spear_battle_standardAI : public ScriptedAI
{
npc_ashran_voljins_spear_battle_standardAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
void Reset() override
{
me->SetReactState(ReactStates::REACT_PASSIVE);
}
void JustDied(Unit* /*p_Killer*/) override
{
me->DespawnOrUnsummon();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_voljins_spear_battle_standardAI(p_Creature);
}
};
/// Warspear Headhunter - 88691
class npc_ashran_warspear_headhunter : public CreatureScript
{
public:
npc_ashran_warspear_headhunter() : CreatureScript("npc_ashran_warspear_headhunter") { }
enum eSpells
{
SpellShoot = 163921,
SpellKillShot = 173642,
SpellHeadhuntersMark = 177203,
SpellConcussiveShot = 17174
};
enum eEvents
{
SearchTarget = 1,
EventShoot,
EventKillShot,
EventHeadhuntersMark,
EventConcussiveShot,
EventClearEvade
};
struct npc_ashran_warspear_headhunterAI : public ScriptedAI
{
npc_ashran_warspear_headhunterAI(Creature* p_Creature) : ScriptedAI(p_Creature)
{
m_CosmeticEvent.Reset();
}
EventMap m_Events;
EventMap m_CosmeticEvent;
void Reset() override
{
m_Events.Reset();
me->SetFlag(EUnitFields::UNIT_FIELD_FLAGS, eUnitFlags::UNIT_FLAG_DISABLE_MOVE);
me->AddUnitState(UnitState::UNIT_STATE_ROOT);
m_CosmeticEvent.ScheduleEvent(eEvents::SearchTarget, 1 * TimeConstants::IN_MILLISECONDS);
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
m_Events.ScheduleEvent(eEvents::EventShoot, 1 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventKillShot, 1 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventHeadhuntersMark, 5 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventConcussiveShot, 10 * TimeConstants::IN_MILLISECONDS);
}
void EnterEvadeMode() override
{
me->ClearUnitState(UnitState::UNIT_STATE_ROOT);
CreatureAI::EnterEvadeMode();
m_CosmeticEvent.ScheduleEvent(eEvents::EventClearEvade, 500);
}
void UpdateAI(uint32 const p_Diff) override
{
m_CosmeticEvent.Update(p_Diff);
switch (m_CosmeticEvent.ExecuteEvent())
{
case eEvents::SearchTarget:
{
if (Player* l_Player = me->FindNearestPlayer(40.0f))
AttackStart(l_Player);
else
m_CosmeticEvent.ScheduleEvent(eEvents::SearchTarget, 1 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventClearEvade:
{
me->ClearUnitState(UnitState::UNIT_STATE_EVADE);
break;
}
default:
break;
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventShoot:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::SpellShoot, false);
m_Events.ScheduleEvent(eEvents::EventShoot, 5 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventKillShot:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
{
if (l_Target->HealthBelowPct(20))
{
me->CastSpell(l_Target, eSpells::SpellKillShot, false);
m_Events.ScheduleEvent(eEvents::EventKillShot, 10 * TimeConstants::IN_MILLISECONDS);
break;
}
}
m_Events.ScheduleEvent(eEvents::EventKillShot, 1 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventHeadhuntersMark:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::SpellHeadhuntersMark, false);
m_Events.ScheduleEvent(eEvents::EventHeadhuntersMark, 18 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventConcussiveShot:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::SpellConcussiveShot, false);
m_Events.ScheduleEvent(eEvents::EventConcussiveShot, 10 * TimeConstants::IN_MILLISECONDS);
break;
}
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_warspear_headhunterAI(p_Creature);
}
};
/// Lord Mes <Horde Captain> - 80497
class npc_ashran_lord_mes : public CreatureScript
{
public:
npc_ashran_lord_mes() : CreatureScript("npc_ashran_lord_mes") { }
enum eSpells
{
PlagueStrike = 164063,
DeathAndDecay = 164334,
DeathCoil = 164064,
DeathGrip = 79894,
DeathGripJump = 168563
};
enum eEvents
{
EventPlagueStrike = 1,
EventDeathAndDecay,
EventDeathCoil,
EventDeathGrip,
EventMove
};
enum eTalks
{
Spawn,
Death
};
enum eData
{
MountID = 25280
};
struct npc_ashran_lord_mesAI : public ScriptedAI
{
npc_ashran_lord_mesAI(Creature* p_Creature) : ScriptedAI(p_Creature)
{
m_Spawn = false;
}
EventMap m_Events;
EventMap m_MoveEvent;
bool m_Spawn;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1 * TimeConstants::IN_MILLISECONDS);
Reset();
}
void Reset() override
{
m_Events.Reset();
if (!m_Spawn)
{
Talk(eTalks::Spawn);
m_Spawn = true;
}
me->Mount(eData::MountID);
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->Mount(0);
me->SetHomePosition(*me);
m_Events.ScheduleEvent(eEvents::EventPlagueStrike, 2 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventDeathAndDecay, 5 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventDeathCoil, 8 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventDeathGrip, 1 * TimeConstants::IN_MILLISECONDS);
}
void JustDied(Unit* /*p_Killer*/) override
{
Talk(eTalks::Death);
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)me->GetZoneScript())
l_Ashran->HandleCaptainDeath(eSpecialSpawns::CaptainLordMes);
}
void SpellHitTarget(Unit* p_Target, SpellInfo const* p_SpellInfo) override
{
if (p_Target == nullptr)
return;
if (p_SpellInfo->Id == eSpells::DeathGrip)
p_Target->CastSpell(*me, eSpells::DeathGripJump, true);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
/// Use same path as Kronus
me->LoadPath(eCreatures::Kronus);
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventPlagueStrike:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::PlagueStrike, false);
m_Events.ScheduleEvent(eEvents::EventPlagueStrike, 8 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventDeathAndDecay:
{
me->CastSpell(me, eSpells::DeathAndDecay, false);
m_Events.ScheduleEvent(eEvents::EventDeathAndDecay, 12 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventDeathCoil:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::DeathCoil, false);
m_Events.ScheduleEvent(eEvents::EventDeathCoil, 10 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventDeathGrip:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::DeathGrip, false);
m_Events.ScheduleEvent(eEvents::EventDeathGrip, 20 * TimeConstants::IN_MILLISECONDS);
break;
}
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_lord_mesAI(p_Creature);
}
};
/// Mindbender Talbadar <Horde Captain> - 80490
class npc_ashran_mindbender_talbadar : public CreatureScript
{
public:
npc_ashran_mindbender_talbadar() : CreatureScript("npc_ashran_mindbender_talbadar") { }
enum eSpells
{
DevouringPlague = 164452,
Dispersion = 164444,
MindBlast = 164448,
MindSear = 177402,
PsychicScream = 164443,
ShadowWordPain = 164446
};
enum eEvents
{
EventDevouringPlague = 1,
EventDispersion,
EventMindBlast,
EventMindSear,
EventPsychicScream,
EventShadowWordPain,
EventMove
};
enum eTalk
{
Spawn
};
struct npc_ashran_mindbender_talbadarAI : public ScriptedAI
{
npc_ashran_mindbender_talbadarAI(Creature* p_Creature) : ScriptedAI(p_Creature)
{
m_Spawn = false;
}
EventMap m_Events;
EventMap m_MoveEvent;
bool m_Spawn;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1 * TimeConstants::IN_MILLISECONDS);
Reset();
}
void Reset() override
{
m_Events.Reset();
if (!m_Spawn)
{
Talk(eTalk::Spawn);
m_Spawn = true;
}
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->SetHomePosition(*me);
m_Events.ScheduleEvent(eEvents::EventDevouringPlague, 10 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventDispersion, 1 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventMindBlast, 5 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventMindSear, 8 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventPsychicScream, 15 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventShadowWordPain, 1 * TimeConstants::IN_MILLISECONDS);
}
void JustDied(Unit* /*p_Killer*/) override
{
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)me->GetZoneScript())
l_Ashran->HandleCaptainDeath(eSpecialSpawns::CaptainMindbenderTalbadar);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
/// Use same path as Kronus
me->LoadPath(eCreatures::Kronus);
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventDevouringPlague:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::DevouringPlague, false);
m_Events.ScheduleEvent(eEvents::EventDevouringPlague, 15 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventDispersion:
{
if (me->HealthBelowPct(50))
me->CastSpell(me, eSpells::Dispersion, true);
else
m_Events.ScheduleEvent(eEvents::EventDispersion, 1 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventMindBlast:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::MindBlast, false);
m_Events.ScheduleEvent(eEvents::EventMindBlast, 10 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventMindSear:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::MindSear, false);
m_Events.ScheduleEvent(eEvents::EventMindSear, 20 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventPsychicScream:
{
me->CastSpell(me, eSpells::PsychicScream, false);
m_Events.ScheduleEvent(eEvents::EventPsychicScream, 30 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventShadowWordPain:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::ShadowWordPain, false);
m_Events.ScheduleEvent(eEvents::EventShadowWordPain, 12 * TimeConstants::IN_MILLISECONDS);
break;
}
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_mindbender_talbadarAI(p_Creature);
}
};
/// Elliott Van Rook <Horde Captain> - 80493
class npc_ashran_elliott_van_rook : public CreatureScript
{
public:
npc_ashran_elliott_van_rook() : CreatureScript("npc_ashran_elliott_van_rook") { }
enum eSpells
{
Blizzard = 162610,
FrostNova = 164067,
Frostbolt = 162608,
IceLance = 162609
};
enum eEvents
{
EventBlizzard = 1,
EventFrostNova,
EventFrostbolt,
EventIceLance,
EventMove
};
enum eTalks
{
Slay,
Death
};
enum eData
{
MountID = 51048
};
struct npc_ashran_elliott_van_rookAI : public ScriptedAI
{
npc_ashran_elliott_van_rookAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
EventMap m_Events;
EventMap m_MoveEvent;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1 * TimeConstants::IN_MILLISECONDS);
Reset();
}
void Reset() override
{
m_Events.Reset();
me->Mount(eData::MountID);
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->Mount(0);
me->SetHomePosition(*me);
m_Events.ScheduleEvent(eEvents::EventBlizzard, 6 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventFrostNova, 5 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventFrostbolt, 1 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventIceLance, 10 * TimeConstants::IN_MILLISECONDS);
}
void KilledUnit(Unit* p_Killed) override
{
if (p_Killed->GetTypeId() == TypeID::TYPEID_PLAYER)
Talk(eTalks::Slay);
}
void JustDied(Unit* /*p_Killer*/) override
{
Talk(eTalks::Death);
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)me->GetZoneScript())
l_Ashran->HandleCaptainDeath(eSpecialSpawns::CaptainElliotVanRook);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
/// Use same path as Kronus
me->LoadPath(eCreatures::Kronus);
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventBlizzard:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::Blizzard, false);
m_Events.ScheduleEvent(eEvents::EventBlizzard, 20 * TimeConstants::IN_MILLISECONDS);
break;
case eEvents::EventFrostNova:
me->CastSpell(me, eSpells::FrostNova, false);
m_Events.ScheduleEvent(eEvents::EventFrostNova, 20 * TimeConstants::IN_MILLISECONDS);
break;
case eEvents::EventFrostbolt:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::Frostbolt, false);
m_Events.ScheduleEvent(eEvents::EventFrostbolt, 5 * TimeConstants::IN_MILLISECONDS);
break;
case eEvents::EventIceLance:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::IceLance, false);
m_Events.ScheduleEvent(eEvents::EventIceLance, 10 * TimeConstants::IN_MILLISECONDS);
break;
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_elliott_van_rookAI(p_Creature);
}
};
/// Vanguard Samuelle <Horde Captain> - 80492
class npc_ashran_vanguard_samuelle : public CreatureScript
{
public:
npc_ashran_vanguard_samuelle() : CreatureScript("npc_ashran_vanguard_samuelle") { }
enum eSpells
{
Judgment = 162760,
HammerOfWrath = 162763,
DivineShield = 164410,
DivineStorm = 162641,
HammerOfJustice = 162764,
AvengingWrath = 164397
};
enum eEvents
{
EventJudgment = 1,
EventHammerOfWrath,
EventDivineShield,
EventDivineStorm,
EventHammerOfJustice,
EventAvengingWrath,
EventMove
};
enum eTalks
{
Slay,
Death
};
struct npc_ashran_vanguard_samuelleAI : public ScriptedAI
{
npc_ashran_vanguard_samuelleAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
EventMap m_Events;
EventMap m_MoveEvent;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1 * TimeConstants::IN_MILLISECONDS);
Reset();
}
void Reset() override
{
m_Events.Reset();
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->SetHomePosition(*me);
m_Events.ScheduleEvent(eEvents::EventJudgment, 1 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventHammerOfWrath, 5 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventDivineShield, 1 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventDivineStorm, 8 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventHammerOfJustice, 7 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventAvengingWrath, 10 * TimeConstants::IN_MILLISECONDS);
}
void KilledUnit(Unit* p_Killed) override
{
if (p_Killed->GetTypeId() == TypeID::TYPEID_PLAYER)
Talk(eTalks::Slay);
}
void JustDied(Unit* /*p_Killer*/) override
{
Talk(eTalks::Death);
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)me->GetZoneScript())
l_Ashran->HandleCaptainDeath(eSpecialSpawns::CaptainVanguardSamuelle);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
/// Use same path as Kronus
me->LoadPath(eCreatures::Kronus);
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventJudgment:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::Judgment, false);
m_Events.ScheduleEvent(eEvents::EventJudgment, 15 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventHammerOfWrath:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::HammerOfWrath, false);
m_Events.ScheduleEvent(eEvents::EventHammerOfWrath, 15 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventDivineShield:
{
if (me->HealthBelowPct(50))
me->CastSpell(me, eSpells::DivineShield, true);
else
m_Events.ScheduleEvent(eEvents::EventDivineShield, 1 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventDivineStorm:
{
me->CastSpell(me, eSpells::DivineStorm, false);
m_Events.ScheduleEvent(eEvents::EventDivineStorm, 15 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventHammerOfJustice:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::HammerOfJustice, false);
m_Events.ScheduleEvent(eEvents::EventHammerOfJustice, 15 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventAvengingWrath:
{
me->CastSpell(me, eSpells::AvengingWrath, false);
m_Events.ScheduleEvent(eEvents::EventAvengingWrath, 45 * TimeConstants::IN_MILLISECONDS);
break;
}
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_vanguard_samuelleAI(p_Creature);
}
};
/// Elementalist Novo <Horde Captain> - 80491
class npc_ashran_elementalist_novo : public CreatureScript
{
public:
npc_ashran_elementalist_novo() : CreatureScript("npc_ashran_elementalist_novo") { }
enum eSpells
{
ChainLightning = 178060,
Hex = 178064,
LavaBurst = 178091,
LightningBolt = 178059,
MagmaTotem = 178063,
MagmaTotemAura = 178062
};
enum eEvents
{
EventChainLightning = 1,
EventHex,
EventLavaBurst,
EventLightningBolt,
EventMagmaTotem,
EventMove
};
enum eTalk
{
Death
};
struct npc_ashran_elementalist_novoAI : public ScriptedAI
{
npc_ashran_elementalist_novoAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
EventMap m_Events;
EventMap m_MoveEvent;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1 * TimeConstants::IN_MILLISECONDS);
Reset();
}
void Reset() override
{
m_Events.Reset();
/// Second equip is a shield
me->SetCanDualWield(false);
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->SetHomePosition(*me);
m_Events.ScheduleEvent(eEvents::EventChainLightning, 5 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventHex, 10 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventLavaBurst, 8 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventLightningBolt, 2 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventMagmaTotem, 15 * TimeConstants::IN_MILLISECONDS);
}
void JustDied(Unit* /*p_Killer*/) override
{
Talk(eTalk::Death);
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)me->GetZoneScript())
l_Ashran->HandleCaptainDeath(eSpecialSpawns::CaptainElementalistNovo);
}
void JustSummoned(Creature* p_Summon) override
{
p_Summon->SetReactState(ReactStates::REACT_PASSIVE);
p_Summon->AddAura(eSpells::MagmaTotemAura, p_Summon);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
/// Use same path as Kronus
me->LoadPath(eCreatures::Kronus);
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventChainLightning:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::ChainLightning, false);
m_Events.ScheduleEvent(eEvents::EventChainLightning, 8 * TimeConstants::IN_MILLISECONDS);
break;
case eEvents::EventHex:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::Hex, false);
m_Events.ScheduleEvent(eEvents::EventHex, 30 * TimeConstants::IN_MILLISECONDS);
break;
case eEvents::EventLavaBurst:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::LavaBurst, false);
m_Events.ScheduleEvent(eEvents::EventLavaBurst, 15 * TimeConstants::IN_MILLISECONDS);
break;
case eEvents::EventLightningBolt:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::LightningBolt, false);
m_Events.ScheduleEvent(eEvents::EventLightningBolt, 6 * TimeConstants::IN_MILLISECONDS);
break;
case eEvents::EventMagmaTotem:
me->CastSpell(me, eSpells::MagmaTotem, false);
m_Events.ScheduleEvent(eEvents::EventMagmaTotem, 40 * TimeConstants::IN_MILLISECONDS);
break;
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_elementalist_novoAI(p_Creature);
}
};
/// Captain Hoodrych <Horde Captain> - 79900
class npc_ashran_captain_hoodrych : public CreatureScript
{
public:
npc_ashran_captain_hoodrych() : CreatureScript("npc_ashran_captain_hoodrych") { }
enum eSpells
{
SpellBladestorm = 164091,
Shockwave = 164092
};
enum eEvents
{
EventBladestorm = 1,
EventShockwave,
EventMove
};
enum eTalks
{
Slay,
Bladestorm,
Death
};
enum eData
{
MountID = 38607
};
struct npc_ashran_captain_hoodrychAI : public ScriptedAI
{
npc_ashran_captain_hoodrychAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
EventMap m_Events;
EventMap m_MoveEvent;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1 * TimeConstants::IN_MILLISECONDS);
Reset();
}
void Reset() override
{
m_Events.Reset();
me->Mount(eData::MountID);
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->Mount(0);
me->SetHomePosition(*me);
m_Events.ScheduleEvent(eEvents::EventBladestorm, 5 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventShockwave, 10 * TimeConstants::IN_MILLISECONDS);
}
void KilledUnit(Unit* p_Killed) override
{
if (p_Killed->GetTypeId() == TypeID::TYPEID_PLAYER)
Talk(eTalks::Slay);
}
void EnterEvadeMode() override
{
me->InterruptNonMeleeSpells(true);
CreatureAI::EnterEvadeMode();
}
void JustDied(Unit* /*p_Killer*/) override
{
Talk(eTalks::Death);
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)me->GetZoneScript())
l_Ashran->HandleCaptainDeath(eSpecialSpawns::CaptainCaptainHoodrych);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
/// Use same path as Kronus
me->LoadPath(eCreatures::Kronus);
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
/// Update position during Bladestorm
if (me->HasAura(eSpells::SpellBladestorm))
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
{
me->GetMotionMaster()->MovePoint(0, *l_Target);
return;
}
}
/// Update target movements here to avoid some movements problems
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
{
if (!me->IsWithinMeleeRange(l_Target))
{
me->GetMotionMaster()->Clear();
me->GetMotionMaster()->MoveChase(l_Target);
}
}
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventBladestorm:
Talk(eTalks::Bladestorm);
me->CastSpell(me, eSpells::SpellBladestorm, false);
m_Events.ScheduleEvent(eEvents::EventBladestorm, 15 * TimeConstants::IN_MILLISECONDS);
break;
case eEvents::EventShockwave:
me->CastSpell(me, eSpells::Shockwave, false);
m_Events.ScheduleEvent(eEvents::EventShockwave, 20 * TimeConstants::IN_MILLISECONDS);
break;
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_captain_hoodrychAI(p_Creature);
}
};
/// Soulbrewer Nadagast <Horde Captain> - 80489
class npc_ashran_soulbrewer_nadagast : public CreatureScript
{
public:
npc_ashran_soulbrewer_nadagast() : CreatureScript("npc_ashran_soulbrewer_nadagast") { }
enum eSpells
{
ChaosBolt = 178076,
RainOfFire = 178069
};
enum eEvents
{
EventChaosBolt = 1,
EventRainOfFire,
EventMove
};
enum eTalks
{
Spawn,
Slay
};
struct npc_ashran_soulbrewer_nadagastAI : public ScriptedAI
{
npc_ashran_soulbrewer_nadagastAI(Creature* p_Creature) : ScriptedAI(p_Creature)
{
m_Spawn = false;
}
EventMap m_Events;
EventMap m_MoveEvent;
bool m_Spawn;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1 * TimeConstants::IN_MILLISECONDS);
Reset();
}
void Reset() override
{
m_Events.Reset();
if (!m_Spawn)
{
m_Spawn = true;
Talk(eTalks::Spawn);
}
/// Second equip is a Off-hand Frill
me->SetCanDualWield(false);
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->SetHomePosition(*me);
m_Events.ScheduleEvent(eEvents::EventChaosBolt, 3 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventRainOfFire, 6 * TimeConstants::IN_MILLISECONDS);
}
void KilledUnit(Unit* p_Killed) override
{
if (p_Killed->GetTypeId() == TypeID::TYPEID_PLAYER)
Talk(eTalks::Slay);
}
void JustDied(Unit* /*p_Killer*/) override
{
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)me->GetZoneScript())
l_Ashran->HandleCaptainDeath(eSpecialSpawns::CaptainSoulbrewerNadagast);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
/// Use same path as Kronus
me->LoadPath(eCreatures::Kronus);
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventChaosBolt:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::ChaosBolt, false);
m_Events.ScheduleEvent(eEvents::EventChaosBolt, 15 * TimeConstants::IN_MILLISECONDS);
break;
case eEvents::EventRainOfFire:
me->CastSpell(me, eSpells::RainOfFire, false);
m_Events.ScheduleEvent(eEvents::EventRainOfFire, 20 * TimeConstants::IN_MILLISECONDS);
break;
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_soulbrewer_nadagastAI(p_Creature);
}
};
/// Necrolord Azael <Horde Captain> - 80486
class npc_ashran_necrolord_azael : public CreatureScript
{
public:
npc_ashran_necrolord_azael() : CreatureScript("npc_ashran_necrolord_azael") { }
enum eSpells
{
ChaosBolt = 178076,
RainOfFire = 178069
};
enum eEvents
{
EventChaosBolt = 1,
EventRainOfFire,
EventMove
};
enum eTalks
{
Slay,
Death
};
enum eData
{
MountID = 51048
};
struct npc_ashran_necrolord_azaelAI : public ScriptedAI
{
npc_ashran_necrolord_azaelAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
EventMap m_Events;
EventMap m_MoveEvent;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1 * TimeConstants::IN_MILLISECONDS);
Reset();
}
void Reset() override
{
m_Events.Reset();
me->Mount(eData::MountID);
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->Mount(0);
me->SetHomePosition(*me);
m_Events.ScheduleEvent(eEvents::EventChaosBolt, 3 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventRainOfFire, 6 * TimeConstants::IN_MILLISECONDS);
}
void KilledUnit(Unit* p_Killed) override
{
if (p_Killed->GetTypeId() == TypeID::TYPEID_PLAYER)
Talk(eTalks::Slay);
}
void JustDied(Unit* /*p_Killer*/) override
{
Talk(eTalks::Death);
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)me->GetZoneScript())
l_Ashran->HandleCaptainDeath(eSpecialSpawns::CaptainNecrolordAzael);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
/// Use same path as Kronus
me->LoadPath(eCreatures::Kronus);
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventChaosBolt:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::ChaosBolt, false);
m_Events.ScheduleEvent(eEvents::EventChaosBolt, 15 * TimeConstants::IN_MILLISECONDS);
break;
case eEvents::EventRainOfFire:
me->CastSpell(me, eSpells::RainOfFire, false);
m_Events.ScheduleEvent(eEvents::EventRainOfFire, 20 * TimeConstants::IN_MILLISECONDS);
break;
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_necrolord_azaelAI(p_Creature);
}
};
/// Rifthunter Yoske <Horde Captain> - 80496
class npc_ashran_rifthunter_yoske : public CreatureScript
{
public:
npc_ashran_rifthunter_yoske() : CreatureScript("npc_ashran_rifthunter_yoske") { }
enum eSpells
{
Shoot = 164095,
SerpentSting = 162754
};
enum eEvents
{
EventShoot = 1,
EventSerpentSting,
EventMove
};
enum eTalks
{
Slay,
Death
};
struct npc_ashran_rifthunter_yoskeAI : public ScriptedAI
{
npc_ashran_rifthunter_yoskeAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
EventMap m_Events;
EventMap m_MoveEvent;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1 * TimeConstants::IN_MILLISECONDS);
Reset();
}
void Reset() override
{
m_Events.Reset();
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->SetHomePosition(*me);
m_Events.ScheduleEvent(eEvents::EventShoot, 3 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventSerpentSting, 5 * TimeConstants::IN_MILLISECONDS);
}
void KilledUnit(Unit* p_Killed) override
{
if (p_Killed->GetTypeId() == TypeID::TYPEID_PLAYER)
Talk(eTalks::Slay);
}
void JustDied(Unit* /*p_Killer*/) override
{
Talk(eTalks::Death);
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)me->GetZoneScript())
l_Ashran->HandleCaptainDeath(eSpecialSpawns::CaptainRifthunterYoske);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
/// Use same path as Kronus
me->LoadPath(eCreatures::Kronus);
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventShoot:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::Shoot, false);
m_Events.ScheduleEvent(eEvents::EventShoot, 5 * TimeConstants::IN_MILLISECONDS);
break;
case eEvents::EventSerpentSting:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::SerpentSting, false);
m_Events.ScheduleEvent(eEvents::EventSerpentSting, 12 * TimeConstants::IN_MILLISECONDS);
break;
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_rifthunter_yoskeAI(p_Creature);
}
};
/// Mor'riz <The Ultimate Troll> - 85133
class npc_ashran_morriz : public CreatureScript
{
public:
npc_ashran_morriz() : CreatureScript("npc_ashran_morriz") { }
enum eSpell
{
Typhoon = 164337
};
enum eEvents
{
EventTyphoon = 1,
EventMove
};
struct npc_ashran_morrizAI : public ScriptedAI
{
npc_ashran_morrizAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
EventMap m_Events;
EventMap m_MoveEvent;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1 * TimeConstants::IN_MILLISECONDS);
Reset();
}
void Reset() override
{
m_Events.Reset();
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->SetHomePosition(*me);
m_Events.ScheduleEvent(eEvents::EventTyphoon, 15 * TimeConstants::IN_MILLISECONDS);
}
void JustDied(Unit* /*p_Killer*/) override
{
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)me->GetZoneScript())
l_Ashran->HandleCaptainDeath(eSpecialSpawns::CaptainMorriz);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
/// Use same path as Kronus
me->LoadPath(eCreatures::Kronus);
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventTyphoon:
{
me->CastSpell(me, eSpell::Typhoon, false);
m_Events.ScheduleEvent(eEvents::EventTyphoon, 20 * TimeConstants::IN_MILLISECONDS);
break;
}
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_morrizAI(p_Creature);
}
};
/// Kaz Endsky <Horde Captain> - 87690
class npc_ashran_kaz_endsky : public CreatureScript
{
public:
npc_ashran_kaz_endsky() : CreatureScript("npc_ashran_kaz_endsky") { }
enum eSpells
{
PlagueStrike = 164063,
DeathAndDecay = 164334,
DeathCoil = 164064,
DeathGrip = 79894,
DeathGripJump = 168563
};
enum eEvents
{
EventPlagueStrike = 1,
EventDeathAndDecay,
EventDeathCoil,
EventDeathGrip,
EventMove
};
enum eTalks
{
Slay,
Death
};
enum eData
{
MountID = 25280
};
struct npc_ashran_kaz_endskyAI : public ScriptedAI
{
npc_ashran_kaz_endskyAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
EventMap m_Events;
EventMap m_MoveEvent;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1 * TimeConstants::IN_MILLISECONDS);
Reset();
}
void Reset() override
{
m_Events.Reset();
me->Mount(eData::MountID);
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->Mount(0);
me->SetHomePosition(*me);
m_Events.ScheduleEvent(eEvents::EventPlagueStrike, 2 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventDeathAndDecay, 5 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventDeathCoil, 8 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventDeathGrip, 1 * TimeConstants::IN_MILLISECONDS);
}
void KilledUnit(Unit* p_Killed) override
{
if (p_Killed->GetTypeId() == TypeID::TYPEID_PLAYER)
Talk(eTalks::Slay);
}
void JustDied(Unit* /*p_Killer*/) override
{
Talk(eTalks::Death);
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)me->GetZoneScript())
l_Ashran->HandleCaptainDeath(eSpecialSpawns::CaptainKazEndsky);
}
void SpellHitTarget(Unit* p_Target, SpellInfo const* p_SpellInfo) override
{
if (p_Target == nullptr)
return;
if (p_SpellInfo->Id == eSpells::DeathGrip)
p_Target->CastSpell(*me, eSpells::DeathGripJump, true);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
/// Use same path as Kronus
me->LoadPath(eCreatures::Kronus);
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventPlagueStrike:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::PlagueStrike, false);
m_Events.ScheduleEvent(eEvents::EventPlagueStrike, 8 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventDeathAndDecay:
{
me->CastSpell(me, eSpells::DeathAndDecay, false);
m_Events.ScheduleEvent(eEvents::EventDeathAndDecay, 12 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventDeathCoil:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::DeathCoil, false);
m_Events.ScheduleEvent(eEvents::EventDeathCoil, 10 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventDeathGrip:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::DeathGrip, false);
m_Events.ScheduleEvent(eEvents::EventDeathGrip, 20 * TimeConstants::IN_MILLISECONDS);
break;
}
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_kaz_endskyAI(p_Creature);
}
};
/// Razor Guerra <Horde Captain> - 85138
class npc_ashran_razor_guerra : public CreatureScript
{
public:
npc_ashran_razor_guerra() : CreatureScript("npc_ashran_razor_guerra") { }
enum eSpells
{
Blind = 178058,
CloakOfShadows = 178055,
Eviscerate = 178054,
FanOfKnives = 178053,
Hemorrhage = 178052,
Shadowstep = 178056,
WoundPoison = 178050
};
enum eEvents
{
EventBlind = 1,
EventCloakOfShadows,
EventEviscerate,
EventFanOfKnives,
EventHemorrhage,
EventShadowStep,
EventWoundPoison,
EventMove
};
enum eTalks
{
Slay,
Death
};
enum eData
{
MountID = 51048
};
struct npc_ashran_razor_guerraAI : public ScriptedAI
{
npc_ashran_razor_guerraAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
EventMap m_Events;
EventMap m_MoveEvent;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1 * TimeConstants::IN_MILLISECONDS);
Reset();
}
void Reset() override
{
m_Events.Reset();
me->Mount(eData::MountID);
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->Mount(0);
me->SetHomePosition(*me);
m_Events.ScheduleEvent(eEvents::EventBlind, 15 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventCloakOfShadows, 1 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventEviscerate, 10 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventFanOfKnives, 8 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventHemorrhage, 2 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventShadowStep, 1 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventWoundPoison, 5 * TimeConstants::IN_MILLISECONDS);
}
void KilledUnit(Unit* p_Killed) override
{
if (p_Killed->GetTypeId() == TypeID::TYPEID_PLAYER)
Talk(eTalks::Slay);
}
void JustDied(Unit* /*p_Killer*/) override
{
Talk(eTalks::Death);
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)me->GetZoneScript())
l_Ashran->HandleCaptainDeath(eSpecialSpawns::CaptainRazorGuerra);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
/// Use same path as Kronus
me->LoadPath(eCreatures::Kronus);
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventBlind:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::Blind, false);
m_Events.ScheduleEvent(eEvents::EventBlind, 30 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventCloakOfShadows:
{
if (me->HealthBelowPct(50))
me->CastSpell(me, eSpells::CloakOfShadows, true);
else
m_Events.ScheduleEvent(eEvents::EventCloakOfShadows, 1 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventEviscerate:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::Eviscerate, false);
m_Events.ScheduleEvent(eEvents::EventEviscerate, 20 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventFanOfKnives:
{
me->CastSpell(me, eSpells::FanOfKnives, false);
m_Events.ScheduleEvent(eEvents::EventFanOfKnives, 10 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventHemorrhage:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::Hemorrhage, false);
m_Events.ScheduleEvent(eEvents::EventHemorrhage, 15 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventShadowStep:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::Shadowstep, false);
m_Events.ScheduleEvent(eEvents::EventShadowStep, 20 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventWoundPoison:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::WoundPoison, false);
m_Events.ScheduleEvent(eEvents::EventWoundPoison, 12 * TimeConstants::IN_MILLISECONDS);
break;
}
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_razor_guerraAI(p_Creature);
}
};
/// Jared V. Hellstrike <Horde Captain> - 85131
class npc_ashran_jared_v_hellstrike : public CreatureScript
{
public:
npc_ashran_jared_v_hellstrike() : CreatureScript("npc_ashran_jared_v_hellstrike") { }
enum eSpells
{
BlackoutKick = 164394,
LegSweep = 164392,
RisingSunKick = 127734,
SpinningCraneKick = 162759
};
enum eEvents
{
EventBlackoutKick = 1,
EventLegSweep,
EventRisingSunKick,
EventSpinningCraneKick,
EventMove
};
struct npc_ashran_jared_v_hellstrikeAI : public ScriptedAI
{
npc_ashran_jared_v_hellstrikeAI(Creature* p_Creature) : ScriptedAI(p_Creature) { }
EventMap m_Events;
EventMap m_MoveEvent;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1 * TimeConstants::IN_MILLISECONDS);
Reset();
}
void Reset() override
{
m_Events.Reset();
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->SetHomePosition(*me);
m_Events.ScheduleEvent(eEvents::EventBlackoutKick, 5 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventLegSweep, 8 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventRisingSunKick, 10 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventSpinningCraneKick, 12 * TimeConstants::IN_MILLISECONDS);
}
void JustDied(Unit* /*p_Killer*/) override
{
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)me->GetZoneScript())
l_Ashran->HandleCaptainDeath(eSpecialSpawns::CaptainJaredVHellstrike);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
me->SetWalk(true);
/// Use same path as Kronus
me->LoadPath(eCreatures::Kronus);
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventBlackoutKick:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::BlackoutKick, false);
m_Events.ScheduleEvent(eEvents::EventBlackoutKick, 10 * TimeConstants::IN_MILLISECONDS);
break;
case eEvents::EventLegSweep:
me->CastSpell(me, eSpells::LegSweep, false);
m_Events.ScheduleEvent(eEvents::EventLegSweep, 25 * TimeConstants::IN_MILLISECONDS);
break;
case eEvents::EventRisingSunKick:
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::RisingSunKick, false);
m_Events.ScheduleEvent(eEvents::EventRisingSunKick, 15 * TimeConstants::IN_MILLISECONDS);
break;
case eEvents::EventSpinningCraneKick:
me->CastSpell(me, eSpells::SpinningCraneKick, false);
m_Events.ScheduleEvent(eEvents::EventSpinningCraneKick, 20 * TimeConstants::IN_MILLISECONDS);
break;
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_jared_v_hellstrikeAI(p_Creature);
}
};
/// Kimilyn <Forged in Flame> - 88109
class npc_ashran_kimilyn : public CreatureScript
{
public:
npc_ashran_kimilyn() : CreatureScript("npc_ashran_kimilyn") { }
enum eSpells
{
DevouringPlague = 164452,
Dispersion = 164444,
MindBlast = 164448,
MindSear = 177402,
PsychicScream = 164443,
ShadowWordPain = 164446
};
enum eEvents
{
EventDevouringPlague = 1,
EventDispersion,
EventMindBlast,
EventMindSear,
EventPsychicScream,
EventShadowWordPain,
EventMove
};
enum eTalks
{
Spawn,
Death
};
enum eData
{
MountID = 51048
};
struct npc_ashran_kimilynAI : public ScriptedAI
{
npc_ashran_kimilynAI(Creature* p_Creature) : ScriptedAI(p_Creature)
{
m_Spawn = false;
}
EventMap m_Events;
EventMap m_MoveEvent;
bool m_Spawn;
void InitializeAI() override
{
m_MoveEvent.ScheduleEvent(eEvents::EventMove, 1 * TimeConstants::IN_MILLISECONDS);
Reset();
}
void Reset() override
{
m_Events.Reset();
if (!m_Spawn)
{
Talk(eTalks::Spawn);
m_Spawn = true;
}
me->Mount(eData::MountID);
}
void EnterCombat(Unit* /*p_Attacker*/) override
{
me->Mount(0);
me->SetHomePosition(*me);
m_Events.ScheduleEvent(eEvents::EventDevouringPlague, 10 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventDispersion, 1 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventMindBlast, 5 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventMindSear, 8 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventPsychicScream, 15 * TimeConstants::IN_MILLISECONDS);
m_Events.ScheduleEvent(eEvents::EventShadowWordPain, 1 * TimeConstants::IN_MILLISECONDS);
}
void JustDied(Unit* /*p_Killer*/) override
{
Talk(eTalks::Death);
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)me->GetZoneScript())
l_Ashran->HandleCaptainDeath(eSpecialSpawns::CaptainKimilyn);
}
void UpdateAI(uint32 const p_Diff) override
{
m_MoveEvent.Update(p_Diff);
if (m_MoveEvent.ExecuteEvent() == eEvents::EventMove)
{
/// Use same path as Kronus
me->LoadPath(eCreatures::Kronus);
me->SetDefaultMovementType(MovementGeneratorType::WAYPOINT_MOTION_TYPE);
me->GetMotionMaster()->Initialize();
}
if (!UpdateVictim())
return;
m_Events.Update(p_Diff);
if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
return;
switch (m_Events.ExecuteEvent())
{
case eEvents::EventDevouringPlague:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::DevouringPlague, false);
m_Events.ScheduleEvent(eEvents::EventDevouringPlague, 15 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventDispersion:
{
if (me->HealthBelowPct(50))
me->CastSpell(me, eSpells::Dispersion, true);
else
m_Events.ScheduleEvent(eEvents::EventDispersion, 1 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventMindBlast:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::MindBlast, false);
m_Events.ScheduleEvent(eEvents::EventMindBlast, 10 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventMindSear:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::MindSear, false);
m_Events.ScheduleEvent(eEvents::EventMindSear, 20 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventPsychicScream:
{
me->CastSpell(me, eSpells::PsychicScream, false);
m_Events.ScheduleEvent(eEvents::EventPsychicScream, 30 * TimeConstants::IN_MILLISECONDS);
break;
}
case eEvents::EventShadowWordPain:
{
if (Unit* l_Target = SelectTarget(SelectAggroTarget::SELECT_TARGET_TOPAGGRO))
me->CastSpell(l_Target, eSpells::ShadowWordPain, false);
m_Events.ScheduleEvent(eEvents::EventShadowWordPain, 12 * TimeConstants::IN_MILLISECONDS);
break;
}
default:
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_kimilynAI(p_Creature);
}
};
/// Speedy Horde Racer - 82903
class npc_ashran_speedy_horde_racer : public CreatureScript
{
public:
npc_ashran_speedy_horde_racer() : CreatureScript("npc_ashran_speedy_horde_racer") { }
enum eSpell
{
HordeRacer = 166819
};
struct npc_ashran_speedy_horde_racerAI : public MS::AI::CosmeticAI
{
npc_ashran_speedy_horde_racerAI(Creature* p_Creature) : MS::AI::CosmeticAI(p_Creature)
{
m_CheckCooldown = uint32(time(nullptr) + 5);
}
uint8 m_MoveIndex;
uint32 m_CheckCooldown;
void InitializeAI() override
{
Reset();
}
void Reset() override
{
me->CastSpell(me, eSpell::HordeRacer, true);
me->ModifyAuraState(AuraStateType::AURA_STATE_UNKNOWN22, true);
m_MoveIndex = 0;
AddTimedDelayedOperation(500, [this]() -> void
{
if (Creature* l_Rider = me->FindNearestCreature(eCreatures::HordeRider, 10.0f))
l_Rider->EnterVehicle(me);
});
AddTimedDelayedOperation(1 * TimeConstants::IN_MILLISECONDS, [this]() -> void
{
me->GetMotionMaster()->MovePoint(m_MoveIndex, g_HordeRacingMoves[m_MoveIndex]);
});
}
void MovementInform(uint32 p_Type, uint32 /*p_ID*/) override
{
if (p_Type != MovementGeneratorType::POINT_MOTION_TYPE)
return;
++m_MoveIndex;
if (m_MoveIndex >= eAshranDatas::HordeRacingMovesCount)
{
m_MoveIndex = 0;
IncreaseLapCount();
}
AddTimedDelayedOperation(100, [this]() -> void
{
me->GetMotionMaster()->MovePoint(m_MoveIndex, g_HordeRacingMoves[m_MoveIndex]);
});
}
void IncreaseLapCount()
{
OutdoorPvP* l_Outdoor = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(me->GetZoneId());
if (OutdoorPvPAshran* l_Ashran = (OutdoorPvPAshran*)l_Outdoor)
l_Ashran->SetEventData(eAshranEvents::EventStadiumRacing, TeamId::TEAM_HORDE, 1);
}
};
CreatureAI* GetAI(Creature* p_Creature) const override
{
return new npc_ashran_speedy_horde_racerAI(p_Creature);
}
};
#ifndef __clang_analyzer__
void AddSC_AshranNPCHorde()
{
new npc_jeron_emberfall();
new npc_ashran_warspear_shaman();
new npc_ashran_illandria_belore();
new npc_ashran_examiner_rahm_flameheart();
new npc_ashran_centurion_firescream();
new npc_ashran_legionnaire_hellaxe();
new npc_ashran_kalgan();
new npc_ashran_fura();
new npc_ashran_nisstyr();
new npc_ashran_atomik();
new npc_ashran_zaram_sunraiser();
new npc_ashran_horde_gateway_guardian();
new npc_ashran_kronus();
new npc_ashran_underpowered_earth_fury();
new npc_ashran_warspear_gladiator();
new npc_ashran_excavator_rustshiv();
new npc_ashran_excavator_hardtooth();
new npc_ashran_voljins_spear_battle_standard();
new npc_ashran_warspear_headhunter();
new npc_ashran_lord_mes();
new npc_ashran_mindbender_talbadar();
new npc_ashran_elliott_van_rook();
new npc_ashran_vanguard_samuelle();
new npc_ashran_elementalist_novo();
new npc_ashran_captain_hoodrych();
new npc_ashran_soulbrewer_nadagast();
new npc_ashran_necrolord_azael();
new npc_ashran_rifthunter_yoske();
new npc_ashran_morriz();
new npc_ashran_kaz_endsky();
new npc_ashran_razor_guerra();
new npc_ashran_jared_v_hellstrike();
new npc_ashran_kimilyn();
new npc_ashran_speedy_horde_racer();
}
#endif
|
6fb2ad4c19ba478c2dadcf57125172c860b29331
|
d312d534036de17b5dad24a26bf710c9fbf102f5
|
/src/modules/persistence/LongCounter.h
|
50101b306a74648d8d785db9aace5bf36960c968
|
[] |
no_license
|
wshmaple/engine
|
e9f3964e7210125b71fa0294c33df35494abb9e2
|
f4ae34f9600ba0004af953a7d2447fd835ad85c4
|
refs/heads/master
| 2021-05-04T12:27:11.545596
| 2018-01-30T17:01:05
| 2018-01-30T18:44:52
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 835
|
h
|
LongCounter.h
|
/**
* @file
*/
#pragma once
namespace persistence {
/**
* @brief This counter maintains a state between the value that is known in the database and the
* value that is current in the memory.
*
* @c update() will deliver the delta value that should be used to do a relative update on the database.
* Just to persist the delta.
*/
class LongCounter {
private:
long _current;
long _persisted;
public:
LongCounter(long initial = 0L, long persisted = 0L) :
_current(initial), _persisted(persisted) {
}
/**
* @return The delta between the value that is persisted and the value that is currently in memory.
*/
long update() {
const long c = _current;
_current = _persisted;
return c - _persisted;
}
/**
* @return The current value as in memory
*/
inline long value() const {
return _current;
}
};
}
|
4fd29bd4eec178e1c0a6403963c6f8e5007e6a5d
|
5918cb61b1232b9bfdedca3236a921433c89dc4b
|
/hydra/algorithms/time_evolution/time_evolution.cpp
|
094f2edc5748d7e2f064fba6f75f81c92ca478b6
|
[
"Apache-2.0"
] |
permissive
|
awietek/hydra
|
589d490fb149c18e299aa5e7589a7acbb82d4e0a
|
cce1bfe9c8365b03daeccaf46da4fd59c602f07a
|
refs/heads/master
| 2023-09-01T05:41:18.135264
| 2023-08-22T08:53:38
| 2023-08-22T08:53:38
| 169,422,780
| 24
| 5
|
Apache-2.0
| 2023-06-21T16:17:44
| 2019-02-06T14:55:19
|
C++
|
UTF-8
|
C++
| false
| false
| 2,846
|
cpp
|
time_evolution.cpp
|
#include "time_evolution.h"
#include <hydra/algebra/algebra.h>
#include <hydra/algorithms/time_evolution/exp_sym_v.h>
#include <hydra/algorithms/time_evolution/zahexpv.h>
#include <hydra/utils/timing.h>
namespace hydra {
std::tuple<double, double> time_evolve_inplace(BondList const &bonds,
StateCplx &state, double time,
double precision, int m,
double anorm, int nnorm) {
auto const &block = state.block();
int iter = 1;
auto apply_A = [&iter, &bonds, &block](arma::cx_vec const &v) {
auto ta = rightnow();
auto w = arma::cx_vec(v.n_rows, arma::fill::zeros);
apply(bonds, block, v, block, w);
w *= -1.0i;
Log(2, "Lanczos iteration {}", iter);
timing(ta, rightnow(), "MVM", 2);
++iter;
return w;
};
auto &v0 = state.vector();
auto t0 = rightnow();
auto [err, hump] =
zahexpv(time, apply_A, v0, precision / time, m, anorm, nnorm);
timing(t0, rightnow(), "Zahexpv time", 1);
return {err, hump};
}
template <>
StateCplx time_evolve(BondList const &bonds, StateReal state, double time,
double precision, int m, double anorm, int nnorm) {
auto state_cplx = to_cplx(state);
auto [err, hump] =
time_evolve_inplace(bonds, state_cplx, time, precision, m, anorm, nnorm);
Log(2, "error (estimated): {}, hump: {}", err, hump);
return state_cplx;
}
template <>
StateCplx time_evolve(BondList const &bonds, StateCplx state, double time,
double precision, int m, double anorm, int nnorm) {
auto [err, hump] =
time_evolve_inplace(bonds, state, time, precision, m, anorm, nnorm);
Log(2, "error (estimated): {}, hump: {}", err, hump);
return state;
}
template <typename coeff_t>
double imag_time_evolve_inplace(BondList const &bonds, State<coeff_t> &state,
double time, double precision) {
return exp_sym_v_inplace(bonds, state, -time, precision);
}
template double imag_time_evolve_inplace(BondList const &, State<double> &,
double, double);
template double imag_time_evolve_inplace(BondList const &, State<complex> &,
double, double);
template <typename coeff_t>
State<coeff_t> imag_time_evolve(BondList const &bonds, State<coeff_t> state,
double time, double precision) {
imag_time_evolve_inplace(bonds, state, time, precision);
return state;
}
template State<double> imag_time_evolve(BondList const &, State<double>, double,
double);
template State<complex> imag_time_evolve(BondList const &, State<complex>,
double, double);
} // namespace hydra
|
1326e518b37b934d85cef95740d1733e1cfeb50a
|
5cbd610dd14c24ba6f2f5e8163d731126543e02d
|
/src/projectors/SbCylinderPlaneProjector.cpp
|
56eba0da225bb6a13cd23db08785bc65b4defaed
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"GPL-1.0-or-later",
"LGPL-2.0-or-later"
] |
permissive
|
roboticslibrary/coin
|
f2a3ae787d85f54d41f31c596e9f7a83b72dd13d
|
aab30f147b2a07c252dbf94d1a59b18f576b8ce5
|
refs/heads/master
| 2021-08-04T18:53:04.087811
| 2021-01-13T21:33:01
| 2021-01-13T21:33:01
| 237,409,873
| 1
| 2
|
BSD-3-Clause
| 2020-01-31T10:42:22
| 2020-01-31T10:42:22
| null |
UTF-8
|
C++
| false
| false
| 7,158
|
cpp
|
SbCylinderPlaneProjector.cpp
|
/**************************************************************************\
* Copyright (c) Kongsberg Oil & Gas Technologies AS
* 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 copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\**************************************************************************/
/*!
\class SbCylinderPlaneProjector SbCylinderPlaneProjector.h Inventor/projectors/SbCylinderPlaneProjector.h
\brief The SbCylinderPlaneProjector class projects 2D points to a half-cylinder and a plane.
\ingroup projectors
This projector uses a plane along with the half-cylinder of
SbCylinderSectionProjector for projections. If the 2D point mapping
"misses" the cylinder section, the 3D point will be projected onto
the plane.
\sa SbSpherePlaneProjector
*/
#include <Inventor/projectors/SbCylinderPlaneProjector.h>
#if COIN_DEBUG
#include <Inventor/errors/SoDebugError.h>
#endif // COIN_DEBUG
#include <cfloat>
/*!
Default constructor. See
SbCylinderSectionProjector::SbCylinderSectionProjector().
*/
SbCylinderPlaneProjector::SbCylinderPlaneProjector(const float edgetol,
const SbBool orienttoeye)
: SbCylinderSectionProjector(edgetol, orienttoeye)
{
}
/*!
Constructor with explicit specification of projection cylinder.
*/
SbCylinderPlaneProjector::SbCylinderPlaneProjector(const SbCylinder & cyl,
const float edgetol,
const SbBool orienttoeye)
: SbCylinderSectionProjector(cyl, edgetol, orienttoeye)
{
}
// Documented in superclass.
SbProjector *
SbCylinderPlaneProjector::copy(void) const
{
return new SbCylinderPlaneProjector(*this);
}
// Documented in superclass.
SbVec3f
SbCylinderPlaneProjector::project(const SbVec2f & point)
{
if (this->needSetup) this->setupTolerance();
SbLine projline = this->getWorkingLine(point);
SbVec3f projpt;
SbBool tst = this->intersectCylinderFront(projline, projpt);
if (!tst || !this->isWithinTolerance(projpt)) {
if (!this->tolPlane.intersect(projline, projpt)) {
#if COIN_DEBUG
SoDebugError::postWarning("SbCylinderSectionProjector::project",
"working line is parallel to cylinder axis.");
#endif // COIN_DEBUG
return SbVec3f(0.0f, 0.0f, 0.0f);
}
}
this->lastPoint = projpt;
return projpt;
}
// Documented in superclass.
SbRotation
SbCylinderPlaneProjector::getRotation(const SbVec3f & point1,
const SbVec3f & point2)
{
SbBool tol1 = this->isWithinTolerance(point1);
SbBool tol2 = this->isWithinTolerance(point2);
return this->getRotation(point1, tol1, point2, tol2);
}
/*!
Calculates rotation from \a point1 to \a point2, with \a tol1 and \a
tol2 deciding whether or not to use the tolerance setting.
*/
SbRotation
SbCylinderPlaneProjector::getRotation(const SbVec3f & point1, const SbBool tol1,
const SbVec3f & point2, const SbBool tol2)
{
if (tol1 && tol2) return inherited::getRotation(point1, point2);
if (point1 == point2) {
return SbRotation(this->cylinder.getAxis().getDirection(), 0.0f);
}
// create a line to project projections onto. This will make
// the below calculations much simpler.
SbLine horizline;
SbVec3f dir = this->cylinder.getAxis().getDirection().cross(this->planeDir);
horizline = SbLine(this->planeLine.getPosition(),
this->planeLine.getPosition() + dir);
//
// pt1 is the point projected onto horizline. pt1_tol is different from
// pt1 if tol1==FALSE. pt1_tol will then be on the edge of the cylinder
// section, where the cylinder section intersects the plane, but it will
// also be on horizline.
//
SbVec3f pt1, pt1_tol, pt2, pt2_tol;
pt1 = horizline.getClosestPoint(point1);
pt2 = horizline.getClosestPoint(point2);
if (tol1) {
pt1_tol = pt1;
}
else {
SbVec3f ptOnLine = this->planeLine.getClosestPoint(point1);
SbLine myLine(point1, ptOnLine);
if (!this->cylinder.intersect(myLine, pt1_tol)) {
// shouldn't happen, but be robust if it does
return SbRotation(SbVec3f(0.0f, 0.0f, 1.0f), 0.0f);
}
pt1_tol = horizline.getClosestPoint(pt1_tol);
}
if (tol2) {
pt2_tol = pt2;
}
else {
SbVec3f ptOnLine = this->planeLine.getClosestPoint(point2);
SbLine myLine(pt2, ptOnLine);
if (!this->cylinder.intersect(myLine, pt2_tol)) {
// shouldn't happen, but be robust if it does
return SbRotation(SbVec3f(0.0f, 0.0f, 1.0f), 0.0f);
}
pt2_tol = horizline.getClosestPoint(pt2_tol);
}
// find normal cylinder-section rotation
SbRotation rot = inherited::getRotation(tol1 ? point1 : pt1_tol,
tol2 ? point2 : pt2_tol);
SbVec3f axis;
float angle;
rot.getValue(axis, angle);
if (axis.dot(this->cylinder.getAxis().getDirection()) < 0.0f) {
axis = -axis;
angle = 2.0f*float(M_PI) - angle;
}
float len = 0.0f;
// both pts on same side of cylinder ?
if (!tol1 && !tol2 && (pt1_tol == pt2_tol)) {
if ((pt1-pt2).dot(dir) < 0.0f) {
len += (pt1-pt2).length();
}
else {
len -= (pt1-pt2).length();
}
}
else {
if (!tol1) {
if ((pt1_tol-pt1).dot(dir) < 0.0f) {
len -= (pt1_tol-pt1).length();
}
else {
len += (pt1_tol-pt1).length();
}
}
if (!tol2) {
if ((pt2_tol-pt2).dot(dir) < 0.0f) {
len += (pt2_tol-pt2).length();
}
else {
len -= (pt2_tol-pt2).length();
}
}
}
angle += len / this->cylinder.getRadius();
return SbRotation(this->cylinder.getAxis().getDirection(), angle);
}
|
803755c34e4fa5dfb2e7b8d28f519cbf2ffcb184
|
6dafcf4033c387e8166317db331e6dbfdede53e6
|
/zmq/zhelpers.hpp
|
3dbd893b8c09eb6be459c0f99fd73d6a5833b19d
|
[] |
no_license
|
hungptit/experiments
|
fafb3519de5d47285ffda84a22a239a4148d5e79
|
9f317f90623bff638dd80864e81f663326be35c2
|
refs/heads/master
| 2020-04-12T08:09:37.297465
| 2018-04-03T03:56:59
| 2018-04-03T03:56:59
| 65,752,945
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,417
|
hpp
|
zhelpers.hpp
|
#pragma once
// Include a bunch of headers that we will need in the examples
#include <zmq.hpp> // https://github.com/zeromq/cppzmq
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <assert.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h> // random() RAND_MAX
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
// Provide random number from 0..(num-1)
#define within(num) (int)((float)(num)*random() / (RAND_MAX + 1.0))
namespace zguide {
// Receive 0MQ string from socket and convert into string
std::string s_recv(zmq::socket_t &socket) {
zmq::message_t message;
socket.recv(&message);
return std::string(static_cast<char *>(message.data()), message.size());
}
// Convert string to 0MQ string and send to socket
bool s_send(zmq::socket_t &socket, const std::string &string) {
zmq::message_t message(string.size());
memcpy(message.data(), string.data(), string.size());
return socket.send(message);
}
// Sends string as 0MQ string, as multipart non-terminal
bool s_sendmore(zmq::socket_t &socket, const std::string &string) {
zmq::message_t message(string.size());
memcpy(message.data(), string.data(), string.size());
return socket.send(message, ZMQ_SNDMORE);
}
// Receives all message parts from socket, prints neatly
//
void s_dump(zmq::socket_t &socket) {
std::cout << "----------------------------------------" << std::endl;
while (1) {
// Process all parts of the message
zmq::message_t message;
socket.recv(&message);
// Dump the message as text or binary
int size = message.size();
std::string data(static_cast<char *>(message.data()), size);
bool is_text = true;
int char_nbr;
unsigned char byte;
for (char_nbr = 0; char_nbr < size; char_nbr++) {
byte = data[char_nbr];
if (byte < 32 || byte > 127)
is_text = false;
}
std::cout << "[" << std::setfill('0') << std::setw(3) << size << "]";
for (char_nbr = 0; char_nbr < size; char_nbr++) {
if (is_text)
std::cout << (char)data[char_nbr];
else
std::cout << std::setfill('0') << std::setw(2) << std::hex
<< (unsigned int)data[char_nbr];
}
std::cout << std::endl;
int more = 0; // Multipart detection
size_t more_size = sizeof(more);
socket.getsockopt(ZMQ_RCVMORE, &more, &more_size);
if (!more)
break; // Last message part
}
}
void s_version(void) {
int major, minor, patch;
zmq_version(&major, &minor, &patch);
std::cout << "Current 0MQ version is " << major << "." << minor << "." << patch
<< std::endl;
}
void s_version_assert(int want_major, int want_minor) {
int major, minor, patch;
zmq_version(&major, &minor, &patch);
if (major < want_major || (major == want_major && minor < want_minor)) {
std::cout << "Current 0MQ version is " << major << "." << minor << std::endl;
std::cout << "Application needs at least " << want_major << "." << want_minor
<< " - cannot continue" << std::endl;
exit(EXIT_FAILURE);
}
}
// Return current system clock as milliseconds
int64_t s_clock(void) {
struct timeval tv;
gettimeofday(&tv, NULL);
return (int64_t)(tv.tv_sec * 1000 + tv.tv_usec / 1000);
}
// Sleep for a number of milliseconds
void s_sleep(int msecs) {
struct timespec t;
t.tv_sec = msecs / 1000;
t.tv_nsec = (msecs % 1000) * 1000000;
nanosleep(&t, NULL);
}
void s_console(const char *format, ...) {
time_t curtime = time(NULL);
struct tm *loctime = localtime(&curtime);
char *formatted = new char[20];
strftime(formatted, 20, "%y-%m-%d %H:%M:%S ", loctime);
printf("%s", formatted);
delete[] formatted;
va_list argptr;
va_start(argptr, format);
vprintf(format, argptr);
va_end(argptr);
printf("\n");
}
// ---------------------------------------------------------------------
// Signal handling
//
// Call s_catch_signals() in your application at startup, and then exit
// your main loop if s_interrupted is ever 1. Works especially well with
// zmq_poll.
static int s_interrupted = 0;
void s_signal_handler(int) { s_interrupted = 1; }
void s_catch_signals() {
struct sigaction action;
action.sa_handler = s_signal_handler;
action.sa_flags = 0;
sigemptyset(&action.sa_mask);
sigaction(SIGINT, &action, NULL);
sigaction(SIGTERM, &action, NULL);
}
std::string s_set_id(zmq::socket_t &socket) {
std::stringstream ss;
ss << std::hex << std::uppercase << std::setw(4) << std::setfill('0') << within(0x10000)
<< "-" << std::setw(4) << std::setfill('0') << within(0x10000);
socket.setsockopt(ZMQ_IDENTITY, ss.str().c_str(), ss.str().length());
return ss.str();
}
}
|
487b977ee1e6120dbbf09160b5f32f3ec09c43f3
|
511589c7e8141d54feb45903d18cc35a57d06380
|
/Stora Spel/Network API/src/NetAPI/socket/server.cpp
|
a4796dd6d4c2ec8335754888bf9d3a4ac5802eac
|
[] |
no_license
|
Trisslotten/robotligan
|
0616f0977ceb791b1482e53953613f76059e42ff
|
ca1165e2d66b67d3b88087de3775316a7d2bf05a
|
refs/heads/master
| 2021-10-13T02:03:24.256759
| 2021-10-11T20:18:24
| 2021-10-11T20:18:24
| 227,684,184
| 14
| 2
| null | null | null | null |
ISO-8859-1
|
C++
| false
| false
| 7,491
|
cpp
|
server.cpp
|
#include <NetAPI/socket/server.hpp>
#include <iostream>
#include <string>
using namespace std::chrono_literals;
void NetAPI::Socket::Server::ClearPackets(NetAPI::Socket::ClientData* data) {
data->packets.clear();
}
void NetAPI::Socket::Server::SendPing() {
NetAPI::Common::Packet to_send;
to_send.GetHeader()->packet_id = NetAPI::Socket::EVERYONE;
int random_number = -1 + std::rand() % ((-1000 - 1) + 1);
to_send << random_number << PacketBlockType::PING;
this->SendToAll(to_send);
}
void NetAPI::Socket::Server::HandleClientPacket() {
// std::pair<const long, NetAPI::Socket::ClientData *> s
}
void NetAPI::Socket::Server::Receive() {
for (auto& c : client_data_) {
if (c.second && !c.second->client.IsConnected() && c.second->is_active) {
std::cout << "DEBUG: removing client, lstrecvlen="
<< c.second->client.GetRaw()->GetLastRecvLen()
<< ", isConnected=" << c.second->client.IsConnected() << "\n";
c.second->client.SetDisconnected(true);
c.second->client.Disconnect();
c.second->is_active = false;
// connected_players_--;
continue;
}
if (c.second && c.second->client.IsConnected()) {
int num_packets = 0;
for (auto& packet : c.second->client.Receive()) {
num_packets++;
if (!packet.IsEmpty()) {
c.second->packets.push_back(packet);
}
}
}
}
}
void NetAPI::Socket::Server::ListenForClients() {
newly_connected_.clear();
// Accept client
if (!connection_client_) {
connection_client_ = new ClientData();
}
auto s = listener_.Accept(connection_client_->client.GetRaw());
bool accepted = false;
if (s) {
sockaddr_in client_addr{};
int size = sizeof(client_addr);
auto ret =
getpeername(connection_client_->client.GetRaw()->GetLowLevelSocket(),
(sockaddr*)&client_addr, &size);
char buffer[14];
inet_ntop(AF_INET, &client_addr.sin_addr, buffer, 14);
auto addr = buffer;
auto port = ntohs(client_addr.sin_port);
std::string address;
if (kEnableReconnect) {
// För att kunna reconnecta till pågående match,
// address = addr;
} else {
// för att kunna testa många klienter
address = addr + (":" + std::to_string(port));
}
// std::string address = "";
std::cout << "DEBUG: tcp connection accepted: "
<< addr + (":" + std::to_string(port)) << "\n";
auto packets = connection_client_->client.Receive();
for (auto& packet : packets) {
int16_t block_type = -1;
packet >> block_type;
if (block_type == PacketBlockType::HWID) {
size_t size;
packet >> size;
std::string str;
str.resize(size);
packet.Remove(str.data(), size);
if(kEnableReconnect) {
address = str; // Kommentera ut detta om du vill debugga två
}
// instanser
break;
}
}
std::cout << "Client ID: " << address << std::endl;
if (address == "") {
accepted = false;
int can_join = -3;
NetAPI::Common::Packet p;
p << can_join << PacketBlockType::SERVER_CAN_JOIN;
connection_client_->client.Send(p);
connection_client_->client.Disconnect();
connection_client_->is_active = false;
connection_client_ = nullptr;
return;
}
connection_client_->packets.clear();
auto find_res = ids_.find(address);
// if already found
if (find_res != ids_.end()) {
accepted = true;
auto client_data = client_data_[find_res->second];
client_data->client.Disconnect();
delete client_data;
connection_client_->ID = find_res->second;
connection_client_->reconnected = true;
client_data_[find_res->second] = connection_client_;
std::cout << "DEBUG: Found existing client, overwriting\n";
} else if (GetNumConnected() < max_players_) {
std::cout << "DEBUG: adding new client\n";
connection_client_->ID = current_client_guid_;
ids_[address] = current_client_guid_;
ids_rev_[current_client_guid_] = address;
client_data_[current_client_guid_] = connection_client_;
//connected_players_++;
//game_players_++;
current_client_guid_++;
accepted = true;
} else {
std::cout << "DEBUG: Server full, disconnecting" << std::endl;
NetAPI::Common::Packet p;
int canJoin = -2;
p << canJoin << PacketBlockType::SERVER_CAN_JOIN;
connection_client_->client.Send(p);
}
if (accepted) {
int can_join = 2;
NetAPI::Common::Packet p;
p << can_join << PacketBlockType::SERVER_CAN_JOIN;
connection_client_->client.Send(p);
connection_client_->address = address;
connection_client_->is_active = true;
newly_connected_.push_back(connection_client_);
} else {
int can_join = -2;
NetAPI::Common::Packet p;
p << can_join << PacketBlockType::SERVER_CAN_JOIN;
}
connection_client_ = nullptr;
}
}
void NetAPI::Socket::Server::SendStoredData() {
SendPing();
NetAPI::Common::PacketHeader header;
for (auto& d : data_to_send_) {
d >> header;
if (header.receiver == EVERYONE) {
for (auto& cli : client_data_) {
cli.second->client.Send(d);
}
} else {
auto result = client_data_.find(header.receiver);
if (result != client_data_.end()) {
auto c = client_data_[header.receiver];
c->client.Send(d);
}
}
}
data_to_send_.clear();
}
unsigned short getHashedID(char* addr, unsigned short port) {
unsigned short retval = 0;
std::string s(addr);
for (auto c : s) {
retval += (unsigned int)c;
}
return retval;
}
bool NetAPI::Socket::Server::Setup(unsigned short port,
unsigned short maxplayers) {
if (!setup_) {
if (listener_.Bind(port)) {
setup_ = true;
std::cout << "Server bound at port: " << port << std::endl;
}
client_data_.reserve(maxplayers);
max_players_ = maxplayers;
}
return setup_;
}
bool NetAPI::Socket::Server::Update() {
if (!setup_) {
return false;
}
ListenForClients();
// Receive Data
Receive();
// Send Data
SendStoredData();
// CHECK DC
//for (auto& [id, client_data] : client_data_) {
// if (client_data->client.TimeSinceLastUpdate() > 3000) {
// client_data->client.Disconnect();
// }
//}
for(auto client_id : client_to_remove_) {
//std::cout << "!!!!!!!!!!!!!!!! Remove client: " << client_id << "\n";
client_data_.erase(client_id);
}
client_to_remove_.clear();
return true;
}
void NetAPI::Socket::Server::SendToAll(const char* data, size_t len) {
data_to_send_.push_back(NetAPI::Common::Packet(data, len));
}
void NetAPI::Socket::Server::SendToAll(NetAPI::Common::Packet& p) {
data_to_send_.push_back(p);
}
void NetAPI::Socket::Server::Send(unsigned id, const char* data, size_t len) {
NetAPI::Common::Packet p(data, len);
NetAPI::Common::PacketHeader h;
h.receiver = id;
p << h;
Send(p);
}
void NetAPI::Socket::Server::Send(NetAPI::Common::Packet& p) {
data_to_send_.push_back(p);
}
bool NetAPI::Socket::Server::KickPlayer(long ID) {
auto id_res = ids_rev_.find(ID);
if(id_res != ids_rev_.end()) {
ids_.erase(id_res->second);
ids_rev_.erase(id_res);
}
auto it = client_data_.find(ID);
if (it != client_data_.end()) {
client_to_remove_.push_back(ID);
return true;
} else {
return false;
}
}
|
88b0c2dd64ca8d0c5744f8c320917daa8b4e3141
|
5c18374f3f2fd48fa0f029183910eec54373b63c
|
/Geometry/Line/IsTwoSegmentsIntersect.cpp
|
3921220b6a2a4d0d11891dc883cb8c151290367a
|
[] |
no_license
|
nguyenchiemminhvu/Algorithms
|
f65984e903a8ebd64fad5ad2069d2a6a019440df
|
88359a31097ebea7e76588b0c2a42880c64d1aba
|
refs/heads/master
| 2021-08-17T00:20:26.661854
| 2021-07-03T00:46:51
| 2021-07-03T00:46:51
| 274,611,559
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,721
|
cpp
|
IsTwoSegmentsIntersect.cpp
|
/*
https://www.geeksforgeeks.org/check-if-two-given-line-segments-intersect/
Given two line segments (p1, q1) and (p2, q2), find if the given line segments intersect with each other.
*/
#include <iostream>
using namespace std;
struct Point
{
float _x;
float _y;
Point(float x = 0, float y = 0)
: _x(x), _y(y)
{
}
void Print()
{
std::cout << "(" << _x << ", " << _y << ")" << std::endl;
}
};
int Orientation(Point a, Point b, Point c)
{
int val = (b._y - a._y) * (c._x - b._x) - (c._y - b._y) * (b._x - a._x);
if (val == 0)
return 0;
return (val > 0) ? 1 : -1;
}
bool IsIntersecting(Point& p1, Point& p2, Point& q1, Point& q2)
{
int o1, o2, o3, o4;
o1 = Orientation(p1, p2, q1);
o2 = Orientation(p1, p2, q2);
o3 = Orientation(q1, q2, p1);
o4 = Orientation(q1, q2, p2);
if (o1 != o2 && o3 != o4)
return true;
return o1 * o2 < 0 && o3 * o4 < 0;
}
int main()
{
Point p1 = {1, 1}, p2 = {10, 1};
Point q1 = {1, 2}, q2 = {10, 2};
if (IsIntersecting(p1, p2, q1, q2))
std::cout << "Two segments intersect" << std::endl;
else
std::cout << "Two segments don't intersect" << std::endl;
p1 = {10, 0}, p2 = {0, 10};
q1 = {0, 0}, q2 = {10, 10};
if (IsIntersecting(p1, p2, q1, q2))
std::cout << "Two segments intersect" << std::endl;
else
std::cout << "Two segments don't intersect" << std::endl;
p1 = {-5, -5}, p2 = {0, 0};
q1 = {1, 1}, q2 = {10, 10};
if (IsIntersecting(p1, p2, q1, q2))
std::cout << "Two segments intersect" << std::endl;
else
std::cout << "Two segments don't intersect" << std::endl;
return 0;
}
|
fa29d2646ed9072f63b27aa29c81b098c37f604e
|
a19ec1048939a9b06617ea52a516bfc230abdc72
|
/EventHandler.h
|
7a8af5688031f3488d1922ad8409b8e495374b3d
|
[] |
no_license
|
natelearnscode/FPSGame
|
c77a50a02b77e971b91ceea233d3031c5c5220fe
|
d260f7e3b4aaf8e9aeafa9d26a24b395ba90fd3a
|
refs/heads/master
| 2023-03-30T18:19:52.868835
| 2021-04-17T04:01:54
| 2021-04-17T04:01:54
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,732
|
h
|
EventHandler.h
|
#include <SDL.h>
#ifndef EVENTHANDLER_H
#define EVENTHANDLER_H
//An event handler to handle SDL Events such as keyboard and mouse inputs
class EventHandler {
public:
bool moveForward;
bool moveBackward;
bool moveLeft;
bool moveRight;
bool isJumping;
int mouseXPos;
int mouseYPos;
EventHandler() : moveForward(false), moveBackward(false), moveLeft(false), moveRight(false), isJumping(false) {};
void handleEvent(SDL_Event e) {
isJumping = false;
//Check key down events to set flags for if the character should move in a direction
if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_w) { //If "w" is pressed
moveForward = true;
}
if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_s) { //If "s" is pressed
moveBackward = true;
}
if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_a) { //If "a" is pressed
moveLeft = true;
}
if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_d) { //If "d" is pressed
moveRight = true;
}
//Check key up events to set flags for if the character should stop moving in a direction
if (e.type == SDL_KEYUP && e.key.keysym.sym == SDLK_w) { //If "w" is released
moveForward = false;
}
if (e.type == SDL_KEYUP && e.key.keysym.sym == SDLK_s) { //If "s" is released
moveBackward = false;
}
if (e.type == SDL_KEYUP && e.key.keysym.sym == SDLK_a) { //If "a" is released
moveLeft = false;
}
if (e.type == SDL_KEYUP && e.key.keysym.sym == SDLK_d) { //If "d" is released
moveRight = false;
}
if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_SPACE) { //If spacebar is pressed
isJumping = true;
}
//Check mouse event
if (e.type == SDL_MOUSEMOTION) {
SDL_GetMouseState(&mouseXPos,&mouseYPos);
}
};
};
#endif
|
132f7e52e9fd1bccf1c1db2db9437433395eb94d
|
5238164634278e5b4866de0381387ebab907932b
|
/src/render/software_device.h
|
456108ed2a09673ea212e8b60a5c2b8bfd24737b
|
[] |
no_license
|
mimir-d/qkamber
|
dfaf96af7ebe7fc0a26f794776facd906f907d39
|
0467309923910118b280db2c7810d08b9ae75302
|
refs/heads/master
| 2021-12-01T02:24:35.949486
| 2021-11-24T01:36:57
| 2021-11-24T01:39:56
| 88,165,162
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,800
|
h
|
software_device.h
|
#pragma once
#include "render_system.h"
#include "material.h"
#include "scene/light.h"
#include "math3.h"
#include "misc.h"
struct RenderPrimitive;
class VertexDecl;
class VertexBuffer;
class IndexBuffer;
namespace detail
{
struct make_mvp
{
mat4 operator()(const mat4& world, const mat4& view, const mat4& proj) const
{
return proj * view * world;
}
};
struct make_mv
{
mat4 operator()(const mat4& world, const mat4& view) const
{
return view * world;
}
};
struct make_normal
{
mat3 operator()(const mat4& view_inv, const mat4& world_inv) const
{
return mat3{ (world_inv * view_inv).transpose() };
}
};
constexpr size_t SOFTWARE_TEXTURE_COUNT = 2;
constexpr size_t SOFTWARE_LIGHT_COUNT = 2;
}
class SoftwareDevice : public RenderDevice
{
protected:
class SoftwareParams : public Params
{
public:
SoftwareParams() = default;
SoftwareParams(const SoftwareParams&) = delete;
~SoftwareParams() = default;
public:
void set_world_matrix(mat4 world_matrix) final;
void set_view_matrix(mat4 view_matrix) final;
void set_proj_matrix(mat4 proj_matrix) final;
void set_clip_matrix(mat3x4 clip_matrix) final;
void set_world_inv_matrix(mat4 world_inv_matrix) final;
void set_view_inv_matrix(mat4 view_inv_matrix) final;
void set_material(const Material& material) final;
public:
const mat4& get_world_matrix() const;
const mat4& get_view_matrix() const;
const mat4& get_proj_matrix() const;
const mat3x4& get_clip_matrix() const;
const mat4& get_mv_matrix();
const mat4& get_mvp_matrix();
const mat3& get_normal_matrix();
const mat4& get_world_inv_matrix() const;
const mat4& get_view_inv_matrix() const;
const Color& get_material_ambient() const;
const Color& get_material_diffuse() const;
const Color& get_material_specular() const;
const Color& get_material_emissive() const;
float get_material_shininess() const;
bool get_material_lighting() const;
private:
mat4 m_world_matrix, m_world_inv_matrix;
mat4 m_view_matrix, m_view_inv_matrix;
mat4 m_proj_matrix;
mat3x4 m_clip_matrix;
Color m_material_ambient;
Color m_material_diffuse;
Color m_material_specular;
Color m_material_emissive;
float m_material_shininess = 0.0f;
bool m_material_lighting = false;
// computed stuff
dirty_t<mat4, detail::make_mv> m_mv_matrix = { m_world_matrix, m_view_matrix };
dirty_t<mat4, detail::make_mvp> m_mvp_matrix = { m_world_matrix, m_view_matrix, m_proj_matrix };
dirty_t<mat3, detail::make_normal> m_normal_matrix = { m_view_inv_matrix, m_world_inv_matrix };
};
struct DevicePoint
{
vec4 position;
optional_t<vec3> view_position;
optional_t<vec3> view_normal;
optional_t<Color> color;
optional_t<vec2> texcoord;
};
public:
SoftwareDevice();
~SoftwareDevice() = default;
public:
// drawing methods
void draw_primitive(const RenderPrimitive& primitive) final;
// device state methods
void set_polygon_mode(PolygonMode mode) final;
void set_render_target(RenderTarget* target) override;
void set_texture_unit(size_t index, const Texture* texture) final;
void set_light_unit(size_t index, const Light* light) final;
Params& get_params() final;
// resource management methods
std::unique_ptr<VertexBuffer> create_vertex_buffer(std::unique_ptr<VertexDecl> decl, size_t count) final;
std::unique_ptr<IndexBuffer> create_index_buffer(size_t count) final;
std::unique_ptr<Texture> create_texture(size_t width, size_t height, PixelFormat format) final;
// capabilities methods
size_t get_texture_unit_count() const final;
size_t get_light_unit_count() const final;
// debug
void debug_normals(bool enable);
protected:
void draw_tri(const DevicePoint& p0, const DevicePoint& p1, const DevicePoint& p2);
// TODO: these 2 should also be software rendered
virtual void draw_points(const std::vector<DevicePoint>& points) = 0;
virtual void draw_lines(const std::vector<DevicePoint>& points) = 0;
void draw_fill(const DevicePoint& p0, const DevicePoint& p1, const DevicePoint& p2);
protected:
SoftwareParams m_params;
PolygonMode m_poly_mode = PolygonMode::Fill;
RenderTarget* m_render_target;
std::array<const Texture*, detail::SOFTWARE_TEXTURE_COUNT> m_texture_units;
std::array<vec3, detail::SOFTWARE_LIGHT_COUNT> m_light_view_positions;
std::array<const Light*, detail::SOFTWARE_LIGHT_COUNT> m_light_units;
std::unique_ptr<RenderTarget> m_null_target;
bool m_debug_normals = false;
};
///////////////////////////////////////////////////////////////////////////////
// SoftwareDevice::SoftwareState impl
///////////////////////////////////////////////////////////////////////////////
inline void SoftwareDevice::SoftwareParams::set_world_matrix(mat4 world_matrix)
{
m_world_matrix = world_matrix;
// TODO: encode the set_dirty inside operator=
m_mvp_matrix.set_dirty();
m_mv_matrix.set_dirty();
}
inline void SoftwareDevice::SoftwareParams::set_view_matrix(mat4 view_matrix)
{
m_view_matrix = view_matrix;
m_mvp_matrix.set_dirty();
m_mv_matrix.set_dirty();
}
inline void SoftwareDevice::SoftwareParams::set_proj_matrix(mat4 proj_matrix)
{
m_proj_matrix = proj_matrix;
m_mvp_matrix.set_dirty();
m_mv_matrix.set_dirty();
}
inline void SoftwareDevice::SoftwareParams::set_clip_matrix(mat3x4 clip_matrix)
{
m_clip_matrix = clip_matrix;
}
inline void SoftwareDevice::SoftwareParams::set_world_inv_matrix(mat4 world_inv_matrix)
{
m_world_inv_matrix = world_inv_matrix;
m_normal_matrix.set_dirty();
}
inline void SoftwareDevice::SoftwareParams::set_view_inv_matrix(mat4 view_inv_matrix)
{
m_view_inv_matrix = view_inv_matrix;
m_normal_matrix.set_dirty();
}
inline void SoftwareDevice::SoftwareParams::set_material(const Material& material)
{
m_material_ambient = material.get_ambient();
m_material_diffuse = material.get_diffuse();
m_material_specular = material.get_specular();
m_material_emissive = material.get_emissive();
m_material_shininess = material.get_shininess();
m_material_lighting = material.get_lighting_enable();
}
inline const mat4& SoftwareDevice::SoftwareParams::get_world_matrix() const
{
return m_world_matrix;
}
inline const mat4& SoftwareDevice::SoftwareParams::get_view_matrix() const
{
return m_view_matrix;
}
inline const mat4& SoftwareDevice::SoftwareParams::get_proj_matrix() const
{
return m_proj_matrix;
}
inline const mat3x4& SoftwareDevice::SoftwareParams::get_clip_matrix() const
{
return m_clip_matrix;
}
inline const mat4& SoftwareDevice::SoftwareParams::get_mv_matrix()
{
return m_mv_matrix.get();
}
inline const mat4& SoftwareDevice::SoftwareParams::get_mvp_matrix()
{
return m_mvp_matrix.get();
}
inline const mat3& SoftwareDevice::SoftwareParams::get_normal_matrix()
{
return m_normal_matrix.get();
}
inline const mat4& SoftwareDevice::SoftwareParams::get_world_inv_matrix() const
{
return m_world_inv_matrix;
}
inline const mat4& SoftwareDevice::SoftwareParams::get_view_inv_matrix() const
{
return m_view_inv_matrix;
}
inline const Color& SoftwareDevice::SoftwareParams::get_material_ambient() const
{
return m_material_ambient;
}
inline const Color& SoftwareDevice::SoftwareParams::get_material_diffuse() const
{
return m_material_diffuse;
}
inline const Color& SoftwareDevice::SoftwareParams::get_material_specular() const
{
return m_material_specular;
}
inline const Color& SoftwareDevice::SoftwareParams::get_material_emissive() const
{
return m_material_emissive;
}
inline float SoftwareDevice::SoftwareParams::get_material_shininess() const
{
return m_material_shininess;
}
inline bool SoftwareDevice::SoftwareParams::get_material_lighting() const
{
return m_material_lighting;
}
///////////////////////////////////////////////////////////////////////////////
// SoftwareDevice impl
///////////////////////////////////////////////////////////////////////////////
inline void SoftwareDevice::set_polygon_mode(PolygonMode mode)
{
m_poly_mode = mode;
}
inline void SoftwareDevice::set_render_target(RenderTarget* target)
{
flog();
if (!target)
{
m_render_target = m_null_target.get();
log_info("Set render target to null");
return;
}
m_render_target = target;
log_info("Set render target %#x", target);
}
inline void SoftwareDevice::set_texture_unit(size_t index, const Texture* texture)
{
if (index >= detail::SOFTWARE_TEXTURE_COUNT)
throw std::runtime_error("invalid texture unit index");
m_texture_units[index] = texture;
}
inline void SoftwareDevice::set_light_unit(size_t index, const Light* light)
{
if (index >= detail::SOFTWARE_LIGHT_COUNT)
throw std::runtime_error("invalid light unit index");
m_light_units[index] = light;
if (light)
m_light_view_positions[index] = vec3{ m_params.get_view_matrix() * light->get_position() };
}
inline RenderDevice::Params& SoftwareDevice::get_params()
{
return m_params;
}
inline size_t SoftwareDevice::get_texture_unit_count() const
{
return detail::SOFTWARE_TEXTURE_COUNT;
}
inline size_t SoftwareDevice::get_light_unit_count() const
{
return detail::SOFTWARE_LIGHT_COUNT;
}
inline void SoftwareDevice::debug_normals(bool enable)
{
m_debug_normals = enable;
}
|
5dceb54e162616c04c40339231144be89d8880f0
|
c62a32d47681e5a915df4f697d31d34e083e24b5
|
/app/src/main/jni/sumOf.cpp
|
aca4c8f5778346a1dbb98886492007bc62e15c18
|
[] |
no_license
|
Belife2012/MyApplication
|
0e3f1ca07bb72513300b168241c046b4ee2376e4
|
270eb9ae22f1803aaeac12c57a475a8eeb33b7bb
|
refs/heads/master
| 2020-04-08T13:10:21.225452
| 2018-11-27T18:15:40
| 2018-11-27T18:15:40
| 159,378,527
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 452
|
cpp
|
sumOf.cpp
|
#include <jni.h>
#include <string>
#include <sstream>
extern "C"
JNIEXPORT jstring JNICALL
Java_com_example_administrator_myapplication_MainActivity_sumof(
JNIEnv* env,
jobject, /* this */
jint x,
jint y) {
std::ostringstream sumChar;
int sum;
sum = x + y;
sumChar << sum;
std::string sumString = sumChar.str();
return env->NewStringUTF( (std::string("sumof x + y = ") + sumString).c_str() );
}
|
ba5c2837906042461cf79a1fa11e3b800e1e5570
|
5cbe916d73a7543f55b05668887d5b12cb479c17
|
/src/UnscentedTransform.h
|
e55eccdc4f55e389e3c6a48b80cffaf88ec43ce8
|
[] |
no_license
|
jcesic/cooperation_server
|
da8fa42cc151a687cdc18536952ce43c73300873
|
c2828922e005a7426b6d5e968a1cd42b195532f1
|
refs/heads/master
| 2021-01-18T08:52:23.474962
| 2017-08-15T10:42:05
| 2017-08-15T10:42:05
| 100,357,319
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,481
|
h
|
UnscentedTransform.h
|
/*
* UnscentedTransform.h
*
* Created on: Nov 17, 2009
* Author: andreja
*/
#ifndef UNSCENTEDTRANSFORM_H_
#define UNSCENTEDTRANSFORM_H_
#include <Eigen/Eigen>
#include <Eigen/Cholesky>
#include <ProcessDefinitions.h>
using namespace Eigen;
class UT {
public:
SE3Mappings SEMap;
int UTCovTranAnglesToAxis(StateVector& x, StateMat& Px, StateVector& y, StateMat& Py) {
int L = x.rows();
int nY = y.rows();
// tunable parameters
double alpha = 1e-3;
double ki = 0;
double beta = 2;
double lambda = pow(alpha,2)*(L+ki)-L; // scaling factor
double c = L+lambda; // scaling factor
VectorXd wm; wm.resize(2*L+1);
MatrixXd Wc; Wc.resize(2*L+1,2*L+1);
wm(0) = lambda/c;
int i;
for (i = 1; i < 2*L+1; i++)
wm(i) = 0.5/c;
Wc.setIdentity();
for (i = 0; i < 2*L+1; i++)
Wc(i,i) = wm(i);
Wc(0,0) += 1-pow(alpha,2)+beta;
c = sqrt(c);
MatrixXd Ls = Px.llt().matrixL();
MatrixXd Chol = c * Ls;
MatrixXd sigmaPoints(x.rows(),2*L+1);
sigmaPoints.block(0,0,x.rows(),x.cols()) = x;
for (i = 1; i <= L; i++)
sigmaPoints.block(0,i,x.rows(),x.cols()) = x + Chol.block(0, i-1, L, 1);
for (i = L+1; i < 2*L+1; i++)
sigmaPoints.block(0,i,x.rows(),x.cols()) = x - Chol.block(0, i-L-1, L, 1);
y.setZero();
MatrixXd tmpY(nY, 2*L+1);
for (i = 0; i < 2*L+1; i++) {
StateVector tmp_block = sigmaPoints.block(0, i, L, 1);
tmpY.block(0, i, nY, 1) = fUTCovTranAnglesToAxis(tmp_block);
y += wm(i)*tmpY.block(0, i, nY, 1);
}
for (i = 0; i < 2*L+1; i++)
tmpY.block(0, i, nY, 1) = tmpY.block(0, i, nY, 1) - y;
Py = tmpY * Wc* tmpY.transpose();
return 0;
}
StateVector fUTCovTranAnglesToAxis(StateVector &x) {
StateVector result;
TranVector angles = x.block(3,0,3,1);
TranVector t = x.block(0,0,3,1);
TranVector axis = SEMap.angle2axis(angles);
result.block(0,0,3,1) = t;
result.block(3,0,3,1) = axis;
return result;
}
int UTAnglesToAxis(TranVector& x, RotMat& Px, TranVector& y, RotMat& Py) {
int L = x.rows();
int nY = y.rows();
// tunable parameters
double alpha = 1e-3;
double ki = 0;
double beta = 2;
double lambda = pow(alpha,2)*(L+ki)-L; // scaling factor
double c = L+lambda; // scaling factor
VectorXd wm; wm.resize(2*L+1);
MatrixXd Wc; Wc.resize(2*L+1,2*L+1);
wm(0) = lambda/c;
int i;
for (i = 1; i < 2*L+1; i++)
wm(i) = 0.5/c;
Wc.setIdentity();
for (i = 0; i < 2*L+1; i++)
Wc(i,i) = wm(i);
Wc(0,0) += 1-pow(alpha,2)+beta;
c = sqrt(c);
MatrixXd Ls = Px.llt().matrixL();
MatrixXd Chol = c * Ls;
MatrixXd sigmaPoints(x.rows(),2*L+1);
sigmaPoints.block(0,0,x.rows(),x.cols()) = x;
for (i = 1; i <= L; i++)
sigmaPoints.block(0,i,x.rows(),x.cols()) = x + Chol.block(0, i-1, L, 1);
for (i = L+1; i < 2*L+1; i++)
sigmaPoints.block(0,i,x.rows(),x.cols()) = x - Chol.block(0, i-L-1, L, 1);
y.setZero();
MatrixXd tmpY(nY, 2*L+1);
for (i = 0; i < 2*L+1; i++) {
TranVector tmp_block = sigmaPoints.block(0, i, L, 1);
tmpY.block(0, i, nY, 1) = SEMap.angle2axis(tmp_block);
y += wm(i)*tmpY.block(0, i, nY, 1);
}
for (i = 0; i < 2*L+1; i++)
tmpY.block(0, i, nY, 1) = tmpY.block(0, i, nY, 1) - y;
Py = tmpY * Wc* tmpY.transpose();
return 0;
}
int UTGroupToAlgebra(StateVector& x, StateMat& Px, StateVector& y, StateMat& Py) {
int L = x.rows();
int nY = y.rows();
// tunable parameters
double alpha = 1e-3;
double ki = 0;
double beta = 2;
double lambda = pow(alpha,2)*(L+ki)-L; // scaling factor
double c = L+lambda; // scaling factor
VectorXd wm; wm.resize(2*L+1);
MatrixXd Wc; Wc.resize(2*L+1,2*L+1);
wm(0) = lambda/c;
int i;
for (i = 1; i < 2*L+1; i++)
wm(i) = 0.5/c;
Wc.setIdentity();
for (i = 0; i < 2*L+1; i++)
Wc(i,i) = wm(i);
Wc(0,0) += 1-pow(alpha,2)+beta;
c = sqrt(c);
MatrixXd Ls = Px.llt().matrixL();
MatrixXd Chol = c * Ls;
MatrixXd sigmaPoints(x.rows(),2*L+1);
sigmaPoints.block(0,0,x.rows(),x.cols()) = x;
for (i = 1; i <= L; i++)
sigmaPoints.block(0,i,x.rows(),x.cols()) = x + Chol.block(0, i-1, L, 1);
for (i = L+1; i < 2*L+1; i++)
sigmaPoints.block(0,i,x.rows(),x.cols()) = x - Chol.block(0, i-L-1, L, 1);
y.setZero();
MatrixXd tmpY(nY, 2*L+1);
for (i = 0; i < 2*L+1; i++) {
StateVector tmp_block = sigmaPoints.block(0, i, L, 1);
tmpY.block(0, i, nY, 1) = fUTGroupToAlgebra(tmp_block);
y += wm(i)*tmpY.block(0, i, nY, 1);
}
for (i = 0; i < 2*L+1; i++)
tmpY.block(0, i, nY, 1) = tmpY.block(0, i, nY, 1) - y;
Py = tmpY * Wc* tmpY.transpose();
return 0;
}
StateVector fUTGroupToAlgebra(StateVector &x) {
StateVector result;
TranVector angles = x.block(3,0,3,1);
TranVector t = x.block(0,0,3,1);
RotMat m_Rot = SEMap.angle2rot(angles);
SE3Mat x_G;
x_G.setIdentity();
x_G.block(0,0,3,3) = m_Rot;
x_G.block(0,3,3,1) = t;
result = SEMap.log(x_G);
return result;
}
/* int UTAlgebraToGroup(StateVector& x, StateMat& Px, StateVector& y, StateMat& Py) {
int L = x.rows();
int nY = y.rows();
// tunable parameters
double alpha = 1e-3;
double ki = 0;
double beta = 2;
double lambda = pow(alpha,2)*(L+ki)-L; // scaling factor
double c = L+lambda; // scaling factor
VectorXd wm; wm.resize(2*L+1);
MatrixXd Wc; Wc.resize(2*L+1,2*L+1);
wm(0) = lambda/c;
int i;
for (i = 1; i < 2*L+1; i++)
wm(i) = 0.5/c;
Wc.setIdentity();
for (i = 0; i < 2*L+1; i++)
Wc(i,i) = wm(i);
Wc(0,0) += 1-pow(alpha,2)+beta;
c = sqrt(c);
MatrixXd Ls = Px.llt().matrixL();
MatrixXd Chol = c * Ls;
MatrixXd sigmaPoints(x.rows(),2*L+1);
sigmaPoints.block(0,0,x.rows(),x.cols()) = x;
for (i = 1; i <= L; i++)
sigmaPoints.block(0,i,x.rows(),x.cols()) = x + Chol.block(0, i-1, L, 1);
for (i = L+1; i < 2*L+1; i++)
sigmaPoints.block(0,i,x.rows(),x.cols()) = x - Chol.block(0, i-L-1, L, 1);
y.setZero();
MatrixXd tmpY(nY, 2*L+1);
for (i = 0; i < 2*L+1; i++) {
StateVector tmp_block = sigmaPoints.block(0, i, L, 1);
tmpY.block(0, i, nY, 1) = fUTAlgebraToGroup(tmp_block);
y += wm(i)*tmpY.block(0, i, nY, 1);
}
for (i = 0; i < 2*L+1; i++)
tmpY.block(0, i, nY, 1) = tmpY.block(0, i, nY, 1) - y;
Py = tmpY * Wc* tmpY.transpose();
return 0;
}
StateVector fUTAlgebraToGroup(StateVector &x) {
StateVector result;
double fi = x(2,0);
result(0) =(x(0,0)*sin(fi)+x(1,0)*(-1+cos(fi)))/fi;
result(1) =(x(0,0)*(1-cos(fi))+x(1,0)*sin(fi))/fi;
result(2) = fi;
return result;
}*/
int UTPoseBetweenStates(VectorXd& x, MatrixXd& Px, StateVector& y, StateMat& Py, int dimPose) {
int L = x.rows();
int nY = y.rows();
// tunable parameters
double alpha = 1e-3;
double ki = 0;
double beta = 2;
double lambda = pow(alpha,2)*(L+ki)-L; // scaling factor
double c = L+lambda; // scaling factor
VectorXd wm; wm.resize(2*L+1);
MatrixXd Wc; Wc.resize(2*L+1,2*L+1);
wm(0) = lambda/c;
int i;
for (i = 1; i < 2*L+1; i++)
wm(i) = 0.5/c;
Wc.setIdentity();
for (i = 0; i < 2*L+1; i++)
Wc(i,i) = wm(i);
Wc(0,0) += 1-pow(alpha,2)+beta;
c = sqrt(c);
MatrixXd Ls = Px.llt().matrixL();
MatrixXd Chol = c * Ls;
MatrixXd sigmaPoints(x.rows(),2*L+1);
sigmaPoints.block(0,0,x.rows(),x.cols()) = x;
for (i = 1; i <= L; i++)
sigmaPoints.block(0,i,x.rows(),x.cols()) = x + Chol.block(0, i-1, L, 1);
for (i = L+1; i < 2*L+1; i++)
sigmaPoints.block(0,i,x.rows(),x.cols()) = x - Chol.block(0, i-L-1, L, 1);
y.setZero();
MatrixXd tmpY(nY, 2*L+1);
for (i = 0; i < 2*L+1; i++) {
VectorXd tmp_block = sigmaPoints.block(0, i, L, 1);
tmpY.block(0, i, nY, 1) = fUTPoseBetweenStates(tmp_block,dimPose);
y += wm(i)*tmpY.block(0, i, nY, 1);
}
for (i = 0; i < 2*L+1; i++)
tmpY.block(0, i, nY, 1) = tmpY.block(0, i, nY, 1) - y;
Py = tmpY * Wc* tmpY.transpose();
return 0;
}
StateVector fUTPoseBetweenStates(VectorXd &x,int dimPose) {
StateVector x_11,x_22, result;
SE3Mat x_11G, x_22G,x_12;
x_11 = x.block(0,0,dimPose,1);
x_22 = x.block(dimPose,0,dimPose,1);
x_11G = SEMap.exp(x_11);
x_22G = SEMap.exp(x_22);
x_12 = x_11G.inverse()*x_22G;
result = SEMap.logV(x_12);
return result;
}
int UTPoseBetweenCoop(VectorXd& x, MatrixXd& Px, StateVector& y, StateMat& Py, int dimPose) {
int L = x.rows();
int nY = y.rows();
// tunable parameters
double alpha = 1e-3;
double ki = 0;
double beta = 2;
double lambda = pow(alpha,2)*(L+ki)-L; // scaling factor
double c = L+lambda; // scaling factor
VectorXd wm; wm.resize(2*L+1);
MatrixXd Wc; Wc.resize(2*L+1,2*L+1);
wm(0) = lambda/c;
int i;
for (i = 1; i < 2*L+1; i++)
wm(i) = 0.5/c;
Wc.setIdentity();
for (i = 0; i < 2*L+1; i++)
Wc(i,i) = wm(i);
Wc(0,0) += 1-pow(alpha,2)+beta;
c = sqrt(c);
MatrixXd Ls = Px.llt().matrixL();
MatrixXd Chol = c * Ls;
MatrixXd sigmaPoints(x.rows(),2*L+1);
sigmaPoints.block(0,0,x.rows(),x.cols()) = x;
for (i = 1; i <= L; i++)
sigmaPoints.block(0,i,x.rows(),x.cols()) = x + Chol.block(0, i-1, L, 1);
for (i = L+1; i < 2*L+1; i++)
sigmaPoints.block(0,i,x.rows(),x.cols()) = x - Chol.block(0, i-L-1, L, 1);
y.setZero();
MatrixXd tmpY(nY, 2*L+1);
for (i = 0; i < 2*L+1; i++) {
VectorXd tmp_block = sigmaPoints.block(0, i, L, 1);
tmpY.block(0, i, nY, 1) = fUTPoseBetweenStates(tmp_block,dimPose);
y += wm(i)*tmpY.block(0, i, nY, 1);
}
for (i = 0; i < 2*L+1; i++)
tmpY.block(0, i, nY, 1) = tmpY.block(0, i, nY, 1) - y;
Py = tmpY * Wc* tmpY.transpose();
return 0;
}
StateVector fUTPoseBetweenCoop(VectorXd &x,int dimPose) {
StateVector x_11,x_22, result;
SE3Mat x_11G, x_22G,x_12;
x_11 = x.block(0,0,dimPose,1);
x_22 = x.block(dimPose,0,dimPose,1);
x_11G = SEMap.exp(x_11);
x_22G = SEMap.exp(x_22);
x_12 = x_11G.inverse()*x_22G;
result = SEMap.logV(x_12);
return result;
}
/* int UTPoseBetweenGroupStates(VectorXd& x, MatrixXd& Px, StateVector& y, StateMat& Py, int dimPose) {
int L = x.rows();
int nY = y.rows();
// tunable parameters
double alpha = 1e-3;
double ki = 0;
double beta = 2;
double lambda = pow(alpha,2)*(L+ki)-L; // scaling factor
double c = L+lambda; // scaling factor
VectorXd wm; wm.resize(2*L+1);
MatrixXd Wc; Wc.resize(2*L+1,2*L+1);
wm(0) = lambda/c;
int i;
for (i = 1; i < 2*L+1; i++)
wm(i) = 0.5/c;
Wc.setIdentity();
for (i = 0; i < 2*L+1; i++)
Wc(i,i) = wm(i);
Wc(0,0) += 1-pow(alpha,2)+beta;
c = sqrt(c);
MatrixXd Ls = Px.llt().matrixL();
MatrixXd Chol = c * Ls;
MatrixXd sigmaPoints(x.rows(),2*L+1);
sigmaPoints.block(0,0,x.rows(),x.cols()) = x;
for (i = 1; i <= L; i++)
sigmaPoints.block(0,i,x.rows(),x.cols()) = x + Chol.block(0, i-1, L, 1);
for (i = L+1; i < 2*L+1; i++)
sigmaPoints.block(0,i,x.rows(),x.cols()) = x - Chol.block(0, i-L-1, L, 1);
y.setZero();
MatrixXd tmpY(nY, 2*L+1);
for (i = 0; i < 2*L+1; i++) {
VectorXd tmp_block = sigmaPoints.block(0, i, L, 1);
tmpY.block(0, i, nY, 1) = fUTPoseBetweenGroupStates(tmp_block,dimPose);
y += wm(i)*tmpY.block(0, i, nY, 1);
}
for (i = 0; i < 2*L+1; i++)
tmpY.block(0, i, nY, 1) = tmpY.block(0, i, nY, 1) - y;
Py = tmpY * Wc* tmpY.transpose();
return 0;
}
StateVector fUTPoseBetweenGroupStates(VectorXd &x,int dimPose) {
StateVector x_11,x_22, result;
StateMat x_11G, x_22G,x_12;
x_11 = x.block(0,0,dimPose,1);
x_22 = x.block(dimPose,0,dimPose,1);
x_11G = SEMap.expV(x_11);
x_22G = SEMap.expV(x_22);
x_12 = x_11G.inverse()*x_22G;
result = SEMap.logV(x_12);
return result;
}*/
};
#endif /* UNSCENTEDTRANSFORM_H_ */
|
dd76115455ddcfcef484643cedda6343f05f9aa4
|
19b4aea6c829b272ae29692ccc51f9ab8dcf573f
|
/src/winrt/impl/Windows.UI.Input.Spatial.0.h
|
ab8b892be30d22d887331f11a9aad806d9260f18
|
[
"MIT"
] |
permissive
|
liquidboy/X
|
9665573b6e30dff8912ab64a8daf08f9f3176628
|
bf94a0af4dd06ab6c66027afdcda88eda0b4ae47
|
refs/heads/master
| 2022-12-10T17:41:15.490231
| 2021-12-07T01:31:38
| 2021-12-07T01:31:38
| 51,222,325
| 29
| 9
| null | 2021-08-04T21:30:44
| 2016-02-06T21:16:04
|
C++
|
UTF-8
|
C++
| false
| false
| 90,182
|
h
|
Windows.UI.Input.Spatial.0.h
|
// C++/WinRT v1.0.170906.1
// Copyright (c) 2017 Microsoft Corporation. All rights reserved.
#pragma once
WINRT_EXPORT namespace winrt::Windows::Devices::Haptics {
struct SimpleHapticsController;
}
WINRT_EXPORT namespace winrt::Windows::Perception {
struct PerceptionTimestamp;
}
WINRT_EXPORT namespace winrt::Windows::Perception::People {
struct HeadPose;
}
WINRT_EXPORT namespace winrt::Windows::Perception::Spatial {
struct SpatialCoordinateSystem;
}
WINRT_EXPORT namespace winrt::Windows::Storage::Streams {
struct IRandomAccessStreamWithContentType;
}
WINRT_EXPORT namespace winrt::Windows::UI::Input::Spatial {
enum class SpatialGestureSettings : uint32_t
{
None = 0x0,
Tap = 0x1,
DoubleTap = 0x2,
Hold = 0x4,
ManipulationTranslate = 0x8,
NavigationX = 0x10,
NavigationY = 0x20,
NavigationZ = 0x40,
NavigationRailsX = 0x80,
NavigationRailsY = 0x100,
NavigationRailsZ = 0x200,
};
enum class SpatialInteractionPressKind : int32_t
{
None = 0,
Select = 1,
Menu = 2,
Grasp = 3,
Touchpad = 4,
Thumbstick = 5,
};
enum class SpatialInteractionSourceHandedness : int32_t
{
Unspecified = 0,
Left = 1,
Right = 2,
};
enum class SpatialInteractionSourceKind : int32_t
{
Other = 0,
Hand = 1,
Voice = 2,
Controller = 3,
};
enum class SpatialInteractionSourcePositionAccuracy : int32_t
{
High = 0,
Approximate = 1,
};
struct ISpatialGestureRecognizer;
struct ISpatialGestureRecognizerFactory;
struct ISpatialHoldCanceledEventArgs;
struct ISpatialHoldCompletedEventArgs;
struct ISpatialHoldStartedEventArgs;
struct ISpatialInteraction;
struct ISpatialInteractionController;
struct ISpatialInteractionController2;
struct ISpatialInteractionControllerProperties;
struct ISpatialInteractionDetectedEventArgs;
struct ISpatialInteractionDetectedEventArgs2;
struct ISpatialInteractionManager;
struct ISpatialInteractionManagerStatics;
struct ISpatialInteractionSource;
struct ISpatialInteractionSource2;
struct ISpatialInteractionSource3;
struct ISpatialInteractionSourceEventArgs;
struct ISpatialInteractionSourceEventArgs2;
struct ISpatialInteractionSourceLocation;
struct ISpatialInteractionSourceLocation2;
struct ISpatialInteractionSourceLocation3;
struct ISpatialInteractionSourceProperties;
struct ISpatialInteractionSourceState;
struct ISpatialInteractionSourceState2;
struct ISpatialManipulationCanceledEventArgs;
struct ISpatialManipulationCompletedEventArgs;
struct ISpatialManipulationDelta;
struct ISpatialManipulationStartedEventArgs;
struct ISpatialManipulationUpdatedEventArgs;
struct ISpatialNavigationCanceledEventArgs;
struct ISpatialNavigationCompletedEventArgs;
struct ISpatialNavigationStartedEventArgs;
struct ISpatialNavigationUpdatedEventArgs;
struct ISpatialPointerInteractionSourcePose;
struct ISpatialPointerInteractionSourcePose2;
struct ISpatialPointerPose;
struct ISpatialPointerPose2;
struct ISpatialPointerPoseStatics;
struct ISpatialRecognitionEndedEventArgs;
struct ISpatialRecognitionStartedEventArgs;
struct ISpatialTappedEventArgs;
struct SpatialGestureRecognizer;
struct SpatialHoldCanceledEventArgs;
struct SpatialHoldCompletedEventArgs;
struct SpatialHoldStartedEventArgs;
struct SpatialInteraction;
struct SpatialInteractionController;
struct SpatialInteractionControllerProperties;
struct SpatialInteractionDetectedEventArgs;
struct SpatialInteractionManager;
struct SpatialInteractionSource;
struct SpatialInteractionSourceEventArgs;
struct SpatialInteractionSourceLocation;
struct SpatialInteractionSourceProperties;
struct SpatialInteractionSourceState;
struct SpatialManipulationCanceledEventArgs;
struct SpatialManipulationCompletedEventArgs;
struct SpatialManipulationDelta;
struct SpatialManipulationStartedEventArgs;
struct SpatialManipulationUpdatedEventArgs;
struct SpatialNavigationCanceledEventArgs;
struct SpatialNavigationCompletedEventArgs;
struct SpatialNavigationStartedEventArgs;
struct SpatialNavigationUpdatedEventArgs;
struct SpatialPointerInteractionSourcePose;
struct SpatialPointerPose;
struct SpatialRecognitionEndedEventArgs;
struct SpatialRecognitionStartedEventArgs;
struct SpatialTappedEventArgs;
}
namespace winrt::impl {
template<> struct is_enum_flag<Windows::UI::Input::Spatial::SpatialGestureSettings> : std::true_type {};
template <> struct category<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialGestureRecognizerFactory>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialHoldCanceledEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialHoldCompletedEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialHoldStartedEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteraction>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionController>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionController2>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionControllerProperties>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionDetectedEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionDetectedEventArgs2>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionManager>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionManagerStatics>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionSource>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionSource2>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionSource3>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionSourceEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionSourceEventArgs2>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation2>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation3>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionSourceProperties>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionSourceState>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialInteractionSourceState2>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialManipulationCanceledEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialManipulationCompletedEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialManipulationDelta>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialManipulationStartedEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialManipulationUpdatedEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialNavigationCanceledEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialNavigationCompletedEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialNavigationStartedEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialNavigationUpdatedEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialPointerInteractionSourcePose>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialPointerInteractionSourcePose2>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialPointerPose>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialPointerPose2>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialPointerPoseStatics>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialRecognitionEndedEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialRecognitionStartedEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::ISpatialTappedEventArgs>{ using type = interface_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialGestureRecognizer>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialHoldCanceledEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialHoldCompletedEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialHoldStartedEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialInteraction>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialInteractionController>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialInteractionControllerProperties>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialInteractionDetectedEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialInteractionManager>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialInteractionSource>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialInteractionSourceEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialInteractionSourceLocation>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialInteractionSourceProperties>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialInteractionSourceState>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialManipulationCanceledEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialManipulationCompletedEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialManipulationDelta>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialManipulationStartedEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialManipulationUpdatedEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialNavigationCanceledEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialNavigationCompletedEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialNavigationStartedEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialNavigationUpdatedEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialPointerInteractionSourcePose>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialPointerPose>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialRecognitionEndedEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialRecognitionStartedEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialTappedEventArgs>{ using type = class_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialGestureSettings>{ using type = enum_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialInteractionPressKind>{ using type = enum_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialInteractionSourceHandedness>{ using type = enum_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialInteractionSourceKind>{ using type = enum_category; };
template <> struct category<Windows::UI::Input::Spatial::SpatialInteractionSourcePositionAccuracy>{ using type = enum_category; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialGestureRecognizer" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialGestureRecognizerFactory>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialGestureRecognizerFactory" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialHoldCanceledEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialHoldCanceledEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialHoldCompletedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialHoldCompletedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialHoldStartedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialHoldStartedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteraction>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteraction" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionController>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionController" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionController2>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionController2" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionControllerProperties>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionControllerProperties" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionDetectedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionDetectedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionDetectedEventArgs2>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionDetectedEventArgs2" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionManager>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionManager" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionManagerStatics>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionManagerStatics" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionSource>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionSource" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionSource2>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionSource2" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionSource3>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionSource3" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionSourceEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionSourceEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionSourceEventArgs2>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionSourceEventArgs2" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionSourceLocation" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation2>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionSourceLocation2" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation3>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionSourceLocation3" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionSourceProperties>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionSourceProperties" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionSourceState>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionSourceState" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialInteractionSourceState2>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialInteractionSourceState2" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialManipulationCanceledEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialManipulationCanceledEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialManipulationCompletedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialManipulationCompletedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialManipulationDelta>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialManipulationDelta" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialManipulationStartedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialManipulationStartedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialManipulationUpdatedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialManipulationUpdatedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialNavigationCanceledEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialNavigationCanceledEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialNavigationCompletedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialNavigationCompletedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialNavigationStartedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialNavigationStartedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialNavigationUpdatedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialNavigationUpdatedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialPointerInteractionSourcePose>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialPointerInteractionSourcePose" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialPointerInteractionSourcePose2>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialPointerInteractionSourcePose2" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialPointerPose>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialPointerPose" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialPointerPose2>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialPointerPose2" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialPointerPoseStatics>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialPointerPoseStatics" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialRecognitionEndedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialRecognitionEndedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialRecognitionStartedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialRecognitionStartedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::ISpatialTappedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.ISpatialTappedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialGestureRecognizer>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialGestureRecognizer" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialHoldCanceledEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialHoldCanceledEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialHoldCompletedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialHoldCompletedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialHoldStartedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialHoldStartedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialInteraction>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialInteraction" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialInteractionController>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialInteractionController" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialInteractionControllerProperties>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialInteractionControllerProperties" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialInteractionDetectedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialInteractionDetectedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialInteractionManager>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialInteractionManager" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialInteractionSource>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialInteractionSource" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialInteractionSourceEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialInteractionSourceEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialInteractionSourceLocation>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialInteractionSourceLocation" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialInteractionSourceProperties>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialInteractionSourceProperties" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialInteractionSourceState>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialInteractionSourceState" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialManipulationCanceledEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialManipulationCanceledEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialManipulationCompletedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialManipulationCompletedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialManipulationDelta>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialManipulationDelta" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialManipulationStartedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialManipulationStartedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialManipulationUpdatedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialManipulationUpdatedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialNavigationCanceledEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialNavigationCanceledEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialNavigationCompletedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialNavigationCompletedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialNavigationStartedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialNavigationStartedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialNavigationUpdatedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialNavigationUpdatedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialPointerInteractionSourcePose>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialPointerInteractionSourcePose" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialPointerPose>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialPointerPose" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialRecognitionEndedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialRecognitionEndedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialRecognitionStartedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialRecognitionStartedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialTappedEventArgs>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialTappedEventArgs" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialGestureSettings>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialGestureSettings" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialInteractionPressKind>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialInteractionPressKind" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialInteractionSourceHandedness>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialInteractionSourceHandedness" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialInteractionSourceKind>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialInteractionSourceKind" }; };
template <> struct name<Windows::UI::Input::Spatial::SpatialInteractionSourcePositionAccuracy>{ static constexpr auto & value{ L"Windows.UI.Input.Spatial.SpatialInteractionSourcePositionAccuracy" }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>{ static constexpr GUID value{ 0x71605BCC,0x0C35,0x4673,{ 0xAD,0xBD,0xCC,0x04,0xCA,0xA6,0xEF,0x45 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialGestureRecognizerFactory>{ static constexpr GUID value{ 0x77214186,0x57B9,0x3150,{ 0x83,0x82,0x69,0x8B,0x24,0xE2,0x64,0xD0 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialHoldCanceledEventArgs>{ static constexpr GUID value{ 0x5DFCB667,0x4CAA,0x4093,{ 0x8C,0x35,0xB6,0x01,0xA8,0x39,0xF3,0x1B } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialHoldCompletedEventArgs>{ static constexpr GUID value{ 0x3F64470B,0x4CFD,0x43DA,{ 0x8D,0xC4,0xE6,0x45,0x52,0x17,0x39,0x71 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialHoldStartedEventArgs>{ static constexpr GUID value{ 0x8E343D79,0xACB6,0x4144,{ 0x86,0x15,0x2C,0xFB,0xA8,0xA3,0xCB,0x3F } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteraction>{ static constexpr GUID value{ 0xFC967639,0x88E6,0x4646,{ 0x91,0x12,0x43,0x44,0xAA,0xEC,0x9D,0xFA } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionController>{ static constexpr GUID value{ 0x5F0E5BA3,0x0954,0x4E97,{ 0x86,0xC5,0xE7,0xF3,0x0B,0x11,0x4D,0xFD } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionController2>{ static constexpr GUID value{ 0x35B6D924,0xC7A2,0x49B7,{ 0xB7,0x2E,0x54,0x36,0xB2,0xFB,0x8F,0x9C } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionControllerProperties>{ static constexpr GUID value{ 0x61056FB1,0x7BA9,0x4E35,{ 0xB9,0x3F,0x92,0x72,0xCB,0xA9,0xB2,0x8B } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionDetectedEventArgs>{ static constexpr GUID value{ 0x075878E4,0x5961,0x3B41,{ 0x9D,0xFB,0xCE,0xA5,0xD8,0x9C,0xC3,0x8A } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionDetectedEventArgs2>{ static constexpr GUID value{ 0x7B263E93,0x5F13,0x419C,{ 0x97,0xD5,0x83,0x46,0x78,0x26,0x6A,0xA6 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionManager>{ static constexpr GUID value{ 0x32A64EA8,0xA15A,0x3995,{ 0xB8,0xBD,0x80,0x51,0x3C,0xB5,0xAD,0xEF } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionManagerStatics>{ static constexpr GUID value{ 0x00E31FA6,0x8CA2,0x30BF,{ 0x91,0xFE,0xD9,0xCB,0x4A,0x00,0x89,0x90 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionSource>{ static constexpr GUID value{ 0xFB5433BA,0xB0B3,0x3148,{ 0x9F,0x3B,0xE9,0xF5,0xDE,0x56,0x8F,0x5D } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionSource2>{ static constexpr GUID value{ 0xE4C5B70C,0x0470,0x4028,{ 0x88,0xC0,0xA0,0xEB,0x44,0xD3,0x4E,0xFE } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionSource3>{ static constexpr GUID value{ 0x0406D9F9,0x9AFD,0x44F9,{ 0x85,0xDC,0x70,0x00,0x23,0xA9,0x62,0xE3 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionSourceEventArgs>{ static constexpr GUID value{ 0x23B786CF,0xEC23,0x3979,{ 0xB2,0x7C,0xEB,0x0E,0x12,0xFE,0xB7,0xC7 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionSourceEventArgs2>{ static constexpr GUID value{ 0xD8B4B467,0xE648,0x4D52,{ 0xAB,0x49,0xE0,0xD2,0x27,0x19,0x9F,0x63 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation>{ static constexpr GUID value{ 0xEA4696C4,0x7E8B,0x30CA,{ 0xBC,0xC5,0xC7,0x71,0x89,0xCE,0xA3,0x0A } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation2>{ static constexpr GUID value{ 0x4C671045,0x3917,0x40FC,{ 0xA9,0xAC,0x31,0xC9,0xCF,0x5F,0xF9,0x1B } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation3>{ static constexpr GUID value{ 0x6702E65E,0xE915,0x4CFB,{ 0x9C,0x1B,0x05,0x38,0xEF,0xC8,0x66,0x87 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionSourceProperties>{ static constexpr GUID value{ 0x05604542,0x3EF7,0x3222,{ 0x9F,0x53,0x63,0xC9,0xCB,0x7E,0x3B,0xC7 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionSourceState>{ static constexpr GUID value{ 0xD5C475EF,0x4B63,0x37EC,{ 0x98,0xB9,0x9F,0xC6,0x52,0xB9,0xD2,0xF2 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialInteractionSourceState2>{ static constexpr GUID value{ 0x45F6D0BD,0x1773,0x492E,{ 0x9B,0xA3,0x8A,0xC1,0xCB,0xE7,0x7C,0x08 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialManipulationCanceledEventArgs>{ static constexpr GUID value{ 0x2D40D1CB,0xE7DA,0x4220,{ 0xB0,0xBF,0x81,0x93,0x01,0x67,0x47,0x80 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialManipulationCompletedEventArgs>{ static constexpr GUID value{ 0x05086802,0xF301,0x4343,{ 0x92,0x50,0x2F,0xBA,0xA5,0xF8,0x7A,0x37 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialManipulationDelta>{ static constexpr GUID value{ 0xA7EC967A,0xD123,0x3A81,{ 0xA1,0x5B,0x99,0x29,0x23,0xDC,0xBE,0x91 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialManipulationStartedEventArgs>{ static constexpr GUID value{ 0xA1D6BBCE,0x42A5,0x377B,{ 0xAD,0xA6,0xD2,0x8E,0x3D,0x38,0x47,0x37 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialManipulationUpdatedEventArgs>{ static constexpr GUID value{ 0x5F230B9B,0x60C6,0x4DC6,{ 0xBD,0xC9,0x9F,0x4A,0x6F,0x15,0xFE,0x49 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialNavigationCanceledEventArgs>{ static constexpr GUID value{ 0xCE503EDC,0xE8A5,0x46F0,{ 0x92,0xD4,0x3C,0x12,0x2B,0x35,0x11,0x2A } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialNavigationCompletedEventArgs>{ static constexpr GUID value{ 0x012E80B7,0xAF3B,0x42C2,{ 0x9E,0x41,0xBA,0xAA,0x0E,0x72,0x1F,0x3A } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialNavigationStartedEventArgs>{ static constexpr GUID value{ 0x754A348A,0xFB64,0x4656,{ 0x8E,0xBD,0x9D,0xEE,0xCA,0xAF,0xE4,0x75 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialNavigationUpdatedEventArgs>{ static constexpr GUID value{ 0x9B713FD7,0x839D,0x4A74,{ 0x87,0x32,0x45,0x46,0x6F,0xC0,0x44,0xB5 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialPointerInteractionSourcePose>{ static constexpr GUID value{ 0xA7104307,0x2C2B,0x4D3A,{ 0x92,0xA7,0x80,0xCE,0xD7,0xC4,0xA0,0xD0 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialPointerInteractionSourcePose2>{ static constexpr GUID value{ 0xECCD86B8,0x52DB,0x469F,{ 0x9E,0x3F,0x80,0xC4,0x7F,0x74,0xBC,0xE9 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialPointerPose>{ static constexpr GUID value{ 0x6953A42E,0xC17E,0x357D,{ 0x97,0xA1,0x72,0x69,0xD0,0xED,0x2D,0x10 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialPointerPose2>{ static constexpr GUID value{ 0x9D202B17,0x954E,0x4E0C,{ 0x96,0xD1,0xB6,0x79,0x0B,0x6F,0xC2,0xFD } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialPointerPoseStatics>{ static constexpr GUID value{ 0xA25591A9,0xACA1,0x3EE0,{ 0x98,0x16,0x78,0x5C,0xFB,0x2E,0x3F,0xB8 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialRecognitionEndedEventArgs>{ static constexpr GUID value{ 0x0E35F5CB,0x3F75,0x43F3,{ 0xAC,0x81,0xD1,0xDC,0x2D,0xF9,0xB1,0xFB } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialRecognitionStartedEventArgs>{ static constexpr GUID value{ 0x24DA128F,0x0008,0x4A6D,{ 0xAA,0x50,0x2A,0x76,0xF9,0xCF,0xB2,0x64 } }; };
template <> struct guid<Windows::UI::Input::Spatial::ISpatialTappedEventArgs>{ static constexpr GUID value{ 0x296D83DE,0xF444,0x4AA1,{ 0xB2,0xBF,0x9D,0xC8,0x8D,0x56,0x7D,0xA6 } }; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialGestureRecognizer>{ using type = Windows::UI::Input::Spatial::ISpatialGestureRecognizer; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialHoldCanceledEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialHoldCanceledEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialHoldCompletedEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialHoldCompletedEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialHoldStartedEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialHoldStartedEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialInteraction>{ using type = Windows::UI::Input::Spatial::ISpatialInteraction; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialInteractionController>{ using type = Windows::UI::Input::Spatial::ISpatialInteractionController; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialInteractionControllerProperties>{ using type = Windows::UI::Input::Spatial::ISpatialInteractionControllerProperties; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialInteractionDetectedEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialInteractionDetectedEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialInteractionManager>{ using type = Windows::UI::Input::Spatial::ISpatialInteractionManager; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialInteractionSource>{ using type = Windows::UI::Input::Spatial::ISpatialInteractionSource; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialInteractionSourceEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialInteractionSourceEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialInteractionSourceLocation>{ using type = Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialInteractionSourceProperties>{ using type = Windows::UI::Input::Spatial::ISpatialInteractionSourceProperties; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialInteractionSourceState>{ using type = Windows::UI::Input::Spatial::ISpatialInteractionSourceState; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialManipulationCanceledEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialManipulationCanceledEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialManipulationCompletedEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialManipulationCompletedEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialManipulationDelta>{ using type = Windows::UI::Input::Spatial::ISpatialManipulationDelta; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialManipulationStartedEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialManipulationStartedEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialManipulationUpdatedEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialManipulationUpdatedEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialNavigationCanceledEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialNavigationCanceledEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialNavigationCompletedEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialNavigationCompletedEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialNavigationStartedEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialNavigationStartedEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialNavigationUpdatedEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialNavigationUpdatedEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialPointerInteractionSourcePose>{ using type = Windows::UI::Input::Spatial::ISpatialPointerInteractionSourcePose; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialPointerPose>{ using type = Windows::UI::Input::Spatial::ISpatialPointerPose; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialRecognitionEndedEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialRecognitionEndedEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialRecognitionStartedEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialRecognitionStartedEventArgs; };
template <> struct default_interface<Windows::UI::Input::Spatial::SpatialTappedEventArgs>{ using type = Windows::UI::Input::Spatial::ISpatialTappedEventArgs; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialGestureRecognizer
{
event_token RecognitionStarted(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialRecognitionStartedEventArgs> const& handler) const;
using RecognitionStarted_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>;
RecognitionStarted_revoker RecognitionStarted(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialRecognitionStartedEventArgs> const& handler) const;
void RecognitionStarted(event_token const& token) const;
event_token RecognitionEnded(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialRecognitionEndedEventArgs> const& handler) const;
using RecognitionEnded_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>;
RecognitionEnded_revoker RecognitionEnded(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialRecognitionEndedEventArgs> const& handler) const;
void RecognitionEnded(event_token const& token) const;
event_token Tapped(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialTappedEventArgs> const& handler) const;
using Tapped_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>;
Tapped_revoker Tapped(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialTappedEventArgs> const& handler) const;
void Tapped(event_token const& token) const;
event_token HoldStarted(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialHoldStartedEventArgs> const& handler) const;
using HoldStarted_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>;
HoldStarted_revoker HoldStarted(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialHoldStartedEventArgs> const& handler) const;
void HoldStarted(event_token const& token) const;
event_token HoldCompleted(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialHoldCompletedEventArgs> const& handler) const;
using HoldCompleted_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>;
HoldCompleted_revoker HoldCompleted(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialHoldCompletedEventArgs> const& handler) const;
void HoldCompleted(event_token const& token) const;
event_token HoldCanceled(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialHoldCanceledEventArgs> const& handler) const;
using HoldCanceled_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>;
HoldCanceled_revoker HoldCanceled(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialHoldCanceledEventArgs> const& handler) const;
void HoldCanceled(event_token const& token) const;
event_token ManipulationStarted(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialManipulationStartedEventArgs> const& handler) const;
using ManipulationStarted_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>;
ManipulationStarted_revoker ManipulationStarted(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialManipulationStartedEventArgs> const& handler) const;
void ManipulationStarted(event_token const& token) const;
event_token ManipulationUpdated(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialManipulationUpdatedEventArgs> const& handler) const;
using ManipulationUpdated_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>;
ManipulationUpdated_revoker ManipulationUpdated(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialManipulationUpdatedEventArgs> const& handler) const;
void ManipulationUpdated(event_token const& token) const;
event_token ManipulationCompleted(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialManipulationCompletedEventArgs> const& handler) const;
using ManipulationCompleted_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>;
ManipulationCompleted_revoker ManipulationCompleted(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialManipulationCompletedEventArgs> const& handler) const;
void ManipulationCompleted(event_token const& token) const;
event_token ManipulationCanceled(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialManipulationCanceledEventArgs> const& handler) const;
using ManipulationCanceled_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>;
ManipulationCanceled_revoker ManipulationCanceled(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialManipulationCanceledEventArgs> const& handler) const;
void ManipulationCanceled(event_token const& token) const;
event_token NavigationStarted(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialNavigationStartedEventArgs> const& handler) const;
using NavigationStarted_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>;
NavigationStarted_revoker NavigationStarted(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialNavigationStartedEventArgs> const& handler) const;
void NavigationStarted(event_token const& token) const;
event_token NavigationUpdated(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialNavigationUpdatedEventArgs> const& handler) const;
using NavigationUpdated_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>;
NavigationUpdated_revoker NavigationUpdated(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialNavigationUpdatedEventArgs> const& handler) const;
void NavigationUpdated(event_token const& token) const;
event_token NavigationCompleted(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialNavigationCompletedEventArgs> const& handler) const;
using NavigationCompleted_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>;
NavigationCompleted_revoker NavigationCompleted(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialNavigationCompletedEventArgs> const& handler) const;
void NavigationCompleted(event_token const& token) const;
event_token NavigationCanceled(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialNavigationCanceledEventArgs> const& handler) const;
using NavigationCanceled_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>;
NavigationCanceled_revoker NavigationCanceled(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialGestureRecognizer, Windows::UI::Input::Spatial::SpatialNavigationCanceledEventArgs> const& handler) const;
void NavigationCanceled(event_token const& token) const;
void CaptureInteraction(Windows::UI::Input::Spatial::SpatialInteraction const& interaction) const;
void CancelPendingGestures() const;
bool TrySetGestureSettings(Windows::UI::Input::Spatial::SpatialGestureSettings const& settings) const;
Windows::UI::Input::Spatial::SpatialGestureSettings GestureSettings() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialGestureRecognizer> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialGestureRecognizer<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialGestureRecognizerFactory
{
Windows::UI::Input::Spatial::SpatialGestureRecognizer Create(Windows::UI::Input::Spatial::SpatialGestureSettings const& settings) const;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialGestureRecognizerFactory> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialGestureRecognizerFactory<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialHoldCanceledEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialHoldCanceledEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialHoldCanceledEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialHoldCompletedEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialHoldCompletedEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialHoldCompletedEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialHoldStartedEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
Windows::UI::Input::Spatial::SpatialPointerPose TryGetPointerPose(Windows::Perception::Spatial::SpatialCoordinateSystem const& coordinateSystem) const;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialHoldStartedEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialHoldStartedEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteraction
{
Windows::UI::Input::Spatial::SpatialInteractionSourceState SourceState() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteraction> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteraction<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionController
{
bool HasTouchpad() const noexcept;
bool HasThumbstick() const noexcept;
Windows::Devices::Haptics::SimpleHapticsController SimpleHapticsController() const noexcept;
uint16_t VendorId() const noexcept;
uint16_t ProductId() const noexcept;
uint16_t Version() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionController> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionController<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionController2
{
Windows::Foundation::IAsyncOperation<Windows::Storage::Streams::IRandomAccessStreamWithContentType> TryGetRenderableModelAsync() const;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionController2> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionController2<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionControllerProperties
{
bool IsTouchpadTouched() const noexcept;
bool IsTouchpadPressed() const noexcept;
bool IsThumbstickPressed() const noexcept;
double ThumbstickX() const noexcept;
double ThumbstickY() const noexcept;
double TouchpadX() const noexcept;
double TouchpadY() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionControllerProperties> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionControllerProperties<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionDetectedEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
Windows::UI::Input::Spatial::SpatialPointerPose TryGetPointerPose(Windows::Perception::Spatial::SpatialCoordinateSystem const& coordinateSystem) const;
Windows::UI::Input::Spatial::SpatialInteraction Interaction() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionDetectedEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionDetectedEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionDetectedEventArgs2
{
Windows::UI::Input::Spatial::SpatialInteractionSource InteractionSource() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionDetectedEventArgs2> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionDetectedEventArgs2<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionManager
{
event_token SourceDetected(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialInteractionManager, Windows::UI::Input::Spatial::SpatialInteractionSourceEventArgs> const& handler) const;
using SourceDetected_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialInteractionManager>;
SourceDetected_revoker SourceDetected(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialInteractionManager, Windows::UI::Input::Spatial::SpatialInteractionSourceEventArgs> const& handler) const;
void SourceDetected(event_token const& token) const;
event_token SourceLost(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialInteractionManager, Windows::UI::Input::Spatial::SpatialInteractionSourceEventArgs> const& handler) const;
using SourceLost_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialInteractionManager>;
SourceLost_revoker SourceLost(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialInteractionManager, Windows::UI::Input::Spatial::SpatialInteractionSourceEventArgs> const& handler) const;
void SourceLost(event_token const& token) const;
event_token SourceUpdated(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialInteractionManager, Windows::UI::Input::Spatial::SpatialInteractionSourceEventArgs> const& handler) const;
using SourceUpdated_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialInteractionManager>;
SourceUpdated_revoker SourceUpdated(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialInteractionManager, Windows::UI::Input::Spatial::SpatialInteractionSourceEventArgs> const& handler) const;
void SourceUpdated(event_token const& token) const;
event_token SourcePressed(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialInteractionManager, Windows::UI::Input::Spatial::SpatialInteractionSourceEventArgs> const& handler) const;
using SourcePressed_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialInteractionManager>;
SourcePressed_revoker SourcePressed(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialInteractionManager, Windows::UI::Input::Spatial::SpatialInteractionSourceEventArgs> const& handler) const;
void SourcePressed(event_token const& token) const;
event_token SourceReleased(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialInteractionManager, Windows::UI::Input::Spatial::SpatialInteractionSourceEventArgs> const& handler) const;
using SourceReleased_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialInteractionManager>;
SourceReleased_revoker SourceReleased(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialInteractionManager, Windows::UI::Input::Spatial::SpatialInteractionSourceEventArgs> const& handler) const;
void SourceReleased(event_token const& token) const;
event_token InteractionDetected(Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialInteractionManager, Windows::UI::Input::Spatial::SpatialInteractionDetectedEventArgs> const& handler) const;
using InteractionDetected_revoker = event_revoker<Windows::UI::Input::Spatial::ISpatialInteractionManager>;
InteractionDetected_revoker InteractionDetected(auto_revoke_t, Windows::Foundation::TypedEventHandler<Windows::UI::Input::Spatial::SpatialInteractionManager, Windows::UI::Input::Spatial::SpatialInteractionDetectedEventArgs> const& handler) const;
void InteractionDetected(event_token const& token) const;
Windows::Foundation::Collections::IVectorView<Windows::UI::Input::Spatial::SpatialInteractionSourceState> GetDetectedSourcesAtTimestamp(Windows::Perception::PerceptionTimestamp const& timeStamp) const;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionManager> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionManager<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionManagerStatics
{
Windows::UI::Input::Spatial::SpatialInteractionManager GetForCurrentView() const;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionManagerStatics> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionManagerStatics<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionSource
{
uint32_t Id() const noexcept;
Windows::UI::Input::Spatial::SpatialInteractionSourceKind Kind() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionSource> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionSource<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionSource2
{
bool IsPointingSupported() const noexcept;
bool IsMenuSupported() const noexcept;
bool IsGraspSupported() const noexcept;
Windows::UI::Input::Spatial::SpatialInteractionController Controller() const noexcept;
Windows::UI::Input::Spatial::SpatialInteractionSourceState TryGetStateAtTimestamp(Windows::Perception::PerceptionTimestamp const& timestamp) const;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionSource2> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionSource2<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionSource3
{
Windows::UI::Input::Spatial::SpatialInteractionSourceHandedness Handedness() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionSource3> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionSource3<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceState State() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionSourceEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceEventArgs2
{
Windows::UI::Input::Spatial::SpatialInteractionPressKind PressKind() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionSourceEventArgs2> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceEventArgs2<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceLocation
{
Windows::Foundation::IReference<Windows::Foundation::Numerics::float3> Position() const noexcept;
Windows::Foundation::IReference<Windows::Foundation::Numerics::float3> Velocity() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceLocation<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceLocation2
{
Windows::Foundation::IReference<Windows::Foundation::Numerics::quaternion> Orientation() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation2> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceLocation2<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceLocation3
{
Windows::UI::Input::Spatial::SpatialInteractionSourcePositionAccuracy PositionAccuracy() const noexcept;
Windows::Foundation::IReference<Windows::Foundation::Numerics::float3> AngularVelocity() const noexcept;
Windows::UI::Input::Spatial::SpatialPointerInteractionSourcePose SourcePointerPose() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation3> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceLocation3<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceProperties
{
Windows::Foundation::IReference<Windows::Foundation::Numerics::float3> TryGetSourceLossMitigationDirection(Windows::Perception::Spatial::SpatialCoordinateSystem const& coordinateSystem) const;
double SourceLossRisk() const noexcept;
Windows::UI::Input::Spatial::SpatialInteractionSourceLocation TryGetLocation(Windows::Perception::Spatial::SpatialCoordinateSystem const& coordinateSystem) const;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionSourceProperties> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceProperties<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceState
{
Windows::UI::Input::Spatial::SpatialInteractionSource Source() const noexcept;
Windows::UI::Input::Spatial::SpatialInteractionSourceProperties Properties() const noexcept;
bool IsPressed() const noexcept;
Windows::Perception::PerceptionTimestamp Timestamp() const noexcept;
Windows::UI::Input::Spatial::SpatialPointerPose TryGetPointerPose(Windows::Perception::Spatial::SpatialCoordinateSystem const& coordinateSystem) const;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionSourceState> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceState<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceState2
{
bool IsSelectPressed() const noexcept;
bool IsMenuPressed() const noexcept;
bool IsGrasped() const noexcept;
double SelectPressedValue() const noexcept;
Windows::UI::Input::Spatial::SpatialInteractionControllerProperties ControllerProperties() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialInteractionSourceState2> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialInteractionSourceState2<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialManipulationCanceledEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialManipulationCanceledEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialManipulationCanceledEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialManipulationCompletedEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
Windows::UI::Input::Spatial::SpatialManipulationDelta TryGetCumulativeDelta(Windows::Perception::Spatial::SpatialCoordinateSystem const& coordinateSystem) const;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialManipulationCompletedEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialManipulationCompletedEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialManipulationDelta
{
Windows::Foundation::Numerics::float3 Translation() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialManipulationDelta> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialManipulationDelta<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialManipulationStartedEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
Windows::UI::Input::Spatial::SpatialPointerPose TryGetPointerPose(Windows::Perception::Spatial::SpatialCoordinateSystem const& coordinateSystem) const;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialManipulationStartedEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialManipulationStartedEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialManipulationUpdatedEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
Windows::UI::Input::Spatial::SpatialManipulationDelta TryGetCumulativeDelta(Windows::Perception::Spatial::SpatialCoordinateSystem const& coordinateSystem) const;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialManipulationUpdatedEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialManipulationUpdatedEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialNavigationCanceledEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialNavigationCanceledEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialNavigationCanceledEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialNavigationCompletedEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
Windows::Foundation::Numerics::float3 NormalizedOffset() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialNavigationCompletedEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialNavigationCompletedEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialNavigationStartedEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
Windows::UI::Input::Spatial::SpatialPointerPose TryGetPointerPose(Windows::Perception::Spatial::SpatialCoordinateSystem const& coordinateSystem) const;
bool IsNavigatingX() const noexcept;
bool IsNavigatingY() const noexcept;
bool IsNavigatingZ() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialNavigationStartedEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialNavigationStartedEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialNavigationUpdatedEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
Windows::Foundation::Numerics::float3 NormalizedOffset() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialNavigationUpdatedEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialNavigationUpdatedEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialPointerInteractionSourcePose
{
Windows::Foundation::Numerics::float3 Position() const noexcept;
Windows::Foundation::Numerics::float3 ForwardDirection() const noexcept;
Windows::Foundation::Numerics::float3 UpDirection() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialPointerInteractionSourcePose> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialPointerInteractionSourcePose<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialPointerInteractionSourcePose2
{
Windows::Foundation::Numerics::quaternion Orientation() const noexcept;
Windows::UI::Input::Spatial::SpatialInteractionSourcePositionAccuracy PositionAccuracy() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialPointerInteractionSourcePose2> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialPointerInteractionSourcePose2<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialPointerPose
{
Windows::Perception::PerceptionTimestamp Timestamp() const noexcept;
Windows::Perception::People::HeadPose Head() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialPointerPose> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialPointerPose<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialPointerPose2
{
Windows::UI::Input::Spatial::SpatialPointerInteractionSourcePose TryGetInteractionSourcePose(Windows::UI::Input::Spatial::SpatialInteractionSource const& source) const;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialPointerPose2> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialPointerPose2<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialPointerPoseStatics
{
Windows::UI::Input::Spatial::SpatialPointerPose TryGetAtTimestamp(Windows::Perception::Spatial::SpatialCoordinateSystem const& coordinateSystem, Windows::Perception::PerceptionTimestamp const& timestamp) const;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialPointerPoseStatics> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialPointerPoseStatics<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialRecognitionEndedEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialRecognitionEndedEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialRecognitionEndedEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialRecognitionStartedEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
Windows::UI::Input::Spatial::SpatialPointerPose TryGetPointerPose(Windows::Perception::Spatial::SpatialCoordinateSystem const& coordinateSystem) const;
bool IsGesturePossible(Windows::UI::Input::Spatial::SpatialGestureSettings const& gesture) const;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialRecognitionStartedEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialRecognitionStartedEventArgs<D>; };
template <typename D>
struct consume_Windows_UI_Input_Spatial_ISpatialTappedEventArgs
{
Windows::UI::Input::Spatial::SpatialInteractionSourceKind InteractionSourceKind() const noexcept;
Windows::UI::Input::Spatial::SpatialPointerPose TryGetPointerPose(Windows::Perception::Spatial::SpatialCoordinateSystem const& coordinateSystem) const;
uint32_t TapCount() const noexcept;
};
template <> struct consume<Windows::UI::Input::Spatial::ISpatialTappedEventArgs> { template <typename D> using type = consume_Windows_UI_Input_Spatial_ISpatialTappedEventArgs<D>; };
template <> struct abi<Windows::UI::Input::Spatial::ISpatialGestureRecognizer>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall add_RecognitionStarted(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_RecognitionStarted(event_token token) = 0;
virtual HRESULT __stdcall add_RecognitionEnded(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_RecognitionEnded(event_token token) = 0;
virtual HRESULT __stdcall add_Tapped(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_Tapped(event_token token) = 0;
virtual HRESULT __stdcall add_HoldStarted(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_HoldStarted(event_token token) = 0;
virtual HRESULT __stdcall add_HoldCompleted(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_HoldCompleted(event_token token) = 0;
virtual HRESULT __stdcall add_HoldCanceled(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_HoldCanceled(event_token token) = 0;
virtual HRESULT __stdcall add_ManipulationStarted(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_ManipulationStarted(event_token token) = 0;
virtual HRESULT __stdcall add_ManipulationUpdated(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_ManipulationUpdated(event_token token) = 0;
virtual HRESULT __stdcall add_ManipulationCompleted(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_ManipulationCompleted(event_token token) = 0;
virtual HRESULT __stdcall add_ManipulationCanceled(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_ManipulationCanceled(event_token token) = 0;
virtual HRESULT __stdcall add_NavigationStarted(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_NavigationStarted(event_token token) = 0;
virtual HRESULT __stdcall add_NavigationUpdated(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_NavigationUpdated(event_token token) = 0;
virtual HRESULT __stdcall add_NavigationCompleted(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_NavigationCompleted(event_token token) = 0;
virtual HRESULT __stdcall add_NavigationCanceled(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_NavigationCanceled(event_token token) = 0;
virtual HRESULT __stdcall CaptureInteraction(::IUnknown* interaction) = 0;
virtual HRESULT __stdcall CancelPendingGestures() = 0;
virtual HRESULT __stdcall TrySetGestureSettings(Windows::UI::Input::Spatial::SpatialGestureSettings settings, bool* succeeded) = 0;
virtual HRESULT __stdcall get_GestureSettings(Windows::UI::Input::Spatial::SpatialGestureSettings* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialGestureRecognizerFactory>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall Create(Windows::UI::Input::Spatial::SpatialGestureSettings settings, ::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialHoldCanceledEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialHoldCompletedEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialHoldStartedEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
virtual HRESULT __stdcall TryGetPointerPose(::IUnknown* coordinateSystem, ::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteraction>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_SourceState(::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionController>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_HasTouchpad(bool* value) = 0;
virtual HRESULT __stdcall get_HasThumbstick(bool* value) = 0;
virtual HRESULT __stdcall get_SimpleHapticsController(::IUnknown** value) = 0;
virtual HRESULT __stdcall get_VendorId(uint16_t* value) = 0;
virtual HRESULT __stdcall get_ProductId(uint16_t* value) = 0;
virtual HRESULT __stdcall get_Version(uint16_t* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionController2>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall TryGetRenderableModelAsync(::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionControllerProperties>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_IsTouchpadTouched(bool* value) = 0;
virtual HRESULT __stdcall get_IsTouchpadPressed(bool* value) = 0;
virtual HRESULT __stdcall get_IsThumbstickPressed(bool* value) = 0;
virtual HRESULT __stdcall get_ThumbstickX(double* value) = 0;
virtual HRESULT __stdcall get_ThumbstickY(double* value) = 0;
virtual HRESULT __stdcall get_TouchpadX(double* value) = 0;
virtual HRESULT __stdcall get_TouchpadY(double* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionDetectedEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
virtual HRESULT __stdcall TryGetPointerPose(::IUnknown* coordinateSystem, ::IUnknown** value) = 0;
virtual HRESULT __stdcall get_Interaction(::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionDetectedEventArgs2>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSource(::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionManager>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall add_SourceDetected(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_SourceDetected(event_token token) = 0;
virtual HRESULT __stdcall add_SourceLost(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_SourceLost(event_token token) = 0;
virtual HRESULT __stdcall add_SourceUpdated(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_SourceUpdated(event_token token) = 0;
virtual HRESULT __stdcall add_SourcePressed(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_SourcePressed(event_token token) = 0;
virtual HRESULT __stdcall add_SourceReleased(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_SourceReleased(event_token token) = 0;
virtual HRESULT __stdcall add_InteractionDetected(::IUnknown* handler, event_token* token) = 0;
virtual HRESULT __stdcall remove_InteractionDetected(event_token token) = 0;
virtual HRESULT __stdcall GetDetectedSourcesAtTimestamp(::IUnknown* timeStamp, ::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionManagerStatics>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall GetForCurrentView(::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionSource>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_Id(uint32_t* value) = 0;
virtual HRESULT __stdcall get_Kind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionSource2>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_IsPointingSupported(bool* value) = 0;
virtual HRESULT __stdcall get_IsMenuSupported(bool* value) = 0;
virtual HRESULT __stdcall get_IsGraspSupported(bool* value) = 0;
virtual HRESULT __stdcall get_Controller(::IUnknown** value) = 0;
virtual HRESULT __stdcall TryGetStateAtTimestamp(::IUnknown* timestamp, ::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionSource3>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_Handedness(Windows::UI::Input::Spatial::SpatialInteractionSourceHandedness* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionSourceEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_State(::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionSourceEventArgs2>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_PressKind(Windows::UI::Input::Spatial::SpatialInteractionPressKind* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_Position(::IUnknown** value) = 0;
virtual HRESULT __stdcall get_Velocity(::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation2>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_Orientation(::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionSourceLocation3>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_PositionAccuracy(Windows::UI::Input::Spatial::SpatialInteractionSourcePositionAccuracy* value) = 0;
virtual HRESULT __stdcall get_AngularVelocity(::IUnknown** value) = 0;
virtual HRESULT __stdcall get_SourcePointerPose(::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionSourceProperties>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall TryGetSourceLossMitigationDirection(::IUnknown* coordinateSystem, ::IUnknown** value) = 0;
virtual HRESULT __stdcall get_SourceLossRisk(double* value) = 0;
virtual HRESULT __stdcall TryGetLocation(::IUnknown* coordinateSystem, ::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionSourceState>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_Source(::IUnknown** value) = 0;
virtual HRESULT __stdcall get_Properties(::IUnknown** value) = 0;
virtual HRESULT __stdcall get_IsPressed(bool* value) = 0;
virtual HRESULT __stdcall get_Timestamp(::IUnknown** value) = 0;
virtual HRESULT __stdcall TryGetPointerPose(::IUnknown* coordinateSystem, ::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialInteractionSourceState2>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_IsSelectPressed(bool* value) = 0;
virtual HRESULT __stdcall get_IsMenuPressed(bool* value) = 0;
virtual HRESULT __stdcall get_IsGrasped(bool* value) = 0;
virtual HRESULT __stdcall get_SelectPressedValue(double* value) = 0;
virtual HRESULT __stdcall get_ControllerProperties(::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialManipulationCanceledEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialManipulationCompletedEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
virtual HRESULT __stdcall TryGetCumulativeDelta(::IUnknown* coordinateSystem, ::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialManipulationDelta>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_Translation(Windows::Foundation::Numerics::float3* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialManipulationStartedEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
virtual HRESULT __stdcall TryGetPointerPose(::IUnknown* coordinateSystem, ::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialManipulationUpdatedEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
virtual HRESULT __stdcall TryGetCumulativeDelta(::IUnknown* coordinateSystem, ::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialNavigationCanceledEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialNavigationCompletedEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
virtual HRESULT __stdcall get_NormalizedOffset(Windows::Foundation::Numerics::float3* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialNavigationStartedEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
virtual HRESULT __stdcall TryGetPointerPose(::IUnknown* coordinateSystem, ::IUnknown** value) = 0;
virtual HRESULT __stdcall get_IsNavigatingX(bool* value) = 0;
virtual HRESULT __stdcall get_IsNavigatingY(bool* value) = 0;
virtual HRESULT __stdcall get_IsNavigatingZ(bool* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialNavigationUpdatedEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
virtual HRESULT __stdcall get_NormalizedOffset(Windows::Foundation::Numerics::float3* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialPointerInteractionSourcePose>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_Position(Windows::Foundation::Numerics::float3* value) = 0;
virtual HRESULT __stdcall get_ForwardDirection(Windows::Foundation::Numerics::float3* value) = 0;
virtual HRESULT __stdcall get_UpDirection(Windows::Foundation::Numerics::float3* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialPointerInteractionSourcePose2>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_Orientation(Windows::Foundation::Numerics::quaternion* value) = 0;
virtual HRESULT __stdcall get_PositionAccuracy(Windows::UI::Input::Spatial::SpatialInteractionSourcePositionAccuracy* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialPointerPose>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_Timestamp(::IUnknown** value) = 0;
virtual HRESULT __stdcall get_Head(::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialPointerPose2>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall TryGetInteractionSourcePose(::IUnknown* source, ::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialPointerPoseStatics>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall TryGetAtTimestamp(::IUnknown* coordinateSystem, ::IUnknown* timestamp, ::IUnknown** value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialRecognitionEndedEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialRecognitionStartedEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
virtual HRESULT __stdcall TryGetPointerPose(::IUnknown* coordinateSystem, ::IUnknown** value) = 0;
virtual HRESULT __stdcall IsGesturePossible(Windows::UI::Input::Spatial::SpatialGestureSettings gesture, bool* value) = 0;
};};
template <> struct abi<Windows::UI::Input::Spatial::ISpatialTappedEventArgs>{ struct type : ::IInspectable
{
virtual HRESULT __stdcall get_InteractionSourceKind(Windows::UI::Input::Spatial::SpatialInteractionSourceKind* value) = 0;
virtual HRESULT __stdcall TryGetPointerPose(::IUnknown* coordinateSystem, ::IUnknown** value) = 0;
virtual HRESULT __stdcall get_TapCount(uint32_t* value) = 0;
};};
}
|
c78e9e6eef308986269a47e96d517b819796d5b2
|
8a1ab43a7179929fc55fcb2d5d15adb3c5e2eaed
|
/tst/xercesguardtest.cpp
|
acc04cc5c9f087802fa34cbc7cf8d11c4a3353e1
|
[] |
no_license
|
freesurfer-rge/sbexperimental
|
61a7546f00d144a97729bf76d2efbf47efaf5b77
|
1c80f145b07965ac803f1ad3f9cc67128d22dcd6
|
refs/heads/master
| 2020-04-07T06:06:40.439568
| 2019-06-16T20:17:07
| 2019-06-16T20:17:07
| 158,122,656
| 0
| 0
| null | 2019-06-16T00:26:58
| 2018-11-18T20:11:48
|
C++
|
UTF-8
|
C++
| false
| false
| 312
|
cpp
|
xercesguardtest.cpp
|
#include <boost/test/unit_test.hpp>
#include "configuration/xercesguard.hpp"
BOOST_AUTO_TEST_SUITE( XercesGuard )
BOOST_AUTO_TEST_CASE( ConstructAndDestruct )
{
Signalbox::Configuration::XercesGuard g;
BOOST_CHECK( (&g) != nullptr );
BOOST_TEST_CHECKPOINT("Constructed");
}
BOOST_AUTO_TEST_SUITE_END()
|
406cc2a64aa3815bddf9800821e1086e9c0fc165
|
e5cd80fd89480cbc27a177b9608ec93359cca5f8
|
/799.cpp
|
5d00d73b0067761c61523a4f739392f8560f320d
|
[] |
no_license
|
higsyuhing/leetcode_middle
|
c5db8dd2e64f1b0a879b54dbd140117a8616c973
|
405c4fabd82ed1188d89851b4df35b28c5cb0fa6
|
refs/heads/master
| 2023-01-28T20:40:52.865658
| 2023-01-12T06:15:28
| 2023-01-12T06:15:28
| 139,873,993
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 958
|
cpp
|
799.cpp
|
class Solution {
public:
double champagneTower(int poured, int query_row, int query_glass) {
double state[query_row+1];
for(int i = 0; i < (query_row+1); i++) state[i] = 0;
state[0] = poured;
for(int curr = 0; curr < query_row; curr++){
// we will compute form right to the left..
// 0-0
// 1-0, 1-1
// 2-0, 2-1, 2-2
// ..
// i-0, i-1, .., i-j, .., i-i (total i+1 entries)
for(int index = curr; index >= 0; index--){
if(state[index] > 1){
double part = (state[index] - 1)/2;
state[index+1] += part;
state[index] = part;
}
else{
state[index] = 0;
}
}
}
if(state[query_glass] > 1) return 1;
else return state[query_glass];
}
};
|
9cb768c295abe4a21429de184276cc95d486b252
|
3d5e0c66c32b3dd6cac8ef22529020d1380d9cda
|
/main.cpp
|
6b4b441e6e8a1e43fb7034fb1774db0e2c311d18
|
[] |
no_license
|
cniculae/IntelligentPuzzleSolver
|
8c39b2711d382af92b941c1219a072b6359bafe3
|
93a7cc8eb2d9956d02abd732a08b322d37a2172d
|
refs/heads/master
| 2021-01-20T08:38:00.471967
| 2017-05-03T17:06:21
| 2017-05-03T17:06:21
| 90,171,813
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,481
|
cpp
|
main.cpp
|
#include <iostream>
#include <vector>
#include <map>
#include <stdlib.h>
#include <time.h>
#include "State.h"
#include "TreeSearcher.h"
using namespace std;
int N;
int newX,newY;
char type;
char srch;
char rev;
char ranBr;
bool ranBool;
bool revBool;
map<pair<int,int>, char> mp;
vector<block> blocks;
int main()
{
cout<<"Select search method:\n1 BFS;\n2 DFS;\n3 Iterative Deepening;\n4 A*\n";
while(true){
cin>>type;
if(type == '1' || type == '2' || type == '3' || type == '4')
break;
else
cout<<"\nInvalid search method. Try again:\n";
}
cout<<"Graph search or Tree search? Type 1 or 2:";
while(true){
cin>>srch;
if(srch == '1' || srch == '2')
break;
else
cout<<"\nInvalid search type. Try again:\n";
}
cout<<"\nShould I include reversing moves? ('no' -> for example if the agent goes up, it can't go down as a next move)\n.Type 'y' or 'n' for yes or no:\n";
while(true){
cin>>rev;
if(rev == 'y' || rev == 'n')
{
if(rev == 'y')
revBool = true;
else revBool = false;
break;
}
else
cout<<"\nInvalid answer. Try again ('y' or 'n'):\n";
}
cout<<"\nRandom order of expanding nodes? 'y' or 'n'\n";
while(true){
cin>>ranBr;
if(ranBr == 'y' || ranBr == 'n')
{
if(ranBr == 'y')
ranBool = true;
else ranBool = false;
break;
}
else
cout<<"\nInvalid answer. Try again ('y' or 'n'):\n";
}
cout<<"Introduce number of blocks:";
cin>>N;
//reading objects:
int cn = N;
++N;
cout<<endl<<"Where should the blocks be? (Don't introduce invalid values)\n";
char c = 'A';
block *p;
do
{
cout<<"For "<<c<<":"<<endl;
cin>>newY>>newX;
if(newX>N+1||newX<1||newY>N+1||newY<1){
cout<<endl<<"The coordinates you tried are invalid. Try again."<<endl;
continue;
}
if(mp[make_pair(newX,newY)]!=0){
cout<<endl<<"The coordinates you tried are occupied by "<<mp[make_pair(newX,newY)]<<" .Try again."<<endl;
continue;
}
mp[make_pair(newX,newY)] = c;
p = new block(newX,newY,c-'A'+1);
blocks.push_back(*p);
p = new block;
c++;
cn--;
}while(cn);
cout<<"Where should the agent be?\n";
block *agent = new block;
cin>> agent->y;
cin>> agent->x;
agent->number = 0;
char obs;
cout<<"Do you want obstacles? ('y' or 'n')";
cin>>obs;
if(obs=='y')
{
vector<block> obstacles;
int nrObs;
cout<<"How many obstacles?\n";
cin>>nrObs;
while(nrObs--){
cin>>newY>>newX;
if(mp[make_pair(newX,newY)]!=0){
cout<<endl<<"The coordinates you tried are occupied by "<<mp[make_pair(newX,newY)]<<" .Try again."<<endl;
nrObs++;
continue;
}
p = new block(newX,newY,'1');
obstacles.push_back(*p);
}
State *startState = new State(blocks,*agent,N,obstacles);
TreeSearcher *tr = new TreeSearcher(startState,type,srch,true,ranBool);
}else{
State *startState = new State(blocks,*agent,N);
TreeSearcher *tr = new TreeSearcher(startState,type,srch,true,ranBool);
}
return 0;
}
|
a2bc5b910b15ea146824ff29753192a00c737378
|
94a5ed13426e71a0df84ae877ec6e19d3921b853
|
/lib/ofpmonitor/ServerTableSorter.h
|
b5e17db7c4e82f9ee62bf9b6754f47a81bce1154
|
[] |
no_license
|
Poweruser/OFPMonitor
|
27aa0ce0d4d689773aeb67aadb7793aa6919666f
|
7034e205996b6f548a421a34f7f586025cfec0cf
|
refs/heads/ooprewrite
| 2021-07-22T22:11:16.426585
| 2016-01-17T15:41:08
| 2016-01-17T15:41:08
| 567,191
| 18
| 5
| null | 2020-02-10T11:21:48
| 2010-03-17T20:23:52
|
C++
|
UTF-8
|
C++
| false
| false
| 1,223
|
h
|
ServerTableSorter.h
|
//---------------------------------------------------------------------------
#ifndef ServerTableSorterH
#define ServerTableSorterH
#include <vcl.h>
/**
This object keeps track of how the server table is currently sorted
*/
enum ServerTableColumn { STC_ID=0, STC_NAME=1, STC_PLAYERS=2, STC_STATE=3, STC_ISLAND=4, STC_MISSION=5, STC_PING=6 };
class ServerTableSorter {
public:
ServerTableSorter();
void reset();
void setId();
void setName();
void setPlayers();
void setStatus();
void setIsland();
void setMission();
void setPing();
bool isIdSet();
bool isNameSet();
bool isPlayersSet();
bool isStatusSet();
bool isIslandSet();
bool isMissionSet();
bool isPingSet();
bool isNormalOrder();
private:
ServerTableColumn currentColumn;
bool normalOrder;
void setProperty(ServerTableColumn stc);
};
//---------------------------------------------------------------------------
#endif
|
0a00ddf4bae4bdd89b25c9c41b89904b906c09a9
|
5ddab10d40231c4e187eda0bf4c8836fc876cbd8
|
/codec/cplusplus/proto/query.pb.h
|
9cff5ba4b5481efd1e401bc2046fdf967ab04e2b
|
[] |
no_license
|
wlijie/recipes
|
f6c588e37a367f2a760095d3cf81ed393dc357b5
|
8e18b437e02c0ce9e16c882f28bf287569917f37
|
refs/heads/master
| 2020-12-16T22:18:34.335208
| 2019-03-20T09:01:33
| 2019-03-20T09:01:33
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| true
| 27,147
|
h
|
query.pb.h
|
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: proto/query.proto
#ifndef PROTOBUF_proto_2fquery_2eproto__INCLUDED
#define PROTOBUF_proto_2fquery_2eproto__INCLUDED
#include <string>
#include <google/protobuf/stubs/common.h>
#if GOOGLE_PROTOBUF_VERSION < 3005000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
namespace protobuf_proto_2fquery_2eproto {
// Internal implementation detail -- do not use these members.
struct TableStruct {
static const ::google::protobuf::internal::ParseTableField entries[];
static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
static const ::google::protobuf::internal::ParseTable schema[3];
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
void AddDescriptors();
void InitDefaultsQueryImpl();
void InitDefaultsQuery();
void InitDefaultsAnswerImpl();
void InitDefaultsAnswer();
void InitDefaultsEmptyImpl();
void InitDefaultsEmpty();
inline void InitDefaults() {
InitDefaultsQuery();
InitDefaultsAnswer();
InitDefaultsEmpty();
}
} // namespace protobuf_proto_2fquery_2eproto
namespace codec {
class Answer;
class AnswerDefaultTypeInternal;
extern AnswerDefaultTypeInternal _Answer_default_instance_;
class Empty;
class EmptyDefaultTypeInternal;
extern EmptyDefaultTypeInternal _Empty_default_instance_;
class Query;
class QueryDefaultTypeInternal;
extern QueryDefaultTypeInternal _Query_default_instance_;
} // namespace codec
namespace codec {
// ===================================================================
class Query : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:codec.Query) */ {
public:
Query();
virtual ~Query();
Query(const Query& from);
inline Query& operator=(const Query& from) {
CopyFrom(from);
return *this;
}
#if LANG_CXX11
Query(Query&& from) noexcept
: Query() {
*this = ::std::move(from);
}
inline Query& operator=(Query&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
#endif
static const ::google::protobuf::Descriptor* descriptor();
static const Query& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const Query* internal_default_instance() {
return reinterpret_cast<const Query*>(
&_Query_default_instance_);
}
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
0;
void Swap(Query* other);
friend void swap(Query& a, Query& b) {
a.Swap(&b);
}
// implements Message ----------------------------------------------
inline Query* New() const PROTOBUF_FINAL { return New(NULL); }
Query* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Query& from);
void MergeFrom(const Query& from);
void Clear() PROTOBUF_FINAL;
bool IsInitialized() const PROTOBUF_FINAL;
size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Query* other);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
return NULL;
}
inline void* MaybeArenaPtr() const {
return NULL;
}
public:
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// string questioner = 2;
void clear_questioner();
static const int kQuestionerFieldNumber = 2;
const ::std::string& questioner() const;
void set_questioner(const ::std::string& value);
#if LANG_CXX11
void set_questioner(::std::string&& value);
#endif
void set_questioner(const char* value);
void set_questioner(const char* value, size_t size);
::std::string* mutable_questioner();
::std::string* release_questioner();
void set_allocated_questioner(::std::string* questioner);
// string question = 3;
void clear_question();
static const int kQuestionFieldNumber = 3;
const ::std::string& question() const;
void set_question(const ::std::string& value);
#if LANG_CXX11
void set_question(::std::string&& value);
#endif
void set_question(const char* value);
void set_question(const char* value, size_t size);
::std::string* mutable_question();
::std::string* release_question();
void set_allocated_question(::std::string* question);
// int64 id = 1;
void clear_id();
static const int kIdFieldNumber = 1;
::google::protobuf::int64 id() const;
void set_id(::google::protobuf::int64 value);
// @@protoc_insertion_point(class_scope:codec.Query)
private:
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::ArenaStringPtr questioner_;
::google::protobuf::internal::ArenaStringPtr question_;
::google::protobuf::int64 id_;
mutable int _cached_size_;
friend struct ::protobuf_proto_2fquery_2eproto::TableStruct;
friend void ::protobuf_proto_2fquery_2eproto::InitDefaultsQueryImpl();
};
// -------------------------------------------------------------------
class Answer : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:codec.Answer) */ {
public:
Answer();
virtual ~Answer();
Answer(const Answer& from);
inline Answer& operator=(const Answer& from) {
CopyFrom(from);
return *this;
}
#if LANG_CXX11
Answer(Answer&& from) noexcept
: Answer() {
*this = ::std::move(from);
}
inline Answer& operator=(Answer&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
#endif
static const ::google::protobuf::Descriptor* descriptor();
static const Answer& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const Answer* internal_default_instance() {
return reinterpret_cast<const Answer*>(
&_Answer_default_instance_);
}
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
1;
void Swap(Answer* other);
friend void swap(Answer& a, Answer& b) {
a.Swap(&b);
}
// implements Message ----------------------------------------------
inline Answer* New() const PROTOBUF_FINAL { return New(NULL); }
Answer* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Answer& from);
void MergeFrom(const Answer& from);
void Clear() PROTOBUF_FINAL;
bool IsInitialized() const PROTOBUF_FINAL;
size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Answer* other);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
return NULL;
}
inline void* MaybeArenaPtr() const {
return NULL;
}
public:
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// string questioner = 2;
void clear_questioner();
static const int kQuestionerFieldNumber = 2;
const ::std::string& questioner() const;
void set_questioner(const ::std::string& value);
#if LANG_CXX11
void set_questioner(::std::string&& value);
#endif
void set_questioner(const char* value);
void set_questioner(const char* value, size_t size);
::std::string* mutable_questioner();
::std::string* release_questioner();
void set_allocated_questioner(::std::string* questioner);
// string answerer = 3;
void clear_answerer();
static const int kAnswererFieldNumber = 3;
const ::std::string& answerer() const;
void set_answerer(const ::std::string& value);
#if LANG_CXX11
void set_answerer(::std::string&& value);
#endif
void set_answerer(const char* value);
void set_answerer(const char* value, size_t size);
::std::string* mutable_answerer();
::std::string* release_answerer();
void set_allocated_answerer(::std::string* answerer);
// string answer = 4;
void clear_answer();
static const int kAnswerFieldNumber = 4;
const ::std::string& answer() const;
void set_answer(const ::std::string& value);
#if LANG_CXX11
void set_answer(::std::string&& value);
#endif
void set_answer(const char* value);
void set_answer(const char* value, size_t size);
::std::string* mutable_answer();
::std::string* release_answer();
void set_allocated_answer(::std::string* answer);
// int64 id = 1;
void clear_id();
static const int kIdFieldNumber = 1;
::google::protobuf::int64 id() const;
void set_id(::google::protobuf::int64 value);
// @@protoc_insertion_point(class_scope:codec.Answer)
private:
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::ArenaStringPtr questioner_;
::google::protobuf::internal::ArenaStringPtr answerer_;
::google::protobuf::internal::ArenaStringPtr answer_;
::google::protobuf::int64 id_;
mutable int _cached_size_;
friend struct ::protobuf_proto_2fquery_2eproto::TableStruct;
friend void ::protobuf_proto_2fquery_2eproto::InitDefaultsAnswerImpl();
};
// -------------------------------------------------------------------
class Empty : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:codec.Empty) */ {
public:
Empty();
virtual ~Empty();
Empty(const Empty& from);
inline Empty& operator=(const Empty& from) {
CopyFrom(from);
return *this;
}
#if LANG_CXX11
Empty(Empty&& from) noexcept
: Empty() {
*this = ::std::move(from);
}
inline Empty& operator=(Empty&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
#endif
static const ::google::protobuf::Descriptor* descriptor();
static const Empty& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const Empty* internal_default_instance() {
return reinterpret_cast<const Empty*>(
&_Empty_default_instance_);
}
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
2;
void Swap(Empty* other);
friend void swap(Empty& a, Empty& b) {
a.Swap(&b);
}
// implements Message ----------------------------------------------
inline Empty* New() const PROTOBUF_FINAL { return New(NULL); }
Empty* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Empty& from);
void MergeFrom(const Empty& from);
void Clear() PROTOBUF_FINAL;
bool IsInitialized() const PROTOBUF_FINAL;
size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Empty* other);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
return NULL;
}
inline void* MaybeArenaPtr() const {
return NULL;
}
public:
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// int32 id = 1;
void clear_id();
static const int kIdFieldNumber = 1;
::google::protobuf::int32 id() const;
void set_id(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:codec.Empty)
private:
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::int32 id_;
mutable int _cached_size_;
friend struct ::protobuf_proto_2fquery_2eproto::TableStruct;
friend void ::protobuf_proto_2fquery_2eproto::InitDefaultsEmptyImpl();
};
// ===================================================================
// ===================================================================
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
// Query
// int64 id = 1;
inline void Query::clear_id() {
id_ = GOOGLE_LONGLONG(0);
}
inline ::google::protobuf::int64 Query::id() const {
// @@protoc_insertion_point(field_get:codec.Query.id)
return id_;
}
inline void Query::set_id(::google::protobuf::int64 value) {
id_ = value;
// @@protoc_insertion_point(field_set:codec.Query.id)
}
// string questioner = 2;
inline void Query::clear_questioner() {
questioner_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Query::questioner() const {
// @@protoc_insertion_point(field_get:codec.Query.questioner)
return questioner_.GetNoArena();
}
inline void Query::set_questioner(const ::std::string& value) {
questioner_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:codec.Query.questioner)
}
#if LANG_CXX11
inline void Query::set_questioner(::std::string&& value) {
questioner_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:codec.Query.questioner)
}
#endif
inline void Query::set_questioner(const char* value) {
GOOGLE_DCHECK(value != NULL);
questioner_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:codec.Query.questioner)
}
inline void Query::set_questioner(const char* value, size_t size) {
questioner_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:codec.Query.questioner)
}
inline ::std::string* Query::mutable_questioner() {
// @@protoc_insertion_point(field_mutable:codec.Query.questioner)
return questioner_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline ::std::string* Query::release_questioner() {
// @@protoc_insertion_point(field_release:codec.Query.questioner)
return questioner_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline void Query::set_allocated_questioner(::std::string* questioner) {
if (questioner != NULL) {
} else {
}
questioner_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), questioner);
// @@protoc_insertion_point(field_set_allocated:codec.Query.questioner)
}
// string question = 3;
inline void Query::clear_question() {
question_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Query::question() const {
// @@protoc_insertion_point(field_get:codec.Query.question)
return question_.GetNoArena();
}
inline void Query::set_question(const ::std::string& value) {
question_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:codec.Query.question)
}
#if LANG_CXX11
inline void Query::set_question(::std::string&& value) {
question_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:codec.Query.question)
}
#endif
inline void Query::set_question(const char* value) {
GOOGLE_DCHECK(value != NULL);
question_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:codec.Query.question)
}
inline void Query::set_question(const char* value, size_t size) {
question_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:codec.Query.question)
}
inline ::std::string* Query::mutable_question() {
// @@protoc_insertion_point(field_mutable:codec.Query.question)
return question_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline ::std::string* Query::release_question() {
// @@protoc_insertion_point(field_release:codec.Query.question)
return question_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline void Query::set_allocated_question(::std::string* question) {
if (question != NULL) {
} else {
}
question_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), question);
// @@protoc_insertion_point(field_set_allocated:codec.Query.question)
}
// -------------------------------------------------------------------
// Answer
// int64 id = 1;
inline void Answer::clear_id() {
id_ = GOOGLE_LONGLONG(0);
}
inline ::google::protobuf::int64 Answer::id() const {
// @@protoc_insertion_point(field_get:codec.Answer.id)
return id_;
}
inline void Answer::set_id(::google::protobuf::int64 value) {
id_ = value;
// @@protoc_insertion_point(field_set:codec.Answer.id)
}
// string questioner = 2;
inline void Answer::clear_questioner() {
questioner_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Answer::questioner() const {
// @@protoc_insertion_point(field_get:codec.Answer.questioner)
return questioner_.GetNoArena();
}
inline void Answer::set_questioner(const ::std::string& value) {
questioner_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:codec.Answer.questioner)
}
#if LANG_CXX11
inline void Answer::set_questioner(::std::string&& value) {
questioner_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:codec.Answer.questioner)
}
#endif
inline void Answer::set_questioner(const char* value) {
GOOGLE_DCHECK(value != NULL);
questioner_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:codec.Answer.questioner)
}
inline void Answer::set_questioner(const char* value, size_t size) {
questioner_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:codec.Answer.questioner)
}
inline ::std::string* Answer::mutable_questioner() {
// @@protoc_insertion_point(field_mutable:codec.Answer.questioner)
return questioner_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline ::std::string* Answer::release_questioner() {
// @@protoc_insertion_point(field_release:codec.Answer.questioner)
return questioner_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline void Answer::set_allocated_questioner(::std::string* questioner) {
if (questioner != NULL) {
} else {
}
questioner_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), questioner);
// @@protoc_insertion_point(field_set_allocated:codec.Answer.questioner)
}
// string answerer = 3;
inline void Answer::clear_answerer() {
answerer_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Answer::answerer() const {
// @@protoc_insertion_point(field_get:codec.Answer.answerer)
return answerer_.GetNoArena();
}
inline void Answer::set_answerer(const ::std::string& value) {
answerer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:codec.Answer.answerer)
}
#if LANG_CXX11
inline void Answer::set_answerer(::std::string&& value) {
answerer_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:codec.Answer.answerer)
}
#endif
inline void Answer::set_answerer(const char* value) {
GOOGLE_DCHECK(value != NULL);
answerer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:codec.Answer.answerer)
}
inline void Answer::set_answerer(const char* value, size_t size) {
answerer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:codec.Answer.answerer)
}
inline ::std::string* Answer::mutable_answerer() {
// @@protoc_insertion_point(field_mutable:codec.Answer.answerer)
return answerer_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline ::std::string* Answer::release_answerer() {
// @@protoc_insertion_point(field_release:codec.Answer.answerer)
return answerer_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline void Answer::set_allocated_answerer(::std::string* answerer) {
if (answerer != NULL) {
} else {
}
answerer_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), answerer);
// @@protoc_insertion_point(field_set_allocated:codec.Answer.answerer)
}
// string answer = 4;
inline void Answer::clear_answer() {
answer_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Answer::answer() const {
// @@protoc_insertion_point(field_get:codec.Answer.answer)
return answer_.GetNoArena();
}
inline void Answer::set_answer(const ::std::string& value) {
answer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:codec.Answer.answer)
}
#if LANG_CXX11
inline void Answer::set_answer(::std::string&& value) {
answer_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:codec.Answer.answer)
}
#endif
inline void Answer::set_answer(const char* value) {
GOOGLE_DCHECK(value != NULL);
answer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:codec.Answer.answer)
}
inline void Answer::set_answer(const char* value, size_t size) {
answer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:codec.Answer.answer)
}
inline ::std::string* Answer::mutable_answer() {
// @@protoc_insertion_point(field_mutable:codec.Answer.answer)
return answer_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline ::std::string* Answer::release_answer() {
// @@protoc_insertion_point(field_release:codec.Answer.answer)
return answer_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline void Answer::set_allocated_answer(::std::string* answer) {
if (answer != NULL) {
} else {
}
answer_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), answer);
// @@protoc_insertion_point(field_set_allocated:codec.Answer.answer)
}
// -------------------------------------------------------------------
// Empty
// int32 id = 1;
inline void Empty::clear_id() {
id_ = 0;
}
inline ::google::protobuf::int32 Empty::id() const {
// @@protoc_insertion_point(field_get:codec.Empty.id)
return id_;
}
inline void Empty::set_id(::google::protobuf::int32 value) {
id_ = value;
// @@protoc_insertion_point(field_set:codec.Empty.id)
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// @@protoc_insertion_point(namespace_scope)
} // namespace codec
// @@protoc_insertion_point(global_scope)
#endif // PROTOBUF_proto_2fquery_2eproto__INCLUDED
|
5e0f16ec83d7ae332ea075c372402020dcb263f3
|
009a15f3a5927ef12d2b40fda61d52774cde9fea
|
/router_proxy/router_proxy.h
|
c7d90598bc727cdc704155e44689e7240fce0a44
|
[] |
no_license
|
huixiaoke2009/router
|
24d81c13393f4e9ae75c7e7bcb8b39a412f8ea8e
|
6067b42513d599edf2909b17a7aeccbb50466aaf
|
refs/heads/master
| 2021-01-10T10:06:50.545240
| 2018-05-08T12:05:58
| 2018-05-08T12:05:58
| 52,494,866
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,176
|
h
|
router_proxy.h
|
/**
*note: m_ProxyReqQueue过来的数据必须封好了包头
m_ProxyRspQueue发出去的数据已经去掉包头
*/
#ifndef _ROUTER_PROXY_H_
#define _ROUTER_PROXY_H_
#include <stdint.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string>
#include <map>
#include <string.h>
#include <vector>
#include <google/protobuf/message.h>
#include "router.pb.h"
#include "shm_queue/shm_queue.h"
#include "common.h"
#include "log/log.h"
#include "util/util.h"
typedef struct tagRouterInfo
{
unsigned int RouterIP;
short RouterPort;
unsigned int RouterSvrID;
int SocketID;
std::string strRecieveBuff;
tagRouterInfo()
{
RouterIP = 0;
RouterPort = 0;
RouterSvrID = 0;
SocketID = -1;
}
int Recv(char* pRecvBuff, unsigned int* pLen)
{
char *pRecvPtr = pRecvBuff;
unsigned int RecvBuffLen = *pLen;
if (!strRecieveBuff.empty())
{
if (strRecieveBuff.length() > (unsigned int)XY_MAXBUFF_LEN)
{
XF_LOG_WARN(0, 0, "recv remain len %lu", strRecieveBuff.length());
return -1;
}
pRecvPtr += strRecieveBuff.length();
RecvBuffLen -= strRecieveBuff.length();
XF_LOG_DEBUG(0, 0, "%s|with recv remain len %lu", __FUNCTION__, (unsigned long)strRecieveBuff.length());
}
int RecvBytes = read(SocketID, pRecvPtr, RecvBuffLen);
if (RecvBytes > 0)
{
XF_LOG_TRACE(0, 0, "recv|%d|%s", RecvBytes, mmlib::CStrTool::Str2Hex(pRecvPtr, RecvBytes));
*pLen = RecvBytes;
if (!strRecieveBuff.empty())
{
*pLen += strRecieveBuff.length();
memcpy(pRecvBuff, strRecieveBuff.data(), strRecieveBuff.length());
strRecieveBuff.clear();
}
return 0;
}
else if (RecvBytes == 0)
{
//连接被终止
XF_LOG_INFO(0, 0, "conn close|%d", RouterSvrID);
return 1;
}
else if (errno == EAGAIN || errno == EWOULDBLOCK)
{
//相当于没有接收到数据
*pLen = 0;
if (!strRecieveBuff.empty())
{
*pLen += strRecieveBuff.length();
memcpy(pRecvBuff, strRecieveBuff.c_str(), strRecieveBuff.length());
strRecieveBuff.clear();
}
return 0;
}
else
{
XF_LOG_WARN(0, 0, "recv failed, ret=%d, errno=%d, errmsg=%s", RecvBytes, errno, strerror(errno));
return -1;
}
return 0;
}
int AddRecvData(const char *pBuff, unsigned int Len)
{
XF_LOG_DEBUG(0, 0, "%s|%lu|%d", __FUNCTION__, (unsigned long)strRecieveBuff.length(), Len);
if (!strRecieveBuff.empty())
{
if (strRecieveBuff.length() + Len > (unsigned int)XY_MAXBUFF_LEN)
{
XF_LOG_WARN(0, 0, "%s|add recv failed, len=%lu, add_len=%d", __FUNCTION__, (unsigned long)strRecieveBuff.length(), Len);
return -1;
}
//TODO 错误处理
strRecieveBuff.append(pBuff, Len);
XF_LOG_DEBUG(0, 0, "%s|after add string|%lu", __FUNCTION__, (unsigned long)strRecieveBuff.length());
}
else
{
if (Len > (unsigned int)XY_MAXBUFF_LEN)
{
XF_LOG_WARN(0, 0, "%s|add recv failed, add_len=%d", __FUNCTION__, Len);
return -1;
}
//TODO 错误处理
strRecieveBuff.assign(pBuff, Len);
XF_LOG_DEBUG(0, 0, "%s|after new string|%lu", __FUNCTION__, (unsigned long)strRecieveBuff.length());
}
return 0;
}
}RouterInfo;
class CRouterProxy
{
public:
CRouterProxy();
~CRouterProxy();
int Init(const char *pConfFile);
int Run();
int GetServerID(){return m_ServerID;}
private:
int ConnectRouter(unsigned int RouterSvrID);
int DisconnetRouter(unsigned int RouterSvrID);
void CheckConnect();
int Send(unsigned int RouterSvrID, const char *pSendBuff, int SendBuffLen);
int Recv(unsigned int RouterSvrID, char* pRecvBuff, unsigned int* pLen);
int AddRecvData(unsigned int RouterSvrID, const char *pBuff, unsigned int Len);
int Forward2Router(char *pSendBuff, int SendBuffLen, int RouterSvrID = 0);
int Send2RouterByMsg(unsigned int RouterSvrID, unsigned int CmdID, const google::protobuf::Message &Rsp);
int SendHeartbeatMsg(unsigned int RouterSvrID);
int SendRegisterMsg(unsigned int RouterSvrID);
int ProcessPkg(unsigned int RouterSvrID, const char* pCurBuffPos, int RecvLen);
private:
int m_EpollFD;
int m_ServerID;
//接收缓冲区
char *m_pProcessBuff;
int m_RouterNum;
RouterInfo m_RouterInfo[XY_MAX_ROUTER_NUM];
mmlib::CShmQueue m_ProxyReqQueue;
mmlib::CShmQueue m_ProxyRspQueue;
};
#endif
|
87683007e57d2b88ca2f46364d399a807e178ffb
|
af34bdb4de223f1f667fdbe51e096f4a8fd0a4d7
|
/cbec.cpp
|
8269882222f4bd36a10f985c63f09d0359007aa6
|
[] |
no_license
|
ptoyoohri/lexyacc
|
4f3a4f5c87dd9928bcb8578c0b194cb75832cd4c
|
022757a0c2ec1dc25829ac10eeb78d2bd7d82282
|
refs/heads/master
| 2022-12-18T16:58:04.546096
| 2020-09-18T10:14:10
| 2020-09-18T10:14:10
| 295,987,041
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,117
|
cpp
|
cbec.cpp
|
/* *****************************************************************************
// [cbec.cpp]
//
// Copyright 2004-2004 SPRINGSOFT. All Rights Reserved.
//
// Except as specified in the license terms of SPRINGSOFT, this material may not be copied, modified,
// re-published, uploaded, executed, or distributed in any way, in any medium,
// in whole or in part, without prior written permission from SPRINGSOFT.
// ****************************************************************************/
#define CBEC_ALLOC
//#include "cbec.h"
//#include <values.h>
#include <float.h>
#include <stdarg.h>
#include "cbec_int.h"
#include "cbec_kw.h"
//#include "cbec_prop.src"
//#include "cbec_ev.src"
//#include "cbec_eval.src"
#include "cbec_kw.src"
//#include "cbec_link.src"
//#include "cbec_misc.src"
#include "cbec_msg.src"
//#include "cbec_opr.src"
//#include "cbec_rng.src"
//#include "cbec_stmt.src"
#include "cbec_main.src"
void Task::init(char task_name[], char o_e_Name[]) {
taskName = task_name;
char *objectsName = o_e_Name;
char *ptr = o_e_Name;
int lenght = strlen(o_e_Name);
for (ptr = o_e_Name; *ptr != '\0' ; ptr++) {
if (*ptr == ',') {
char *ptr_NULL = ptr;
ptr ++;
*ptr_NULL = '\0';
break;
}
}
evnetsName = ptr;
printf("Task::init(): %s; %s; %s \n", taskName, objectsName, evnetsName);
}
void Task::setIn(char var_name[], char is_name[], char in_set_name[]) {
sets[countSet].defineIn.varName = var_name; // P
sets[countSet].defineIn.isName = is_name; // is "people"
sets[countSet].defineIn.inSetName = in_set_name; // in objects
printf("Task::setIs(): %s; %s; %s;\n", var_name, is_name, in_set_name);
}
void Task::everyAny(int qlfy) {
sets[countSet].everyAny = qlfy; // 1:every or 2: any
printf("Task::everyAny(): %d;\n", qlfy);
}
void Task::setCondition(char condition[]) {
sets[countSet].conditionClause = condition; // 1:every or 2: any
printf("Task::setCondition(): %s;\n", sets[countSet].conditionClause);
}
|
d4aef3194c9d85a2e1e2d7ac07fc615820932e82
|
3f43bd002547a363669f6dccbde4e9d4bb449b8a
|
/GFG/Trees/is-tree-foldable.cpp
|
e2a4dd2adddef9685c122ef2338142a4f664fecd
|
[] |
no_license
|
Ad1tyaV/Coding-Problems
|
0203ee46d9b119beaac4b0c11106f18d4e80e160
|
7423eeb790afc5a2d5ddb5cd1fa4a0a58e15a78d
|
refs/heads/main
| 2023-07-24T10:28:47.587493
| 2021-09-08T19:54:10
| 2021-09-08T19:54:10
| 351,480,597
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,081
|
cpp
|
is-tree-foldable.cpp
|
/*
$ g++ -std=c++0x foldable-tree.cpp -o isFoldable
$ ./isFoldable
Tree is foldable
*/
#include<iostream>
using namespace std;
struct Node{
int data;
Node* left;
Node* right;
Node(int data){
this->data = data;
this->left = NULL;
this->right = NULL;
}
};
Node* invert(Node* root){
if(root){
if(root->left==NULL && root->right==NULL) // If happens to be leaf
return root;
Node* leftChild = root->left;
Node* rightChild = root->right;
root->left = invert(rightChild);
root->right = invert(leftChild);
return root;
}
return NULL;
}
bool areSame(Node* root, Node* secondRoot){
if(root==NULL && secondRoot==NULL)
return true;
if(root && secondRoot){
return areSame(root->left, secondRoot->left) && areSame(root->right, secondRoot->right);
}
return false;
}
Node* deepCopy(Node* root){
if(root){
Node* copiedNode = new Node(root->data);
if(root->left){
copiedNode->left = deepCopy(root->left);
}
if(root->right){
copiedNode->right = deepCopy(root->right);
}
return copiedNode;
}
return NULL;
}
int main(){
//This Tree is foldable!
Node* root = new Node(10);
root->left = new Node(7);
root->right = new Node(15);
root->left->right = new Node(9);
root->right->left = new Node(11);
// This tree is foldable
// Node* root = new Node(10);
// root->left = new Node(7);
// root->right = new Node(15);
// root->left->left = new Node(9);
// root->right->right = new Node(11);
//This Tree is not foldable
// Node* root = new Node(10);
// root->left = new Node(7);
// root->right = new Node(15);
// root->left->left = new Node(5);
// root->right->left = new Node(11);
if(areSame(root, invert(deepCopy(root))))
cout<<"Tree is foldable\n";
else
cout<<"Tree is not foldable\n";
return 0;
}
|
272249c257fd258a05b678eb3b271135d9b1b970
|
ec4adcef06ca6aee2887d922396da7ee7a039da1
|
/football/UIItemScore.cpp
|
6c58dd66efb5a96323b29858921866f550fffec7
|
[] |
no_license
|
tjakubowski/sfml-football
|
d439e3924eecb445f3105e7662e4faa1c3468e94
|
2d9a43c064a0b170615f32d5076c2d6b5bd23985
|
refs/heads/master
| 2022-04-08T19:21:16.482929
| 2020-03-23T01:20:28
| 2020-03-23T01:20:28
| 176,612,792
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 916
|
cpp
|
UIItemScore.cpp
|
#include "UIItemScore.hpp"
namespace Football
{
UIItemScore::UIItemScore(sf::Vector2f centerAnchor, Score score, unsigned fontSize, sf::Color color, std::string fontName, float bgPadding, sf::Color bgColor) : UIItem(centerAnchor, "", fontSize, color, fontName, bgPadding, bgColor)
{
clickable = false;
stringStream->str(std::string());
*stringStream << score.leftPoints << " : " << score.rightPoints << "\t" << timestampToDate(score.timestamp);
text->setString(stringStream->str());
text->setPosition(centerAnchor - sf::Vector2f(text->getGlobalBounds().width, text->getGlobalBounds().height) / 2.f);
}
UIItemScore::~UIItemScore()
{
}
std::string UIItemScore::timestampToDate(const time_t timestamp)
{
char buffer[30];
struct tm* dt = localtime(×tamp);
strftime(buffer, sizeof(buffer), "%H:%M, %d.%m.%y", dt);
return std::string(buffer);
}
void UIItemScore::onClick()
{
}
}
|
9b89ad55e1612266a6ad2b0770fdb4c33ecdc93a
|
ed8e87a2a6829f470338c29245aa73067ea08690
|
/Zork/Zork/Inventory.cpp
|
4e84e5a0e05e65d20441b7c913a027e57cee2a00
|
[] |
no_license
|
SirGauci/GamesProgrammingRepo
|
e8b2db10e79fd910db948055988cc3b1d3dee8e9
|
bbf7744ac613cd03f6cea3d99a38202aeea2b930
|
refs/heads/master
| 2020-09-24T21:43:28.971706
| 2016-10-17T23:44:15
| 2016-10-17T23:44:15
| 66,178,555
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 765
|
cpp
|
Inventory.cpp
|
#include "stdafx.h"
#include "Inventory.h"
#include <iostream>
Inventory::Inventory(){}
Inventory::~Inventory(){}
void Inventory::Add(Item* item)
{
prInventory.push_back(item);
}
Item* Inventory::Access(std::string item)
{
for each (Item* i in prInventory)
{
if (i->getName() == item)
{
return i;
}
}
return NULL;
}
void Inventory::Remove(std::string item)
{
auto it = std::find(prInventory.begin(), prInventory.end(), Access(item));
if (it != prInventory.end())
{
std::swap(*it, prInventory.back());
prInventory.pop_back();
}
}
std::string Inventory::Display()
{
std::string result;
for each (Item* i in prInventory)
{
result += "\t" + i->getName() + "\n";
}
return result;
}
|
30a3a98ad93bde19993a306f8e9fccbe6fc91749
|
bbdce094abc58e47269117a78b61d85243b353e4
|
/Maze.cpp
|
190ca8b63b8c8f022429420f56657702497e1b08
|
[] |
no_license
|
nathansmith11170/MazesWithSFML
|
40da7b06b49cb892fe58ec80cc664100e221edc8
|
1a2f2ff5a2405cc73beb7bbd6370e5b9a2efc21f
|
refs/heads/master
| 2020-03-29T16:39:50.854821
| 2018-10-02T15:38:30
| 2018-10-02T15:38:30
| 150,123,719
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,633
|
cpp
|
Maze.cpp
|
#include <SFML/Graphics.hpp>
#include "MatrixGraph.h"
#include <cstdio>
#include <vector>
#include <unordered_set>
#include <cstdlib>
#define WINDOW_WIDTH 800
#define WINDOW_HEIGHT 600
#define NODES 20
#define STROKE 5
/*This function returns the next vertex of the graph given by depth first
search with a recursive backtracker*/
int recursiveBacktracker(MatrixGraph, MatrixGraph*, std::vector<int>*, std::unordered_set<int>*, int);
int main(int argc, char **argv) {
//Shapes
std::vector<sf::RectangleShape> rects;
std::vector<sf::RectangleShape> bottomEdges;
std::vector<sf::RectangleShape> rightEdges;
//The top and left borders are fixed
sf::RectangleShape topBorder;
sf::RectangleShape leftBorder;
sf::RenderWindow window;
//Model variables
MatrixGraph grid, maze;
std::vector<int> stack;
std::unordered_set<int> visitedSet;
int i, currentVertex, row, column, j, seed;
char *commandLine;
//Get command line arg, seed random
commandLine = *(argv+1);
seed = atoi(commandLine);
srand(seed);
//Create two graphs with N^2 vertices
for( i = 0; i < NODES * NODES; i++ ) {
grid.add_vertice(i);
maze.add_vertice(i);
}
//Populate the grid with the proper edges
row = 0;
column = 0;
for( i = 0; i < NODES * NODES; i++ ) {
if( i + 1 <= (row+1) * NODES - 1 ) {
grid.add_edge(i, i + 1);
}
if( i - 1 >= row * NODES ) {
grid.add_edge(i, i - 1);
}
if( i + NODES <= NODES * NODES - 1 ) {
grid.add_edge(i, i + NODES);
}
if( i - NODES >= 0 ) {
grid.add_edge(i, i - NODES);
}
column++;
if(column >= NODES) {
column = 0;
row++;
}
}
//Start at the vertex 0
currentVertex = 0;
visitedSet.insert(currentVertex);
stack.push_back(currentVertex);
//Create the SFML window, set framerate
window.create(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "Maze");
window.setFramerateLimit(30
);
//Set up borders
topBorder = sf::RectangleShape(sf::Vector2f(WINDOW_WIDTH, STROKE));
leftBorder = sf::RectangleShape(sf::Vector2f(STROKE, WINDOW_HEIGHT));
//Set up vertices
row = 0;
column = 0;
for( i = 0; i < NODES * NODES; i++ ) {
rects.push_back(sf::RectangleShape(sf::Vector2f(WINDOW_WIDTH/NODES-STROKE,\
WINDOW_HEIGHT/NODES-STROKE)));
rects.at(i).setPosition(STROKE + column * (WINDOW_WIDTH/NODES),\
STROKE + row * (WINDOW_HEIGHT/NODES));
column++;
if(column >= NODES) {
column = 0;
row++;
}
}
//Set up edges
row = 0;
column = 0;
for( i = 0; i < NODES * NODES; i++ ) {
rightEdges.push_back(sf::RectangleShape(sf::Vector2f(STROKE,\
WINDOW_HEIGHT/NODES-STROKE)));
rightEdges.at(i).setPosition((column + 1) * (WINDOW_WIDTH/NODES),\
STROKE + row * (WINDOW_HEIGHT/NODES));
column++;
if(column >= NODES) {
column = 0;
row++;
}
}
row = 0;
column = 0;
for( i = 0; i < NODES * NODES; i++ ) {
bottomEdges.push_back(sf::RectangleShape(sf::Vector2f(WINDOW_WIDTH/NODES-STROKE,\
STROKE)));
bottomEdges.at(i).setPosition(STROKE + column * (WINDOW_WIDTH/NODES),\
(row + 1) * (WINDOW_HEIGHT/NODES));
column++;
if(column >= NODES) {
column = 0;
row++;
}
}
for( i = 0; i < rects.size(); i++) {
rects.at(i).setFillColor(sf::Color::Black);
bottomEdges.at(i).setFillColor(sf::Color::Cyan);
rightEdges.at(i).setFillColor(sf::Color::Cyan);
}
//Main loop
while( window.isOpen() ) {
//Handle events in order to close the window
sf::Event event;
while( window.pollEvent(event) ){
if(event.type == sf::Event::Closed) {
window.close();
}
}
//Begin frame
window.clear(sf::Color::Black);
//Indicate current position
rects.at(currentVertex).setFillColor(sf::Color::Red);
/* Drawing Logic */
for( i = 0; i < rects.size(); i++) {
if(i != currentVertex && visitedSet.count(i)) {
rects.at(i).setFillColor(sf::Color::Cyan);
window.draw(rects.at(i));
}
if( i == currentVertex ) {
window.draw(rects.at(i));
}
}
//Draw existent edges
for( i = 0; i < rightEdges.size(); i++ ) {
std::vector<int> neighbors = maze.get_neighbors(i);
for( j = 0; j < neighbors.size(); j++ ) {
if(neighbors.at(j) == i + 1) {
window.draw(rightEdges.at(i));
}
}
}
for( i = 0; i < bottomEdges.size(); i++ ) {
std::vector<int> neighbors = maze.get_neighbors(i);
for( j = 0; j < neighbors.size(); j++ ) {
if(neighbors.at(j) == i + NODES) {
window.draw(bottomEdges.at(i));
}
}
}
window.display();
//End frame
//Get next position from recursive backtracker
if(!stack.empty()) {
currentVertex = recursiveBacktracker(grid, &maze, &stack, &visitedSet, currentVertex);
}
}
return 0;
}
int recursiveBacktracker(MatrixGraph grid, MatrixGraph *maze, std::vector<int> *stack,\
std::unordered_set<int> *visitedSet, int currentVertex) {
int i, j, isVisited = 0, randomIndex, nextVertex;
std::vector<int> unvisitedNeighbors;
std::vector<int> neighbors;
int isvisited;
//From the neighbors of the current node, determine which are unvisited
neighbors = grid.get_neighbors(currentVertex);
for( i = 0; i < neighbors.size(); i++ ) {
if(!(*visitedSet).count(neighbors.at(i))) {
unvisitedNeighbors.push_back(neighbors.at(i));
}
}
if(!unvisitedNeighbors.empty()) {
//Get a random neighbor
std::random_shuffle (unvisitedNeighbors.begin(), unvisitedNeighbors.end());
nextVertex = unvisitedNeighbors.back();
//Push current node onto the stack
(*stack).push_back(currentVertex);
//Add the appropriate edge to the maze
(*maze).add_edge(currentVertex, nextVertex);
(*visitedSet).insert(nextVertex);
} else if (!(*stack).empty()) {
nextVertex = (*stack).back();
(*stack).pop_back();
}
return nextVertex;
}
|
1553b1e4dfef2459fcddc15497cb8bcb639917cc
|
590ad531651d7f5f5f73baa1b3ac36866877104b
|
/tuxbox/neutrino/src/driver/file.h
|
75de80c9cd109cc44218a9ffd6a12cd5c869da2b
|
[] |
no_license
|
ChakaZulu/tuxbox_apps
|
1217f53e3adc27227e0ed07de4778120e294f574
|
1a28fedaecef864ecc7d696b739795321ea3bdb1
|
refs/heads/master
| 2021-01-23T17:20:36.229379
| 2009-12-30T13:38:15
| 2009-12-30T13:38:15
| 129,129
| 10
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,978
|
h
|
file.h
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: non-nil; c-basic-offset: 4 -*- */
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
Kommentar:
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert
auf der Client-Server Idee, diese GUI ist also von der direkten DBox-
Steuerung getrennt. Diese wird dann von Daemons uebernommen.
License: GPL
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __FILE_H__
#define __FILE_H__
#include <features.h> /* make sure off_t has size 8
in __USE_FILE_OFFSET64 mode */
#ifndef __USE_FILE_OFFSET64
#error not using 64 bit file offsets
#endif /* __USE_FILE__OFFSET64 */
#include <sys/types.h>
#include <string>
#include <vector>
class CFile
{
public:
enum FileType
{
FILE_UNKNOWN = 0,
FILE_DIR,
FILE_TEXT,
FILE_CDR,
FILE_MP3,
FILE_OGG,
FILE_WAV,
FILE_FLAC,
FILE_XML,
FILE_PLAYLIST,
STREAM_AUDIO,
FILE_PICTURE,
STREAM_PICTURE
};
FileType getType(void) const;
std::string getFileName(void) const;
std::string getPath(void) const;
CFile();
off_t Size;
std::string Name;
std::string Url;
mode_t Mode;
bool Marked;
time_t Time;
};
typedef std::vector<CFile> CFileList;
#endif /* __FILE_H__ */
|
5137ab200ebfbf4a1a3ded64950f89e6561f94bf
|
54eb1f4846bd2f74b213e5c48816e523dec17b7f
|
/Auxiliary.h
|
b683eb66c84b0801c4eb3248dd2be1fff967a1e7
|
[] |
no_license
|
karvandi/KeyMgr
|
d91ba512ee1ef0b46e737c51e71bef506d274890
|
a1e3073cc7b4afb54c73bd4a4f800e1c78be9cf2
|
refs/heads/master
| 2021-01-19T04:33:10.017717
| 2017-04-12T17:32:07
| 2017-04-12T17:32:07
| 87,380,516
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,139
|
h
|
Auxiliary.h
|
//
// Auxilary.h
// KeyMgr
//
// part of "an example programon using the Openssl library"
//
// Created by Babak Karvandi on 04/06/2017.
// Copyright (C) Geeks Dominion LLC 2017. All rights reserved.
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
#ifndef __COMMON_H_INCLUDED__ // if header hasn't been defined yet...
#define __COMMON_H_INCLUDED__ // #define this so the compiler knows it has been included
#include "SysLog.h"
#include <iostream> // cout
#include <pthread.h> // create_thread ; Library is passes to the linker as well
#include <vector> // vector
#include <sstream> // stringstream
#include <string> // string
#include <cstring> // <cstring> = <string.h> ; (in C) strlen()
#include <unistd.h> // getpid()
#include <map> // map key-value pair
#include <fstream> // ofstream (file type)
#include <algorithm> // find_if(), remove_if(), toupper
#include <fcntl.h> // fcntl, C style file write (used in daemonize)
#include <libgen.h> // dirname()
#include <dirent.h> // opendir(), readdir()
//#include <experimental/filesystem> // filesystem handling
#include <ext/stdio_filebuf.h> // GNU stdio_filebuf for istream on system call
#include <sys/wait.h> // wait(), wait for child process to finish
#include <sys/stat.h> // fstat, umask
#include <sys/poll.h> // POLL, fds
#include <termios.h> // struct termios; Keyboard poll TC
#include <tr1/memory> // smart pointers
#include <memory> // smart pointers
using namespace std;
//////////////////////////////////////////////////////////////////////////////
// Utilities
string ASCII_to_POSIX (string &);
int exec (ostringstream &, int loglvl = LOG_ERR );
string s_exec ( string );
int exec ( string &, int loglvl = LOG_ERR );
int exec ( vector <string> &, int loglvl = LOG_ERR );
int exec ( string cmd, vector <string> *myvec = NULL, char *envp[] = NULL, int loglvl = LOG_ERR );
// runs the /bin/sh for wildcard char safety
bool isPrintable ( string );
bool isNumeric ( string );
bool isAlpha ( string );
bool isAlphaWS ( string );
bool isEmail ( string );
string trim ( string );
string toUpperCase ( string & );
string uuidgen ();
string formattedTime ( time_t t = time(0));
string formattedGMTTime( time_t t = time(0));
string formattedTime ( time_t, bool GMT ); // true = GMT; false = US Local time;
void stringReplace (string &, string, string, bool all = true); // true = All occuranses, false = First occurance
//////////////////////////////////////////////////////////////////////////////
class cmdOpt
{
public:
cmdOpt (string);
~cmdOpt () {};
int init (int, char *[]);
string getErrors ();
string getWarnings ();
bool anyWarnings ();
bool isSet (char);
bool isSet (char, int &);
string getValue (char);
private:
struct Flags {
char attrib;
string value;
bool flag;
};
vector <Flags> options;
vector <char> mandatory;
vector <string> arguments;
ostringstream errors;
ostringstream warnings;
};
//////////////////////////////////////////////////////////////////////////////////////////////////////
class fileWrapper
{
public:
fileWrapper(int logLvl = LOG_ERR);
~fileWrapper();
int RC;
bool fileExists, IS_DIR;
string ETag;
int init(string);
bool isDir() { return IS_DIR; }
bool isValidFilename();
string lastAccessed(bool);
string lastModified(bool);
string getetag( bool CHK_DIR = true );
int size() { if ( RC == 200 ) return fstat.st_size; else return -1; }
int mkDir();
int lsDir( vector <string> *output = NULL );
int rmDir( bool force_all = false );
int mkFile( bool force = false );
int rmFile();
int write( ostringstream *output = NULL, bool append = false );
int append( ostringstream *output ) { return write( output, true ); };
int erase() { write(); tlog->INFO( "204: erase() successfull" ) ; return 204; };
int read( stringstream & );
static string DirName ( string );
static string BaseName ( string );
string fname;
protected:
struct stat fstat;
int loglevel;
private:
ThreadLog *tlog;
};
#endif
|
b19000c76c659d775c78e212e67dc6103cd3a1fb
|
004e499a6dbbd363555b3134ac015c7374ad33a5
|
/AcWing/13.4.1111. 字母 .cpp
|
77a8c69bc2d99a345ba9f0010d76471bd752297c
|
[] |
no_license
|
wwwkkkp/Algorithm
|
c8721eae64d15d60beb9ef6ce37c70b9e78e8f6d
|
fc4d103700212264d3d84cb374353b0476f371af
|
refs/heads/master
| 2022-11-24T13:45:29.845925
| 2020-07-14T03:24:39
| 2020-07-14T03:24:39
| 279,460,886
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,449
|
cpp
|
13.4.1111. 字母 .cpp
|
//13.4.1111. 字母
给定一个R×S的大写字母矩阵,你的起始位置位于左上角,你可以向上下左右四个方向进行移动,但是不能移出边界,或者移动到曾经经过的字母(左上角字母看作第一个经过的字母)。
请问,你最多可以经过几个字母。
输入格式
第一行包含两个整数 R和 S,表示字母矩阵的行和列。
接下来 R行,每行包含一个长度为 S的大写字母构成的字符串,共同构成字母矩阵。
输出格式
输出一个整数,表示最多能够经过的字母个数。
数据范围
1≤R,S≤20
输入样例:
3 6
HFDFFB
AJHGDH
DGAGEH
输出样例:
6
//dfs 自己的写法有点笨拙
#include<iostream>
using namespace std;
const int N=21;
int n,m;
bool st[30];
char a[N][N];
int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};
int dfs(int x,int y){ //在x,y这个位置所能到的最远距离
int ju=0;
for(int i=0;i<4;i++){
int t=x+dx[i];
int b=y+dy[i];
if(t>=0&&t<n&&b>=0&&b<m){
if(st[a[t][b]-'A'])
ju++;
}
}
if(ju==4)return 1; //如果上下左右都访问过了,那就返回1,
int s=1;//初始值是1
for(int i=0;i<4;i++){
int t=x+dx[i];
int b=y+dy[i];
if(t>=0&&t<n&&b>=0&&b<m){
if(!st[a[t][b]-'A']){
st[a[t][b]-'A']=true;
s=max(s,dfs(t,b)+1);//四个方向所能到的最远值+1=当前位置的最远值
st[a[t][b]-'A']=false;
}
}
}
return s;
}
int main(){
cin>>n>>m;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>a[i][j];
}
}
st[a[0][0]-'A']=true;
cout<<dfs(0,0)<<endl;
return 0;
}
//y总写法
#include <iostream>
#include <cstring>
using namespace std;
const int N = 30;
int n, m;
char g[N][N];
bool st[N];
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
int dfs(int x, int y)
{
int u = g[x][y] - 'A';
st[u] = true;
int sum = 0;
for (int i = 0; i < 4; i ++ )
{
int a = x + dx[i], b = y + dy[i];
if (a >= 0 && a < n && b >= 0 && b < m)
{
int t = g[a][b] - 'A';
if (!st[t]) sum = max(sum, dfs(a, b));
}
}
st[u] = false;
return sum + 1;
}
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i ++ ) cin >> g[i];
cout << dfs(0, 0) << endl;
return 0;
}
|
bbfcb5a6614c41079cd6a4504b0c52393028e459
|
8b1f827d1ae87ad9ac82fdc4f75869ec6ea75eb3
|
/IO/ReadingTextFile.cpp
|
86b3c6b56e236eb50f28463c3f644e31ddfce854
|
[] |
no_license
|
ByVictorrr/Beginning-Cpp-Programming-From-Beginner-to-Beyond
|
0934f78c457760618dbdd2a0fdd16dc643218eb7
|
1a9a87a2f91c7d0431a9ef8d8dd2d8395e1b7425
|
refs/heads/master
| 2020-11-24T09:34:22.752713
| 2019-12-31T21:05:38
| 2019-12-31T21:05:38
| 228,081,587
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 463
|
cpp
|
ReadingTextFile.cpp
|
#include <iostream>
#include <fstream>
void read_file(std::string file_name) {
//---- YOU WRITE YOUR CODE BELOW THIS LINE----
std::string name;
std::ifstream i_file(file_name);
if(!i_file.is_open()){
std::cerr << "Error opening file" << std::endl;
}else{
while(!i_file.eof()){
i_file >> name;
std::cout << name << std::endl;
}
}
//---- YOU WRITE YOUR CODE ABOVE THIS LINE----
}
|
68365e7199033bdf275b4666fc6c30ec80e70f0e
|
e98db42b7dd6f1bfffe684b976402bbce1b615f7
|
/1109 false ordering.cpp
|
4352ff096507e8597f6d52aa2d14a621c9207eba
|
[] |
no_license
|
Shaykat/LightOJ
|
274506393bb43d48cbc3b3d314f6149cbe4f13d3
|
cbd62054629b0a482a14cfc49400ac6909ace03b
|
refs/heads/master
| 2021-01-11T02:09:17.514424
| 2017-11-27T21:49:34
| 2017-11-27T21:49:34
| 70,826,832
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,377
|
cpp
|
1109 false ordering.cpp
|
#include<bits/stdc++.h>
using namespace std;
#define a 1500
vector< pair<int,int> >v;
int arr[a];
int prime[1005],k,f[20],p[20],l,t;
bool compare(const pair<int,int>&i,const pair<int,int>&j){
if(i.second == j.second) return i.first > j.first;
return i.second < j.second;
}
void sieve(){
int i,j;
k = 1;
prime[0] = 2;
int sn = sqrt((double)a);
arr[0] = 1;
arr[1] = 1;
arr[2] = 0;
for(i=3;i<=sn;i+=2)
{
if(arr[i] == 0)
{
prime[k++] = i;
for(j=i*i;j<a;j+=2*i)
{
arr[j] = 1;
}
}
}
}
int number_of_devisor(int n){
int dev = 1;
int sq = sqrt(n),cnt = 0;
l =0;
for(int i =0; i < k && prime[i] <= sq; i++ ){
if(n%prime[i] == 0){
cnt = 0;
while(n%prime[i] == 0){
cnt++;
n/= prime[i];
}
f[l] = prime[i];
p[l] = cnt;
l++;
sq = sqrt(n);
}
}
if(n > 1){
f[l] = n;
p[l] = 1;
}
for(int i = 0; i <= l; i++){
dev *= (p[i]+1);
}
memset(p,0,sizeof(p));
memset(f,0,sizeof(f));
return dev;
}
int main(){
sieve();
for(int i = 1; i <= 1000; i++){
v.push_back(make_pair(i,number_of_devisor(i)));
}
sort(v.begin(),v.end(),compare);
scanf("%d",&t);
int p;
for(int i = 1; i <= t; i++){
cin >> p;
printf("Case %d: %d\n",i,v[p-1].first);
}
return 0;
}
|
bedf2f6812b100861a5a26691579cd3d9cb418bf
|
f21c5df2b9a9f32913c617bf173ec4f33d48460a
|
/S6086643_CDodds_GPP_Server/S6086643_CDodds_GPP_Server/Card.h
|
0fb79322706cdb4ae3a3b4bac7c483f7d05d36b5
|
[] |
no_license
|
Chris-Dodds-s6086643/GPP
|
6588d27263bb622c0745de484cedc5655ae01923
|
c6d73292e2a40f07a42b65c8ac84a178a47a99f1
|
refs/heads/master
| 2020-12-27T22:04:43.257493
| 2020-05-24T11:28:30
| 2020-05-24T11:28:30
| 238,075,522
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 549
|
h
|
Card.h
|
#pragma once
#include <string>
#include <iostream>
enum CardSuit
{
spades = 0,
diamonds = 1,
clubs = 2,
hearts = 3
};
enum CardValue
{
ace = 1,
two = 2,
three = 3,
four = 4,
five = 5,
six = 6,
seven = 7,
eight = 8,
nine = 9,
ten = 10,
jack = 11,
queen = 12,
king = 13
};
class Card
{
public:
Card() {
std::cout << "SOMETHING HAS GONE WRONG";
}
Card(int inSuit, int inValue) : suit((CardSuit)inSuit), value((CardValue)inValue), seen(new bool[4]) {}
CardSuit suit;
CardValue value;
bool* seen;
std::string toString();
};
|
fd44deea886c3c2fd1da43f2ef15515b7bb94c5e
|
92a575f0e26fe49806b3c490d2a870598fa5c372
|
/MscAssignmentCpp/binarytodecimal.cpp
|
2e7621359be5a1071cbfb3cab61dfa2e9c8c4da4
|
[] |
no_license
|
bluesaiyancodes/Basic-Computer-Conversions
|
47dc81c193d32358b2da0157f01c4be9797c6a1d
|
71eda9443c89c8762aac00ebe159f659ee1fef32
|
refs/heads/master
| 2020-04-05T20:58:53.435313
| 2018-11-12T11:01:53
| 2018-11-12T11:01:53
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 762
|
cpp
|
binarytodecimal.cpp
|
//
// binarytodecimal.cpp
// MscAssignmentCpp
//
// Created by Bishal Blue on 01/10/18.
// Copyright © 2018 Bishal Blue. All rights reserved.
//
#include "binarytodecimal.hpp"
#include <iostream>
#include <math.h>
#define SIZE 8
using namespace std;
void binarytodecimal::initialize(){
for(int i=0;i<SIZE;i++){
arr[i]=0;
}
val=0;
}
void binarytodecimal::calcbintodec(int n){
num=n;
int i=SIZE-1;
while(n){
int temp = n % 10;
arr[i--] = temp;
n = n / 10;
}
for(int i=SIZE-1,j=0;i>=0;i--,j++){
val += arr[i]*int(pow(double(2), double(j)));
}
if (arr[0]==1){
val-=256;
}
return;
}
void binarytodecimal::printbintodec(){
cout<<"\nDecimal is "<<val<<endl;
}
|
4d91119b249d1502e24ac0c6e17d64c2a13d9c0f
|
db4a6991ad018a7887a59f0fa3a629320c400967
|
/Tests/ClosestApproachTest.hh
|
79b868c8460bc707da531d2c7950c5d0cc210f1f
|
[
"Apache-2.0"
] |
permissive
|
KFTrack/KinKal
|
f19e195db5470b26fe01e7b9ec6a939181d4aa69
|
7533898608d8a921d689904a5de18baebe751c9d
|
refs/heads/main
| 2023-09-01T08:43:01.205448
| 2023-08-15T21:47:09
| 2023-08-15T21:47:09
| 241,995,258
| 3
| 17
| null | 2023-09-01T21:24:06
| 2020-02-20T21:36:41
|
C++
|
UTF-8
|
C++
| false
| false
| 10,209
|
hh
|
ClosestApproachTest.hh
|
//
// test basic functions of ClosestApproach using KTraj and Line
//
#include "KinKal/Trajectory/Line.hh"
#include "KinKal/Trajectory/ClosestApproach.hh"
#include "KinKal/Trajectory/PointClosestApproach.hh"
#include "KinKal/Trajectory/PiecewiseClosestApproach.hh"
#include "KinKal/Trajectory/ParticleTrajectory.hh"
#include "KinKal/General/BFieldMap.hh"
#include "KinKal/General/PhysicalConstants.h"
#include <iostream>
#include <cstdio>
#include <iostream>
#include <getopt.h>
#include <climits>
#include "TH1F.h"
#include "THelix.h"
#include "TFile.h"
#include "TPolyLine3D.h"
#include "TAxis3D.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "TVector3.h"
#include "TPolyLine3D.h"
#include "TPolyMarker3D.h"
#include "TLegend.h"
#include "TGraph.h"
#include "TRandom3.h"
#include "TH2F.h"
#include "TDirectory.h"
#include "TProfile.h"
#include "TProfile2D.h"
#include "TRandom3.h"
#include "TROOT.h"
#include "TStyle.h"
#include "TF1.h"
#include "TFitResult.h"
using namespace KinKal;
using namespace std;
// avoid confusion with root
using KinKal::Line;
void print_usage() {
printf("Usage: ClosestApproachTest --charge i--gap f --tmin f --tmax f --vprop f --delta f \n");
}
template <class KTRAJ>
int ClosestApproachTest(int argc, char **argv, KinKal::DVEC pchange ){
gROOT->SetBatch(kTRUE);
gStyle->SetOptFit(1);
using TCA = ClosestApproach<KTRAJ,Line>;
using TCAP = PointClosestApproach<KTRAJ>;
using PCA = PiecewiseClosestApproach<KTRAJ,Line>;
using PTRAJ = ParticleTrajectory<KTRAJ>;
int opt;
int status(0);
double mom(105.0), mincost(0.1), maxcost(0.7);
int icharge(-1);
double pmass(0.511), oz(0.0), ot(0.0);
double tmin(-10.0), tmax(10.0);
double wlen(1000.0); //length of the wire
double maxgap(2.5); // distance between Line and KTRAJ
double vprop(0.7);
double delta(5e-2);
unsigned nstep(50),ntstep(100), ntrks(10);
TRandom3 tr_; // random number generator
static struct option long_options[] = {
{"charge", required_argument, 0, 'q' },
{"tmin", required_argument, 0, 't' },
{"tmax", required_argument, 0, 'T' },
{"vprop", required_argument, 0, 'v' },
{"delta", required_argument, 0, 'd' }
};
int long_index =0;
while ((opt = getopt_long_only(argc, argv,"",
long_options, &long_index )) != -1) {
switch (opt) {
case 'q' : icharge = atoi(optarg);
break;
case 't' : tmin = atof(optarg);
break;
case 'T' : tmax = atof(optarg);
break;
case 'v' : vprop = atof(optarg);
break;
case 'd' : delta = atof(optarg);
break;
default: print_usage();
exit(EXIT_FAILURE);
}
}
// create helix
VEC3 bnom(0.0,0.0,1.0);
UniformBFieldMap BF(bnom); // 1 Tesla
VEC4 origin(0.0,0.0,oz,ot);
TFile tpfile((KTRAJ::trajName()+"ClosestApproach.root").c_str(),"RECREATE");
TCanvas* ttpcan = new TCanvas("ttpcan","DToca",1200,800);
ttpcan->Divide(3,2);
TCanvas* dtpcan = new TCanvas("dtpcan","DDoca",1200,800);
dtpcan->Divide(3,2);
std::vector<TGraph*> dtpoca, ttpoca;
for(size_t ipar=0;ipar<NParams();ipar++){
typename KTRAJ::ParamIndex parindex = static_cast<typename KTRAJ::ParamIndex>(ipar);
dtpoca.push_back(new TGraph(nstep*ntstep*ntrks));
string ts = KTRAJ::paramTitle(parindex)+string(" DOCA Change;#Delta DOCA (exact);#Delta DOCA (derivative)");
dtpoca.back()->SetTitle(ts.c_str());
ttpoca.push_back(new TGraph(nstep*ntstep*ntrks));
ts = KTRAJ::paramTitle(parindex)+string(" TOCA Change;#Delta TOCA (exact);#Delta TOCA (derivative)");
ttpoca.back()->SetTitle(ts.c_str());
}
for(unsigned itrk=0;itrk<ntrks;++itrk){
double phi = tr_.Uniform(-3.14,3.14);
double cost = tr_.Uniform(mincost,maxcost);
if(tr_.Uniform(-1.0,1.0) < 0.0)cost *= -1.0;
double sint = sqrt(1.0-cost*cost);
MOM4 momv(mom*sint*cos(phi),mom*sint*sin(phi),mom*cost,pmass);
KTRAJ ktraj(origin,momv,icharge,bnom);
for(unsigned itime=0;itime < ntstep;itime++){
double time = tmin + itime*(tmax-tmin)/(ntstep-1);
// create tline perp to trajectory at the specified time, separated by the specified gap
VEC3 ppos, pdir;
ppos = ktraj.position3(time);
pdir = ktraj.direction(time);
VEC3 perp1 = ktraj.direction(time,MomBasis::perpdir_);
VEC3 perp2 = ktraj.direction(time,MomBasis::phidir_);
// choose a specific direction for DOCA
// the line traj must be perp. to this and perp to the track
double eta = tr_.Uniform(-3.14,3.14);
VEC3 docadir = cos(eta)*perp1 + sin(eta)*perp2;
// sensor dir is perp to docadir and z axis
static VEC3 zdir(0.0,0.0,1.0);
VEC3 sdir = (docadir.Cross(zdir)).Unit();
double sspeed = CLHEP::c_light*vprop; // vprop is relative to c
VEC3 svel = sdir*sspeed;
// shift the sensor position
double gap = tr_.Uniform(0.01,maxgap);
VEC3 spos = ppos + gap*docadir;
// create the Line
Line tline(spos, time, svel, wlen);
// create ClosestApproach from these
CAHint tphint(time,time);
TCA tp(ktraj,tline,tphint,1e-8);
// test: delta vector should be perpendicular to both trajs
VEC3 del = tp.delta().Vect();
auto pd = tp.particleDirection();
auto sd = tp.sensorDirection();
double dp = del.Dot(pd);
if(dp>1e-9){
cout << "CA delta not perpendicular to particle direction" << endl;
status = 2;
}
double ds = del.Dot(sd);
if(ds>1e-9){
cout << "CA delta not perpendicular to sensor direction" << endl;
status = 2;
}
// test PointClosestApproach
VEC4 pt(spos.X(),spos.Y(),spos.Z(),time-1.0);
TCAP tpp(ktraj,pt,1e-8);
if(fabs(fabs(tpp.doca()) - gap) > 1e-8){
cout << "Point DOCA not correct, doca = " << tpp.doca() << " gap " << gap << endl;
status = 3;
}
// test against a piece-traj
PTRAJ ptraj(ktraj);
PCA pca(ptraj,tline,tphint,1e-8);
if(tp.status() != ClosestApproachData::converged)cout << "ClosestApproach status " << tp.statusName() << " doca " << tp.doca() << " dt " << tp.deltaT() << endl;
if(tpp.status() != ClosestApproachData::converged)cout << "PointClosestApproach status " << tpp.statusName() << " doca " << tpp.doca() << " dt " << tpp.deltaT() << endl;
if(pca.status() != ClosestApproachData::converged)cout << "PiecewiseClosestApproach status " << pca.statusName() << " doca " << pca.doca() << " dt " << pca.deltaT() << endl;
VEC3 thpos, tlpos;
thpos = tp.particlePoca().Vect();
tlpos = tp.sensorPoca().Vect();
double refd = tp.doca();
double reft = tp.deltaT(); // what matters physically is deltaT
// cout << " Helix Pos " << pos << " ClosestApproach KTRAJ pos " << thpos << " ClosestApproach Line pos " << tlpos << endl;
// cout << " ClosestApproach particlePoca " << tp.particlePoca() << " ClosestApproach sensorPoca " << tp.sensorPoca() << " DOCA " << refd << endl;
// cout << "ClosestApproach dDdP " << tp.dDdP() << " dTdP " << tp.dTdP() << endl;
// test against numerical derivatives
// range to change specific parameters; most are a few mm
for(size_t ipar=0;ipar<NParams();ipar++){
double dstep = pchange[ipar]/(nstep-1);
double dstart = -0.5*pchange[ipar];
for(unsigned istep=0;istep<nstep;istep++){
// compute exact change in DOCA
auto dvec = ktraj.params().parameters();
double dpar = dstart + dstep*istep;
dvec[ipar] += dpar;
Parameters pdata(dvec,ktraj.params().covariance());
KTRAJ dktraj(pdata,ktraj);
TCA dtp(dktraj,tline,tphint,1e-9);
double xd = dtp.doca();
double xt = dtp.deltaT();
// now derivatives; sign flip is due to convention sensor-prediction
double dd = -tp.dDdP()[ipar]*dpar;
double dt = -tp.dTdP()[ipar]*dpar;
int ientry = istep + nstep*itime + itrk*ntstep*nstep;
dtpoca[ipar]->SetPoint(ientry,xd-refd,dd);
ttpoca[ipar]->SetPoint(ientry,xt-reft,dt);
}
}
}
}
TF1* pline = new TF1("pline","[0]+[1]*x");
for(size_t ipar=0;ipar<NParams();ipar++){
// dtpoca[ipar]->SetStats(1);
dtpcan->cd(ipar+1);
// test linearity
pline->SetParameters(0.0,1.0);
// ignore parameters that don't have appreciable range
double xmax = -std::numeric_limits<float>::max();
double xmin = std::numeric_limits<float>::max();
unsigned npt = (unsigned)dtpoca[ipar]->GetN();
for(unsigned ipt=0; ipt < npt;++ipt){
xmax = std::max(dtpoca[ipar]->GetPointX(ipt),xmax);
xmin = std::min(dtpoca[ipar]->GetPointX(ipt),xmin);
}
if(xmax-xmin > 1e-6) {
TFitResultPtr pfitr = dtpoca[ipar]->Fit(pline,"SQ","AC*");
if(fabs(pfitr->Parameter(0))> 10*delta || fabs(pfitr->Parameter(1)-1.0) > delta){
cout << "DOCA derivative for parameter "
<< KTRAJ::paramName(typename KTRAJ::ParamIndex(ipar))
<< " Out of tolerance : Offset " << pfitr->Parameter(0) << " Slope " << pfitr->Parameter(1) << endl;
status = 1;
}
}
dtpoca[ipar]->Draw("AF*");
}
for(size_t ipar=0;ipar<NParams();ipar++){
ttpcan->cd(ipar+1);
double xmax = -std::numeric_limits<float>::max();
double xmin = std::numeric_limits<float>::max();
unsigned npt = (unsigned)dtpoca[ipar]->GetN();
for(unsigned ipt=0; ipt < npt;++ipt){
xmax = std::max(ttpoca[ipar]->GetPointX(ipt),xmax);
xmin = std::min(ttpoca[ipar]->GetPointX(ipt),xmin);
}
if(xmax-xmin > 1e-6) {
TFitResultPtr pfitr = ttpoca[ipar]->Fit(pline,"SQ","AC*");
if(fabs(pfitr->Parameter(0))> 10*delta || fabs(pfitr->Parameter(1)-1.0) > delta){
cout << "DeltaT derivative for parameter "
<< KTRAJ::paramName(typename KTRAJ::ParamIndex(ipar))
<< " Out of tolerance : Offset " << pfitr->Parameter(0) << " Slope " << pfitr->Parameter(1) << endl;
status = 1;
}
}
ttpoca[ipar]->Draw("AF*");
}
dtpcan->Write();
ttpcan->Write();
tpfile.Write();
tpfile.Close();
return status;
}
|
1ab595beb048a4ab48d8c5c74bc3cc3c7d793624
|
8213a319bbe4532875faa01539cc4f1e77bf78af
|
/btree.cpp
|
a8a3cba1ec9ea5b8d9f1e631bcea5cb097ab6b65
|
[] |
no_license
|
wawila/B-Tree
|
f93fbffe5e633bb5a33f94fa487137b8e87895c8
|
e17c73e64993769ff3a8d358ed3a034418a4ff8a
|
refs/heads/master
| 2020-05-31T21:18:28.584891
| 2015-09-20T00:53:42
| 2015-09-20T00:53:42
| 42,378,404
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,785
|
cpp
|
btree.cpp
|
#include "btree.h"
bool Btree::insert(dtype x)
{ node *pNew;
dtype xNew;
status code = ins(root, x, xNew, pNew);
if (code == DuplicateKey)
cout << "Duplicate key ignored.\n";
if (code == InsertNotComplete)
{ node *root0 = root;
root = new node;
root->n = 1; root->k[0] = xNew;
root->p[0] = root0; root->p[1] = pNew;
return true;
}
return false;
}
status Btree::ins(node *r, dtype x, dtype &y, node* &q)
{ // Insert x in *this. If not completely successful, the
// integer y and the pointer q remain to be inserted.
// Return value:
// Success, DuplicateKey or InsertNotComplete.
node *pNew, *pFinal;
int i, j, n;
dtype xNew, kFinal;
status code;
if (r == NULL){q = NULL; y = x; return InsertNotComplete;}
n = r->n;
i = NodeSearch(x, r->k, n);
if (i < n && x == r->k[i]) return DuplicateKey;
code = ins(r->p[i], x, xNew, pNew);
if (code != InsertNotComplete) return code;
// Insertion in subtree did not completely succeed;
// try to insert xNew and pNew in the current node:
if (n < M - 1)
{ i = NodeSearch(xNew, r->k, n);
for (j=n; j>i; j--)
{ r->k[j] = r->k[j-1]; r->p[j+1] = r->p[j];
}
r->k[i] = xNew; r->p[i+1] = pNew; ++r->n;
return Success;
}
// Current node is full (n == M - 1) and will be split.
// Pass item k[h] in the middle of the augmented
// sequence back via parameter y, so that it
// can move upward in the tree. Also, pass a pointer
// to the newly created node back via parameter q:
if (i == M - 1) {kFinal = xNew; pFinal = pNew;} else
{ kFinal = r->k[M-2]; pFinal = r->p[M-1];
for (j=M-2; j>i; j--)
{ r->k[j] = r->k[j-1]; r->p[j+1] = r->p[j];
}
r->k[i] = xNew; r->p[i+1] = pNew;
}
int h = (M - 1)/2;
y = r->k[h]; // y and q are passed on to the
q = new node; // next higher level in the tree
// The values p[0],k[0],p[1],...,k[h-1],p[h] belong to
// the left of k[h] and are kept in *r:
r->n = h;
// p[h+1],k[h+1],p[h+2],...,k[M-2],p[M-1],kFinal,pFinal
// belong to the right of k[h] and are moved to *q:
q->n = M - 1 - h;
for (j=0; j < q->n; j++)
{ q->p[j] = r->p[j + h + 1];
q->k[j] = (j < q->n - 1 ? r->k[j + h + 1] : kFinal);
}
q->p[q->n] = pFinal;
return InsertNotComplete;
}
void Btree::pr(const node *r, int nSpace)const
{ if (r)
{ int i;
cout << setw(nSpace) << "";
for (i=0; i < r->n; i++)
cout << setw(3) << r->k[i] << " ";
cout << endl;
for (i=0; i <= r->n; i++) pr(r->p[i], nSpace+8);
}
}
int Btree::NodeSearch(dtype x, const dtype *a, int n)const
{ int i=0;
while (i < n && x > a[i]) i++;
return i;
}
void Btree::ShowSearch(dtype x)const
{ cout << "Search path:\n";
int i, j, n;
node *r = root;
while (r)
{ n = r->n;
for (j=0; j<r->n; j++) cout << " " << r->k[j];
cout << endl;
i = NodeSearch(x, r->k, n);
if (i < n && x == r->k[i])
{ cout << "Key " << x << " found in position " << i
<< " of last displayed node.\n";
return;
}
r = r->p[i];
}
cout << "Key " << x << " not found.\n";
}
bool Btree::DelNode(dtype x)
{ node *root0;
switch (del(root, x))
{
case NotFound:
cout << x << " not found.\n";
break;
case Underflow:
root0 = root;
root = root->p[0];
delete root0;
return true;
}
return false;
}
status Btree::del(node *r, dtype x)
{ if (r == NULL) return NotFound;
int i, j, pivot, n = r->n;
dtype *k = r->k; // k[i] means r->k[i]
const int nMin = (M - 1)/2;
status code;
node **p = r->p, *pL, *pR; // p[i] means r->p[i]
i = NodeSearch(x, k, n);
if (p[0] == NULL) // *r is a leaf
{ if (i == n || x < k[i]) return NotFound;
// x == k[i], and *r is a leaf
for (j=i+1; j < n; j++)
{ k[j-1] = k[j]; p[j] = p[j+1];
}
return
--r->n >= (r==root ? 1 : nMin) ? Success : Underflow;
}
// *r is an interior node, not a leaf:
if (i < n && x == k[i])
{ // x found in an interior node. Go to left child
// *p[i] and follow a path all the way to a leaf,
// using rightmost branches:
node *q = p[i], *q1; int nq;
for (;;)
{ nq = q->n; q1 = q->p[nq];
if (q1 == NULL) break;
q = q1;
}
// Exchange k[i] (= x) with rightmost item in leaf:
k[i] = q->k[nq-1];
q->k[nq - 1] = x;
}
// Delete x in leaf of subtree with root p[i]:
code = del(p[i], x);
if (code != Underflow) return code;
// There is underflow; borrow, and, if necessary, merge:
// Too few data items in node *p[i]
if (i > 0 && p[i-1]->n > nMin) // Borrow from left sibling
{ pivot = i - 1; // k[pivot] between pL and pR:
pL = p[pivot]; pR = p[i];
// Increase contents of *pR, borrowing from *pL:
pR->p[pR->n + 1] = pR->p[pR->n];
for (j=pR->n; j>0; j--)
{ pR->k[j] = pR->k[j-1];
pR->p[j] = pR->p[j-1];
}
pR->n++;
pR->k[0] = k[pivot];
pR->p[0] = pL->p[pL->n];
k[pivot] = pL->k[--pL->n];
return Success;
}
if (i<n && p[i+1]->n > nMin) // Borrow from right sibling
{ pivot = i; // k[pivot] between pL and pR:
pL = p[pivot]; pR = p[pivot+1];
// Increase contents of *pL, borrowing from *pR:
pL->k[pL->n] = k[pivot];
pL->p[pL->n + 1] = pR->p[0];
k[pivot] = pR->k[0];
pL->n++; pR->n--;
for (j=0; j < pR->n; j++)
{ pR->k[j] = pR->k[j+1];
pR->p[j] = pR->p[j+1];
}
pR->p[pR->n] = pR->p[pR->n + 1];
return Success;
}
// Merge; neither borrow left nor borrow right possible.
pivot = (i == n ? i - 1 : i);
pL = p[pivot]; pR = p[pivot+1];
// Add k[pivot] and *pR to *pL:
pL->k[pL->n] = k[pivot];
pL->p[pL->n + 1] = pR->p[0];
for (j=0; j < pR->n; j++)
{ pL->k[pL->n + 1 + j] = pR->k[j];
pL->p[pL->n + 2 + j] = pR->p[j+1];
}
pL->n += 1 + pR->n;
delete pR;
for (j=i+1; j < n; j++)
{ k[j-1] = k[j]; p[j] = p[j+1];
}
return
--r->n >= (r == root ? 1 : nMin) ? Success : Underflow;
}
// Retorna la altura del arbol, empieza en 0, i = -1
int Btree :: altura(node * root, int i)
{
if(!root)
{
cout<<"NULL"<<endl;
return i;
}
else
{
cout<<root->k[0]<<"("<<root->n<<") - ";
i++;
altura(root->p[0], i);
}
}
// Retorna cuantas Hojas hay (Nodos sin hijos), empieza en 0, j y l = -1
int Btree :: numHojas(node *root, int j, int l)
{
if(!root)
{
return j;
}
else
{
for(int i = 0; i <= root->n ; i++)
{
if(l > j) j = l;
l = numHojas(root->p[i], j++, l);
}
}
return l;
}
QString Btree :: buscar(dtype x)
{
QString sr;
sr.clear();
int i, j, n;
node *r = root;
while (r)
{ n = r->n;
for (j=0; j<r->n; j++)
{
sr.append(" ");
sr.append(QString::number(r->k[j]));
}
sr.append(" -> ");
i = NodeSearch(x, r->k, n);
if (i < n && x == r->k[i])
{
return sr;
}
r = r->p[i];
}
sr.append("No se encontro: ");
sr.append(QString::number(x));
return sr;
}
void Btree :: printTree(node * rt, int x, int y)
{
if(!rt)
return;
else
{
scene->addRect(QRectF(320, 81, 25, 25));
for(int i = 0; i < y ; i++)
{
int j = 0;
while (rt->p[j])
{
if(j % 2 == 0)
scene->addRect(QRectF(320+(x*25), 81+(y*25), 25, 25));
else
scene->addRect(QRectF(320-(x*25), 81+(y*25), 25, 25));
j++;
}
rt = rt->p[i];
}
// scene->addRect(QRectF(310+x, 71+y, 25, 25));
// for(int i = 0; i < rt->n; i++)
// printTree(rt->p[i], (x+1)*25, (y+1)*25);
}
}
void Btree :: play()
{ cout <<
"B-tree structure shown by indentation. For each\n"
"node, the number of links to other nodes will not\n"
"be greater than " << M <<
", the order M of the B-tree.\n\n"
"Enter some integers, followed by a slash (/):\n";
Btree t;
dtype x;
char ch;
while (cin >> x, !cin.fail()) t.insert(x);
cout <<
"\nB-tree representation (indentation similar to the\n"
"table of contents of a book). The items stored in\n"
"each node are displayed on a single line.\n";
t.print();
cin.clear(); cin >> ch; // Skip terminating character
for (;;)
{ cout <<
"\nEnter an integer, followed by I, D, or S (for\n"
"Insert, Delete and Search), or enter Q to quit: ";
cin >> x >> ch;
if (cin.fail()) break;
ch = toupper(ch);
switch(ch)
{
case 'S': t.ShowSearch(x); break;
case 'I': t.insert(x); break;
case 'D': t.DelNode(x); break;
default:
cout << "Invalid command, use S, I or D\n"; break;
}
if (ch == 'I' || ch == 'D') t.print();
}
cout<<"-------------------------------------------------------"<<endl;
cout<<"Altura: "<<altura(t.root, -1)<<endl;
cout<<"----------------------------------"<<endl;
cout<<"Num Hojas: "<<numHojas(t.root, -1, -1)<<endl;
}
|
3a96a31376c7825ab93fe14c7a6d0d52e6b9fbe9
|
cb8c337a790b62905ad3b30f7891a4dff0ae7b6d
|
/st-ericsson/tools/platform/flash_kit/loader_communication/source/CEH/ProtromRpcInterface.h
|
f4c83093c31adef7a893036f696d5d721828230c
|
[
"Apache-1.1",
"SMLNJ",
"BSD-3-Clause",
"LicenseRef-scancode-other-permissive",
"W3C",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-public-domain-disclaimer"
] |
permissive
|
CustomROMs/android_vendor
|
67a2a096bfaa805d47e7d72b0c7a0d7e4830fa31
|
295e660547846f90ac7ebe42a952e613dbe1b2c3
|
refs/heads/master
| 2020-04-27T15:01:52.612258
| 2019-03-11T13:26:23
| 2019-03-12T11:23:02
| 174,429,381
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,337
|
h
|
ProtromRpcInterface.h
|
/*******************************************************************************
* Copyright (C) ST-Ericsson SA 2011
* License terms: 3-clause BSD license
******************************************************************************/
#ifndef _PROTROMRPCINTERFACE_H_
#define _PROTROMRPCINTERFACE_H_
#include "CmdResult.h"
#include "LcmInterface.h"
#ifdef _WIN32
#include "WinApiWrappers.h"
#else
#include "CSimpleQueue.h"
#endif
/// <summary>
/// PROTROM command definitions.
/// </summary>
#define HEADER_A2_IDENTIFIER (0x0003BEBA)
typedef enum {
PROTROM_PDU_HEADER = 1,
PROTROM_PDU_PAYLOAD = 2,
PROTROM_PDU_PAYLOAD_FINAL = 3,
PROTROM_PDU_RESULT = 4,
PROTROM_PDU_READY_TO_RECEIVE = 5,
PROTROM_PDU_ERROR_DATA = 6,
PROTROM_PDU_SECURITY_DATA_REQ = 8,
PROTROM_PDU_SECURITY_DATA_RES = 9,
PROTROM_PDU_DOMAIN_DATA_REQ = 43,
PROTROM_PDU_DOMAIN_DATA = 44,
PROTROM_PDU_ROOT_KEY_REQ = 45,
PROTROM_PDU_ROOT_KEY_DATA = 46,
PROTROM_PDU_PATCH_REQ = 47,
PROTROM_PDU_PATCH_DATA = 48,
PROTROM_PDU_PATCH_DATA_FINAL = 49,
PROTROM_PDU_HEADER_OK_SW_REV = 51,
PROTROM_PDU_SW_REV_DATA = 52,
PROTROM_PDU_WDOG_RESET = 53,
PROTROM_PDU_DATA_NOT_FOUND = 100
} PROTROMCommandId_e;
struct TProtromInfo {
int ReceivedPdu;
void *DataP;
uint32 Length;
uint8 Status;
};
class ProtromRpcInterface
{
public:
ProtromRpcInterface(CmdResult *CmdResult, LcmInterface *LcmInterface);
virtual ~ProtromRpcInterface();
CSimpleQueue ProtromQueue;
//PROTROM-Protocol
ErrorCode_e DoRPC_PROTROM_ResultPdu(int Status);
ErrorCode_e DoRPC_PROTROM_SendLoaderHeader(unsigned char *pFile, uint32 Size);
ErrorCode_e DoRPC_PROTROM_SendLoaderPayload(unsigned char *pFile, uint32 Size);
ErrorCode_e DoRPC_PROTROM_SendLoaderFinalPayload(unsigned char *pFile, uint32 Size);
ErrorCode_e DoRPC_PROTROM_ReadSecurityData(uint8 SecDataId);
ErrorCode_e DoneRPC_PROTROM_ResultImpl(CommandData_t CmdData);
ErrorCode_e DoneRPC_PROTROM_ReadSecurityDataImpl(CommandData_t CmdData);
ErrorCode_e DoneRPC_PROTROM_ReadyToReceiveImpl(CommandData_t CmdData);
ErrorCode_e Do_CEH_Callback(CommandData_t *pCmdData);
private:
uint8 *PROTROM_Payload;
CmdResult *cmdResult_;
LcmInterface *lcmInterface_;
};
#endif // _PROTROMRPCINTERFACE_H_
|
522e98160acd1f90e594278144e2188e5b6a6a03
|
1c38b1403f0024b7eaf583db01836d1bd2a1d62c
|
/GameEngine/Include/Component/Light.cpp
|
229f856bb67753aaef3bb69e1d20c54aa13a9f30
|
[] |
no_license
|
chimec153/DirectX11-2D-Game
|
46f349418fae2e4420d0eb6e768b57b0a3f4d990
|
fbedaad9bc0fd33666393480be041f9fc8f89e19
|
refs/heads/master
| 2023-06-13T23:28:51.831499
| 2021-06-11T16:19:25
| 2021-06-11T16:19:25
| 295,000,343
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,658
|
cpp
|
Light.cpp
|
#include "Light.h"
#include "../Resource/ShaderManager.h"
#include "../Camera/CameraManager.h"
#include "../Component/Camera.h"
#include "../Device.h"
std::unordered_map<std::string, Light*> Light::m_mapLight = {};
Light* Light::m_pMainLight = nullptr;
Light::Light() :
m_tCBuffer()
, m_matView()
, m_matProj()
, m_matVP()
{
m_tCBuffer.vDif = Vector4::White;
m_tCBuffer.vAmb = Vector4(0.2f, 0.2f, 0.2f, 1.f);
m_tCBuffer.vSpc = Vector4::White;
m_tCBuffer.vEmv = Vector4::White;
m_tCBuffer.fAngleOut = PI_DIV2 / 3.f;
m_tCBuffer.fAngleIn = PI_DIV4 / 2.f;
m_tCBuffer.fRange = 50.f;
m_tCBuffer.vAttn.y = 5.f;
m_tCBuffer.vAttn.z = 7.f;
}
Light::Light(const Light& light) :
m_tCBuffer(light.m_tCBuffer)
, m_matView(light.m_matView)
, m_matProj(light.m_matProj)
, m_matVP(light.m_matVP)
{
}
Light::~Light()
{
}
const Matrix& Light::GetView() const
{
return m_matView;
}
const Matrix& Light::GetProj() const
{
return m_matProj;
}
const Matrix& Light::GetVP() const
{
return m_matVP;
}
void Light::SetRange(float fRange)
{
m_tCBuffer.fRange = fRange;
}
void Light::SetAngleIn(float fAngleIn)
{
m_tCBuffer.fAngleIn = fAngleIn;
}
void Light::SetAngleOut(float fAngleOut)
{
m_tCBuffer.fAngleOut = fAngleOut;
}
void Light::SetAttn(float c, float a, float b)
{
SetAttn(Vector3(c, a, b));
}
void Light::SetAttn(const Vector3& vAttn)
{
m_tCBuffer.vAttn = vAttn;
}
void Light::SetDif(const Vector4& vDif)
{
m_tCBuffer.vDif = vDif;
}
void Light::SetAmb(const Vector4& vAmb)
{
m_tCBuffer.vAmb = vAmb;
}
void Light::SetSpc(const Vector4& vSpc)
{
m_tCBuffer.vSpc = vSpc;
}
void Light::SetEmv(const Vector4& vEmv)
{
m_tCBuffer.vEmv = vEmv;
}
void Light::SetDif(float r, float g, float b, float a)
{
SetDif(Vector4(r, g, b, a));
}
void Light::SetAmb(float r, float g, float b, float a)
{
SetAmb(Vector4(r, g, b, a));
}
void Light::SetSpc(float r, float g, float b, float a)
{
SetSpc(Vector4(r, g, b, a));
}
void Light::SetEmv(float r, float g, float b, float a)
{
SetEmv(Vector4(r, g, b, a));
}
void Light::SetDif(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
SetDif(Vector4(r/255.f, g / 255.f, b / 255.f, a / 255.f));
}
void Light::SetAmb(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
SetAmb(Vector4(r / 255.f, g / 255.f, b / 255.f, a / 255.f));
}
void Light::SetSpc(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
SetSpc(Vector4(r / 255.f, g / 255.f, b / 255.f, a / 255.f));
}
void Light::SetEmv(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
SetEmv(Vector4(r / 255.f, g / 255.f, b / 255.f, a / 255.f));
}
void Light::SetLightType(LIGHT_TYPE eType)
{
m_tCBuffer.eType = eType;
switch (m_tCBuffer.eType)
{
case LIGHT_TYPE::DIRECTIONAL:
{
Resolution tRS = RESOLUTION;
m_matProj = XMMatrixOrthographicLH(
static_cast<float>(tRS.iWidth), static_cast<float>(tRS.iHeight),
0.3f, 5000.f);
}
break;
case LIGHT_TYPE::POINT:
{
}
break;
case LIGHT_TYPE::SPOT:
{
}
break;
}
}
bool Light::Init()
{
if (!CSceneComponent::Init())
return false;
SetLightType(LIGHT_TYPE::DIRECTIONAL);
return true;
}
void Light::Start()
{
CSceneComponent::Start();
}
void Light::Update(float fTime)
{
CSceneComponent::Update(fTime);
CCamera* pCam = GET_SINGLE(CCameraManager)->GetMainCam();
Matrix view = pCam->GetViewMat();
SAFE_RELEASE(pCam);
switch (m_tCBuffer.eType)
{
case LIGHT_TYPE::DIRECTIONAL:
{
Vector3 vAxis = GetWorldAxis(WORLD_AXIS::AXIS_Z);
m_tCBuffer.vDir = vAxis.TransformNormal(view);
m_tCBuffer.vDir.Normalize();
Vector3 vPos = GetWorldPos();
Vector3 vAxis_x = GetWorldAxis(WORLD_AXIS::AXIS_X);
Vector3 vAxis_y = GetWorldAxis(WORLD_AXIS::AXIS_Y);
m_matView[0][0] = vAxis_x.x;
m_matView[1][0] = vAxis_x.y;
m_matView[2][0] = vAxis_x.z;
m_matView[0][1] = vAxis_y.x;
m_matView[1][1] = vAxis_y.y;
m_matView[2][1] = vAxis_y.z;
m_matView[0][2] = vAxis.x;
m_matView[1][2] = vAxis.y;
m_matView[2][2] = vAxis.z;
m_matView[3][0] = -vPos.Dot(vAxis_x);
m_matView[3][1] = -vPos.Dot(vAxis_y);
m_matView[3][1] = -vPos.Dot(vAxis);
m_matVP = m_matView * m_matProj;
m_tCBuffer.matVP = m_matVP;
m_tCBuffer.matVP.Transpose();
}
break;
case LIGHT_TYPE::POINT:
{
Vector3 vPos = GetWorldPos();
m_tCBuffer.vPos = vPos.TransformCoord(view);
}
break;
case LIGHT_TYPE::SPOT:
{
Vector3 vPos = GetWorldPos();
m_tCBuffer.vPos = vPos.TransformCoord(view);
Vector3 vAxis = GetWorldAxis(WORLD_AXIS::AXIS_Z);
m_tCBuffer.vDir = vAxis.TransformNormal(view);
m_tCBuffer.vDir.Normalize();
}
break;
}
}
void Light::PostUpdate(float fTime)
{
CSceneComponent::PostUpdate(fTime);
}
void Light::Collision(float fTime)
{
CSceneComponent::Collision(fTime);
}
void Light::PreRender(float fTime)
{
//CSceneComponent::PreRender(fTime);
}
void Light::Render(float fTime)
{
CSceneComponent::Render(fTime);
SetShader();
UINT iStride = 0;
UINT iOffset = 0;
ID3D11Buffer* pBuffer = nullptr;
CONTEXT->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
CONTEXT->IASetVertexBuffers(0, 1, &pBuffer, &iStride, &iOffset);
CONTEXT->Draw(4, 0);
}
void Light::PostRender(float fTime)
{
CSceneComponent::PostRender(fTime);
}
Light* Light::Clone()
{
return new Light(*this);
}
void Light::Save(FILE* pFile)
{
CSceneComponent::Save(pFile);
}
void Light::Load(FILE* pFile)
{
CSceneComponent::Load(pFile);
}
void Light::SpawnWindow()
{
CSceneComponent::SpawnWindow();
const char* pName = GetName().c_str();
if (!strcmp(pName, ""))
{
pName = "None";
}
if(ImGui::Begin(pName))
{
ImGui::ColorPicker4("Diffuse", &m_tCBuffer.vDif.x);
ImGui::ColorPicker4("Ambient", &m_tCBuffer.vAmb.x);
ImGui::ColorPicker4("Specular", &m_tCBuffer.vSpc.x);
ImGui::ColorPicker4("Emissive", &m_tCBuffer.vEmv.x);
static Vector3 vRot = {};
ImGui::SliderFloat3("Rotation", &vRot.x, -180.f, 180.f);
SetQuaternionRot(Vector4(1.f, 0.f, 0.f, 0.f), vRot.x);
Vector3 vPos = GetWorldPos();
ImGui::InputFloat3("Position", &vPos.x);
SetWorldPos(vPos);
ImGui::SliderFloat("AngleIn", &m_tCBuffer.fAngleIn, 0.f, 90.f);
ImGui::SliderFloat("AngleOut", &m_tCBuffer.fAngleOut, 0.f, 90.f);
ImGui::InputFloat3("Attenuation", &m_tCBuffer.vAttn.x);
ImGui::SliderInt("Light Type", reinterpret_cast<int*>(&m_tCBuffer.eType), 0, static_cast<int>(LIGHT_TYPE::SPOT));
ImGui::InputFloat("Light Range", &m_tCBuffer.fRange);
}
ImGui::End();
}
void Light::SetShader()
{
GET_SINGLE(CShaderManager)->UpdateCBuffer("Light", &m_tCBuffer);
}
Light* Light::FindLight(const std::string& strKey)
{
std::unordered_map<std::string, Light*>::iterator iter = m_mapLight.find(strKey);
if (iter == m_mapLight.end())
return nullptr;
iter->second->AddRef();
return iter->second;
}
void Light::SetLight()
{
std::unordered_map<std::string, Light*>::iterator iter = m_mapLight.begin();
std::unordered_map<std::string, Light*>::iterator iterEnd = m_mapLight.end();
for (; iter != iterEnd; ++iter)
{
iter->second->SetShader();
}
}
void Light::Destroy()
{
SAFE_RELEASE_MAP(m_mapLight);
SAFE_RELEASE(m_pMainLight);
}
void Light::RenderAll(float fTime)
{
std::unordered_map<std::string, Light*>::iterator iter = m_mapLight.begin();
std::unordered_map<std::string, Light*>::iterator iterEnd = m_mapLight.end();
for (; iter != iterEnd; ++iter)
{
iter->second->Render(fTime);
}
}
void Light::SetMainLight(Light* pLight)
{
SAFE_RELEASE(m_pMainLight);
m_pMainLight = pLight;
if (m_pMainLight)
{
m_pMainLight->AddRef();
}
}
Light* Light::GetMainLight()
{
if (m_pMainLight)
{
m_pMainLight->AddRef();
}
return m_pMainLight;
}
|
2f83f3363b17998830abcdc34f5d53021c563c7c
|
886bf2d5c9b956fd402c351e8de15ae7f5c5ecaf
|
/dhruvil_11/1183/A [Nearest Interesting Number].cpp
|
3226407fd94af9f42bf82cd2e04e1a2af4599b2b
|
[] |
no_license
|
dhruwill/Codeforces
|
7656d6013c29c25b9312ce021cd2ce8ce7f8c798
|
d034a19562291dc84fe5ed914b6c0f66782708c8
|
refs/heads/master
| 2020-06-17T02:55:04.521369
| 2019-07-08T08:50:53
| 2019-07-08T08:50:53
| 195,772,744
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 758
|
cpp
|
A [Nearest Interesting Number].cpp
|
#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
using namespace std;
#define testcase(t) int t;cin>>t;while(t--)
#define pb push_back
#define eb emplace_back
#define ll long long int
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define endl "\n"
#define imax INT_MAX
#define imin INT_MIN
bool sortbysec(const pair<int,int> &a,
const pair<int,int> &b)
{
return (a.second < b.second);
}
int main()
{
IOS
//n==1
int n;
cin>>n;
int f=0;
while(1)
{
int z = n;
int sum =0 ;
while(z>0)
{
sum+=z%10;
z/=10;
}
if(sum%4==0)
{
cout<<n;
return 0;
}
n++;
}
}
|
d81c11088476a4ad2593e3f1f7b435cdd1cb5291
|
4d78001ee2b4bafb3e7f1435e7a082fc6f634d55
|
/BaseUtil/source/TaskLoop.cpp
|
66c64d5f6adc1f4c35dd5e53e8c7dbdfb356d04d
|
[] |
no_license
|
tanxinhua/BaseUtil
|
94c751fbc23ead4f8f3346820955fc90c2d768bd
|
f4f59da1c5a8692b75604e9ee3220a7f97656a7f
|
refs/heads/master
| 2020-12-09T17:12:53.627170
| 2020-01-12T11:13:03
| 2020-01-12T11:13:03
| 233,367,863
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,005
|
cpp
|
TaskLoop.cpp
|
#include <deque>
#include <mutex>
#include <uv.h>
//#include "log\i_local_logger_helper.h"
#include <TaskLoop.h>
namespace BaseUtil
{
using FlowFlag = enum FlowFlag
{
FlowNone,
FlowRuning,
FlowEnd
};
}
class BaseUtil::PrivateTaskLoop {
public:
PrivateTaskLoop();
~PrivateTaskLoop();
static void WakeUp(uv_async_t *handle);
static void RunTask(uv_async_t *handle);
void WakeUp();
void RunTask();
Task init_func_;
Task uninit_func_;
std::deque<BaseUtil::TaskPacket> container_low_;
std::deque<BaseUtil::TaskPacket> container_high_;
std::mutex lock_low_;
std::mutex lock_high_;
uv_loop_t thread_loop_;
uv_async_t async_1_;
uv_async_t async_2_;
FlowFlag flow_flag_ = FlowNone;
};
BaseUtil::PrivateTaskLoop::PrivateTaskLoop() {
}
BaseUtil::PrivateTaskLoop::~PrivateTaskLoop() {
}
void BaseUtil::PrivateTaskLoop::WakeUp(uv_async_t *handle)
{
;
}
void BaseUtil::PrivateTaskLoop::RunTask(uv_async_t *handle)
{
BaseUtil::PrivateTaskLoop *d_ = (BaseUtil::PrivateTaskLoop*)handle->data;
d_->RunTask();
}
void BaseUtil::PrivateTaskLoop::RunTask()
{
{
std::deque<BaseUtil::TaskPacket> deque_high;
lock_high_.lock();
std::swap(deque_high, container_high_);
lock_high_.unlock();
while (deque_high.size() > 0) {
auto t = deque_high.front();
t.task_();
deque_high.pop_front();
}
}
{
std::deque<BaseUtil::TaskPacket> deque_low;
lock_low_.lock();
std::swap(deque_low, container_high_);
lock_low_.unlock();
while (deque_low.size() > 0) {
auto t = deque_low.front();
t.task_();
deque_low.pop_front();
}
}
}
void BaseUtil::PrivateTaskLoop::WakeUp()
{
uv_async_send(&async_2_);
}
///////////////////////////////////////////////////////////////////////////////////////////
BaseUtil::TaskLoop::TaskLoop():d_(new PrivateTaskLoop)
{
}
BaseUtil::TaskLoop::~TaskLoop()
{
}
void BaseUtil::TaskLoop::RunLoop()
{
int ret = uv_loop_init(&d_->thread_loop_);
//uv_timer_t uv_timer_;
//uv_timer_init(&d_->thread_loop_, &uv_timer_);
//uv_timer_start(&uv_timer_, [](uv_timer_t* handle) {
// printf("=============");
// //uv_timer_stop(handle);
// //uv_close((uv_handle_t*)handle, NULL);
//}, 10000, 3);
if (ret != 0) {
// LOG_ERROR << "uv_loop_init init error!ret =" << ret << LOG_END;
return;
}
d_->async_1_.data = (void*)this;
d_->async_2_.data = (void*)this;
uv_async_init(&d_->thread_loop_, &d_->async_1_, BaseUtil::PrivateTaskLoop::RunTask);
uv_async_init(&d_->thread_loop_, &d_->async_2_, BaseUtil::PrivateTaskLoop::WakeUp);
d_->flow_flag_ = FlowRuning;
//crp->init_func_ ? crp->init_func_() : nullptr;
uv_run(&d_->thread_loop_, UV_RUN_DEFAULT);
//crp->uninit_func_ ? crp->uninit_func_() : nullptr;
uv_close((uv_handle_t*)&d_->async_1_, NULL);
uv_close((uv_handle_t*)&d_->async_2_, NULL);
uv_loop_close(&d_->thread_loop_);
d_->flow_flag_ = FlowEnd;
}
bool BaseUtil::TaskLoop::IsRuning()
{
return FlowRuning == d_->flow_flag_ ? true : false;
}
void BaseUtil::TaskLoop::QuitLoop()
{
uv_stop(&d_->thread_loop_);
}
bool BaseUtil::TaskLoop::PostTask(const Task & cb, int type_id_, TaskType type)
{
if (!IsRuning()) {
return false;
}
TaskPacket task;
task.task_ = cb;
task.type_id_ = type_id_;
switch (type)
{
case BaseUtil::AllLevel:
case BaseUtil::LowLevel:
{
std::unique_lock<std::mutex> locker(d_->lock_low_);
d_->container_low_.push_back(task);
}
break;
case BaseUtil::HighLevel:
{
std::unique_lock<std::mutex> locker(d_->lock_high_);
d_->container_high_.push_back(task);
}
break;
default:
break;
}
d_->WakeUp();
return true;
}
void BaseUtil::TaskLoop::WakeUp()
{
d_->WakeUp();
}
void BaseUtil::TaskLoop::ClearByTaskType(TaskType type)
{
switch (type)
{
case BaseUtil::AllLevel:
{
std::unique_lock<std::mutex> locker(d_->lock_low_);
d_->container_low_.clear();
}
{
std::unique_lock<std::mutex> locker(d_->lock_high_);
d_->container_high_.clear();
}
break;
case BaseUtil::LowLevel:
{
std::unique_lock<std::mutex> locker(d_->lock_low_);
d_->container_low_.clear();
}
break;
case BaseUtil::HighLevel:
{
std::unique_lock<std::mutex> locker(d_->lock_high_);
d_->container_high_.clear();
}
break;
default:
break;
}
}
void BaseUtil::TaskLoop::ClearByTaskId(int type_id)
{
{
std::unique_lock<std::mutex> locker(d_->lock_low_);
std::deque<BaseUtil::TaskPacket>::iterator dequeIter = d_->container_low_.begin();
for (; dequeIter != d_->container_low_.end();)
{
if (dequeIter->type_id_ == type_id)
{
++dequeIter;
}
else
{
dequeIter = d_->container_low_.erase(dequeIter);
}
}
}
{
std::unique_lock<std::mutex> locker(d_->lock_high_);
std::deque<BaseUtil::TaskPacket>::iterator dequeIter = d_->container_high_.begin();
for (; dequeIter != d_->container_high_.end();)
{
if (dequeIter->type_id_ == type_id)
{
++dequeIter;
}
else
{
dequeIter = d_->container_high_.erase(dequeIter);
}
}
}
}
uv_loop_t* BaseUtil::TaskLoop::UVLoop()
{
return &d_->thread_loop_;
}
|
0b5ffaca0fef8f4197dbd639a8e137e33d7f0a11
|
c36e0e07b1cb968e34e894598cefec0d7b78f532
|
/c/unrealpkts_generated.h
|
e4830153ed2ba45f88568a23d3cc62540bca21fa
|
[] |
no_license
|
drFerg/ArdanFlatbuffers
|
db045d115739122ca55cf02c6e9969dceefb70a0
|
8fc235e0e763308f72572f572f7efd721bf33fc9
|
refs/heads/master
| 2023-01-11T18:26:13.941426
| 2019-12-14T22:03:06
| 2019-12-14T22:03:06
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 10,199
|
h
|
unrealpkts_generated.h
|
// automatically generated by the FlatBuffers compiler, do not modify
#ifndef FLATBUFFERS_GENERATED_UNREALPKTS_UNREALCOOJAMSG_H_
#define FLATBUFFERS_GENERATED_UNREALPKTS_UNREALCOOJAMSG_H_
#include "flatbuffers/flatbuffers.h"
namespace UnrealCoojaMsg {
struct Vec3;
struct RadioDuty;
struct RadioState;
struct Message;
enum MsgType {
MsgType_SIMSTATE = 1,
MsgType_LED = 2,
MsgType_BEEPER = 3,
MsgType_LOCATION = 4,
MsgType_RADIO = 5,
MsgType_RADIO_STATE = 6,
MsgType_RADIO_DUTY = 7,
MsgType_BUTTON = 8,
MsgType_PIR = 9,
MsgType_FIRE = 10,
MsgType_TEMP = 11,
MsgType_SMOKE = 12,
MsgType_TARGET = 13,
MsgType_TSTAMP = 14,
MsgType_MIN = MsgType_SIMSTATE,
MsgType_MAX = MsgType_TSTAMP
};
inline const char **EnumNamesMsgType() {
static const char *names[] = {
"SIMSTATE",
"LED",
"BEEPER",
"LOCATION",
"RADIO",
"RADIO_STATE",
"RADIO_DUTY",
"BUTTON",
"PIR",
"FIRE",
"TEMP",
"SMOKE",
"TARGET",
"TSTAMP",
nullptr
};
return names;
}
inline const char *EnumNameMsgType(MsgType e) {
const size_t index = static_cast<int>(e) - static_cast<int>(MsgType_SIMSTATE);
return EnumNamesMsgType()[index];
}
enum SimState {
SimState_PAUSE = 0,
SimState_RESUME = 1,
SimState_NORMAL = 2,
SimState_SLOW = 3,
SimState_DOUBLE = 4,
SimState_TRIPLE = 5,
SimState_MIN = SimState_PAUSE,
SimState_MAX = SimState_TRIPLE
};
inline const char **EnumNamesSimState() {
static const char *names[] = {
"PAUSE",
"RESUME",
"NORMAL",
"SLOW",
"DOUBLE",
"TRIPLE",
nullptr
};
return names;
}
inline const char *EnumNameSimState(SimState e) {
const size_t index = static_cast<int>(e);
return EnumNamesSimState()[index];
}
MANUALLY_ALIGNED_STRUCT(4) Vec3 FLATBUFFERS_FINAL_CLASS {
private:
float x_;
float y_;
float z_;
public:
Vec3() {
memset(this, 0, sizeof(Vec3));
}
Vec3(const Vec3 &_o) {
memcpy(this, &_o, sizeof(Vec3));
}
Vec3(float _x, float _y, float _z)
: x_(flatbuffers::EndianScalar(_x)),
y_(flatbuffers::EndianScalar(_y)),
z_(flatbuffers::EndianScalar(_z)) {
}
float x() const {
return flatbuffers::EndianScalar(x_);
}
float y() const {
return flatbuffers::EndianScalar(y_);
}
float z() const {
return flatbuffers::EndianScalar(z_);
}
};
STRUCT_END(Vec3, 12);
MANUALLY_ALIGNED_STRUCT(8) RadioDuty FLATBUFFERS_FINAL_CLASS {
private:
double radioOnRatio_;
double radioTxRatio_;
double radioRxRatio_;
double radioInterferedRatio_;
public:
RadioDuty() {
memset(this, 0, sizeof(RadioDuty));
}
RadioDuty(const RadioDuty &_o) {
memcpy(this, &_o, sizeof(RadioDuty));
}
RadioDuty(double _radioOnRatio, double _radioTxRatio, double _radioRxRatio, double _radioInterferedRatio)
: radioOnRatio_(flatbuffers::EndianScalar(_radioOnRatio)),
radioTxRatio_(flatbuffers::EndianScalar(_radioTxRatio)),
radioRxRatio_(flatbuffers::EndianScalar(_radioRxRatio)),
radioInterferedRatio_(flatbuffers::EndianScalar(_radioInterferedRatio)) {
}
double radioOnRatio() const {
return flatbuffers::EndianScalar(radioOnRatio_);
}
double radioTxRatio() const {
return flatbuffers::EndianScalar(radioTxRatio_);
}
double radioRxRatio() const {
return flatbuffers::EndianScalar(radioRxRatio_);
}
double radioInterferedRatio() const {
return flatbuffers::EndianScalar(radioInterferedRatio_);
}
};
STRUCT_END(RadioDuty, 32);
MANUALLY_ALIGNED_STRUCT(8) RadioState FLATBUFFERS_FINAL_CLASS {
private:
uint8_t radioOn_;
int8_t padding0__; int16_t padding1__; int32_t padding2__;
double signalStrength_;
double outputPower_;
public:
RadioState() {
memset(this, 0, sizeof(RadioState));
}
RadioState(const RadioState &_o) {
memcpy(this, &_o, sizeof(RadioState));
}
RadioState(bool _radioOn, double _signalStrength, double _outputPower)
: radioOn_(flatbuffers::EndianScalar(static_cast<uint8_t>(_radioOn))),
padding0__(0),
padding1__(0),
padding2__(0),
signalStrength_(flatbuffers::EndianScalar(_signalStrength)),
outputPower_(flatbuffers::EndianScalar(_outputPower)) {
(void)padding0__; (void)padding1__; (void)padding2__;
}
bool radioOn() const {
return flatbuffers::EndianScalar(radioOn_) != 0;
}
double signalStrength() const {
return flatbuffers::EndianScalar(signalStrength_);
}
double outputPower() const {
return flatbuffers::EndianScalar(outputPower_);
}
};
STRUCT_END(RadioState, 24);
struct Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
enum {
VT_TYPE = 4,
VT_SIMSTATE = 6,
VT_ID = 8,
VT_LOCATION = 10,
VT_NODE = 12,
VT_RCVD = 14,
VT_LED = 16,
VT_RADIOSTATE = 18,
VT_TARGET = 20,
VT_TSTAMP = 22
};
int32_t type() const {
return GetField<int32_t>(VT_TYPE, 0);
}
int32_t simState() const {
return GetField<int32_t>(VT_SIMSTATE, 0);
}
int32_t id() const {
return GetField<int32_t>(VT_ID, 0);
}
const Vec3 *location() const {
return GetStruct<const Vec3 *>(VT_LOCATION);
}
const flatbuffers::Vector<const RadioDuty *> *node() const {
return GetPointer<const flatbuffers::Vector<const RadioDuty *> *>(VT_NODE);
}
const flatbuffers::Vector<int32_t> *rcvd() const {
return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_RCVD);
}
const flatbuffers::Vector<int32_t> *led() const {
return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_LED);
}
const RadioState *radioState() const {
return GetStruct<const RadioState *>(VT_RADIOSTATE);
}
int32_t target() const {
return GetField<int32_t>(VT_TARGET, 0);
}
int64_t tstamp() const {
return GetField<int64_t>(VT_TSTAMP, 0);
}
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<int32_t>(verifier, VT_TYPE) &&
VerifyField<int32_t>(verifier, VT_SIMSTATE) &&
VerifyField<int32_t>(verifier, VT_ID) &&
VerifyField<Vec3>(verifier, VT_LOCATION) &&
VerifyOffset(verifier, VT_NODE) &&
verifier.Verify(node()) &&
VerifyOffset(verifier, VT_RCVD) &&
verifier.Verify(rcvd()) &&
VerifyOffset(verifier, VT_LED) &&
verifier.Verify(led()) &&
VerifyField<RadioState>(verifier, VT_RADIOSTATE) &&
VerifyField<int32_t>(verifier, VT_TARGET) &&
VerifyField<int64_t>(verifier, VT_TSTAMP) &&
verifier.EndTable();
}
};
struct MessageBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_type(int32_t type) {
fbb_.AddElement<int32_t>(Message::VT_TYPE, type, 0);
}
void add_simState(int32_t simState) {
fbb_.AddElement<int32_t>(Message::VT_SIMSTATE, simState, 0);
}
void add_id(int32_t id) {
fbb_.AddElement<int32_t>(Message::VT_ID, id, 0);
}
void add_location(const Vec3 *location) {
fbb_.AddStruct(Message::VT_LOCATION, location);
}
void add_node(flatbuffers::Offset<flatbuffers::Vector<const RadioDuty *>> node) {
fbb_.AddOffset(Message::VT_NODE, node);
}
void add_rcvd(flatbuffers::Offset<flatbuffers::Vector<int32_t>> rcvd) {
fbb_.AddOffset(Message::VT_RCVD, rcvd);
}
void add_led(flatbuffers::Offset<flatbuffers::Vector<int32_t>> led) {
fbb_.AddOffset(Message::VT_LED, led);
}
void add_radioState(const RadioState *radioState) {
fbb_.AddStruct(Message::VT_RADIOSTATE, radioState);
}
void add_target(int32_t target) {
fbb_.AddElement<int32_t>(Message::VT_TARGET, target, 0);
}
void add_tstamp(int64_t tstamp) {
fbb_.AddElement<int64_t>(Message::VT_TSTAMP, tstamp, 0);
}
MessageBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
}
MessageBuilder &operator=(const MessageBuilder &);
flatbuffers::Offset<Message> Finish() {
const auto end = fbb_.EndTable(start_, 10);
auto o = flatbuffers::Offset<Message>(end);
return o;
}
};
inline flatbuffers::Offset<Message> CreateMessage(
flatbuffers::FlatBufferBuilder &_fbb,
int32_t type = 0,
int32_t simState = 0,
int32_t id = 0,
const Vec3 *location = 0,
flatbuffers::Offset<flatbuffers::Vector<const RadioDuty *>> node = 0,
flatbuffers::Offset<flatbuffers::Vector<int32_t>> rcvd = 0,
flatbuffers::Offset<flatbuffers::Vector<int32_t>> led = 0,
const RadioState *radioState = 0,
int32_t target = 0,
int64_t tstamp = 0) {
MessageBuilder builder_(_fbb);
builder_.add_tstamp(tstamp);
builder_.add_target(target);
builder_.add_radioState(radioState);
builder_.add_led(led);
builder_.add_rcvd(rcvd);
builder_.add_node(node);
builder_.add_location(location);
builder_.add_id(id);
builder_.add_simState(simState);
builder_.add_type(type);
return builder_.Finish();
}
inline flatbuffers::Offset<Message> CreateMessageDirect(
flatbuffers::FlatBufferBuilder &_fbb,
int32_t type = 0,
int32_t simState = 0,
int32_t id = 0,
const Vec3 *location = 0,
const std::vector<const RadioDuty *> *node = nullptr,
const std::vector<int32_t> *rcvd = nullptr,
const std::vector<int32_t> *led = nullptr,
const RadioState *radioState = 0,
int32_t target = 0,
int64_t tstamp = 0) {
return UnrealCoojaMsg::CreateMessage(
_fbb,
type,
simState,
id,
location,
node ? _fbb.CreateVector<const RadioDuty *>(*node) : 0,
rcvd ? _fbb.CreateVector<int32_t>(*rcvd) : 0,
led ? _fbb.CreateVector<int32_t>(*led) : 0,
radioState,
target,
tstamp);
}
inline const UnrealCoojaMsg::Message *GetMessage(const void *buf) {
return flatbuffers::GetRoot<UnrealCoojaMsg::Message>(buf);
}
inline bool VerifyMessageBuffer(
flatbuffers::Verifier &verifier) {
return verifier.VerifyBuffer<UnrealCoojaMsg::Message>(nullptr);
}
inline void FinishMessageBuffer(
flatbuffers::FlatBufferBuilder &fbb,
flatbuffers::Offset<UnrealCoojaMsg::Message> root) {
fbb.Finish(root);
}
} // namespace UnrealCoojaMsg
#endif // FLATBUFFERS_GENERATED_UNREALPKTS_UNREALCOOJAMSG_H_
|
792eb8f3140bb42fde017c6154023572859809c3
|
1dca729b7bde6e6ab56a0e65f34b6498da8bc30a
|
/cse576_sp20_hw1-master/src/Source.cpp
|
479dc4534cb2bc257a86d4b00994778651f72ea5
|
[] |
no_license
|
hua19971997/Computer-vision
|
22818c5551674693a94fe3ed6af2365d3bf3439b
|
cf52837ff1ebd26e81a79d5cf39e8c99bfaebc41
|
refs/heads/master
| 2022-11-15T10:29:55.332182
| 2020-07-09T07:06:26
| 2020-07-09T07:06:26
| 275,074,155
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 397
|
cpp
|
Source.cpp
|
#include <string>
#include "image.h"
using namespace std;
int main(int argc, char** argv)
{
Image im = load_image("C:/Users/24078/Desktop/576Cv/cse576_sp20_hw1-master/data/dog.jpg");
Image gray = rgb_to_grayscale(im);
Image g = load_image("C:/Users/24078/Desktop/576Cv/cse576_sp20_hw1-master/output/pixel_modifying_output");
TEST(same_image(gray, g));
return 0;
}
|
1e36b5d594ad41bfb7a12212f00f51fdd1621ca0
|
d7e7b9f295454b916e3f47ba32c1d4558c0bcd4b
|
/IsolationChamber.ino
|
9334e83604fbeba7da21a467a895ca5270764b6a
|
[] |
no_license
|
Advik007/Luna_Iter
|
c116182ca537285d19c55a7fd7a3de7f719dc446
|
bc644b9a695e1c40f97eecdf26e05856c4bb2bac
|
refs/heads/master
| 2020-09-14T13:38:03.837422
| 2019-12-03T04:49:34
| 2019-12-03T04:49:34
| 223,143,111
| 0
| 0
| null | 2019-12-17T13:37:36
| 2019-11-21T09:59:53
|
C++
|
UTF-8
|
C++
| false
| false
| 2,834
|
ino
|
IsolationChamber.ino
|
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <K30_I2C.h>
const int O2Sensor = A0; //Attachment of Grove - Gas Sensor (O2) to A0
const float VRefer = 3.3; //O2 Sensor Voltage - Reference
float temp; //Temperature - Variable
int temperaturePin = A3; //Temperature Sensor (LM-35) to A3
int co2 = 0; //CO2 - Variable
int CO2Error = 1; //CO2 - Reference
int DCMotorPin= 3; //DC Motor for Ventilation Area Door - intake of CO2 into the chamber using KOH regarded in Deliverable 2
double starttime,starttimec,endtime,endtimec; //MILLIS Function Variables
K30_I2C k30_i2c = K30_I2C(0x68); //Initalisation of CO2 Sensor @ Address - 0x68
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); //Positions of placement of LCD Screen @ Address - 0x27
void setup() {
pinMode(DCMotorPin, OUTPUT);
Serial.begin(9600);
}
void CO2Testing(){
CO2Error=k30_i2c.readCO2(co2); //Data from CO2 Sensor
if(CO2Error == 0){
lcd.setCursor(0,2); //Column 0, Row 2
lcd.print("CO2 Content: ");
lcd.print(co2);
delay(1000); //Sleep for 1 seconds
}
}
float readO2Vout() //Regardless to code, processing for O2 Sensor Data
{
long sum = 0;
for(int i=0; i<32; i++)
{
sum += analogRead(O2Sensor);
}
sum >>= 5;
float MeasuredVout = sum * (VRefer / 1023.0);
return MeasuredVout;
}
float O2Content()
{
// Voltage samples are with reference to 3.3V
float MeasuredVout = readO2Vout();
//when its output voltage is 2.0V,
float Concentration = MeasuredVout * 0.21 / 2.0;
float Concentration_Percentage=Concentration*100;
//Regardless - display
lcd.setCursor(0,3); //Column 0, Row 3
lcd.print("O2 Content: ");
lcd.print(Concentration_Percentage);
delay(1000); //Sleep for 1 seconds
}
void TemperatureSet(){
temp = analogRead(temperaturePin); //Reading of Data
temp = temp * 0.48828125; // Conversion of analog volt to its temperature equivalent
lcd.setCursor(0,4); //Column 0, Row 4
lcd.print("Temperature :");
lcd.print(temp);
lcd.print("*C");
delay(1000); //Sleep for 1 seconds
}
void loop() {
lcd.clear(); //Clearing LCD once accomplished
//Implementation and Calling of Classes
CO2Testing();
O2Content();
TemperatureSet();
if(co2<400){ //Test that if CO2 Content is less than 400ppm, open Ventilation Door (KOH)- connected to a Motor to open it up!
//estimate that it takes 100 turns to open the door
//DC Motor is 150 RPM
starttime = millis();
while ((millis() - starttime) <=(40000)) // Do this loop for up to 40sec
{
int DCspeed = 150; //ClockwiseRPM
analogWrite(DCMotorPin, DCspeed);
}
delay(1000);
if(co2>=400){
starttimec=millis();
while((millis()-starttimec)<=40000){ //Do for 40sec
int DCSpeed2=-150; //AnticlockwiseRPM
analogWrite(DCMotorPin, DCSpeed2);
}
}
}
}
|
cda89baad92a0aa37219be322d3d984b62c5b68d
|
6729e41cb16603032de731c434fa203924105d41
|
/sudoku_solver.cpp
|
9f75f39247d2f00c7781f61645457cbb7a825c7e
|
[] |
no_license
|
hemantgarg923/SudokuSolver
|
01e04dca7872954968a952ebd817fff5a56fc867
|
217727c5a6b4963e963b1e05aae7db5fa5b139fb
|
refs/heads/master
| 2023-04-16T09:58:05.435102
| 2021-04-21T07:12:13
| 2021-04-21T07:12:13
| 360,067,929
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,460
|
cpp
|
sudoku_solver.cpp
|
#include<iostream>
using namespace std;
// check if any cell is unassigned
bool unassignedCell(int grid[9][9], int& row, int& col){
for(row=0; row<9; row++){
for(col=0; col<9; col++){
if(grid[row][col]==0){
return true;
}
}
}
return false;
}
// check if number is already used in column
bool usedInCol(int grid[9][9], int col, int i){
for(int rows=0; rows<9; rows++){
if(grid[rows][col]==i){
return false;
}
}
return false;
}
// check if number is already used in row
bool usedInRow(int grid[9][9], int row, int i){
for(int cols=0; cols<9; cols++){
if(grid[row][cols]==i){
return true;
}
}
return false;
}
// check if number is already used in box
bool usedInBox(int grid[9][9], int boxRow, int boxCol, int i){
for(int row=0; row<3; row++){
for(int col=0; col<3; col++){
if(grid[row+boxRow][col+boxCol]==i){
return true;
}
}
}
return false;
}
bool isSafe(int grid[9][9], int row, int col, int i){
if(!usedInCol(grid, col, i) && !usedInRow(grid, row, i) && !usedInBox(grid, row-(row%3), col-(col%3), i) && grid[row][col]==0){
return true;
}
return false;
}
bool solve(int grid[9][9]){
int row, col;
if(!unassignedCell(grid, row, col)){
return true;
}
for(int i=1; i<=9; i++){
if(isSafe(grid, row, col, i)){
grid[row][col] = i;
if(solve(grid)){
return true;
}
grid[row][col] = 0;
}
}
return false;
}
void printGrid(int grid[9][9]){
for(int i=0; i<9; i++){
for(int j=0; j<9; j++){
cout<<grid[i][j]<<" ";
}
cout<<endl;
}
}
int main(){
int grid[9][9] = { { 3, 0, 6, 5, 0, 8, 4, 0, 0 },
{ 5, 2, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 8, 7, 0, 0, 0, 0, 3, 1 },
{ 0, 0, 3, 0, 1, 0, 0, 8, 0 },
{ 9, 0, 0, 8, 6, 3, 0, 0, 5 },
{ 0, 5, 0, 0, 9, 0, 6, 0, 0 },
{ 1, 3, 0, 0, 0, 0, 2, 5, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 7, 4 },
{ 0, 0, 5, 2, 0, 6, 3, 0, 0 } };
// cout<<"Enter numbers";
// for(int i=0; i<9; i++){
// for(int j=0; j<9; j++){
// cin>>grid[i][j];
// }
// }
if(solve(grid)==true){
printGrid(grid);
}
else{
cout<<"Solution Not possible";
}
return 0;
}
|
baa89d4cb072fc7734087ecf9dbd2abee920482d
|
4172a3e2199b324781b0ca5e9c7a35e4f3418bca
|
/MP6/sources/student/running_processes/process_1.cpp
|
f235e6f98ea6242b7ed83b02a9c1ff66516fcfe6
|
[] |
no_license
|
astro-nat/Random_Project_3_1_3
|
0707bdb3e549e755224590477652a1c641fce40d
|
8adf841567c66b7b773337dd3e6d62e062769a51
|
refs/heads/master
| 2021-01-20T04:09:44.962564
| 2017-01-12T20:17:24
| 2017-01-12T20:17:24
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,772
|
cpp
|
process_1.cpp
|
/* --------------------------------------------------------------------------- */
/* Developer: Andrew Kirfman, Margaret Baxter */
/* Project: CSCE-313 Machine Problem #1 */
/* */
/* File: ./MP6/cpu_bound_processes/cpu_bound_2.cpp */
/* --------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------- */
/* Standard Library Includes */
/* --------------------------------------------------------------------------- */
#include<iostream>
#include<sys/types.h>
#include<signal.h>
#include<unistd.h>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<string>
#include<cstdlib>
#include<vector>
/* Sieve of Erastosthenes is a fast algorithm for calculating prime numbers */
void runEratosthenesSieve(int upperBound)
{
int count = 1;
std::vector<bool> arr;
for(int i=0; i<upperBound; i++)
{
arr.push_back(true);
}
for(int i=2; i<upperBound - 1; i++)
{
if(count == upperBound)
{
break;
}
// Mark all multiples
for(int j=2; (j*i) < upperBound-1; j++)
{
arr[i*j] = false;
}
// Find next prime
for(int k=(i + 1); k<upperBound-1; k++)
{
if(arr[k])
{
i=k;
++count;
break;
}
}
}
}
int main()
{
kill(getpid(), SIGSTOP);
int prime_max = 2 << 24;
runEratosthenesSieve(prime_max);
exit(0);
}
|
07b20b96a18ed57d5b3ba1589d101a99f082760b
|
401c85904267e7b8f398ba843b31d708856e015f
|
/benchmark/demo_benchmark.cpp
|
c8984d333677f29c9b68c8bc5b80ebfab52c6c75
|
[
"MIT"
] |
permissive
|
puumbaa/semester-work-graham-scan
|
56a345f7d083870180c786f15b1b97abbd9f9018
|
da4cc0bf94ce135a0a24e576c29576279e960796
|
refs/heads/main
| 2023-04-11T17:11:03.508276
| 2021-05-18T03:52:31
| 2021-05-18T03:52:31
| 365,040,538
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,398
|
cpp
|
demo_benchmark.cpp
|
#include <fstream> // ifstream
#include <iostream> // cout
#include <string> // string, stoi
#include <string_view> // string_view
#include <chrono> // high_resolution_clock, duration_cast, nanoseconds
#include <vector>
#include <graham_scan.hpp>
#include "point.hpp"
using namespace std;
// абсолютный путь до набора данных и папки проекта
static constexpr auto kDatasetPath = string_view{PROJECT_DATASET_DIR};
static constexpr auto kProjectPath = string_view{PROJECT_SOURCE_DIR};
int main() {
// работа с набором данных
const auto path = string(kDatasetPath);
cout << "Path to the 'dataset/' folder: " << path << endl;
auto input_file = ifstream(path);
string line;
string line_item;
std::vector<point> testVector;
int num = 0;
for (int i = 1; i < 8; ++i) {
switch (i) {
case 1: num = 100; break;
case 2: num = 1000; break;
case 3: num = 5000; break;
case 4: num = 10000; break;
case 5: num = 50000; break;
case 6: num = 100000; break;
case 7: num = 500000; break;
}
input_file = ifstream(path + "\\dataset" + to_string(num) + ".csv");
cout << "dataset: " + to_string(i) << endl;
// Парсинг строеки и заполнение входного вектора
while (getline(input_file, line, ';')) {
size_t position = 0;
string pair_item;
auto *new_point = new point(); // Следующая точка
position = line.find(',');
pair_item = line.substr(0, position);
new_point->setX(stoi(pair_item)); // спарсил координаты Х
line.erase(0, position + 1);
new_point->setY(stoi(line)); // спарсил координаты Y
testVector.push_back(*new_point);
}
for (int j = 1; j < 11; ++j) {
const auto time_point_before = chrono::steady_clock::now();
itis::get_convex_hull(testVector);
const auto time_point_after = chrono::steady_clock::now();
// переводим время в наносекунды
const auto time_diff = time_point_after - time_point_before;
const auto time_elapsed_ns = chrono::duration_cast<chrono::nanoseconds>(time_diff).count();
cout << to_string(j) + ") Time (ms): " << time_elapsed_ns / 1000000 << '\n';
}
}
testVector.clear();
return 0;
}
|
72b828eec1049853348b0a4e4b0a123520d3f8f9
|
dddf5597142861a38d3fe4bb3f3886e46ae7119e
|
/autoware_map/include/autoware_map/util.h
|
48387062841078782cab0ee539b691addd2c8ef7
|
[
"Apache-2.0"
] |
permissive
|
neophack/utilities
|
9bf7ca0011b2462cce53f8c57fff4b9f6a0c32bc
|
a6ce6d7c1b407e555955491874d66e7ef263d52d
|
refs/heads/master
| 2023-09-05T07:06:30.871140
| 2019-06-27T01:22:27
| 2019-06-27T01:22:27
| 415,839,489
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,959
|
h
|
util.h
|
/*
* Copyright 2019 Autoware Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __AUTOWARE_MAP_UTIL_H__
#define __AUTOWARE_MAP_UTIL_H__
#include <autoware_map/map_handler.hpp>
#include <geometry_msgs/Point.h>
#include <geometry_msgs/Quaternion.h>
#ifndef M_PI
#define M_PI 3.14159265358979
#endif
inline double degreeToRadian(double x) {return x * M_PI / 180.0;}
autoware_map_msgs::Point getPointFromWaypointId(int waypoint_id, autoware_map::AutowareMapHandler autoware_map);
geometry_msgs::Point convertPointToGeomPoint(const autoware_map_msgs::Point& autoware_point);
geometry_msgs::Quaternion convertAngleToGeomQuaternion(const double horizontal_angle, const double vertical_angle);
bool isJapaneseCoordinate(int epsg);
//
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::Lane& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::LaneAttributeRelation& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::LaneRelation& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::LaneSignalLightRelation& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::LaneChangeRelation& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::OppositeLaneRelation& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::Point& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::Area& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::Signal& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::SignalLight& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::Wayarea& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::Waypoint& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::WaypointLaneRelation& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::WaypointRelation& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map_msgs::WaypointSignalRelation& obj);
std::ostream& operator<<(std::ostream& os, const autoware_map::Category& cat);
//
std::istream& operator>>(std::istream& os, autoware_map_msgs::Lane& obj);
std::istream& operator>>(std::istream& os, autoware_map_msgs::LaneAttributeRelation& obj);
std::istream& operator>>(std::istream& os, autoware_map_msgs::LaneRelation& obj);
std::istream& operator>>(std::istream& os, autoware_map_msgs::LaneSignalLightRelation& obj);
std::istream& operator>>(std::istream& os, autoware_map_msgs::LaneChangeRelation& obj);
std::istream& operator>>(std::istream& os, autoware_map_msgs::OppositeLaneRelation& obj);
std::istream& operator>>(std::istream& os, autoware_map_msgs::Point& obj);
std::istream& operator>>(std::istream& os, autoware_map_msgs::Area& obj);
std::istream& operator>>(std::istream& os, autoware_map_msgs::Signal& obj);
std::istream& operator>>(std::istream& os, autoware_map_msgs::SignalLight& obj);
std::istream& operator>>(std::istream& os, autoware_map_msgs::Wayarea& obj);
std::istream& operator>>(std::istream& os, autoware_map_msgs::Waypoint& obj);
std::istream& operator>>(std::istream& os, autoware_map_msgs::WaypointLaneRelation& obj);
std::istream& operator>>(std::istream& os, autoware_map_msgs::WaypointSignalRelation& obj);
std::istream& operator>>(std::istream& os, autoware_map_msgs::WaypointRelation& obj);
#endif
|
7dac8dfc56bfa59fea21c91101438a40817a696a
|
dc0ec6048d18b55956b143ea1b6511f066b26bb3
|
/OpenGLTest/source/renderer.cpp
|
17d9e751c8fc2609e1caab968c07bc69db8d9bb8
|
[
"Apache-2.0"
] |
permissive
|
urieken/Galen
|
b042da7ba32550570b27ad0966ed1fb8f43fd2fb
|
61fb306eace45af136456e610b02608822174aa8
|
refs/heads/master
| 2020-04-06T13:26:27.212163
| 2018-12-13T19:54:40
| 2018-12-13T19:54:40
| 157,500,206
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 999
|
cpp
|
renderer.cpp
|
#include "renderer.h"
Renderer::Renderer()
: m_drawingMode{GL_TRIANGLES}
{
}
Renderer::~Renderer()
{
}
const unsigned int Renderer::GetDrawingMode() const
{
return m_drawingMode;
}
void Renderer::SetDrawingMode(const unsigned int drawingMode)
{
m_drawingMode = drawingMode;
}
void Renderer::SetPolygonMode(unsigned int face, unsigned int mode)
{
GLCall(::glPolygonMode(face, mode));
}
void Renderer::SetClearColor(float r, float g, float b, float a)
{
GLCall(::glClearColor(r, g, b, a));
}
void Renderer::Clear() const
{
GLCall(::glClear(GL_COLOR_BUFFER_BIT));
}
void Renderer::Draw(const VertexArray& va, const IndexBuffer& ib, const ShaderProgram& shader) const
{
va.Bind();
ib.Bind();
shader.Bind();
GLCall(::glDrawElements(m_drawingMode, ib.GetCount(), GL_UNSIGNED_INT, nullptr));
}
void Renderer::Draw(const VertexArray& va, const VertexBuffer& vb, ShaderProgram& shader) const
{
va.Bind();
shader.Bind();
GLCall(::glDrawArrays(m_drawingMode, 0, vb.GetVertexCount()));
}
|
ce4bada44d32c760072fb35227dadcae263af482
|
a1ce1c416e8cd75b51fc0a05e8483dfbc8eab79e
|
/Engine/source/T3D/tsPathShape.h
|
942fae468d654592534bddc49f206544817c392f
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
wwhitehead/OmniEngine.Net
|
238da56998ac5473c3d3b9f0da705c7c08c0ee17
|
b52de3ca5e15a18a6320ced6cbabc41d6fa6be86
|
refs/heads/master
| 2020-12-26T04:16:46.475080
| 2015-06-18T00:16:45
| 2015-06-18T00:16:45
| 34,730,441
| 0
| 0
| null | 2015-04-28T12:57:08
| 2015-04-28T12:57:08
| null |
UTF-8
|
C++
| false
| false
| 4,537
|
h
|
tsPathShape.h
|
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
// Much of this code was taken directly from the PathShape
// resource: http://www.garagegames.com/community/resource/view/20385/1
// With additional improvements by Azaezel:
// http://www.garagegames.com/community/forums/viewthread/137195
//-----------------------------------------------------------------------------
#ifndef _TSPATHSHAPE_H_
#define _TSPATHSHAPE_H_
#ifndef _TSDYNAMIC_H_
#include "tsDynamic.h"
#endif
#ifndef _CAMERASPLINE_H_
#include "T3D/cameraSpline.h"
#endif
#ifndef _SIMPATH_H_
#include "scene/simPath.h"
#endif
/// A simple pathed shape with optional ambient animation.
class TSPathShape : public TSDynamic
{
private:
typedef TSDynamic Parent;
public:
/// The movement states
enum MoveState {
Forward,
Backward,
Stop
};
MoveState mState;
protected:
enum MaskBits
{
WindowMask = Parent::NextFreeMask << 0,
PositionMask = Parent::NextFreeMask << 1,
TargetMask = Parent::NextFreeMask << 2,
StateMask = Parent::NextFreeMask << 3,
NextFreeMask = Parent::NextFreeMask << 4
};
private:
struct StateDelta {
F32 time;
F32 timeVec;
MoveState state;
};
StateDelta delta;
enum Constants {
NodeWindow = 128, // Maximum number of active nodes
MoveStateBits = 2 // 2 bits for 3 states
};
CameraSpline mSpline;
S32 mNodeBase;
S32 mNodeCount;
F32 mPosition;
F32 mTarget;
bool mTargetSet;
bool mLooping;
void interpolateMat(F32 pos, MatrixF* mat);
void advancePosition(S32 ms);
// The client must be synched to the server so they both represent the shape at the same
// location, but updating too frequently makes the shape jitter due to varying transmission
// time. This sets the number of ticks between position updates.
static U32 mUpdateTics;
U32 mUpdateTickCount;
protected:
bool onAdd();
void onRemove();
virtual void onStaticModified(const char* slotName, const char*newValue = NULL);
// ProcessObject
virtual void processTick( const Move *move );
virtual void interpolateTick( F32 delta );
virtual bool _getShouldTick();
public:
TSPathShape();
~TSPathShape();
DECLARE_CONOBJECT(TSPathShape);
DECLARE_CALLBACK(void, onAdd, () );
DECLARE_CALLBACK(void, onPathChange, () );
DECLARE_CALLBACK(void, onNode, (S32 node));
DECLARE_CALLBACK(void, onTargetReached, (F32 val));
static void initPersistFields();
// NetObject
U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream );
void unpackUpdate( NetConnection *conn, BitStream *stream );
// Path setup
SimObjectRef< SimPath::Path > mPath;
bool reset(F32 speed, bool makeKnot);
void pushFront(CameraSpline::Knot *knot);
void pushBack(CameraSpline::Knot *knot);
void popFront();
// Movement control
void setPathPosition(F32 pos);
F32 getPathPosition(void) { return mPosition; }
void setTarget(F32 pos);
void setMoveState(MoveState s);
MoveState getMoveState() { return mState; }
void setLooping(bool isLooping);
bool getLooping() { return mLooping; }
S32 getNodeCount() { return mNodeCount; }
};
typedef TSPathShape::MoveState PathShapeState;
DefineEnumType( PathShapeState );
#endif // _TSPATHSHAPE_H_
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.